summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/autofit/afloader.c
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-03-19 17:34:42 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-03-20 13:42:29 +0000
commit2eaf0cf8fd6e7c290497fedb08134a89e7b49b1d (patch)
tree0a4f7bf528e87d0b0a71ce7fccf702b87f4cdec1 /src/3rdparty/freetype/src/autofit/afloader.c
parent77c518a50334d4dcf2476a4f39edc1e3990c7f0b (diff)
Update bundled FreeType to 2.5.5
Removed everything, imported with help of import_from_tarball.sh script, and then added a pre-generated builds/unix/ftconfig.h Task-number: QTBUG-44648 Change-Id: Iea948e41f7761f1580382b3763d04c7a61383382 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/freetype/src/autofit/afloader.c')
-rw-r--r--src/3rdparty/freetype/src/autofit/afloader.c158
1 files changed, 97 insertions, 61 deletions
diff --git a/src/3rdparty/freetype/src/autofit/afloader.c b/src/3rdparty/freetype/src/autofit/afloader.c
index 6dd9f2a314..fb15c87f0e 100644
--- a/src/3rdparty/freetype/src/autofit/afloader.c
+++ b/src/3rdparty/freetype/src/autofit/afloader.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter glyph loading routines (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2003-2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,31 +16,41 @@
/***************************************************************************/
+#include "afglobal.h"
#include "afloader.h"
#include "afhints.h"
-#include "afglobal.h"
#include "aferrors.h"
+#include "afmodule.h"
+#include "afpic.h"
+ /* Initialize glyph loader. */
+
FT_LOCAL_DEF( FT_Error )
- af_loader_init( AF_Loader loader,
- FT_Memory memory )
+ af_loader_init( AF_Module module )
{
+ AF_Loader loader = module->loader;
+ FT_Memory memory = module->root.library->memory;
+
+
FT_ZERO( loader );
af_glyph_hints_init( &loader->hints, memory );
-#ifdef AF_DEBUG
+#ifdef FT_DEBUG_AUTOFIT
_af_debug_hints = &loader->hints;
#endif
return FT_GlyphLoader_New( memory, &loader->gloader );
}
+ /* Reset glyph loader and compute globals if necessary. */
+
FT_LOCAL_DEF( FT_Error )
- af_loader_reset( AF_Loader loader,
+ af_loader_reset( AF_Module module,
FT_Face face )
{
- FT_Error error = AF_Err_Ok;
+ FT_Error error = FT_Err_Ok;
+ AF_Loader loader = module->loader;
loader->face = face;
@@ -50,7 +60,7 @@
if ( loader->globals == NULL )
{
- error = af_face_globals_new( face, &loader->globals );
+ error = af_face_globals_new( face, &loader->globals, module );
if ( !error )
{
face->autohint.data =
@@ -64,15 +74,20 @@
}
+ /* Finalize glyph loader. */
+
FT_LOCAL_DEF( void )
- af_loader_done( AF_Loader loader )
+ af_loader_done( AF_Module module )
{
+ AF_Loader loader = module->loader;
+
+
af_glyph_hints_done( &loader->hints );
loader->face = NULL;
loader->globals = NULL;
-#ifdef AF_DEBUG
+#ifdef FT_DEBUG_AUTOFIT
_af_debug_hints = NULL;
#endif
FT_GlyphLoader_Done( loader->gloader );
@@ -80,6 +95,10 @@
}
+ /* Load a single glyph component. This routine calls itself */
+ /* recursively, if necessary, and does the main work of */
+ /* `af_loader_load_glyph.' */
+
static FT_Error
af_loader_load_g( AF_Loader loader,
AF_Scaler scaler,
@@ -90,13 +109,15 @@
FT_Error error;
FT_Face face = loader->face;
FT_GlyphLoader gloader = loader->gloader;
- AF_ScriptMetrics metrics = loader->metrics;
+ AF_StyleMetrics metrics = loader->metrics;
AF_GlyphHints hints = &loader->hints;
FT_GlyphSlot slot = face->glyph;
FT_Slot_Internal internal = slot->internal;
+ FT_Int32 flags;
- error = FT_Load_Glyph( face, glyph_index, load_flags );
+ flags = load_flags | FT_LOAD_LINEAR_DESIGN;
+ error = FT_Load_Glyph( face, glyph_index, flags );
if ( error )
goto Exit;
@@ -110,14 +131,10 @@
loader->trans_delta = internal->glyph_delta;
inverse = loader->trans_matrix;
- FT_Matrix_Invert( &inverse );
- FT_Vector_Transform( &loader->trans_delta, &inverse );
+ if ( !FT_Matrix_Invert( &inverse ) )
+ FT_Vector_Transform( &loader->trans_delta, &inverse );
}
- /* set linear metrics */
- slot->linearHoriAdvance = slot->metrics.horiAdvance;
- slot->linearVertAdvance = slot->metrics.vertAdvance;
-
switch ( slot->format )
{
case FT_GLYPH_FORMAT_OUTLINE:
@@ -127,8 +144,8 @@
loader->trans_delta.x,
loader->trans_delta.y );
- /* copy the outline points in the loader's current */
- /* extra points which is used to keep original glyph coordinates */
+ /* 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 );
@@ -164,13 +181,23 @@
/* now load the slot image into the auto-outline and run the */
/* automatic hinting process */
- if ( metrics->clazz->script_hints_apply )
- metrics->clazz->script_hints_apply( hints,
- &gloader->current.outline,
- metrics );
+ {
+#ifdef FT_CONFIG_OPTION_PIC
+ AF_FaceGlobals globals = loader->globals;
+#endif
+ AF_StyleClass style_class = metrics->style_class;
+ AF_WritingSystemClass writing_system_class =
+ AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
- /* we now need to hint the metrics according to the change in */
- /* width/positioning that occurred during the hinting process */
+
+ if ( writing_system_class->style_hints_apply )
+ writing_system_class->style_hints_apply( hints,
+ &gloader->current.outline,
+ metrics );
+ }
+
+ /* we now need to adjust the metrics according to the change in */
+ /* width/positioning that occurred during the hinting process */
if ( scaler->render_mode != FT_RENDER_MODE_LIGHT )
{
FT_Pos old_rsb, old_lsb, new_lsb;
@@ -265,7 +292,7 @@
gloader->current.num_subglyphs = num_subglyphs;
num_base_subgs = gloader->base.num_subglyphs;
- /* now, read each subglyph independently */
+ /* now read each subglyph independently */
for ( nn = 0; nn < num_subglyphs; nn++ )
{
FT_Vector pp1, pp2;
@@ -291,12 +318,7 @@
/* recompute subglyph pointer */
subglyph = gloader->base.subglyphs + num_base_subgs + nn;
- if ( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS )
- {
- pp1 = loader->pp1;
- pp2 = loader->pp2;
- }
- else
+ if ( !( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS ) )
{
loader->pp1 = pp1;
loader->pp2 = pp2;
@@ -305,7 +327,7 @@
num_points = gloader->base.outline.n_points;
num_new_points = num_points - num_base_points;
- /* now perform the transform required for this subglyph */
+ /* now perform the transformation required for this subglyph */
if ( subglyph->flags & ( FT_SUBGLYPH_FLAG_SCALE |
FT_SUBGLYPH_FLAG_XY_SCALE |
@@ -333,14 +355,14 @@
if ( start_point + k >= num_base_points ||
l >= (FT_UInt)num_new_points )
{
- error = AF_Err_Invalid_Composite;
+ error = FT_THROW( Invalid_Composite );
goto Exit;
}
l += num_base_points;
- /* for now, only use the current point coordinates; */
- /* we may consider another approach in the near future */
+ /* for now, only use the current point coordinates; */
+ /* we eventually may consider another approach */
p1 = gloader->base.outline.points + start_point + k;
p2 = gloader->base.outline.points + start_point + l;
@@ -371,7 +393,7 @@
default:
/* we don't support other formats (yet?) */
- error = AF_Err_Unimplemented_Feature;
+ error = FT_THROW( Unimplemented_Feature );
}
Hint_Metrics:
@@ -423,9 +445,10 @@
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
x_scale );
#else
- if ( FT_IS_FIXED_WIDTH( slot->face ) ||
- ( af_face_globals_is_digit( loader->globals, glyph_index ) &&
- metrics->digits_have_same_width ) )
+ if ( scaler->render_mode != FT_RENDER_MODE_LIGHT &&
+ ( FT_IS_FIXED_WIDTH( slot->face ) ||
+ ( af_face_globals_is_digit( loader->globals, glyph_index ) &&
+ metrics->digits_have_same_width ) ) )
{
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
metrics->scaler.x_scale );
@@ -444,7 +467,7 @@
#endif
slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
- metrics->scaler.y_scale );
+ metrics->scaler.y_scale );
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
@@ -455,32 +478,37 @@
if ( error )
goto Exit;
- slot->outline = internal->loader->base.outline;
+ /* 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;
+ slot->outline.points = internal->loader->base.outline.points;
+ slot->outline.tags = internal->loader->base.outline.tags;
+ slot->outline.contours = internal->loader->base.outline.contours;
+
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
-#ifdef DEBUG_HINTER
- af_debug_hinter = hinter;
-#endif
-
Exit:
return error;
}
+ /* Load a glyph. */
+
FT_LOCAL_DEF( FT_Error )
- af_loader_load_glyph( AF_Loader loader,
+ af_loader_load_glyph( AF_Module module,
FT_Face face,
FT_UInt gindex,
- FT_UInt32 load_flags )
+ FT_Int32 load_flags )
{
FT_Error error;
- FT_Size size = face->size;
+ FT_Size size = face->size;
+ AF_Loader loader = module->loader;
AF_ScalerRec scaler;
if ( !size )
- return AF_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Size_Handle );
FT_ZERO( &scaler );
@@ -493,37 +521,45 @@
scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
scaler.flags = 0; /* XXX: fix this */
- error = af_loader_reset( loader, face );
+ error = af_loader_reset( module, face );
if ( !error )
{
- AF_ScriptMetrics metrics;
- FT_UInt options = 0;
+ AF_StyleMetrics metrics;
+ FT_UInt options = AF_STYLE_NONE_DFLT;
#ifdef FT_OPTION_AUTOFIT2
- /* XXX: undocumented hook to activate the latin2 hinter */
+ /* XXX: undocumented hook to activate the latin2 writing system */
if ( load_flags & ( 1UL << 20 ) )
- options = 2;
+ options = AF_STYLE_LTN2_DFLT;
#endif
error = af_face_globals_get_metrics( loader->globals, gindex,
options, &metrics );
if ( !error )
{
+#ifdef FT_CONFIG_OPTION_PIC
+ AF_FaceGlobals globals = loader->globals;
+#endif
+ AF_StyleClass style_class = metrics->style_class;
+ AF_WritingSystemClass writing_system_class =
+ AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
+
+
loader->metrics = metrics;
- if ( metrics->clazz->script_metrics_scale )
- metrics->clazz->script_metrics_scale( metrics, &scaler );
+ if ( writing_system_class->style_metrics_scale )
+ writing_system_class->style_metrics_scale( metrics, &scaler );
else
metrics->scaler = scaler;
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;
- if ( metrics->clazz->script_hints_init )
+ if ( writing_system_class->style_hints_init )
{
- error = metrics->clazz->script_hints_init( &loader->hints,
- metrics );
+ error = writing_system_class->style_hints_init( &loader->hints,
+ metrics );
if ( error )
goto Exit;
}