ref: a4117fbda7399e201d4e438d301ab588d28dcea7
parent: ae6699f86c42d3f81626eca1833d0537356f196a
author: Behdad Esfahbod <[email protected]>
date: Wed Jan 14 14:07:54 EST 2015
[autofit] Reuse slot glyph loader. No need to create a new glyph loader; we can reuse the one from `slot->internal->loader'. It's hard to tell why it was written that way originally, but new code looks sound and correct to me, and avoids lots of allocations. * src/autofit/afloader.c (af_loader_init): Change return type to `void'. Don't call `FT_GlyphLoader_New'. (af_loader_reset): Don't call `FT_GlyphLoader_Rewind'. (af_loader_load_g): Update code to use `internal->loader', which doesn't need copying of data. * src/autofit/afloader.h (AF_LoaderRec): Remove `gloader' member. Update prototype. * src/autofit/afmodule.c (af_autofitter_load_glyph): Updated.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2015-01-14 Behdad Esfahbod <[email protected]>
+ [autofit] Reuse slot glyph loader.
+
+ No need to create a new glyph loader; we can reuse the one from
+ `slot->internal->loader'. It's hard to tell why it was written that
+ way originally, but new code looks sound and correct to me, and
+ avoids lots of allocations.
+
+ * src/autofit/afloader.c (af_loader_init): Change return type to
+ `void'.
+ Don't call `FT_GlyphLoader_New'.
+ (af_loader_reset): Don't call `FT_GlyphLoader_Rewind'.
+ (af_loader_load_g): Update code to use `internal->loader', which
+ doesn't need copying of data.
+
+ * src/autofit/afloader.h (AF_LoaderRec): Remove `gloader' member.
+ Update prototype.
+
+ * src/autofit/afmodule.c (af_autofitter_load_glyph): Updated.
+
+2015-01-14 Behdad Esfahbod <[email protected]>
+
[autofit] Remove (unused) support for composite glyphs.
We never have to deal with composite glyphs in the autohinter, as
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -26,7 +26,7 @@
/* Initialize glyph loader. */
- FT_LOCAL_DEF( FT_Error )
+ FT_LOCAL_DEF( void )
af_loader_init( AF_Loader loader,
FT_Memory memory )
{
@@ -36,7 +36,6 @@
#ifdef FT_DEBUG_AUTOFIT
_af_debug_hints = &loader->hints;
#endif
- return FT_GlyphLoader_New( memory, &loader->gloader );
}
@@ -53,8 +52,6 @@
loader->face = face;
loader->globals = (AF_FaceGlobals)face->autohint.data;
- FT_GlyphLoader_Rewind( loader->gloader );
-
if ( loader->globals == NULL )
{
error = af_face_globals_new( face, &loader->globals, module );
@@ -84,8 +81,6 @@
#ifdef FT_DEBUG_AUTOFIT
_af_debug_hints = NULL;
#endif
- FT_GlyphLoader_Done( loader->gloader );
- loader->gloader = NULL;
}
@@ -103,11 +98,11 @@
{
FT_Error error;
FT_Face face = loader->face;
- FT_GlyphLoader gloader = loader->gloader;
AF_StyleMetrics metrics = loader->metrics;
AF_GlyphHints hints = &loader->hints;
FT_GlyphSlot slot = face->glyph;
FT_Slot_Internal internal = slot->internal;
+ FT_GlyphLoader gloader = internal->loader;
FT_Int32 flags;
@@ -139,29 +134,6 @@
loader->trans_delta.x,
loader->trans_delta.y );
- /* copy the outline points in the loader's current */
- /* extra points which are used to keep original glyph coordinates */
- error = FT_GLYPHLOADER_CHECK_POINTS( gloader,
- slot->outline.n_points + 4,
- slot->outline.n_contours );
- if ( error )
- goto Exit;
-
- FT_ARRAY_COPY( gloader->current.outline.points,
- slot->outline.points,
- slot->outline.n_points );
-
- FT_ARRAY_COPY( gloader->current.outline.contours,
- slot->outline.contours,
- slot->outline.n_contours );
-
- FT_ARRAY_COPY( gloader->current.outline.tags,
- slot->outline.tags,
- slot->outline.n_points );
-
- gloader->current.outline.n_points = slot->outline.n_points;
- gloader->current.outline.n_contours = slot->outline.n_contours;
-
/* compute original horizontal phantom points (and ignore */
/* vertical ones) */
loader->pp1.x = hints->x_delta;
@@ -187,7 +159,7 @@
if ( writing_system_class->style_hints_apply )
writing_system_class->style_hints_apply( hints,
- &gloader->current.outline,
+ &gloader->base.outline,
metrics );
}
@@ -262,8 +234,6 @@
slot->rsb_delta = loader->pp2.x - pp2x;
}
- /* good, we simply add the glyph to our loader's base */
- FT_GlyphLoader_Add( gloader );
break;
default:
@@ -346,12 +316,7 @@
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
- /* now copy outline into glyph slot */
- FT_GlyphLoader_Rewind( internal->loader );
- error = FT_GlyphLoader_CopyPoints( internal->loader, gloader );
- if ( error )
- goto Exit;
-
+#if 0
/* reassign all outline fields except flags to protect them */
slot->outline.n_contours = internal->loader->base.outline.n_contours;
slot->outline.n_points = internal->loader->base.outline.n_points;
@@ -358,6 +323,7 @@
slot->outline.points = internal->loader->base.outline.points;
slot->outline.tags = internal->loader->base.outline.tags;
slot->outline.contours = internal->loader->base.outline.contours;
+#endif
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
--- a/src/autofit/afloader.h
+++ b/src/autofit/afloader.h
@@ -41,7 +41,6 @@
AF_FaceGlobals globals;
/* current glyph data */
- FT_GlyphLoader gloader;
AF_GlyphHintsRec hints;
AF_StyleMetrics metrics;
FT_Bool transformed;
@@ -54,7 +53,7 @@
} AF_LoaderRec, *AF_Loader;
- FT_LOCAL( FT_Error )
+ FT_LOCAL( void )
af_loader_init( AF_Loader loader,
FT_Memory memory );
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -277,9 +277,7 @@
FT_UNUSED( size );
- error = af_loader_init( loader, module->root.library->memory );
- if ( error )
- return error;
+ af_loader_init( loader, module->root.library->memory );
error = af_loader_load_glyph( loader, module, slot->face,
glyph_index, load_flags );