summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoazin Khatti <moazinkhatri@gmail.com>2019-06-20 22:59:36 +0500
committerMoazin Khatti <moazinkhatri@gmail.com>2019-07-11 14:09:43 +0500
commite676c86e928c1a1a08d7a630d47f70f5ce73fb32 (patch)
treeae3d13f64e546b598cdea327b34947b1625f01d4
parent5381d51956d688d405f1ed8df1a0a9b7e7d20cc6 (diff)
downloadfreetype2-e676c86e928c1a1a08d7a630d47f70f5ce73fb32.tar.gz
Reverts the changes made in the structure of `TT_GlyphSlot'
-rw-r--r--include/freetype/internal/cffotypes.h5
-rw-r--r--include/freetype/internal/tttypes.h40
-rw-r--r--src/cff/cffgload.c15
-rw-r--r--src/truetype/ttgload.c74
-rw-r--r--src/truetype/ttobjs.h15
5 files changed, 51 insertions, 98 deletions
diff --git a/include/freetype/internal/cffotypes.h b/include/freetype/internal/cffotypes.h
index 73cb159e0..b26893eab 100644
--- a/include/freetype/internal/cffotypes.h
+++ b/include/freetype/internal/cffotypes.h
@@ -61,11 +61,6 @@ FT_BEGIN_HEADER
{
FT_GlyphSlotRec root;
- /* (OT-SVG) Added these here so that CFFGlyphSlot can be cast to
- TT_GlyphSlot */
- FT_Byte* svg_document;
- FT_ULong svg_document_length;
-
FT_Bool hint;
FT_Bool scaled;
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index 3539e1865..42a921fe7 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -967,8 +967,8 @@ FT_BEGIN_HEADER
* This structure/class is defined here because it is common to the
* following formats: TTF, OpenType-TT, and OpenType-CFF.
*
- * Note, however, that the class TT_Size is not shared between font driver,
- * and is thus defined in `ttobjs.h`.
+ * Note, however, that the classes TT_Size and TT_GlyphSlot are not shared
+ * between font drivers, and are thus defined in `ttobjs.h`.
*
*/
@@ -988,42 +988,6 @@ FT_BEGIN_HEADER
*/
typedef struct TT_FaceRec_* TT_Face;
- /**************************************************************************
- *
- * @type:
- * TT_GlyphSlotRec_
- *
- * @description:
- * A glyph slot that inherits from FT_GlyphSlotRec_ but adds more fields
- *
- * @fields:
- * root ::
- * Inherits this structure from FT_GlyphSlotRec. See note below.
- *
- * svg_document ::
- * A pointer to the SVG Document stream under interest. The stream
- * will be in plain text.
- *
- * svg_document_length ::
- * The length of the `svg_document' stream.
- *
- * @note:
- * This structure has been created to accomodate the needs of OT-SVG
- * rendering. It inherits from FT_GlyphSlotRect. So that `TT_GlyphSlot'
- * can be casted to `FT_GlyphSlot' and behave that way too. It's defined
- * here because it is common to OpenType-TTF and OpenType-CFF.
- */
- typedef struct TT_GlyphSlotRec_
- {
- FT_GlyphSlotRec root;
- FT_Byte* svg_document;
- FT_ULong svg_document_length;
- } TT_GlyphSlotRec;
-
-
- /* A handle to a TrueType glyph slot object. */
- typedef struct TT_GlyphSlotRec_* TT_GlyphSlot;
-
/* a function type used for the truetype bytecode interpreter hooks */
typedef FT_Error
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 95e2fa6c9..36aa7d1b9 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -347,21 +347,6 @@
if ( load_flags & FT_LOAD_SBITS_ONLY )
return FT_THROW( Invalid_Argument );
- /* check for OT-SVG */
- if ( ( load_flags & FT_LOAD_COLOR ) &&
- ( ((TT_Face)glyph->root.face)->svg ) )
- {
- SFNT_Service sfnt = (SFNT_Service)(((TT_Face)glyph->root.face)->sfnt);
- error = sfnt->load_svg_doc( &(glyph->root), glyph_index );
- if( error == FT_Err_Ok )
- {
- glyph->root.format = FT_GLYPH_FORMAT_SVG;
- return error;
- }
- }
-
- /* OpenType SVG Support End */
-
/* if we have a CID subfont, use its matrix (which has already */
/* been multiplied with the root matrix) */
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index ac6613e08..2aafc9a63 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -2204,12 +2204,7 @@
FT_BBox bbox;
FT_Fixed y_scale;
-
- /* TODO: (OT-SVG) Temporary hack to accomodate the change
- * in the `TT_GlyphSlot' made. Rewrite properly
- */
- TT_GlyphSlot glyph_ = (TT_GlyphSlot)loader->glyph;
- FT_GlyphSlot glyph = (FT_GlyphSlot)glyph_;
+ TT_GlyphSlot glyph = loader->glyph;
TT_Size size = loader->size;
@@ -2396,10 +2391,8 @@
FT_Error error;
TT_SBit_MetricsRec sbit_metrics;
- /* (OT-SVG) face assignment changed to accomodate the change in
- * the structure of TT_GlyphSlot
- */
- face = (TT_Face)(glyph->root.face);
+
+ face = (TT_Face)glyph->face;
sfnt = (SFNT_Service)face->sfnt;
stream = face->root.stream;
@@ -2408,39 +2401,35 @@
glyph_index,
(FT_UInt)load_flags,
stream,
- &(glyph->root.bitmap),
+ &glyph->bitmap,
&sbit_metrics );
- /* TODO: (OT-SVG) So many `glyph->root' look ugly. Maybe create a new variable
- * to make this look good.
- */
-
if ( !error )
{
- (glyph->root).outline.n_points = 0;
- (glyph->root).outline.n_contours = 0;
+ glyph->outline.n_points = 0;
+ glyph->outline.n_contours = 0;
- (glyph->root).metrics.width = (FT_Pos)sbit_metrics.width * 64;
- (glyph->root).metrics.height = (FT_Pos)sbit_metrics.height * 64;
+ glyph->metrics.width = (FT_Pos)sbit_metrics.width * 64;
+ glyph->metrics.height = (FT_Pos)sbit_metrics.height * 64;
- (glyph->root).metrics.horiBearingX = (FT_Pos)sbit_metrics.horiBearingX * 64;
- (glyph->root).metrics.horiBearingY = (FT_Pos)sbit_metrics.horiBearingY * 64;
- (glyph->root).metrics.horiAdvance = (FT_Pos)sbit_metrics.horiAdvance * 64;
+ glyph->metrics.horiBearingX = (FT_Pos)sbit_metrics.horiBearingX * 64;
+ glyph->metrics.horiBearingY = (FT_Pos)sbit_metrics.horiBearingY * 64;
+ glyph->metrics.horiAdvance = (FT_Pos)sbit_metrics.horiAdvance * 64;
- (glyph->root).metrics.vertBearingX = (FT_Pos)sbit_metrics.vertBearingX * 64;
- (glyph->root).metrics.vertBearingY = (FT_Pos)sbit_metrics.vertBearingY * 64;
- (glyph->root).metrics.vertAdvance = (FT_Pos)sbit_metrics.vertAdvance * 64;
+ glyph->metrics.vertBearingX = (FT_Pos)sbit_metrics.vertBearingX * 64;
+ glyph->metrics.vertBearingY = (FT_Pos)sbit_metrics.vertBearingY * 64;
+ glyph->metrics.vertAdvance = (FT_Pos)sbit_metrics.vertAdvance * 64;
- (glyph->root).format = FT_GLYPH_FORMAT_BITMAP;
+ glyph->format = FT_GLYPH_FORMAT_BITMAP;
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
- (glyph->root).bitmap_left = sbit_metrics.vertBearingX;
- (glyph->root).bitmap_top = sbit_metrics.vertBearingY;
+ glyph->bitmap_left = sbit_metrics.vertBearingX;
+ glyph->bitmap_top = sbit_metrics.vertBearingY;
}
else
{
- (glyph->root).bitmap_left = sbit_metrics.horiBearingX;
- (glyph->root).bitmap_top = sbit_metrics.horiBearingY;
+ glyph->bitmap_left = sbit_metrics.horiBearingX;
+ glyph->bitmap_top = sbit_metrics.horiBearingY;
}
}
@@ -2449,6 +2438,7 @@
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
+
static FT_Error
tt_loader_init( TT_Loader loader,
TT_Size size,
@@ -2464,12 +2454,12 @@
FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
#if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \
defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( (TT_Face)(glyph->root).face );
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( (TT_Face)glyph->face );
#endif
#endif
- face = (TT_Face)(glyph->root.face);
+ face = (TT_Face)glyph->face;
stream = face->root.stream;
FT_ZERO( loader );
@@ -2721,7 +2711,7 @@
/* get face's glyph loader */
if ( !glyf_table_only )
{
- FT_GlyphLoader gloader = (glyph->root).internal->loader;
+ FT_GlyphLoader gloader = glyph->internal->loader;
FT_GlyphLoader_Rewind( gloader );
@@ -2785,7 +2775,7 @@
*/
FT_LOCAL_DEF( FT_Error )
TT_Load_Glyph( TT_Size size,
- TT_GlyphSlot glyph_,
+ TT_GlyphSlot glyph,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
@@ -2793,9 +2783,6 @@
TT_LoaderRec loader;
SFNT_Service sfnt;
- /* TODO: (OT-SVG) maybe find a proper way to do this */
- FT_GlyphSlot glyph = (FT_GlyphSlot)glyph_;
-
FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -2809,7 +2796,7 @@
FT_Fixed y_scale = size->root.metrics.y_scale;
- error = load_sbit_image( size, glyph_, glyph_index, load_flags );
+ error = load_sbit_image( size, glyph, glyph_index, load_flags );
if ( FT_ERR_EQ( error, Missing_Bitmap ) )
{
/* the bitmap strike is incomplete and misses the requested glyph; */
@@ -2876,7 +2863,7 @@
if ( FT_IS_SCALABLE( glyph->face ) )
{
/* for the bbox we need the header only */
- (void)tt_loader_init( &loader, size, glyph_, load_flags, TRUE );
+ (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
(void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
tt_loader_done( &loader );
glyph->linearHoriAdvance = loader.linear;
@@ -2898,6 +2885,13 @@
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
+ /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
+ if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
+ {
+ error = FT_THROW( Invalid_Size_Handle );
+ goto Exit;
+ }
+
/* check for OT-SVG */
if ( ( load_flags & FT_LOAD_COLOR ) && ( ((TT_Face)glyph->face)->svg ) )
{
@@ -2916,7 +2910,7 @@
goto Exit;
}
- error = tt_loader_init( &loader, size, glyph_, load_flags, FALSE );
+ error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
if ( error )
goto Exit;
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index d131a9a86..9fc654d5d 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -41,6 +41,21 @@ FT_BEGIN_HEADER
/**************************************************************************
*
+ * @Type:
+ * TT_GlyphSlot
+ *
+ * @Description:
+ * A handle to a TrueType glyph slot object.
+ *
+ * @Note:
+ * This is a direct typedef of FT_GlyphSlot, as there is nothing
+ * specific about the TrueType glyph slot.
+ */
+ typedef FT_GlyphSlot TT_GlyphSlot;
+
+
+ /**************************************************************************
+ *
* @Struct:
* TT_GraphicsState
*