summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/truetype/ttgload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/truetype/ttgload.c')
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgload.c120
1 files changed, 83 insertions, 37 deletions
diff --git a/src/3rdparty/freetype/src/truetype/ttgload.c b/src/3rdparty/freetype/src/truetype/ttgload.c
index f6d6f9fcd..06e9ccd1d 100644
--- a/src/3rdparty/freetype/src/truetype/ttgload.c
+++ b/src/3rdparty/freetype/src/truetype/ttgload.c
@@ -69,12 +69,12 @@
/* `check' is true, take care of monospaced fonts by returning the */
/* advance width maximum. */
/* */
- static void
- Get_HMetrics( TT_Face face,
- FT_UInt idx,
- FT_Bool check,
- FT_Short* lsb,
- FT_UShort* aw )
+ FT_LOCAL_DEF(void)
+ TT_Get_HMetrics( TT_Face face,
+ FT_UInt idx,
+ FT_Bool check,
+ FT_Short* lsb,
+ FT_UShort* aw )
{
( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
@@ -96,12 +96,12 @@
/* The monospace `check' is probably not meaningful here, but we leave */
/* it in for a consistent interface. */
/* */
- static void
- Get_VMetrics( TT_Face face,
- FT_UInt idx,
- FT_Bool check,
- FT_Short* tsb,
- FT_UShort* ah )
+ FT_LOCAL_DEF(void)
+ TT_Get_VMetrics( TT_Face face,
+ FT_UInt idx,
+ FT_Bool check,
+ FT_Short* tsb,
+ FT_UShort* ah )
{
FT_UNUSED( check );
@@ -382,8 +382,8 @@
for ( ; vec < vec_limit; vec++, flag++ )
{
- FT_Pos y = 0;
- FT_Byte f = *flag;
+ FT_Pos y = 0;
+ FT_Byte f = *flag;
if ( f & 2 )
@@ -405,7 +405,8 @@
x += y;
vec->x = x;
- *flag = f & ~( 2 | 16 );
+ /* the cast is for stupid compilers */
+ *flag = (FT_Byte)( f & ~( 2 | 16 ) );
}
/* reading the Y coordinates */
@@ -417,8 +418,8 @@
for ( ; vec < vec_limit; vec++, flag++ )
{
- FT_Pos y = 0;
- FT_Byte f = *flag;
+ FT_Pos y = 0;
+ FT_Byte f = *flag;
if ( f & 4 )
@@ -440,7 +441,8 @@
x += y;
vec->y = x;
- *flag = f & FT_CURVE_TAG_ON;
+ /* the cast is for stupid compilers */
+ *flag = (FT_Byte)( f & FT_CURVE_TAG_ON );
}
outline->n_points = (FT_UShort)n_points;
@@ -557,10 +559,10 @@
FT_Stream stream = loader->stream;
- /* we must undo the FT_FRAME_ENTER in order to point to the */
- /* composite instructions, if we find some. */
- /* we will process them later... */
- /* */
+ /* we must undo the FT_FRAME_ENTER in order to point */
+ /* to the composite instructions, if we find some. */
+ /* We will process them later. */
+ /* */
loader->ins_pos = (FT_ULong)( FT_STREAM_POS() +
p - limit );
}
@@ -1143,16 +1145,16 @@
FT_UShort advance_width = 0, advance_height = 0;
- Get_HMetrics( face, glyph_index,
- (FT_Bool)!( loader->load_flags &
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
- &left_bearing,
- &advance_width );
- Get_VMetrics( face, glyph_index,
- (FT_Bool)!( loader->load_flags &
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
- &top_bearing,
- &advance_height );
+ TT_Get_HMetrics( face, glyph_index,
+ (FT_Bool)!( loader->load_flags &
+ FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
+ &left_bearing,
+ &advance_width );
+ TT_Get_VMetrics( face, glyph_index,
+ (FT_Bool)!( loader->load_flags &
+ FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ),
+ &top_bearing,
+ &advance_height );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -1243,6 +1245,13 @@
if ( loader->byte_len > 0 )
{
+ if ( !loader->glyf_offset )
+ {
+ FT_TRACE2(( "no `glyf' table but non-zero `loca' entry!\n" ));
+ error = TT_Err_Invalid_Table;
+ goto Exit;
+ }
+
error = face->access_glyph_frame( loader, glyph_index,
loader->glyf_offset + offset,
loader->byte_len );
@@ -1668,8 +1677,8 @@
}
/* adjust advance width to the value contained in the hdmx table */
- if ( !face->postscript.isFixedPitch &&
- IS_HINTED( loader->load_flags ) )
+ if ( !face->postscript.isFixedPitch &&
+ IS_HINTED( loader->load_flags ) )
{
FT_Byte* widthp;
@@ -1838,12 +1847,15 @@
FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 );
- if ( error )
+ if ( error == TT_Err_Table_Missing )
+ loader->glyf_offset = 0;
+ else if ( error )
{
FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" ));
return error;
}
- loader->glyf_offset = FT_STREAM_POS();
+ else
+ loader->glyf_offset = FT_STREAM_POS();
}
/* get face's glyph loader */
@@ -1855,7 +1867,7 @@
loader->gloader = gloader;
}
- loader->load_flags = load_flags;
+ loader->load_flags = load_flags;
loader->face = (FT_Face)face;
loader->size = (FT_Size)size;
@@ -1958,6 +1970,40 @@
FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
}
+#ifdef TT_USE_BYTECODE_INTERPRETER
+
+ if ( IS_HINTED( load_flags ) )
+ {
+ if ( loader.exec->GS.scan_control )
+ {
+ /* convert scan conversion mode to FT_OUTLINE_XXX flags */
+ switch ( loader.exec->GS.scan_type )
+ {
+ case 0: /* simple drop-outs including stubs */
+ glyph->outline.flags |= FT_OUTLINE_INCLUDE_STUBS;
+ break;
+ case 1: /* simple drop-outs excluding stubs */
+ /* nothing; it's the default rendering mode */
+ break;
+ case 4: /* smart drop-outs including stubs */
+ glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS |
+ FT_OUTLINE_INCLUDE_STUBS;
+ break;
+ case 5: /* smart drop-outs excluding stubs */
+ glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS;
+ break;
+
+ default: /* no drop-out control */
+ glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
+ break;
+ }
+ }
+ else
+ glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
+ }
+
+#endif /* TT_USE_BYTECODE_INTERPRETER */
+
compute_glyph_metrics( &loader, glyph_index );
}