[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft-devel] Re: How FT_Load_Glyph() should work for the glyph description
From: |
mpsuzuki |
Subject: |
[ft-devel] Re: How FT_Load_Glyph() should work for the glyph description that cannot be rendered correctly? |
Date: |
Thu, 9 Jul 2009 18:33:24 +0900 |
Hi,
Just I've finished the patch for all existing outline
drivers in FT2 to pass GID to FT_GlyphLoader.
By this patch, FT_GlyphLoader_CheckPoints() generates
debug messages for the glyphs including too many points/
contours, with GID.
The source of FT_GlyphLoader (to avoid writing GID to
the memory at the invalid pointer) is described in
ChangeLog.
Any comments are welcomed.
Regards,
mpsuzuki
diff --git a/ChangeLog b/ChangeLog
index b74dc22..85fc3e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,38 @@
2009-07-09 suzuki toshiya <address@hidden>
+ New member FT_GlyphLoader->glyph_index for better debug messages.
+
+ * include/freetype/internal/ftgloadr.h (FT_GlyphLoaderRec):
+ New member `glyph_index'.
+ * src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Clear `glyph_index'
+ when we rewind the loader.
+
+ * src/cff/cffgload.c (cff_slot_load): Copy loading GID to
+ CFF_Decoder->CFF_Builder->FT_GlyphLoader->glyph_index.
+ The destination FT_GlyphLoader is copied from the root glyph slot
+ by cff_builder_init() called in cff_slot_load().
+
+ * src/cid/cidgload.c (cid_slot_load_glyph): Copy loading GID to
+ T1_Decoder->T1_Builder->FT_GlyphLoader->glyph_index.
+ The destination FT_GlyphLoader is copied from the `internal' of
+ the glyph slot, by t1_builder_init() called in cid_slot_load_glyph().
+
+ * src/pfr/pfrobjs.c (pfr_slot_load): Copy loading GID to
+ PFR_Slot->PFR_Glyph->FT_GlyphLoader->glyph_index.
+ The destination FT_GlyphLoader is copied from the `internal' of
+ the glyph slot, by pfr_slot_load() called before pfr_slot_load().
+
+ * src/truetype/ttgload.c (TT_Load_Glyph): Copy loading GID to
+ TT_Loader->FT_GlyphLoader->glyph_index. The destination
+ FT_GlyphLoader is included in the first argument TT_Loader.
+
+ * src/type1/t1gload.c (T1_Load_Glyph): Copy loading GID to
+ T1_Decoder->T1_Builder->FT_GlyphLoader->glyph_index.
+ The destination FT_GlyphLoader is copied from the `internal' of
+ the glyph slot, by t1_builder_init() called in T1_Load_Glyph().
+
+2009-07-09 suzuki toshiya <address@hidden>
+
smooth: Check glyph size by width/height, instead of pitch/height.
Suggested by der Mouse <address@hidden>.
diff --git a/include/freetype/internal/ftgloadr.h
b/include/freetype/internal/ftgloadr.h
index ce4dc6c..76f9cf5 100644
--- a/include/freetype/internal/ftgloadr.h
+++ b/include/freetype/internal/ftgloadr.h
@@ -87,6 +87,7 @@ FT_BEGIN_HEADER
FT_GlyphLoadRec base;
FT_GlyphLoadRec current;
+ FT_ULong glyph_index; /* just for warning */
void* other; /* for possible future extension? */
} FT_GlyphLoaderRec;
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c
index ac0010d..aa84295 100644
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -93,6 +93,7 @@
base->outline.n_points = 0;
base->outline.n_contours = 0;
base->num_subglyphs = 0;
+ loader->glyph_index = 0;
*current = *base;
}
@@ -219,7 +220,11 @@
new_max = FT_PAD_CEIL( new_max, 8 );
if ( new_max > FT_OUTLINE_POINTS_MAX )
+ {
+ FT_TRACE0(( "Too many points in the outline of GID=%d\n",
+ loader->glyph_index ));
return FT_Err_Array_Too_Large;
+ }
if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
@@ -251,7 +256,11 @@
new_max = FT_PAD_CEIL( new_max, 4 );
if ( new_max > FT_OUTLINE_CONTOURS_MAX )
+ {
+ FT_TRACE0(( "Too many contours in the outline of GID=%d\n",
+ loader->glyph_index ));
return FT_Err_Array_Too_Large;
+ }
if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
goto Exit;
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 7074160..fb49635 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2616,6 +2616,7 @@
cff_decoder_init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
+ decoder.builder.loader->glyph_index = glyph_index;
if ( load_flags & FT_LOAD_ADVANCE_ONLY )
decoder.width_only = TRUE;
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index f59035f..acd820c 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -317,6 +317,7 @@
/* if we ever support CID-keyed multiple master fonts */
/* set up the decoder */
+ decoder.builder.loader->glyph_index = glyph_index;
decoder.builder.no_recurse = FT_BOOL(
( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) );
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index 56d617d..81245cb 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -312,6 +312,7 @@
FT_ULong gps_offset;
+ slot->glyph.loader->glyph_index = gindex;
if ( gindex > 0 )
gindex--;
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 9251cab..8f9ed1b 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1952,6 +1952,7 @@
if ( error )
return error;
+ loader.gloader->glyph_index = glyph_index;
glyph->format = FT_GLYPH_FORMAT_OUTLINE;
glyph->num_subglyphs = 0;
glyph->outline.flags = 0;
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 01bc4ce..7177383 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -330,6 +330,7 @@
must_finish_decoder = TRUE;
+ decoder.builder.loader->glyph_index = glyph_index;
decoder.builder.no_recurse = FT_BOOL(
( load_flags & FT_LOAD_NO_RECURSE ) != 0 );