summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/truetype
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/truetype')
-rw-r--r--src/3rdparty/freetype/src/truetype/Jamfile37
-rw-r--r--src/3rdparty/freetype/src/truetype/module.mk2
-rw-r--r--src/3rdparty/freetype/src/truetype/rules.mk6
-rw-r--r--src/3rdparty/freetype/src/truetype/truetype.c35
-rw-r--r--src/3rdparty/freetype/src/truetype/ttdriver.c383
-rw-r--r--src/3rdparty/freetype/src/truetype/ttdriver.h37
-rw-r--r--src/3rdparty/freetype/src/truetype/tterrors.h52
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgload.c1527
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgload.h33
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgxvar.c2813
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgxvar.h438
-rw-r--r--src/3rdparty/freetype/src/truetype/ttinterp.c4706
-rw-r--r--src/3rdparty/freetype/src/truetype/ttinterp.h326
-rw-r--r--src/3rdparty/freetype/src/truetype/ttobjs.c671
-rw-r--r--src/3rdparty/freetype/src/truetype/ttobjs.h327
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpic.c101
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpic.h88
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpload.c421
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpload.h41
-rw-r--r--src/3rdparty/freetype/src/truetype/ttsubpix.c1014
-rw-r--r--src/3rdparty/freetype/src/truetype/ttsubpix.h111
21 files changed, 5754 insertions, 7415 deletions
diff --git a/src/3rdparty/freetype/src/truetype/Jamfile b/src/3rdparty/freetype/src/truetype/Jamfile
deleted file mode 100644
index e321fba14a..0000000000
--- a/src/3rdparty/freetype/src/truetype/Jamfile
+++ /dev/null
@@ -1,37 +0,0 @@
-# FreeType 2 src/truetype Jamfile
-#
-# Copyright 2001-2018 by
-# David Turner, Robert Wilhelm, and Werner Lemberg.
-#
-# This file is part of the FreeType project, and may only be used, modified,
-# and distributed under the terms of the FreeType project license,
-# LICENSE.TXT. By continuing to use, modify, or distribute this file you
-# indicate that you have read the license and understand and accept it
-# fully.
-
-SubDir FT2_TOP $(FT2_SRC_DIR) truetype ;
-
-{
- local _sources ;
-
- if $(FT2_MULTI)
- {
- _sources = ttdriver
- ttgload
- ttgxvar
- ttinterp
- ttobjs
- ttpic
- ttpload
- ttsubpix
- ;
- }
- else
- {
- _sources = truetype ;
- }
-
- Library $(FT2_LIB) : $(_sources).c ;
-}
-
-# end of src/truetype Jamfile
diff --git a/src/3rdparty/freetype/src/truetype/module.mk b/src/3rdparty/freetype/src/truetype/module.mk
index 16bc9c8b20..5d44ac1f41 100644
--- a/src/3rdparty/freetype/src/truetype/module.mk
+++ b/src/3rdparty/freetype/src/truetype/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2018 by
+# Copyright (C) 1996-2023 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/src/3rdparty/freetype/src/truetype/rules.mk b/src/3rdparty/freetype/src/truetype/rules.mk
index e16113f128..dde26de1cc 100644
--- a/src/3rdparty/freetype/src/truetype/rules.mk
+++ b/src/3rdparty/freetype/src/truetype/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2018 by
+# Copyright (C) 1996-2023 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -33,9 +33,7 @@ TT_DRV_SRC := $(TT_DIR)/ttdriver.c \
$(TT_DIR)/ttgxvar.c \
$(TT_DIR)/ttinterp.c \
$(TT_DIR)/ttobjs.c \
- $(TT_DIR)/ttpic.c \
- $(TT_DIR)/ttpload.c \
- $(TT_DIR)/ttsubpix.c
+ $(TT_DIR)/ttpload.c
# TrueType driver headers
#
diff --git a/src/3rdparty/freetype/src/truetype/truetype.c b/src/3rdparty/freetype/src/truetype/truetype.c
index 484370975c..fcc0ea334f 100644
--- a/src/3rdparty/freetype/src/truetype/truetype.c
+++ b/src/3rdparty/freetype/src/truetype/truetype.c
@@ -1,32 +1,29 @@
-/***************************************************************************/
-/* */
-/* truetype.c */
-/* */
-/* FreeType TrueType driver component (body only). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * truetype.c
+ *
+ * FreeType TrueType driver component (body only).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#define FT_MAKE_OPTION_SINGLE_OBJECT
-#include <ft2build.h>
#include "ttdriver.c" /* driver interface */
#include "ttgload.c" /* glyph loader */
#include "ttgxvar.c" /* gx distortable font */
#include "ttinterp.c"
#include "ttobjs.c" /* object manager */
-#include "ttpic.c"
#include "ttpload.c" /* tables loader */
-#include "ttsubpix.c"
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttdriver.c b/src/3rdparty/freetype/src/truetype/ttdriver.c
index 820cafbb8d..d1496fec7f 100644
--- a/src/3rdparty/freetype/src/truetype/ttdriver.c
+++ b/src/3rdparty/freetype/src/truetype/ttdriver.c
@@ -1,37 +1,36 @@
-/***************************************************************************/
-/* */
-/* ttdriver.c */
-/* */
-/* TrueType font driver implementation (body). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_SFNT_H
-#include FT_SERVICE_FONT_FORMAT_H
+/****************************************************************************
+ *
+ * ttdriver.c
+ *
+ * TrueType font driver implementation (body).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/internal/services/svfntfmt.h>
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#include FT_MULTIPLE_MASTERS_H
-#include FT_SERVICE_MULTIPLE_MASTERS_H
-#include FT_SERVICE_METRICS_VARIATIONS_H
+#include <freetype/ftmm.h>
+#include <freetype/internal/services/svmm.h>
+#include <freetype/internal/services/svmetric.h>
#endif
-#include FT_SERVICE_TRUETYPE_ENGINE_H
-#include FT_SERVICE_TRUETYPE_GLYF_H
-#include FT_SERVICE_PROPERTIES_H
-#include FT_DRIVER_H
+#include <freetype/internal/services/svtteng.h>
+#include <freetype/internal/services/svttglyf.h>
+#include <freetype/internal/services/svprop.h>
+#include <freetype/ftdriver.h>
#include "ttdriver.h"
#include "ttgload.h"
@@ -43,23 +42,22 @@
#include "tterrors.h"
-#include "ttpic.h"
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttdriver
+#define FT_COMPONENT ttdriver
/*
- * PROPERTY SERVICE
+ * PROPERTY SERVICE
*
*/
- static FT_Error
+ FT_CALLBACK_DEF( FT_Error )
tt_property_set( FT_Module module, /* TT_Driver */
const char* property_name,
const void* value,
@@ -95,31 +93,36 @@
interpreter_version = *iv;
}
- if ( interpreter_version == TT_INTERPRETER_VERSION_35
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- || interpreter_version == TT_INTERPRETER_VERSION_38
-#endif
+ switch ( interpreter_version )
+ {
+ case TT_INTERPRETER_VERSION_35:
+ driver->interpreter_version = TT_INTERPRETER_VERSION_35;
+ break;
+
+ case TT_INTERPRETER_VERSION_38:
+ case TT_INTERPRETER_VERSION_40:
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- || interpreter_version == TT_INTERPRETER_VERSION_40
+ driver->interpreter_version = TT_INTERPRETER_VERSION_40;
+ break;
#endif
- )
- driver->interpreter_version = interpreter_version;
- else
+
+ default:
error = FT_ERR( Unimplemented_Feature );
+ }
return error;
}
- FT_TRACE0(( "tt_property_set: missing property `%s'\n",
+ FT_TRACE2(( "tt_property_set: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
- static FT_Error
+ FT_CALLBACK_DEF( FT_Error )
tt_property_get( FT_Module module, /* TT_Driver */
const char* property_name,
- const void* value )
+ void* value )
{
FT_Error error = FT_Err_Ok;
TT_Driver driver = (TT_Driver)module;
@@ -137,7 +140,7 @@
return error;
}
- FT_TRACE0(( "tt_property_get: missing property `%s'\n",
+ FT_TRACE2(( "tt_property_get: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
@@ -146,8 +149,8 @@
FT_DEFINE_SERVICE_PROPERTIESREC(
tt_service_properties,
- (FT_Properties_SetFunc)tt_property_set, /* set_property */
- (FT_Properties_GetFunc)tt_property_get /* get_property */
+ tt_property_set, /* FT_Properties_SetFunc set_property */
+ tt_property_get /* FT_Properties_GetFunc get_property */
)
@@ -164,67 +167,71 @@
/*************************************************************************/
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_get_kerning */
- /* */
- /* <Description> */
- /* A driver method used to return the kerning vector between two */
- /* glyphs of the same face. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* left_glyph :: The index of the left glyph in the kern pair. */
- /* */
- /* right_glyph :: The index of the right glyph in the kern pair. */
- /* */
- /* <Output> */
- /* kerning :: The kerning vector. This is in font units for */
- /* scalable formats, and in pixels for fixed-sizes */
- /* formats. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only horizontal layouts (left-to-right & right-to-left) are */
- /* supported by this function. Other layouts, or more sophisticated */
- /* kernings, are out of scope of this method (the basic driver */
- /* interface is meant to be simple). */
- /* */
- /* They can be implemented by format-specific interfaces. */
- /* */
- static FT_Error
- tt_get_kerning( FT_Face ttface, /* TT_Face */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_get_kerning
+ *
+ * @Description:
+ * A driver method used to return the kerning vector between two
+ * glyphs of the same face.
+ *
+ * @Input:
+ * face ::
+ * A handle to the source face object.
+ *
+ * left_glyph ::
+ * The index of the left glyph in the kern pair.
+ *
+ * right_glyph ::
+ * The index of the right glyph in the kern pair.
+ *
+ * @Output:
+ * kerning ::
+ * The kerning vector. This is in font units for
+ * scalable formats, and in pixels for fixed-sizes
+ * formats.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ *
+ * @Note:
+ * Only horizontal layouts (left-to-right & right-to-left) are
+ * supported by this function. Other layouts, or more sophisticated
+ * kernings, are out of scope of this method (the basic driver
+ * interface is meant to be simple).
+ *
+ * They can be implemented by format-specific interfaces.
+ */
+ FT_CALLBACK_DEF( FT_Error )
+ tt_get_kerning( FT_Face face, /* TT_Face */
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
- TT_Face face = (TT_Face)ttface;
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+ TT_Face ttface = (TT_Face)face;
+ SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
kerning->x = 0;
kerning->y = 0;
if ( sfnt )
- kerning->x = sfnt->get_kerning( face, left_glyph, right_glyph );
+ kerning->x = sfnt->get_kerning( ttface, left_glyph, right_glyph );
return 0;
}
- static FT_Error
- tt_get_advances( FT_Face ttface,
+ FT_CALLBACK_DEF( FT_Error )
+ tt_get_advances( FT_Face face, /* TT_Face */
FT_UInt start,
FT_UInt count,
FT_Int32 flags,
FT_Fixed *advances )
{
FT_UInt nn;
- TT_Face face = (TT_Face)ttface;
+ TT_Face ttface = (TT_Face)face;
/* XXX: TODO: check for sbits */
@@ -233,8 +240,8 @@
{
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* no fast retrieval for blended MM fonts without VVAR table */
- if ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) &&
- !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
+ if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
+ !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
return FT_THROW( Unimplemented_Feature );
#endif
@@ -245,7 +252,7 @@
/* since we don't need `tsb', we use zero for `yMax' parameter */
- TT_Get_VMetrics( face, start + nn, 0, &tsb, &ah );
+ TT_Get_VMetrics( ttface, start + nn, 0, &tsb, &ah );
advances[nn] = ah;
}
}
@@ -253,8 +260,8 @@
{
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* no fast retrieval for blended MM fonts without HVAR table */
- if ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) &&
- !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
+ if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
+ !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
return FT_THROW( Unimplemented_Feature );
#endif
@@ -264,7 +271,7 @@
FT_UShort aw;
- TT_Get_HMetrics( face, start + nn, &lsb, &aw );
+ TT_Get_HMetrics( ttface, start + nn, &lsb, &aw );
advances[nn] = aw;
}
}
@@ -288,7 +295,7 @@
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
- static FT_Error
+ FT_CALLBACK_DEF( FT_Error )
tt_size_select( FT_Size size,
FT_ULong strike_index )
{
@@ -304,7 +311,7 @@
/* use the scaled metrics, even when tt_size_reset fails */
FT_Select_Metrics( size->face, strike_index );
- tt_size_reset( ttsize, 0 ); /* ignore return value */
+ tt_size_reset( ttsize ); /* ignore return value */
}
else
{
@@ -325,7 +332,7 @@
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
- static FT_Error
+ FT_CALLBACK_DEF( FT_Error )
tt_size_request( FT_Size size,
FT_Size_Request req )
{
@@ -352,11 +359,20 @@
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
- FT_Request_Metrics( size->face, req );
+ {
+ FT_Error err = FT_Request_Metrics( size->face, req );
+
+
+ if ( err )
+ {
+ error = err;
+ goto Exit;
+ }
+ }
if ( FT_IS_SCALABLE( size->face ) )
{
- error = tt_size_reset( ttsize, 0 );
+ error = tt_size_reset( ttsize );
#ifdef TT_USE_BYTECODE_INTERPRETER
/* for the `MPS' bytecode instruction we need the point size */
@@ -380,45 +396,50 @@
#endif
}
+ Exit:
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_glyph_load */
- /* */
- /* <Description> */
- /* A driver method used to load a glyph within a given glyph slot. */
- /* */
- /* <Input> */
- /* slot :: A handle to the target slot object where the glyph */
- /* will be loaded. */
- /* */
- /* size :: A handle to the source face size at which the glyph */
- /* must be scaled, loaded, etc. */
- /* */
- /* glyph_index :: The index of the glyph in the font file. */
- /* */
- /* load_flags :: A flag indicating what to load for this glyph. The */
- /* FT_LOAD_XXX constants can be used to control the */
- /* glyph loading process (e.g., whether the outline */
- /* should be scaled, whether to load bitmaps or not, */
- /* whether to hint the outline, etc). */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static FT_Error
- tt_glyph_load( FT_GlyphSlot ttslot, /* TT_GlyphSlot */
- FT_Size ttsize, /* TT_Size */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_glyph_load
+ *
+ * @Description:
+ * A driver method used to load a glyph within a given glyph slot.
+ *
+ * @Input:
+ * slot ::
+ * A handle to the target slot object where the glyph
+ * will be loaded.
+ *
+ * size ::
+ * A handle to the source face size at which the glyph
+ * must be scaled, loaded, etc.
+ *
+ * glyph_index ::
+ * The index of the glyph in the font file.
+ *
+ * load_flags ::
+ * A flag indicating what to load for this glyph. The
+ * FT_LOAD_XXX constants can be used to control the
+ * glyph loading process (e.g., whether the outline
+ * should be scaled, whether to load bitmaps or not,
+ * whether to hint the outline, etc).
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
+ FT_CALLBACK_DEF( FT_Error )
+ tt_glyph_load( FT_GlyphSlot slot, /* TT_GlyphSlot */
+ FT_Size size, /* TT_Size */
FT_UInt glyph_index,
FT_Int32 load_flags )
{
- TT_GlyphSlot slot = (TT_GlyphSlot)ttslot;
- TT_Size size = (TT_Size)ttsize;
- FT_Face face = ttslot->face;
+ TT_GlyphSlot ttslot = (TT_GlyphSlot)slot;
+ TT_Size ttsize = (TT_Size)size;
+ FT_Face face = ttslot->face;
FT_Error error;
@@ -460,12 +481,12 @@
}
/* use hinted metrics only if we load a glyph with hinting */
- size->metrics = ( load_flags & FT_LOAD_NO_HINTING )
- ? &ttsize->metrics
- : &size->hinted_metrics;
+ ttsize->metrics = ( load_flags & FT_LOAD_NO_HINTING )
+ ? &size->metrics
+ : &ttsize->hinted_metrics;
- /* now load the glyph outline if necessary */
- error = TT_Load_Glyph( size, slot, glyph_index, load_flags );
+ /* now fill in the glyph slot with outline/bitmap/layered */
+ error = TT_Load_Glyph( ttsize, ttslot, glyph_index, load_flags );
/* force drop-out mode to 2 - irrelevant now */
/* slot->outline.dropout_mode = 2; */
@@ -491,32 +512,47 @@
FT_DEFINE_SERVICE_MULTIMASTERSREC(
tt_service_gx_multi_masters,
- (FT_Get_MM_Func) NULL, /* get_mm */
- (FT_Set_MM_Design_Func) NULL, /* set_mm_design */
- (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */
- (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */
- (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */
- (FT_Set_Var_Design_Func)TT_Set_Var_Design, /* set_var_design */
- (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */
- (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */
-
- (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */
- (FT_Done_Blend_Func) tt_done_blend /* done_blend */
+ NULL, /* FT_Get_MM_Func get_mm */
+ NULL, /* FT_Set_MM_Design_Func set_mm_design */
+ TT_Set_MM_Blend, /* FT_Set_MM_Blend_Func set_mm_blend */
+ TT_Get_MM_Blend, /* FT_Get_MM_Blend_Func get_mm_blend */
+ TT_Get_MM_Var, /* FT_Get_MM_Var_Func get_mm_var */
+ TT_Set_Var_Design, /* FT_Set_Var_Design_Func set_var_design */
+ TT_Get_Var_Design, /* FT_Get_Var_Design_Func get_var_design */
+ TT_Set_Named_Instance, /* FT_Set_Named_Instance_Func set_named_instance */
+ TT_Get_Default_Named_Instance,
+ /* FT_Get_Default_Named_Instance_Func get_default_named_instance */
+ NULL, /* FT_Set_MM_WeightVector_Func set_mm_weightvector */
+ NULL, /* FT_Get_MM_WeightVector_Func get_mm_weightvector */
+
+ tt_construct_ps_name, /* FT_Construct_PS_Name_Func construct_ps_name */
+ tt_var_load_delta_set_index_mapping,
+ /* FT_Var_Load_Delta_Set_Idx_Map_Func load_delta_set_idx_map */
+ tt_var_load_item_variation_store,
+ /* FT_Var_Load_Item_Var_Store_Func load_item_variation_store */
+ tt_var_get_item_delta, /* FT_Var_Get_Item_Delta_Func get_item_delta */
+ tt_var_done_item_variation_store,
+ /* FT_Var_Done_Item_Var_Store_Func done_item_variation_store */
+ tt_var_done_delta_set_index_map,
+ /* FT_Var_Done_Delta_Set_Idx_Map_Func done_delta_set_index_map */
+ tt_get_var_blend, /* FT_Get_Var_Blend_Func get_var_blend */
+ tt_done_blend /* FT_Done_Blend_Func done_blend */
)
FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
tt_service_metrics_variations,
- (FT_HAdvance_Adjust_Func)tt_hadvance_adjust, /* hadvance_adjust */
- (FT_LSB_Adjust_Func) NULL, /* lsb_adjust */
- (FT_RSB_Adjust_Func) NULL, /* rsb_adjust */
+ tt_hadvance_adjust, /* FT_HAdvance_Adjust_Func hadvance_adjust */
+ NULL, /* FT_LSB_Adjust_Func lsb_adjust */
+ NULL, /* FT_RSB_Adjust_Func rsb_adjust */
- (FT_VAdvance_Adjust_Func)tt_vadvance_adjust, /* vadvance_adjust */
- (FT_TSB_Adjust_Func) NULL, /* tsb_adjust */
- (FT_BSB_Adjust_Func) NULL, /* bsb_adjust */
- (FT_VOrg_Adjust_Func) NULL, /* vorg_adjust */
+ tt_vadvance_adjust, /* FT_VAdvance_Adjust_Func vadvance_adjust */
+ NULL, /* FT_TSB_Adjust_Func tsb_adjust */
+ NULL, /* FT_BSB_Adjust_Func bsb_adjust */
+ NULL, /* FT_VOrg_Adjust_Func vorg_adjust */
- (FT_Metrics_Adjust_Func) tt_apply_mvar /* metrics_adjust */
+ tt_apply_mvar, /* FT_Metrics_Adjust_Func metrics_adjust */
+ tt_size_reset_height /* FT_Size_Reset_Func size_reset */
)
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
@@ -548,19 +584,19 @@
tt_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE,
- FT_SERVICE_ID_MULTI_MASTERS, &TT_SERVICE_GX_MULTI_MASTERS_GET,
- FT_SERVICE_ID_METRICS_VARIATIONS, &TT_SERVICE_METRICS_VARIATIONS_GET,
+ FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters,
+ FT_SERVICE_ID_METRICS_VARIATIONS, &tt_service_metrics_variations,
FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine,
- FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET,
- FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET )
+ FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf,
+ FT_SERVICE_ID_PROPERTIES, &tt_service_properties )
#else
FT_DEFINE_SERVICEDESCREC4(
tt_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE,
FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine,
- FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET,
- FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET )
+ FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf,
+ FT_SERVICE_ID_PROPERTIES, &tt_service_properties )
#endif
@@ -574,26 +610,15 @@
SFNT_Service sfnt;
- /* TT_SERVICES_GET dereferences `library' in PIC mode */
-#ifdef FT_CONFIG_OPTION_PIC
- if ( !driver )
- return NULL;
- library = driver->library;
- if ( !library )
- return NULL;
-#endif
-
- result = ft_service_list_lookup( TT_SERVICES_GET, tt_interface );
+ result = ft_service_list_lookup( tt_services, tt_interface );
if ( result )
return result;
-#ifndef FT_CONFIG_OPTION_PIC
if ( !driver )
return NULL;
library = driver->library;
if ( !library )
return NULL;
-#endif
/* only return the default interface from the SFNT module */
sfntd = FT_Get_Module( library, "sfnt" );
diff --git a/src/3rdparty/freetype/src/truetype/ttdriver.h b/src/3rdparty/freetype/src/truetype/ttdriver.h
index 707aa68edf..757a66f425 100644
--- a/src/3rdparty/freetype/src/truetype/ttdriver.h
+++ b/src/3rdparty/freetype/src/truetype/ttdriver.h
@@ -1,35 +1,32 @@
-/***************************************************************************/
-/* */
-/* ttdriver.h */
-/* */
-/* High-level TrueType driver interface (specification). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttdriver.h
+ *
+ * High-level TrueType driver interface (specification).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef TTDRIVER_H_
#define TTDRIVER_H_
-#include <ft2build.h>
-#include FT_INTERNAL_DRIVER_H
+#include <freetype/internal/ftdrv.h>
FT_BEGIN_HEADER
-
FT_DECLARE_DRIVER( tt_driver_class )
-
FT_END_HEADER
#endif /* TTDRIVER_H_ */
diff --git a/src/3rdparty/freetype/src/truetype/tterrors.h b/src/3rdparty/freetype/src/truetype/tterrors.h
index 88bca3a04a..008ee99853 100644
--- a/src/3rdparty/freetype/src/truetype/tterrors.h
+++ b/src/3rdparty/freetype/src/truetype/tterrors.h
@@ -1,32 +1,32 @@
-/***************************************************************************/
-/* */
-/* tterrors.h */
-/* */
-/* TrueType error codes (specification only). */
-/* */
-/* Copyright 2001-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* This file is used to define the TrueType error enumeration */
- /* constants. */
- /* */
- /*************************************************************************/
+/****************************************************************************
+ *
+ * tterrors.h
+ *
+ * TrueType error codes (specification only).
+ *
+ * Copyright (C) 2001-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * This file is used to define the TrueType error enumeration
+ * constants.
+ *
+ */
#ifndef TTERRORS_H_
#define TTERRORS_H_
-#include FT_MODULE_ERRORS_H
+#include <freetype/ftmoderr.h>
#undef FTERRORS_H_
@@ -34,7 +34,7 @@
#define FT_ERR_PREFIX TT_Err_
#define FT_ERR_BASE FT_Mod_Err_TrueType
-#include FT_ERRORS_H
+#include <freetype/fterrors.h>
#endif /* TTERRORS_H_ */
diff --git a/src/3rdparty/freetype/src/truetype/ttgload.c b/src/3rdparty/freetype/src/truetype/ttgload.c
index 39d9c3f736..dc427e8a11 100644
--- a/src/3rdparty/freetype/src/truetype/ttgload.c
+++ b/src/3rdparty/freetype/src/truetype/ttgload.c
@@ -1,31 +1,31 @@
-/***************************************************************************/
-/* */
-/* ttgload.c */
-/* */
-/* TrueType Glyph Loader (body). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttgload.c
+ *
+ * TrueType Glyph Loader (body).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
+#include <freetype/internal/ftdebug.h>
#include FT_CONFIG_CONFIG_H
-#include FT_INTERNAL_CALC_H
-#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_SFNT_H
-#include FT_TRUETYPE_TAGS_H
-#include FT_OUTLINE_H
-#include FT_DRIVER_H
-#include FT_LIST_H
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/tttags.h>
+#include <freetype/ftoutln.h>
+#include <freetype/ftdriver.h>
+#include <freetype/ftlist.h>
#include "ttgload.h"
#include "ttpload.h"
@@ -35,23 +35,37 @@
#endif
#include "tterrors.h"
-#include "ttsubpix.h"
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttgload
+#define FT_COMPONENT ttgload
- /*************************************************************************/
- /* */
- /* Composite glyph flags. */
- /* */
+ /**************************************************************************
+ *
+ * Simple glyph flags.
+ */
+#define ON_CURVE_POINT 0x01 /* same value as FT_CURVE_TAG_ON */
+#define X_SHORT_VECTOR 0x02
+#define Y_SHORT_VECTOR 0x04
+#define REPEAT_FLAG 0x08
+#define X_POSITIVE 0x10 /* two meanings depending on X_SHORT_VECTOR */
+#define SAME_X 0x10
+#define Y_POSITIVE 0x20 /* two meanings depending on Y_SHORT_VECTOR */
+#define SAME_Y 0x20
+#define OVERLAP_SIMPLE 0x40 /* retained as FT_OUTLINE_OVERLAP */
+
+
+ /**************************************************************************
+ *
+ * Composite glyph flags.
+ */
#define ARGS_ARE_WORDS 0x0001
#define ARGS_ARE_XY_VALUES 0x0002
#define ROUND_XY_TO_GRID 0x0004
@@ -62,15 +76,24 @@
#define WE_HAVE_A_2X2 0x0080
#define WE_HAVE_INSTR 0x0100
#define USE_MY_METRICS 0x0200
-#define OVERLAP_COMPOUND 0x0400
+#define OVERLAP_COMPOUND 0x0400 /* retained as FT_OUTLINE_OVERLAP */
#define SCALED_COMPONENT_OFFSET 0x0800
#define UNSCALED_COMPONENT_OFFSET 0x1000
- /*************************************************************************/
- /* */
- /* Return the horizontal metrics in font units for a given glyph. */
- /* */
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+#define IS_DEFAULT_INSTANCE( _face ) \
+ ( !( FT_IS_NAMED_INSTANCE( _face ) || \
+ FT_IS_VARIATION( _face ) ) )
+#else
+#define IS_DEFAULT_INSTANCE( _face ) 1
+#endif
+
+
+ /**************************************************************************
+ *
+ * Return the horizontal metrics in font units for a given glyph.
+ */
FT_LOCAL_DEF( void )
TT_Get_HMetrics( TT_Face face,
FT_UInt idx,
@@ -84,11 +107,11 @@
}
- /*************************************************************************/
- /* */
- /* Return the vertical metrics in font units for a given glyph. */
- /* See function `tt_loader_set_pp' below for explanations. */
- /* */
+ /**************************************************************************
+ *
+ * Return the vertical metrics in font units for a given glyph.
+ * See function `tt_loader_set_pp' below for explanations.
+ */
FT_LOCAL_DEF( void )
TT_Get_VMetrics( TT_Face face,
FT_UInt idx,
@@ -113,6 +136,11 @@
face->horizontal.Descender );
}
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !face->vertical_info )
+ FT_TRACE5(( " [vertical metrics missing, computing values]\n" ));
+#endif
+
FT_TRACE5(( " advance height (font units): %d\n", *ah ));
FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
}
@@ -123,9 +151,6 @@
FT_UInt glyph_index )
{
TT_Face face = loader->face;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
-#endif
FT_Error error;
FT_Stream stream = loader->stream;
@@ -154,24 +179,17 @@
loader->top_bearing = top_bearing;
loader->vadvance = advance_height;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 &&
- loader->exec )
- {
- loader->exec->sph_tweak_flags = 0;
-
- /* This may not be the right place for this, but it works... */
- /* Note that we have to unconditionally load the tweaks since */
- /* it is possible that glyphs individually switch ClearType's */
- /* backward compatibility mode on and off. */
- sph_set_tweaks( loader, glyph_index );
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
- if ( !loader->linear_def )
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ /* With the incremental interface, these values are set by */
+ /* a call to `tt_get_metrics_incremental'. */
+ if ( face->root.internal->incremental_interface == NULL )
+#endif
{
- loader->linear_def = 1;
- loader->linear = advance_width;
+ if ( !loader->linear_def )
+ {
+ loader->linear_def = 1;
+ loader->linear = advance_width;
+ }
}
return FT_Err_Ok;
@@ -181,8 +199,8 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
static void
- tt_get_metrics_incr_overrides( TT_Loader loader,
- FT_UInt glyph_index )
+ tt_get_metrics_incremental( TT_Loader loader,
+ FT_UInt glyph_index )
{
TT_Face face = loader->face;
@@ -250,13 +268,13 @@
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- /*************************************************************************/
- /* */
- /* The following functions are used by default with TrueType fonts. */
- /* However, they can be replaced by alternatives if we need to support */
- /* TrueType-compressed formats (like MicroType) in the future. */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * The following functions are used by default with TrueType fonts.
+ * However, they can be replaced by alternatives if we need to support
+ * TrueType-compressed formats (like MicroType) in the future.
+ *
+ */
FT_CALLBACK_DEF( FT_Error )
TT_Access_Glyph_Frame( TT_Loader loader,
@@ -267,12 +285,9 @@
FT_Error error;
FT_Stream stream = loader->stream;
- /* for non-debug mode */
FT_UNUSED( glyph_index );
- FT_TRACE4(( "Glyph %ld\n", glyph_index ));
-
/* the following line sets the `error' variable through macros! */
if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) )
return error;
@@ -312,9 +327,9 @@
loader->bbox.yMax = FT_NEXT_SHORT( p );
FT_TRACE5(( " # of contours: %d\n", loader->n_contours ));
- FT_TRACE5(( " xMin: %4d xMax: %4d\n", loader->bbox.xMin,
+ FT_TRACE5(( " xMin: %4ld xMax: %4ld\n", loader->bbox.xMin,
loader->bbox.xMax ));
- FT_TRACE5(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin,
+ FT_TRACE5(( " yMin: %4ld yMax: %4ld\n", loader->bbox.yMin,
loader->bbox.yMax ));
loader->cursor = p;
@@ -329,17 +344,16 @@
FT_Byte* p = load->cursor;
FT_Byte* limit = load->limit;
FT_GlyphLoader gloader = load->gloader;
+ FT_Outline* outline = &gloader->current.outline;
FT_Int n_contours = load->n_contours;
- FT_Outline* outline;
- FT_UShort n_ins;
FT_Int n_points;
+ FT_UShort n_ins;
FT_Byte *flag, *flag_limit;
FT_Byte c, count;
FT_Vector *vec, *vec_limit;
- FT_Pos x;
- FT_Short *cont, *cont_limit, prev_cont;
- FT_Int xy_size = 0;
+ FT_Pos x, y;
+ FT_Short *cont, *cont_limit, last;
/* check that we can add the contours to the glyph */
@@ -347,99 +361,76 @@
if ( error )
goto Fail;
- /* reading the contours' endpoints & number of points */
- cont = gloader->current.outline.contours;
- cont_limit = cont + n_contours;
-
/* check space for contours array + instructions count */
- if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit )
+ if ( n_contours >= 0xFFF || p + 2 * n_contours + 2 > limit )
goto Invalid_Outline;
- prev_cont = FT_NEXT_SHORT( p );
-
- if ( n_contours > 0 )
- cont[0] = prev_cont;
-
- if ( prev_cont < 0 )
- goto Invalid_Outline;
+ /* reading the contours' endpoints & number of points */
+ cont = outline->contours;
+ cont_limit = cont + n_contours;
- for ( cont++; cont < cont_limit; cont++ )
+ last = -1;
+ for ( ; cont < cont_limit; cont++ )
{
- cont[0] = FT_NEXT_SHORT( p );
- if ( cont[0] <= prev_cont )
- {
- /* unordered contours: this is invalid */
- goto Invalid_Outline;
- }
- prev_cont = cont[0];
- }
+ *cont = FT_NEXT_SHORT( p );
- n_points = 0;
- if ( n_contours > 0 )
- {
- n_points = cont[-1] + 1;
- if ( n_points < 0 )
+ if ( *cont <= last )
goto Invalid_Outline;
+
+ last = *cont;
}
+ n_points = last + 1;
+
+ FT_TRACE5(( " # of points: %d\n", n_points ));
+
/* note that we will add four phantom points later */
error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 );
if ( error )
goto Fail;
- /* reading the bytecode instructions */
- load->glyph->control_len = 0;
- load->glyph->control_data = NULL;
-
- if ( p + 2 > limit )
- goto Invalid_Outline;
-
+ /* space checked above */
n_ins = FT_NEXT_USHORT( p );
FT_TRACE5(( " Instructions size: %u\n", n_ins ));
+ /* check instructions size */
+ if ( p + n_ins > limit )
+ {
+ FT_TRACE1(( "TT_Load_Simple_Glyph: excessive instruction count\n" ));
+ error = FT_THROW( Too_Many_Hints );
+ goto Fail;
+ }
+
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( IS_HINTED( load->load_flags ) )
{
- FT_ULong tmp;
+ TT_ExecContext exec = load->exec;
+ FT_Memory memory = exec->memory;
- /* check instructions size */
- if ( ( limit - p ) < n_ins )
- {
- FT_TRACE1(( "TT_Load_Simple_Glyph: instruction count mismatch\n" ));
- error = FT_THROW( Too_Many_Hints );
- goto Fail;
- }
+ if ( exec->glyphSize )
+ FT_FREE( exec->glyphIns );
+ exec->glyphSize = 0;
/* we don't trust `maxSizeOfInstructions' in the `maxp' table */
- /* and thus update the bytecode array size by ourselves */
-
- tmp = load->exec->glyphSize;
- error = Update_Max( load->exec->memory,
- &tmp,
- sizeof ( FT_Byte ),
- (void*)&load->exec->glyphIns,
- n_ins );
-
- load->exec->glyphSize = (FT_UShort)tmp;
- if ( error )
- return error;
+ /* and thus allocate the bytecode array size by ourselves */
+ if ( n_ins )
+ {
+ if ( FT_QNEW_ARRAY( exec->glyphIns, n_ins ) )
+ return error;
- load->glyph->control_len = n_ins;
- load->glyph->control_data = load->exec->glyphIns;
+ FT_MEM_COPY( exec->glyphIns, p, (FT_Long)n_ins );
- if ( n_ins )
- FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins );
+ exec->glyphSize = n_ins;
+ }
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
p += n_ins;
- outline = &gloader->current.outline;
-
/* reading the point tags */
flag = (FT_Byte*)outline->tags;
flag_limit = flag + n_points;
@@ -452,7 +443,7 @@
goto Invalid_Outline;
*flag++ = c = FT_NEXT_BYTE( p );
- if ( c & 8 )
+ if ( c & REPEAT_FLAG )
{
if ( p + 1 > limit )
goto Invalid_Outline;
@@ -466,6 +457,10 @@
}
}
+ /* retain the overlap flag */
+ if ( n_points && outline->tags[0] & OVERLAP_SIMPLE )
+ gloader->base.outline.flags |= FT_OUTLINE_OVERLAP;
+
/* reading the X coordinates */
vec = outline->points;
@@ -473,72 +468,68 @@
flag = (FT_Byte*)outline->tags;
x = 0;
- if ( p + xy_size > limit )
- goto Invalid_Outline;
-
for ( ; vec < vec_limit; vec++, flag++ )
{
- FT_Pos y = 0;
- FT_Byte f = *flag;
+ FT_Pos delta = 0;
+ FT_Byte f = *flag;
- if ( f & 2 )
+ if ( f & X_SHORT_VECTOR )
{
if ( p + 1 > limit )
goto Invalid_Outline;
- y = (FT_Pos)FT_NEXT_BYTE( p );
- if ( ( f & 16 ) == 0 )
- y = -y;
+ delta = (FT_Pos)FT_NEXT_BYTE( p );
+ if ( !( f & X_POSITIVE ) )
+ delta = -delta;
}
- else if ( ( f & 16 ) == 0 )
+ else if ( !( f & SAME_X ) )
{
if ( p + 2 > limit )
goto Invalid_Outline;
- y = (FT_Pos)FT_NEXT_SHORT( p );
+ delta = (FT_Pos)FT_NEXT_SHORT( p );
}
- x += y;
+ x += delta;
vec->x = x;
- /* the cast is for stupid compilers */
- *flag = (FT_Byte)( f & ~( 2 | 16 ) );
}
/* reading the Y coordinates */
- vec = gloader->current.outline.points;
+ vec = outline->points;
vec_limit = vec + n_points;
flag = (FT_Byte*)outline->tags;
- x = 0;
+ y = 0;
for ( ; vec < vec_limit; vec++, flag++ )
{
- FT_Pos y = 0;
- FT_Byte f = *flag;
+ FT_Pos delta = 0;
+ FT_Byte f = *flag;
- if ( f & 4 )
+ if ( f & Y_SHORT_VECTOR )
{
if ( p + 1 > limit )
goto Invalid_Outline;
- y = (FT_Pos)FT_NEXT_BYTE( p );
- if ( ( f & 32 ) == 0 )
- y = -y;
+ delta = (FT_Pos)FT_NEXT_BYTE( p );
+ if ( !( f & Y_POSITIVE ) )
+ delta = -delta;
}
- else if ( ( f & 32 ) == 0 )
+ else if ( !( f & SAME_Y ) )
{
if ( p + 2 > limit )
goto Invalid_Outline;
- y = (FT_Pos)FT_NEXT_SHORT( p );
+ delta = (FT_Pos)FT_NEXT_SHORT( p );
}
- x += y;
- vec->y = x;
+ y += delta;
+ vec->y = y;
+
/* the cast is for stupid compilers */
- *flag = (FT_Byte)( f & FT_CURVE_TAG_ON );
+ *flag = (FT_Byte)( f & ON_CURVE_POINT );
}
outline->n_points = (FT_Short)n_points;
@@ -559,9 +550,10 @@
TT_Load_Composite_Glyph( TT_Loader loader )
{
FT_Error error;
- FT_Byte* p = loader->cursor;
- FT_Byte* limit = loader->limit;
- FT_GlyphLoader gloader = loader->gloader;
+ FT_Byte* p = loader->cursor;
+ FT_Byte* limit = loader->limit;
+ FT_GlyphLoader gloader = loader->gloader;
+ FT_Long num_glyphs = loader->face->root.num_glyphs;
FT_SubGlyph subglyph;
FT_UInt num_subglyphs;
@@ -590,6 +582,11 @@
subglyph->flags = FT_NEXT_USHORT( p );
subglyph->index = FT_NEXT_USHORT( p );
+ /* we reject composites that have components */
+ /* with invalid glyph indices */
+ if ( subglyph->index >= num_glyphs )
+ goto Invalid_Composite;
+
/* check space */
count = 2;
if ( subglyph->flags & ARGS_ARE_WORDS )
@@ -693,18 +690,20 @@
if ( subglyph->flags & WE_HAVE_A_SCALE )
FT_TRACE7(( " scaling: %f\n",
- subglyph->transform.xx / 65536.0 ));
+ (double)subglyph->transform.xx / 65536 ));
else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
FT_TRACE7(( " scaling: x=%f, y=%f\n",
- subglyph->transform.xx / 65536.0,
- subglyph->transform.yy / 65536.0 ));
+ (double)subglyph->transform.xx / 65536,
+ (double)subglyph->transform.yy / 65536 ));
else if ( subglyph->flags & WE_HAVE_A_2X2 )
- FT_TRACE7(( " scaling: xx=%f, yx=%f\n"
- " xy=%f, yy=%f\n",
- subglyph->transform.xx / 65536.0,
- subglyph->transform.yx / 65536.0,
- subglyph->transform.xy / 65536.0,
- subglyph->transform.yy / 65536.0 ));
+ {
+ FT_TRACE7(( " scaling: xx=%f, yx=%f\n",
+ (double)subglyph->transform.xx / 65536,
+ (double)subglyph->transform.yx / 65536 ));
+ FT_TRACE7(( " xy=%f, yy=%f\n",
+ (double)subglyph->transform.xy / 65536,
+ (double)subglyph->transform.yy / 65536 ));
+ }
subglyph++;
}
@@ -755,7 +754,7 @@
FT_UInt start_point,
FT_UInt start_contour )
{
- zone->n_points = (FT_UShort)load->outline.n_points -
+ zone->n_points = (FT_UShort)load->outline.n_points + 4 -
(FT_UShort)start_point;
zone->n_contours = load->outline.n_contours -
(FT_Short)start_contour;
@@ -768,21 +767,20 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Hint_Glyph */
- /* */
- /* <Description> */
- /* Hint the glyph using the zone prepared by the caller. Note that */
- /* the zone is supposed to include four phantom points. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Hint_Glyph
+ *
+ * @Description:
+ * Hint the glyph using the zone prepared by the caller. Note that
+ * the zone is supposed to include four phantom points.
+ */
static FT_Error
TT_Hint_Glyph( TT_Loader loader,
FT_Bool is_composite )
{
-#if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \
- defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
TT_Face face = loader->face;
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
@@ -790,41 +788,34 @@
TT_GlyphZone zone = &loader->zone;
#ifdef TT_USE_BYTECODE_INTERPRETER
- FT_Long n_ins;
+ TT_ExecContext exec = loader->exec;
+ FT_Long n_ins = exec->glyphSize;
#else
FT_UNUSED( is_composite );
#endif
#ifdef TT_USE_BYTECODE_INTERPRETER
- if ( loader->glyph->control_len > 0xFFFFL )
- {
- FT_TRACE1(( "TT_Hint_Glyph: too long instructions" ));
- FT_TRACE1(( " (0x%lx byte) is truncated\n",
- loader->glyph->control_len ));
- }
- n_ins = loader->glyph->control_len;
-
- /* save original point position in org */
+ /* save original point positions in `org' array */
if ( n_ins > 0 )
FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
/* Reset graphics state. */
- loader->exec->GS = loader->size->GS;
+ exec->GS = loader->size->GS;
/* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
/* completely refer to the (already) hinted subglyphs. */
if ( is_composite )
{
- loader->exec->metrics.x_scale = 1 << 16;
- loader->exec->metrics.y_scale = 1 << 16;
+ exec->metrics.x_scale = 1 << 16;
+ exec->metrics.y_scale = 1 << 16;
FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points );
}
else
{
- loader->exec->metrics.x_scale = loader->size->metrics->x_scale;
- loader->exec->metrics.y_scale = loader->size->metrics->y_scale;
+ exec->metrics.x_scale = loader->size->metrics->x_scale;
+ exec->metrics.y_scale = loader->size->metrics->y_scale;
}
#endif
@@ -844,116 +835,87 @@
{
FT_Error error;
- FT_GlyphLoader gloader = loader->gloader;
- FT_Outline current_outline = gloader->current.outline;
+ TT_Set_CodeRange( exec, tt_coderange_glyph, exec->glyphIns, n_ins );
- TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
- loader->exec->glyphIns, n_ins );
+ exec->is_composite = is_composite;
+ exec->pts = *zone;
- loader->exec->is_composite = is_composite;
- loader->exec->pts = *zone;
-
- error = TT_Run_Context( loader->exec );
- if ( error && loader->exec->pedantic_hinting )
+ error = TT_Run_Context( exec );
+ if ( error && exec->pedantic_hinting )
return error;
/* store drop-out mode in bits 5-7; set bit 2 also as a marker */
- current_outline.tags[0] |=
- ( loader->exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE;
+ loader->gloader->current.outline.tags[0] |=
+ ( exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE;
}
#endif
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
/* Save possibly modified glyph phantom points unless in v40 backward */
/* compatibility mode, where no movement on the x axis means no reason */
/* to change bearings or advance widths. */
- if ( !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
- loader->exec->backward_compatibility ) )
- {
-#endif
- loader->pp1 = zone->cur[zone->n_points - 4];
- loader->pp2 = zone->cur[zone->n_points - 3];
- loader->pp3 = zone->cur[zone->n_points - 2];
- loader->pp4 = zone->cur[zone->n_points - 1];
+
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- }
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
+ exec->backward_compatibility )
+ return FT_Err_Ok;
#endif
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
- {
- if ( loader->exec->sph_tweak_flags & SPH_TWEAK_DEEMBOLDEN )
- FT_Outline_EmboldenXY( &loader->gloader->current.outline, -24, 0 );
-
- else if ( loader->exec->sph_tweak_flags & SPH_TWEAK_EMBOLDEN )
- FT_Outline_EmboldenXY( &loader->gloader->current.outline, 24, 0 );
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
+ loader->pp1 = zone->cur[zone->n_points - 4];
+ loader->pp2 = zone->cur[zone->n_points - 3];
+ loader->pp3 = zone->cur[zone->n_points - 2];
+ loader->pp4 = zone->cur[zone->n_points - 1];
return FT_Err_Ok;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Process_Simple_Glyph */
- /* */
- /* <Description> */
- /* Once a simple glyph has been loaded, it needs to be processed. */
- /* Usually, this means scaling and hinting through bytecode */
- /* interpretation. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Process_Simple_Glyph
+ *
+ * @Description:
+ * Once a simple glyph has been loaded, it needs to be processed.
+ * Usually, this means scaling and hinting through bytecode
+ * interpretation.
+ */
static FT_Error
TT_Process_Simple_Glyph( TT_Loader loader )
{
- FT_GlyphLoader gloader = loader->gloader;
- FT_Error error = FT_Err_Ok;
- FT_Outline* outline;
- FT_Int n_points;
+ FT_Error error = FT_Err_Ok;
+ FT_GlyphLoader gloader = loader->gloader;
+ FT_Outline* outline = &gloader->current.outline;
+ FT_Int n_points = outline->n_points;
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ FT_Memory memory = loader->face->root.memory;
+ FT_Vector* unrounded = NULL;
+#endif
- outline = &gloader->current.outline;
- n_points = outline->n_points;
/* set phantom points */
-
outline->points[n_points ] = loader->pp1;
outline->points[n_points + 1] = loader->pp2;
outline->points[n_points + 2] = loader->pp3;
outline->points[n_points + 3] = loader->pp4;
- outline->tags[n_points ] = 0;
- outline->tags[n_points + 1] = 0;
- outline->tags[n_points + 2] = 0;
- outline->tags[n_points + 3] = 0;
-
n_points += 4;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( FT_IS_NAMED_INSTANCE( FT_FACE( loader->face ) ) ||
- FT_IS_VARIATION( FT_FACE( loader->face ) ) )
+ if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) )
{
+ if ( FT_QNEW_ARRAY( unrounded, n_points ) )
+ goto Exit;
+
/* Deltas apply to the unscaled data. */
- error = TT_Vary_Apply_Glyph_Deltas( loader->face,
- loader->glyph_index,
+ error = TT_Vary_Apply_Glyph_Deltas( loader,
outline,
- (FT_UInt)n_points );
-
- /* recalculate linear horizontal and vertical advances */
- /* if we don't have HVAR and VVAR, respectively */
- if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
- loader->linear = outline->points[n_points - 3].x -
- outline->points[n_points - 4].x;
- if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
- loader->vadvance = outline->points[n_points - 1].x -
- outline->points[n_points - 2].x;
-
+ unrounded );
if ( error )
- return error;
+ goto Exit;
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
@@ -963,20 +925,10 @@
tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
- loader->zone.n_points + 4 );
+ loader->zone.n_points );
}
{
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- TT_Face face = loader->face;
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
-
- FT_String* family = face->root.family_name;
- FT_UInt ppem = loader->size->metrics->x_ppem;
- FT_String* style = face->root.style_name;
- FT_UInt x_scale_factor = 1000;
-#endif
-
FT_Vector* vec = outline->points;
FT_Vector* limit = outline->points + n_points;
@@ -986,39 +938,6 @@
FT_Bool do_scale = FALSE;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
- {
- /* scale, but only if enabled and only if TT hinting is being used */
- if ( IS_HINTED( loader->load_flags ) )
- x_scale_factor = sph_test_tweak_x_scaling( face,
- family,
- ppem,
- style,
- loader->glyph_index );
- /* scale the glyph */
- if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ||
- x_scale_factor != 1000 )
- {
- x_scale = FT_MulDiv( loader->size->metrics->x_scale,
- (FT_Long)x_scale_factor, 1000 );
- y_scale = loader->size->metrics->y_scale;
-
- /* compensate for any scaling by de/emboldening; */
- /* the amount was determined via experimentation */
- if ( x_scale_factor != 1000 && ppem > 11 )
- FT_Outline_EmboldenXY( outline,
- FT_MulFix( 1280 * ppem,
- 1000 - x_scale_factor ),
- 0 );
- do_scale = TRUE;
- }
- }
- else
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
{
/* scale the glyph */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
@@ -1032,17 +951,40 @@
if ( do_scale )
{
- for ( ; vec < limit; vec++ )
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) )
{
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
+ FT_Vector* u = unrounded;
+
+
+ for ( ; vec < limit; vec++, u++ )
+ {
+ vec->x = ADD_LONG( FT_MulFix( u->x, x_scale ), 32 ) >> 6;
+ vec->y = ADD_LONG( FT_MulFix( u->y, y_scale ), 32 ) >> 6;
+ }
+ }
+ else
+#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
+ {
+ for ( ; vec < limit; vec++ )
+ {
+ vec->x = FT_MulFix( vec->x, x_scale );
+ vec->y = FT_MulFix( vec->y, y_scale );
+ }
}
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* if we have a HVAR table, `pp1' and/or `pp2' are already adjusted */
- if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ||
- !IS_HINTED( loader->load_flags ) )
+ /* if we have a HVAR table, `pp1' and/or `pp2' */
+ /* are already adjusted but unscaled */
+ if ( ( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) &&
+ IS_HINTED( loader->load_flags ) )
+ {
+ loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
+ loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
+ /* pp1.y and pp2.y are always zero */
+ }
+ else
#endif
{
loader->pp1 = outline->points[n_points - 4];
@@ -1050,9 +992,17 @@
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /* if we have a VVAR table, `pp3' and/or `pp4' are already adjusted */
- if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ||
- !IS_HINTED( loader->load_flags ) )
+ /* if we have a VVAR table, `pp3' and/or `pp4' */
+ /* are already adjusted but unscaled */
+ if ( ( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) &&
+ IS_HINTED( loader->load_flags ) )
+ {
+ loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
+ loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
+ loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
+ loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
+ }
+ else
#endif
{
loader->pp3 = outline->points[n_points - 2];
@@ -1061,25 +1011,26 @@
}
if ( IS_HINTED( loader->load_flags ) )
- {
- loader->zone.n_points += 4;
-
error = TT_Hint_Glyph( loader, 0 );
- }
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ Exit:
+ FT_FREE( unrounded );
+#endif
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Process_Composite_Component */
- /* */
- /* <Description> */
- /* Once a composite component has been loaded, it needs to be */
- /* processed. Usually, this means transforming and translating. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Process_Composite_Component
+ *
+ * @Description:
+ * Once a composite component has been loaded, it needs to be
+ * processed. Usually, this means transforming and translating.
+ */
static FT_Error
TT_Process_Composite_Component( TT_Loader loader,
FT_SubGlyph subglyph,
@@ -1128,8 +1079,8 @@
p1 = gloader->base.outline.points + k;
p2 = gloader->base.outline.points + l;
- x = p1->x - p2->x;
- y = p1->y - p2->y;
+ x = SUB_LONG( p1->x, p2->x );
+ y = SUB_LONG( p1->y, p2->y );
}
else
{
@@ -1153,10 +1104,10 @@
#if 0
- /*******************************************************************/
- /* */
- /* This algorithm is what Apple documents. But it doesn't work. */
- /* */
+ /********************************************************************
+ *
+ * This algorithm is what Apple documents. But it doesn't work.
+ */
int a = subglyph->transform.xx > 0 ? subglyph->transform.xx
: -subglyph->transform.xx;
int b = subglyph->transform.yx > 0 ? subglyph->transform.yx
@@ -1178,10 +1129,10 @@
#else /* 1 */
- /*******************************************************************/
- /* */
- /* This algorithm is a guess and works much better than the above. */
- /* */
+ /********************************************************************
+ *
+ * This algorithm is a guess and works much better than the above.
+ */
FT_Fixed mac_xscale = FT_Hypot( subglyph->transform.xx,
subglyph->transform.xy );
FT_Fixed mac_yscale = FT_Hypot( subglyph->transform.yy,
@@ -1239,28 +1190,28 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Process_Composite_Glyph */
- /* */
- /* <Description> */
- /* This is slightly different from TT_Process_Simple_Glyph, in that */
- /* its sole purpose is to hint the glyph. Thus this function is */
- /* only available when bytecode interpreter is enabled. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Process_Composite_Glyph
+ *
+ * @Description:
+ * This is slightly different from TT_Process_Simple_Glyph, in that
+ * its sole purpose is to hint the glyph. Thus this function is
+ * only available when bytecode interpreter is enabled.
+ */
static FT_Error
TT_Process_Composite_Glyph( TT_Loader loader,
FT_UInt start_point,
FT_UInt start_contour )
{
FT_Error error;
- FT_Outline* outline;
+ FT_Outline* outline = &loader->gloader->base.outline;
+ FT_Stream stream = loader->stream;
+ FT_UShort n_ins;
FT_UInt i;
- outline = &loader->gloader->base.outline;
-
/* make room for phantom points */
error = FT_GLYPHLOADER_CHECK_POINTS( loader->gloader,
outline->n_points + 4,
@@ -1273,18 +1224,16 @@
outline->points[outline->n_points + 2] = loader->pp3;
outline->points[outline->n_points + 3] = loader->pp4;
- outline->tags[outline->n_points ] = 0;
- outline->tags[outline->n_points + 1] = 0;
- outline->tags[outline->n_points + 2] = 0;
- outline->tags[outline->n_points + 3] = 0;
-
#ifdef TT_USE_BYTECODE_INTERPRETER
{
- FT_Stream stream = loader->stream;
- FT_UShort n_ins, max_ins;
- FT_ULong tmp;
+ TT_ExecContext exec = loader->exec;
+ FT_Memory memory = exec->memory;
+
+ if ( exec->glyphSize )
+ FT_FREE( exec->glyphIns );
+ exec->glyphSize = 0;
/* TT_Load_Composite_Glyph only gives us the offset of instructions */
/* so we read them here */
@@ -1292,41 +1241,26 @@
FT_READ_USHORT( n_ins ) )
return error;
- FT_TRACE5(( " Instructions size = %d\n", n_ins ));
+ FT_TRACE5(( " Instructions size = %hu\n", n_ins ));
- /* check it */
- max_ins = loader->face->max_profile.maxSizeOfInstructions;
- if ( n_ins > max_ins )
- {
- /* don't trust `maxSizeOfInstructions'; */
- /* only do a rough safety check */
- if ( (FT_Int)n_ins > loader->byte_len )
- {
- FT_TRACE1(( "TT_Process_Composite_Glyph:"
- " too many instructions (%d) for glyph with length %d\n",
- n_ins, loader->byte_len ));
- return FT_THROW( Too_Many_Hints );
- }
-
- tmp = loader->exec->glyphSize;
- error = Update_Max( loader->exec->memory,
- &tmp,
- sizeof ( FT_Byte ),
- (void*)&loader->exec->glyphIns,
- n_ins );
+ if ( !n_ins )
+ return FT_Err_Ok;
- loader->exec->glyphSize = (FT_UShort)tmp;
- if ( error )
- return error;
+ /* don't trust `maxSizeOfInstructions'; */
+ /* only do a rough safety check */
+ if ( n_ins > loader->byte_len )
+ {
+ FT_TRACE1(( "TT_Process_Composite_Glyph:"
+ " too many instructions (%hu) for glyph with length %u\n",
+ n_ins, loader->byte_len ));
+ return FT_THROW( Too_Many_Hints );
}
- else if ( n_ins == 0 )
- return FT_Err_Ok;
- if ( FT_STREAM_READ( loader->exec->glyphIns, n_ins ) )
+ if ( FT_QNEW_ARRAY( exec->glyphIns, n_ins ) ||
+ FT_STREAM_READ( exec->glyphIns, n_ins ) )
return error;
- loader->glyph->control_data = loader->exec->glyphIns;
- loader->glyph->control_len = n_ins;
+ exec->glyphSize = n_ins;
}
#endif
@@ -1336,11 +1270,9 @@
/* Some points are likely touched during execution of */
/* instructions on components. So let's untouch them. */
- for ( i = 0; i < loader->zone.n_points; i++ )
+ for ( i = 0; i < loader->zone.n_points - 4U; i++ )
loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
- loader->zone.n_points += 4;
-
return TT_Hint_Glyph( loader, 1 );
}
@@ -1432,45 +1364,31 @@
static void
tt_loader_set_pp( TT_Loader loader )
{
- FT_Bool subpixel_hinting = 0;
- FT_Bool grayscale = 0;
- FT_Bool use_aw_2 = 0;
-
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( loader->face );
-#endif
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
- {
- subpixel_hinting = loader->exec ? loader->exec->subpixel_hinting
- : 0;
- grayscale = loader->exec ? loader->exec->grayscale
- : 0;
- }
-#endif
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
- {
- subpixel_hinting = loader->exec ? loader->exec->subpixel_hinting_lean
- : 0;
- grayscale = loader->exec ? loader->exec->grayscale_cleartype
- : 0;
- }
-#endif
-
- use_aw_2 = (FT_Bool)( subpixel_hinting && grayscale );
-
loader->pp1.x = loader->bbox.xMin - loader->left_bearing;
loader->pp1.y = 0;
loader->pp2.x = loader->pp1.x + loader->advance;
loader->pp2.y = 0;
- loader->pp3.x = use_aw_2 ? loader->advance / 2 : 0;
+ loader->pp3.x = 0;
loader->pp3.y = loader->bbox.yMax + loader->top_bearing;
- loader->pp4.x = use_aw_2 ? loader->advance / 2 : 0;
+ loader->pp4.x = 0;
loader->pp4.y = loader->pp3.y - loader->vadvance;
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ {
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( loader->face );
+
+
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
+ loader->exec &&
+ loader->exec->subpixel_hinting_lean &&
+ loader->exec->grayscale_cleartype )
+ {
+ loader->pp3.x = loader->advance / 2;
+ loader->pp4.x = loader->advance / 2;
+ }
+ }
+#endif
}
@@ -1497,27 +1415,28 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* load_truetype_glyph */
- /* */
- /* <Description> */
- /* Loads a given truetype glyph. Handles composites and uses a */
- /* TT_Loader object. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * load_truetype_glyph
+ *
+ * @Description:
+ * Loads a given truetype glyph. Handles composites and uses a
+ * TT_Loader object.
+ */
static FT_Error
load_truetype_glyph( TT_Loader loader,
FT_UInt glyph_index,
FT_UInt recurse_count,
FT_Bool header_only )
{
- FT_Error error = FT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Fixed x_scale, y_scale;
FT_ULong offset;
- TT_Face face = loader->face;
- FT_GlyphLoader gloader = loader->gloader;
- FT_Bool opened_frame = 0;
+ TT_Face face = loader->face;
+ FT_GlyphLoader gloader = loader->gloader;
+
+ FT_Bool opened_frame = 0;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_StreamRec inc_stream;
@@ -1550,15 +1469,15 @@
loader->glyph_index = glyph_index;
- if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
+ if ( loader->load_flags & FT_LOAD_NO_SCALE )
{
- x_scale = loader->size->metrics->x_scale;
- y_scale = loader->size->metrics->y_scale;
+ x_scale = 0x10000L;
+ y_scale = 0x10000L;
}
else
{
- x_scale = 0x10000L;
- y_scale = 0x10000L;
+ x_scale = loader->size->metrics->x_scale;
+ y_scale = loader->size->metrics->y_scale;
}
/* Set `offset' to the start of the glyph relative to the start of */
@@ -1585,16 +1504,21 @@
FT_ZERO( &inc_stream );
FT_Stream_OpenMemory( &inc_stream,
glyph_data.pointer,
- (FT_ULong)glyph_data.length );
+ glyph_data.length );
loader->stream = &inc_stream;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+ {
+ FT_ULong len;
+
- offset = tt_face_get_location( face, glyph_index,
- (FT_UInt*)&loader->byte_len );
+ offset = tt_face_get_location( FT_FACE( face ), glyph_index, &len );
+
+ loader->byte_len = (FT_UInt)len;
+ }
if ( loader->byte_len > 0 )
{
@@ -1613,49 +1537,45 @@
error = face->access_glyph_frame( loader, glyph_index,
face->glyf_offset + offset,
- (FT_UInt)loader->byte_len );
+ loader->byte_len );
if ( error )
goto Exit;
- opened_frame = 1;
-
/* read glyph header first */
error = face->read_glyph_header( loader );
- if ( error )
- goto Exit;
- /* the metrics must be computed after loading the glyph header */
- /* since we need the glyph's `yMax' value in case the vertical */
- /* metrics must be emulated */
- error = tt_get_metrics( loader, glyph_index );
- if ( error )
- goto Exit;
+ face->forget_glyph_frame( loader );
- if ( header_only )
+ if ( error )
goto Exit;
}
+ /* a space glyph */
if ( loader->byte_len == 0 || loader->n_contours == 0 )
{
loader->bbox.xMin = 0;
loader->bbox.xMax = 0;
loader->bbox.yMin = 0;
loader->bbox.yMax = 0;
+ }
- error = tt_get_metrics( loader, glyph_index );
- if ( error )
- goto Exit;
-
- if ( header_only )
- goto Exit;
+ /* the metrics must be computed after loading the glyph header */
+ /* since we need the glyph's `yMax' value in case the vertical */
+ /* metrics must be emulated */
+ error = tt_get_metrics( loader, glyph_index );
+ if ( error )
+ goto Exit;
- /* must initialize points before (possibly) overriding */
- /* glyph metrics from the incremental interface */
- tt_loader_set_pp( loader );
+ if ( header_only )
+ goto Exit;
+ if ( loader->byte_len == 0 || loader->n_contours == 0 )
+ {
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- tt_get_metrics_incr_overrides( loader, glyph_index );
+ tt_get_metrics_incremental( loader, glyph_index );
#endif
+ tt_loader_set_pp( loader );
+
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
@@ -1665,52 +1585,29 @@
/* a small outline structure with four elements for */
/* communication with `TT_Vary_Apply_Glyph_Deltas' */
FT_Vector points[4];
- char tags[4] = { 1, 1, 1, 1 };
- short contours[4] = { 0, 1, 2, 3 };
FT_Outline outline;
+ /* unrounded values */
+ FT_Vector unrounded[4] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} };
- points[0].x = loader->pp1.x;
- points[0].y = loader->pp1.y;
- points[1].x = loader->pp2.x;
- points[1].y = loader->pp2.y;
- points[2].x = loader->pp3.x;
- points[2].y = loader->pp3.y;
- points[3].x = loader->pp4.x;
- points[3].y = loader->pp4.y;
+ points[0] = loader->pp1;
+ points[1] = loader->pp2;
+ points[2] = loader->pp3;
+ points[3] = loader->pp4;
- outline.n_points = 4;
- outline.n_contours = 4;
+ outline.n_points = 0;
+ outline.n_contours = 0;
outline.points = points;
- outline.tags = tags;
- outline.contours = contours;
+ outline.tags = NULL;
+ outline.contours = NULL;
/* this must be done before scaling */
- error = TT_Vary_Apply_Glyph_Deltas( loader->face,
- glyph_index,
+ error = TT_Vary_Apply_Glyph_Deltas( loader,
&outline,
- (FT_UInt)outline.n_points );
+ unrounded );
if ( error )
goto Exit;
-
- loader->pp1.x = points[0].x;
- loader->pp1.y = points[0].y;
- loader->pp2.x = points[1].x;
- loader->pp2.y = points[1].y;
-
- loader->pp3.x = points[2].x;
- loader->pp3.y = points[2].y;
- loader->pp4.x = points[3].x;
- loader->pp4.y = points[3].y;
-
-
- /* recalculate linear horizontal and vertical advances */
- /* if we don't have HVAR and VVAR, respectively */
- if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
- loader->linear = loader->pp2.x - loader->pp1.x;
- if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
- loader->vadvance = loader->pp4.x - loader->pp3.x;
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
@@ -1733,18 +1630,26 @@
goto Exit;
}
- /* must initialize phantom points before (possibly) overriding */
- /* glyph metrics from the incremental interface */
- tt_loader_set_pp( loader );
-
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- tt_get_metrics_incr_overrides( loader, glyph_index );
+ tt_get_metrics_incremental( loader, glyph_index );
#endif
+ tt_loader_set_pp( loader );
+
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
+ /* we now open a frame again, right after the glyph header */
+ /* (which consists of 10 bytes) */
+ error = face->access_glyph_frame( loader, glyph_index,
+ face->glyf_offset + offset + 10,
+ loader->byte_len - 10 );
+ if ( error )
+ goto Exit;
+
+ opened_frame = 1;
+
/* if it is a simple glyph, load it */
if ( loader->n_contours > 0 )
@@ -1790,11 +1695,10 @@
* pointers with a width of at least 32 bits.
*/
-
/* clear the nodes filled by sibling chains */
node = ft_list_get_node_at( &loader->composites, recurse_count );
for ( node2 = node; node2; node2 = node2->next )
- node2->data = (void*)FT_ULONG_MAX;
+ node2->data = (void*)-1;
/* check whether we already have a composite glyph with this index */
if ( FT_List_Find( &loader->composites,
@@ -1811,7 +1715,7 @@
else
{
- if ( FT_NEW( node ) )
+ if ( FT_QNEW( node ) )
goto Exit;
node->data = FT_UINT_TO_POINTER( glyph_index );
FT_List_Add( &loader->composites, node );
@@ -1840,28 +1744,22 @@
short i, limit;
FT_SubGlyph subglyph;
- FT_Outline outline;
- FT_Vector* points = NULL;
- char* tags = NULL;
- short* contours = NULL;
+ FT_Outline outline = { 0, 0, NULL, NULL, NULL, 0 };
+ FT_Vector* unrounded = NULL;
limit = (short)gloader->current.num_subglyphs;
/* construct an outline structure for */
/* communication with `TT_Vary_Apply_Glyph_Deltas' */
- outline.n_points = (short)( gloader->current.num_subglyphs + 4 );
- outline.n_contours = outline.n_points;
-
- outline.points = NULL;
- outline.tags = NULL;
- outline.contours = NULL;
-
- if ( FT_NEW_ARRAY( points, outline.n_points ) ||
- FT_NEW_ARRAY( tags, outline.n_points ) ||
- FT_NEW_ARRAY( contours, outline.n_points ) )
+ if ( FT_QNEW_ARRAY( outline.points, limit + 4 ) ||
+ FT_QNEW_ARRAY( outline.tags, limit ) ||
+ FT_QNEW_ARRAY( outline.contours, limit ) ||
+ FT_QNEW_ARRAY( unrounded, limit + 4 ) )
goto Exit1;
+ outline.n_contours = outline.n_points = limit;
+
subglyph = gloader->current.subglyphs;
for ( i = 0; i < limit; i++, subglyph++ )
@@ -1869,46 +1767,22 @@
/* applying deltas for anchor points doesn't make sense, */
/* but we don't have to specially check this since */
/* unused delta values are zero anyways */
- points[i].x = subglyph->arg1;
- points[i].y = subglyph->arg2;
- tags[i] = 1;
- contours[i] = i;
+ outline.points[i].x = subglyph->arg1;
+ outline.points[i].y = subglyph->arg2;
+ outline.tags[i] = ON_CURVE_POINT;
+ outline.contours[i] = i;
}
- points[i].x = loader->pp1.x;
- points[i].y = loader->pp1.y;
- tags[i] = 1;
- contours[i] = i;
-
- i++;
- points[i].x = loader->pp2.x;
- points[i].y = loader->pp2.y;
- tags[i] = 1;
- contours[i] = i;
-
- i++;
- points[i].x = loader->pp3.x;
- points[i].y = loader->pp3.y;
- tags[i] = 1;
- contours[i] = i;
-
- i++;
- points[i].x = loader->pp4.x;
- points[i].y = loader->pp4.y;
- tags[i] = 1;
- contours[i] = i;
-
- outline.points = points;
- outline.tags = tags;
- outline.contours = contours;
+ outline.points[i++] = loader->pp1;
+ outline.points[i++] = loader->pp2;
+ outline.points[i++] = loader->pp3;
+ outline.points[i ] = loader->pp4;
/* this call provides additional offsets */
/* for each component's translation */
- if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
- face,
- glyph_index,
- &outline,
- (FT_UInt)outline.n_points ) ) )
+ if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( loader,
+ &outline,
+ unrounded ) ) )
goto Exit1;
subglyph = gloader->current.subglyphs;
@@ -1917,32 +1791,16 @@
{
if ( subglyph->flags & ARGS_ARE_XY_VALUES )
{
- subglyph->arg1 = (FT_Int16)points[i].x;
- subglyph->arg2 = (FT_Int16)points[i].y;
+ subglyph->arg1 = (FT_Int16)outline.points[i].x;
+ subglyph->arg2 = (FT_Int16)outline.points[i].y;
}
}
- loader->pp1.x = points[i + 0].x;
- loader->pp1.y = points[i + 0].y;
- loader->pp2.x = points[i + 1].x;
- loader->pp2.y = points[i + 1].y;
-
- loader->pp3.x = points[i + 2].x;
- loader->pp3.y = points[i + 2].y;
- loader->pp4.x = points[i + 3].x;
- loader->pp4.y = points[i + 3].y;
-
- /* recalculate linear horizontal and vertical advances */
- /* if we don't have HVAR and VVAR, respectively */
- if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
- loader->linear = loader->pp2.x - loader->pp1.x;
- if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
- loader->vadvance = loader->pp4.x - loader->pp3.x;
-
Exit1:
FT_FREE( outline.points );
FT_FREE( outline.tags );
FT_FREE( outline.contours );
+ FT_FREE( unrounded );
if ( error )
goto Exit;
@@ -1988,7 +1846,7 @@
FT_UInt num_base_subgs = gloader->base.num_subglyphs;
FT_Stream old_stream = loader->stream;
- FT_Int old_byte_len = loader->byte_len;
+ FT_UInt old_byte_len = loader->byte_len;
FT_GlyphLoader_Add( gloader );
@@ -2002,7 +1860,7 @@
FT_Int linear_vadvance;
- /* Each time we call load_truetype_glyph in this loop, the */
+ /* Each time we call `load_truetype_glyph' in this loop, the */
/* value of `gloader.base.subglyphs' can change due to table */
/* reallocations. We thus need to recompute the subglyph */
/* pointer on each iteration. */
@@ -2045,12 +1903,14 @@
if ( num_points == num_base_points )
continue;
- /* gloader->base.outline consists of three parts: */
- /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
- /* */
- /* (1): exists from the beginning */
- /* (2): components that have been loaded so far */
- /* (3): the newly loaded component */
+ /* gloader->base.outline consists of three parts: */
+ /* */
+ /* 0 ----> start_point ----> num_base_points ----> n_points */
+ /* (1) (2) (3) */
+ /* */
+ /* (1) points that exist from the beginning */
+ /* (2) component points that have been loaded so far */
+ /* (3) points of the newly loaded component */
error = TT_Process_Composite_Component( loader,
subglyph,
start_point,
@@ -2066,6 +1926,7 @@
loader->ins_pos = ins_pos;
if ( IS_HINTED( loader->load_flags ) &&
#ifdef TT_USE_BYTECODE_INTERPRETER
+ subglyph &&
subglyph->flags & WE_HAVE_INSTR &&
#endif
num_points > start_point )
@@ -2077,6 +1938,11 @@
goto Exit;
}
}
+
+ /* retain the overlap flag */
+ if ( gloader->base.num_subglyphs &&
+ gloader->base.subglyphs[0].flags & OVERLAP_COMPOUND )
+ gloader->base.outline.flags |= FT_OUTLINE_OVERLAP;
}
/***********************************************************************/
@@ -2105,16 +1971,11 @@
compute_glyph_metrics( TT_Loader loader,
FT_UInt glyph_index )
{
- TT_Face face = loader->face;
-#if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \
- defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
-#endif
-
+ TT_Face face = loader->face;
+ TT_Size size = loader->size;
+ TT_GlyphSlot glyph = loader->glyph;
FT_BBox bbox;
FT_Fixed y_scale;
- TT_GlyphSlot glyph = loader->glyph;
- TT_Size size = loader->size;
y_scale = 0x10000L;
@@ -2132,53 +1993,10 @@
glyph->metrics.horiBearingX = bbox.xMin;
glyph->metrics.horiBearingY = bbox.yMax;
- glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
-
- /* Adjust advance width to the value contained in the hdmx table */
- /* unless FT_LOAD_COMPUTE_METRICS is set or backward compatibility */
- /* mode of the v40 interpreter is active. See `ttinterp.h' for */
- /* details on backward compatibility mode. */
- if (
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
- ( loader->exec && loader->exec->backward_compatibility ) ) &&
-#endif
- !face->postscript.isFixedPitch &&
- IS_HINTED( loader->load_flags ) &&
- !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) )
- {
- FT_Byte* widthp;
-
-
- widthp = tt_face_get_device_metrics( face,
- size->metrics->x_ppem,
- glyph_index );
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
- {
- FT_Bool ignore_x_mode;
-
-
- ignore_x_mode = FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags ) !=
- FT_RENDER_MODE_MONO );
-
- if ( widthp &&
- ( ( ignore_x_mode && loader->exec->compatible_widths ) ||
- !ignore_x_mode ||
- SPH_OPTION_BITMAP_WIDTHS ) )
- glyph->metrics.horiAdvance = *widthp * 64;
- }
- else
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
- {
- if ( widthp )
- glyph->metrics.horiAdvance = *widthp * 64;
- }
- }
+ if ( loader->widthp )
+ glyph->metrics.horiAdvance = loader->widthp[glyph_index] * 64;
+ else
+ glyph->metrics.horiAdvance = SUB_LONG( loader->pp2.x, loader->pp1.x );
/* set glyph dimensions */
glyph->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin );
@@ -2196,13 +2014,14 @@
if ( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 )
{
- top = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax,
+ top = (FT_Short)FT_DivFix( SUB_LONG( loader->pp3.y, bbox.yMax ),
y_scale );
if ( loader->pp3.y <= loader->pp4.y )
advance = 0;
else
- advance = (FT_UShort)FT_DivFix( loader->pp3.y - loader->pp4.y,
+ advance = (FT_UShort)FT_DivFix( SUB_LONG( loader->pp3.y,
+ loader->pp4.y ),
y_scale );
}
else
@@ -2276,13 +2095,13 @@
/* XXX: for now, we have no better algorithm for the lsb, but it */
/* should work fine. */
/* */
- glyph->metrics.vertBearingX = glyph->metrics.horiBearingX -
- glyph->metrics.horiAdvance / 2;
+ glyph->metrics.vertBearingX = SUB_LONG( glyph->metrics.horiBearingX,
+ glyph->metrics.horiAdvance / 2 );
glyph->metrics.vertBearingY = top;
glyph->metrics.vertAdvance = advance;
}
- return 0;
+ return FT_Err_Ok;
}
@@ -2294,17 +2113,13 @@
FT_UInt glyph_index,
FT_Int32 load_flags )
{
- TT_Face face;
- SFNT_Service sfnt;
- FT_Stream stream;
+ TT_Face face = (TT_Face)glyph->face;
+ SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+ FT_Stream stream = face->root.stream;
FT_Error error;
TT_SBit_MetricsRec sbit_metrics;
- face = (TT_Face)glyph->face;
- sfnt = (SFNT_Service)face->sfnt;
- stream = face->root.stream;
-
error = sfnt->load_sbit_image( face,
size->strike_index,
glyph_index,
@@ -2355,22 +2170,18 @@
FT_Int32 load_flags,
FT_Bool glyf_table_only )
{
- TT_Face face;
- FT_Stream stream;
+ TT_Face face = (TT_Face)glyph->face;
+ FT_Stream stream = face->root.stream;
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_Error error;
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->face );
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( glyph->face );
#endif
#endif
- face = (TT_Face)glyph->face;
- stream = face->root.stream;
-
FT_ZERO( loader );
#ifdef TT_USE_BYTECODE_INTERPRETER
@@ -2385,20 +2196,6 @@
FT_Bool grayscale_cleartype;
#endif
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- FT_Bool subpixel_hinting = FALSE;
-
-#if 0
- /* not used yet */
- FT_Bool compatible_widths;
- FT_Bool symmetrical_smoothing;
- FT_Bool bgr;
- FT_Bool vertical_lcd;
- FT_Bool subpixel_positioned;
- FT_Bool gray_cleartype;
-#endif
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
FT_Bool reexecute = FALSE;
@@ -2418,6 +2215,9 @@
if ( !exec )
return FT_THROW( Could_Not_Find_Context );
+ grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+ FT_RENDER_MODE_MONO );
+
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
{
@@ -2434,6 +2234,7 @@
FT_BOOL( subpixel_hinting_lean &&
( load_flags &
FT_LOAD_TARGET_LCD_V ) );
+ grayscale = FT_BOOL( grayscale && !subpixel_hinting_lean );
}
else
{
@@ -2443,111 +2244,11 @@
}
#endif
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
- {
- subpixel_hinting = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags ) !=
- FT_RENDER_MODE_MONO ) &&
- SPH_OPTION_SET_SUBPIXEL );
-
- if ( subpixel_hinting )
- grayscale = FALSE;
- else if ( SPH_OPTION_SET_GRAYSCALE )
- {
- grayscale = TRUE;
- subpixel_hinting = FALSE;
- }
- else
- grayscale = FALSE;
-
- if ( FT_IS_TRICKY( glyph->face ) )
- subpixel_hinting = FALSE;
-
- exec->ignore_x_mode = subpixel_hinting || grayscale;
- exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
- if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
- exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
-
-#if 1
- exec->compatible_widths = SPH_OPTION_SET_COMPATIBLE_WIDTHS;
- exec->symmetrical_smoothing = TRUE;
- exec->bgr = FALSE;
- exec->vertical_lcd = FALSE;
- exec->subpixel_positioned = TRUE;
- exec->gray_cleartype = FALSE;
-#else /* 0 */
- exec->compatible_widths =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- TT_LOAD_COMPATIBLE_WIDTHS );
- exec->symmetrical_smoothing =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- TT_LOAD_SYMMETRICAL_SMOOTHING );
- exec->bgr =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- TT_LOAD_BGR );
- exec->vertical_lcd =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- TT_LOAD_VERTICAL_LCD );
- exec->subpixel_positioned =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- TT_LOAD_SUBPIXEL_POSITIONED );
- exec->gray_cleartype =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- TT_LOAD_GRAY_CLEARTYPE );
-#endif /* 0 */
-
- }
- else
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
- grayscale = FT_BOOL( !subpixel_hinting_lean &&
- FT_LOAD_TARGET_MODE( load_flags ) !=
- FT_RENDER_MODE_MONO );
- else
-#endif
- grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- FT_RENDER_MODE_MONO );
-
error = TT_Load_Context( exec, face, size );
if ( error )
return error;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
- {
- /* a change from mono to subpixel rendering (and vice versa) */
- /* requires a re-execution of the CVT program */
- if ( subpixel_hinting != exec->subpixel_hinting )
- {
- FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
- " re-executing `prep' table\n" ));
-
- exec->subpixel_hinting = subpixel_hinting;
- reexecute = TRUE;
- }
-
- /* a change from mono to grayscale rendering (and vice versa) */
- /* requires a re-execution of the CVT program */
- if ( grayscale != exec->grayscale )
- {
- FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
- " re-executing `prep' table\n" ));
-
- exec->grayscale = grayscale;
- reexecute = TRUE;
- }
- }
- else
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
{
-
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
{
@@ -2589,14 +2290,12 @@
if ( reexecute )
{
- FT_UInt i;
-
-
- for ( i = 0; i < size->cvt_size; i++ )
- size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
error = tt_size_run_prep( size, pedantic );
if ( error )
return error;
+ error = TT_Load_Context( exec, face, size );
+ if ( error )
+ return error;
}
/* check whether the cvt program has disabled hinting */
@@ -2607,17 +2306,48 @@
if ( exec->GS.instruct_control & 2 )
exec->GS = tt_default_graphics_state;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* check whether we have a font hinted for ClearType -- */
- /* note that this flag can also be modified in a glyph's bytecode */
- if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 &&
- exec->GS.instruct_control & 4 )
- exec->ignore_x_mode = 0;
-#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /*
+ * Toggle backward compatibility according to what font wants, except
+ * when
+ *
+ * 1) we have a `tricky' font that heavily relies on the interpreter to
+ * render glyphs correctly, for example DFKai-SB, or
+ * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested.
+ *
+ * In those cases, backward compatibility needs to be turned off to get
+ * correct rendering. The rendering is then completely up to the
+ * font's programming.
+ *
+ */
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
+ subpixel_hinting_lean &&
+ !FT_IS_TRICKY( glyph->face ) )
+ exec->backward_compatibility = !( exec->GS.instruct_control & 4 );
+ else
+ exec->backward_compatibility = FALSE;
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */
exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
loader->exec = exec;
loader->instructions = exec->glyphIns;
+
+ /* Use the hdmx table if any unless FT_LOAD_COMPUTE_METRICS */
+ /* is set or backward compatibility mode of the v38 or v40 */
+ /* interpreters is active. See `ttinterp.h' for details on */
+ /* backward compatibility mode. */
+ if ( IS_HINTED( loader->load_flags ) &&
+ !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 &&
+ exec->backward_compatibility ) &&
+#endif
+ !face->postscript.isFixedPitch )
+ {
+ loader->widthp = size->widthp;
+ }
+ else
+ loader->widthp = NULL;
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
@@ -2656,49 +2386,48 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Load_Glyph */
- /* */
- /* <Description> */
- /* A function used to load a single glyph within a given glyph slot, */
- /* for a given size. */
- /* */
- /* <Input> */
- /* glyph :: A handle to a target slot object where the glyph */
- /* will be loaded. */
- /* */
- /* size :: A handle to the source face size at which the glyph */
- /* must be scaled/loaded. */
- /* */
- /* glyph_index :: The index of the glyph in the font file. */
- /* */
- /* load_flags :: A flag indicating what to load for this glyph. The */
- /* FT_LOAD_XXX constants can be used to control the */
- /* glyph loading process (e.g., whether the outline */
- /* should be scaled, whether to load bitmaps or not, */
- /* whether to hint the outline, etc). */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Load_Glyph
+ *
+ * @Description:
+ * A function used to load a single glyph within a given glyph slot,
+ * for a given size.
+ *
+ * @InOut:
+ * glyph ::
+ * A handle to a target slot object where the glyph
+ * will be loaded.
+ *
+ * @Input:
+ * size ::
+ * A handle to the source face size at which the glyph
+ * must be scaled/loaded.
+ *
+ * glyph_index ::
+ * The index of the glyph in the font file.
+ *
+ * load_flags ::
+ * A flag indicating what to load for this glyph. The
+ * FT_LOAD_XXX constants can be used to control the
+ * glyph loading process (e.g., whether the outline
+ * should be scaled, whether to load bitmaps or not,
+ * whether to hint the outline, etc).
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
TT_Load_Glyph( TT_Size size,
TT_GlyphSlot glyph,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
+ TT_Face face = (TT_Face)glyph->face;
FT_Error error;
TT_LoaderRec loader;
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#define IS_DEFAULT_INSTANCE ( !( FT_IS_NAMED_INSTANCE( glyph->face ) || \
- FT_IS_VARIATION( glyph->face ) ) )
-#else
-#define IS_DEFAULT_INSTANCE 1
-#endif
-
FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
@@ -2707,7 +2436,7 @@
/* try to load embedded bitmap (if any) */
if ( size->strike_index != 0xFFFFFFFFUL &&
( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
- IS_DEFAULT_INSTANCE )
+ IS_DEFAULT_INSTANCE( glyph->face ) )
{
FT_Fixed x_scale = size->root.metrics.x_scale;
FT_Fixed y_scale = size->root.metrics.y_scale;
@@ -2720,8 +2449,6 @@
/* if we have a bitmap-only font, return an empty glyph */
if ( !FT_IS_SCALABLE( glyph->face ) )
{
- TT_Face face = (TT_Face)glyph->face;
-
FT_Short left_bearing = 0;
FT_Short top_bearing = 0;
@@ -2777,7 +2504,8 @@
}
else
{
- if ( FT_IS_SCALABLE( glyph->face ) )
+ if ( FT_IS_SCALABLE( glyph->face ) ||
+ FT_HAS_SBIX( glyph->face ) )
{
/* for the bbox we need the header only */
(void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
@@ -2786,6 +2514,35 @@
glyph->linearHoriAdvance = loader.linear;
glyph->linearVertAdvance = loader.vadvance;
+ /* Bitmaps from the 'sbix' table need special treatment: */
+ /* if there is a glyph contour, the bitmap origin must be */
+ /* shifted to be relative to the lower left corner of the */
+ /* glyph bounding box, also taking the left-side bearing */
+ /* (or top bearing) into account. */
+ if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX &&
+ loader.n_contours > 0 )
+ {
+ FT_Int bitmap_left;
+ FT_Int bitmap_top;
+
+
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ {
+ /* This is a guess, since Apple's CoreText engine doesn't */
+ /* really do vertical typesetting. */
+ bitmap_left = loader.bbox.xMin;
+ bitmap_top = loader.top_bearing;
+ }
+ else
+ {
+ bitmap_left = loader.left_bearing;
+ bitmap_top = loader.bbox.yMin;
+ }
+
+ glyph->bitmap_left += FT_MulFix( bitmap_left, x_scale ) >> 6;
+ glyph->bitmap_top += FT_MulFix( bitmap_top, y_scale ) >> 6;
+ }
+
/* sanity checks: if `xxxAdvance' in the sbit metric */
/* structure isn't set, use `linearXXXAdvance' */
if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
@@ -2800,6 +2557,12 @@
}
}
+ if ( load_flags & FT_LOAD_SBITS_ONLY )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
@@ -2809,16 +2572,79 @@
goto Exit;
}
- if ( load_flags & FT_LOAD_SBITS_ONLY )
+#ifdef FT_CONFIG_OPTION_SVG
+
+ /* check for OT-SVG */
+ if ( ( load_flags & FT_LOAD_NO_SVG ) == 0 &&
+ ( load_flags & FT_LOAD_COLOR ) &&
+ face->svg )
+ {
+ SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+
+
+ FT_TRACE3(( "Trying to load SVG glyph\n" ));
+
+ error = sfnt->load_svg_doc( glyph, glyph_index );
+ if ( !error )
+ {
+ FT_Fixed x_scale = size->root.metrics.x_scale;
+ FT_Fixed y_scale = size->root.metrics.y_scale;
+
+ FT_Short leftBearing;
+ FT_Short topBearing;
+ FT_UShort advanceX;
+ FT_UShort advanceY;
+
+
+ FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
+
+ glyph->format = FT_GLYPH_FORMAT_SVG;
+
+ sfnt->get_metrics( face,
+ FALSE,
+ glyph_index,
+ &leftBearing,
+ &advanceX );
+ sfnt->get_metrics( face,
+ TRUE,
+ glyph_index,
+ &topBearing,
+ &advanceY );
+
+ glyph->linearHoriAdvance = advanceX;
+ glyph->linearVertAdvance = advanceY;
+
+ glyph->metrics.horiAdvance = FT_MulFix( advanceX, x_scale );
+ glyph->metrics.vertAdvance = FT_MulFix( advanceY, y_scale );
+
+ return error;
+ }
+
+ FT_TRACE3(( "Failed to load SVG glyph\n" ));
+ }
+
+ /* return immediately if we only want SVG glyphs */
+ if ( load_flags & FT_LOAD_SVG_ONLY )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
+#endif /* FT_CONFIG_OPTION_SVG */
+
error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
if ( error )
goto Exit;
+ /* done if we are only interested in the `hdmx` advance */
+ if ( load_flags & FT_LOAD_ADVANCE_ONLY &&
+ !( load_flags & FT_LOAD_VERTICAL_LAYOUT ) &&
+ loader.widthp )
+ {
+ glyph->metrics.horiAdvance = loader.widthp[glyph_index] * 64;
+ goto Done;
+ }
+
glyph->format = FT_GLYPH_FORMAT_OUTLINE;
glyph->num_subglyphs = 0;
glyph->outline.flags = 0;
@@ -2849,6 +2675,9 @@
if ( IS_HINTED( load_flags ) )
{
+ glyph->control_data = loader.exec->glyphIns;
+ glyph->control_len = loader.exec->glyphSize;
+
if ( loader.exec->GS.scan_control )
{
/* convert scan conversion mode to FT_OUTLINE_XXX flags */
@@ -2882,8 +2711,6 @@
error = compute_glyph_metrics( &loader, glyph_index );
}
- tt_loader_done( &loader );
-
/* Set the `high precision' bit flag. */
/* This is _critical_ to get correct output for monochrome */
/* TrueType glyphs at all sizes using the bytecode interpreter. */
@@ -2892,6 +2719,16 @@
size->metrics->y_ppem < 24 )
glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
+ FT_TRACE1(( " subglyphs = %u, contours = %hd, points = %hd,"
+ " flags = 0x%.3x\n",
+ loader.gloader->base.num_subglyphs,
+ glyph->outline.n_contours,
+ glyph->outline.n_points,
+ glyph->outline.flags ));
+
+ Done:
+ tt_loader_done( &loader );
+
Exit:
#ifdef FT_DEBUG_LEVEL_TRACE
if ( error )
diff --git a/src/3rdparty/freetype/src/truetype/ttgload.h b/src/3rdparty/freetype/src/truetype/ttgload.h
index d237cfd284..f18637dce3 100644
--- a/src/3rdparty/freetype/src/truetype/ttgload.h
+++ b/src/3rdparty/freetype/src/truetype/ttgload.h
@@ -1,26 +1,25 @@
-/***************************************************************************/
-/* */
-/* ttgload.h */
-/* */
-/* TrueType Glyph Loader (specification). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttgload.h
+ *
+ * TrueType Glyph Loader (specification).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef TTGLOAD_H_
#define TTGLOAD_H_
-#include <ft2build.h>
#include "ttobjs.h"
#ifdef TT_USE_BYTECODE_INTERPRETER
diff --git a/src/3rdparty/freetype/src/truetype/ttgxvar.c b/src/3rdparty/freetype/src/truetype/ttgxvar.c
index 29ab2a4efd..ad4f266b27 100644
--- a/src/3rdparty/freetype/src/truetype/ttgxvar.c
+++ b/src/3rdparty/freetype/src/truetype/ttgxvar.c
@@ -1,53 +1,55 @@
-/***************************************************************************/
-/* */
-/* ttgxvar.c */
-/* */
-/* TrueType GX Font Variation loader */
-/* */
-/* Copyright 2004-2018 by */
-/* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* Apple documents the `fvar', `gvar', `cvar', and `avar' tables at */
- /* */
- /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html */
- /* */
- /* The documentation for `gvar' is not intelligible; `cvar' refers you */
- /* to `gvar' and is thus also incomprehensible. */
- /* */
- /* The documentation for `avar' appears correct, but Apple has no fonts */
- /* with an `avar' table, so it is hard to test. */
- /* */
- /* Many thanks to John Jenkins (at Apple) in figuring this out. */
- /* */
- /* */
- /* Apple's `kern' table has some references to tuple indices, but as */
- /* there is no indication where these indices are defined, nor how to */
- /* interpolate the kerning values (different tuples have different */
- /* classes) this issue is ignored. */
- /* */
- /*************************************************************************/
+/****************************************************************************
+ *
+ * ttgxvar.c
+ *
+ * TrueType GX Font Variation loader
+ *
+ * Copyright (C) 2004-2023 by
+ * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * Apple documents the `fvar', `gvar', `cvar', and `avar' tables at
+ *
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html
+ *
+ * The documentation for `gvar' is not intelligible; `cvar' refers you
+ * to `gvar' and is thus also incomprehensible.
+ *
+ * The documentation for `avar' appears correct, but Apple has no fonts
+ * with an `avar' table, so it is hard to test.
+ *
+ * Many thanks to John Jenkins (at Apple) in figuring this out.
+ *
+ *
+ * Apple's `kern' table has some references to tuple indices, but as
+ * there is no indication where these indices are defined, nor how to
+ * interpolate the kerning values (different tuples have different
+ * classes) this issue is ignored.
+ *
+ */
#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
+#include <freetype/internal/ftdebug.h>
#include FT_CONFIG_CONFIG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_SFNT_H
-#include FT_TRUETYPE_TAGS_H
-#include FT_TRUETYPE_IDS_H
-#include FT_MULTIPLE_MASTERS_H
-#include FT_LIST_H
+#include <freetype/internal/ftcalc.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/internal/services/svmetric.h>
+#include <freetype/tttags.h>
+#include <freetype/ttnameid.h>
+#include <freetype/ftmm.h>
+#include <freetype/ftlist.h>
#include "ttpload.h"
#include "ttgxvar.h"
@@ -67,14 +69,27 @@
: (stream)->limit
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /* some macros we need */
+#define FT_fdot14ToFixed( x ) \
+ ( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
+#define FT_intToFixed( i ) \
+ ( (FT_Fixed)( (FT_ULong)(i) << 16 ) )
+#define FT_fdot6ToFixed( i ) \
+ ( (FT_Fixed)( (FT_ULong)(i) << 10 ) )
+#define FT_fixedToInt( x ) \
+ ( (FT_Short)( ( (x) + 0x8000U ) >> 16 ) )
+#define FT_fixedToFdot6( x ) \
+ ( (FT_Pos)( ( (x) + 0x200 ) >> 10 ) )
+
+
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttgxvar
+#define FT_COMPONENT ttgxvar
/*************************************************************************/
@@ -86,12 +101,12 @@
/*************************************************************************/
- /*************************************************************************/
- /* */
- /* The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It */
- /* indicates that there is a delta for every point without needing to */
- /* enumerate all of them. */
- /* */
+ /**************************************************************************
+ *
+ * The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It
+ * indicates that there is a delta for every point without needing to
+ * enumerate all of them.
+ */
/* ensure that value `0' has the same width as a pointer */
#define ALL_POINTS (FT_UShort*)~(FT_PtrDist)0
@@ -101,29 +116,32 @@
#define GX_PT_POINT_RUN_COUNT_MASK 0x7FU
- /*************************************************************************/
- /* */
- /* <Function> */
- /* ft_var_readpackedpoints */
- /* */
- /* <Description> */
- /* Read a set of points to which the following deltas will apply. */
- /* Points are packed with a run length encoding. */
- /* */
- /* <Input> */
- /* stream :: The data stream. */
- /* */
- /* size :: The size of the table holding the data. */
- /* */
- /* <Output> */
- /* point_cnt :: The number of points read. A zero value means that */
- /* all points in the glyph will be affected, without */
- /* enumerating them individually. */
- /* */
- /* <Return> */
- /* An array of FT_UShort containing the affected points or the */
- /* special value ALL_POINTS. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * ft_var_readpackedpoints
+ *
+ * @Description:
+ * Read a set of points to which the following deltas will apply.
+ * Points are packed with a run length encoding.
+ *
+ * @Input:
+ * stream ::
+ * The data stream.
+ *
+ * size ::
+ * The size of the table holding the data.
+ *
+ * @Output:
+ * point_cnt ::
+ * The number of points read. A zero value means that
+ * all points in the glyph will be affected, without
+ * enumerating them individually.
+ *
+ * @Return:
+ * An array of FT_UShort containing the affected points or the
+ * special value ALL_POINTS.
+ */
static FT_UShort*
ft_var_readpackedpoints( FT_Stream stream,
FT_ULong size,
@@ -135,9 +153,7 @@
FT_UInt i, j;
FT_UShort first;
FT_Memory memory = stream->memory;
- FT_Error error = FT_Err_Ok;
-
- FT_UNUSED( error );
+ FT_Error error;
*point_cnt = 0;
@@ -162,7 +178,7 @@
/* in the nested loops below we increase `i' twice; */
/* it is faster to simply allocate one more slot */
/* than to add another test within the loop */
- if ( FT_NEW_ARRAY( points, n + 1 ) )
+ if ( FT_QNEW_ARRAY( points, n + 1 ) )
return NULL;
*point_cnt = n;
@@ -211,114 +227,152 @@
#define GX_DT_DELTA_RUN_COUNT_MASK 0x3FU
- /*************************************************************************/
- /* */
- /* <Function> */
- /* ft_var_readpackeddeltas */
- /* */
- /* <Description> */
- /* Read a set of deltas. These are packed slightly differently than */
- /* points. In particular there is no overall count. */
- /* */
- /* <Input> */
- /* stream :: The data stream. */
- /* */
- /* size :: The size of the table holding the data. */
- /* */
- /* delta_cnt :: The number of deltas to be read. */
- /* */
- /* <Return> */
- /* An array of FT_Short containing the deltas for the affected */
- /* points. (This only gets the deltas for one dimension. It will */
- /* generally be called twice, once for x, once for y. When used in */
- /* cvt table, it will only be called once.) */
- /* */
- static FT_Short*
+ /**************************************************************************
+ *
+ * @Function:
+ * ft_var_readpackeddeltas
+ *
+ * @Description:
+ * Read a set of deltas. These are packed slightly differently than
+ * points. In particular there is no overall count.
+ *
+ * @Input:
+ * stream ::
+ * The data stream.
+ *
+ * size ::
+ * The size of the table holding the data.
+ *
+ * delta_cnt ::
+ * The number of deltas to be read.
+ *
+ * @Return:
+ * An array of FT_Fixed containing the deltas for the affected
+ * points. (This only gets the deltas for one dimension. It will
+ * generally be called twice, once for x, once for y. When used in
+ * cvt table, it will only be called once.)
+ *
+ * We use FT_Fixed to avoid accumulation errors while summing up all
+ * deltas (the rounding to integer values happens as the very last
+ * step).
+ */
+ static FT_Fixed*
ft_var_readpackeddeltas( FT_Stream stream,
FT_ULong size,
FT_UInt delta_cnt )
{
- FT_Short *deltas = NULL;
+ FT_Fixed *deltas = NULL;
FT_UInt runcnt, cnt;
FT_UInt i, j;
+ FT_UInt bytes_used;
FT_Memory memory = stream->memory;
- FT_Error error = FT_Err_Ok;
-
- FT_UNUSED( error );
+ FT_Error error;
- if ( delta_cnt > size )
- {
- FT_TRACE1(( "ft_var_readpackeddeltas: number of points too large\n" ));
+ if ( FT_QNEW_ARRAY( deltas, delta_cnt ) )
return NULL;
- }
- if ( FT_NEW_ARRAY( deltas, delta_cnt ) )
- return NULL;
+ i = 0;
+ bytes_used = 0;
- i = 0;
- while ( i < delta_cnt )
+ while ( i < delta_cnt && bytes_used < size )
{
runcnt = FT_GET_BYTE();
cnt = runcnt & GX_DT_DELTA_RUN_COUNT_MASK;
+ bytes_used++;
+
if ( runcnt & GX_DT_DELTAS_ARE_ZERO )
{
- /* `runcnt' zeroes get added */
+ /* `cnt` + 1 zeroes get added */
for ( j = 0; j <= cnt && i < delta_cnt; j++ )
deltas[i++] = 0;
}
else if ( runcnt & GX_DT_DELTAS_ARE_WORDS )
{
- /* `runcnt' shorts from the stack */
+ /* `cnt` + 1 shorts from the stack */
+ bytes_used += 2 * ( cnt + 1 );
+ if ( bytes_used > size )
+ {
+ FT_TRACE1(( "ft_var_readpackeddeltas:"
+ " number of short deltas too large\n" ));
+ goto Fail;
+ }
+
for ( j = 0; j <= cnt && i < delta_cnt; j++ )
- deltas[i++] = FT_GET_SHORT();
+ deltas[i++] = FT_intToFixed( FT_GET_SHORT() );
}
else
{
- /* `runcnt' signed bytes from the stack */
+ /* `cnt` + 1 signed bytes from the stack */
+ bytes_used += cnt + 1;
+ if ( bytes_used > size )
+ {
+ FT_TRACE1(( "ft_var_readpackeddeltas:"
+ " number of byte deltas too large\n" ));
+ goto Fail;
+ }
+
for ( j = 0; j <= cnt && i < delta_cnt; j++ )
- deltas[i++] = FT_GET_CHAR();
+ deltas[i++] = FT_intToFixed( FT_GET_CHAR() );
}
if ( j <= cnt )
{
- /* bad format */
- FT_FREE( deltas );
- return NULL;
+ FT_TRACE1(( "ft_var_readpackeddeltas:"
+ " number of deltas too large\n" ));
+ goto Fail;
}
}
+ if ( i < delta_cnt )
+ {
+ FT_TRACE1(( "ft_var_readpackeddeltas: not enough deltas\n" ));
+ goto Fail;
+ }
+
return deltas;
+
+ Fail:
+ FT_FREE( deltas );
+ return NULL;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* ft_var_load_avar */
- /* */
- /* <Description> */
- /* Parse the `avar' table if present. It need not be, so we return */
- /* nothing. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * ft_var_load_avar
+ *
+ * @Description:
+ * Parse the `avar' table if present. It need not be, so we return
+ * nothing.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ */
static void
ft_var_load_avar( TT_Face face )
{
- FT_Stream stream = FT_FACE_STREAM( face );
- FT_Memory memory = stream->memory;
+ FT_Error error;
+ FT_Stream stream = FT_FACE_STREAM( face );
+ FT_Memory memory = stream->memory;
+ FT_Int i, j;
+
GX_Blend blend = face->blend;
GX_AVarSegment segment;
- FT_Error error = FT_Err_Ok;
- FT_Long version;
- FT_Long axisCount;
- FT_Int i, j;
- FT_ULong table_len;
+ GX_AVarTable table;
- FT_UNUSED( error );
+ FT_Long version;
+ FT_Long axisCount;
+ FT_ULong table_len;
+
+#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
+ FT_ULong table_offset;
+ FT_ULong store_offset;
+ FT_ULong axisMap_offset;
+#endif
FT_TRACE2(( "AVAR " ));
@@ -331,13 +385,21 @@
return;
}
+#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
+ table_offset = FT_STREAM_POS();
+#endif
+
if ( FT_FRAME_ENTER( table_len ) )
return;
version = FT_GET_LONG();
axisCount = FT_GET_LONG();
- if ( version != 0x00010000L )
+ if ( version != 0x00010000L
+#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
+ && version != 0x00020000L
+#endif
+ )
{
FT_TRACE2(( "bad table version\n" ));
goto Exit;
@@ -347,81 +409,110 @@
if ( axisCount != (FT_Long)blend->mmvar->num_axis )
{
- FT_TRACE2(( "ft_var_load_avar: number of axes in `avar' and `fvar'\n"
- " table are different\n" ));
+ FT_TRACE2(( "ft_var_load_avar:"
+ " number of axes in `avar' and `fvar'\n" ));
+ FT_TRACE2(( " table are different\n" ));
goto Exit;
}
- if ( FT_NEW_ARRAY( blend->avar_segment, axisCount ) )
+ if ( FT_NEW( blend->avar_table ) )
+ goto Exit;
+ table = blend->avar_table;
+
+ if ( FT_QNEW_ARRAY( table->avar_segment, axisCount ) )
goto Exit;
- segment = &blend->avar_segment[0];
+ segment = &table->avar_segment[0];
for ( i = 0; i < axisCount; i++, segment++ )
{
FT_TRACE5(( " axis %d:\n", i ));
segment->pairCount = FT_GET_USHORT();
- if ( (FT_ULong)segment->pairCount * 4 > table_len ||
- FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) )
+ if ( (FT_ULong)segment->pairCount * 4 > table_len ||
+ FT_QNEW_ARRAY( segment->correspondence, segment->pairCount ) )
{
/* Failure. Free everything we have done so far. We must do */
/* it right now since loading the `avar' table is optional. */
for ( j = i - 1; j >= 0; j-- )
- FT_FREE( blend->avar_segment[j].correspondence );
+ FT_FREE( table->avar_segment[j].correspondence );
- FT_FREE( blend->avar_segment );
- blend->avar_segment = NULL;
+ FT_FREE( table->avar_segment );
goto Exit;
}
for ( j = 0; j < segment->pairCount; j++ )
{
- /* convert to Fixed */
- segment->correspondence[j].fromCoord = FT_GET_SHORT() * 4;
- segment->correspondence[j].toCoord = FT_GET_SHORT() * 4;
+ segment->correspondence[j].fromCoord =
+ FT_fdot14ToFixed( FT_GET_SHORT() );
+ segment->correspondence[j].toCoord =
+ FT_fdot14ToFixed( FT_GET_SHORT() );
FT_TRACE5(( " mapping %.5f to %.5f\n",
- segment->correspondence[j].fromCoord / 65536.0,
- segment->correspondence[j].toCoord / 65536.0 ));
+ (double)segment->correspondence[j].fromCoord / 65536,
+ (double)segment->correspondence[j].toCoord / 65536 ));
}
FT_TRACE5(( "\n" ));
}
- Exit:
- FT_FRAME_EXIT();
- }
+#ifndef TT_CONFIG_OPTION_NO_BORING_EXPANSION
+ if ( version < 0x00020000L )
+ goto Exit;
+ axisMap_offset = FT_GET_ULONG();
+ store_offset = FT_GET_ULONG();
- /* some macros we need */
-#define FT_FIXED_ONE ( (FT_Fixed)0x10000 )
+ if ( store_offset )
+ {
+ error = tt_var_load_item_variation_store(
+ FT_FACE( face ),
+ table_offset + store_offset,
+ &table->itemStore );
+ if ( error )
+ goto Exit;
+ }
-#define FT_fdot14ToFixed( x ) \
- ( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
-#define FT_intToFixed( i ) \
- ( (FT_Fixed)( (FT_ULong)(i) << 16 ) )
-#define FT_fixedToInt( x ) \
- ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
+ if ( axisMap_offset )
+ {
+ error = tt_var_load_delta_set_index_mapping(
+ FT_FACE( face ),
+ table_offset + axisMap_offset,
+ &table->axisMap,
+ &table->itemStore,
+ table_len );
+ if ( error )
+ goto Exit;
+ }
+#endif
- static FT_Error
- ft_var_load_item_variation_store( TT_Face face,
+ Exit:
+ FT_FRAME_EXIT();
+ }
+
+
+ FT_LOCAL_DEF( FT_Error )
+ tt_var_load_item_variation_store( FT_Face face, /* TT_Face */
FT_ULong offset,
GX_ItemVarStore itemStore )
{
+ TT_Face ttface = (TT_Face)face;
FT_Stream stream = FT_FACE_STREAM( face );
FT_Memory memory = stream->memory;
FT_Error error;
FT_UShort format;
FT_ULong region_offset;
- FT_UInt i, j, k;
- FT_UInt shortDeltaCount;
- GX_Blend blend = face->blend;
- GX_ItemVarData varData;
+ FT_UInt data_count;
+ FT_UShort axis_count;
+ FT_UInt region_count;
+
+ FT_UInt i, j;
+ FT_Bool long_words;
+ GX_Blend blend = ttface->blend;
FT_ULong* dataOffsetArray = NULL;
@@ -431,31 +522,31 @@
if ( format != 1 )
{
- FT_TRACE2(( "ft_var_load_item_variation_store: bad store format %d\n",
+ FT_TRACE2(( "tt_var_load_item_variation_store: bad store format %d\n",
format ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* read top level fields */
- if ( FT_READ_ULONG( region_offset ) ||
- FT_READ_USHORT( itemStore->dataCount ) )
+ if ( FT_READ_ULONG( region_offset ) ||
+ FT_READ_USHORT( data_count ) )
goto Exit;
/* we need at least one entry in `itemStore->varData' */
- if ( !itemStore->dataCount )
+ if ( !data_count )
{
- FT_TRACE2(( "ft_var_load_item_variation_store: missing varData\n" ));
+ FT_TRACE2(( "tt_var_load_item_variation_store: missing varData\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* make temporary copy of item variation data offsets; */
/* we will parse region list first, then come back */
- if ( FT_NEW_ARRAY( dataOffsetArray, itemStore->dataCount ) )
+ if ( FT_QNEW_ARRAY( dataOffsetArray, data_count ) )
goto Exit;
- for ( i = 0; i < itemStore->dataCount; i++ )
+ for ( i = 0; i < data_count; i++ )
{
if ( FT_READ_ULONG( dataOffsetArray[i] ) )
goto Exit;
@@ -465,30 +556,40 @@
if ( FT_STREAM_SEEK( offset + region_offset ) )
goto Exit;
- if ( FT_READ_USHORT( itemStore->axisCount ) ||
- FT_READ_USHORT( itemStore->regionCount ) )
+ if ( FT_READ_USHORT( axis_count ) ||
+ FT_READ_USHORT( region_count ) )
goto Exit;
- if ( itemStore->axisCount != (FT_Long)blend->mmvar->num_axis )
+ if ( axis_count != (FT_Long)blend->mmvar->num_axis )
{
- FT_TRACE2(( "ft_var_load_item_variation_store:"
- " number of axes in item variation store\n"
- " "
+ FT_TRACE2(( "tt_var_load_item_variation_store:"
+ " number of axes in item variation store\n" ));
+ FT_TRACE2(( " "
" and `fvar' table are different\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
+ itemStore->axisCount = axis_count;
+
+ /* new constraint in OpenType 1.8.4 */
+ if ( region_count >= 32768U )
+ {
+ FT_TRACE2(( "tt_var_load_item_variation_store:"
+ " too many variation region tables\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
- if ( FT_NEW_ARRAY( itemStore->varRegionList, itemStore->regionCount ) )
+ if ( FT_NEW_ARRAY( itemStore->varRegionList, region_count ) )
goto Exit;
+ itemStore->regionCount = region_count;
for ( i = 0; i < itemStore->regionCount; i++ )
{
GX_AxisCoords axisCoords;
- if ( FT_NEW_ARRAY( itemStore->varRegionList[i].axisList,
- itemStore->axisCount ) )
+ if ( FT_NEW_ARRAY( itemStore->varRegionList[i].axisList, axis_count ) )
goto Exit;
axisCoords = itemStore->varRegionList[i].axisList;
@@ -512,44 +613,56 @@
/* end of region list parse */
/* use dataOffsetArray now to parse varData items */
- if ( FT_NEW_ARRAY( itemStore->varData, itemStore->dataCount ) )
+ if ( FT_NEW_ARRAY( itemStore->varData, data_count ) )
goto Exit;
+ itemStore->dataCount = data_count;
- for ( i = 0; i < itemStore->dataCount; i++ )
+ for ( i = 0; i < data_count; i++ )
{
- varData = &itemStore->varData[i];
+ GX_ItemVarData varData = &itemStore->varData[i];
+
+ FT_UInt item_count;
+ FT_UShort word_delta_count;
+ FT_UInt region_idx_count;
+ FT_UInt per_region_size;
+
if ( FT_STREAM_SEEK( offset + dataOffsetArray[i] ) )
goto Exit;
- if ( FT_READ_USHORT( varData->itemCount ) ||
- FT_READ_USHORT( shortDeltaCount ) ||
- FT_READ_USHORT( varData->regionIdxCount ) )
+ if ( FT_READ_USHORT( item_count ) ||
+ FT_READ_USHORT( word_delta_count ) ||
+ FT_READ_USHORT( region_idx_count ) )
goto Exit;
+ long_words = !!( word_delta_count & 0x8000 );
+ word_delta_count &= 0x7FFF;
+
/* check some data consistency */
- if ( shortDeltaCount > varData->regionIdxCount )
+ if ( word_delta_count > region_idx_count )
{
FT_TRACE2(( "bad short count %d or region count %d\n",
- shortDeltaCount,
- varData->regionIdxCount ));
+ word_delta_count,
+ region_idx_count ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
- if ( varData->regionIdxCount > itemStore->regionCount )
+ if ( region_idx_count > itemStore->regionCount )
{
FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n",
- varData->regionIdxCount,
+ region_idx_count,
i ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* parse region indices */
- if ( FT_NEW_ARRAY( varData->regionIndices,
- varData->regionIdxCount ) )
+ if ( FT_NEW_ARRAY( varData->regionIndices, region_idx_count ) )
goto Exit;
+ varData->regionIdxCount = region_idx_count;
+ varData->wordDeltaCount = word_delta_count;
+ varData->longWords = long_words;
for ( j = 0; j < varData->regionIdxCount; j++ )
{
@@ -565,43 +678,22 @@
}
}
- /* Parse delta set. */
- /* */
- /* On input, deltas are (shortDeltaCount + regionIdxCount) bytes */
- /* each; on output, deltas are expanded to `regionIdxCount' shorts */
- /* each. */
- if ( FT_NEW_ARRAY( varData->deltaSet,
- varData->regionIdxCount * varData->itemCount ) )
- goto Exit;
+ per_region_size = word_delta_count + region_idx_count;
+ if ( long_words )
+ per_region_size *= 2;
- /* the delta set is stored as a 2-dimensional array of shorts; */
- /* sign-extend signed bytes to signed shorts */
- for ( j = 0; j < varData->itemCount * varData->regionIdxCount; )
+ if ( FT_NEW_ARRAY( varData->deltaSet, per_region_size * item_count ) )
+ goto Exit;
+ if ( FT_Stream_Read( stream,
+ varData->deltaSet,
+ per_region_size * item_count ) )
{
- for ( k = 0; k < shortDeltaCount; k++, j++ )
- {
- /* read the short deltas */
- FT_Short delta;
-
-
- if ( FT_READ_SHORT( delta ) )
- goto Exit;
-
- varData->deltaSet[j] = delta;
- }
-
- for ( ; k < varData->regionIdxCount; k++, j++ )
- {
- /* read the (signed) byte deltas */
- FT_Char delta;
-
-
- if ( FT_READ_CHAR( delta ) )
- goto Exit;
-
- varData->deltaSet[j] = delta;
- }
+ FT_TRACE2(( "deltaSet read failed." ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
}
+
+ varData->itemCount = item_count;
}
Exit:
@@ -611,41 +703,70 @@
}
- static FT_Error
- ft_var_load_delta_set_index_mapping( TT_Face face,
+ FT_LOCAL_DEF( FT_Error )
+ tt_var_load_delta_set_index_mapping( FT_Face face, /* TT_Face */
FT_ULong offset,
GX_DeltaSetIdxMap map,
- GX_ItemVarStore itemStore )
+ GX_ItemVarStore itemStore,
+ FT_ULong table_len )
{
FT_Stream stream = FT_FACE_STREAM( face );
FT_Memory memory = stream->memory;
- FT_Error error;
+ FT_Error error;
- FT_UShort format;
- FT_UInt entrySize;
- FT_UInt innerBitCount;
- FT_UInt innerIndexMask;
- FT_UInt i, j;
+ FT_Byte format;
+ FT_Byte entryFormat;
+ FT_UInt entrySize;
+ FT_UInt innerBitCount;
+ FT_UInt innerIndexMask;
+ FT_ULong i;
+ FT_UInt j;
- if ( FT_STREAM_SEEK( offset ) ||
- FT_READ_USHORT( format ) ||
- FT_READ_USHORT( map->mapCount ) )
+ if ( FT_STREAM_SEEK( offset ) ||
+ FT_READ_BYTE( format ) ||
+ FT_READ_BYTE( entryFormat ) )
goto Exit;
- if ( format & 0xFFC0 )
+ if ( format == 0 )
+ {
+ if ( FT_READ_USHORT( map->mapCount ) )
+ goto Exit;
+ }
+ else if ( format == 1 ) /* new in OpenType 1.9 */
+ {
+ if ( FT_READ_ULONG( map->mapCount ) )
+ goto Exit;
+ }
+ else
{
FT_TRACE2(( "bad map format %d\n", format ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
+ if ( entryFormat & 0xC0 )
+ {
+ FT_TRACE2(( "bad entry format %d\n", format ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
/* bytes per entry: 1, 2, 3, or 4 */
- entrySize = ( ( format & 0x0030 ) >> 4 ) + 1;
- innerBitCount = ( format & 0x000F ) + 1;
+ entrySize = ( ( entryFormat & 0x30 ) >> 4 ) + 1;
+ innerBitCount = ( entryFormat & 0x0F ) + 1;
innerIndexMask = ( 1 << innerBitCount ) - 1;
+ /* rough sanity check */
+ if ( map->mapCount * entrySize > table_len )
+ {
+ FT_TRACE1(( "tt_var_load_delta_set_index_mapping:"
+ " invalid number of delta-set index mappings\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
if ( FT_NEW_ARRAY( map->innerIndex, map->mapCount ) )
goto Exit;
@@ -670,11 +791,21 @@
mapData = ( mapData << 8 ) | data;
}
+ /* new in OpenType 1.8.4 */
+ if ( mapData == 0xFFFFFFFFUL )
+ {
+ /* no variation data for this item */
+ map->outerIndex[i] = 0xFFFFU;
+ map->innerIndex[i] = 0xFFFFU;
+
+ continue;
+ }
+
outerIndex = mapData >> innerBitCount;
if ( outerIndex >= itemStore->dataCount )
{
- FT_TRACE2(( "outerIndex[%d] == %d out of range\n",
+ FT_TRACE2(( "outerIndex[%ld] == %d out of range\n",
i,
outerIndex ));
error = FT_THROW( Invalid_Table );
@@ -687,7 +818,7 @@
if ( innerIndex >= itemStore->varData[outerIndex].itemCount )
{
- FT_TRACE2(( "innerIndex[%d] == %d out of range\n",
+ FT_TRACE2(( "innerIndex[%ld] == %d out of range\n",
i,
innerIndex ));
error = FT_THROW( Invalid_Table );
@@ -702,29 +833,30 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* ft_var_load_hvvar */
- /* */
- /* <Description> */
- /* If `vertical' is zero, parse the `HVAR' table and set */
- /* `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked' */
- /* is set to TRUE. */
- /* */
- /* If `vertical' is not zero, parse the `VVAR' table and set */
- /* `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked' */
- /* is set to TRUE. */
- /* */
- /* Some memory may remain allocated on error; it is always freed in */
- /* `tt_done_blend', however. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * ft_var_load_hvvar
+ *
+ * @Description:
+ * If `vertical' is zero, parse the `HVAR' table and set
+ * `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked'
+ * is set to TRUE.
+ *
+ * If `vertical' is not zero, parse the `VVAR' table and set
+ * `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked'
+ * is set to TRUE.
+ *
+ * Some memory may remain allocated on error; it is always freed in
+ * `tt_done_blend', however.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
static FT_Error
ft_var_load_hvvar( TT_Face face,
FT_Bool vertical )
@@ -798,8 +930,8 @@
table = blend->hvar_table;
}
- error = ft_var_load_item_variation_store(
- face,
+ error = tt_var_load_item_variation_store(
+ FT_FACE( face ),
table_offset + store_offset,
&table->itemStore );
if ( error )
@@ -807,11 +939,12 @@
if ( widthMap_offset )
{
- error = ft_var_load_delta_set_index_mapping(
- face,
+ error = tt_var_load_delta_set_index_mapping(
+ FT_FACE( face ),
table_offset + widthMap_offset,
&table->widthMap,
- &table->itemStore );
+ &table->itemStore,
+ table_len );
if ( error )
goto Exit;
}
@@ -848,31 +981,91 @@
}
- static FT_Int
- ft_var_get_item_delta( TT_Face face,
+ FT_LOCAL_DEF( FT_ItemVarDelta )
+ tt_var_get_item_delta( FT_Face face, /* TT_Face */
GX_ItemVarStore itemStore,
FT_UInt outerIndex,
FT_UInt innerIndex )
{
- GX_ItemVarData varData;
- FT_Short* deltaSet;
+ TT_Face ttface = (TT_Face)face;
+ FT_Stream stream = FT_FACE_STREAM( face );
+ FT_Memory memory = stream->memory;
+ FT_Error error = FT_Err_Ok;
- FT_UInt master, j;
- FT_Fixed netAdjustment = 0; /* accumulated adjustment */
- FT_Fixed scaledDelta;
- FT_Fixed delta;
+ GX_ItemVarData varData;
+ FT_ItemVarDelta* deltaSet = NULL;
+ FT_ItemVarDelta deltaSetStack[16];
+ FT_Fixed* scalars = NULL;
+ FT_Fixed scalarsStack[16];
+
+ FT_UInt master, j;
+ FT_ItemVarDelta returnValue = 0;
+ FT_UInt per_region_size;
+ FT_Byte* bytes;
+
+
+ if ( !ttface->blend || !ttface->blend->normalizedcoords )
+ return 0;
+
+ /* OpenType 1.8.4+: No variation data for this item */
+ /* as indices have special value 0xFFFF. */
+ if ( outerIndex == 0xFFFF && innerIndex == 0xFFFF )
+ return 0;
/* See pseudo code from `Font Variations Overview' */
/* in the OpenType specification. */
- varData = &itemStore->varData[outerIndex];
- deltaSet = &varData->deltaSet[varData->regionIdxCount * innerIndex];
+ if ( outerIndex >= itemStore->dataCount )
+ return 0; /* Out of range. */
+
+ varData = &itemStore->varData[outerIndex];
+
+ if ( innerIndex >= varData->itemCount )
+ return 0; /* Out of range. */
+
+ if ( varData->regionIdxCount < 16 )
+ {
+ deltaSet = deltaSetStack;
+ scalars = scalarsStack;
+ }
+ else
+ {
+ if ( FT_QNEW_ARRAY( deltaSet, varData->regionIdxCount ) )
+ goto Exit;
+ if ( FT_QNEW_ARRAY( scalars, varData->regionIdxCount ) )
+ goto Exit;
+ }
+
+ /* Parse delta set. */
+ /* */
+ /* Deltas are (word_delta_count + region_idx_count) bytes each */
+ /* if `longWords` isn't set, and twice as much otherwise. */
+ per_region_size = varData->wordDeltaCount + varData->regionIdxCount;
+ if ( varData->longWords )
+ per_region_size *= 2;
+
+ bytes = varData->deltaSet + per_region_size * innerIndex;
+
+ if ( varData->longWords )
+ {
+ for ( master = 0; master < varData->wordDeltaCount; master++ )
+ deltaSet[master] = FT_NEXT_LONG( bytes );
+ for ( ; master < varData->regionIdxCount; master++ )
+ deltaSet[master] = FT_NEXT_SHORT( bytes );
+ }
+ else
+ {
+ for ( master = 0; master < varData->wordDeltaCount; master++ )
+ deltaSet[master] = FT_NEXT_SHORT( bytes );
+ for ( ; master < varData->regionIdxCount; master++ )
+ deltaSet[master] = FT_NEXT_CHAR( bytes );
+ }
/* outer loop steps through master designs to be blended */
for ( master = 0; master < varData->regionIdxCount; master++ )
{
- FT_Fixed scalar = FT_FIXED_ONE;
+ FT_Fixed scalar = 0x10000L;
FT_UInt regionIndex = varData->regionIndices[master];
GX_AxisCoords axis = itemStore->varRegionList[regionIndex].axisList;
@@ -881,81 +1074,100 @@
/* inner loop steps through axes in this region */
for ( j = 0; j < itemStore->axisCount; j++, axis++ )
{
- FT_Fixed axisScalar;
-
-
/* compute the scalar contribution of this axis; */
/* ignore invalid ranges */
if ( axis->startCoord > axis->peakCoord ||
axis->peakCoord > axis->endCoord )
- axisScalar = FT_FIXED_ONE;
+ continue;
else if ( axis->startCoord < 0 &&
axis->endCoord > 0 &&
axis->peakCoord != 0 )
- axisScalar = FT_FIXED_ONE;
+ continue;
/* peak of 0 means ignore this axis */
else if ( axis->peakCoord == 0 )
- axisScalar = FT_FIXED_ONE;
+ continue;
- /* ignore this region if coords are out of range */
- else if ( face->blend->normalizedcoords[j] < axis->startCoord ||
- face->blend->normalizedcoords[j] > axis->endCoord )
- axisScalar = 0;
+ else if ( ttface->blend->normalizedcoords[j] == axis->peakCoord )
+ continue;
- /* calculate a proportional factor */
- else
+ /* ignore this region if coords are out of range */
+ else if ( ttface->blend->normalizedcoords[j] <= axis->startCoord ||
+ ttface->blend->normalizedcoords[j] >= axis->endCoord )
{
- if ( face->blend->normalizedcoords[j] == axis->peakCoord )
- axisScalar = FT_FIXED_ONE;
- else if ( face->blend->normalizedcoords[j] < axis->peakCoord )
- axisScalar =
- FT_DivFix( face->blend->normalizedcoords[j] - axis->startCoord,
- axis->peakCoord - axis->startCoord );
- else
- axisScalar =
- FT_DivFix( axis->endCoord - face->blend->normalizedcoords[j],
- axis->endCoord - axis->peakCoord );
+ scalar = 0;
+ break;
}
- /* take product of all the axis scalars */
- scalar = FT_MulFix( scalar, axisScalar );
+ /* cumulative product of all the axis scalars */
+ else if ( ttface->blend->normalizedcoords[j] < axis->peakCoord )
+ scalar =
+ FT_MulDiv( scalar,
+ ttface->blend->normalizedcoords[j] - axis->startCoord,
+ axis->peakCoord - axis->startCoord );
+ else
+ scalar =
+ FT_MulDiv( scalar,
+ axis->endCoord - ttface->blend->normalizedcoords[j],
+ axis->endCoord - axis->peakCoord );
} /* per-axis loop */
- /* get the scaled delta for this region */
- delta = FT_intToFixed( deltaSet[master] );
- scaledDelta = FT_MulFix( scalar, delta );
-
- /* accumulate the adjustments from each region */
- netAdjustment = netAdjustment + scaledDelta;
+ scalars[master] = scalar;
} /* per-region loop */
- return FT_fixedToInt( netAdjustment );
+
+ /* Compute the scaled delta for this region.
+ *
+ * From: https://docs.microsoft.com/en-us/typography/opentype/spec/otvarcommonformats#item-variation-store-header-and-item-variation-data-subtables:
+ *
+ * `Fixed` is a 32-bit (16.16) type and, in the general case, requires
+ * 32-bit deltas. As described above, the `DeltaSet` record can
+ * accommodate deltas that are, logically, either 16-bit or 32-bit.
+ * When scaled deltas are applied to `Fixed` values, the `Fixed` value
+ * is treated like a 32-bit integer.
+ *
+ * `FT_MulAddFix` internally uses 64-bit precision; it thus can handle
+ * deltas ranging from small 8-bit to large 32-bit values that are
+ * applied to 16.16 `FT_Fixed` / OpenType `Fixed` values.
+ */
+ returnValue = FT_MulAddFix( scalars, deltaSet, varData->regionIdxCount );
+
+ Exit:
+ if ( scalars != scalarsStack )
+ FT_FREE( scalars );
+ if ( deltaSet != deltaSetStack )
+ FT_FREE( deltaSet );
+
+ return returnValue;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_hvadvance_adjust */
- /* */
- /* <Description> */
- /* Apply `HVAR' advance width or `VVAR' advance height adjustment of */
- /* a given glyph. */
- /* */
- /* <Input> */
- /* gindex :: The glyph index. */
- /* */
- /* vertical :: If set, handle `VVAR' table. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* */
- /* adelta :: Points to width or height value that gets modified. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_hvadvance_adjust
+ *
+ * @Description:
+ * Apply `HVAR' advance width or `VVAR' advance height adjustment of
+ * a given glyph.
+ *
+ * @Input:
+ * gindex ::
+ * The glyph index.
+ *
+ * vertical ::
+ * If set, handle `VVAR' table.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ *
+ * adelta ::
+ * Points to width or height value that gets modified.
+ */
static FT_Error
tt_hvadvance_adjust( TT_Face face,
FT_UInt gindex,
@@ -1022,35 +1234,27 @@
}
else
{
- GX_ItemVarData varData;
-
-
/* no widthMap data */
outerIndex = 0;
innerIndex = gindex;
-
- varData = &table->itemStore.varData[outerIndex];
- if ( gindex >= varData->itemCount )
- {
- FT_TRACE2(( "gindex %d out of range\n", gindex ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
}
- delta = ft_var_get_item_delta( face,
+ delta = tt_var_get_item_delta( FT_FACE( face ),
&table->itemStore,
outerIndex,
innerIndex );
- FT_TRACE5(( "%s value %d adjusted by %d unit%s (%s)\n",
- vertical ? "vertical height" : "horizontal width",
- *avalue,
- delta,
- delta == 1 ? "" : "s",
- vertical ? "VVAR" : "HVAR" ));
-
- *avalue += delta;
+ if ( delta )
+ {
+ FT_TRACE5(( "%s value %d adjusted by %d unit%s (%s)\n",
+ vertical ? "vertical height" : "horizontal width",
+ *avalue,
+ delta,
+ delta == 1 ? "" : "s",
+ vertical ? "VVAR" : "HVAR" ));
+
+ *avalue = ADD_INT( *avalue, delta );
+ }
Exit:
return error;
@@ -1058,20 +1262,20 @@
FT_LOCAL_DEF( FT_Error )
- tt_hadvance_adjust( TT_Face face,
+ tt_hadvance_adjust( FT_Face face, /* TT_Face */
FT_UInt gindex,
FT_Int *avalue )
{
- return tt_hvadvance_adjust( face, gindex, avalue, 0 );
+ return tt_hvadvance_adjust( (TT_Face)face, gindex, avalue, 0 );
}
FT_LOCAL_DEF( FT_Error )
- tt_vadvance_adjust( TT_Face face,
+ tt_vadvance_adjust( FT_Face face, /* TT_Face */
FT_UInt gindex,
FT_Int *avalue )
{
- return tt_hvadvance_adjust( face, gindex, avalue, 1 );
+ return tt_hvadvance_adjust( (TT_Face)face, gindex, avalue, 1 );
}
@@ -1151,20 +1355,21 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* ft_var_load_mvar */
- /* */
- /* <Description> */
- /* Parse the `MVAR' table. */
- /* */
- /* Some memory may remain allocated on error; it is always freed in */
- /* `tt_done_blend', however. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * ft_var_load_mvar
+ *
+ * @Description:
+ * Parse the `MVAR' table.
+ *
+ * Some memory may remain allocated on error; it is always freed in
+ * `tt_done_blend', however.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ */
static void
ft_var_load_mvar( TT_Face face )
{
@@ -1216,8 +1421,8 @@
records_offset = FT_STREAM_POS();
- error = ft_var_load_item_variation_store(
- face,
+ error = tt_var_load_item_variation_store(
+ FT_FACE( face ),
table_offset + store_offset,
&blend->mvar_table->itemStore );
if ( error )
@@ -1232,7 +1437,7 @@
return;
value = blend->mvar_table->values;
- limit = value + blend->mvar_table->valueCount;
+ limit = FT_OFFSET( value, blend->mvar_table->valueCount );
itemStore = &blend->mvar_table->itemStore;
for ( ; value < limit; value++ )
@@ -1241,6 +1446,13 @@
value->outerIndex = FT_GET_USHORT();
value->innerIndex = FT_GET_USHORT();
+ /* new in OpenType 1.8.4 */
+ if ( value->outerIndex == 0xFFFFU && value->innerIndex == 0xFFFFU )
+ {
+ /* no variation data for this item */
+ continue;
+ }
+
if ( value->outerIndex >= itemStore->dataCount ||
value->innerIndex >= itemStore->varData[value->outerIndex]
.itemCount )
@@ -1258,7 +1470,7 @@
FT_TRACE2(( "loaded\n" ));
value = blend->mvar_table->values;
- limit = value + blend->mvar_table->valueCount;
+ limit = FT_OFFSET( value, blend->mvar_table->valueCount );
/* save original values of the data MVAR is going to modify */
for ( ; value < limit; value++ )
@@ -1283,56 +1495,62 @@
static FT_Error
- tt_size_reset_iterator( FT_ListNode node,
+ ft_size_reset_iterator( FT_ListNode node,
void* user )
{
- TT_Size size = (TT_Size)node->data;
-
- FT_UNUSED( user );
+ FT_Size size = (FT_Size)node->data;
+ FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)user;
- tt_size_reset( size, 1 );
+ var->size_reset( size );
return FT_Err_Ok;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_apply_mvar */
- /* */
- /* <Description> */
- /* Apply `MVAR' table adjustments. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_apply_mvar
+ *
+ * @Description:
+ * Apply `MVAR' table adjustments.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ */
FT_LOCAL_DEF( void )
- tt_apply_mvar( TT_Face face )
+ tt_apply_mvar( FT_Face face ) /* TT_Face */
{
- GX_Blend blend = face->blend;
+ TT_Face ttface = (TT_Face)face;
+
+ GX_Blend blend = ttface->blend;
GX_Value value, limit;
+ FT_Short mvar_hasc_delta = 0;
+ FT_Short mvar_hdsc_delta = 0;
+ FT_Short mvar_hlgp_delta = 0;
- if ( !( face->variation_support & TT_FACE_FLAG_VAR_MVAR ) )
+
+ if ( !( ttface->variation_support & TT_FACE_FLAG_VAR_MVAR ) )
return;
value = blend->mvar_table->values;
- limit = value + blend->mvar_table->valueCount;
+ limit = FT_OFFSET( value, blend->mvar_table->valueCount );
for ( ; value < limit; value++ )
{
- FT_Short* p = ft_var_get_value_pointer( face, value->tag );
+ FT_Short* p = ft_var_get_value_pointer( ttface, value->tag );
FT_Int delta;
- delta = ft_var_get_item_delta( face,
+ delta = tt_var_get_item_delta( face,
&blend->mvar_table->itemStore,
value->outerIndex,
value->innerIndex );
- if ( p )
+ if ( p && delta )
{
FT_TRACE5(( "value %c%c%c%c (%d unit%s) adjusted by %d unit%s (MVAR)\n",
(FT_Char)( value->tag >> 24 ),
@@ -1347,42 +1565,67 @@
/* since we handle both signed and unsigned values as FT_Short, */
/* ensure proper overflow arithmetic */
*p = (FT_Short)( value->unmodified + (FT_Short)delta );
+
+ /* Treat hasc, hdsc and hlgp specially, see below. */
+ if ( value->tag == MVAR_TAG_HASC )
+ mvar_hasc_delta = (FT_Short)delta;
+ else if ( value->tag == MVAR_TAG_HDSC )
+ mvar_hdsc_delta = (FT_Short)delta;
+ else if ( value->tag == MVAR_TAG_HLGP )
+ mvar_hlgp_delta = (FT_Short)delta;
}
}
/* adjust all derived values */
{
- FT_Face root = &face->root;
-
-
- if ( face->os2.version != 0xFFFFU )
- {
- if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
- {
- root->ascender = face->os2.sTypoAscender;
- root->descender = face->os2.sTypoDescender;
-
- root->height = root->ascender - root->descender +
- face->os2.sTypoLineGap;
- }
- else
- {
- root->ascender = (FT_Short)face->os2.usWinAscent;
- root->descender = -(FT_Short)face->os2.usWinDescent;
-
- root->height = root->ascender - root->descender;
- }
- }
-
- root->underline_position = face->postscript.underlinePosition -
- face->postscript.underlineThickness / 2;
- root->underline_thickness = face->postscript.underlineThickness;
-
- /* iterate over all FT_Size objects and call `tt_size_reset' */
- /* to propagate the metrics changes */
- FT_List_Iterate( &root->sizes_list,
- tt_size_reset_iterator,
- NULL );
+ FT_Service_MetricsVariations var =
+ (FT_Service_MetricsVariations)ttface->face_var;
+
+ /*
+ * Apply the deltas of hasc, hdsc and hlgp to the FT_Face's ascender,
+ * descender and height attributes, no matter how they were originally
+ * computed.
+ *
+ * (Code that ignores those and accesses the font's metrics values
+ * directly is already served by the delta application code above.)
+ *
+ * The MVAR table supports variations for both typo and win metrics.
+ * According to Behdad Esfahbod, the thinking of the working group was
+ * that no one uses win metrics anymore for setting line metrics (the
+ * specification even calls these metrics "horizontal clipping
+ * ascent/descent", probably for their role on the Windows platform in
+ * computing clipping boxes), and new fonts should use typo metrics, so
+ * typo deltas should be applied to whatever sfnt_load_face decided the
+ * line metrics should be.
+ *
+ * Before, the following led to different line metrics between default
+ * outline and instances, visible when e.g. the default outlines were
+ * used as the regular face and instances for everything else:
+ *
+ * 1. sfnt_load_face applied the hhea metrics by default.
+ * 2. This code later applied the typo metrics by default, regardless of
+ * whether they were actually changed or the font had the OS/2 table's
+ * fsSelection's bit 7 (USE_TYPO_METRICS) set.
+ */
+ FT_Short current_line_gap = face->height - face->ascender +
+ face->descender;
+
+
+ face->ascender = face->ascender + mvar_hasc_delta;
+ face->descender = face->descender + mvar_hdsc_delta;
+ face->height = face->ascender - face->descender +
+ current_line_gap + mvar_hlgp_delta;
+
+ face->underline_position = ttface->postscript.underlinePosition -
+ ttface->postscript.underlineThickness / 2;
+ face->underline_thickness = ttface->postscript.underlineThickness;
+
+ /* iterate over all FT_Size objects and call `var->size_reset' */
+ /* to propagate the metrics changes */
+ if ( var && var->size_reset )
+ FT_List_Iterate( &face->sizes_list,
+ ft_size_reset_iterator,
+ (void*)var );
}
}
@@ -1400,21 +1643,22 @@
} GX_GVar_Head;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* ft_var_load_gvar */
- /* */
- /* <Description> */
- /* Parse the `gvar' table if present. If `fvar' is there, `gvar' had */
- /* better be there too. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * ft_var_load_gvar
+ *
+ * @Description:
+ * Parse the `gvar' table if present. If `fvar' is there, `gvar' had
+ * better be there too.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
static FT_Error
ft_var_load_gvar( TT_Face face )
{
@@ -1426,6 +1670,7 @@
FT_ULong table_len;
FT_ULong gvar_start;
FT_ULong offsetToData;
+ FT_ULong offsets_len;
GX_GVar_Head gvar_head;
static const FT_Frame_Field gvar_fields[] =
@@ -1470,8 +1715,9 @@
if ( gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis )
{
- FT_TRACE1(( "ft_var_load_gvar: number of axes in `gvar' and `cvar'\n"
- " table are different\n" ));
+ FT_TRACE1(( "ft_var_load_gvar:"
+ " number of axes in `gvar' and `cvar'\n" ));
+ FT_TRACE1(( " table are different\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -1486,9 +1732,13 @@
goto Exit;
}
- /* rough sanity check: offsets can be either 2 or 4 bytes */
- if ( (FT_ULong)gvar_head.glyphCount *
- ( ( gvar_head.flags & 1 ) ? 4 : 2 ) > table_len )
+ /* offsets can be either 2 or 4 bytes */
+ /* (one more offset than glyphs, to mark size of last) */
+ offsets_len = ( gvar_head.glyphCount + 1 ) *
+ ( ( gvar_head.flags & 1 ) ? 4L : 2L );
+
+ /* rough sanity check */
+ if (offsets_len > table_len )
{
FT_TRACE1(( "ft_var_load_gvar: invalid number of glyphs\n" ));
error = FT_THROW( Invalid_Table );
@@ -1497,66 +1747,116 @@
FT_TRACE2(( "loaded\n" ));
- blend->gvar_size = table_len;
- blend->tuplecount = gvar_head.globalCoordCount;
- blend->gv_glyphcnt = gvar_head.glyphCount;
- offsetToData = gvar_start + gvar_head.offsetToData;
+ blend->gvar_size = table_len;
+ offsetToData = gvar_start + gvar_head.offsetToData;
FT_TRACE5(( "gvar: there %s %d shared coordinate%s:\n",
- blend->tuplecount == 1 ? "is" : "are",
- blend->tuplecount,
- blend->tuplecount == 1 ? "" : "s" ));
+ gvar_head.globalCoordCount == 1 ? "is" : "are",
+ gvar_head.globalCoordCount,
+ gvar_head.globalCoordCount == 1 ? "" : "s" ));
- if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) )
+ if ( FT_FRAME_ENTER( offsets_len ) )
goto Exit;
+ /* offsets (one more offset than glyphs, to mark size of last) */
+ if ( FT_QNEW_ARRAY( blend->glyphoffsets, gvar_head.glyphCount + 1 ) )
+ goto Fail2;
+
if ( gvar_head.flags & 1 )
{
- /* long offsets (one more offset than glyphs, to mark size of last) */
- if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) )
- goto Exit;
+ FT_ULong limit = gvar_start + table_len;
+ FT_ULong max_offset = 0;
+
- for ( i = 0; i <= blend->gv_glyphcnt; i++ )
+ for ( i = 0; i <= gvar_head.glyphCount; i++ )
+ {
blend->glyphoffsets[i] = offsetToData + FT_GET_ULONG();
- FT_FRAME_EXIT();
+ if ( max_offset <= blend->glyphoffsets[i] )
+ max_offset = blend->glyphoffsets[i];
+ else
+ {
+ FT_TRACE2(( "ft_var_load_gvar:"
+ " glyph variation data offset %d not monotonic\n",
+ i ));
+ blend->glyphoffsets[i] = max_offset;
+ }
+
+ /* use `<', not `<=' */
+ if ( limit < blend->glyphoffsets[i] )
+ {
+ FT_TRACE2(( "ft_var_load_gvar:"
+ " glyph variation data offset %d out of range\n",
+ i ));
+ blend->glyphoffsets[i] = limit;
+ }
+ }
}
else
{
- /* short offsets (one more offset than glyphs, to mark size of last) */
- if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) )
- goto Exit;
+ FT_ULong limit = gvar_start + table_len;
+ FT_ULong max_offset = 0;
+
- for ( i = 0; i <= blend->gv_glyphcnt; i++ )
+ for ( i = 0; i <= gvar_head.glyphCount; i++ )
+ {
blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2;
- /* XXX: Undocumented: `*2'! */
- FT_FRAME_EXIT();
+ if ( max_offset <= blend->glyphoffsets[i] )
+ max_offset = blend->glyphoffsets[i];
+ else
+ {
+ FT_TRACE2(( "ft_var_load_gvar:"
+ " glyph variation data offset %d not monotonic\n",
+ i ));
+ blend->glyphoffsets[i] = max_offset;
+ }
+
+ /* use `<', not `<=' */
+ if ( limit < blend->glyphoffsets[i] )
+ {
+ FT_TRACE2(( "ft_var_load_gvar:"
+ " glyph variation data offset %d out of range\n",
+ i ));
+ blend->glyphoffsets[i] = limit;
+ }
+ }
}
- if ( blend->tuplecount != 0 )
+ blend->gv_glyphcnt = gvar_head.glyphCount;
+
+ FT_FRAME_EXIT();
+
+ if ( gvar_head.globalCoordCount != 0 )
{
- if ( FT_NEW_ARRAY( blend->tuplecoords,
- gvar_head.axisCount * blend->tuplecount ) )
- goto Exit;
+ if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) ||
+ FT_FRAME_ENTER( gvar_head.globalCoordCount *
+ gvar_head.axisCount * 2L ) )
+ {
+ FT_TRACE2(( "ft_var_load_gvar:"
+ " glyph variation shared tuples missing\n" ));
+ goto Fail;
+ }
- if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) ||
- FT_FRAME_ENTER( blend->tuplecount * gvar_head.axisCount * 2L ) )
- goto Exit;
+ if ( FT_QNEW_ARRAY( blend->tuplecoords,
+ gvar_head.axisCount * gvar_head.globalCoordCount ) )
+ goto Fail2;
- for ( i = 0; i < blend->tuplecount; i++ )
+ for ( i = 0; i < gvar_head.globalCoordCount; i++ )
{
FT_TRACE5(( " [ " ));
for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ )
{
blend->tuplecoords[i * gvar_head.axisCount + j] =
- FT_GET_SHORT() * 4; /* convert to FT_Fixed */
+ FT_fdot14ToFixed( FT_GET_SHORT() );
FT_TRACE5(( "%.5f ",
- blend->tuplecoords[i * gvar_head.axisCount + j] / 65536.0 ));
+ (double)blend->tuplecoords[i * gvar_head.axisCount + j] / 65536 ));
}
FT_TRACE5(( "]\n" ));
}
+ blend->tuplecount = gvar_head.globalCoordCount;
+
FT_TRACE5(( "\n" ));
FT_FRAME_EXIT();
@@ -1564,36 +1864,49 @@
Exit:
return error;
+
+ Fail2:
+ FT_FRAME_EXIT();
+
+ Fail:
+ FT_FREE( blend->glyphoffsets );
+ blend->gv_glyphcnt = 0;
+ goto Exit;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* ft_var_apply_tuple */
- /* */
- /* <Description> */
- /* Figure out whether a given tuple (design) applies to the current */
- /* blend, and if so, what is the scaling factor. */
- /* */
- /* <Input> */
- /* blend :: The current blend of the font. */
- /* */
- /* tupleIndex :: A flag saying whether this is an intermediate */
- /* tuple or not. */
- /* */
- /* tuple_coords :: The coordinates of the tuple in normalized axis */
- /* units. */
- /* */
- /* im_start_coords :: The initial coordinates where this tuple starts */
- /* to apply (for intermediate coordinates). */
- /* */
- /* im_end_coords :: The final coordinates after which this tuple no */
- /* longer applies (for intermediate coordinates). */
- /* */
- /* <Return> */
- /* An FT_Fixed value containing the scaling factor. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * ft_var_apply_tuple
+ *
+ * @Description:
+ * Figure out whether a given tuple (design) applies to the current
+ * blend, and if so, what is the scaling factor.
+ *
+ * @Input:
+ * blend ::
+ * The current blend of the font.
+ *
+ * tupleIndex ::
+ * A flag saying whether this is an intermediate
+ * tuple or not.
+ *
+ * tuple_coords ::
+ * The coordinates of the tuple in normalized axis
+ * units.
+ *
+ * im_start_coords ::
+ * The initial coordinates where this tuple starts
+ * to apply (for intermediate coordinates).
+ *
+ * im_end_coords ::
+ * The final coordinates after which this tuple no
+ * longer applies (for intermediate coordinates).
+ *
+ * @Return:
+ * An FT_Fixed value containing the scaling factor.
+ */
static FT_Fixed
ft_var_apply_tuple( GX_Blend blend,
FT_UShort tupleIndex,
@@ -1607,13 +1920,8 @@
for ( i = 0; i < blend->num_axis; i++ )
{
- FT_TRACE6(( " axis coordinate %d (%.5f):\n",
- i, blend->normalizedcoords[i] / 65536.0 ));
- if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
- FT_TRACE6(( " intermediate coordinates %d (%.5f, %.5f):\n",
- i,
- im_start_coords[i] / 65536.0,
- im_end_coords[i] / 65536.0 ));
+ FT_TRACE6(( " axis %d coordinate %.5f:\n",
+ i, (double)blend->normalizedcoords[i] / 65536 ));
/* It's not clear why (for intermediate tuples) we don't need */
/* to check against start/end -- the documentation says we don't. */
@@ -1622,7 +1930,7 @@
if ( tuple_coords[i] == 0 )
{
- FT_TRACE6(( " tuple coordinate is zero, ignored\n", i ));
+ FT_TRACE6(( " tuple coordinate is zero, ignore\n" ));
continue;
}
@@ -1635,8 +1943,8 @@
if ( blend->normalizedcoords[i] == tuple_coords[i] )
{
- FT_TRACE6(( " tuple coordinate value %.5f fits perfectly\n",
- tuple_coords[i] / 65536.0 ));
+ FT_TRACE6(( " tuple coordinate %.5f fits perfectly\n",
+ (double)tuple_coords[i] / 65536 ));
/* `apply' does not change */
continue;
}
@@ -1648,14 +1956,14 @@
if ( blend->normalizedcoords[i] < FT_MIN( 0, tuple_coords[i] ) ||
blend->normalizedcoords[i] > FT_MAX( 0, tuple_coords[i] ) )
{
- FT_TRACE6(( " tuple coordinate value %.5f is exceeded, stop\n",
- tuple_coords[i] / 65536.0 ));
+ FT_TRACE6(( " tuple coordinate %.5f is exceeded, stop\n",
+ (double)tuple_coords[i] / 65536 ));
apply = 0;
break;
}
- FT_TRACE6(( " tuple coordinate value %.5f fits\n",
- tuple_coords[i] / 65536.0 ));
+ FT_TRACE6(( " tuple coordinate %.5f fits\n",
+ (double)tuple_coords[i] / 65536 ));
apply = FT_MulDiv( apply,
blend->normalizedcoords[i],
tuple_coords[i] );
@@ -1664,40 +1972,32 @@
{
/* intermediate tuple */
- if ( blend->normalizedcoords[i] < im_start_coords[i] ||
- blend->normalizedcoords[i] > im_end_coords[i] )
+ if ( blend->normalizedcoords[i] <= im_start_coords[i] ||
+ blend->normalizedcoords[i] >= im_end_coords[i] )
{
- FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] is exceeded,"
+ FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ is exceeded,"
" stop\n",
- im_start_coords[i] / 65536.0,
- im_end_coords[i] / 65536.0 ));
+ (double)im_start_coords[i] / 65536,
+ (double)im_end_coords[i] / 65536 ));
apply = 0;
break;
}
- else if ( blend->normalizedcoords[i] < tuple_coords[i] )
- {
- FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n",
- im_start_coords[i] / 65536.0,
- im_end_coords[i] / 65536.0 ));
+ FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ fits\n",
+ (double)im_start_coords[i] / 65536,
+ (double)im_end_coords[i] / 65536 ));
+ if ( blend->normalizedcoords[i] < tuple_coords[i] )
apply = FT_MulDiv( apply,
blend->normalizedcoords[i] - im_start_coords[i],
tuple_coords[i] - im_start_coords[i] );
- }
-
else
- {
- FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n",
- im_start_coords[i] / 65536.0,
- im_end_coords[i] / 65536.0 ));
apply = FT_MulDiv( apply,
im_end_coords[i] - blend->normalizedcoords[i],
im_end_coords[i] - tuple_coords[i] );
- }
}
}
- FT_TRACE6(( " apply factor is %.5f\n", apply / 65536.0 ));
+ FT_TRACE6(( " apply factor is %.5f\n", (double)apply / 65536 ));
return apply;
}
@@ -1711,12 +2011,18 @@
FT_Fixed* coords,
FT_Fixed* normalized )
{
+ FT_Error error = FT_Err_Ok;
+ FT_Memory memory = face->root.memory;
+ FT_UInt i, j;
+
GX_Blend blend;
FT_MM_Var* mmvar;
- FT_UInt i, j;
FT_Var_Axis* a;
GX_AVarSegment av;
+ FT_Fixed* new_normalized = NULL;
+ FT_Fixed* old_normalized;
+
blend = face->blend;
mmvar = blend->mmvar;
@@ -1739,28 +2045,25 @@
FT_Fixed coord = coords[i];
- FT_TRACE5(( " %d: %.5f\n", i, coord / 65536.0 ));
+ FT_TRACE5(( " %d: %.5f\n", i, (double)coord / 65536 ));
if ( coord > a->maximum || coord < a->minimum )
{
- FT_TRACE1((
- "ft_var_to_normalized: design coordinate %.5f\n"
- " is out of range [%.5f;%.5f]; clamping\n",
- coord / 65536.0,
- a->minimum / 65536.0,
- a->maximum / 65536.0 ));
-
- if ( coord > a->maximum )
- coord = a->maximum;
- else
- coord = a->minimum;
+ FT_TRACE1(( "ft_var_to_normalized: design coordinate %.5f\n",
+ (double)coord / 65536 ));
+ FT_TRACE1(( " is out of range [%.5f;%.5f];"
+ " clamping\n",
+ (double)a->minimum / 65536,
+ (double)a->maximum / 65536 ));
}
- if ( coord < a->def )
- normalized[i] = -FT_DivFix( coord - a->def,
- a->minimum - a->def );
- else if ( coord > a->def )
- normalized[i] = FT_DivFix( coord - a->def,
- a->maximum - a->def );
+ if ( coord > a->def )
+ normalized[i] = coord >= a->maximum ? 0x10000L :
+ FT_DivFix( SUB_LONG( coord, a->def ),
+ SUB_LONG( a->maximum, a->def ) );
+ else if ( coord < a->def )
+ normalized[i] = coord <= a->minimum ? -0x10000L :
+ FT_DivFix( SUB_LONG( coord, a->def ),
+ SUB_LONG( a->def, a->minimum ) );
else
normalized[i] = 0;
}
@@ -1770,30 +2073,91 @@
for ( ; i < mmvar->num_axis; i++ )
normalized[i] = 0;
- if ( blend->avar_segment )
+ if ( blend->avar_table )
{
+ GX_AVarTable table = blend->avar_table;
+
+
FT_TRACE5(( "normalized design coordinates"
" before applying `avar' data:\n" ));
- av = blend->avar_segment;
- for ( i = 0; i < mmvar->num_axis; i++, av++ )
+ if ( table->avar_segment )
{
- for ( j = 1; j < (FT_UInt)av->pairCount; j++ )
+ av = table->avar_segment;
+
+ for ( i = 0; i < mmvar->num_axis; i++, av++ )
{
- if ( normalized[i] < av->correspondence[j].fromCoord )
+ for ( j = 1; j < (FT_UInt)av->pairCount; j++ )
{
- FT_TRACE5(( " %.5f\n", normalized[i] / 65536.0 ));
+ if ( normalized[i] < av->correspondence[j].fromCoord )
+ {
+ FT_TRACE5(( " %.5f\n", (double)normalized[i] / 65536 ));
+
+ normalized[i] =
+ FT_MulDiv( normalized[i] - av->correspondence[j - 1].fromCoord,
+ av->correspondence[j].toCoord -
+ av->correspondence[j - 1].toCoord,
+ av->correspondence[j].fromCoord -
+ av->correspondence[j - 1].fromCoord ) +
+ av->correspondence[j - 1].toCoord;
+ break;
+ }
+ }
+ }
+ }
- normalized[i] =
- FT_MulDiv( normalized[i] - av->correspondence[j - 1].fromCoord,
- av->correspondence[j].toCoord -
- av->correspondence[j - 1].toCoord,
- av->correspondence[j].fromCoord -
- av->correspondence[j - 1].fromCoord ) +
- av->correspondence[j - 1].toCoord;
- break;
+ if ( table->itemStore.varData )
+ {
+ if ( FT_QNEW_ARRAY( new_normalized, mmvar->num_axis ) )
+ return;
+
+ /* Install our half-normalized coordinates for the next */
+ /* Item Variation Store to work with. */
+ old_normalized = face->blend->normalizedcoords;
+ face->blend->normalizedcoords = normalized;
+
+ for ( i = 0; i < mmvar->num_axis; i++ )
+ {
+ FT_Fixed v = normalized[i];
+ FT_UInt innerIndex = i;
+ FT_UInt outerIndex = 0;
+ FT_Int delta;
+
+
+ if ( table->axisMap.innerIndex )
+ {
+ FT_UInt idx = i;
+
+
+ if ( idx >= table->axisMap.mapCount )
+ idx = table->axisMap.mapCount - 1;
+
+ outerIndex = table->axisMap.outerIndex[idx];
+ innerIndex = table->axisMap.innerIndex[idx];
}
+
+ delta = tt_var_get_item_delta( FT_FACE( face ),
+ &table->itemStore,
+ outerIndex,
+ innerIndex );
+
+ v += delta << 2;
+
+ /* Clamp value range. */
+ v = v >= 0x10000L ? 0x10000 : v;
+ v = v <= -0x10000L ? -0x10000 : v;
+
+ new_normalized[i] = v;
}
+
+ for ( i = 0; i < mmvar->num_axis; i++ )
+ {
+ normalized[i] = new_normalized[i];
+ }
+
+ face->blend->normalizedcoords = old_normalized;
+
+ FT_FREE( new_normalized );
}
}
}
@@ -1831,9 +2195,9 @@
for ( ; i < num_coords; i++ )
design[i] = 0;
- if ( blend->avar_segment )
+ if ( blend->avar_table && blend->avar_table->avar_segment )
{
- GX_AVarSegment av = blend->avar_segment;
+ GX_AVarSegment av = blend->avar_table->avar_segment;
FT_TRACE5(( "design coordinates"
@@ -1853,7 +2217,7 @@
av->correspondence[j - 1].toCoord ) +
av->correspondence[j - 1].fromCoord;
- FT_TRACE5(( " %.5f\n", design[i] / 65536.0 ));
+ FT_TRACE5(( " %.5f\n", (double)design[i] / 65536 ));
break;
}
}
@@ -1910,33 +2274,36 @@
} GX_FVar_Axis;
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Get_MM_Var */
- /* */
- /* <Description> */
- /* Check that the font's `fvar' table is valid, parse it, and return */
- /* those data. It also loads (and parses) the `MVAR' table, if */
- /* possible. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* TT_Get_MM_Var initializes the blend structure. */
- /* */
- /* <Output> */
- /* master :: The `fvar' data (must be freed by caller). Can be NULL, */
- /* which makes this function simply load MM support. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Get_MM_Var
+ *
+ * @Description:
+ * Check that the font's `fvar' table is valid, parse it, and return
+ * those data. It also loads (and parses) the `MVAR' table, if
+ * possible.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ * TT_Get_MM_Var initializes the blend structure.
+ *
+ * @Output:
+ * master ::
+ * The `fvar' data (must be freed by caller). Can be NULL,
+ * which makes this function simply load MM support.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
- TT_Get_MM_Var( TT_Face face,
+ TT_Get_MM_Var( FT_Face face, /* TT_Face */
FT_MM_Var* *master )
{
- FT_Stream stream = face->root.stream;
- FT_Memory memory = face->root.memory;
+ TT_Face ttface = (TT_Face)face;
+ FT_Stream stream = FT_FACE_STREAM( face );
+ FT_Memory memory = FT_FACE_MEMORY( face );
FT_ULong table_len;
FT_Error error = FT_Err_Ok;
FT_ULong fvar_start = 0;
@@ -1948,7 +2315,7 @@
FT_Var_Axis* a;
FT_Fixed* c;
FT_Var_Named_Style* ns;
- GX_FVar_Head fvar_head;
+ GX_FVar_Head fvar_head = { 0, 0, 0, 0, 0, 0 };
FT_Bool usePsName = 0;
FT_UInt num_instances;
FT_UInt num_axes;
@@ -1996,32 +2363,23 @@
FT_FRAME_END
};
+ /* `num_instances` holds the number of all named instances including */
+ /* the default instance, which might be missing in the table of named */
+ /* instances (in 'fvar'). This value is validated in `sfobjs.c` and */
+ /* may be reset to 0 if consistency checks fail. */
+ num_instances = (FT_UInt)face->style_flags >> 16;
/* read the font data and set up the internal representation */
/* if not already done */
- need_init = !face->blend;
+ need_init = !ttface->blend;
if ( need_init )
{
FT_TRACE2(( "FVAR " ));
- /* both `fvar' and `gvar' must be present */
- if ( FT_SET_ERROR( face->goto_table( face, TTAG_gvar,
- stream, &table_len ) ) )
- {
- /* CFF2 is an alternate to gvar here */
- if ( FT_SET_ERROR( face->goto_table( face, TTAG_CFF2,
+ if ( FT_SET_ERROR( ttface->goto_table( ttface, TTAG_fvar,
stream, &table_len ) ) )
- {
- FT_TRACE1(( "\n"
- "TT_Get_MM_Var: `gvar' or `CFF2' table is missing\n" ));
- goto Exit;
- }
- }
-
- if ( FT_SET_ERROR( face->goto_table( face, TTAG_fvar,
- stream, &table_len ) ) )
{
FT_TRACE1(( "is missing\n" ));
goto Exit;
@@ -2034,6 +2392,17 @@
if ( FT_STREAM_READ_FIELDS( fvar_fields, &fvar_head ) )
goto Exit;
+ /* If `num_instances` is larger, synthetization of the default */
+ /* instance is required. If `num_instances` is smaller, */
+ /* however, the value has been reset to 0 in `sfnt_init_face` */
+ /* (in `sfobjs.c`); in this case we have underallocated `mmvar` */
+ /* structs. */
+ if ( num_instances < fvar_head.instanceCount )
+ {
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
usePsName = FT_BOOL( fvar_head.instanceSize ==
6 + 4 * fvar_head.axisCount );
@@ -2043,26 +2412,21 @@
fvar_head.axisCount,
fvar_head.axisCount == 1 ? "is" : "es" ));
- if ( FT_NEW( face->blend ) )
+ if ( FT_NEW( ttface->blend ) )
goto Exit;
- num_axes = fvar_head.axisCount;
- face->blend->num_axis = num_axes;
+ num_axes = fvar_head.axisCount;
+ ttface->blend->num_axis = num_axes;
}
else
- num_axes = face->blend->num_axis;
-
- /* `num_instances' holds the number of all named instances, */
- /* including the default instance which might be missing */
- /* in fvar's table of named instances */
- num_instances = (FT_UInt)face->root.style_flags >> 16;
+ num_axes = ttface->blend->num_axis;
/* prepare storage area for MM data; this cannot overflow */
/* 32-bit arithmetic because of the size limits used in the */
/* `fvar' table validity check in `sfnt_init_face' */
/* the various `*_size' variables, which we also use as */
- /* offsets into the `mmlen' array, must be multiples of the */
+ /* offsets into the `mmvar' array, must be multiples of the */
/* pointer size (except the last one); without such an */
/* alignment there might be runtime errors due to */
/* misaligned addresses */
@@ -2084,16 +2448,16 @@
if ( need_init )
{
- face->blend->mmvar_len = mmvar_size +
- axis_flags_size +
- axis_size +
- namedstyle_size +
- next_coords_size +
- next_name_size;
-
- if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
+ ttface->blend->mmvar_len = mmvar_size +
+ axis_flags_size +
+ axis_size +
+ namedstyle_size +
+ next_coords_size +
+ next_name_size;
+
+ if ( FT_ALLOC( mmvar, ttface->blend->mmvar_len ) )
goto Exit;
- face->blend->mmvar = mmvar;
+ ttface->blend->mmvar = mmvar;
/* set up pointers and offsets into the `mmvar' array; */
/* the data gets filled in later on */
@@ -2184,9 +2548,9 @@
" %10.5f %10.5f %10.5f 0x%04X%s\n",
i,
a->name,
- a->minimum / 65536.0,
- a->def / 65536.0,
- a->maximum / 65536.0,
+ (double)a->minimum / 65536,
+ (double)a->def / 65536,
+ (double)a->maximum / 65536,
*axis_flags,
invalid ? " (invalid, disabled)" : "" ));
#endif
@@ -2199,27 +2563,27 @@
/* named instance coordinates are stored as design coordinates; */
/* we have to convert them to normalized coordinates also */
- if ( FT_NEW_ARRAY( face->blend->normalized_stylecoords,
+ if ( FT_NEW_ARRAY( ttface->blend->normalized_stylecoords,
num_axes * num_instances ) )
goto Exit;
- if ( fvar_head.instanceCount && !face->blend->avar_loaded )
+ if ( fvar_head.instanceCount && !ttface->blend->avar_loaded )
{
FT_ULong offset = FT_STREAM_POS();
- ft_var_load_avar( face );
+ ft_var_load_avar( ttface );
if ( FT_STREAM_SEEK( offset ) )
goto Exit;
}
- FT_TRACE5(( "%d instance%s\n",
+ FT_TRACE5(( "%d named instance%s\n",
fvar_head.instanceCount,
fvar_head.instanceCount == 1 ? "" : "s" ));
ns = mmvar->namedstyle;
- nsc = face->blend->normalized_stylecoords;
+ nsc = ttface->blend->normalized_stylecoords;
for ( i = 0; i < fvar_head.instanceCount; i++, ns++ )
{
/* PostScript names add 2 bytes to the instance record size */
@@ -2242,7 +2606,7 @@
#ifdef FT_DEBUG_LEVEL_TRACE
{
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+ SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
FT_String* strname = NULL;
FT_String* psname = NULL;
@@ -2254,7 +2618,7 @@
if ( ns->strid != 0xFFFF )
{
- (void)sfnt->get_name( face,
+ (void)sfnt->get_name( ttface,
(FT_UShort)ns->strid,
&strname );
if ( strname && !ft_strcmp( strname, ".notdef" ) )
@@ -2263,7 +2627,7 @@
if ( ns->psid != 0xFFFF )
{
- (void)sfnt->get_name( face,
+ (void)sfnt->get_name( ttface,
(FT_UShort)ns->psid,
&psname );
if ( psname && !ft_strcmp( psname, ".notdef" ) )
@@ -2272,7 +2636,7 @@
(void)FT_STREAM_SEEK( pos );
- FT_TRACE5(( " instance %d (%s%s%s, %s%s%s)\n",
+ FT_TRACE5(( " named instance %d (%s%s%s, %s%s%s)\n",
i,
strname ? "name: `" : "",
strname ? strname : "unnamed",
@@ -2286,7 +2650,7 @@
}
#endif /* FT_DEBUG_LEVEL_TRACE */
- ft_var_to_normalized( face, num_axes, ns->coords, nsc );
+ ft_var_to_normalized( ttface, num_axes, ns->coords, nsc );
nsc += num_axes;
FT_FRAME_EXIT();
@@ -2294,15 +2658,17 @@
if ( num_instances != fvar_head.instanceCount )
{
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+ SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
FT_Int found, dummy1, dummy2;
FT_UInt strid = ~0U;
- /* the default instance is missing in array the */
- /* of named instances; try to synthesize an entry */
- found = sfnt->get_name_id( face,
+ /* The default instance is missing in array the */
+ /* of named instances; try to synthesize an entry. */
+ /* If this fails, `default_named_instance` remains */
+ /* at value zero, which doesn't do any harm. */
+ found = sfnt->get_name_id( ttface,
TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY,
&dummy1,
&dummy2 );
@@ -2310,7 +2676,7 @@
strid = TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY;
else
{
- found = sfnt->get_name_id( face,
+ found = sfnt->get_name_id( ttface,
TT_NAME_ID_FONT_SUBFAMILY,
&dummy1,
&dummy2 );
@@ -2320,7 +2686,7 @@
if ( found )
{
- found = sfnt->get_name_id( face,
+ found = sfnt->get_name_id( ttface,
TT_NAME_ID_PS_NAME,
&dummy1,
&dummy2 );
@@ -2329,6 +2695,9 @@
FT_TRACE5(( "TT_Get_MM_Var:"
" Adding default instance to named instances\n" ));
+ /* named instance indices start with value 1 */
+ ttface->var_default_named_instance = num_instances;
+
ns = &mmvar->namedstyle[fvar_head.instanceCount];
ns->strid = strid;
@@ -2342,7 +2711,7 @@
}
}
- ft_var_load_mvar( face );
+ ft_var_load_mvar( ttface );
}
/* fill the output array if requested */
@@ -2352,9 +2721,9 @@
FT_UInt n;
- if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
+ if ( FT_ALLOC( mmvar, ttface->blend->mmvar_len ) )
goto Exit;
- FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len );
+ FT_MEM_COPY( mmvar, ttface->blend->mmvar, ttface->blend->mmvar_len );
axis_flags =
(FT_UShort*)( (char*)mmvar + mmvar_size );
@@ -2387,6 +2756,8 @@
a->name = (char*)"OpticalSize";
else if ( a->tag == TTAG_slnt )
a->name = (char*)"Slant";
+ else if ( a->tag == TTAG_ital )
+ a->name = (char*)"Italic";
next_name += 5;
a++;
@@ -2428,7 +2799,7 @@
if ( !face->blend )
{
- if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
+ if ( FT_SET_ERROR( TT_Get_MM_Var( FT_FACE( face ), NULL ) ) )
goto Exit;
}
@@ -2443,17 +2814,17 @@
num_coords = mmvar->num_axis;
}
- FT_TRACE5(( "TT_Set_MM_Blend:\n"
- " normalized design coordinates:\n" ));
+ FT_TRACE5(( "TT_Set_MM_Blend:\n" ));
+ FT_TRACE5(( " normalized design coordinates:\n" ));
for ( i = 0; i < num_coords; i++ )
{
- FT_TRACE5(( " %.5f\n", coords[i] / 65536.0 ));
+ FT_TRACE5(( " %.5f\n", (double)coords[i] / 65536 ));
if ( coords[i] < -0x00010000L || coords[i] > 0x00010000L )
{
- FT_TRACE1(( "TT_Set_MM_Blend: normalized design coordinate %.5f\n"
- " is out of range [-1;1]\n",
- coords[i] / 65536.0 ));
+ FT_TRACE1(( "TT_Set_MM_Blend: normalized design coordinate %.5f\n",
+ (double)coords[i] / 65536 ));
+ FT_TRACE1(( " is out of range [-1;1]\n" ));
error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -2462,8 +2833,16 @@
FT_TRACE5(( "\n" ));
if ( !face->is_cff2 && !blend->glyphoffsets )
- if ( FT_SET_ERROR( ft_var_load_gvar( face ) ) )
+ {
+ /* While a missing 'gvar' table is acceptable, for example for */
+ /* fonts that only vary metrics information or 'COLR' v1 */
+ /* `PaintVar*` tables, an incorrect SFNT table offset or size */
+ /* for 'gvar', or an inconsistent 'gvar' table is not. */
+ error = ft_var_load_gvar( face );
+ if ( error != FT_Err_Table_Missing && error != FT_Err_Ok )
goto Exit;
+ error = FT_Err_Ok;
+ }
if ( !blend->coords )
{
@@ -2505,28 +2884,38 @@
}
}
- if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) )
+ if ( !have_diff )
{
- FT_UInt idx = (FT_UInt)face->root.face_index >> 16;
+ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) )
+ {
+ FT_UInt instance_index = (FT_UInt)face->root.face_index >> 16;
- c = blend->normalizedcoords + i;
- n = blend->normalized_stylecoords + idx * mmvar->num_axis + i;
- for ( j = i; j < mmvar->num_axis; j++, n++, c++ )
- if ( *c != *n )
- have_diff = 1;
- }
- else
- {
- c = blend->normalizedcoords + i;
- for ( j = i; j < mmvar->num_axis; j++, c++ )
- if ( *c != 0 )
- have_diff = 1;
+ c = blend->normalizedcoords + i;
+ n = blend->normalized_stylecoords +
+ ( instance_index - 1 ) * mmvar->num_axis +
+ i;
+
+ for ( j = i; j < mmvar->num_axis; j++, n++, c++ )
+ if ( *c != *n )
+ have_diff = 1;
+ }
+ else
+ {
+ c = blend->normalizedcoords + i;
+ for ( j = i; j < mmvar->num_axis; j++, c++ )
+ if ( *c != 0 )
+ have_diff = 1;
+ }
}
/* return value -1 indicates `no change' */
if ( !have_diff )
+ {
+ face->doblend = TRUE;
+
return -1;
+ }
for ( ; i < mmvar->num_axis; i++ )
{
@@ -2544,9 +2933,10 @@
}
blend->num_axis = mmvar->num_axis;
- FT_MEM_COPY( blend->normalizedcoords,
- coords,
- num_coords * sizeof ( FT_Fixed ) );
+ if ( coords )
+ FT_MEM_COPY( blend->normalizedcoords,
+ coords,
+ num_coords * sizeof ( FT_Fixed ) );
if ( set_design_coords )
ft_var_to_design( face,
@@ -2564,7 +2954,6 @@
/* The cvt table has been loaded already; every time we change the */
/* blend we may need to reload and remodify the cvt table. */
FT_FREE( face->cvt );
- face->cvt = NULL;
error = tt_face_load_cvt( face, face->root.stream );
break;
@@ -2581,107 +2970,101 @@
}
}
- /* enforce recomputation of the PostScript name; */
- FT_FREE( face->postscript_name );
- face->postscript_name = NULL;
-
Exit:
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Set_MM_Blend */
- /* */
- /* <Description> */
- /* Set the blend (normalized) coordinates for this instance of the */
- /* font. Check that the `gvar' table is reasonable and does some */
- /* initial preparation. */
- /* */
- /* <InOut> */
- /* face :: The font. */
- /* Initialize the blend structure with `gvar' data. */
- /* */
- /* <Input> */
- /* num_coords :: The number of available coordinates. If it is */
- /* larger than the number of axes, ignore the excess */
- /* values. If it is smaller than the number of axes, */
- /* use the default value (0) for the remaining axes. */
- /* */
- /* coords :: An array of `num_coords', each between [-1,1]. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Set_MM_Blend
+ *
+ * @Description:
+ * Set the blend (normalized) coordinates for this instance of the
+ * font. Check that the `gvar' table is reasonable and does some
+ * initial preparation.
+ *
+ * @InOut:
+ * face ::
+ * The font.
+ * Initialize the blend structure with `gvar' data.
+ *
+ * @Input:
+ * num_coords ::
+ * The number of available coordinates. If it is
+ * larger than the number of axes, ignore the excess
+ * values. If it is smaller than the number of axes,
+ * use the default value (0) for the remaining axes.
+ *
+ * coords ::
+ * An array of `num_coords', each between [-1,1].
+ *
+ * @Return:
+ * FreeType error code. 0 means success, -1 means success and unchanged
+ * axis values.
+ */
FT_LOCAL_DEF( FT_Error )
- TT_Set_MM_Blend( TT_Face face,
+ TT_Set_MM_Blend( FT_Face face, /* TT_Face */
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Error error;
-
-
- error = tt_set_mm_blend( face, num_coords, coords, 1 );
- if ( error )
- return error;
-
- if ( num_coords )
- face->root.face_flags |= FT_FACE_FLAG_VARIATION;
- else
- face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
-
- return FT_Err_Ok;
+ return tt_set_mm_blend( (TT_Face)face, num_coords, coords, 1 );
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Get_MM_Blend */
- /* */
- /* <Description> */
- /* Get the blend (normalized) coordinates for this instance of the */
- /* font. */
- /* */
- /* <InOut> */
- /* face :: The font. */
- /* Initialize the blend structure with `gvar' data. */
- /* */
- /* <Input> */
- /* num_coords :: The number of available coordinates. If it is */
- /* larger than the number of axes, set the excess */
- /* values to 0. */
- /* */
- /* coords :: An array of `num_coords', each between [-1,1]. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Get_MM_Blend
+ *
+ * @Description:
+ * Get the blend (normalized) coordinates for this instance of the
+ * font.
+ *
+ * @InOut:
+ * face ::
+ * The font.
+ * Initialize the blend structure with `gvar' data.
+ *
+ * @Input:
+ * num_coords ::
+ * The number of available coordinates. If it is
+ * larger than the number of axes, set the excess
+ * values to 0.
+ *
+ * coords ::
+ * An array of `num_coords', each between [-1,1].
+ *
+ * @Return:
+ * FreeType error code. 0 means success, -1 means success and unchanged
+ * axis values.
+ */
FT_LOCAL_DEF( FT_Error )
- TT_Get_MM_Blend( TT_Face face,
+ TT_Get_MM_Blend( FT_Face face, /* TT_Face */
FT_UInt num_coords,
FT_Fixed* coords )
{
+ TT_Face ttface = (TT_Face)face;
+
FT_Error error = FT_Err_Ok;
GX_Blend blend;
FT_UInt i, nc;
- if ( !face->blend )
+ if ( !ttface->blend )
{
if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
return error;
}
- blend = face->blend;
+ blend = ttface->blend;
if ( !blend->coords )
{
/* select default instance coordinates */
/* if no instance is selected yet */
- if ( FT_SET_ERROR( tt_set_mm_blend( face, 0, NULL, 1 ) ) )
+ if ( FT_SET_ERROR( tt_set_mm_blend( ttface, 0, NULL, 1 ) ) )
return error;
}
@@ -2694,7 +3077,7 @@
nc = blend->num_axis;
}
- if ( face->doblend )
+ if ( ttface->doblend )
{
for ( i = 0; i < nc; i++ )
coords[i] = blend->normalizedcoords[i];
@@ -2712,41 +3095,45 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Set_Var_Design */
- /* */
- /* <Description> */
- /* Set the coordinates for the instance, measured in the user */
- /* coordinate system. Parse the `avar' table (if present) to convert */
- /* from user to normalized coordinates. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* Initialize the blend struct with `gvar' data. */
- /* */
- /* <Input> */
- /* num_coords :: The number of available coordinates. If it is */
- /* larger than the number of axes, ignore the excess */
- /* values. If it is smaller than the number of axes, */
- /* use the default values for the remaining axes. */
- /* */
- /* coords :: A coordinate array with `num_coords' elements. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Set_Var_Design
+ *
+ * @Description:
+ * Set the coordinates for the instance, measured in the user
+ * coordinate system. Parse the `avar' table (if present) to convert
+ * from user to normalized coordinates.
+ *
+ * @InOut:
+ * face ::
+ * The font face.
+ * Initialize the blend struct with `gvar' data.
+ *
+ * @Input:
+ * num_coords ::
+ * The number of available coordinates. If it is
+ * larger than the number of axes, ignore the excess
+ * values. If it is smaller than the number of axes,
+ * use the default values for the remaining axes.
+ *
+ * coords ::
+ * A coordinate array with `num_coords' elements.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
- TT_Set_Var_Design( TT_Face face,
+ TT_Set_Var_Design( FT_Face face, /* TT_Face */
FT_UInt num_coords,
FT_Fixed* coords )
{
+ TT_Face ttface = (TT_Face)face;
FT_Error error = FT_Err_Ok;
GX_Blend blend;
FT_MM_Var* mmvar;
FT_UInt i;
- FT_Memory memory = face->root.memory;
+ FT_Memory memory = FT_FACE_MEMORY( face );
FT_Fixed* c;
FT_Fixed* n;
@@ -2755,13 +3142,13 @@
FT_Bool have_diff = 0;
- if ( !face->blend )
+ if ( !ttface->blend )
{
if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
goto Exit;
}
- blend = face->blend;
+ blend = ttface->blend;
mmvar = blend->mmvar;
if ( num_coords > mmvar->num_axis )
@@ -2789,13 +3176,13 @@
}
}
- if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) )
+ if ( FT_IS_NAMED_INSTANCE( face ) )
{
FT_UInt instance_index;
FT_Var_Named_Style* named_style;
- instance_index = (FT_UInt)face->root.face_index >> 16;
+ instance_index = (FT_UInt)face->face_index >> 16;
named_style = mmvar->namedstyle + instance_index - 1;
n = named_style->coords + num_coords;
@@ -2832,73 +3219,72 @@
if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
goto Exit;
- if ( !face->blend->avar_loaded )
- ft_var_load_avar( face );
+ if ( !ttface->blend->avar_loaded )
+ ft_var_load_avar( ttface );
- FT_TRACE5(( "TT_Set_Var_Design:\n"
- " normalized design coordinates:\n" ));
- ft_var_to_normalized( face, num_coords, blend->coords, normalized );
+ FT_TRACE5(( "TT_Set_Var_Design:\n" ));
+ FT_TRACE5(( " normalized design coordinates:\n" ));
+ ft_var_to_normalized( ttface, num_coords, blend->coords, normalized );
- error = tt_set_mm_blend( face, mmvar->num_axis, normalized, 0 );
+ error = tt_set_mm_blend( ttface, mmvar->num_axis, normalized, 0 );
if ( error )
goto Exit;
- if ( num_coords )
- face->root.face_flags |= FT_FACE_FLAG_VARIATION;
- else
- face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
-
Exit:
FT_FREE( normalized );
return error;
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Get_Var_Design */
- /* */
- /* <Description> */
- /* Get the design coordinates of the currently selected interpolated */
- /* font. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face. */
- /* */
- /* num_coords :: The number of design coordinates to retrieve. If it */
- /* is larger than the number of axes, set the excess */
- /* values to~0. */
- /* */
- /* <Output> */
- /* coords :: The design coordinates array. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Get_Var_Design
+ *
+ * @Description:
+ * Get the design coordinates of the currently selected interpolated
+ * font.
+ *
+ * @Input:
+ * face ::
+ * A handle to the source face.
+ *
+ * num_coords ::
+ * The number of design coordinates to retrieve. If it
+ * is larger than the number of axes, set the excess
+ * values to~0.
+ *
+ * @Output:
+ * coords ::
+ * The design coordinates array.
+ *
+ * @Return:
+ * FreeType error code. 0~means success.
+ */
FT_LOCAL_DEF( FT_Error )
- TT_Get_Var_Design( TT_Face face,
+ TT_Get_Var_Design( FT_Face face, /* TT_Face */
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Error error = FT_Err_Ok;
+ TT_Face ttface = (TT_Face)face;
+ FT_Error error = FT_Err_Ok;
GX_Blend blend;
FT_UInt i, nc;
- if ( !face->blend )
+ if ( !ttface->blend )
{
if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
return error;
}
- blend = face->blend;
+ blend = ttface->blend;
if ( !blend->coords )
{
/* select default instance coordinates */
/* if no instance is selected yet */
- if ( FT_SET_ERROR( tt_set_mm_blend( face, 0, NULL, 1 ) ) )
+ if ( FT_SET_ERROR( tt_set_mm_blend( ttface, 0, NULL, 1 ) ) )
return error;
}
@@ -2911,7 +3297,7 @@
nc = blend->num_axis;
}
- if ( face->doblend )
+ if ( ttface->doblend )
{
for ( i = 0; i < nc; i++ )
coords[i] = blend->coords[i];
@@ -2929,54 +3315,62 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Set_Named_Instance */
- /* */
- /* <Description> */
- /* Set the given named instance, also resetting any further */
- /* variation. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face. */
- /* */
- /* instance_index :: The instance index, starting with value 1. */
- /* Value 0 indicates to not use an instance. */
- /* */
- /* <Return> */
- /* FreeType error code. 0~means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Set_Named_Instance
+ *
+ * @Description:
+ * Set the given named instance, also resetting any further
+ * variation.
+ *
+ * @Input:
+ * face ::
+ * A handle to the source face.
+ *
+ * instance_index ::
+ * The instance index, starting with value 1.
+ * Value 0 indicates to not use an instance.
+ *
+ * @Return:
+ * FreeType error code. 0~means success, -1 means success and unchanged
+ * axis values.
+ */
FT_LOCAL_DEF( FT_Error )
- TT_Set_Named_Instance( TT_Face face,
+ TT_Set_Named_Instance( FT_Face face, /* TT_Face */
FT_UInt instance_index )
{
- FT_Error error = FT_ERR( Invalid_Argument );
+ TT_Face ttface = (TT_Face)face;
+ FT_Error error;
GX_Blend blend;
FT_MM_Var* mmvar;
+ FT_Memory memory = FT_FACE_MEMORY( face );
+
FT_UInt num_instances;
- if ( !face->blend )
+ if ( !ttface->blend )
{
if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
goto Exit;
}
- blend = face->blend;
+ blend = ttface->blend;
mmvar = blend->mmvar;
- num_instances = (FT_UInt)face->root.style_flags >> 16;
+ num_instances = (FT_UInt)face->style_flags >> 16;
/* `instance_index' starts with value 1, thus `>' */
if ( instance_index > num_instances )
+ {
+ error = FT_ERR( Invalid_Argument );
goto Exit;
+ }
- if ( instance_index > 0 && mmvar->namedstyle )
+ if ( instance_index > 0 )
{
- FT_Memory memory = face->root.memory;
- SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+ SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
FT_Var_Named_Style* named_style;
FT_String* style_name;
@@ -2984,35 +3378,89 @@
named_style = mmvar->namedstyle + instance_index - 1;
- error = sfnt->get_name( face,
+ error = sfnt->get_name( ttface,
(FT_UShort)named_style->strid,
&style_name );
if ( error )
goto Exit;
/* set (or replace) style name */
- FT_FREE( face->root.style_name );
- face->root.style_name = style_name;
+ FT_FREE( face->style_name );
+ face->style_name = style_name;
/* finally, select the named instance */
error = TT_Set_Var_Design( face,
mmvar->num_axis,
named_style->coords );
- if ( error )
- goto Exit;
}
else
+ {
+ /* restore non-VF style name */
+ FT_FREE( face->style_name );
+ if ( FT_STRDUP( face->style_name, ttface->non_var_style_name ) )
+ goto Exit;
error = TT_Set_Var_Design( face, 0, NULL );
+ }
+
+ Exit:
+ return error;
+ }
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Get_Default_Named_Instance
+ *
+ * @Description:
+ * Get the default named instance.
+ *
+ * @Input:
+ * face ::
+ * A handle to the source face.
+ *
+ * @Output:
+ * instance_index ::
+ * The default named instance index.
+ *
+ * @Return:
+ * FreeType error code. 0~means success.
+ */
+ FT_LOCAL_DEF( FT_Error )
+ TT_Get_Default_Named_Instance( FT_Face face,
+ FT_UInt *instance_index )
+ {
+ TT_Face ttface = (TT_Face)face;
+ FT_Error error = FT_Err_Ok;
- face->root.face_index = ( instance_index << 16 ) |
- ( face->root.face_index & 0xFFFFL );
- face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ if ( !ttface->blend )
+ {
+ if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
+ goto Exit;
+ }
+
+ *instance_index = ttface->var_default_named_instance;
Exit:
return error;
}
+ /* This function triggers (lazy) recomputation of the `postscript_name` */
+ /* field in `TT_Face`. */
+
+ FT_LOCAL_DEF( void )
+ tt_construct_ps_name( FT_Face face )
+ {
+ TT_Face ttface = (TT_Face)face;
+ FT_Memory memory = FT_FACE_MEMORY( face );
+
+
+ FT_FREE( ttface->postscript_name );
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -3022,64 +3470,100 @@
/*************************************************************************/
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_vary_cvt */
- /* */
- /* <Description> */
- /* Modify the loaded cvt table according to the `cvar' table and the */
- /* font's blend. */
- /* */
- /* <InOut> */
- /* face :: A handle to the target face object. */
- /* */
- /* <Input> */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* Most errors are ignored. It is perfectly valid not to have a */
- /* `cvar' table even if there is a `gvar' and `fvar' table. */
- /* */
+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
+ static FT_Error
+ tt_cvt_ready_iterator( FT_ListNode node,
+ void* user )
+ {
+ TT_Size size = (TT_Size)node->data;
+
+ FT_UNUSED( user );
+
+
+ size->cvt_ready = -1;
+
+ return FT_Err_Ok;
+ }
+
+#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_vary_cvt
+ *
+ * @Description:
+ * Modify the loaded cvt table according to the `cvar' table and the
+ * font's blend.
+ *
+ * @InOut:
+ * face ::
+ * A handle to the target face object.
+ *
+ * @Input:
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ *
+ * Most errors are ignored. It is perfectly valid not to have a
+ * `cvar' table even if there is a `gvar' and `fvar' table.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_vary_cvt( TT_Face face,
FT_Stream stream )
{
- FT_Error error;
- FT_Memory memory = stream->memory;
- FT_ULong table_start;
- FT_ULong table_len;
- FT_UInt tupleCount;
- FT_ULong offsetToData;
- FT_ULong here;
- FT_UInt i, j;
- FT_Fixed* tuple_coords = NULL;
- FT_Fixed* im_start_coords = NULL;
- FT_Fixed* im_end_coords = NULL;
- GX_Blend blend = face->blend;
- FT_UInt point_count, spoint_count = 0;
+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
+ FT_Error error;
+ FT_Memory memory = stream->memory;
+
+ FT_Face root = &face->root;
+
+ FT_ULong table_start;
+ FT_ULong table_len;
+
+ FT_UInt tupleCount;
+ FT_ULong offsetToData;
+
+ FT_ULong here;
+ FT_UInt i, j;
+
+ FT_Fixed* tuple_coords = NULL;
+ FT_Fixed* im_start_coords = NULL;
+ FT_Fixed* im_end_coords = NULL;
+
+ GX_Blend blend = face->blend;
+
+ FT_UInt point_count;
+ FT_UInt spoint_count = 0;
+
FT_UShort* sharedpoints = NULL;
FT_UShort* localpoints = NULL;
FT_UShort* points;
- FT_Short* deltas;
+
+ FT_Fixed* deltas = NULL;
+ FT_Fixed* cvt_deltas = NULL;
FT_TRACE2(( "CVAR " ));
if ( !blend )
{
- FT_TRACE2(( "\n"
- "tt_face_vary_cvt: no blend specified\n" ));
+ FT_TRACE2(( "\n" ));
+ FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" ));
error = FT_Err_Ok;
goto Exit;
}
if ( !face->cvt )
{
- FT_TRACE2(( "\n"
- "tt_face_vary_cvt: no `cvt ' table\n" ));
+ FT_TRACE2(( "\n" ));
+ FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" ));
error = FT_Err_Ok;
goto Exit;
}
@@ -3146,11 +3630,14 @@
}
FT_TRACE5(( "cvar: there %s %d tuple%s:\n",
- ( tupleCount & 0xFFF ) == 1 ? "is" : "are",
- tupleCount & 0xFFF,
- ( tupleCount & 0xFFF ) == 1 ? "" : "s" ));
+ ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are",
+ tupleCount & GX_TC_TUPLE_COUNT_MASK,
+ ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
- for ( i = 0; i < ( tupleCount & 0xFFF ); i++ )
+ if ( FT_NEW_ARRAY( cvt_deltas, face->cvt_size ) )
+ goto FExit;
+
+ for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
{
FT_UInt tupleDataSize;
FT_UInt tupleIndex;
@@ -3165,8 +3652,7 @@
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; j++ )
- tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */
- /* short frac to fixed */
+ tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
@@ -3174,20 +3660,32 @@
" invalid tuple index\n" ));
error = FT_THROW( Invalid_Table );
- goto Exit;
+ goto FExit;
}
else
+ {
+ if ( !blend->tuplecoords )
+ {
+ FT_TRACE2(( "tt_face_vary_cvt:"
+ " no valid tuple coordinates available\n" ));
+
+ error = FT_THROW( Invalid_Table );
+ goto FExit;
+ }
+
FT_MEM_COPY(
tuple_coords,
- &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis],
+ blend->tuplecoords +
+ ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis,
blend->num_axis * sizeof ( FT_Fixed ) );
+ }
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; j++ )
- im_start_coords[j] = FT_GET_SHORT() * 4;
+ im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
for ( j = 0; j < blend->num_axis; j++ )
- im_end_coords[j] = FT_GET_SHORT() * 4;
+ im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
apply = ft_var_apply_tuple( blend,
@@ -3215,6 +3713,7 @@
}
else
{
+ localpoints = NULL;
points = sharedpoints;
point_count = spoint_count;
}
@@ -3224,9 +3723,7 @@
point_count == 0 ? face->cvt_size
: point_count );
- if ( !points ||
- !deltas ||
- ( localpoints == ALL_POINTS && point_count != face->cvt_size ) )
+ if ( !points || !deltas )
; /* failure, ignore it */
else if ( localpoints == ALL_POINTS )
@@ -3241,17 +3738,21 @@
/* this means that there are deltas for every entry in cvt */
for ( j = 0; j < face->cvt_size; j++ )
{
- FT_Long orig_cvt = face->cvt[j];
+ FT_Fixed old_cvt_delta;
- face->cvt[j] = (FT_Short)( orig_cvt +
- FT_MulFix( deltas[j], apply ) );
+ old_cvt_delta = cvt_deltas[j];
+ cvt_deltas[j] = old_cvt_delta + FT_MulFix( deltas[j], apply );
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( orig_cvt != face->cvt[j] )
+ if ( old_cvt_delta != cvt_deltas[j] )
{
- FT_TRACE7(( " %d: %d -> %d\n",
- j, orig_cvt, face->cvt[j] ));
+ FT_TRACE7(( " %d: %f -> %f\n",
+ j,
+ (double)( FT_fdot6ToFixed( face->cvt[j] ) +
+ old_cvt_delta ) / 65536,
+ (double)( FT_fdot6ToFixed( face->cvt[j] ) +
+ cvt_deltas[j] ) / 65536 ));
count++;
}
#endif
@@ -3274,23 +3775,26 @@
for ( j = 0; j < point_count; j++ )
{
- int pindex;
- FT_Long orig_cvt;
+ int pindex;
+ FT_Fixed old_cvt_delta;
pindex = points[j];
if ( (FT_ULong)pindex >= face->cvt_size )
continue;
- orig_cvt = face->cvt[pindex];
- face->cvt[pindex] = (FT_Short)( orig_cvt +
- FT_MulFix( deltas[j], apply ) );
+ old_cvt_delta = cvt_deltas[pindex];
+ cvt_deltas[pindex] = old_cvt_delta + FT_MulFix( deltas[j], apply );
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( orig_cvt != face->cvt[pindex] )
+ if ( old_cvt_delta != cvt_deltas[pindex] )
{
- FT_TRACE7(( " %d: %d -> %d\n",
- pindex, orig_cvt, face->cvt[pindex] ));
+ FT_TRACE7(( " %d: %f -> %f\n",
+ pindex,
+ (double)( FT_fdot6ToFixed( face->cvt[pindex] ) +
+ old_cvt_delta ) / 65536,
+ (double)( FT_fdot6ToFixed( face->cvt[pindex] ) +
+ cvt_deltas[pindex] ) / 65536 ));
count++;
}
#endif
@@ -3313,6 +3817,9 @@
FT_TRACE5(( "\n" ));
+ for ( i = 0; i < face->cvt_size; i++ )
+ face->cvt[i] += FT_fixedToFdot6( cvt_deltas[i] );
+
FExit:
FT_FRAME_EXIT();
@@ -3322,8 +3829,25 @@
FT_FREE( tuple_coords );
FT_FREE( im_start_coords );
FT_FREE( im_end_coords );
+ FT_FREE( cvt_deltas );
+
+ /* iterate over all FT_Size objects and set `cvt_ready' to -1 */
+ /* to trigger rescaling of all CVT values */
+ FT_List_Iterate( &root->sizes_list,
+ tt_cvt_ready_iterator,
+ NULL );
return error;
+
+#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+
+ FT_UNUSED( face );
+ FT_UNUSED( stream );
+
+ return FT_Err_Ok;
+
+#endif /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+
}
@@ -3367,9 +3891,8 @@
/* between `p1' and `p2', using `ref1' and `ref2' as the reference */
/* point indices. */
- /* modeled after `af_iup_interp', `_iup_worker_interpolate', and */
- /* `Ins_IUP' */
-
+ /* modeled after `af_iup_interp', `_iup_worker_interpolate', and */
+ /* `Ins_IUP' with spec differences in handling ill-defined cases. */
static void
tt_delta_interpolate( int p1,
int p2,
@@ -3528,67 +4051,88 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Vary_Apply_Glyph_Deltas */
- /* */
- /* <Description> */
- /* Apply the appropriate deltas to the current glyph. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* glyph_index :: The index of the glyph being modified. */
- /* */
- /* n_points :: The number of the points in the glyph, including */
- /* phantom points. */
- /* */
- /* <InOut> */
- /* outline :: The outline to change. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Vary_Apply_Glyph_Deltas
+ *
+ * @Description:
+ * Apply the appropriate deltas to the current glyph.
+ *
+ * @InOut:
+ * loader ::
+ * A handle to the loader object.
+ *
+ * outline ::
+ * The outline to change, with appended phantom points.
+ *
+ * @Output:
+ * unrounded ::
+ * An array with `n_points' elements that is filled with unrounded
+ * point coordinates (in 26.6 format).
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
- TT_Vary_Apply_Glyph_Deltas( TT_Face face,
- FT_UInt glyph_index,
+ TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
FT_Outline* outline,
- FT_UInt n_points )
+ FT_Vector* unrounded )
{
- FT_Stream stream = face->root.stream;
- FT_Memory memory = stream->memory;
- GX_Blend blend = face->blend;
-
- FT_Vector* points_org = NULL;
- FT_Vector* points_out = NULL;
+ FT_Error error;
+ TT_Face face = loader->face;
+ FT_Stream stream = face->root.stream;
+ FT_Memory memory = stream->memory;
+ FT_UInt glyph_index = loader->glyph_index;
+ FT_UInt n_points = (FT_UInt)outline->n_points + 4;
+
+ FT_Vector* points_org = NULL; /* coordinates in 16.16 format */
+ FT_Vector* points_out = NULL; /* coordinates in 16.16 format */
FT_Bool* has_delta = NULL;
- FT_Error error;
- FT_ULong glyph_start;
- FT_UInt tupleCount;
- FT_ULong offsetToData;
- FT_ULong here;
- FT_UInt i, j;
- FT_Fixed* tuple_coords = NULL;
- FT_Fixed* im_start_coords = NULL;
- FT_Fixed* im_end_coords = NULL;
- FT_UInt point_count, spoint_count = 0;
+ FT_ULong glyph_start;
+
+ FT_UInt tupleCount;
+ FT_ULong offsetToData;
+ FT_ULong dataSize;
+
+ FT_ULong here;
+ FT_UInt i, j;
+
+ FT_Fixed* tuple_coords = NULL;
+ FT_Fixed* im_start_coords = NULL;
+ FT_Fixed* im_end_coords = NULL;
+
+ GX_Blend blend = face->blend;
+
+ FT_UInt point_count;
+ FT_UInt spoint_count = 0;
+
FT_UShort* sharedpoints = NULL;
FT_UShort* localpoints = NULL;
FT_UShort* points;
- FT_Short *deltas_x, *deltas_y;
+
+ FT_Fixed* deltas_x = NULL;
+ FT_Fixed* deltas_y = NULL;
+ FT_Fixed* point_deltas_x = NULL;
+ FT_Fixed* point_deltas_y = NULL;
if ( !face->doblend || !blend )
return FT_THROW( Invalid_Argument );
+ for ( i = 0; i < n_points; i++ )
+ {
+ unrounded[i].x = INT_TO_F26DOT6( outline->points[i].x );
+ unrounded[i].y = INT_TO_F26DOT6( outline->points[i].y );
+ }
+
if ( glyph_index >= blend->gv_glyphcnt ||
blend->glyphoffsets[glyph_index] ==
blend->glyphoffsets[glyph_index + 1] )
{
FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
- " no variation data for this glyph\n" ));
+ " no variation data for glyph %d\n", glyph_index ));
return FT_Err_Ok;
}
@@ -3597,9 +4141,11 @@
FT_NEW_ARRAY( has_delta, n_points ) )
goto Fail1;
- if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
- FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] -
- blend->glyphoffsets[glyph_index] ) )
+ dataSize = blend->glyphoffsets[glyph_index + 1] -
+ blend->glyphoffsets[glyph_index];
+
+ if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
+ FT_FRAME_ENTER( dataSize ) )
goto Fail1;
glyph_start = FT_Stream_FTell( stream );
@@ -3615,8 +4161,8 @@
offsetToData = FT_GET_USHORT();
/* rough sanity test */
- if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 >
- blend->gvar_size )
+ if ( offsetToData > dataSize ||
+ ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > dataSize )
{
FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
" invalid glyph variation array header\n" ));
@@ -3646,8 +4192,15 @@
tupleCount & GX_TC_TUPLE_COUNT_MASK,
( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
+ if ( FT_NEW_ARRAY( point_deltas_x, n_points ) ||
+ FT_NEW_ARRAY( point_deltas_y, n_points ) )
+ goto Fail3;
+
for ( j = 0; j < n_points; j++ )
- points_org[j] = outline->points[j];
+ {
+ points_org[j].x = FT_intToFixed( outline->points[j].x );
+ points_org[j].y = FT_intToFixed( outline->points[j].y );
+ }
for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
{
@@ -3664,8 +4217,7 @@
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; j++ )
- tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */
- /* short frac to fixed */
+ tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
@@ -3673,20 +4225,21 @@
" invalid tuple index\n" ));
error = FT_THROW( Invalid_Table );
- goto Fail2;
+ goto Fail3;
}
else
FT_MEM_COPY(
tuple_coords,
- &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis],
+ blend->tuplecoords +
+ ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis,
blend->num_axis * sizeof ( FT_Fixed ) );
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; j++ )
- im_start_coords[j] = FT_GET_SHORT() * 4;
+ im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
for ( j = 0; j < blend->num_axis; j++ )
- im_end_coords[j] = FT_GET_SHORT() * 4;
+ im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
apply = ft_var_apply_tuple( blend,
@@ -3742,50 +4295,29 @@
/* this means that there are deltas for every point in the glyph */
for ( j = 0; j < n_points; j++ )
{
- FT_Pos delta_x = FT_MulFix( deltas_x[j], apply );
- FT_Pos delta_y = FT_MulFix( deltas_y[j], apply );
+ FT_Fixed old_point_delta_x = point_deltas_x[j];
+ FT_Fixed old_point_delta_y = point_deltas_y[j];
+ FT_Fixed point_delta_x = FT_MulFix( deltas_x[j], apply );
+ FT_Fixed point_delta_y = FT_MulFix( deltas_y[j], apply );
- if ( j < n_points - 4 )
- {
- outline->points[j].x += delta_x;
- outline->points[j].y += delta_y;
- }
- else
- {
- /* To avoid double adjustment of advance width or height, */
- /* adjust phantom points only if there is no HVAR or VVAR */
- /* support, respectively. */
- if ( j == ( n_points - 4 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_LSB ) )
- outline->points[j].x += delta_x;
-
- else if ( j == ( n_points - 3 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_HADVANCE ) )
- outline->points[j].x += delta_x;
-
- else if ( j == ( n_points - 2 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_TSB ) )
- outline->points[j].y += delta_y;
-
- else if ( j == ( n_points - 1 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_VADVANCE ) )
- outline->points[j].y += delta_y;
- }
+
+ point_deltas_x[j] = old_point_delta_x + point_delta_x;
+ point_deltas_y[j] = old_point_delta_y + point_delta_y;
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( delta_x || delta_y )
+ if ( point_delta_x || point_delta_y )
{
- FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n",
+ FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n",
j,
- outline->points[j].x - delta_x,
- outline->points[j].y - delta_y,
- outline->points[j].x,
- outline->points[j].y ));
+ (double)( FT_intToFixed( outline->points[j].x ) +
+ old_point_delta_x ) / 65536,
+ (double)( FT_intToFixed( outline->points[j].y ) +
+ old_point_delta_y ) / 65536,
+ (double)( FT_intToFixed( outline->points[j].x ) +
+ point_deltas_x[j] ) / 65536,
+ (double)( FT_intToFixed( outline->points[j].y ) +
+ point_deltas_y[j] ) / 65536 ));
count++;
}
#endif
@@ -3837,50 +4369,29 @@
for ( j = 0; j < n_points; j++ )
{
- FT_Pos delta_x = points_out[j].x - points_org[j].x;
- FT_Pos delta_y = points_out[j].y - points_org[j].y;
+ FT_Fixed old_point_delta_x = point_deltas_x[j];
+ FT_Fixed old_point_delta_y = point_deltas_y[j];
+ FT_Pos point_delta_x = points_out[j].x - points_org[j].x;
+ FT_Pos point_delta_y = points_out[j].y - points_org[j].y;
- if ( j < n_points - 4 )
- {
- outline->points[j].x += delta_x;
- outline->points[j].y += delta_y;
- }
- else
- {
- /* To avoid double adjustment of advance width or height, */
- /* adjust phantom points only if there is no HVAR or VVAR */
- /* support, respectively. */
- if ( j == ( n_points - 4 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_LSB ) )
- outline->points[j].x += delta_x;
-
- else if ( j == ( n_points - 3 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_HADVANCE ) )
- outline->points[j].x += delta_x;
-
- else if ( j == ( n_points - 2 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_TSB ) )
- outline->points[j].y += delta_y;
-
- else if ( j == ( n_points - 1 ) &&
- !( face->variation_support &
- TT_FACE_FLAG_VAR_VADVANCE ) )
- outline->points[j].y += delta_y;
- }
+
+ point_deltas_x[j] = old_point_delta_x + point_delta_x;
+ point_deltas_y[j] = old_point_delta_y + point_delta_y;
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( delta_x || delta_y )
+ if ( point_delta_x || point_delta_y )
{
- FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n",
+ FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n",
j,
- outline->points[j].x - delta_x,
- outline->points[j].y - delta_y,
- outline->points[j].x,
- outline->points[j].y ));
+ (double)( FT_intToFixed( outline->points[j].x ) +
+ old_point_delta_x ) / 65536,
+ (double)( FT_intToFixed( outline->points[j].y ) +
+ old_point_delta_y ) / 65536,
+ (double)( FT_intToFixed( outline->points[j].x ) +
+ point_deltas_x[j] ) / 65536,
+ (double)( FT_intToFixed( outline->points[j].y ) +
+ point_deltas_y[j] ) / 65536 ));
count++;
}
#endif
@@ -3904,6 +4415,55 @@
FT_TRACE5(( "\n" ));
+ /* To avoid double adjustment of advance width or height, */
+ /* do not move phantom points if there is HVAR or VVAR */
+ /* support, respectively. */
+ if ( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE )
+ {
+ point_deltas_x[n_points - 4] = 0;
+ point_deltas_y[n_points - 4] = 0;
+ point_deltas_x[n_points - 3] = 0;
+ point_deltas_y[n_points - 3] = 0;
+ }
+ if ( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE )
+ {
+ point_deltas_x[n_points - 2] = 0;
+ point_deltas_y[n_points - 2] = 0;
+ point_deltas_x[n_points - 1] = 0;
+ point_deltas_y[n_points - 1] = 0;
+ }
+
+ for ( i = 0; i < n_points; i++ )
+ {
+ unrounded[i].x += FT_fixedToFdot6( point_deltas_x[i] );
+ unrounded[i].y += FT_fixedToFdot6( point_deltas_y[i] );
+
+ outline->points[i].x += FT_fixedToInt( point_deltas_x[i] );
+ outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
+ }
+
+ /* To avoid double adjustment of advance width or height, */
+ /* adjust phantom points only if there is no HVAR or VVAR */
+ /* support, respectively. */
+ if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
+ {
+ loader->pp1 = outline->points[n_points - 4];
+ loader->pp2 = outline->points[n_points - 3];
+ loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x -
+ unrounded[n_points - 4].x ) / 64;
+ }
+ if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
+ {
+ loader->pp3 = outline->points[n_points - 2];
+ loader->pp4 = outline->points[n_points - 1];
+ loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].y -
+ unrounded[n_points - 2].y ) / 64;
+ }
+
+ Fail3:
+ FT_FREE( point_deltas_x );
+ FT_FREE( point_deltas_y );
+
Fail2:
if ( sharedpoints != ALL_POINTS )
FT_FREE( sharedpoints );
@@ -3922,33 +4482,36 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_get_var_blend */
- /* */
- /* <Description> */
- /* An extended internal version of `TT_Get_MM_Blend' that returns */
- /* pointers instead of copying data, without any initialization of */
- /* the MM machinery in case it isn't loaded yet. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_get_var_blend
+ *
+ * @Description:
+ * An extended internal version of `TT_Get_MM_Blend' that returns
+ * pointers instead of copying data, without any initialization of
+ * the MM machinery in case it isn't loaded yet.
+ */
FT_LOCAL_DEF( FT_Error )
- tt_get_var_blend( TT_Face face,
+ tt_get_var_blend( FT_Face face, /* TT_Face */
FT_UInt *num_coords,
FT_Fixed* *coords,
FT_Fixed* *normalizedcoords,
FT_MM_Var* *mm_var )
{
- if ( face->blend )
+ TT_Face ttface = (TT_Face)face;
+
+
+ if ( ttface->blend )
{
if ( num_coords )
- *num_coords = face->blend->num_axis;
+ *num_coords = ttface->blend->num_axis;
if ( coords )
- *coords = face->blend->coords;
+ *coords = ttface->blend->coords;
if ( normalizedcoords )
- *normalizedcoords = face->blend->normalizedcoords;
+ *normalizedcoords = ttface->blend->normalizedcoords;
if ( mm_var )
- *mm_var = face->blend->mmvar;
+ *mm_var = ttface->blend->mmvar;
}
else
{
@@ -3964,8 +4527,8 @@
}
- static void
- ft_var_done_item_variation_store( TT_Face face,
+ FT_LOCAL_DEF( void )
+ tt_var_done_item_variation_store( FT_Face face,
GX_ItemVarStore itemStore )
{
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -3993,19 +4556,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_done_blend */
- /* */
- /* <Description> */
- /* Free the blend internal data structure. */
- /* */
FT_LOCAL_DEF( void )
- tt_done_blend( TT_Face face )
+ tt_var_done_delta_set_index_map( FT_Face face,
+ GX_DeltaSetIdxMap deltaSetIdxMap )
{
FT_Memory memory = FT_FACE_MEMORY( face );
- GX_Blend blend = face->blend;
+
+
+ FT_FREE( deltaSetIdxMap->innerIndex );
+ FT_FREE( deltaSetIdxMap->outerIndex );
+ }
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_done_blend
+ *
+ * @Description:
+ * Free the blend internal data structure.
+ */
+ FT_LOCAL_DEF( void )
+ tt_done_blend( FT_Face face )
+ {
+ TT_Face ttface = (TT_Face)face;
+ FT_Memory memory = FT_FACE_MEMORY( face );
+ GX_Blend blend = ttface->blend;
if ( blend )
@@ -4021,36 +4597,47 @@
FT_FREE( blend->normalized_stylecoords );
FT_FREE( blend->mmvar );
- if ( blend->avar_segment )
+ if ( blend->avar_table )
{
- for ( i = 0; i < num_axes; i++ )
- FT_FREE( blend->avar_segment[i].correspondence );
- FT_FREE( blend->avar_segment );
+ if ( blend->avar_table->avar_segment )
+ {
+ for ( i = 0; i < num_axes; i++ )
+ FT_FREE( blend->avar_table->avar_segment[i].correspondence );
+ FT_FREE( blend->avar_table->avar_segment );
+ }
+
+ tt_var_done_item_variation_store( face,
+ &blend->avar_table->itemStore );
+
+ tt_var_done_delta_set_index_map( face,
+ &blend->avar_table->axisMap );
+
+ FT_FREE( blend->avar_table );
}
if ( blend->hvar_table )
{
- ft_var_done_item_variation_store( face,
+ tt_var_done_item_variation_store( face,
&blend->hvar_table->itemStore );
- FT_FREE( blend->hvar_table->widthMap.innerIndex );
- FT_FREE( blend->hvar_table->widthMap.outerIndex );
+ tt_var_done_delta_set_index_map( face,
+ &blend->hvar_table->widthMap );
FT_FREE( blend->hvar_table );
}
if ( blend->vvar_table )
{
- ft_var_done_item_variation_store( face,
+ tt_var_done_item_variation_store( face,
&blend->vvar_table->itemStore );
- FT_FREE( blend->vvar_table->widthMap.innerIndex );
- FT_FREE( blend->vvar_table->widthMap.outerIndex );
+ tt_var_done_delta_set_index_map( face,
+ &blend->vvar_table->widthMap );
FT_FREE( blend->vvar_table );
}
if ( blend->mvar_table )
{
- ft_var_done_item_variation_store( face,
+ tt_var_done_item_variation_store( face,
&blend->mvar_table->itemStore );
FT_FREE( blend->mvar_table->values );
@@ -4066,7 +4653,7 @@
#else /* !TT_CONFIG_OPTION_GX_VAR_SUPPORT */
/* ANSI C doesn't like empty source files */
- typedef int _tt_gxvar_dummy;
+ typedef int tt_gxvar_dummy_;
#endif /* !TT_CONFIG_OPTION_GX_VAR_SUPPORT */
diff --git a/src/3rdparty/freetype/src/truetype/ttgxvar.h b/src/3rdparty/freetype/src/truetype/ttgxvar.h
index a37bb90266..e3da6d1705 100644
--- a/src/3rdparty/freetype/src/truetype/ttgxvar.h
+++ b/src/3rdparty/freetype/src/truetype/ttgxvar.h
@@ -1,26 +1,26 @@
-/***************************************************************************/
-/* */
-/* ttgxvar.h */
-/* */
-/* TrueType GX Font Variation loader (specification) */
-/* */
-/* Copyright 2004-2018 by */
-/* David Turner, Robert Wilhelm, Werner Lemberg and George Williams. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttgxvar.h
+ *
+ * TrueType GX Font Variation loader (specification)
+ *
+ * Copyright (C) 2004-2023 by
+ * David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef TTGXVAR_H_
#define TTGXVAR_H_
-#include <ft2build.h>
+#include <freetype/internal/ftmmtypes.h>
#include "ttobjs.h"
@@ -29,15 +29,15 @@ FT_BEGIN_HEADER
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* GX_AVarCorrespondenceRec */
- /* */
- /* <Description> */
- /* A data structure representing `shortFracCorrespondence' in `avar' */
- /* table according to the specifications from Apple. */
- /* */
+ /**************************************************************************
+ *
+ * @Struct:
+ * GX_AVarCorrespondenceRec
+ *
+ * @Description:
+ * A data structure representing `shortFracCorrespondence' in `avar'
+ * table according to the specifications from Apple.
+ */
typedef struct GX_AVarCorrespondenceRec_
{
FT_Fixed fromCoord;
@@ -46,15 +46,15 @@ FT_BEGIN_HEADER
} GX_AVarCorrespondenceRec_, *GX_AVarCorrespondence;
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* GX_AVarRec */
- /* */
- /* <Description> */
- /* Data from the segment field of `avar' table. */
- /* There is one of these for each axis. */
- /* */
+ /**************************************************************************
+ *
+ * @Struct:
+ * GX_AVarRec
+ *
+ * @Description:
+ * Data from the segment field of `avar' table.
+ * There is one of these for each axis.
+ */
typedef struct GX_AVarSegmentRec_
{
FT_UShort pairCount;
@@ -63,65 +63,31 @@ FT_BEGIN_HEADER
} GX_AVarSegmentRec, *GX_AVarSegment;
- typedef struct GX_ItemVarDataRec_
+ /**************************************************************************
+ *
+ * @Struct:
+ * GX_AVarTableRec
+ *
+ * @Description:
+ * Data from the `avar' table.
+ */
+ typedef struct GX_AVarTableRec_
{
- FT_UInt itemCount; /* number of delta sets per item */
- FT_UInt regionIdxCount; /* number of region indices in this data */
- FT_UInt* regionIndices; /* array of `regionCount' indices; */
- /* these index `varRegionList' */
- FT_Short* deltaSet; /* array of `itemCount' deltas */
- /* use `innerIndex' for this array */
+ GX_AVarSegment avar_segment; /* avar_segment[num_axis] */
+ GX_ItemVarStoreRec itemStore; /* Item Variation Store */
+ GX_DeltaSetIdxMapRec axisMap; /* Axis Mapping */
- } GX_ItemVarDataRec, *GX_ItemVarData;
+ } GX_AVarTableRec, *GX_AVarTable;
- /* contribution of one axis to a region */
- typedef struct GX_AxisCoordsRec_
- {
- FT_Fixed startCoord;
- FT_Fixed peakCoord; /* zero means no effect (factor = 1) */
- FT_Fixed endCoord;
-
- } GX_AxisCoordsRec, *GX_AxisCoords;
-
-
- typedef struct GX_VarRegionRec_
- {
- GX_AxisCoords axisList; /* array of axisCount records */
-
- } GX_VarRegionRec, *GX_VarRegion;
-
-
- /* item variation store */
- typedef struct GX_ItemVarStoreRec_
- {
- FT_UInt dataCount;
- GX_ItemVarData varData; /* array of dataCount records; */
- /* use `outerIndex' for this array */
- FT_UShort axisCount;
- FT_UInt regionCount; /* total number of regions defined */
- GX_VarRegion varRegionList;
-
- } GX_ItemVarStoreRec, *GX_ItemVarStore;
-
-
- typedef struct GX_DeltaSetIdxMapRec_
- {
- FT_UInt mapCount;
- FT_UInt* outerIndex; /* indices to item var data */
- FT_UInt* innerIndex; /* indices to delta set */
-
- } GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap;
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* GX_HVVarTableRec */
- /* */
- /* <Description> */
- /* Data from either the `HVAR' or `VVAR' table. */
- /* */
+ /**************************************************************************
+ *
+ * @Struct:
+ * GX_HVVarTableRec
+ *
+ * @Description:
+ * Data from either the `HVAR' or `VVAR' table.
+ */
typedef struct GX_HVVarTableRec_
{
GX_ItemVarStoreRec itemStore; /* Item Variation Store */
@@ -191,14 +157,14 @@ FT_BEGIN_HEADER
} GX_ValueRec, *GX_Value;
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* GX_MVarTableRec */
- /* */
- /* <Description> */
- /* Data from the `MVAR' table. */
- /* */
+ /**************************************************************************
+ *
+ * @Struct:
+ * GX_MVarTableRec
+ *
+ * @Description:
+ * Data from the `MVAR' table.
+ */
typedef struct GX_MVarTableRec_
{
FT_UShort valueCount;
@@ -209,95 +175,95 @@ FT_BEGIN_HEADER
} GX_MVarTableRec, *GX_MVarTable;
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* GX_BlendRec */
- /* */
- /* <Description> */
- /* Data for interpolating a font from a distortable font specified */
- /* by the GX *var tables ([fgcahvm]var). */
- /* */
- /* <Fields> */
- /* num_axis :: */
- /* The number of axes along which interpolation may happen. */
- /* */
- /* coords :: */
- /* An array of design coordinates (in user space) indicating the */
- /* contribution along each axis to the final interpolated font. */
- /* `normalizedcoords' holds the same values. */
- /* */
- /* normalizedcoords :: */
- /* An array of normalized values (between [-1,1]) indicating the */
- /* contribution along each axis to the final interpolated font. */
- /* `coords' holds the same values. */
- /* */
- /* mmvar :: */
- /* Data from the `fvar' table. */
- /* */
- /* mmvar_len :: */
- /* The length of the `mmvar' structure. */
- /* */
- /* normalized_stylecoords :: */
- /* A two-dimensional array that holds the named instance data from */
- /* `mmvar' as normalized values. */
- /* */
- /* avar_loaded :: */
- /* A Boolean; if set, FreeType tried to load (and parse) the `avar' */
- /* table. */
- /* */
- /* avar_segment :: */
- /* Data from the `avar' table. */
- /* */
- /* hvar_loaded :: */
- /* A Boolean; if set, FreeType tried to load (and parse) the `hvar' */
- /* table. */
- /* */
- /* hvar_checked :: */
- /* A Boolean; if set, FreeType successfully loaded and parsed the */
- /* `hvar' table. */
- /* */
- /* hvar_error :: */
- /* If loading and parsing of the `hvar' table failed, this field */
- /* holds the corresponding error code. */
- /* */
- /* hvar_table :: */
- /* Data from the `hvar' table. */
- /* */
- /* vvar_loaded :: */
- /* A Boolean; if set, FreeType tried to load (and parse) the `vvar' */
- /* table. */
- /* */
- /* vvar_checked :: */
- /* A Boolean; if set, FreeType successfully loaded and parsed the */
- /* `vvar' table. */
- /* */
- /* vvar_error :: */
- /* If loading and parsing of the `vvar' table failed, this field */
- /* holds the corresponding error code. */
- /* */
- /* vvar_table :: */
- /* Data from the `vvar' table. */
- /* */
- /* mvar_table :: */
- /* Data from the `mvar' table. */
- /* */
- /* tuplecount :: */
- /* The number of shared tuples in the `gvar' table. */
- /* */
- /* tuplecoords :: */
- /* A two-dimensional array that holds the shared tuple coordinates */
- /* in the `gvar' table. */
- /* */
- /* gv_glyphcnt :: */
- /* The number of glyphs handled in the `gvar' table. */
- /* */
- /* glyphoffsets :: */
- /* Offsets into the glyph variation data array. */
- /* */
- /* gvar_size :: */
- /* The size of the `gvar' table. */
- /* */
+ /**************************************************************************
+ *
+ * @Struct:
+ * GX_BlendRec
+ *
+ * @Description:
+ * Data for interpolating a font from a distortable font specified
+ * by the GX *var tables ([fgcahvm]var).
+ *
+ * @Fields:
+ * num_axis ::
+ * The number of axes along which interpolation may happen.
+ *
+ * coords ::
+ * An array of design coordinates (in user space) indicating the
+ * contribution along each axis to the final interpolated font.
+ * `normalizedcoords' holds the same values.
+ *
+ * normalizedcoords ::
+ * An array of normalized values (between [-1,1]) indicating the
+ * contribution along each axis to the final interpolated font.
+ * `coords' holds the same values.
+ *
+ * mmvar ::
+ * Data from the `fvar' table.
+ *
+ * mmvar_len ::
+ * The length of the `mmvar' structure.
+ *
+ * normalized_stylecoords ::
+ * A two-dimensional array that holds the named instance data from
+ * `mmvar' as normalized values.
+ *
+ * avar_loaded ::
+ * A Boolean; if set, FreeType tried to load (and parse) the `avar'
+ * table.
+ *
+ * avar_table ::
+ * Data from the `avar' table.
+ *
+ * hvar_loaded ::
+ * A Boolean; if set, FreeType tried to load (and parse) the `hvar'
+ * table.
+ *
+ * hvar_checked ::
+ * A Boolean; if set, FreeType successfully loaded and parsed the
+ * `hvar' table.
+ *
+ * hvar_error ::
+ * If loading and parsing of the `hvar' table failed, this field
+ * holds the corresponding error code.
+ *
+ * hvar_table ::
+ * Data from the `hvar' table.
+ *
+ * vvar_loaded ::
+ * A Boolean; if set, FreeType tried to load (and parse) the `vvar'
+ * table.
+ *
+ * vvar_checked ::
+ * A Boolean; if set, FreeType successfully loaded and parsed the
+ * `vvar' table.
+ *
+ * vvar_error ::
+ * If loading and parsing of the `vvar' table failed, this field
+ * holds the corresponding error code.
+ *
+ * vvar_table ::
+ * Data from the `vvar' table.
+ *
+ * mvar_table ::
+ * Data from the `mvar' table.
+ *
+ * tuplecount ::
+ * The number of shared tuples in the `gvar' table.
+ *
+ * tuplecoords ::
+ * A two-dimensional array that holds the shared tuple coordinates
+ * in the `gvar' table.
+ *
+ * gv_glyphcnt ::
+ * The number of glyphs handled in the `gvar' table.
+ *
+ * glyphoffsets ::
+ * Offsets into the glyph variation data array.
+ *
+ * gvar_size ::
+ * The size of the `gvar' table.
+ */
typedef struct GX_BlendRec_
{
FT_UInt num_axis;
@@ -311,7 +277,7 @@ FT_BEGIN_HEADER
/* normalized_stylecoords[num_namedstyles][num_axis] */
FT_Bool avar_loaded;
- GX_AVarSegment avar_segment; /* avar_segment[num_axis] */
+ GX_AVarTable avar_table;
FT_Bool hvar_loaded;
FT_Bool hvar_checked;
@@ -336,14 +302,14 @@ FT_BEGIN_HEADER
} GX_BlendRec;
- /*************************************************************************/
- /* */
- /* <enum> */
- /* GX_TupleCountFlags */
- /* */
- /* <Description> */
- /* Flags used within the `TupleCount' field of the `gvar' table. */
- /* */
+ /**************************************************************************
+ *
+ * @enum:
+ * GX_TupleCountFlags
+ *
+ * @Description:
+ * Flags used within the `TupleCount' field of the `gvar' table.
+ */
typedef enum GX_TupleCountFlags_
{
GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000,
@@ -353,15 +319,15 @@ FT_BEGIN_HEADER
} GX_TupleCountFlags;
- /*************************************************************************/
- /* */
- /* <enum> */
- /* GX_TupleIndexFlags */
- /* */
- /* <Description> */
- /* Flags used within the `TupleIndex' field of the `gvar' and `cvar' */
- /* tables. */
- /* */
+ /**************************************************************************
+ *
+ * @enum:
+ * GX_TupleIndexFlags
+ *
+ * @Description:
+ * Flags used within the `TupleIndex' field of the `gvar' and `cvar'
+ * tables.
+ */
typedef enum GX_TupleIndexFlags_
{
GX_TI_EMBEDDED_TUPLE_COORD = 0x8000,
@@ -377,69 +343,103 @@ FT_BEGIN_HEADER
#define TTAG_wdth FT_MAKE_TAG( 'w', 'd', 't', 'h' )
#define TTAG_opsz FT_MAKE_TAG( 'o', 'p', 's', 'z' )
#define TTAG_slnt FT_MAKE_TAG( 's', 'l', 'n', 't' )
+#define TTAG_ital FT_MAKE_TAG( 'i', 't', 'a', 'l' )
FT_LOCAL( FT_Error )
- TT_Set_MM_Blend( TT_Face face,
+ TT_Set_MM_Blend( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
FT_LOCAL( FT_Error )
- TT_Get_MM_Blend( TT_Face face,
+ TT_Get_MM_Blend( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
FT_LOCAL( FT_Error )
- TT_Set_Var_Design( TT_Face face,
+ TT_Set_Var_Design( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
FT_LOCAL( FT_Error )
- TT_Get_MM_Var( TT_Face face,
+ TT_Get_MM_Var( FT_Face face,
FT_MM_Var* *master );
FT_LOCAL( FT_Error )
- TT_Get_Var_Design( TT_Face face,
+ TT_Get_Var_Design( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
FT_LOCAL( FT_Error )
- TT_Set_Named_Instance( TT_Face face,
+ TT_Set_Named_Instance( FT_Face face,
FT_UInt instance_index );
FT_LOCAL( FT_Error )
+ TT_Get_Default_Named_Instance( FT_Face face,
+ FT_UInt *instance_index );
+
+ FT_LOCAL( void )
+ tt_construct_ps_name( FT_Face face );
+
+ FT_LOCAL( FT_Error )
tt_face_vary_cvt( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
- TT_Vary_Apply_Glyph_Deltas( TT_Face face,
- FT_UInt glyph_index,
+ TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
FT_Outline* outline,
- FT_UInt n_points );
+ FT_Vector* unrounded );
FT_LOCAL( FT_Error )
- tt_hadvance_adjust( TT_Face face,
+ tt_hadvance_adjust( FT_Face face,
FT_UInt gindex,
FT_Int *adelta );
FT_LOCAL( FT_Error )
- tt_vadvance_adjust( TT_Face face,
+ tt_vadvance_adjust( FT_Face face,
FT_UInt gindex,
FT_Int *adelta );
FT_LOCAL( void )
- tt_apply_mvar( TT_Face face );
+ tt_apply_mvar( FT_Face face );
+
+ FT_LOCAL( FT_Error )
+ tt_var_load_item_variation_store( FT_Face face,
+ FT_ULong offset,
+ GX_ItemVarStore itemStore );
+
+ FT_LOCAL( FT_Error )
+ tt_var_load_delta_set_index_mapping( FT_Face face,
+ FT_ULong offset,
+ GX_DeltaSetIdxMap map,
+ GX_ItemVarStore itemStore,
+ FT_ULong table_len );
+
+ FT_LOCAL( FT_ItemVarDelta )
+ tt_var_get_item_delta( FT_Face face,
+ GX_ItemVarStore itemStore,
+ FT_UInt outerIndex,
+ FT_UInt innerIndex );
+
+ FT_LOCAL( void )
+ tt_var_done_item_variation_store( FT_Face face,
+ GX_ItemVarStore itemStore );
+
+ FT_LOCAL( void )
+ tt_var_done_delta_set_index_map( FT_Face face,
+ GX_DeltaSetIdxMap deltaSetIdxMap );
+
FT_LOCAL( FT_Error )
- tt_get_var_blend( TT_Face face,
+ tt_get_var_blend( FT_Face face,
FT_UInt *num_coords,
FT_Fixed* *coords,
FT_Fixed* *normalizedcoords,
FT_MM_Var* *mm_var );
FT_LOCAL( void )
- tt_done_blend( TT_Face face );
+ tt_done_blend( FT_Face face );
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
diff --git a/src/3rdparty/freetype/src/truetype/ttinterp.c b/src/3rdparty/freetype/src/truetype/ttinterp.c
index da9b595aba..79df4555d9 100644
--- a/src/3rdparty/freetype/src/truetype/ttinterp.c
+++ b/src/3rdparty/freetype/src/truetype/ttinterp.c
@@ -1,36 +1,34 @@
-/***************************************************************************/
-/* */
-/* ttinterp.c */
-/* */
-/* TrueType bytecode interpreter (body). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttinterp.c
+ *
+ * TrueType bytecode interpreter (body).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
/* Greg Hitchcock from Microsoft has helped a lot in resolving unclear */
/* issues; many thanks! */
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_CALC_H
-#include FT_TRIGONOMETRY_H
-#include FT_SYSTEM_H
-#include FT_DRIVER_H
-#include FT_MULTIPLE_MASTERS_H
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftcalc.h>
+#include <freetype/fttrigon.h>
+#include <freetype/ftsystem.h>
+#include <freetype/ftdriver.h>
+#include <freetype/ftmm.h>
#include "ttinterp.h"
#include "tterrors.h"
-#include "ttsubpix.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.h"
#endif
@@ -39,26 +37,20 @@
#ifdef TT_USE_BYTECODE_INTERPRETER
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttinterp
+#define FT_COMPONENT ttinterp
#define NO_SUBPIXEL_HINTING \
( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
TT_INTERPRETER_VERSION_35 )
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-#define SUBPIXEL_HINTING_INFINALITY \
- ( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
- TT_INTERPRETER_VERSION_38 )
-#endif
-
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
#define SUBPIXEL_HINTING_MINIMAL \
( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
@@ -82,10 +74,10 @@
exc->func_dualproj( exc, (v)->x, (v)->y )
- /*************************************************************************/
- /* */
- /* Two simple bounds-checking macros. */
- /* */
+ /**************************************************************************
+ *
+ * Two simple bounds-checking macros.
+ */
#define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) )
#define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) )
@@ -97,30 +89,33 @@
#define FAILURE 1
- /*************************************************************************/
- /* */
- /* CODERANGE FUNCTIONS */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Goto_CodeRange */
- /* */
- /* <Description> */
- /* Switches to a new code range (updates the code related elements in */
- /* `exec', and `IP'). */
- /* */
- /* <Input> */
- /* range :: The new execution code range. */
- /* */
- /* IP :: The new IP in the new code range. */
- /* */
- /* <InOut> */
- /* exec :: The target execution context. */
- /* */
+ /**************************************************************************
+ *
+ * CODERANGE FUNCTIONS
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Goto_CodeRange
+ *
+ * @Description:
+ * Switches to a new code range (updates the code related elements in
+ * `exec', and `IP').
+ *
+ * @Input:
+ * range ::
+ * The new execution code range.
+ *
+ * IP ::
+ * The new IP in the new code range.
+ *
+ * @InOut:
+ * exec ::
+ * The target execution context.
+ */
FT_LOCAL_DEF( void )
TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
@@ -148,24 +143,28 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Set_CodeRange */
- /* */
- /* <Description> */
- /* Sets a code range. */
- /* */
- /* <Input> */
- /* range :: The code range index. */
- /* */
- /* base :: The new code base. */
- /* */
- /* length :: The range size in bytes. */
- /* */
- /* <InOut> */
- /* exec :: The target execution context. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Set_CodeRange
+ *
+ * @Description:
+ * Sets a code range.
+ *
+ * @Input:
+ * range ::
+ * The code range index.
+ *
+ * base ::
+ * The new code base.
+ *
+ * length ::
+ * The range size in bytes.
+ *
+ * @InOut:
+ * exec ::
+ * The target execution context.
+ */
FT_LOCAL_DEF( void )
TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
@@ -179,20 +178,22 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Clear_CodeRange */
- /* */
- /* <Description> */
- /* Clears a code range. */
- /* */
- /* <Input> */
- /* range :: The code range index. */
- /* */
- /* <InOut> */
- /* exec :: The target execution context. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Clear_CodeRange
+ *
+ * @Description:
+ * Clears a code range.
+ *
+ * @Input:
+ * range ::
+ * The code range index.
+ *
+ * @InOut:
+ * exec ::
+ * The target execution context.
+ */
FT_LOCAL_DEF( void )
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range )
@@ -204,29 +205,31 @@
}
- /*************************************************************************/
- /* */
- /* EXECUTION CONTEXT ROUTINES */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Done_Context */
- /* */
- /* <Description> */
- /* Destroys a given context. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* memory :: A handle to the parent memory object. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
+ /**************************************************************************
+ *
+ * EXECUTION CONTEXT ROUTINES
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Done_Context
+ *
+ * @Description:
+ * Destroys a given context.
+ *
+ * @Input:
+ * exec ::
+ * A handle to the target execution context.
+ *
+ * memory ::
+ * A handle to the parent memory object.
+ *
+ * @Note:
+ * Only the glyph loader and debugger should call this function.
+ */
FT_LOCAL_DEF( void )
TT_Done_Context( TT_ExecContext exec )
{
@@ -241,6 +244,14 @@
FT_FREE( exec->stack );
exec->stackSize = 0;
+ /* free glyf cvt working area */
+ FT_FREE( exec->glyfCvt );
+ exec->glyfCvtSize = 0;
+
+ /* free glyf storage working area */
+ FT_FREE( exec->glyfStorage );
+ exec->glyfStoreSize = 0;
+
/* free call stack */
FT_FREE( exec->callStack );
exec->callSize = 0;
@@ -257,139 +268,42 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Init_Context */
- /* */
- /* <Description> */
- /* Initializes a context object. */
- /* */
- /* <Input> */
- /* memory :: A handle to the parent memory object. */
- /* */
- /* <InOut> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- static FT_Error
- Init_Context( TT_ExecContext exec,
- FT_Memory memory )
- {
- FT_Error error;
-
-
- FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec ));
-
- exec->memory = memory;
- exec->callSize = 32;
-
- if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) )
- goto Fail_Memory;
-
- /* all values in the context are set to 0 already, but this is */
- /* here as a remainder */
- exec->maxPoints = 0;
- exec->maxContours = 0;
-
- exec->stackSize = 0;
- exec->glyphSize = 0;
-
- exec->stack = NULL;
- exec->glyphIns = NULL;
-
- exec->face = NULL;
- exec->size = NULL;
-
- return FT_Err_Ok;
-
- Fail_Memory:
- FT_ERROR(( "Init_Context: not enough memory for %p\n", exec ));
- TT_Done_Context( exec );
-
- return error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Update_Max */
- /* */
- /* <Description> */
- /* Checks the size of a buffer and reallocates it if necessary. */
- /* */
- /* <Input> */
- /* memory :: A handle to the parent memory object. */
- /* */
- /* multiplier :: The size in bytes of each element in the buffer. */
- /* */
- /* new_max :: The new capacity (size) of the buffer. */
- /* */
- /* <InOut> */
- /* size :: The address of the buffer's current size expressed */
- /* in elements. */
- /* */
- /* buff :: The address of the buffer base pointer. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- FT_LOCAL_DEF( FT_Error )
- Update_Max( FT_Memory memory,
- FT_ULong* size,
- FT_ULong multiplier,
- void* _pbuff,
- FT_ULong new_max )
- {
- FT_Error error;
- void** pbuff = (void**)_pbuff;
-
-
- if ( *size < new_max )
- {
- if ( FT_REALLOC( *pbuff, *size * multiplier, new_max * multiplier ) )
- return error;
- *size = new_max;
- }
-
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Load_Context */
- /* */
- /* <Description> */
- /* Prepare an execution context for glyph hinting. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* size :: A handle to the source size object. */
- /* */
- /* <InOut> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Load_Context
+ *
+ * @Description:
+ * Prepare an execution context for glyph hinting.
+ *
+ * @Input:
+ * face ::
+ * A handle to the source face object.
+ *
+ * size ::
+ * A handle to the source size object.
+ *
+ * @InOut:
+ * exec ::
+ * A handle to the target execution context.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ *
+ * @Note:
+ * Only the glyph loader and debugger should call this function.
+ *
+ * Note that not all members of `TT_ExecContext` get initialized.
+ */
FT_LOCAL_DEF( FT_Error )
TT_Load_Context( TT_ExecContext exec,
TT_Face face,
TT_Size size )
{
FT_Int i;
- FT_ULong tmp;
TT_MaxProfile* maxp;
FT_Error error;
+ FT_Memory memory = exec->memory;
exec->face = face;
@@ -434,25 +348,15 @@
/* XXX: We reserve a little more elements on the stack to deal safely */
/* with broken fonts like arialbs, courbs, timesbs, etc. */
- tmp = (FT_ULong)exec->stackSize;
- error = Update_Max( exec->memory,
- &tmp,
- sizeof ( FT_F26Dot6 ),
- (void*)&exec->stack,
- maxp->maxStackElements + 32 );
- exec->stackSize = (FT_Long)tmp;
- if ( error )
+ if ( FT_QRENEW_ARRAY( exec->stack,
+ exec->stackSize,
+ maxp->maxStackElements + 32 ) )
return error;
+ exec->stackSize = maxp->maxStackElements + 32;
- tmp = exec->glyphSize;
- error = Update_Max( exec->memory,
- &tmp,
- sizeof ( FT_Byte ),
- (void*)&exec->glyphIns,
- maxp->maxSizeOfInstructions );
- exec->glyphSize = (FT_UShort)tmp;
- if ( error )
- return error;
+ /* free previous glyph code range */
+ FT_FREE( exec->glyphIns );
+ exec->glyphSize = 0;
exec->pts.n_points = 0;
exec->pts.n_contours = 0;
@@ -467,23 +371,25 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Save_Context */
- /* */
- /* <Description> */
- /* Saves the code ranges in a `size' object. */
- /* */
- /* <Input> */
- /* exec :: A handle to the source execution context. */
- /* */
- /* <InOut> */
- /* size :: A handle to the target size object. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Save_Context
+ *
+ * @Description:
+ * Saves the code ranges in a `size' object.
+ *
+ * @Input:
+ * exec ::
+ * A handle to the source execution context.
+ *
+ * @InOut:
+ * size ::
+ * A handle to the target size object.
+ *
+ * @Note:
+ * Only the glyph loader and debugger should call this function.
+ */
FT_LOCAL_DEF( void )
TT_Save_Context( TT_ExecContext exec,
TT_Size size )
@@ -505,27 +411,21 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_Run_Context */
- /* */
- /* <Description> */
- /* Executes one or more instructions in the execution context. */
- /* */
- /* <Input> */
- /* debug :: A Boolean flag. If set, the function sets some internal */
- /* variables and returns immediately, otherwise TT_RunIns() */
- /* is called. */
- /* */
- /* This is commented out currently. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* <Return> */
- /* TrueType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_Run_Context
+ *
+ * @Description:
+ * Executes one or more instructions in the execution context.
+ *
+ * @Input:
+ * exec ::
+ * A handle to the target execution context.
+ *
+ * @Return:
+ * TrueType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
TT_Run_Context( TT_ExecContext exec )
{
@@ -593,38 +493,38 @@
memory = driver->root.root.memory;
- /* allocate object */
+ /* allocate object and zero everything inside */
if ( FT_NEW( exec ) )
goto Fail;
- /* initialize it; in case of error this deallocates `exec' too */
- error = Init_Context( exec, memory );
- if ( error )
- goto Fail;
+ /* create callStack here, other allocations delayed */
+ exec->memory = memory;
+ exec->callSize = 32;
- return exec;
+ if ( FT_QNEW_ARRAY( exec->callStack, exec->callSize ) )
+ FT_FREE( exec );
Fail:
- return NULL;
+ return exec;
}
- /*************************************************************************/
- /* */
- /* Before an opcode is executed, the interpreter verifies that there are */
- /* enough arguments on the stack, with the help of the `Pop_Push_Count' */
- /* table. */
- /* */
- /* For each opcode, the first column gives the number of arguments that */
- /* are popped from the stack; the second one gives the number of those */
- /* that are pushed in result. */
- /* */
- /* Opcodes which have a varying number of parameters in the data stream */
- /* (NPUSHB, NPUSHW) are handled specially; they have a negative value in */
- /* the `opcode_length' table, and the value in `Pop_Push_Count' is set */
- /* to zero. */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * Before an opcode is executed, the interpreter verifies that there are
+ * enough arguments on the stack, with the help of the `Pop_Push_Count'
+ * table.
+ *
+ * For each opcode, the first column gives the number of arguments that
+ * are popped from the stack; the second one gives the number of those
+ * that are pushed in result.
+ *
+ * Opcodes which have a varying number of parameters in the data stream
+ * (NPUSHB, NPUSHW) are handled specially; they have a negative value in
+ * the `opcode_length' table, and the value in `Pop_Push_Count' is set
+ * to zero.
+ *
+ */
#undef PACK
@@ -637,23 +537,25 @@
/* opcodes are gathered in groups of 16 */
/* please keep the spaces as they are */
- /* SVTCA y */ PACK( 0, 0 ),
- /* SVTCA x */ PACK( 0, 0 ),
- /* SPvTCA y */ PACK( 0, 0 ),
- /* SPvTCA x */ PACK( 0, 0 ),
- /* SFvTCA y */ PACK( 0, 0 ),
- /* SFvTCA x */ PACK( 0, 0 ),
- /* SPvTL // */ PACK( 2, 0 ),
- /* SPvTL + */ PACK( 2, 0 ),
- /* SFvTL // */ PACK( 2, 0 ),
- /* SFvTL + */ PACK( 2, 0 ),
- /* SPvFS */ PACK( 2, 0 ),
- /* SFvFS */ PACK( 2, 0 ),
- /* GPv */ PACK( 0, 2 ),
- /* GFv */ PACK( 0, 2 ),
- /* SFvTPv */ PACK( 0, 0 ),
+ /* 0x00 */
+ /* SVTCA[0] */ PACK( 0, 0 ),
+ /* SVTCA[1] */ PACK( 0, 0 ),
+ /* SPVTCA[0] */ PACK( 0, 0 ),
+ /* SPVTCA[1] */ PACK( 0, 0 ),
+ /* SFVTCA[0] */ PACK( 0, 0 ),
+ /* SFVTCA[1] */ PACK( 0, 0 ),
+ /* SPVTL[0] */ PACK( 2, 0 ),
+ /* SPVTL[1] */ PACK( 2, 0 ),
+ /* SFVTL[0] */ PACK( 2, 0 ),
+ /* SFVTL[1] */ PACK( 2, 0 ),
+ /* SPVFS */ PACK( 2, 0 ),
+ /* SFVFS */ PACK( 2, 0 ),
+ /* GPV */ PACK( 0, 2 ),
+ /* GFV */ PACK( 0, 2 ),
+ /* SFVTPV */ PACK( 0, 0 ),
/* ISECT */ PACK( 5, 0 ),
+ /* 0x10 */
/* SRP0 */ PACK( 1, 0 ),
/* SRP1 */ PACK( 1, 0 ),
/* SRP2 */ PACK( 1, 0 ),
@@ -667,10 +569,11 @@
/* SMD */ PACK( 1, 0 ),
/* ELSE */ PACK( 0, 0 ),
/* JMPR */ PACK( 1, 0 ),
- /* SCvTCi */ PACK( 1, 0 ),
- /* SSwCi */ PACK( 1, 0 ),
+ /* SCVTCI */ PACK( 1, 0 ),
+ /* SSWCI */ PACK( 1, 0 ),
/* SSW */ PACK( 1, 0 ),
+ /* 0x20 */
/* DUP */ PACK( 1, 2 ),
/* POP */ PACK( 1, 0 ),
/* CLEAR */ PACK( 0, 0 ),
@@ -678,7 +581,7 @@
/* DEPTH */ PACK( 0, 1 ),
/* CINDEX */ PACK( 1, 1 ),
/* MINDEX */ PACK( 1, 0 ),
- /* AlignPTS */ PACK( 2, 0 ),
+ /* ALIGNPTS */ PACK( 2, 0 ),
/* INS_$28 */ PACK( 0, 0 ),
/* UTP */ PACK( 1, 0 ),
/* LOOPCALL */ PACK( 2, 0 ),
@@ -688,6 +591,7 @@
/* MDAP[0] */ PACK( 1, 0 ),
/* MDAP[1] */ PACK( 1, 0 ),
+ /* 0x30 */
/* IUP[0] */ PACK( 0, 0 ),
/* IUP[1] */ PACK( 0, 0 ),
/* SHP[0] */ PACK( 0, 0 ), /* loops */
@@ -700,17 +604,18 @@
/* IP */ PACK( 0, 0 ), /* loops */
/* MSIRP[0] */ PACK( 2, 0 ),
/* MSIRP[1] */ PACK( 2, 0 ),
- /* AlignRP */ PACK( 0, 0 ), /* loops */
+ /* ALIGNRP */ PACK( 0, 0 ), /* loops */
/* RTDG */ PACK( 0, 0 ),
/* MIAP[0] */ PACK( 2, 0 ),
/* MIAP[1] */ PACK( 2, 0 ),
- /* NPushB */ PACK( 0, 0 ),
- /* NPushW */ PACK( 0, 0 ),
+ /* 0x40 */
+ /* NPUSHB */ PACK( 0, 0 ),
+ /* NPUSHW */ PACK( 0, 0 ),
/* WS */ PACK( 2, 0 ),
/* RS */ PACK( 1, 1 ),
- /* WCvtP */ PACK( 2, 0 ),
- /* RCvt */ PACK( 1, 1 ),
+ /* WCVTP */ PACK( 2, 0 ),
+ /* RCVT */ PACK( 1, 1 ),
/* GC[0] */ PACK( 1, 1 ),
/* GC[1] */ PACK( 1, 1 ),
/* SCFS */ PACK( 2, 0 ),
@@ -718,10 +623,11 @@
/* MD[1] */ PACK( 2, 1 ),
/* MPPEM */ PACK( 0, 1 ),
/* MPS */ PACK( 0, 1 ),
- /* FlipON */ PACK( 0, 0 ),
- /* FlipOFF */ PACK( 0, 0 ),
+ /* FLIPON */ PACK( 0, 0 ),
+ /* FLIPOFF */ PACK( 0, 0 ),
/* DEBUG */ PACK( 1, 0 ),
+ /* 0x50 */
/* LT */ PACK( 2, 1 ),
/* LTEQ */ PACK( 2, 1 ),
/* GT */ PACK( 2, 1 ),
@@ -735,10 +641,11 @@
/* AND */ PACK( 2, 1 ),
/* OR */ PACK( 2, 1 ),
/* NOT */ PACK( 1, 1 ),
- /* DeltaP1 */ PACK( 1, 0 ),
+ /* DELTAP1 */ PACK( 1, 0 ),
/* SDB */ PACK( 1, 0 ),
/* SDS */ PACK( 1, 0 ),
+ /* 0x60 */
/* ADD */ PACK( 2, 1 ),
/* SUB */ PACK( 2, 1 ),
/* DIV */ PACK( 2, 1 ),
@@ -756,14 +663,15 @@
/* NROUND[2] */ PACK( 1, 1 ),
/* NROUND[3] */ PACK( 1, 1 ),
- /* WCvtF */ PACK( 2, 0 ),
- /* DeltaP2 */ PACK( 1, 0 ),
- /* DeltaP3 */ PACK( 1, 0 ),
- /* DeltaCn[0] */ PACK( 1, 0 ),
- /* DeltaCn[1] */ PACK( 1, 0 ),
- /* DeltaCn[2] */ PACK( 1, 0 ),
+ /* 0x70 */
+ /* WCVTF */ PACK( 2, 0 ),
+ /* DELTAP2 */ PACK( 1, 0 ),
+ /* DELTAP3 */ PACK( 1, 0 ),
+ /* DELTAC1 */ PACK( 1, 0 ),
+ /* DELTAC2 */ PACK( 1, 0 ),
+ /* DELTAC3 */ PACK( 1, 0 ),
/* SROUND */ PACK( 1, 0 ),
- /* S45Round */ PACK( 1, 0 ),
+ /* S45ROUND */ PACK( 1, 0 ),
/* JROT */ PACK( 2, 0 ),
/* JROF */ PACK( 2, 0 ),
/* ROFF */ PACK( 0, 0 ),
@@ -773,23 +681,25 @@
/* SANGW */ PACK( 1, 0 ),
/* AA */ PACK( 1, 0 ),
- /* FlipPT */ PACK( 0, 0 ), /* loops */
- /* FlipRgON */ PACK( 2, 0 ),
- /* FlipRgOFF */ PACK( 2, 0 ),
+ /* 0x80 */
+ /* FLIPPT */ PACK( 0, 0 ), /* loops */
+ /* FLIPRGON */ PACK( 2, 0 ),
+ /* FLIPRGOFF */ PACK( 2, 0 ),
/* INS_$83 */ PACK( 0, 0 ),
/* INS_$84 */ PACK( 0, 0 ),
- /* ScanCTRL */ PACK( 1, 0 ),
- /* SDPvTL[0] */ PACK( 2, 0 ),
- /* SDPvTL[1] */ PACK( 2, 0 ),
- /* GetINFO */ PACK( 1, 1 ),
+ /* SCANCTRL */ PACK( 1, 0 ),
+ /* SDPVTL[0] */ PACK( 2, 0 ),
+ /* SDPVTL[1] */ PACK( 2, 0 ),
+ /* GETINFO */ PACK( 1, 1 ),
/* IDEF */ PACK( 1, 0 ),
/* ROLL */ PACK( 3, 3 ),
/* MAX */ PACK( 2, 1 ),
/* MIN */ PACK( 2, 1 ),
- /* ScanTYPE */ PACK( 1, 0 ),
- /* InstCTRL */ PACK( 2, 0 ),
+ /* SCANTYPE */ PACK( 1, 0 ),
+ /* INSTCTRL */ PACK( 2, 0 ),
/* INS_$8F */ PACK( 0, 0 ),
+ /* 0x90 */
/* INS_$90 */ PACK( 0, 0 ),
/* GETVAR */ PACK( 0, 0 ), /* will be handled specially */
/* GETDATA */ PACK( 0, 1 ),
@@ -807,6 +717,7 @@
/* INS_$9E */ PACK( 0, 0 ),
/* INS_$9F */ PACK( 0, 0 ),
+ /* 0xA0 */
/* INS_$A0 */ PACK( 0, 0 ),
/* INS_$A1 */ PACK( 0, 0 ),
/* INS_$A2 */ PACK( 0, 0 ),
@@ -824,23 +735,25 @@
/* INS_$AE */ PACK( 0, 0 ),
/* INS_$AF */ PACK( 0, 0 ),
- /* PushB[0] */ PACK( 0, 1 ),
- /* PushB[1] */ PACK( 0, 2 ),
- /* PushB[2] */ PACK( 0, 3 ),
- /* PushB[3] */ PACK( 0, 4 ),
- /* PushB[4] */ PACK( 0, 5 ),
- /* PushB[5] */ PACK( 0, 6 ),
- /* PushB[6] */ PACK( 0, 7 ),
- /* PushB[7] */ PACK( 0, 8 ),
- /* PushW[0] */ PACK( 0, 1 ),
- /* PushW[1] */ PACK( 0, 2 ),
- /* PushW[2] */ PACK( 0, 3 ),
- /* PushW[3] */ PACK( 0, 4 ),
- /* PushW[4] */ PACK( 0, 5 ),
- /* PushW[5] */ PACK( 0, 6 ),
- /* PushW[6] */ PACK( 0, 7 ),
- /* PushW[7] */ PACK( 0, 8 ),
-
+ /* 0xB0 */
+ /* PUSHB[0] */ PACK( 0, 1 ),
+ /* PUSHB[1] */ PACK( 0, 2 ),
+ /* PUSHB[2] */ PACK( 0, 3 ),
+ /* PUSHB[3] */ PACK( 0, 4 ),
+ /* PUSHB[4] */ PACK( 0, 5 ),
+ /* PUSHB[5] */ PACK( 0, 6 ),
+ /* PUSHB[6] */ PACK( 0, 7 ),
+ /* PUSHB[7] */ PACK( 0, 8 ),
+ /* PUSHW[0] */ PACK( 0, 1 ),
+ /* PUSHW[1] */ PACK( 0, 2 ),
+ /* PUSHW[2] */ PACK( 0, 3 ),
+ /* PUSHW[3] */ PACK( 0, 4 ),
+ /* PUSHW[4] */ PACK( 0, 5 ),
+ /* PUSHW[5] */ PACK( 0, 6 ),
+ /* PUSHW[6] */ PACK( 0, 7 ),
+ /* PUSHW[7] */ PACK( 0, 8 ),
+
+ /* 0xC0 */
/* MDRP[00] */ PACK( 1, 0 ),
/* MDRP[01] */ PACK( 1, 0 ),
/* MDRP[02] */ PACK( 1, 0 ),
@@ -858,6 +771,7 @@
/* MDRP[14] */ PACK( 1, 0 ),
/* MDRP[15] */ PACK( 1, 0 ),
+ /* 0xD0 */
/* MDRP[16] */ PACK( 1, 0 ),
/* MDRP[17] */ PACK( 1, 0 ),
/* MDRP[18] */ PACK( 1, 0 ),
@@ -875,6 +789,7 @@
/* MDRP[30] */ PACK( 1, 0 ),
/* MDRP[31] */ PACK( 1, 0 ),
+ /* 0xE0 */
/* MIRP[00] */ PACK( 2, 0 ),
/* MIRP[01] */ PACK( 2, 0 ),
/* MIRP[02] */ PACK( 2, 0 ),
@@ -892,6 +807,7 @@
/* MIRP[14] */ PACK( 2, 0 ),
/* MIRP[15] */ PACK( 2, 0 ),
+ /* 0xF0 */
/* MIRP[16] */ PACK( 2, 0 ),
/* MIRP[17] */ PACK( 2, 0 ),
/* MIRP[18] */ PACK( 2, 0 ),
@@ -920,23 +836,25 @@
static
const char* const opcode_name[256] =
{
- "7 SVTCA y",
- "7 SVTCA x",
- "8 SPvTCA y",
- "8 SPvTCA x",
- "8 SFvTCA y",
- "8 SFvTCA x",
- "8 SPvTL ||",
- "7 SPvTL +",
- "8 SFvTL ||",
- "7 SFvTL +",
- "5 SPvFS",
- "5 SFvFS",
- "3 GPv",
- "3 GFv",
- "6 SFvTPv",
+ /* 0x00 */
+ "8 SVTCA[y]",
+ "8 SVTCA[x]",
+ "9 SPVTCA[y]",
+ "9 SPVTCA[x]",
+ "9 SFVTCA[y]",
+ "9 SFVTCA[x]",
+ "9 SPVTL[||]",
+ "8 SPVTL[+]",
+ "9 SFVTL[||]",
+ "8 SFVTL[+]",
+ "5 SPVFS",
+ "5 SFVFS",
+ "3 GPV",
+ "3 GFV",
+ "6 SFVTPV",
"5 ISECT",
+ /* 0x10 */
"4 SRP0",
"4 SRP1",
"4 SRP2",
@@ -950,10 +868,11 @@
"3 SMD",
"4 ELSE",
"4 JMPR",
- "6 SCvTCi",
- "5 SSwCi",
+ "6 SCVTCI",
+ "5 SSWCI",
"3 SSW",
+ /* 0x20 */
"3 DUP",
"3 POP",
"5 CLEAR",
@@ -961,50 +880,53 @@
"5 DEPTH",
"6 CINDEX",
"6 MINDEX",
- "8 AlignPTS",
+ "8 ALIGNPTS",
"7 INS_$28",
"3 UTP",
"8 LOOPCALL",
"4 CALL",
"4 FDEF",
"4 ENDF",
- "7 MDAP[0]",
- "7 MDAP[1]",
-
- "6 IUP[0]",
- "6 IUP[1]",
- "6 SHP[0]",
- "6 SHP[1]",
- "6 SHC[0]",
- "6 SHC[1]",
- "6 SHZ[0]",
- "6 SHZ[1]",
+ "6 MDAP[]",
+ "9 MDAP[rnd]",
+
+ /* 0x30 */
+ "6 IUP[y]",
+ "6 IUP[x]",
+ "8 SHP[rp2]",
+ "8 SHP[rp1]",
+ "8 SHC[rp2]",
+ "8 SHC[rp1]",
+ "8 SHZ[rp2]",
+ "8 SHZ[rp1]",
"5 SHPIX",
"2 IP",
- "8 MSIRP[0]",
- "8 MSIRP[1]",
- "7 AlignRP",
+ "7 MSIRP[]",
+ "A MSIRP[rp0]",
+ "7 ALIGNRP",
"4 RTDG",
- "7 MIAP[0]",
- "7 MIAP[1]",
+ "6 MIAP[]",
+ "9 MIAP[rnd]",
- "6 NPushB",
- "6 NPushW",
+ /* 0x40 */
+ "6 NPUSHB",
+ "6 NPUSHW",
"2 WS",
"2 RS",
- "5 WCvtP",
- "4 RCvt",
- "5 GC[0]",
- "5 GC[1]",
+ "5 WCVTP",
+ "4 RCVT",
+ "8 GC[curr]",
+ "8 GC[orig]",
"4 SCFS",
- "5 MD[0]",
- "5 MD[1]",
+ "8 MD[curr]",
+ "8 MD[orig]",
"5 MPPEM",
"3 MPS",
- "6 FlipON",
- "7 FlipOFF",
+ "6 FLIPON",
+ "7 FLIPOFF",
"5 DEBUG",
+ /* 0x50 */
"2 LT",
"4 LTEQ",
"2 GT",
@@ -1018,10 +940,11 @@
"3 AND",
"2 OR",
"3 NOT",
- "7 DeltaP1",
+ "7 DELTAP1",
"3 SDB",
"3 SDS",
+ /* 0x60 */
"3 ADD",
"3 SUB",
"3 DIV",
@@ -1030,23 +953,24 @@
"3 NEG",
"5 FLOOR",
"7 CEILING",
- "8 ROUND[0]",
- "8 ROUND[1]",
- "8 ROUND[2]",
- "8 ROUND[3]",
- "9 NROUND[0]",
- "9 NROUND[1]",
- "9 NROUND[2]",
- "9 NROUND[3]",
-
- "5 WCvtF",
- "7 DeltaP2",
- "7 DeltaP3",
- "A DeltaCn[0]",
- "A DeltaCn[1]",
- "A DeltaCn[2]",
+ "8 ROUND[G]",
+ "8 ROUND[B]",
+ "8 ROUND[W]",
+ "7 ROUND[]",
+ "9 NROUND[G]",
+ "9 NROUND[B]",
+ "9 NROUND[W]",
+ "8 NROUND[]",
+
+ /* 0x70 */
+ "5 WCVTF",
+ "7 DELTAP2",
+ "7 DELTAP3",
+ "7 DELTAC1",
+ "7 DELTAC2",
+ "7 DELTAC3",
"6 SROUND",
- "8 S45Round",
+ "8 S45ROUND",
"4 JROT",
"4 JROF",
"4 ROFF",
@@ -1056,26 +980,28 @@
"5 SANGW",
"2 AA",
- "6 FlipPT",
- "8 FlipRgON",
- "9 FlipRgOFF",
+ /* 0x80 */
+ "6 FLIPPT",
+ "8 FLIPRGON",
+ "9 FLIPRGOFF",
"7 INS_$83",
"7 INS_$84",
- "8 ScanCTRL",
- "9 SDPvTL[0]",
- "9 SDPvTL[1]",
- "7 GetINFO",
+ "8 SCANCTRL",
+ "A SDPVTL[||]",
+ "9 SDPVTL[+]",
+ "7 GETINFO",
"4 IDEF",
"4 ROLL",
"3 MAX",
"3 MIN",
- "8 ScanTYPE",
- "8 InstCTRL",
+ "8 SCANTYPE",
+ "8 INSTCTRL",
"7 INS_$8F",
+ /* 0x90 */
"7 INS_$90",
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- "6 GETVAR",
+ "C GETVARIATION",
"7 GETDATA",
#else
"7 INS_$91",
@@ -1095,6 +1021,7 @@
"7 INS_$9E",
"7 INS_$9F",
+ /* 0xA0 */
"7 INS_$A0",
"7 INS_$A1",
"7 INS_$A2",
@@ -1112,90 +1039,95 @@
"7 INS_$AE",
"7 INS_$AF",
- "8 PushB[0]",
- "8 PushB[1]",
- "8 PushB[2]",
- "8 PushB[3]",
- "8 PushB[4]",
- "8 PushB[5]",
- "8 PushB[6]",
- "8 PushB[7]",
- "8 PushW[0]",
- "8 PushW[1]",
- "8 PushW[2]",
- "8 PushW[3]",
- "8 PushW[4]",
- "8 PushW[5]",
- "8 PushW[6]",
- "8 PushW[7]",
-
- "8 MDRP[00]",
- "8 MDRP[01]",
- "8 MDRP[02]",
- "8 MDRP[03]",
- "8 MDRP[04]",
- "8 MDRP[05]",
- "8 MDRP[06]",
- "8 MDRP[07]",
- "8 MDRP[08]",
- "8 MDRP[09]",
- "8 MDRP[10]",
- "8 MDRP[11]",
- "8 MDRP[12]",
- "8 MDRP[13]",
- "8 MDRP[14]",
- "8 MDRP[15]",
-
- "8 MDRP[16]",
- "8 MDRP[17]",
- "8 MDRP[18]",
- "8 MDRP[19]",
- "8 MDRP[20]",
- "8 MDRP[21]",
- "8 MDRP[22]",
- "8 MDRP[23]",
- "8 MDRP[24]",
- "8 MDRP[25]",
- "8 MDRP[26]",
- "8 MDRP[27]",
- "8 MDRP[28]",
- "8 MDRP[29]",
- "8 MDRP[30]",
- "8 MDRP[31]",
-
- "8 MIRP[00]",
- "8 MIRP[01]",
- "8 MIRP[02]",
- "8 MIRP[03]",
- "8 MIRP[04]",
- "8 MIRP[05]",
- "8 MIRP[06]",
- "8 MIRP[07]",
- "8 MIRP[08]",
- "8 MIRP[09]",
- "8 MIRP[10]",
- "8 MIRP[11]",
- "8 MIRP[12]",
- "8 MIRP[13]",
- "8 MIRP[14]",
- "8 MIRP[15]",
-
- "8 MIRP[16]",
- "8 MIRP[17]",
- "8 MIRP[18]",
- "8 MIRP[19]",
- "8 MIRP[20]",
- "8 MIRP[21]",
- "8 MIRP[22]",
- "8 MIRP[23]",
- "8 MIRP[24]",
- "8 MIRP[25]",
- "8 MIRP[26]",
- "8 MIRP[27]",
- "8 MIRP[28]",
- "8 MIRP[29]",
- "8 MIRP[30]",
- "8 MIRP[31]"
+ /* 0xB0 */
+ "8 PUSHB[0]",
+ "8 PUSHB[1]",
+ "8 PUSHB[2]",
+ "8 PUSHB[3]",
+ "8 PUSHB[4]",
+ "8 PUSHB[5]",
+ "8 PUSHB[6]",
+ "8 PUSHB[7]",
+ "8 PUSHW[0]",
+ "8 PUSHW[1]",
+ "8 PUSHW[2]",
+ "8 PUSHW[3]",
+ "8 PUSHW[4]",
+ "8 PUSHW[5]",
+ "8 PUSHW[6]",
+ "8 PUSHW[7]",
+
+ /* 0xC0 */
+ "7 MDRP[G]",
+ "7 MDRP[B]",
+ "7 MDRP[W]",
+ "6 MDRP[]",
+ "8 MDRP[rG]",
+ "8 MDRP[rB]",
+ "8 MDRP[rW]",
+ "7 MDRP[r]",
+ "8 MDRP[mG]",
+ "8 MDRP[mB]",
+ "8 MDRP[mW]",
+ "7 MDRP[m]",
+ "9 MDRP[mrG]",
+ "9 MDRP[mrB]",
+ "9 MDRP[mrW]",
+ "8 MDRP[mr]",
+
+ /* 0xD0 */
+ "8 MDRP[pG]",
+ "8 MDRP[pB]",
+ "8 MDRP[pW]",
+ "7 MDRP[p]",
+ "9 MDRP[prG]",
+ "9 MDRP[prB]",
+ "9 MDRP[prW]",
+ "8 MDRP[pr]",
+ "9 MDRP[pmG]",
+ "9 MDRP[pmB]",
+ "9 MDRP[pmW]",
+ "8 MDRP[pm]",
+ "A MDRP[pmrG]",
+ "A MDRP[pmrB]",
+ "A MDRP[pmrW]",
+ "9 MDRP[pmr]",
+
+ /* 0xE0 */
+ "7 MIRP[G]",
+ "7 MIRP[B]",
+ "7 MIRP[W]",
+ "6 MIRP[]",
+ "8 MIRP[rG]",
+ "8 MIRP[rB]",
+ "8 MIRP[rW]",
+ "7 MIRP[r]",
+ "8 MIRP[mG]",
+ "8 MIRP[mB]",
+ "8 MIRP[mW]",
+ "7 MIRP[m]",
+ "9 MIRP[mrG]",
+ "9 MIRP[mrB]",
+ "9 MIRP[mrW]",
+ "8 MIRP[mr]",
+
+ /* 0xF0 */
+ "8 MIRP[pG]",
+ "8 MIRP[pB]",
+ "8 MIRP[pW]",
+ "7 MIRP[p]",
+ "9 MIRP[prG]",
+ "9 MIRP[prB]",
+ "9 MIRP[prW]",
+ "8 MIRP[pr]",
+ "9 MIRP[pmG]",
+ "9 MIRP[pmB]",
+ "9 MIRP[pmW]",
+ "8 MIRP[pm]",
+ "A MIRP[pmrG]",
+ "A MIRP[pmrB]",
+ "A MIRP[pmrW]",
+ "9 MIRP[pmr]"
};
#endif /* FT_DEBUG_LEVEL_TRACE */
@@ -1448,18 +1380,18 @@
#endif /* TT_DotFix14 */
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Current_Ratio */
- /* */
- /* <Description> */
- /* Returns the current aspect ratio scaling factor depending on the */
- /* projection vector's state and device resolutions. */
- /* */
- /* <Return> */
- /* The aspect ratio in 16.16 format, always <= 1.0 . */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Current_Ratio
+ *
+ * @Description:
+ * Returns the current aspect ratio scaling factor depending on the
+ * projection vector's state and device resolutions.
+ *
+ * @Return:
+ * The aspect ratio in 16.16 format, always <= 1.0 .
+ */
static FT_Long
Current_Ratio( TT_ExecContext exc )
{
@@ -1501,11 +1433,11 @@
}
- /*************************************************************************/
- /* */
- /* Functions related to the control value table (CVT). */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * Functions related to the control value table (CVT).
+ *
+ */
FT_CALLBACK_DEF( FT_F26Dot6 )
@@ -1524,11 +1456,37 @@
}
+ static void
+ Modify_CVT_Check( TT_ExecContext exc )
+ {
+ if ( exc->iniRange == tt_coderange_glyph &&
+ exc->cvt != exc->glyfCvt )
+ {
+ FT_Memory memory = exc->memory;
+ FT_Error error;
+
+
+ FT_MEM_QRENEW_ARRAY( exc->glyfCvt, exc->glyfCvtSize, exc->cvtSize );
+ exc->error = error;
+ if ( error )
+ return;
+
+ exc->glyfCvtSize = exc->cvtSize;
+ FT_ARRAY_COPY( exc->glyfCvt, exc->cvt, exc->glyfCvtSize );
+ exc->cvt = exc->glyfCvt;
+ }
+ }
+
+
FT_CALLBACK_DEF( void )
Write_CVT( TT_ExecContext exc,
FT_ULong idx,
FT_F26Dot6 value )
{
+ Modify_CVT_Check( exc );
+ if ( exc->error )
+ return;
+
exc->cvt[idx] = value;
}
@@ -1538,6 +1496,10 @@
FT_ULong idx,
FT_F26Dot6 value )
{
+ Modify_CVT_Check( exc );
+ if ( exc->error )
+ return;
+
exc->cvt[idx] = FT_DivFix( value, Current_Ratio( exc ) );
}
@@ -1547,7 +1509,11 @@
FT_ULong idx,
FT_F26Dot6 value )
{
- exc->cvt[idx] += value;
+ Modify_CVT_Check( exc );
+ if ( exc->error )
+ return;
+
+ exc->cvt[idx] = ADD_LONG( exc->cvt[idx], value );
}
@@ -1556,25 +1522,30 @@
FT_ULong idx,
FT_F26Dot6 value )
{
- exc->cvt[idx] += FT_DivFix( value, Current_Ratio( exc ) );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* GetShortIns */
- /* */
- /* <Description> */
- /* Returns a short integer taken from the instruction stream at */
- /* address IP. */
- /* */
- /* <Return> */
- /* Short read at code[IP]. */
- /* */
- /* <Note> */
- /* This one could become a macro. */
- /* */
+ Modify_CVT_Check( exc );
+ if ( exc->error )
+ return;
+
+ exc->cvt[idx] = ADD_LONG( exc->cvt[idx],
+ FT_DivFix( value, Current_Ratio( exc ) ) );
+ }
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * GetShortIns
+ *
+ * @Description:
+ * Returns a short integer taken from the instruction stream at
+ * address IP.
+ *
+ * @Return:
+ * Short read at code[IP].
+ *
+ * @Note:
+ * This one could become a macro.
+ */
static FT_Short
GetShortIns( TT_ExecContext exc )
{
@@ -1585,22 +1556,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Ins_Goto_CodeRange */
- /* */
- /* <Description> */
- /* Goes to a certain code range in the instruction stream. */
- /* */
- /* <Input> */
- /* aRange :: The index of the code range. */
- /* */
- /* aIP :: The new IP address in the code range. */
- /* */
- /* <Return> */
- /* SUCCESS or FAILURE. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Ins_Goto_CodeRange
+ *
+ * @Description:
+ * Goes to a certain code range in the instruction stream.
+ *
+ * @Input:
+ * aRange ::
+ * The index of the code range.
+ *
+ * aIP ::
+ * The new IP address in the code range.
+ *
+ * @Return:
+ * SUCCESS or FAILURE.
+ */
static FT_Bool
Ins_Goto_CodeRange( TT_ExecContext exc,
FT_Int aRange,
@@ -1642,27 +1615,56 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Direct_Move */
- /* */
- /* <Description> */
- /* Moves a point by a given distance along the freedom vector. The */
- /* point will be `touched'. */
- /* */
- /* <Input> */
- /* point :: The index of the point to move. */
- /* */
- /* distance :: The distance to apply. */
- /* */
- /* <InOut> */
- /* zone :: The affected glyph zone. */
- /* */
- /* <Note> */
- /* See `ttinterp.h' for details on backward compatibility mode. */
- /* `Touches' the point. */
- /* */
+ /*
+ *
+ * Apple's TrueType specification at
+ *
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#order
+ *
+ * gives the following order of operations in instructions that move
+ * points.
+ *
+ * - check single width cut-in (MIRP, MDRP)
+ *
+ * - check control value cut-in (MIRP, MIAP)
+ *
+ * - apply engine compensation (MIRP, MDRP)
+ *
+ * - round distance (MIRP, MDRP) or value (MIAP, MDAP)
+ *
+ * - check minimum distance (MIRP,MDRP)
+ *
+ * - move point (MIRP, MDRP, MIAP, MSIRP, MDAP)
+ *
+ * For rounding instructions, engine compensation happens before rounding.
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * Direct_Move
+ *
+ * @Description:
+ * Moves a point by a given distance along the freedom vector. The
+ * point will be `touched'.
+ *
+ * @Input:
+ * point ::
+ * The index of the point to move.
+ *
+ * distance ::
+ * The distance to apply.
+ *
+ * @InOut:
+ * zone ::
+ * The affected glyph zone.
+ *
+ * @Note:
+ * See `ttinterp.h' for details on backward compatibility mode.
+ * `Touches' the point.
+ */
static void
Direct_Move( TT_ExecContext exc,
TT_GlyphZone zone,
@@ -1676,17 +1678,6 @@
if ( v != 0 )
{
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- ( !exc->ignore_x_mode ||
- ( exc->sph_tweak_flags & SPH_TWEAK_ALLOW_X_DMOVE ) ) )
- zone->cur[point].x = ADD_LONG( zone->cur[point].x,
- FT_MulDiv( distance,
- v,
- exc->F_dot_P ) );
- else
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
/* Exception to the post-IUP curfew: Allow the x component of */
/* diagonal moves, but only post-IUP. DejaVu tries to adjust */
@@ -1728,23 +1719,26 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Direct_Move_Orig */
- /* */
- /* <Description> */
- /* Moves the *original* position of a point by a given distance along */
- /* the freedom vector. Obviously, the point will not be `touched'. */
- /* */
- /* <Input> */
- /* point :: The index of the point to move. */
- /* */
- /* distance :: The distance to apply. */
- /* */
- /* <InOut> */
- /* zone :: The affected glyph zone. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Direct_Move_Orig
+ *
+ * @Description:
+ * Moves the *original* position of a point by a given distance along
+ * the freedom vector. Obviously, the point will not be `touched'.
+ *
+ * @Input:
+ * point ::
+ * The index of the point to move.
+ *
+ * distance ::
+ * The distance to apply.
+ *
+ * @InOut:
+ * zone ::
+ * The affected glyph zone.
+ */
static void
Direct_Move_Orig( TT_ExecContext exc,
TT_GlyphZone zone,
@@ -1772,15 +1766,15 @@
}
- /*************************************************************************/
- /* */
- /* Special versions of Direct_Move() */
- /* */
- /* The following versions are used whenever both vectors are both */
- /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
- /* See `ttinterp.h' for details on backward compatibility mode. */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * Special versions of Direct_Move()
+ *
+ * The following versions are used whenever both vectors are both
+ * along one of the coordinate unit vectors, i.e. in 90% of the cases.
+ * See `ttinterp.h' for details on backward compatibility mode.
+ *
+ */
static void
@@ -1789,12 +1783,6 @@
FT_UShort point,
FT_F26Dot6 distance )
{
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY && !exc->ignore_x_mode )
- zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
- else
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
@@ -1827,14 +1815,14 @@
}
- /*************************************************************************/
- /* */
- /* Special versions of Direct_Move_Orig() */
- /* */
- /* The following versions are used whenever both vectors are both */
- /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * Special versions of Direct_Move_Orig()
+ *
+ * The following versions are used whenever both vectors are both
+ * along one of the coordinate unit vectors, i.e. in 90% of the cases.
+ *
+ */
static void
@@ -1860,38 +1848,32 @@
zone->org[point].y = ADD_LONG( zone->org[point].y, distance );
}
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_None */
- /* */
- /* <Description> */
- /* Does not round, but adds engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance (not) to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* The compensated distance. */
- /* */
- /* <Note> */
- /* The TrueType specification says very few about the relationship */
- /* between rounding and engine compensation. However, it seems from */
- /* the description of super round that we should add the compensation */
- /* before rounding. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_None
+ *
+ * @Description:
+ * Does not round, but adds engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance (not) to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * The compensated distance.
+ */
static FT_F26Dot6
Round_None( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
- FT_UNUSED( exc );
-
if ( distance >= 0 )
{
@@ -1909,31 +1891,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_To_Grid */
- /* */
- /* <Description> */
- /* Rounds value to grid after adding engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* Rounded distance. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_To_Grid
+ *
+ * @Description:
+ * Rounds value to grid after adding engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * Rounded distance.
+ */
static FT_F26Dot6
Round_To_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
- FT_UNUSED( exc );
-
if ( distance >= 0 )
{
@@ -1953,31 +1936,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_To_Half_Grid */
- /* */
- /* <Description> */
- /* Rounds value to half grid after adding engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* Rounded distance. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_To_Half_Grid
+ *
+ * @Description:
+ * Rounds value to half grid after adding engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * Rounded distance.
+ */
static FT_F26Dot6
Round_To_Half_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
- FT_UNUSED( exc );
-
if ( distance >= 0 )
{
@@ -1999,31 +1983,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_Down_To_Grid */
- /* */
- /* <Description> */
- /* Rounds value down to grid after adding engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* Rounded distance. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_Down_To_Grid
+ *
+ * @Description:
+ * Rounds value down to grid after adding engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * Rounded distance.
+ */
static FT_F26Dot6
Round_Down_To_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
- FT_UNUSED( exc );
-
if ( distance >= 0 )
{
@@ -2042,31 +2027,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_Up_To_Grid */
- /* */
- /* <Description> */
- /* Rounds value up to grid after adding engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* Rounded distance. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_Up_To_Grid
+ *
+ * @Description:
+ * Rounds value up to grid after adding engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * Rounded distance.
+ */
static FT_F26Dot6
Round_Up_To_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
- FT_UNUSED( exc );
-
if ( distance >= 0 )
{
@@ -2086,31 +2072,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_To_Double_Grid */
- /* */
- /* <Description> */
- /* Rounds value to double grid after adding engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* Rounded distance. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_To_Double_Grid
+ *
+ * @Description:
+ * Rounds value to double grid after adding engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * Rounded distance.
+ */
static FT_F26Dot6
Round_To_Double_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
- FT_UNUSED( exc );
-
if ( distance >= 0 )
{
@@ -2130,33 +2117,36 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_Super */
- /* */
- /* <Description> */
- /* Super-rounds value to grid after adding engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* Rounded distance. */
- /* */
- /* <Note> */
- /* The TrueType specification says very little about the relationship */
- /* between rounding and engine compensation. However, it seems from */
- /* the description of super round that we should add the compensation */
- /* before rounding. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_Super
+ *
+ * @Description:
+ * Super-rounds value to grid after adding engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * Rounded distance.
+ *
+ * @Note:
+ * The TrueType specification says very little about the relationship
+ * between rounding and engine compensation. However, it seems from
+ * the description of super round that we should add the compensation
+ * before rounding.
+ */
static FT_F26Dot6
Round_Super( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
@@ -2183,31 +2173,34 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Round_Super_45 */
- /* */
- /* <Description> */
- /* Super-rounds value to grid after adding engine compensation. */
- /* */
- /* <Input> */
- /* distance :: The distance to round. */
- /* */
- /* compensation :: The engine compensation. */
- /* */
- /* <Return> */
- /* Rounded distance. */
- /* */
- /* <Note> */
- /* There is a separate function for Round_Super_45() as we may need */
- /* greater precision. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Round_Super_45
+ *
+ * @Description:
+ * Super-rounds value to grid after adding engine compensation.
+ *
+ * @Input:
+ * distance ::
+ * The distance to round.
+ *
+ * color ::
+ * The engine compensation color.
+ *
+ * @Return:
+ * Rounded distance.
+ *
+ * @Note:
+ * There is a separate function for Round_Super_45() as we may need
+ * greater precision.
+ */
static FT_F26Dot6
Round_Super_45( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation )
+ FT_Int color )
{
+ FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
@@ -2234,17 +2227,18 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Compute_Round */
- /* */
- /* <Description> */
- /* Sets the rounding mode. */
- /* */
- /* <Input> */
- /* round_mode :: The rounding mode to be used. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Compute_Round
+ *
+ * @Description:
+ * Sets the rounding mode.
+ *
+ * @Input:
+ * round_mode ::
+ * The rounding mode to be used.
+ */
static void
Compute_Round( TT_ExecContext exc,
FT_Byte round_mode )
@@ -2286,19 +2280,21 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* SetSuperRound */
- /* */
- /* <Description> */
- /* Sets Super Round parameters. */
- /* */
- /* <Input> */
- /* GridPeriod :: The grid period. */
- /* */
- /* selector :: The SROUND opcode. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * SetSuperRound
+ *
+ * @Description:
+ * Sets Super Round parameters.
+ *
+ * @Input:
+ * GridPeriod ::
+ * The grid period.
+ *
+ * selector ::
+ * The SROUND opcode.
+ */
static void
SetSuperRound( TT_ExecContext exc,
FT_F2Dot14 GridPeriod,
@@ -2355,22 +2351,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Project */
- /* */
- /* <Description> */
- /* Computes the projection of vector given by (v2-v1) along the */
- /* current projection vector. */
- /* */
- /* <Input> */
- /* v1 :: First input vector. */
- /* v2 :: Second input vector. */
- /* */
- /* <Return> */
- /* The distance in F26dot6 format. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Project
+ *
+ * @Description:
+ * Computes the projection of vector given by (v2-v1) along the
+ * current projection vector.
+ *
+ * @Input:
+ * v1 ::
+ * First input vector.
+ * v2 ::
+ * Second input vector.
+ *
+ * @Return:
+ * The distance in F26dot6 format.
+ */
static FT_F26Dot6
Project( TT_ExecContext exc,
FT_Pos dx,
@@ -2382,22 +2380,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Dual_Project */
- /* */
- /* <Description> */
- /* Computes the projection of the vector given by (v2-v1) along the */
- /* current dual vector. */
- /* */
- /* <Input> */
- /* v1 :: First input vector. */
- /* v2 :: Second input vector. */
- /* */
- /* <Return> */
- /* The distance in F26dot6 format. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Dual_Project
+ *
+ * @Description:
+ * Computes the projection of the vector given by (v2-v1) along the
+ * current dual vector.
+ *
+ * @Input:
+ * v1 ::
+ * First input vector.
+ * v2 ::
+ * Second input vector.
+ *
+ * @Return:
+ * The distance in F26dot6 format.
+ */
static FT_F26Dot6
Dual_Project( TT_ExecContext exc,
FT_Pos dx,
@@ -2409,22 +2409,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Project_x */
- /* */
- /* <Description> */
- /* Computes the projection of the vector given by (v2-v1) along the */
- /* horizontal axis. */
- /* */
- /* <Input> */
- /* v1 :: First input vector. */
- /* v2 :: Second input vector. */
- /* */
- /* <Return> */
- /* The distance in F26dot6 format. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Project_x
+ *
+ * @Description:
+ * Computes the projection of the vector given by (v2-v1) along the
+ * horizontal axis.
+ *
+ * @Input:
+ * v1 ::
+ * First input vector.
+ * v2 ::
+ * Second input vector.
+ *
+ * @Return:
+ * The distance in F26dot6 format.
+ */
static FT_F26Dot6
Project_x( TT_ExecContext exc,
FT_Pos dx,
@@ -2437,22 +2439,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Project_y */
- /* */
- /* <Description> */
- /* Computes the projection of the vector given by (v2-v1) along the */
- /* vertical axis. */
- /* */
- /* <Input> */
- /* v1 :: First input vector. */
- /* v2 :: Second input vector. */
- /* */
- /* <Return> */
- /* The distance in F26dot6 format. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Project_y
+ *
+ * @Description:
+ * Computes the projection of the vector given by (v2-v1) along the
+ * vertical axis.
+ *
+ * @Input:
+ * v1 ::
+ * First input vector.
+ * v2 ::
+ * Second input vector.
+ *
+ * @Return:
+ * The distance in F26dot6 format.
+ */
static FT_F26Dot6
Project_y( TT_ExecContext exc,
FT_Pos dx,
@@ -2465,15 +2469,15 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Compute_Funcs */
- /* */
- /* <Description> */
- /* Computes the projection and movement function pointers according */
- /* to the current graphics state. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Compute_Funcs
+ *
+ * @Description:
+ * Computes the projection and movement function pointers according
+ * to the current graphics state.
+ */
static void
Compute_Funcs( TT_ExecContext exc )
{
@@ -2528,28 +2532,31 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Normalize */
- /* */
- /* <Description> */
- /* Norms a vector. */
- /* */
- /* <Input> */
- /* Vx :: The horizontal input vector coordinate. */
- /* Vy :: The vertical input vector coordinate. */
- /* */
- /* <Output> */
- /* R :: The normed unit vector. */
- /* */
- /* <Return> */
- /* Returns FAILURE if a vector parameter is zero. */
- /* */
- /* <Note> */
- /* In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and */
- /* R is undefined. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * Normalize
+ *
+ * @Description:
+ * Norms a vector.
+ *
+ * @Input:
+ * Vx ::
+ * The horizontal input vector coordinate.
+ * Vy ::
+ * The vertical input vector coordinate.
+ *
+ * @Output:
+ * R ::
+ * The normed unit vector.
+ *
+ * @Return:
+ * Returns FAILURE if a vector parameter is zero.
+ *
+ * @Note:
+ * In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and
+ * R is undefined.
+ */
static FT_Bool
Normalize( FT_F26Dot6 Vx,
FT_F26Dot6 Vy,
@@ -2577,11 +2584,11 @@
}
- /*************************************************************************/
- /* */
- /* Here we start with the implementation of the various opcodes. */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * Here we start with the implementation of the various opcodes.
+ *
+ */
#define ARRAY_BOUND_ERROR \
@@ -2592,12 +2599,12 @@
} while (0)
- /*************************************************************************/
- /* */
- /* MPPEM[]: Measure Pixel Per EM */
- /* Opcode range: 0x4B */
- /* Stack: --> Euint16 */
- /* */
+ /**************************************************************************
+ *
+ * MPPEM[]: Measure Pixel Per EM
+ * Opcode range: 0x4B
+ * Stack: --> Euint16
+ */
static void
Ins_MPPEM( TT_ExecContext exc,
FT_Long* args )
@@ -2606,12 +2613,12 @@
}
- /*************************************************************************/
- /* */
- /* MPS[]: Measure Point Size */
- /* Opcode range: 0x4C */
- /* Stack: --> Euint16 */
- /* */
+ /**************************************************************************
+ *
+ * MPS[]: Measure Point Size
+ * Opcode range: 0x4C
+ * Stack: --> Euint16
+ */
static void
Ins_MPS( TT_ExecContext exc,
FT_Long* args )
@@ -2633,12 +2640,12 @@
}
- /*************************************************************************/
- /* */
- /* DUP[]: DUPlicate the stack's top element */
- /* Opcode range: 0x20 */
- /* Stack: StkElt --> StkElt StkElt */
- /* */
+ /**************************************************************************
+ *
+ * DUP[]: DUPlicate the stack's top element
+ * Opcode range: 0x20
+ * Stack: StkElt --> StkElt StkElt
+ */
static void
Ins_DUP( FT_Long* args )
{
@@ -2646,12 +2653,12 @@
}
- /*************************************************************************/
- /* */
- /* POP[]: POP the stack's top element */
- /* Opcode range: 0x21 */
- /* Stack: StkElt --> */
- /* */
+ /**************************************************************************
+ *
+ * POP[]: POP the stack's top element
+ * Opcode range: 0x21
+ * Stack: StkElt -->
+ */
static void
Ins_POP( void )
{
@@ -2659,12 +2666,12 @@
}
- /*************************************************************************/
- /* */
- /* CLEAR[]: CLEAR the entire stack */
- /* Opcode range: 0x22 */
- /* Stack: StkElt... --> */
- /* */
+ /**************************************************************************
+ *
+ * CLEAR[]: CLEAR the entire stack
+ * Opcode range: 0x22
+ * Stack: StkElt... -->
+ */
static void
Ins_CLEAR( TT_ExecContext exc )
{
@@ -2672,12 +2679,12 @@
}
- /*************************************************************************/
- /* */
- /* SWAP[]: SWAP the stack's top two elements */
- /* Opcode range: 0x23 */
- /* Stack: 2 * StkElt --> 2 * StkElt */
- /* */
+ /**************************************************************************
+ *
+ * SWAP[]: SWAP the stack's top two elements
+ * Opcode range: 0x23
+ * Stack: 2 * StkElt --> 2 * StkElt
+ */
static void
Ins_SWAP( FT_Long* args )
{
@@ -2690,12 +2697,12 @@
}
- /*************************************************************************/
- /* */
- /* DEPTH[]: return the stack DEPTH */
- /* Opcode range: 0x24 */
- /* Stack: --> uint32 */
- /* */
+ /**************************************************************************
+ *
+ * DEPTH[]: return the stack DEPTH
+ * Opcode range: 0x24
+ * Stack: --> uint32
+ */
static void
Ins_DEPTH( TT_ExecContext exc,
FT_Long* args )
@@ -2704,12 +2711,12 @@
}
- /*************************************************************************/
- /* */
- /* LT[]: Less Than */
- /* Opcode range: 0x50 */
- /* Stack: int32? int32? --> bool */
- /* */
+ /**************************************************************************
+ *
+ * LT[]: Less Than
+ * Opcode range: 0x50
+ * Stack: int32? int32? --> bool
+ */
static void
Ins_LT( FT_Long* args )
{
@@ -2717,12 +2724,12 @@
}
- /*************************************************************************/
- /* */
- /* LTEQ[]: Less Than or EQual */
- /* Opcode range: 0x51 */
- /* Stack: int32? int32? --> bool */
- /* */
+ /**************************************************************************
+ *
+ * LTEQ[]: Less Than or EQual
+ * Opcode range: 0x51
+ * Stack: int32? int32? --> bool
+ */
static void
Ins_LTEQ( FT_Long* args )
{
@@ -2730,12 +2737,12 @@
}
- /*************************************************************************/
- /* */
- /* GT[]: Greater Than */
- /* Opcode range: 0x52 */
- /* Stack: int32? int32? --> bool */
- /* */
+ /**************************************************************************
+ *
+ * GT[]: Greater Than
+ * Opcode range: 0x52
+ * Stack: int32? int32? --> bool
+ */
static void
Ins_GT( FT_Long* args )
{
@@ -2743,12 +2750,12 @@
}
- /*************************************************************************/
- /* */
- /* GTEQ[]: Greater Than or EQual */
- /* Opcode range: 0x53 */
- /* Stack: int32? int32? --> bool */
- /* */
+ /**************************************************************************
+ *
+ * GTEQ[]: Greater Than or EQual
+ * Opcode range: 0x53
+ * Stack: int32? int32? --> bool
+ */
static void
Ins_GTEQ( FT_Long* args )
{
@@ -2756,12 +2763,12 @@
}
- /*************************************************************************/
- /* */
- /* EQ[]: EQual */
- /* Opcode range: 0x54 */
- /* Stack: StkElt StkElt --> bool */
- /* */
+ /**************************************************************************
+ *
+ * EQ[]: EQual
+ * Opcode range: 0x54
+ * Stack: StkElt StkElt --> bool
+ */
static void
Ins_EQ( FT_Long* args )
{
@@ -2769,12 +2776,12 @@
}
- /*************************************************************************/
- /* */
- /* NEQ[]: Not EQual */
- /* Opcode range: 0x55 */
- /* Stack: StkElt StkElt --> bool */
- /* */
+ /**************************************************************************
+ *
+ * NEQ[]: Not EQual
+ * Opcode range: 0x55
+ * Stack: StkElt StkElt --> bool
+ */
static void
Ins_NEQ( FT_Long* args )
{
@@ -2782,40 +2789,40 @@
}
- /*************************************************************************/
- /* */
- /* ODD[]: Is ODD */
- /* Opcode range: 0x56 */
- /* Stack: f26.6 --> bool */
- /* */
+ /**************************************************************************
+ *
+ * ODD[]: Is ODD
+ * Opcode range: 0x56
+ * Stack: f26.6 --> bool
+ */
static void
Ins_ODD( TT_ExecContext exc,
FT_Long* args )
{
- args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 64 );
+ args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 64 );
}
- /*************************************************************************/
- /* */
- /* EVEN[]: Is EVEN */
- /* Opcode range: 0x57 */
- /* Stack: f26.6 --> bool */
- /* */
+ /**************************************************************************
+ *
+ * EVEN[]: Is EVEN
+ * Opcode range: 0x57
+ * Stack: f26.6 --> bool
+ */
static void
Ins_EVEN( TT_ExecContext exc,
FT_Long* args )
{
- args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 0 );
+ args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 0 );
}
- /*************************************************************************/
- /* */
- /* AND[]: logical AND */
- /* Opcode range: 0x5A */
- /* Stack: uint32 uint32 --> uint32 */
- /* */
+ /**************************************************************************
+ *
+ * AND[]: logical AND
+ * Opcode range: 0x5A
+ * Stack: uint32 uint32 --> uint32
+ */
static void
Ins_AND( FT_Long* args )
{
@@ -2823,12 +2830,12 @@
}
- /*************************************************************************/
- /* */
- /* OR[]: logical OR */
- /* Opcode range: 0x5B */
- /* Stack: uint32 uint32 --> uint32 */
- /* */
+ /**************************************************************************
+ *
+ * OR[]: logical OR
+ * Opcode range: 0x5B
+ * Stack: uint32 uint32 --> uint32
+ */
static void
Ins_OR( FT_Long* args )
{
@@ -2836,12 +2843,12 @@
}
- /*************************************************************************/
- /* */
- /* NOT[]: logical NOT */
- /* Opcode range: 0x5C */
- /* Stack: StkElt --> uint32 */
- /* */
+ /**************************************************************************
+ *
+ * NOT[]: logical NOT
+ * Opcode range: 0x5C
+ * Stack: StkElt --> uint32
+ */
static void
Ins_NOT( FT_Long* args )
{
@@ -2849,12 +2856,12 @@
}
- /*************************************************************************/
- /* */
- /* ADD[]: ADD */
- /* Opcode range: 0x60 */
- /* Stack: f26.6 f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * ADD[]: ADD
+ * Opcode range: 0x60
+ * Stack: f26.6 f26.6 --> f26.6
+ */
static void
Ins_ADD( FT_Long* args )
{
@@ -2862,12 +2869,12 @@
}
- /*************************************************************************/
- /* */
- /* SUB[]: SUBtract */
- /* Opcode range: 0x61 */
- /* Stack: f26.6 f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * SUB[]: SUBtract
+ * Opcode range: 0x61
+ * Stack: f26.6 f26.6 --> f26.6
+ */
static void
Ins_SUB( FT_Long* args )
{
@@ -2875,12 +2882,12 @@
}
- /*************************************************************************/
- /* */
- /* DIV[]: DIVide */
- /* Opcode range: 0x62 */
- /* Stack: f26.6 f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * DIV[]: DIVide
+ * Opcode range: 0x62
+ * Stack: f26.6 f26.6 --> f26.6
+ */
static void
Ins_DIV( TT_ExecContext exc,
FT_Long* args )
@@ -2892,12 +2899,12 @@
}
- /*************************************************************************/
- /* */
- /* MUL[]: MULtiply */
- /* Opcode range: 0x63 */
- /* Stack: f26.6 f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * MUL[]: MULtiply
+ * Opcode range: 0x63
+ * Stack: f26.6 f26.6 --> f26.6
+ */
static void
Ins_MUL( FT_Long* args )
{
@@ -2905,12 +2912,12 @@
}
- /*************************************************************************/
- /* */
- /* ABS[]: ABSolute value */
- /* Opcode range: 0x64 */
- /* Stack: f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * ABS[]: ABSolute value
+ * Opcode range: 0x64
+ * Stack: f26.6 --> f26.6
+ */
static void
Ins_ABS( FT_Long* args )
{
@@ -2919,12 +2926,12 @@
}
- /*************************************************************************/
- /* */
- /* NEG[]: NEGate */
- /* Opcode range: 0x65 */
- /* Stack: f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * NEG[]: NEGate
+ * Opcode range: 0x65
+ * Stack: f26.6 --> f26.6
+ */
static void
Ins_NEG( FT_Long* args )
{
@@ -2932,12 +2939,12 @@
}
- /*************************************************************************/
- /* */
- /* FLOOR[]: FLOOR */
- /* Opcode range: 0x66 */
- /* Stack: f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * FLOOR[]: FLOOR
+ * Opcode range: 0x66
+ * Stack: f26.6 --> f26.6
+ */
static void
Ins_FLOOR( FT_Long* args )
{
@@ -2945,12 +2952,12 @@
}
- /*************************************************************************/
- /* */
- /* CEILING[]: CEILING */
- /* Opcode range: 0x67 */
- /* Stack: f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * CEILING[]: CEILING
+ * Opcode range: 0x67
+ * Stack: f26.6 --> f26.6
+ */
static void
Ins_CEILING( FT_Long* args )
{
@@ -2958,12 +2965,12 @@
}
- /*************************************************************************/
- /* */
- /* RS[]: Read Store */
- /* Opcode range: 0x43 */
- /* Stack: uint32 --> uint32 */
- /* */
+ /**************************************************************************
+ *
+ * RS[]: Read Store
+ * Opcode range: 0x43
+ * Stack: uint32 --> uint32
+ */
static void
Ins_RS( TT_ExecContext exc,
FT_Long* args )
@@ -2979,37 +2986,16 @@
args[0] = 0;
}
else
- {
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* subpixel hinting - avoid Typeman Dstroke and */
- /* IStroke and Vacuform rounds */
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- ( ( I == 24 &&
- ( exc->face->sph_found_func_flags &
- ( SPH_FDEF_SPACING_1 |
- SPH_FDEF_SPACING_2 ) ) ) ||
- ( I == 22 &&
- ( exc->sph_in_func_flags &
- SPH_FDEF_TYPEMAN_STROKES ) ) ||
- ( I == 8 &&
- ( exc->face->sph_found_func_flags &
- SPH_FDEF_VACUFORM_ROUND_1 ) &&
- exc->iup_called ) ) )
- args[0] = 0;
- else
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
- args[0] = exc->storage[I];
- }
+ args[0] = exc->storage[I];
}
- /*************************************************************************/
- /* */
- /* WS[]: Write Store */
- /* Opcode range: 0x42 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * WS[]: Write Store
+ * Opcode range: 0x42
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_WS( TT_ExecContext exc,
FT_Long* args )
@@ -3023,16 +3009,37 @@
ARRAY_BOUND_ERROR;
}
else
+ {
+ if ( exc->iniRange == tt_coderange_glyph &&
+ exc->storage != exc->glyfStorage )
+ {
+ FT_Memory memory = exc->memory;
+ FT_Error error;
+
+
+ FT_MEM_QRENEW_ARRAY( exc->glyfStorage,
+ exc->glyfStoreSize,
+ exc->storeSize );
+ exc->error = error;
+ if ( error )
+ return;
+
+ exc->glyfStoreSize = exc->storeSize;
+ FT_ARRAY_COPY( exc->glyfStorage, exc->storage, exc->glyfStoreSize );
+ exc->storage = exc->glyfStorage;
+ }
+
exc->storage[I] = args[1];
+ }
}
- /*************************************************************************/
- /* */
- /* WCVTP[]: Write CVT in Pixel units */
- /* Opcode range: 0x44 */
- /* Stack: f26.6 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * WCVTP[]: Write CVT in Pixel units
+ * Opcode range: 0x44
+ * Stack: f26.6 uint32 -->
+ */
static void
Ins_WCVTP( TT_ExecContext exc,
FT_Long* args )
@@ -3050,12 +3057,12 @@
}
- /*************************************************************************/
- /* */
- /* WCVTF[]: Write CVT in Funits */
- /* Opcode range: 0x70 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * WCVTF[]: Write CVT in Funits
+ * Opcode range: 0x70
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_WCVTF( TT_ExecContext exc,
FT_Long* args )
@@ -3073,12 +3080,12 @@
}
- /*************************************************************************/
- /* */
- /* RCVT[]: Read CVT */
- /* Opcode range: 0x45 */
- /* Stack: uint32 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * RCVT[]: Read CVT
+ * Opcode range: 0x45
+ * Stack: uint32 --> f26.6
+ */
static void
Ins_RCVT( TT_ExecContext exc,
FT_Long* args )
@@ -3098,12 +3105,12 @@
}
- /*************************************************************************/
- /* */
- /* AA[]: Adjust Angle */
- /* Opcode range: 0x7F */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * AA[]: Adjust Angle
+ * Opcode range: 0x7F
+ * Stack: uint32 -->
+ */
static void
Ins_AA( void )
{
@@ -3111,14 +3118,14 @@
}
- /*************************************************************************/
- /* */
- /* DEBUG[]: DEBUG. Unsupported. */
- /* Opcode range: 0x4F */
- /* Stack: uint32 --> */
- /* */
- /* Note: The original instruction pops a value from the stack. */
- /* */
+ /**************************************************************************
+ *
+ * DEBUG[]: DEBUG. Unsupported.
+ * Opcode range: 0x4F
+ * Stack: uint32 -->
+ *
+ * Note: The original instruction pops a value from the stack.
+ */
static void
Ins_DEBUG( TT_ExecContext exc )
{
@@ -3126,46 +3133,40 @@
}
- /*************************************************************************/
- /* */
- /* ROUND[ab]: ROUND value */
- /* Opcode range: 0x68-0x6B */
- /* Stack: f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * ROUND[ab]: ROUND value
+ * Opcode range: 0x68-0x6B
+ * Stack: f26.6 --> f26.6
+ */
static void
Ins_ROUND( TT_ExecContext exc,
FT_Long* args )
{
- args[0] = exc->func_round(
- exc,
- args[0],
- exc->tt_metrics.compensations[exc->opcode - 0x68] );
+ args[0] = exc->func_round( exc, args[0], exc->opcode & 3 );
}
- /*************************************************************************/
- /* */
- /* NROUND[ab]: No ROUNDing of value */
- /* Opcode range: 0x6C-0x6F */
- /* Stack: f26.6 --> f26.6 */
- /* */
+ /**************************************************************************
+ *
+ * NROUND[ab]: No ROUNDing of value
+ * Opcode range: 0x6C-0x6F
+ * Stack: f26.6 --> f26.6
+ */
static void
Ins_NROUND( TT_ExecContext exc,
FT_Long* args )
{
- args[0] = Round_None(
- exc,
- args[0],
- exc->tt_metrics.compensations[exc->opcode - 0x6C] );
+ args[0] = Round_None( exc, args[0], exc->opcode & 3 );
}
- /*************************************************************************/
- /* */
- /* MAX[]: MAXimum */
- /* Opcode range: 0x8B */
- /* Stack: int32? int32? --> int32 */
- /* */
+ /**************************************************************************
+ *
+ * MAX[]: MAXimum
+ * Opcode range: 0x8B
+ * Stack: int32? int32? --> int32
+ */
static void
Ins_MAX( FT_Long* args )
{
@@ -3174,12 +3175,12 @@
}
- /*************************************************************************/
- /* */
- /* MIN[]: MINimum */
- /* Opcode range: 0x8C */
- /* Stack: int32? int32? --> int32 */
- /* */
+ /**************************************************************************
+ *
+ * MIN[]: MINimum
+ * Opcode range: 0x8C
+ * Stack: int32? int32? --> int32
+ */
static void
Ins_MIN( FT_Long* args )
{
@@ -3188,12 +3189,12 @@
}
- /*************************************************************************/
- /* */
- /* MINDEX[]: Move INDEXed element */
- /* Opcode range: 0x26 */
- /* Stack: int32? --> StkElt */
- /* */
+ /**************************************************************************
+ *
+ * MINDEX[]: Move INDEXed element
+ * Opcode range: 0x26
+ * Stack: int32? --> StkElt
+ */
static void
Ins_MINDEX( TT_ExecContext exc,
FT_Long* args )
@@ -3221,12 +3222,12 @@
}
- /*************************************************************************/
- /* */
- /* CINDEX[]: Copy INDEXed element */
- /* Opcode range: 0x25 */
- /* Stack: int32 --> StkElt */
- /* */
+ /**************************************************************************
+ *
+ * CINDEX[]: Copy INDEXed element
+ * Opcode range: 0x25
+ * Stack: int32 --> StkElt
+ */
static void
Ins_CINDEX( TT_ExecContext exc,
FT_Long* args )
@@ -3247,12 +3248,12 @@
}
- /*************************************************************************/
- /* */
- /* ROLL[]: ROLL top three elements */
- /* Opcode range: 0x8A */
- /* Stack: 3 * StkElt --> 3 * StkElt */
- /* */
+ /**************************************************************************
+ *
+ * ROLL[]: ROLL top three elements
+ * Opcode range: 0x8A
+ * Stack: 3 * StkElt --> 3 * StkElt
+ */
static void
Ins_ROLL( FT_Long* args )
{
@@ -3269,19 +3270,19 @@
}
- /*************************************************************************/
- /* */
- /* MANAGING THE FLOW OF CONTROL */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * MANAGING THE FLOW OF CONTROL
+ *
+ */
- /*************************************************************************/
- /* */
- /* SLOOP[]: Set LOOP variable */
- /* Opcode range: 0x17 */
- /* Stack: int32? --> */
- /* */
+ /**************************************************************************
+ *
+ * SLOOP[]: Set LOOP variable
+ * Opcode range: 0x17
+ * Stack: int32? -->
+ */
static void
Ins_SLOOP( TT_ExecContext exc,
FT_Long* args )
@@ -3323,12 +3324,12 @@
}
- /*************************************************************************/
- /* */
- /* IF[]: IF test */
- /* Opcode range: 0x58 */
- /* Stack: StkElt --> */
- /* */
+ /**************************************************************************
+ *
+ * IF[]: IF test
+ * Opcode range: 0x58
+ * Stack: StkElt -->
+ */
static void
Ins_IF( TT_ExecContext exc,
FT_Long* args )
@@ -3367,12 +3368,12 @@
}
- /*************************************************************************/
- /* */
- /* ELSE[]: ELSE */
- /* Opcode range: 0x1B */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * ELSE[]: ELSE
+ * Opcode range: 0x1B
+ * Stack: -->
+ */
static void
Ins_ELSE( TT_ExecContext exc )
{
@@ -3400,12 +3401,12 @@
}
- /*************************************************************************/
- /* */
- /* EIF[]: End IF */
- /* Opcode range: 0x59 */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * EIF[]: End IF
+ * Opcode range: 0x59
+ * Stack: -->
+ */
static void
Ins_EIF( void )
{
@@ -3413,12 +3414,12 @@
}
- /*************************************************************************/
- /* */
- /* JMPR[]: JuMP Relative */
- /* Opcode range: 0x1C */
- /* Stack: int32 --> */
- /* */
+ /**************************************************************************
+ *
+ * JMPR[]: JuMP Relative
+ * Opcode range: 0x1C
+ * Stack: int32 -->
+ */
static void
Ins_JMPR( TT_ExecContext exc,
FT_Long* args )
@@ -3429,7 +3430,7 @@
return;
}
- exc->IP += args[0];
+ exc->IP = ADD_LONG( exc->IP, args[0] );
if ( exc->IP < 0 ||
( exc->callTop > 0 &&
exc->IP > exc->callStack[exc->callTop - 1].Def->end ) )
@@ -3448,12 +3449,12 @@
}
- /*************************************************************************/
- /* */
- /* JROT[]: Jump Relative On True */
- /* Opcode range: 0x78 */
- /* Stack: StkElt int32 --> */
- /* */
+ /**************************************************************************
+ *
+ * JROT[]: Jump Relative On True
+ * Opcode range: 0x78
+ * Stack: StkElt int32 -->
+ */
static void
Ins_JROT( TT_ExecContext exc,
FT_Long* args )
@@ -3463,12 +3464,12 @@
}
- /*************************************************************************/
- /* */
- /* JROF[]: Jump Relative On False */
- /* Opcode range: 0x79 */
- /* Stack: StkElt int32 --> */
- /* */
+ /**************************************************************************
+ *
+ * JROF[]: Jump Relative On False
+ * Opcode range: 0x79
+ * Stack: StkElt int32 -->
+ */
static void
Ins_JROF( TT_ExecContext exc,
FT_Long* args )
@@ -3478,19 +3479,19 @@
}
- /*************************************************************************/
- /* */
- /* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * DEFINING AND USING FUNCTIONS AND INSTRUCTIONS
+ *
+ */
- /*************************************************************************/
- /* */
- /* FDEF[]: Function DEFinition */
- /* Opcode range: 0x2C */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * FDEF[]: Function DEFinition
+ * Opcode range: 0x2C
+ * Stack: uint32 -->
+ */
static void
Ins_FDEF( TT_ExecContext exc,
FT_Long* args )
@@ -3499,109 +3500,9 @@
TT_DefRecord* rec;
TT_DefRecord* limit;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* arguments to opcodes are skipped by `SKIP_Code' */
- FT_Byte opcode_pattern[9][12] = {
- /* #0 inline delta function 1 */
- {
- 0x4B, /* PPEM */
- 0x53, /* GTEQ */
- 0x23, /* SWAP */
- 0x4B, /* PPEM */
- 0x51, /* LTEQ */
- 0x5A, /* AND */
- 0x58, /* IF */
- 0x38, /* SHPIX */
- 0x1B, /* ELSE */
- 0x21, /* POP */
- 0x21, /* POP */
- 0x59 /* EIF */
- },
- /* #1 inline delta function 2 */
- {
- 0x4B, /* PPEM */
- 0x54, /* EQ */
- 0x58, /* IF */
- 0x38, /* SHPIX */
- 0x1B, /* ELSE */
- 0x21, /* POP */
- 0x21, /* POP */
- 0x59 /* EIF */
- },
- /* #2 diagonal stroke function */
- {
- 0x20, /* DUP */
- 0x20, /* DUP */
- 0xB0, /* PUSHB_1 */
- /* 1 */
- 0x60, /* ADD */
- 0x46, /* GC_cur */
- 0xB0, /* PUSHB_1 */
- /* 64 */
- 0x23, /* SWAP */
- 0x42 /* WS */
- },
- /* #3 VacuFormRound function */
- {
- 0x45, /* RCVT */
- 0x23, /* SWAP */
- 0x46, /* GC_cur */
- 0x60, /* ADD */
- 0x20, /* DUP */
- 0xB0 /* PUSHB_1 */
- /* 38 */
- },
- /* #4 TTFautohint bytecode (old) */
- {
- 0x20, /* DUP */
- 0x64, /* ABS */
- 0xB0, /* PUSHB_1 */
- /* 32 */
- 0x60, /* ADD */
- 0x66, /* FLOOR */
- 0x23, /* SWAP */
- 0xB0 /* PUSHB_1 */
- },
- /* #5 spacing function 1 */
- {
- 0x01, /* SVTCA_x */
- 0xB0, /* PUSHB_1 */
- /* 24 */
- 0x43, /* RS */
- 0x58 /* IF */
- },
- /* #6 spacing function 2 */
- {
- 0x01, /* SVTCA_x */
- 0x18, /* RTG */
- 0xB0, /* PUSHB_1 */
- /* 24 */
- 0x43, /* RS */
- 0x58 /* IF */
- },
- /* #7 TypeMan Talk DiagEndCtrl function */
- {
- 0x01, /* SVTCA_x */
- 0x20, /* DUP */
- 0xB0, /* PUSHB_1 */
- /* 3 */
- 0x25, /* CINDEX */
- },
- /* #8 TypeMan Talk Align */
- {
- 0x06, /* SPVTL */
- 0x7D, /* RDTG */
- },
- };
- FT_UShort opcode_patterns = 9;
- FT_UShort opcode_pointer[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- FT_UShort opcode_size[9] = { 12, 8, 8, 6, 7, 4, 5, 4, 2 };
- FT_UShort i;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
/* FDEF is only allowed in `prep' or `fpgm' */
- if ( exc->curRange == tt_coderange_glyph )
+ if ( exc->iniRange == tt_coderange_glyph )
{
exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
return;
@@ -3611,7 +3512,7 @@
/* We will then parse the current table. */
rec = exc->FDefs;
- limit = rec + exc->numFDefs;
+ limit = FT_OFFSET( rec, exc->numFDefs );
n = (FT_ULong)args[0];
for ( ; rec < limit; rec++ )
@@ -3643,136 +3544,15 @@
rec->opc = (FT_UInt16)n;
rec->start = exc->IP + 1;
rec->active = TRUE;
- rec->inline_delta = FALSE;
- rec->sph_fdef_flags = 0x0000;
if ( n > exc->maxFunc )
exc->maxFunc = (FT_UInt16)n;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* We don't know for sure these are typeman functions, */
- /* however they are only active when RS 22 is called */
- if ( n >= 64 && n <= 66 )
- rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_STROKES;
-#endif
-
/* Now skip the whole function definition. */
/* We don't allow nested IDEFS & FDEFs. */
while ( SkipCode( exc ) == SUCCESS )
{
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- if ( SUBPIXEL_HINTING_INFINALITY )
- {
- for ( i = 0; i < opcode_patterns; i++ )
- {
- if ( opcode_pointer[i] < opcode_size[i] &&
- exc->opcode == opcode_pattern[i][opcode_pointer[i]] )
- {
- opcode_pointer[i] += 1;
-
- if ( opcode_pointer[i] == opcode_size[i] )
- {
- FT_TRACE6(( "sph: Function %d, opcode ptrn: %d, %s %s\n",
- i, n,
- exc->face->root.family_name,
- exc->face->root.style_name ));
-
- switch ( i )
- {
- case 0:
- rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_1;
- exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_1;
- break;
-
- case 1:
- rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_2;
- exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_2;
- break;
-
- case 2:
- switch ( n )
- {
- /* needs to be implemented still */
- case 58:
- rec->sph_fdef_flags |= SPH_FDEF_DIAGONAL_STROKE;
- exc->face->sph_found_func_flags |= SPH_FDEF_DIAGONAL_STROKE;
- }
- break;
-
- case 3:
- switch ( n )
- {
- case 0:
- rec->sph_fdef_flags |= SPH_FDEF_VACUFORM_ROUND_1;
- exc->face->sph_found_func_flags |= SPH_FDEF_VACUFORM_ROUND_1;
- }
- break;
-
- case 4:
- /* probably not necessary to detect anymore */
- rec->sph_fdef_flags |= SPH_FDEF_TTFAUTOHINT_1;
- exc->face->sph_found_func_flags |= SPH_FDEF_TTFAUTOHINT_1;
- break;
-
- case 5:
- switch ( n )
- {
- case 0:
- case 1:
- case 2:
- case 4:
- case 7:
- case 8:
- rec->sph_fdef_flags |= SPH_FDEF_SPACING_1;
- exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_1;
- }
- break;
-
- case 6:
- switch ( n )
- {
- case 0:
- case 1:
- case 2:
- case 4:
- case 7:
- case 8:
- rec->sph_fdef_flags |= SPH_FDEF_SPACING_2;
- exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_2;
- }
- break;
-
- case 7:
- rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
- exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
- break;
-
- case 8:
-#if 0
- rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
- exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
-#endif
- break;
- }
- opcode_pointer[i] = 0;
- }
- }
-
- else
- opcode_pointer[i] = 0;
- }
-
- /* Set sph_compatibility_mode only when deltas are detected */
- exc->face->sph_compatibility_mode =
- ( ( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) |
- ( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) );
- }
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
switch ( exc->opcode )
{
case 0x89: /* IDEF */
@@ -3788,22 +3568,18 @@
}
- /*************************************************************************/
- /* */
- /* ENDF[]: END Function definition */
- /* Opcode range: 0x2D */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * ENDF[]: END Function definition
+ * Opcode range: 0x2D
+ * Stack: -->
+ */
static void
Ins_ENDF( TT_ExecContext exc )
{
TT_CallRec* pRec;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- exc->sph_in_func_flags = 0x0000;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
if ( exc->callTop <= 0 ) /* We encountered an ENDF without a call */
{
exc->error = FT_THROW( ENDF_In_Exec_Stream );
@@ -3837,12 +3613,12 @@
}
- /*************************************************************************/
- /* */
- /* CALL[]: CALL function */
- /* Opcode range: 0x2B */
- /* Stack: uint32? --> */
- /* */
+ /**************************************************************************
+ *
+ * CALL[]: CALL function
+ * Opcode range: 0x2B
+ * Stack: uint32? -->
+ */
static void
Ins_CALL( TT_ExecContext exc,
FT_Long* args )
@@ -3858,6 +3634,9 @@
if ( BOUNDSL( F, exc->maxFunc + 1 ) )
goto Fail;
+ if ( !exc->FDefs )
+ goto Fail;
+
/* Except for some old Apple fonts, all functions in a TrueType */
/* font are defined in increasing order, starting from 0. This */
/* means that we normally have */
@@ -3888,17 +3667,6 @@
if ( !def->active )
goto Fail;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- ( ( exc->iup_called &&
- ( exc->sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) ) ||
- ( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) ) )
- goto Fail;
- else
- exc->sph_in_func_flags = def->sph_fdef_flags;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
/* check the call stack */
if ( exc->callTop >= exc->callSize )
{
@@ -3926,12 +3694,12 @@
}
- /*************************************************************************/
- /* */
- /* LOOPCALL[]: LOOP and CALL function */
- /* Opcode range: 0x2A */
- /* Stack: uint32? Eint16? --> */
- /* */
+ /**************************************************************************
+ *
+ * LOOPCALL[]: LOOP and CALL function
+ * Opcode range: 0x2A
+ * Stack: uint32? Eint16? -->
+ */
static void
Ins_LOOPCALL( TT_ExecContext exc,
FT_Long* args )
@@ -3955,7 +3723,7 @@
/* */
/* If this isn't true, we need to look up the function table. */
- def = exc->FDefs + F;
+ def = FT_OFFSET( exc->FDefs, F );
if ( exc->maxFunc + 1 != exc->numFDefs || def->opc != F )
{
/* look up the FDefs table */
@@ -3963,7 +3731,7 @@
def = exc->FDefs;
- limit = def + exc->numFDefs;
+ limit = FT_OFFSET( def, exc->numFDefs );
while ( def < limit && def->opc != F )
def++;
@@ -3976,15 +3744,6 @@
if ( !def->active )
goto Fail;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- ( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) )
- goto Fail;
- else
- exc->sph_in_func_flags = def->sph_fdef_flags;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
/* check stack */
if ( exc->callTop >= exc->callSize )
{
@@ -4019,12 +3778,12 @@
}
- /*************************************************************************/
- /* */
- /* IDEF[]: Instruction DEFinition */
- /* Opcode range: 0x89 */
- /* Stack: Eint8 --> */
- /* */
+ /**************************************************************************
+ *
+ * IDEF[]: Instruction DEFinition
+ * Opcode range: 0x89
+ * Stack: Eint8 -->
+ */
static void
Ins_IDEF( TT_ExecContext exc,
FT_Long* args )
@@ -4034,7 +3793,7 @@
/* we enable IDEF only in `prep' or `fpgm' */
- if ( exc->curRange == tt_coderange_glyph )
+ if ( exc->iniRange == tt_coderange_glyph )
{
exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
return;
@@ -4043,7 +3802,7 @@
/* First of all, look for the same function in our table */
def = exc->IDefs;
- limit = def + exc->numIDefs;
+ limit = FT_OFFSET( def, exc->numIDefs );
for ( ; def < limit; def++ )
if ( def->opc == (FT_ULong)args[0] )
@@ -4094,19 +3853,19 @@
}
- /*************************************************************************/
- /* */
- /* PUSHING DATA ONTO THE INTERPRETER STACK */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * PUSHING DATA ONTO THE INTERPRETER STACK
+ *
+ */
- /*************************************************************************/
- /* */
- /* NPUSHB[]: PUSH N Bytes */
- /* Opcode range: 0x40 */
- /* Stack: --> uint32... */
- /* */
+ /**************************************************************************
+ *
+ * NPUSHB[]: PUSH N Bytes
+ * Opcode range: 0x40
+ * Stack: --> uint32...
+ */
static void
Ins_NPUSHB( TT_ExecContext exc,
FT_Long* args )
@@ -4129,12 +3888,12 @@
}
- /*************************************************************************/
- /* */
- /* NPUSHW[]: PUSH N Words */
- /* Opcode range: 0x41 */
- /* Stack: --> int32... */
- /* */
+ /**************************************************************************
+ *
+ * NPUSHW[]: PUSH N Words
+ * Opcode range: 0x41
+ * Stack: --> int32...
+ */
static void
Ins_NPUSHW( TT_ExecContext exc,
FT_Long* args )
@@ -4160,12 +3919,12 @@
}
- /*************************************************************************/
- /* */
- /* PUSHB[abc]: PUSH Bytes */
- /* Opcode range: 0xB0-0xB7 */
- /* Stack: --> uint32... */
- /* */
+ /**************************************************************************
+ *
+ * PUSHB[abc]: PUSH Bytes
+ * Opcode range: 0xB0-0xB7
+ * Stack: --> uint32...
+ */
static void
Ins_PUSHB( TT_ExecContext exc,
FT_Long* args )
@@ -4186,12 +3945,12 @@
}
- /*************************************************************************/
- /* */
- /* PUSHW[abc]: PUSH Words */
- /* Opcode range: 0xB8-0xBF */
- /* Stack: --> int32... */
- /* */
+ /**************************************************************************
+ *
+ * PUSHW[abc]: PUSH Words
+ * Opcode range: 0xB8-0xBF
+ * Stack: --> int32...
+ */
static void
Ins_PUSHW( TT_ExecContext exc,
FT_Long* args )
@@ -4216,11 +3975,11 @@
}
- /*************************************************************************/
- /* */
- /* MANAGING THE GRAPHICS STATE */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * MANAGING THE GRAPHICS STATE
+ *
+ */
static FT_Bool
@@ -4263,7 +4022,7 @@
if ( ( opcode & 1 ) != 0 )
{
- C = B; /* counter clockwise rotation */
+ C = B; /* counter-clockwise rotation */
B = A;
A = NEG_LONG( C );
}
@@ -4274,20 +4033,20 @@
}
- /*************************************************************************/
- /* */
- /* SVTCA[a]: Set (F and P) Vectors to Coordinate Axis */
- /* Opcode range: 0x00-0x01 */
- /* Stack: --> */
- /* */
- /* SPvTCA[a]: Set PVector to Coordinate Axis */
- /* Opcode range: 0x02-0x03 */
- /* Stack: --> */
- /* */
- /* SFvTCA[a]: Set FVector to Coordinate Axis */
- /* Opcode range: 0x04-0x05 */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * SVTCA[a]: Set (F and P) Vectors to Coordinate Axis
+ * Opcode range: 0x00-0x01
+ * Stack: -->
+ *
+ * SPvTCA[a]: Set PVector to Coordinate Axis
+ * Opcode range: 0x02-0x03
+ * Stack: -->
+ *
+ * SFvTCA[a]: Set FVector to Coordinate Axis
+ * Opcode range: 0x04-0x05
+ * Stack: -->
+ */
static void
Ins_SxyTCA( TT_ExecContext exc )
{
@@ -4318,12 +4077,12 @@
}
- /*************************************************************************/
- /* */
- /* SPvTL[a]: Set PVector To Line */
- /* Opcode range: 0x06-0x07 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SPvTL[a]: Set PVector To Line
+ * Opcode range: 0x06-0x07
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_SPVTL( TT_ExecContext exc,
FT_Long* args )
@@ -4339,12 +4098,12 @@
}
- /*************************************************************************/
- /* */
- /* SFvTL[a]: Set FVector To Line */
- /* Opcode range: 0x08-0x09 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SFvTL[a]: Set FVector To Line
+ * Opcode range: 0x08-0x09
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_SFVTL( TT_ExecContext exc,
FT_Long* args )
@@ -4359,12 +4118,12 @@
}
- /*************************************************************************/
- /* */
- /* SFvTPv[]: Set FVector To PVector */
- /* Opcode range: 0x0E */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * SFvTPv[]: Set FVector To PVector
+ * Opcode range: 0x0E
+ * Stack: -->
+ */
static void
Ins_SFVTPV( TT_ExecContext exc )
{
@@ -4373,12 +4132,12 @@
}
- /*************************************************************************/
- /* */
- /* SPvFS[]: Set PVector From Stack */
- /* Opcode range: 0x0A */
- /* Stack: f2.14 f2.14 --> */
- /* */
+ /**************************************************************************
+ *
+ * SPvFS[]: Set PVector From Stack
+ * Opcode range: 0x0A
+ * Stack: f2.14 f2.14 -->
+ */
static void
Ins_SPVFS( TT_ExecContext exc,
FT_Long* args )
@@ -4400,12 +4159,12 @@
}
- /*************************************************************************/
- /* */
- /* SFvFS[]: Set FVector From Stack */
- /* Opcode range: 0x0B */
- /* Stack: f2.14 f2.14 --> */
- /* */
+ /**************************************************************************
+ *
+ * SFvFS[]: Set FVector From Stack
+ * Opcode range: 0x0B
+ * Stack: f2.14 f2.14 -->
+ */
static void
Ins_SFVFS( TT_ExecContext exc,
FT_Long* args )
@@ -4425,12 +4184,12 @@
}
- /*************************************************************************/
- /* */
- /* GPv[]: Get Projection Vector */
- /* Opcode range: 0x0C */
- /* Stack: ef2.14 --> ef2.14 */
- /* */
+ /**************************************************************************
+ *
+ * GPv[]: Get Projection Vector
+ * Opcode range: 0x0C
+ * Stack: ef2.14 --> ef2.14
+ */
static void
Ins_GPV( TT_ExecContext exc,
FT_Long* args )
@@ -4440,12 +4199,12 @@
}
- /*************************************************************************/
- /* */
- /* GFv[]: Get Freedom Vector */
- /* Opcode range: 0x0D */
- /* Stack: ef2.14 --> ef2.14 */
- /* */
+ /**************************************************************************
+ *
+ * GFv[]: Get Freedom Vector
+ * Opcode range: 0x0D
+ * Stack: ef2.14 --> ef2.14
+ */
static void
Ins_GFV( TT_ExecContext exc,
FT_Long* args )
@@ -4455,12 +4214,12 @@
}
- /*************************************************************************/
- /* */
- /* SRP0[]: Set Reference Point 0 */
- /* Opcode range: 0x10 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SRP0[]: Set Reference Point 0
+ * Opcode range: 0x10
+ * Stack: uint32 -->
+ */
static void
Ins_SRP0( TT_ExecContext exc,
FT_Long* args )
@@ -4469,12 +4228,12 @@
}
- /*************************************************************************/
- /* */
- /* SRP1[]: Set Reference Point 1 */
- /* Opcode range: 0x11 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SRP1[]: Set Reference Point 1
+ * Opcode range: 0x11
+ * Stack: uint32 -->
+ */
static void
Ins_SRP1( TT_ExecContext exc,
FT_Long* args )
@@ -4483,12 +4242,12 @@
}
- /*************************************************************************/
- /* */
- /* SRP2[]: Set Reference Point 2 */
- /* Opcode range: 0x12 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SRP2[]: Set Reference Point 2
+ * Opcode range: 0x12
+ * Stack: uint32 -->
+ */
static void
Ins_SRP2( TT_ExecContext exc,
FT_Long* args )
@@ -4497,12 +4256,12 @@
}
- /*************************************************************************/
- /* */
- /* SMD[]: Set Minimum Distance */
- /* Opcode range: 0x1A */
- /* Stack: f26.6 --> */
- /* */
+ /**************************************************************************
+ *
+ * SMD[]: Set Minimum Distance
+ * Opcode range: 0x1A
+ * Stack: f26.6 -->
+ */
static void
Ins_SMD( TT_ExecContext exc,
FT_Long* args )
@@ -4511,12 +4270,12 @@
}
- /*************************************************************************/
- /* */
- /* SCVTCI[]: Set Control Value Table Cut In */
- /* Opcode range: 0x1D */
- /* Stack: f26.6 --> */
- /* */
+ /**************************************************************************
+ *
+ * SCVTCI[]: Set Control Value Table Cut In
+ * Opcode range: 0x1D
+ * Stack: f26.6 -->
+ */
static void
Ins_SCVTCI( TT_ExecContext exc,
FT_Long* args )
@@ -4525,12 +4284,12 @@
}
- /*************************************************************************/
- /* */
- /* SSWCI[]: Set Single Width Cut In */
- /* Opcode range: 0x1E */
- /* Stack: f26.6 --> */
- /* */
+ /**************************************************************************
+ *
+ * SSWCI[]: Set Single Width Cut In
+ * Opcode range: 0x1E
+ * Stack: f26.6 -->
+ */
static void
Ins_SSWCI( TT_ExecContext exc,
FT_Long* args )
@@ -4539,12 +4298,12 @@
}
- /*************************************************************************/
- /* */
- /* SSW[]: Set Single Width */
- /* Opcode range: 0x1F */
- /* Stack: int32? --> */
- /* */
+ /**************************************************************************
+ *
+ * SSW[]: Set Single Width
+ * Opcode range: 0x1F
+ * Stack: int32? -->
+ */
static void
Ins_SSW( TT_ExecContext exc,
FT_Long* args )
@@ -4554,12 +4313,12 @@
}
- /*************************************************************************/
- /* */
- /* FLIPON[]: Set auto-FLIP to ON */
- /* Opcode range: 0x4D */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * FLIPON[]: Set auto-FLIP to ON
+ * Opcode range: 0x4D
+ * Stack: -->
+ */
static void
Ins_FLIPON( TT_ExecContext exc )
{
@@ -4567,12 +4326,12 @@
}
- /*************************************************************************/
- /* */
- /* FLIPOFF[]: Set auto-FLIP to OFF */
- /* Opcode range: 0x4E */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * FLIPOFF[]: Set auto-FLIP to OFF
+ * Opcode range: 0x4E
+ * Stack: -->
+ */
static void
Ins_FLIPOFF( TT_ExecContext exc )
{
@@ -4580,12 +4339,12 @@
}
- /*************************************************************************/
- /* */
- /* SANGW[]: Set ANGle Weight */
- /* Opcode range: 0x7E */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SANGW[]: Set ANGle Weight
+ * Opcode range: 0x7E
+ * Stack: uint32 -->
+ */
static void
Ins_SANGW( void )
{
@@ -4593,12 +4352,12 @@
}
- /*************************************************************************/
- /* */
- /* SDB[]: Set Delta Base */
- /* Opcode range: 0x5E */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SDB[]: Set Delta Base
+ * Opcode range: 0x5E
+ * Stack: uint32 -->
+ */
static void
Ins_SDB( TT_ExecContext exc,
FT_Long* args )
@@ -4607,12 +4366,12 @@
}
- /*************************************************************************/
- /* */
- /* SDS[]: Set Delta Shift */
- /* Opcode range: 0x5F */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SDS[]: Set Delta Shift
+ * Opcode range: 0x5F
+ * Stack: uint32 -->
+ */
static void
Ins_SDS( TT_ExecContext exc,
FT_Long* args )
@@ -4624,12 +4383,12 @@
}
- /*************************************************************************/
- /* */
- /* RTHG[]: Round To Half Grid */
- /* Opcode range: 0x19 */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * RTHG[]: Round To Half Grid
+ * Opcode range: 0x19
+ * Stack: -->
+ */
static void
Ins_RTHG( TT_ExecContext exc )
{
@@ -4638,12 +4397,12 @@
}
- /*************************************************************************/
- /* */
- /* RTG[]: Round To Grid */
- /* Opcode range: 0x18 */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * RTG[]: Round To Grid
+ * Opcode range: 0x18
+ * Stack: -->
+ */
static void
Ins_RTG( TT_ExecContext exc )
{
@@ -4652,11 +4411,11 @@
}
- /*************************************************************************/
- /* RTDG[]: Round To Double Grid */
- /* Opcode range: 0x3D */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ * RTDG[]: Round To Double Grid
+ * Opcode range: 0x3D
+ * Stack: -->
+ */
static void
Ins_RTDG( TT_ExecContext exc )
{
@@ -4665,11 +4424,11 @@
}
- /*************************************************************************/
- /* RUTG[]: Round Up To Grid */
- /* Opcode range: 0x7C */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ * RUTG[]: Round Up To Grid
+ * Opcode range: 0x7C
+ * Stack: -->
+ */
static void
Ins_RUTG( TT_ExecContext exc )
{
@@ -4678,12 +4437,12 @@
}
- /*************************************************************************/
- /* */
- /* RDTG[]: Round Down To Grid */
- /* Opcode range: 0x7D */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * RDTG[]: Round Down To Grid
+ * Opcode range: 0x7D
+ * Stack: -->
+ */
static void
Ins_RDTG( TT_ExecContext exc )
{
@@ -4692,12 +4451,12 @@
}
- /*************************************************************************/
- /* */
- /* ROFF[]: Round OFF */
- /* Opcode range: 0x7A */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * ROFF[]: Round OFF
+ * Opcode range: 0x7A
+ * Stack: -->
+ */
static void
Ins_ROFF( TT_ExecContext exc )
{
@@ -4706,12 +4465,12 @@
}
- /*************************************************************************/
- /* */
- /* SROUND[]: Super ROUND */
- /* Opcode range: 0x76 */
- /* Stack: Eint8 --> */
- /* */
+ /**************************************************************************
+ *
+ * SROUND[]: Super ROUND
+ * Opcode range: 0x76
+ * Stack: Eint8 -->
+ */
static void
Ins_SROUND( TT_ExecContext exc,
FT_Long* args )
@@ -4723,12 +4482,12 @@
}
- /*************************************************************************/
- /* */
- /* S45ROUND[]: Super ROUND 45 degrees */
- /* Opcode range: 0x77 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * S45ROUND[]: Super ROUND 45 degrees
+ * Opcode range: 0x77
+ * Stack: uint32 -->
+ */
static void
Ins_S45ROUND( TT_ExecContext exc,
FT_Long* args )
@@ -4740,15 +4499,15 @@
}
- /*************************************************************************/
- /* */
- /* GC[a]: Get Coordinate projected onto */
- /* Opcode range: 0x46-0x47 */
- /* Stack: uint32 --> f26.6 */
- /* */
- /* XXX: UNDOCUMENTED: Measures from the original glyph must be taken */
- /* along the dual projection vector! */
- /* */
+ /**************************************************************************
+ *
+ * GC[a]: Get Coordinate projected onto
+ * Opcode range: 0x46-0x47
+ * Stack: uint32 --> f26.6
+ *
+ * XXX: UNDOCUMENTED: Measures from the original glyph must be taken
+ * along the dual projection vector!
+ */
static void
Ins_GC( TT_ExecContext exc,
FT_Long* args )
@@ -4777,16 +4536,16 @@
}
- /*************************************************************************/
- /* */
- /* SCFS[]: Set Coordinate From Stack */
- /* Opcode range: 0x48 */
- /* Stack: f26.6 uint32 --> */
- /* */
- /* Formula: */
- /* */
- /* OA := OA + ( value - OA.p )/( f.p ) * f */
- /* */
+ /**************************************************************************
+ *
+ * SCFS[]: Set Coordinate From Stack
+ * Opcode range: 0x48
+ * Stack: f26.6 uint32 -->
+ *
+ * Formula:
+ *
+ * OA := OA + ( value - OA.p )/( f.p ) * f
+ */
static void
Ins_SCFS( TT_ExecContext exc,
FT_Long* args )
@@ -4815,21 +4574,21 @@
}
- /*************************************************************************/
- /* */
- /* MD[a]: Measure Distance */
- /* Opcode range: 0x49-0x4A */
- /* Stack: uint32 uint32 --> f26.6 */
- /* */
- /* XXX: UNDOCUMENTED: Measure taken in the original glyph must be along */
- /* the dual projection vector. */
- /* */
- /* XXX: UNDOCUMENTED: Flag attributes are inverted! */
- /* 0 => measure distance in original outline */
- /* 1 => measure distance in grid-fitted outline */
- /* */
- /* XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! */
- /* */
+ /**************************************************************************
+ *
+ * MD[a]: Measure Distance
+ * Opcode range: 0x49-0x4A
+ * Stack: uint32 uint32 --> f26.6
+ *
+ * XXX: UNDOCUMENTED: Measure taken in the original glyph must be along
+ * the dual projection vector.
+ *
+ * XXX: UNDOCUMENTED: Flag attributes are inverted!
+ * 0 => measure distance in original outline
+ * 1 => measure distance in grid-fitted outline
+ *
+ * XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1!
+ */
static void
Ins_MD( TT_ExecContext exc,
FT_Long* args )
@@ -4890,24 +4649,16 @@
}
}
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- FT_ABS( D ) == 64 )
- D += 1;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
args[0] = D;
}
- /*************************************************************************/
- /* */
- /* SDPvTL[a]: Set Dual PVector to Line */
- /* Opcode range: 0x86-0x87 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SDPvTL[a]: Set Dual PVector to Line
+ * Opcode range: 0x86-0x87
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_SDPVTL( TT_ExecContext exc,
FT_Long* args )
@@ -4951,7 +4702,7 @@
if ( ( opcode & 1 ) != 0 )
{
- C = B; /* counter clockwise rotation */
+ C = B; /* counter-clockwise rotation */
B = A;
A = NEG_LONG( C );
}
@@ -4975,7 +4726,7 @@
if ( ( opcode & 1 ) != 0 )
{
- C = B; /* counter clockwise rotation */
+ C = B; /* counter-clockwise rotation */
B = A;
A = NEG_LONG( C );
}
@@ -4985,12 +4736,12 @@
}
- /*************************************************************************/
- /* */
- /* SZP0[]: Set Zone Pointer 0 */
- /* Opcode range: 0x13 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SZP0[]: Set Zone Pointer 0
+ * Opcode range: 0x13
+ * Stack: uint32 -->
+ */
static void
Ins_SZP0( TT_ExecContext exc,
FT_Long* args )
@@ -5015,12 +4766,12 @@
}
- /*************************************************************************/
- /* */
- /* SZP1[]: Set Zone Pointer 1 */
- /* Opcode range: 0x14 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SZP1[]: Set Zone Pointer 1
+ * Opcode range: 0x14
+ * Stack: uint32 -->
+ */
static void
Ins_SZP1( TT_ExecContext exc,
FT_Long* args )
@@ -5045,12 +4796,12 @@
}
- /*************************************************************************/
- /* */
- /* SZP2[]: Set Zone Pointer 2 */
- /* Opcode range: 0x15 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SZP2[]: Set Zone Pointer 2
+ * Opcode range: 0x15
+ * Stack: uint32 -->
+ */
static void
Ins_SZP2( TT_ExecContext exc,
FT_Long* args )
@@ -5075,12 +4826,12 @@
}
- /*************************************************************************/
- /* */
- /* SZPS[]: Set Zone PointerS */
- /* Opcode range: 0x16 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SZPS[]: Set Zone PointerS
+ * Opcode range: 0x16
+ * Stack: uint32 -->
+ */
static void
Ins_SZPS( TT_ExecContext exc,
FT_Long* args )
@@ -5110,12 +4861,12 @@
}
- /*************************************************************************/
- /* */
- /* INSTCTRL[]: INSTruction ConTRoL */
- /* Opcode range: 0x8E */
- /* Stack: int32 int32 --> */
- /* */
+ /**************************************************************************
+ *
+ * INSTCTRL[]: INSTruction ConTRoL
+ * Opcode range: 0x8E
+ * Stack: int32 int32 -->
+ */
static void
Ins_INSTCTRL( TT_ExecContext exc,
FT_Long* args )
@@ -5149,18 +4900,16 @@
}
}
- exc->GS.instruct_control &= ~(FT_Byte)Kf;
- exc->GS.instruct_control |= (FT_Byte)L;
-
- if ( K == 3 )
+ /* INSTCTRL should only be used in the CVT program */
+ if ( exc->iniRange == tt_coderange_cvt )
{
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* INSTCTRL modifying flag 3 also has an effect */
- /* outside of the CVT program */
- if ( SUBPIXEL_HINTING_INFINALITY )
- exc->ignore_x_mode = FT_BOOL( L == 4 );
-#endif
+ exc->GS.instruct_control &= ~(FT_Byte)Kf;
+ exc->GS.instruct_control |= (FT_Byte)L;
+ }
+ /* except to change the subpixel flags temporarily */
+ else if ( exc->iniRange == tt_coderange_glyph && K == 3 )
+ {
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
/* Native ClearType fonts sign a waiver that turns off all backward */
/* compatibility hacks and lets them program points to the grid like */
@@ -5169,15 +4918,17 @@
exc->backward_compatibility = !FT_BOOL( L == 4 );
#endif
}
+ else if ( exc->pedantic_hinting )
+ exc->error = FT_THROW( Invalid_Reference );
}
- /*************************************************************************/
- /* */
- /* SCANCTRL[]: SCAN ConTRoL */
- /* Opcode range: 0x85 */
- /* Stack: uint32? --> */
- /* */
+ /**************************************************************************
+ *
+ * SCANCTRL[]: SCAN ConTRoL
+ * Opcode range: 0x85
+ * Stack: uint32? -->
+ */
static void
Ins_SCANCTRL( TT_ExecContext exc,
FT_Long* args )
@@ -5219,12 +4970,12 @@
}
- /*************************************************************************/
- /* */
- /* SCANTYPE[]: SCAN TYPE */
- /* Opcode range: 0x8D */
- /* Stack: uint16 --> */
- /* */
+ /**************************************************************************
+ *
+ * SCANTYPE[]: SCAN TYPE
+ * Opcode range: 0x8D
+ * Stack: uint16 -->
+ */
static void
Ins_SCANTYPE( TT_ExecContext exc,
FT_Long* args )
@@ -5234,19 +4985,19 @@
}
- /*************************************************************************/
- /* */
- /* MANAGING OUTLINES */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * MANAGING OUTLINES
+ *
+ */
- /*************************************************************************/
- /* */
- /* FLIPPT[]: FLIP PoinT */
- /* Opcode range: 0x80 */
- /* Stack: uint32... --> */
- /* */
+ /**************************************************************************
+ *
+ * FLIPPT[]: FLIP PoinT
+ * Opcode range: 0x80
+ * Stack: uint32... -->
+ */
static void
Ins_FLIPPT( TT_ExecContext exc )
{
@@ -5295,12 +5046,12 @@
}
- /*************************************************************************/
- /* */
- /* FLIPRGON[]: FLIP RanGe ON */
- /* Opcode range: 0x81 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * FLIPRGON[]: FLIP RanGe ON
+ * Opcode range: 0x81
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_FLIPRGON( TT_ExecContext exc,
FT_Long* args )
@@ -5333,12 +5084,12 @@
}
- /*************************************************************************/
- /* */
- /* FLIPRGOFF: FLIP RanGe OFF */
- /* Opcode range: 0x82 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * FLIPRGOFF: FLIP RanGe OFF
+ * Opcode range: 0x82
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_FLIPRGOFF( TT_ExecContext exc,
FT_Long* args )
@@ -5450,12 +5201,12 @@
}
- /*************************************************************************/
- /* */
- /* SHP[a]: SHift Point by the last point */
- /* Opcode range: 0x32-0x33 */
- /* Stack: uint32... --> */
- /* */
+ /**************************************************************************
+ *
+ * SHP[a]: SHift Point by the last point
+ * Opcode range: 0x32-0x33
+ * Stack: uint32... -->
+ */
static void
Ins_SHP( TT_ExecContext exc )
{
@@ -5490,12 +5241,6 @@
}
}
else
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* doesn't follow Cleartype spec but produces better result */
- if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode )
- Move_Zp2_Point( exc, point, 0, dy, TRUE );
- else
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
Move_Zp2_Point( exc, point, dx, dy, TRUE );
exc->GS.loop--;
@@ -5507,16 +5252,16 @@
}
- /*************************************************************************/
- /* */
- /* SHC[a]: SHift Contour */
- /* Opcode range: 0x34-35 */
- /* Stack: uint32 --> */
- /* */
- /* UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) */
- /* contour in the twilight zone, namely contour number */
- /* zero which includes all points of it. */
- /* */
+ /**************************************************************************
+ *
+ * SHC[a]: SHift Contour
+ * Opcode range: 0x34-35
+ * Stack: uint32 -->
+ *
+ * UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual)
+ * contour in the twilight zone, namely contour number
+ * zero which includes all points of it.
+ */
static void
Ins_SHC( TT_ExecContext exc,
FT_Long* args )
@@ -5563,12 +5308,12 @@
}
- /*************************************************************************/
- /* */
- /* SHZ[a]: SHift Zone */
- /* Opcode range: 0x36-37 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * SHZ[a]: SHift Zone
+ * Opcode range: 0x36-37
+ * Stack: uint32 -->
+ */
static void
Ins_SHZ( TT_ExecContext exc,
FT_Long* args )
@@ -5611,21 +5356,18 @@
}
- /*************************************************************************/
- /* */
- /* SHPIX[]: SHift points by a PIXel amount */
- /* Opcode range: 0x38 */
- /* Stack: f26.6 uint32... --> */
- /* */
+ /**************************************************************************
+ *
+ * SHPIX[]: SHift points by a PIXel amount
+ * Opcode range: 0x38
+ * Stack: f26.6 uint32... -->
+ */
static void
Ins_SHPIX( TT_ExecContext exc,
FT_Long* args )
{
FT_F26Dot6 dx, dy;
FT_UShort point;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- FT_Int B1, B2;
-#endif
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
FT_Bool in_twilight = FT_BOOL( exc->GS.gep0 == 0 ||
exc->GS.gep1 == 0 ||
@@ -5659,87 +5401,6 @@
}
}
else
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY )
- {
- /* If not using ignore_x_mode rendering, allow ZP2 move. */
- /* If inline deltas aren't allowed, skip ZP2 move. */
- /* If using ignore_x_mode rendering, allow ZP2 point move if: */
- /* - freedom vector is y and sph_compatibility_mode is off */
- /* - the glyph is composite and the move is in the Y direction */
- /* - the glyph is specifically set to allow SHPIX moves */
- /* - the move is on a previously Y-touched point */
-
- if ( exc->ignore_x_mode )
- {
- /* save point for later comparison */
- if ( exc->GS.freeVector.y != 0 )
- B1 = exc->zp2.cur[point].y;
- else
- B1 = exc->zp2.cur[point].x;
-
- if ( !exc->face->sph_compatibility_mode &&
- exc->GS.freeVector.y != 0 )
- {
- Move_Zp2_Point( exc, point, dx, dy, TRUE );
-
- /* save new point */
- if ( exc->GS.freeVector.y != 0 )
- {
- B2 = exc->zp2.cur[point].y;
-
- /* reverse any disallowed moves */
- if ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
- ( B1 & 63 ) != 0 &&
- ( B2 & 63 ) != 0 &&
- B1 != B2 )
- Move_Zp2_Point( exc,
- point,
- NEG_LONG( dx ),
- NEG_LONG( dy ),
- TRUE );
- }
- }
- else if ( exc->face->sph_compatibility_mode )
- {
- if ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
- {
- dx = FT_PIX_ROUND( B1 + dx ) - B1;
- dy = FT_PIX_ROUND( B1 + dy ) - B1;
- }
-
- /* skip post-iup deltas */
- if ( exc->iup_called &&
- ( ( exc->sph_in_func_flags & SPH_FDEF_INLINE_DELTA_1 ) ||
- ( exc->sph_in_func_flags & SPH_FDEF_INLINE_DELTA_2 ) ) )
- goto Skip;
-
- if ( !( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) &&
- ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
- ( exc->zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y ) ||
- ( exc->sph_tweak_flags & SPH_TWEAK_DO_SHPIX ) ) )
- Move_Zp2_Point( exc, point, 0, dy, TRUE );
-
- /* save new point */
- if ( exc->GS.freeVector.y != 0 )
- {
- B2 = exc->zp2.cur[point].y;
-
- /* reverse any disallowed moves */
- if ( ( B1 & 63 ) == 0 &&
- ( B2 & 63 ) != 0 &&
- B1 != B2 )
- Move_Zp2_Point( exc, point, 0, NEG_LONG( dy ), TRUE );
- }
- }
- else if ( exc->sph_in_func_flags & SPH_FDEF_TYPEMAN_DIAGENDCTRL )
- Move_Zp2_Point( exc, point, dx, dy, TRUE );
- }
- else
- Move_Zp2_Point( exc, point, dx, dy, TRUE );
- }
- else
-#endif
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
if ( SUBPIXEL_HINTING_MINIMAL &&
exc->backward_compatibility )
@@ -5759,9 +5420,6 @@
#endif
Move_Zp2_Point( exc, point, dx, dy, TRUE );
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- Skip:
-#endif
exc->GS.loop--;
}
@@ -5771,34 +5429,20 @@
}
- /*************************************************************************/
- /* */
- /* MSIRP[a]: Move Stack Indirect Relative Position */
- /* Opcode range: 0x3A-0x3B */
- /* Stack: f26.6 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * MSIRP[a]: Move Stack Indirect Relative Position
+ * Opcode range: 0x3A-0x3B
+ * Stack: f26.6 uint32 -->
+ */
static void
Ins_MSIRP( TT_ExecContext exc,
FT_Long* args )
{
FT_UShort point = 0;
FT_F26Dot6 distance;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- FT_F26Dot6 control_value_cutin = 0;
- FT_F26Dot6 delta;
- if ( SUBPIXEL_HINTING_INFINALITY )
- {
- control_value_cutin = exc->GS.control_value_cutin;
-
- if ( exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 &&
- !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
- control_value_cutin = 0;
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
point = (FT_UShort)args[0];
if ( BOUNDS( point, exc->zp1.n_points ) ||
@@ -5820,19 +5464,6 @@
distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 );
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- delta = SUB_LONG( distance, args[1] );
- if ( delta < 0 )
- delta = NEG_LONG( delta );
-
- /* subpixel hinting - make MSIRP respect CVT cut-in; */
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 &&
- delta >= control_value_cutin )
- distance = args[1];
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
exc->func_move( exc,
&exc->zp1,
point,
@@ -5846,12 +5477,12 @@
}
- /*************************************************************************/
- /* */
- /* MDAP[a]: Move Direct Absolute Point */
- /* Opcode range: 0x2E-0x2F */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * MDAP[a]: Move Direct Absolute Point
+ * Opcode range: 0x2E-0x2F
+ * Stack: uint32 -->
+ */
static void
Ins_MDAP( TT_ExecContext exc,
FT_Long* args )
@@ -5873,22 +5504,7 @@
if ( ( exc->opcode & 1 ) != 0 )
{
cur_dist = FAST_PROJECT( &exc->zp0.cur[point] );
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 )
- distance = SUB_LONG(
- Round_None( exc,
- cur_dist,
- exc->tt_metrics.compensations[0] ),
- cur_dist );
- else
-#endif
- distance = SUB_LONG(
- exc->func_round( exc,
- cur_dist,
- exc->tt_metrics.compensations[0] ),
- cur_dist );
+ distance = SUB_LONG( exc->func_round( exc, cur_dist, 3 ), cur_dist );
}
else
distance = 0;
@@ -5900,12 +5516,12 @@
}
- /*************************************************************************/
- /* */
- /* MIAP[a]: Move Indirect Absolute Point */
- /* Opcode range: 0x3E-0x3F */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * MIAP[a]: Move Indirect Absolute Point
+ * Opcode range: 0x3E-0x3F
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_MIAP( TT_ExecContext exc,
FT_Long* args )
@@ -5914,21 +5530,10 @@
FT_UShort point;
FT_F26Dot6 distance;
FT_F26Dot6 org_dist;
- FT_F26Dot6 control_value_cutin;
-
- control_value_cutin = exc->GS.control_value_cutin;
- cvtEntry = (FT_ULong)args[1];
- point = (FT_UShort)args[0];
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 &&
- exc->GS.freeVector.y == 0 &&
- !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
- control_value_cutin = 0;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
+ cvtEntry = (FT_ULong)args[1];
+ point = (FT_UShort)args[0];
if ( BOUNDS( point, exc->zp0.n_points ) ||
BOUNDSL( cvtEntry, exc->cvtSize ) )
@@ -5962,32 +5567,18 @@
if ( exc->GS.gep0 == 0 ) /* If in twilight zone */
{
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */
- /* Determined via experimentation and may be incorrect... */
- if ( !( SUBPIXEL_HINTING_INFINALITY &&
- ( exc->ignore_x_mode &&
- exc->face->sph_compatibility_mode ) ) )
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
- exc->zp0.org[point].x = TT_MulFix14( distance,
+ exc->zp0.org[point].x = TT_MulFix14( distance,
exc->GS.freeVector.x );
exc->zp0.org[point].y = TT_MulFix14( distance,
- exc->GS.freeVector.y ),
+ exc->GS.freeVector.y );
exc->zp0.cur[point] = exc->zp0.org[point];
}
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- ( exc->sph_tweak_flags & SPH_TWEAK_MIAP_HACK ) &&
- distance > 0 &&
- exc->GS.freeVector.y != 0 )
- distance = 0;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
org_dist = FAST_PROJECT( &exc->zp0.cur[point] );
if ( ( exc->opcode & 1 ) != 0 ) /* rounding and control cut-in flag */
{
+ FT_F26Dot6 control_value_cutin = exc->GS.control_value_cutin;
FT_F26Dot6 delta;
@@ -5998,18 +5589,7 @@
if ( delta > control_value_cutin )
distance = org_dist;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 )
- distance = Round_None( exc,
- distance,
- exc->tt_metrics.compensations[0] );
- else
-#endif
- distance = exc->func_round( exc,
- distance,
- exc->tt_metrics.compensations[0] );
+ distance = exc->func_round( exc, distance, 3 );
}
exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) );
@@ -6020,29 +5600,19 @@
}
- /*************************************************************************/
- /* */
- /* MDRP[abcde]: Move Direct Relative Point */
- /* Opcode range: 0xC0-0xDF */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * MDRP[abcde]: Move Direct Relative Point
+ * Opcode range: 0xC0-0xDF
+ * Stack: uint32 -->
+ */
static void
Ins_MDRP( TT_ExecContext exc,
FT_Long* args )
{
FT_UShort point = 0;
- FT_F26Dot6 org_dist, distance, minimum_distance;
-
+ FT_F26Dot6 org_dist, distance;
- minimum_distance = exc->GS.minimum_distance;
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 &&
- !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
- minimum_distance = 0;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
point = (FT_UShort)args[0];
@@ -6112,31 +5682,18 @@
if ( ( exc->opcode & 4 ) != 0 )
{
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 )
- distance = Round_None(
- exc,
- org_dist,
- exc->tt_metrics.compensations[exc->opcode & 3] );
- else
-#endif
- distance = exc->func_round(
- exc,
- org_dist,
- exc->tt_metrics.compensations[exc->opcode & 3] );
+ distance = exc->func_round( exc, org_dist, exc->opcode & 3 );
}
else
- distance = Round_None(
- exc,
- org_dist,
- exc->tt_metrics.compensations[exc->opcode & 3] );
+ distance = Round_None( exc, org_dist, exc->opcode & 3 );
/* minimum distance flag */
if ( ( exc->opcode & 8 ) != 0 )
{
+ FT_F26Dot6 minimum_distance = exc->GS.minimum_distance;
+
+
if ( org_dist >= 0 )
{
if ( distance < minimum_distance )
@@ -6164,12 +5721,12 @@
}
- /*************************************************************************/
- /* */
- /* MIRP[abcde]: Move Indirect Relative Point */
- /* Opcode range: 0xE0-0xFF */
- /* Stack: int32? uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * MIRP[abcde]: Move Indirect Relative Point
+ * Opcode range: 0xE0-0xFF
+ * Stack: int32? uint32 -->
+ */
static void
Ins_MIRP( TT_ExecContext exc,
FT_Long* args )
@@ -6180,28 +5737,13 @@
FT_F26Dot6 cvt_dist,
distance,
cur_dist,
- org_dist,
- control_value_cutin,
- minimum_distance;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- FT_Int B1 = 0; /* pacify compiler */
- FT_Int B2 = 0;
- FT_Bool reverse_move = FALSE;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
-
- minimum_distance = exc->GS.minimum_distance;
- control_value_cutin = exc->GS.control_value_cutin;
- point = (FT_UShort)args[0];
- cvtEntry = (FT_ULong)( ADD_LONG( args[1], 1 ) );
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 &&
- !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
- control_value_cutin = minimum_distance = 0;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
+ org_dist;
+
+ FT_F26Dot6 delta;
+
+
+ point = (FT_UShort)args[0];
+ cvtEntry = (FT_ULong)( ADD_LONG( args[1], 1 ) );
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
@@ -6221,8 +5763,11 @@
/* single width test */
- if ( FT_ABS( cvt_dist - exc->GS.single_width_value ) <
- exc->GS.single_width_cutin )
+ delta = SUB_LONG( cvt_dist, exc->GS.single_width_value );
+ if ( delta < 0 )
+ delta = NEG_LONG( delta );
+
+ if ( delta < exc->GS.single_width_cutin )
{
if ( cvt_dist >= 0 )
cvt_dist = exc->GS.single_width_value;
@@ -6234,12 +5779,14 @@
/* twilight points (confirmed by Greg Hitchcock) */
if ( exc->GS.gep1 == 0 )
{
- exc->zp1.org[point].x = exc->zp0.org[exc->GS.rp0].x +
- TT_MulFix14( cvt_dist,
- exc->GS.freeVector.x );
- exc->zp1.org[point].y = exc->zp0.org[exc->GS.rp0].y +
- TT_MulFix14( cvt_dist,
- exc->GS.freeVector.y );
+ exc->zp1.org[point].x = ADD_LONG(
+ exc->zp0.org[exc->GS.rp0].x,
+ TT_MulFix14( cvt_dist,
+ exc->GS.freeVector.x ) );
+ exc->zp1.org[point].y = ADD_LONG(
+ exc->zp0.org[exc->GS.rp0].y,
+ TT_MulFix14( cvt_dist,
+ exc->GS.freeVector.y ) );
exc->zp1.cur[point] = exc->zp1.org[point];
}
@@ -6251,22 +5798,9 @@
if ( exc->GS.auto_flip )
{
if ( ( org_dist ^ cvt_dist ) < 0 )
- cvt_dist = -cvt_dist;
+ cvt_dist = NEG_LONG( cvt_dist );
}
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.y != 0 &&
- ( exc->sph_tweak_flags & SPH_TWEAK_TIMES_NEW_ROMAN_HACK ) )
- {
- if ( cur_dist < -64 )
- cvt_dist -= 16;
- else if ( cur_dist > 64 && cur_dist < 84 )
- cvt_dist += 32;
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
/* control value cut-in and round */
if ( ( exc->opcode & 4 ) != 0 )
@@ -6276,7 +5810,7 @@
if ( exc->GS.gep0 == exc->GS.gep1 )
{
- FT_F26Dot6 delta;
+ FT_F26Dot6 control_value_cutin = exc->GS.control_value_cutin;
/* XXX: According to Greg Hitchcock, the following wording is */
@@ -6299,42 +5833,18 @@
cvt_dist = org_dist;
}
- distance = exc->func_round(
- exc,
- cvt_dist,
- exc->tt_metrics.compensations[exc->opcode & 3] );
+ distance = exc->func_round( exc, cvt_dist, exc->opcode & 3 );
}
else
- {
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /* do cvt cut-in always in MIRP for sph */
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->GS.gep0 == exc->GS.gep1 )
- {
- FT_F26Dot6 delta;
-
-
- delta = SUB_LONG( cvt_dist, org_dist );
- if ( delta < 0 )
- delta = NEG_LONG( delta );
-
- if ( delta > control_value_cutin )
- cvt_dist = org_dist;
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
- distance = Round_None(
- exc,
- cvt_dist,
- exc->tt_metrics.compensations[exc->opcode & 3] );
- }
+ distance = Round_None( exc, cvt_dist, exc->opcode & 3 );
/* minimum distance test */
if ( ( exc->opcode & 8 ) != 0 )
{
+ FT_F26Dot6 minimum_distance = exc->GS.minimum_distance;
+
+
if ( org_dist >= 0 )
{
if ( distance < minimum_distance )
@@ -6347,61 +5857,11 @@
}
}
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY )
- {
- B1 = exc->zp1.cur[point].y;
-
- /* Round moves if necessary */
- if ( exc->ignore_x_mode &&
- exc->GS.freeVector.y != 0 &&
- ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) )
- distance = FT_PIX_ROUND( B1 + distance - cur_dist ) - B1 + cur_dist;
-
- if ( exc->ignore_x_mode &&
- exc->GS.freeVector.y != 0 &&
- ( exc->opcode & 16 ) == 0 &&
- ( exc->opcode & 8 ) == 0 &&
- ( exc->sph_tweak_flags & SPH_TWEAK_COURIER_NEW_2_HACK ) )
- distance += 64;
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
exc->func_move( exc,
&exc->zp1,
point,
SUB_LONG( distance, cur_dist ) );
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY )
- {
- B2 = exc->zp1.cur[point].y;
-
- /* Reverse move if necessary */
- if ( exc->ignore_x_mode )
- {
- if ( exc->face->sph_compatibility_mode &&
- exc->GS.freeVector.y != 0 &&
- ( B1 & 63 ) == 0 &&
- ( B2 & 63 ) != 0 )
- reverse_move = TRUE;
-
- if ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
- exc->GS.freeVector.y != 0 &&
- ( B2 & 63 ) != 0 &&
- ( B1 & 63 ) != 0 )
- reverse_move = TRUE;
- }
-
- if ( reverse_move )
- exc->func_move( exc,
- &exc->zp1,
- point,
- SUB_LONG( cur_dist, distance ) );
- }
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
Fail:
exc->GS.rp1 = exc->GS.rp0;
@@ -6412,12 +5872,12 @@
}
- /*************************************************************************/
- /* */
- /* ALIGNRP[]: ALIGN Relative Point */
- /* Opcode range: 0x3C */
- /* Stack: uint32 uint32... --> */
- /* */
+ /**************************************************************************
+ *
+ * ALIGNRP[]: ALIGN Relative Point
+ * Opcode range: 0x3C
+ * Stack: uint32 uint32... -->
+ */
static void
Ins_ALIGNRP( TT_ExecContext exc )
{
@@ -6425,17 +5885,6 @@
FT_F26Dot6 distance;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->iup_called &&
- ( exc->sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) )
- {
- exc->error = FT_THROW( Invalid_Reference );
- goto Fail;
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
if ( exc->top < exc->GS.loop ||
BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
{
@@ -6475,12 +5924,12 @@
}
- /*************************************************************************/
- /* */
- /* ISECT[]: moves point to InterSECTion */
- /* Opcode range: 0x0F */
- /* Stack: 5 * uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * ISECT[]: moves point to InterSECTion
+ * Opcode range: 0x0F
+ * Stack: 5 * uint32 -->
+ */
static void
Ins_ISECT( TT_ExecContext exc,
FT_Long* args )
@@ -6571,12 +6020,12 @@
}
- /*************************************************************************/
- /* */
- /* ALIGNPTS[]: ALIGN PoinTS */
- /* Opcode range: 0x27 */
- /* Stack: uint32 uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * ALIGNPTS[]: ALIGN PoinTS
+ * Opcode range: 0x27
+ * Stack: uint32 uint32 -->
+ */
static void
Ins_ALIGNPTS( TT_ExecContext exc,
FT_Long* args )
@@ -6603,12 +6052,12 @@
}
- /*************************************************************************/
- /* */
- /* IP[]: Interpolate Point */
- /* Opcode range: 0x39 */
- /* Stack: uint32... --> */
- /* */
+ /**************************************************************************
+ *
+ * IP[]: Interpolate Point
+ * Opcode range: 0x39
+ * Stack: uint32... -->
+ */
/* SOMETIMES, DUMBER CODE IS BETTER CODE */
@@ -6763,12 +6212,12 @@
}
- /*************************************************************************/
- /* */
- /* UTP[a]: UnTouch Point */
- /* Opcode range: 0x29 */
- /* Stack: uint32 --> */
- /* */
+ /**************************************************************************
+ *
+ * UTP[a]: UnTouch Point
+ * Opcode range: 0x29
+ * Stack: uint32 -->
+ */
static void
Ins_UTP( TT_ExecContext exc,
FT_Long* args )
@@ -6810,7 +6259,7 @@
static void
- _iup_worker_shift( IUP_Worker worker,
+ iup_worker_shift_( IUP_Worker worker,
FT_UInt p1,
FT_UInt p2,
FT_UInt p )
@@ -6832,7 +6281,7 @@
static void
- _iup_worker_interpolate( IUP_Worker worker,
+ iup_worker_interpolate_( IUP_Worker worker,
FT_UInt p1,
FT_UInt p2,
FT_UInt ref1,
@@ -6932,12 +6381,12 @@
}
- /*************************************************************************/
- /* */
- /* IUP[a]: Interpolate Untouched Points */
- /* Opcode range: 0x30-0x31 */
- /* Stack: --> */
- /* */
+ /**************************************************************************
+ *
+ * IUP[a]: Interpolate Untouched Points
+ * Opcode range: 0x30-0x31
+ * Stack: -->
+ */
static void
Ins_IUP( TT_ExecContext exc )
{
@@ -6994,16 +6443,6 @@
contour = 0;
point = 0;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode )
- {
- exc->iup_called = TRUE;
- if ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_IUP )
- return;
- }
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
do
{
end_point = exc->pts.contours[contour] - exc->pts.first_point;
@@ -7026,7 +6465,7 @@
{
if ( ( exc->pts.tags[point] & mask ) != 0 )
{
- _iup_worker_interpolate( &V,
+ iup_worker_interpolate_( &V,
cur_touched + 1,
point - 1,
cur_touched,
@@ -7038,17 +6477,17 @@
}
if ( cur_touched == first_touched )
- _iup_worker_shift( &V, first_point, end_point, cur_touched );
+ iup_worker_shift_( &V, first_point, end_point, cur_touched );
else
{
- _iup_worker_interpolate( &V,
+ iup_worker_interpolate_( &V,
(FT_UShort)( cur_touched + 1 ),
end_point,
cur_touched,
first_touched );
if ( first_touched > 0 )
- _iup_worker_interpolate( &V,
+ iup_worker_interpolate_( &V,
first_point,
first_touched - 1,
cur_touched,
@@ -7060,12 +6499,12 @@
}
- /*************************************************************************/
- /* */
- /* DELTAPn[]: DELTA exceptions P1, P2, P3 */
- /* Opcode range: 0x5D,0x71,0x72 */
- /* Stack: uint32 (2 * uint32)... --> */
- /* */
+ /**************************************************************************
+ *
+ * DELTAPn[]: DELTA exceptions P1, P2, P3
+ * Opcode range: 0x5D,0x71,0x72
+ * Stack: uint32 (2 * uint32)... -->
+ */
static void
Ins_DELTAP( TT_ExecContext exc,
FT_Long* args )
@@ -7074,17 +6513,8 @@
FT_UShort A;
FT_ULong C, P;
FT_Long B;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- FT_UShort B1, B2;
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->ignore_x_mode &&
- exc->iup_called &&
- ( exc->sph_tweak_flags & SPH_TWEAK_NO_DELTAP_AFTER_IUP ) )
- goto Fail;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
P = (FT_ULong)exc->func_cur_ppem( exc );
nump = (FT_ULong)args[0]; /* some points theoretically may occur more
than once, thus UShort isn't enough */
@@ -7137,84 +6567,21 @@
B++;
B *= 1L << ( 6 - exc->GS.delta_shift );
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING_INFINALITY )
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* See `ttinterp.h' for details on backward compatibility */
+ /* mode. */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility )
{
- /*
- * Allow delta move if
- *
- * - not using ignore_x_mode rendering,
- * - glyph is specifically set to allow it, or
- * - glyph is composite and freedom vector is not in subpixel
- * direction.
- */
- if ( !exc->ignore_x_mode ||
- ( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) ||
- ( exc->is_composite && exc->GS.freeVector.y != 0 ) )
+ if ( !( exc->iupx_called && exc->iupy_called ) &&
+ ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
+ ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) )
exc->func_move( exc, &exc->zp0, A, B );
-
- /* Otherwise, apply subpixel hinting and compatibility mode */
- /* rules, always skipping deltas in subpixel direction. */
- else if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 )
- {
- /* save the y value of the point now; compare after move */
- B1 = (FT_UShort)exc->zp0.cur[A].y;
-
- /* Standard subpixel hinting: Allow y move for y-touched */
- /* points. This messes up DejaVu ... */
- if ( !exc->face->sph_compatibility_mode &&
- ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
- exc->func_move( exc, &exc->zp0, A, B );
-
- /* compatibility mode */
- else if ( exc->face->sph_compatibility_mode &&
- !( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
- {
- if ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
- B = FT_PIX_ROUND( B1 + B ) - B1;
-
- /* Allow delta move if using sph_compatibility_mode, */
- /* IUP has not been called, and point is touched on Y. */
- if ( !exc->iup_called &&
- ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
- exc->func_move( exc, &exc->zp0, A, B );
- }
-
- B2 = (FT_UShort)exc->zp0.cur[A].y;
-
- /* Reverse this move if it results in a disallowed move */
- if ( exc->GS.freeVector.y != 0 &&
- ( ( exc->face->sph_compatibility_mode &&
- ( B1 & 63 ) == 0 &&
- ( B2 & 63 ) != 0 ) ||
- ( ( exc->sph_tweak_flags &
- SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) &&
- ( B1 & 63 ) != 0 &&
- ( B2 & 63 ) != 0 ) ) )
- exc->func_move( exc, &exc->zp0, A, NEG_LONG( B ) );
- }
}
else
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
- {
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backward compatibility */
- /* mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backward_compatibility )
- {
- if ( !( exc->iupx_called && exc->iupy_called ) &&
- ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
- ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) )
- exc->func_move( exc, &exc->zp0, A, B );
- }
- else
#endif
- exc->func_move( exc, &exc->zp0, A, B );
- }
+ exc->func_move( exc, &exc->zp0, A, B );
}
}
else
@@ -7227,12 +6594,12 @@
}
- /*************************************************************************/
- /* */
- /* DELTACn[]: DELTA exceptions C1, C2, C3 */
- /* Opcode range: 0x73,0x74,0x75 */
- /* Stack: uint32 (2 * uint32)... --> */
- /* */
+ /**************************************************************************
+ *
+ * DELTACn[]: DELTA exceptions C1, C2, C3
+ * Opcode range: 0x73,0x74,0x75
+ * Stack: uint32 (2 * uint32)... -->
+ */
static void
Ins_DELTAC( TT_ExecContext exc,
FT_Long* args )
@@ -7305,27 +6672,19 @@
}
- /*************************************************************************/
- /* */
- /* MISC. INSTRUCTIONS */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * MISC. INSTRUCTIONS
+ *
+ */
- /*************************************************************************/
- /* */
- /* GETINFO[]: GET INFOrmation */
- /* Opcode range: 0x88 */
- /* Stack: uint32 --> uint32 */
- /* */
- /* XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May */
- /* 2015) not documented in the OpenType specification. */
- /* */
- /* Selector bit 11 is incorrectly described as bit 8, while the */
- /* real meaning of bit 8 (vertical LCD subpixels) stays */
- /* undocumented. The same mistake can be found in Greg Hitchcock's */
- /* whitepaper. */
- /* */
+ /**************************************************************************
+ *
+ * GETINFO[]: GET INFOrmation
+ * Opcode range: 0x88
+ * Stack: uint32 --> uint32
+ */
static void
Ins_GETINFO( TT_ExecContext exc,
FT_Long* args )
@@ -7336,65 +6695,41 @@
K = 0;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- /********************************/
- /* RASTERIZER VERSION */
- /* Selector Bit: 0 */
- /* Return Bit(s): 0-7 */
- /* */
- if ( SUBPIXEL_HINTING_INFINALITY &&
- ( args[0] & 1 ) != 0 &&
- exc->subpixel_hinting )
- {
- if ( exc->ignore_x_mode )
- {
- /* if in ClearType backward compatibility mode, */
- /* we sometimes change the TrueType version dynamically */
- K = exc->rasterizer_version;
- FT_TRACE6(( "Setting rasterizer version %d\n",
- exc->rasterizer_version ));
- }
- else
- K = TT_INTERPRETER_VERSION_38;
- }
- else
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
- if ( ( args[0] & 1 ) != 0 )
- K = driver->interpreter_version;
-
- /********************************/
- /* GLYPH ROTATED */
- /* Selector Bit: 1 */
- /* Return Bit(s): 8 */
- /* */
+ if ( ( args[0] & 1 ) != 0 )
+ K = driver->interpreter_version;
+
+ /*********************************
+ * GLYPH ROTATED
+ * Selector Bit: 1
+ * Return Bit(s): 8
+ */
if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated )
K |= 1 << 8;
- /********************************/
- /* GLYPH STRETCHED */
- /* Selector Bit: 2 */
- /* Return Bit(s): 9 */
- /* */
+ /*********************************
+ * GLYPH STRETCHED
+ * Selector Bit: 2
+ * Return Bit(s): 9
+ */
if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched )
K |= 1 << 9;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /********************************/
- /* VARIATION GLYPH */
- /* Selector Bit: 3 */
- /* Return Bit(s): 10 */
- /* */
- /* XXX: UNDOCUMENTED! */
+ /*********************************
+ * VARIATION GLYPH
+ * Selector Bit: 3
+ * Return Bit(s): 10
+ */
if ( (args[0] & 8 ) != 0 && exc->face->blend )
K |= 1 << 10;
#endif
- /********************************/
- /* BI-LEVEL HINTING AND */
- /* GRAYSCALE RENDERING */
- /* Selector Bit: 5 */
- /* Return Bit(s): 12 */
- /* */
+ /*********************************
+ * BI-LEVEL HINTING AND
+ * GRAYSCALE RENDERING
+ * Selector Bit: 5
+ * Return Bit(s): 12
+ */
if ( ( args[0] & 32 ) != 0 && exc->grayscale )
K |= 1 << 12;
@@ -7405,148 +6740,75 @@
/* Bold Italic'. */
if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean )
{
- /********************************/
- /* HINTING FOR SUBPIXEL */
- /* Selector Bit: 6 */
- /* Return Bit(s): 13 */
- /* */
- /* v40 does subpixel hinting by default. */
+ /*********************************
+ * HINTING FOR SUBPIXEL
+ * Selector Bit: 6
+ * Return Bit(s): 13
+ *
+ * v40 does subpixel hinting by default.
+ */
if ( ( args[0] & 64 ) != 0 )
K |= 1 << 13;
- /********************************/
- /* VERTICAL LCD SUBPIXELS? */
- /* Selector Bit: 8 */
- /* Return Bit(s): 15 */
- /* */
+ /*********************************
+ * VERTICAL LCD SUBPIXELS?
+ * Selector Bit: 8
+ * Return Bit(s): 15
+ */
if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean )
K |= 1 << 15;
- /********************************/
- /* SUBPIXEL POSITIONED? */
- /* Selector Bit: 10 */
- /* Return Bit(s): 17 */
- /* */
- /* XXX: FreeType supports it, dependent on what client does? */
+ /*********************************
+ * SUBPIXEL POSITIONED?
+ * Selector Bit: 10
+ * Return Bit(s): 17
+ *
+ * XXX: FreeType supports it, dependent on what client does?
+ */
if ( ( args[0] & 1024 ) != 0 )
K |= 1 << 17;
- /********************************/
- /* SYMMETRICAL SMOOTHING */
- /* Selector Bit: 11 */
- /* Return Bit(s): 18 */
- /* */
- /* The only smoothing method FreeType supports unless someone sets */
- /* FT_LOAD_TARGET_MONO. */
+ /*********************************
+ * SYMMETRICAL SMOOTHING
+ * Selector Bit: 11
+ * Return Bit(s): 18
+ *
+ * The only smoothing method FreeType supports unless someone sets
+ * FT_LOAD_TARGET_MONO.
+ */
if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean )
K |= 1 << 18;
- /********************************/
- /* CLEARTYPE HINTING AND */
- /* GRAYSCALE RENDERING */
- /* Selector Bit: 12 */
- /* Return Bit(s): 19 */
- /* */
- /* Grayscale rendering is what FreeType does anyway unless someone */
- /* sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) */
+ /*********************************
+ * CLEARTYPE HINTING AND
+ * GRAYSCALE RENDERING
+ * Selector Bit: 12
+ * Return Bit(s): 19
+ *
+ * Grayscale rendering is what FreeType does anyway unless someone
+ * sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V)
+ */
if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype )
K |= 1 << 19;
}
#endif
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- if ( SUBPIXEL_HINTING_INFINALITY &&
- exc->rasterizer_version >= TT_INTERPRETER_VERSION_35 )
- {
-
- if ( exc->rasterizer_version >= 37 )
- {
- /********************************/
- /* HINTING FOR SUBPIXEL */
- /* Selector Bit: 6 */
- /* Return Bit(s): 13 */
- /* */
- if ( ( args[0] & 64 ) != 0 && exc->subpixel_hinting )
- K |= 1 << 13;
-
- /********************************/
- /* COMPATIBLE WIDTHS ENABLED */
- /* Selector Bit: 7 */
- /* Return Bit(s): 14 */
- /* */
- /* Functionality still needs to be added */
- if ( ( args[0] & 128 ) != 0 && exc->compatible_widths )
- K |= 1 << 14;
-
- /********************************/
- /* VERTICAL LCD SUBPIXELS? */
- /* Selector Bit: 8 */
- /* Return Bit(s): 15 */
- /* */
- /* Functionality still needs to be added */
- if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd )
- K |= 1 << 15;
-
- /********************************/
- /* HINTING FOR BGR? */
- /* Selector Bit: 9 */
- /* Return Bit(s): 16 */
- /* */
- /* Functionality still needs to be added */
- if ( ( args[0] & 512 ) != 0 && exc->bgr )
- K |= 1 << 16;
-
- if ( exc->rasterizer_version >= 38 )
- {
- /********************************/
- /* SUBPIXEL POSITIONED? */
- /* Selector Bit: 10 */
- /* Return Bit(s): 17 */
- /* */
- /* Functionality still needs to be added */
- if ( ( args[0] & 1024 ) != 0 && exc->subpixel_positioned )
- K |= 1 << 17;
-
- /********************************/
- /* SYMMETRICAL SMOOTHING */
- /* Selector Bit: 11 */
- /* Return Bit(s): 18 */
- /* */
- /* Functionality still needs to be added */
- if ( ( args[0] & 2048 ) != 0 && exc->symmetrical_smoothing )
- K |= 1 << 18;
-
- /********************************/
- /* GRAY CLEARTYPE */
- /* Selector Bit: 12 */
- /* Return Bit(s): 19 */
- /* */
- /* Functionality still needs to be added */
- if ( ( args[0] & 4096 ) != 0 && exc->gray_cleartype )
- K |= 1 << 19;
- }
- }
- }
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
args[0] = K;
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- /*************************************************************************/
- /* */
- /* GETVARIATION[]: get normalized variation (blend) coordinates */
- /* Opcode range: 0x91 */
- /* Stack: --> f2.14... */
- /* */
- /* XXX: UNDOCUMENTED! There is no official documentation from Apple for */
- /* this bytecode instruction. Active only if a font has GX */
- /* variation axes. */
- /* */
+ /**************************************************************************
+ *
+ * GETVARIATION[]: get normalized variation (blend) coordinates
+ * Opcode range: 0x91
+ * Stack: --> f2.14...
+ *
+ * XXX: UNDOCUMENTED! There is no official documentation from Apple for
+ * this bytecode instruction. Active only if a font has GX
+ * variation axes.
+ */
static void
Ins_GETVARIATION( TT_ExecContext exc,
FT_Long* args )
@@ -7576,15 +6838,15 @@
}
- /*************************************************************************/
- /* */
- /* GETDATA[]: no idea what this is good for */
- /* Opcode range: 0x92 */
- /* Stack: --> 17 */
- /* */
- /* XXX: UNDOCUMENTED! There is no documentation from Apple for this */
- /* very weird bytecode instruction. */
- /* */
+ /**************************************************************************
+ *
+ * GETDATA[]: no idea what this is good for
+ * Opcode range: 0x92
+ * Stack: --> 17
+ *
+ * XXX: UNDOCUMENTED! There is no documentation from Apple for this
+ * very weird bytecode instruction.
+ */
static void
Ins_GETDATA( FT_Long* args )
{
@@ -7598,7 +6860,7 @@
Ins_UNKNOWN( TT_ExecContext exc )
{
TT_DefRecord* def = exc->IDefs;
- TT_DefRecord* limit = def + exc->numIDefs;
+ TT_DefRecord* limit = FT_OFFSET( def, exc->numIDefs );
for ( ; def < limit; def++ )
@@ -7632,87 +6894,47 @@
}
- /*************************************************************************/
- /* */
- /* RUN */
- /* */
- /* This function executes a run of opcodes. It will exit in the */
- /* following cases: */
- /* */
- /* - Errors (in which case it returns FALSE). */
- /* */
- /* - Reaching the end of the main code range (returns TRUE). */
- /* Reaching the end of a code range within a function call is an */
- /* error. */
- /* */
- /* - After executing one single opcode, if the flag `Instruction_Trap' */
- /* is set to TRUE (returns TRUE). */
- /* */
- /* On exit with TRUE, test IP < CodeSize to know whether it comes from */
- /* an instruction trap or a normal termination. */
- /* */
- /* */
- /* Note: The documented DEBUG opcode pops a value from the stack. This */
- /* behaviour is unsupported; here a DEBUG opcode is always an */
- /* error. */
- /* */
- /* */
- /* THIS IS THE INTERPRETER'S MAIN LOOP. */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * RUN
+ *
+ * This function executes a run of opcodes. It will exit in the
+ * following cases:
+ *
+ * - Errors (in which case it returns FALSE).
+ *
+ * - Reaching the end of the main code range (returns TRUE).
+ * Reaching the end of a code range within a function call is an
+ * error.
+ *
+ * - After executing one single opcode, if the flag `Instruction_Trap'
+ * is set to TRUE (returns TRUE).
+ *
+ * On exit with TRUE, test IP < CodeSize to know whether it comes from
+ * an instruction trap or a normal termination.
+ *
+ *
+ * Note: The documented DEBUG opcode pops a value from the stack. This
+ * behaviour is unsupported; here a DEBUG opcode is always an
+ * error.
+ *
+ *
+ * THIS IS THE INTERPRETER'S MAIN LOOP.
+ *
+ */
/* documentation is in ttinterp.h */
FT_EXPORT_DEF( FT_Error )
- TT_RunIns( TT_ExecContext exc )
+ TT_RunIns( void* exec )
{
+ TT_ExecContext exc = (TT_ExecContext)exec;
+
FT_ULong ins_counter = 0; /* executed instructions counter */
FT_ULong num_twilight_points;
FT_UShort i;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- FT_Byte opcode_pattern[1][2] = {
- /* #8 TypeMan Talk Align */
- {
- 0x06, /* SPVTL */
- 0x7D, /* RDTG */
- },
- };
- FT_UShort opcode_patterns = 1;
- FT_UShort opcode_pointer[1] = { 0 };
- FT_UShort opcode_size[1] = { 1 };
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- exc->iup_called = FALSE;
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /*
- * Toggle backward compatibility according to what font wants, except
- * when
- *
- * 1) we have a `tricky' font that heavily relies on the interpreter to
- * render glyphs correctly, for example DFKai-SB, or
- * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested.
- *
- * In those cases, backward compatibility needs to be turned off to get
- * correct rendering. The rendering is then completely up to the
- * font's programming.
- *
- */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->subpixel_hinting_lean &&
- !FT_IS_TRICKY( &exc->face->root ) )
- exc->backward_compatibility = !( exc->GS.instruct_control & 4 );
- else
- exc->backward_compatibility = FALSE;
-
- exc->iupx_called = FALSE;
- exc->iupy_called = FALSE;
-#endif
/* We restrict the number of twilight points to a reasonable, */
/* heuristic value to avoid slow execution of malformed bytecode. */
@@ -7723,8 +6945,8 @@
if ( num_twilight_points > 0xFFFFU )
num_twilight_points = 0xFFFFU;
- FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n"
- " from %d to the more reasonable value %d\n",
+ FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n" ));
+ FT_TRACE5(( " from %d to the more reasonable value %ld\n",
exc->twilight.n_points,
num_twilight_points ));
exc->twilight.n_points = (FT_UShort)num_twilight_points;
@@ -7750,7 +6972,7 @@
FT_MAX( 50,
exc->cvtSize / 10 );
else
- exc->loopcall_counter_max = 300 + 8 * exc->cvtSize;
+ exc->loopcall_counter_max = 300 + 22 * exc->cvtSize;
/* as a protection against an unreasonable number of CVT entries */
/* we assume at most 100 control values per glyph for the counter */
@@ -7759,11 +6981,11 @@
exc->loopcall_counter_max = 100 * (FT_ULong)exc->face->root.num_glyphs;
FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL"
- " to %d\n", exc->loopcall_counter_max ));
+ " to %ld\n", exc->loopcall_counter_max ));
exc->neg_jump_counter_max = exc->loopcall_counter_max;
FT_TRACE5(( "TT_RunIns: Limiting total number of backward jumps"
- " to %d\n", exc->neg_jump_counter_max ));
+ " to %ld\n", exc->neg_jump_counter_max ));
/* set PPEM and CVT functions */
exc->tt_metrics.ratio = 0;
@@ -7784,14 +7006,23 @@
exc->func_move_cvt = Move_CVT;
}
+ exc->iniRange = exc->curRange;
+
Compute_Funcs( exc );
Compute_Round( exc, (FT_Byte)exc->GS.round_state );
+ /* These flags cancel execution of some opcodes after IUP is called */
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ exc->iupx_called = FALSE;
+ exc->iupy_called = FALSE;
+#endif
+
do
{
exc->opcode = exc->code[exc->IP];
#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( ft_trace_levels[trace_ttinterp] >= 6 )
{
FT_Long cnt = FT_MIN( 8, exc->top );
FT_Long n;
@@ -7800,14 +7031,14 @@
/* if tracing level is 7, show current code position */
/* and the first few stack elements also */
FT_TRACE6(( " " ));
- FT_TRACE7(( "%06d ", exc->IP ));
- FT_TRACE6(( opcode_name[exc->opcode] + 2 ));
+ FT_TRACE7(( "%06ld ", exc->IP ));
+ FT_TRACE6(( "%s", opcode_name[exc->opcode] + 2 ));
FT_TRACE7(( "%*s", *opcode_name[exc->opcode] == 'A'
? 2
: 12 - ( *opcode_name[exc->opcode] - '0' ),
"#" ));
for ( n = 1; n <= cnt; n++ )
- FT_TRACE7(( " %d", exc->stack[exc->top - n] ));
+ FT_TRACE7(( " %ld", exc->stack[exc->top - n] ));
FT_TRACE6(( "\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
@@ -7849,7 +7080,7 @@
/* a variable number of arguments */
/* it is the job of the application to `activate' GX handling, */
- /* this is, calling any of the GX API functions on the current */
+ /* that is, calling any of the GX API functions on the current */
/* font to select a variation instance */
if ( exc->face->blend )
exc->new_top = exc->args + exc->face->blend->num_axis;
@@ -7870,39 +7101,6 @@
exc->step_ins = TRUE;
exc->error = FT_Err_Ok;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- if ( SUBPIXEL_HINTING_INFINALITY )
- {
- for ( i = 0; i < opcode_patterns; i++ )
- {
- if ( opcode_pointer[i] < opcode_size[i] &&
- exc->opcode == opcode_pattern[i][opcode_pointer[i]] )
- {
- opcode_pointer[i] += 1;
-
- if ( opcode_pointer[i] == opcode_size[i] )
- {
- FT_TRACE6(( "sph: opcode ptrn: %d, %s %s\n",
- i,
- exc->face->root.family_name,
- exc->face->root.style_name ));
-
- switch ( i )
- {
- case 0:
- break;
- }
- opcode_pointer[i] = 0;
- }
- }
- else
- opcode_pointer[i] = 0;
- }
- }
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
{
FT_Long* args = exc->stack + exc->args;
FT_Byte opcode = exc->opcode;
@@ -8409,7 +7607,7 @@
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
case 0x91:
/* it is the job of the application to `activate' GX handling, */
- /* this is, calling any of the GX API functions on the current */
+ /* that is, calling any of the GX API functions on the current */
/* font to select a variation instance */
if ( exc->face->blend )
Ins_GETVARIATION( exc, args );
@@ -8450,7 +7648,7 @@
case FT_ERR( Invalid_Opcode ):
{
TT_DefRecord* def = exc->IDefs;
- TT_DefRecord* limit = def + exc->numIDefs;
+ TT_DefRecord* limit = FT_OFFSET( def, exc->numIDefs );
for ( ; def < limit; def++ )
@@ -8509,7 +7707,10 @@
/* increment instruction counter and check if we didn't */
/* run this program for too long (e.g. infinite loops). */
if ( ++ins_counter > TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES )
- return FT_THROW( Execution_Too_Long );
+ {
+ exc->error = FT_THROW( Execution_Too_Long );
+ goto LErrorLabel_;
+ }
LSuiteLabel_:
if ( exc->IP >= exc->codeSize )
@@ -8525,9 +7726,10 @@
} while ( !exc->instruction_trap );
LNo_Error_:
- FT_TRACE4(( " %d instruction%s executed\n",
+ FT_TRACE4(( " %ld instruction%s executed\n",
ins_counter,
ins_counter == 1 ? "" : "s" ));
+
return FT_Err_Ok;
LErrorCodeOverflow_:
@@ -8543,7 +7745,7 @@
#else /* !TT_USE_BYTECODE_INTERPRETER */
/* ANSI C doesn't like empty source files */
- typedef int _tt_interp_dummy;
+ typedef int tt_interp_dummy_;
#endif /* !TT_USE_BYTECODE_INTERPRETER */
diff --git a/src/3rdparty/freetype/src/truetype/ttinterp.h b/src/3rdparty/freetype/src/truetype/ttinterp.h
index 2966439ea2..e98e258fe7 100644
--- a/src/3rdparty/freetype/src/truetype/ttinterp.h
+++ b/src/3rdparty/freetype/src/truetype/ttinterp.h
@@ -1,35 +1,34 @@
-/***************************************************************************/
-/* */
-/* ttinterp.h */
-/* */
-/* TrueType bytecode interpreter (specification). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttinterp.h
+ *
+ * TrueType bytecode interpreter (specification).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef TTINTERP_H_
#define TTINTERP_H_
-#include <ft2build.h>
#include "ttobjs.h"
FT_BEGIN_HEADER
- /*************************************************************************/
- /* */
- /* Rounding mode constants. */
- /* */
+ /**************************************************************************
+ *
+ * Rounding mode constants.
+ */
#define TT_Round_Off 5
#define TT_Round_To_Half_Grid 0
#define TT_Round_To_Grid 1
@@ -40,19 +39,19 @@ FT_BEGIN_HEADER
#define TT_Round_Super_45 7
- /*************************************************************************/
- /* */
- /* Function types used by the interpreter, depending on various modes */
- /* (e.g. the rounding mode, whether to render a vertical or horizontal */
- /* line etc). */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * Function types used by the interpreter, depending on various modes
+ * (e.g. the rounding mode, whether to render a vertical or horizontal
+ * line etc).
+ *
+ */
/* Rounding function */
typedef FT_F26Dot6
(*TT_Round_Func)( TT_ExecContext exc,
FT_F26Dot6 distance,
- FT_F26Dot6 compensation );
+ FT_Int color );
/* Point displacement along the freedom vector routine */
typedef void
@@ -84,10 +83,10 @@ FT_BEGIN_HEADER
FT_F26Dot6 value );
- /*************************************************************************/
- /* */
- /* This structure defines a call record, used to manage function calls. */
- /* */
+ /**************************************************************************
+ *
+ * This structure defines a call record, used to manage function calls.
+ */
typedef struct TT_CallRec_
{
FT_Int Caller_Range;
@@ -99,83 +98,45 @@ FT_BEGIN_HEADER
} TT_CallRec, *TT_CallStack;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- /*************************************************************************/
- /* */
- /* These structures define rules used to tweak subpixel hinting for */
- /* various fonts. "", 0, "", NULL value indicates to match any value. */
- /* */
-
-#define SPH_MAX_NAME_SIZE 32
-#define SPH_MAX_CLASS_MEMBERS 100
-
- typedef struct SPH_TweakRule_
- {
- const char family[SPH_MAX_NAME_SIZE];
- const FT_UInt ppem;
- const char style[SPH_MAX_NAME_SIZE];
- const FT_ULong glyph;
-
- } SPH_TweakRule;
-
-
- typedef struct SPH_ScaleRule_
- {
- const char family[SPH_MAX_NAME_SIZE];
- const FT_UInt ppem;
- const char style[SPH_MAX_NAME_SIZE];
- const FT_ULong glyph;
- const FT_ULong scale;
-
- } SPH_ScaleRule;
-
-
- typedef struct SPH_Font_Class_
- {
- const char name[SPH_MAX_NAME_SIZE];
- const char member[SPH_MAX_CLASS_MEMBERS][SPH_MAX_NAME_SIZE];
-
- } SPH_Font_Class;
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
-
- /*************************************************************************/
- /* */
- /* The main structure for the interpreter which collects all necessary */
- /* variables and states. */
- /* */
+ /**************************************************************************
+ *
+ * The main structure for the interpreter which collects all necessary
+ * variables and states.
+ *
+ * Members that are initialized by `TT_Load_Context` are marked with '!'.
+ * Members that are initialized by `TT_Run_Context` are marked with '@'.
+ */
typedef struct TT_ExecContextRec_
{
- TT_Face face;
- TT_Size size;
+ TT_Face face; /* ! */
+ TT_Size size; /* ! */
FT_Memory memory;
/* instructions state */
FT_Error error; /* last execution error */
- FT_Long top; /* top of exec. stack */
+ FT_Long top; /* @ top of exec. stack */
- FT_Long stackSize; /* size of exec. stack */
- FT_Long* stack; /* current exec. stack */
+ FT_Long stackSize; /* ! size of exec. stack */
+ FT_Long* stack; /* ! current exec. stack */
FT_Long args;
- FT_Long new_top; /* new top after exec. */
+ FT_Long new_top; /* new top after exec. */
- TT_GlyphZoneRec zp0, /* zone records */
- zp1,
- zp2,
- pts,
- twilight;
+ TT_GlyphZoneRec zp0, /* @! zone records */
+ zp1, /* @! */
+ zp2, /* @! */
+ pts, /* ! */
+ twilight; /* ! */
- FT_Long pointSize; /* in 26.6 format */
- FT_Size_Metrics metrics;
- TT_Size_Metrics tt_metrics; /* size metrics */
+ FT_Long pointSize; /* ! in 26.6 format */
+ FT_Size_Metrics metrics; /* ! */
+ TT_Size_Metrics tt_metrics; /* ! size metrics */
- TT_GraphicsState GS; /* current graphics state */
+ TT_GraphicsState GS; /* !@ current graphics state */
+ FT_Int iniRange; /* initial code range number */
FT_Int curRange; /* current code range number */
FT_Byte* code; /* current code range */
FT_Long IP; /* current instruction pointer */
@@ -186,43 +147,47 @@ FT_BEGIN_HEADER
FT_Bool step_ins; /* true if the interpreter must */
/* increment IP after ins. exec */
- FT_ULong cvtSize;
- FT_Long* cvt;
+ FT_ULong cvtSize; /* ! */
+ FT_Long* cvt; /* ! */
+ FT_ULong glyfCvtSize;
+ FT_Long* glyfCvt; /* cvt working copy for glyph */
- FT_UInt glyphSize; /* glyph instructions buffer size */
- FT_Byte* glyphIns; /* glyph instructions buffer */
+ FT_UInt glyphSize; /* ! glyph instructions buffer size */
+ FT_Byte* glyphIns; /* ! glyph instructions buffer */
- FT_UInt numFDefs; /* number of function defs */
- FT_UInt maxFDefs; /* maximum number of function defs */
- TT_DefArray FDefs; /* table of FDefs entries */
+ FT_UInt numFDefs; /* ! number of function defs */
+ FT_UInt maxFDefs; /* ! maximum number of function defs */
+ TT_DefArray FDefs; /* table of FDefs entries */
- FT_UInt numIDefs; /* number of instruction defs */
- FT_UInt maxIDefs; /* maximum number of ins defs */
- TT_DefArray IDefs; /* table of IDefs entries */
+ FT_UInt numIDefs; /* ! number of instruction defs */
+ FT_UInt maxIDefs; /* ! maximum number of ins defs */
+ TT_DefArray IDefs; /* table of IDefs entries */
- FT_UInt maxFunc; /* maximum function index */
- FT_UInt maxIns; /* maximum instruction index */
+ FT_UInt maxFunc; /* ! maximum function index */
+ FT_UInt maxIns; /* ! maximum instruction index */
- FT_Int callTop, /* top of call stack during execution */
- callSize; /* size of call stack */
- TT_CallStack callStack; /* call stack */
+ FT_Int callTop, /* @ top of call stack during execution */
+ callSize; /* size of call stack */
+ TT_CallStack callStack; /* call stack */
FT_UShort maxPoints; /* capacity of this context's `pts' */
FT_Short maxContours; /* record, expressed in points and */
/* contours. */
- TT_CodeRangeTable codeRangeTable; /* table of valid code ranges */
- /* useful for the debugger */
+ TT_CodeRangeTable codeRangeTable; /* ! table of valid code ranges */
+ /* useful for the debugger */
- FT_UShort storeSize; /* size of current storage */
- FT_Long* storage; /* storage area */
+ FT_UShort storeSize; /* ! size of current storage */
+ FT_Long* storage; /* ! storage area */
+ FT_UShort glyfStoreSize;
+ FT_Long* glyfStorage; /* storage working copy for glyph */
FT_F26Dot6 period; /* values used for the */
FT_F26Dot6 phase; /* `SuperRounding' */
FT_F26Dot6 threshold;
- FT_Bool instruction_trap; /* If `True', the interpreter will */
- /* exit after each instruction */
+ FT_Bool instruction_trap; /* ! If `True', the interpreter */
+ /* exits after each instruction */
TT_GraphicsState default_GS; /* graphics state resulting from */
/* the prep program */
@@ -239,7 +204,7 @@ FT_BEGIN_HEADER
func_dualproj, /* current dual proj. function */
func_freeProj; /* current freedom proj. func */
- TT_Move_Func func_move; /* current point move function */
+ TT_Move_Func func_move; /* current point move function */
TT_Move_Func func_move_orig; /* move original position function */
TT_Cur_Ppem_Func func_cur_ppem; /* get current proj. ppem value */
@@ -352,7 +317,7 @@ FT_BEGIN_HEADER
* https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
*
* [3] Beat Stamm describes it in more detail:
- * http://www.beatstamm.com/typography/RTRCh4.htm#Sec12
+ * http://rastertragedy.com/RTRCh4.htm#Sec12.
*
* [4] The list of `native ClearType' fonts is small at the time of this
* writing; I found the following on a Windows 10 Update 1511
@@ -392,38 +357,6 @@ FT_BEGIN_HEADER
FT_Bool grayscale_cleartype;
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- TT_Round_Func func_round_sphn; /* subpixel rounding function */
-
- FT_Bool subpixel_hinting; /* Using subpixel hinting? */
- FT_Bool ignore_x_mode; /* Standard rendering mode for */
- /* subpixel hinting. On if gray */
- /* or subpixel hinting is on. */
-
- /* The following 6 aren't fully implemented but here for MS rasterizer */
- /* compatibility. */
- FT_Bool compatible_widths; /* compatible widths? */
- FT_Bool symmetrical_smoothing; /* symmetrical_smoothing? */
- FT_Bool bgr; /* bgr instead of rgb? */
- FT_Bool vertical_lcd; /* long side of LCD subpixel */
- /* rectangles is horizontal */
- FT_Bool subpixel_positioned; /* subpixel positioned */
- /* (DirectWrite ClearType)? */
- FT_Bool gray_cleartype; /* ClearType hinting but */
- /* grayscale rendering */
-
- FT_Int rasterizer_version; /* MS rasterizer version */
-
- FT_Bool iup_called; /* IUP called for glyph? */
-
- FT_ULong sph_tweak_flags; /* flags to control */
- /* hint tweaks */
-
- FT_ULong sph_in_func_flags; /* flags to indicate if in */
- /* special functions */
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
/* We maintain two counters (in addition to the instruction counter) */
/* that act as loop detectors for LOOPCALL and jump opcodes with */
/* negative arguments. */
@@ -453,37 +386,29 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range );
-
-
- FT_LOCAL( FT_Error )
- Update_Max( FT_Memory memory,
- FT_ULong* size,
- FT_ULong multiplier,
- void* _pbuff,
- FT_ULong new_max );
#endif /* TT_USE_BYTECODE_INTERPRETER */
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_New_Context */
- /* */
- /* <Description> */
- /* Queries the face context for a given font. Note that there is */
- /* now a _single_ execution context in the TrueType driver which is */
- /* shared among faces. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* <Return> */
- /* A handle to the execution context. Initialized for `face'. */
- /* */
- /* <Note> */
- /* Only the glyph loader and debugger should call this function. */
- /* (And right now only the glyph loader uses it.) */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_New_Context
+ *
+ * @Description:
+ * Create a `TT_ExecContext`. Note that there is now an execution
+ * context per `TT_Size` that is not shared among faces.
+ *
+ * @Input:
+ * driver ::
+ * A handle to the driver, used for memory allocation.
+ *
+ * @Return:
+ * A handle to a new empty execution context.
+ *
+ * @Note:
+ * Only the glyph loader and debugger should call this function.
+ * (And right now only the glyph loader uses it.)
+ */
FT_EXPORT( TT_ExecContext )
TT_New_Context( TT_Driver driver );
@@ -506,29 +431,30 @@ FT_BEGIN_HEADER
#endif /* TT_USE_BYTECODE_INTERPRETER */
- /*************************************************************************/
- /* */
- /* <Function> */
- /* TT_RunIns */
- /* */
- /* <Description> */
- /* Executes one or more instruction in the execution context. This */
- /* is the main function of the TrueType opcode interpreter. */
- /* */
- /* <Input> */
- /* exec :: A handle to the target execution context. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Only the object manager and debugger should call this function. */
- /* */
- /* This function is publicly exported because it is directly */
- /* invoked by the TrueType debugger. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * TT_RunIns
+ *
+ * @Description:
+ * Executes one or more instruction in the execution context. This
+ * is the main function of the TrueType opcode interpreter.
+ *
+ * @Input:
+ * exec ::
+ * A handle to the target execution context.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ *
+ * @Note:
+ * Only the object manager and debugger should call this function.
+ *
+ * This function is publicly exported because it is directly
+ * invoked by the TrueType debugger.
+ */
FT_EXPORT( FT_Error )
- TT_RunIns( TT_ExecContext exec );
+ TT_RunIns( void* exec );
FT_END_HEADER
diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.c b/src/3rdparty/freetype/src/truetype/ttobjs.c
index 6685dc8196..5b56af711d 100644
--- a/src/3rdparty/freetype/src/truetype/ttobjs.c
+++ b/src/3rdparty/freetype/src/truetype/ttobjs.c
@@ -1,27 +1,26 @@
-/***************************************************************************/
-/* */
-/* ttobjs.c */
-/* */
-/* Objects manager (body). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_TRUETYPE_TAGS_H
-#include FT_INTERNAL_SFNT_H
-#include FT_DRIVER_H
+/****************************************************************************
+ *
+ * ttobjs.c
+ *
+ * Objects manager (body).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/tttags.h>
+#include <freetype/internal/sfnt.h>
+#include <freetype/ftdriver.h>
#include "ttgload.h"
#include "ttpload.h"
@@ -36,36 +35,37 @@
#include "ttgxvar.h"
#endif
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttobjs
+#define FT_COMPONENT ttobjs
#ifdef TT_USE_BYTECODE_INTERPRETER
- /*************************************************************************/
- /* */
- /* GLYPH ZONE FUNCTIONS */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_glyphzone_done */
- /* */
- /* <Description> */
- /* Deallocate a glyph zone. */
- /* */
- /* <Input> */
- /* zone :: A pointer to the target glyph zone. */
- /* */
+ /**************************************************************************
+ *
+ * GLYPH ZONE FUNCTIONS
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_glyphzone_done
+ *
+ * @Description:
+ * Deallocate a glyph zone.
+ *
+ * @Input:
+ * zone ::
+ * A pointer to the target glyph zone.
+ */
FT_LOCAL_DEF( void )
tt_glyphzone_done( TT_GlyphZone zone )
{
@@ -87,27 +87,31 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_glyphzone_new */
- /* */
- /* <Description> */
- /* Allocate a new glyph zone. */
- /* */
- /* <Input> */
- /* memory :: A handle to the current memory object. */
- /* */
- /* maxPoints :: The capacity of glyph zone in points. */
- /* */
- /* maxContours :: The capacity of glyph zone in contours. */
- /* */
- /* <Output> */
- /* zone :: A pointer to the target glyph zone record. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_glyphzone_new
+ *
+ * @Description:
+ * Allocate a new glyph zone.
+ *
+ * @Input:
+ * memory ::
+ * A handle to the current memory object.
+ *
+ * maxPoints ::
+ * The capacity of glyph zone in points.
+ *
+ * maxContours ::
+ * The capacity of glyph zone in contours.
+ *
+ * @Output:
+ * zone ::
+ * A pointer to the target glyph zone record.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_glyphzone_new( FT_Memory memory,
FT_UShort maxPoints,
@@ -136,18 +140,42 @@
return error;
}
-#endif /* TT_USE_BYTECODE_INTERPRETER */
+
+
+ /*
+ * Fonts embedded in PDFs are made unique by prepending randomization
+ * prefixes to their names: as defined in Section 5.5.3, 'Font Subsets',
+ * of the PDF Reference, they consist of 6 uppercase letters followed by
+ * the `+` sign. For safety, we do not skip prefixes violating this rule.
+ */
+
+ static const FT_String*
+ tt_skip_pdffont_random_tag( const FT_String* name )
+ {
+ unsigned int i;
+
+
+ if ( ft_strlen( name ) < 8 || name[6] != '+' )
+ return name;
+
+ for ( i = 0; i < 6; i++ )
+ if ( !ft_isupper( name[i] ) )
+ return name;
+
+ FT_TRACE7(( "name without randomization tag: %s\n", name + 7 ));
+ return name + 7;
+ }
/* Compare the face with a list of well-known `tricky' fonts. */
/* This list shall be expanded as we find more of them. */
static FT_Bool
- tt_check_trickyness_family( FT_String* name )
+ tt_check_trickyness_family( const FT_String* name )
{
#define TRICK_NAMES_MAX_CHARACTERS 19
-#define TRICK_NAMES_COUNT 26
+#define TRICK_NAMES_COUNT 20
static const char trick_names[TRICK_NAMES_COUNT]
[TRICK_NAMES_MAX_CHARACTERS + 1] =
@@ -167,22 +195,28 @@
"DFGirl-W6-WIN-BF", /* dftt-h6.ttf; version 1.00, 1993 */
"DFGothic-EB", /* DynaLab Inc. 1992-1995 */
"DFGyoSho-Lt", /* DynaLab Inc. 1992-1995 */
- "DFHei-Md-HK-BF", /* maybe DynaLab Inc. */
+ "DFHei", /* DynaLab Inc. 1992-1995 [DFHei-Bd-WIN-HK-BF] */
+ /* covers "DFHei-Md-HK-BF", maybe DynaLab Inc. */
+
"DFHSGothic-W5", /* DynaLab Inc. 1992-1995 */
"DFHSMincho-W3", /* DynaLab Inc. 1992-1995 */
"DFHSMincho-W7", /* DynaLab Inc. 1992-1995 */
"DFKaiSho-SB", /* dfkaisb.ttf */
- "DFKaiShu",
- "DFKaiShu-Md-HK-BF", /* maybe DynaLab Inc. */
+ "DFKaiShu", /* covers "DFKaiShu-Md-HK-BF", maybe DynaLab Inc. */
"DFKai-SB", /* kaiu.ttf; version 3.00, 1998 [DFKaiShu-SB-Estd-BF] */
- "DFMing-Bd-HK-BF", /* maybe DynaLab Inc. */
+
+ "DFMing", /* DynaLab Inc. 1992-1995 [DFMing-Md-WIN-HK-BF] */
+ /* covers "DFMing-Bd-HK-BF", maybe DynaLab Inc. */
+
"DLC", /* dftt-m7.ttf; version 1.00, 1993 [DLCMingBold] */
/* dftt-f5.ttf; version 1.00, 1993 [DLCFongSung] */
- "DLCHayMedium", /* dftt-b5.ttf; version 1.00, 1993 */
- "DLCHayBold", /* dftt-b7.ttf; version 1.00, 1993 */
- "DLCKaiMedium", /* dftt-k5.ttf; version 1.00, 1992 */
- "DLCLiShu", /* dftt-l5.ttf; version 1.00, 1992 */
- "DLCRoundBold", /* dftt-r7.ttf; version 1.00, 1993 */
+ /* covers following */
+ /* "DLCHayMedium", dftt-b5.ttf; version 1.00, 1993 */
+ /* "DLCHayBold", dftt-b7.ttf; version 1.00, 1993 */
+ /* "DLCKaiMedium", dftt-k5.ttf; version 1.00, 1992 */
+ /* "DLCLiShu", dftt-l5.ttf; version 1.00, 1992 */
+ /* "DLCRoundBold", dftt-r7.ttf; version 1.00, 1993 */
+
"HuaTianKaiTi?", /* htkt2.ttf */
"HuaTianSongTi?", /* htst3.ttf */
"Ming(for ISO10646)", /* hkscsiic.ttf; version 0.12, 2007 [Ming] */
@@ -195,10 +229,12 @@
};
int nn;
+ const FT_String* name_without_tag;
+ name_without_tag = tt_skip_pdffont_random_tag( name );
for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ )
- if ( ft_strstr( name, trick_names[nn] ) )
+ if ( ft_strstr( name_without_tag, trick_names[nn] ) )
return TRUE;
return FALSE;
@@ -273,10 +309,11 @@
tt_check_trickyness_sfnt_ids( TT_Face face )
{
#define TRICK_SFNT_IDS_PER_FACE 3
-#define TRICK_SFNT_IDS_NUM_FACES 29
+#define TRICK_SFNT_IDS_NUM_FACES 31
static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES]
- [TRICK_SFNT_IDS_PER_FACE] = {
+ [TRICK_SFNT_IDS_PER_FACE] =
+ {
#define TRICK_SFNT_ID_cvt 0
#define TRICK_SFNT_ID_fpgm 1
@@ -426,6 +463,16 @@
{ 0x00170003UL, 0x00000060UL }, /* cvt */
{ 0xDBB4306EUL, 0x000058AAUL }, /* fpgm */
{ 0xD643482AUL, 0x00000035UL } /* prep */
+ },
+ { /* DFHei-Bd-WIN-HK-BF, issue #1087 */
+ { 0x1269EB58UL, 0x00000350UL }, /* cvt */
+ { 0x5CD5957AUL, 0x00006A4EUL }, /* fpgm */
+ { 0xF758323AUL, 0x00000380UL } /* prep */
+ },
+ { /* DFMing-Md-WIN-HK-BF, issue #1087 */
+ { 0x122FEB0BUL, 0x00000350UL }, /* cvt */
+ { 0x7F10919AUL, 0x000070A9UL }, /* fpgm */
+ { 0x7CD7E7B7UL, 0x0000025CUL } /* prep */
}
};
@@ -506,17 +553,27 @@
/* For first, check the face name for quick check. */
if ( face->family_name &&
tt_check_trickyness_family( face->family_name ) )
+ {
+ FT_TRACE3(( "found as a tricky font"
+ " by its family name: %s\n", face->family_name ));
return TRUE;
+ }
/* Type42 fonts may lack `name' tables, we thus try to identify */
/* tricky fonts by checking the checksums of Type42-persistent */
/* sfnt tables (`cvt', `fpgm', and `prep'). */
if ( tt_check_trickyness_sfnt_ids( (TT_Face)face ) )
+ {
+ FT_TRACE3(( "found as a tricky font"
+ " by its cvt/fpgm/prep table checksum\n" ));
return TRUE;
+ }
return FALSE;
}
+#endif /* TT_USE_BYTECODE_INTERPRETER */
+
/* Check whether `.notdef' is the only glyph in the `loca' table. */
static FT_Bool
@@ -525,7 +582,7 @@
FT_Bool result = FALSE;
TT_Face face = (TT_Face)ttface;
- FT_UInt asize;
+ FT_ULong asize;
FT_ULong i;
FT_ULong glyph_index = 0;
FT_UInt count = 0;
@@ -533,7 +590,7 @@
for( i = 0; i < face->num_locations; i++ )
{
- tt_face_get_location( face, i, &asize );
+ tt_face_get_location( ttface, i, &asize );
if ( asize > 0 )
{
count += 1;
@@ -566,32 +623,37 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_init */
- /* */
- /* <Description> */
- /* Initialize a given TrueType face object. */
- /* */
- /* <Input> */
- /* stream :: The source font stream. */
- /* */
- /* face_index :: The index of the TrueType font, if we are opening a */
- /* collection, in bits 0-15. The numbered instance */
- /* index~+~1 of a GX (sub)font, if applicable, in bits */
- /* 16-30. */
- /* */
- /* num_params :: Number of additional generic parameters. Ignored. */
- /* */
- /* params :: Additional generic parameters. Ignored. */
- /* */
- /* <InOut> */
- /* face :: The newly built face object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_init
+ *
+ * @Description:
+ * Initialize a given TrueType face object.
+ *
+ * @Input:
+ * stream ::
+ * The source font stream.
+ *
+ * face_index ::
+ * The index of the TrueType font, if we are opening a
+ * collection, in bits 0-15. The numbered instance
+ * index~+~1 of a GX (sub)font, if applicable, in bits
+ * 16-30.
+ *
+ * num_params ::
+ * Number of additional generic parameters. Ignored.
+ *
+ * params ::
+ * Additional generic parameters. Ignored.
+ *
+ * @InOut:
+ * face ::
+ * The newly built face object.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_init( FT_Stream stream,
FT_Face ttface, /* TT_Face */
@@ -657,14 +719,17 @@
if ( error )
goto Exit;
+#ifdef TT_USE_BYTECODE_INTERPRETER
if ( tt_check_trickyness( ttface ) )
ttface->face_flags |= FT_FACE_FLAG_TRICKY;
+#endif
error = tt_face_load_hdmx( face, stream );
if ( error )
goto Exit;
- if ( FT_IS_SCALABLE( ttface ) )
+ if ( FT_IS_SCALABLE( ttface ) ||
+ FT_HAS_SBIX( ttface ) )
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( !ttface->internal->incremental_interface )
@@ -703,8 +768,8 @@
tt_check_single_notdef( ttface ) )
{
FT_TRACE5(( "tt_face_init:"
- " Only the `.notdef' glyph has an outline.\n"
- " "
+ " Only the `.notdef' glyph has an outline.\n" ));
+ FT_TRACE5(( " "
" Resetting scalable flag to FALSE.\n" ));
ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
@@ -713,7 +778,6 @@
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
{
FT_UInt instance_index = (FT_UInt)face_index >> 16;
@@ -721,14 +785,11 @@
if ( FT_HAS_MULTIPLE_MASTERS( ttface ) &&
instance_index > 0 )
{
- error = TT_Set_Named_Instance( face, instance_index );
+ error = FT_Set_Named_Instance( ttface, instance_index );
if ( error )
goto Exit;
-
- tt_apply_mvar( face );
}
}
-
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
/* initialize standard glyph loading routines */
@@ -743,17 +804,18 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_done */
- /* */
- /* <Description> */
- /* Finalize a given face object. */
- /* */
- /* <Input> */
- /* face :: A pointer to the face object to destroy. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_done
+ *
+ * @Description:
+ * Finalize a given face object.
+ *
+ * @Input:
+ * face ::
+ * A pointer to the face object to destroy.
+ */
FT_LOCAL_DEF( void )
tt_face_done( FT_Face ttface ) /* TT_Face */
{
@@ -793,36 +855,38 @@
face->cvt_program_size = 0;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- tt_done_blend( face );
+ tt_done_blend( ttface );
face->blend = NULL;
#endif
}
- /*************************************************************************/
- /* */
- /* SIZE FUNCTIONS */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * SIZE FUNCTIONS
+ *
+ */
#ifdef TT_USE_BYTECODE_INTERPRETER
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_size_run_fpgm */
- /* */
- /* <Description> */
- /* Run the font program. */
- /* */
- /* <Input> */
- /* size :: A handle to the size object. */
- /* */
- /* pedantic :: Set if bytecode execution should be pedantic. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_size_run_fpgm
+ *
+ * @Description:
+ * Run the font program.
+ *
+ * @Input:
+ * size ::
+ * A handle to the size object.
+ *
+ * pedantic ::
+ * Set if bytecode execution should be pedantic.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_size_run_fpgm( TT_Size size,
FT_Bool pedantic )
@@ -899,22 +963,24 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_size_run_prep */
- /* */
- /* <Description> */
- /* Run the control value program. */
- /* */
- /* <Input> */
- /* size :: A handle to the size object. */
- /* */
- /* pedantic :: Set if bytecode execution should be pedantic. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_size_run_prep
+ *
+ * @Description:
+ * Run the control value program.
+ *
+ * @Input:
+ * size ::
+ * A handle to the size object.
+ *
+ * pedantic ::
+ * Set if bytecode execution should be pedantic.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_size_run_prep( TT_Size size,
FT_Bool pedantic )
@@ -922,8 +988,23 @@
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
FT_Error error;
+ FT_UInt i;
+
+ /* unscaled CVT values are already stored in 26.6 format */
+ FT_Fixed scale = size->ttmetrics.scale >> 6;
+ /* Scale the cvt values to the new ppem. */
+ /* By default, we use the y ppem value for scaling. */
+ FT_TRACE6(( "CVT values:\n" ));
+ for ( i = 0; i < size->cvt_size; i++ )
+ {
+ size->cvt[i] = FT_MulFix( face->cvt[i], scale );
+ FT_TRACE6(( " %3d: %f (%f)\n",
+ i, (double)face->cvt[i] / 64, (double)size->cvt[i] / 64 ));
+ }
+ FT_TRACE6(( "\n" ));
+
exec = size->context;
error = TT_Load_Context( exec, face, size );
@@ -1079,11 +1160,17 @@
tt_metrics->rotated = FALSE;
tt_metrics->stretched = FALSE;
- /* set default engine compensation */
- tt_metrics->compensations[0] = 0; /* gray */
- tt_metrics->compensations[1] = 0; /* black */
- tt_metrics->compensations[2] = 0; /* white */
- tt_metrics->compensations[3] = 0; /* reserved */
+ /* Set default engine compensation. Value 3 is not described */
+ /* in the OpenType specification (as of Mai 2019), but Greg */
+ /* says that MS handles it the same as `gray'. */
+ /* */
+ /* The Apple specification says that the compensation for */
+ /* `gray' is always zero. FreeType doesn't do any */
+ /* compensation at all. */
+ tt_metrics->compensations[0] = 0; /* gray */
+ tt_metrics->compensations[1] = 0; /* black */
+ tt_metrics->compensations[2] = 0; /* white */
+ tt_metrics->compensations[3] = 0; /* zero */
}
/* allocate function defs, instruction defs, cvt, and storage area */
@@ -1155,17 +1242,11 @@
/* rescale CVT when needed */
if ( size->cvt_ready < 0 )
{
- FT_UInt i;
- TT_Face face = (TT_Face)size->root.face;
-
+ FT_UShort i;
- /* Scale the cvt values to the new ppem. */
- /* We use by default the y ppem to scale the CVT. */
- for ( i = 0; i < size->cvt_size; i++ )
- size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
/* all twilight points are originally zero */
- for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
+ for ( i = 0; i < size->twilight.n_points; i++ )
{
size->twilight.org[i].x = 0;
size->twilight.org[i].y = 0;
@@ -1174,7 +1255,7 @@
}
/* clear storage area */
- for ( i = 0; i < (FT_UInt)size->storage_size; i++ )
+ for ( i = 0; i < size->storage_size; i++ )
size->storage[i] = 0;
size->GS = tt_default_graphics_state;
@@ -1191,20 +1272,21 @@
#endif /* TT_USE_BYTECODE_INTERPRETER */
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_size_init */
- /* */
- /* <Description> */
- /* Initialize a new TrueType size object. */
- /* */
- /* <InOut> */
- /* size :: A handle to the size object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_size_init
+ *
+ * @Description:
+ * Initialize a new TrueType size object.
+ *
+ * @InOut:
+ * size ::
+ * A handle to the size object.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_size_init( FT_Size ttsize ) /* TT_Size */
{
@@ -1224,17 +1306,18 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_size_done */
- /* */
- /* <Description> */
- /* The TrueType size object finalizer. */
- /* */
- /* <Input> */
- /* size :: A handle to the target size object. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_size_done
+ *
+ * @Description:
+ * The TrueType size object finalizer.
+ *
+ * @Input:
+ * size ::
+ * A handle to the target size object.
+ */
FT_LOCAL_DEF( void )
tt_size_done( FT_Size ttsize ) /* TT_Size */
{
@@ -1249,40 +1332,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_size_reset */
- /* */
- /* <Description> */
- /* Reset a TrueType size when resolutions and character dimensions */
- /* have been changed. */
- /* */
- /* <Input> */
- /* size :: A handle to the target size object. */
- /* */
- /* only_height :: Only recompute ascender, descender, and height; */
- /* this flag is used for variation fonts where */
- /* `tt_size_reset' is used as an iterator function. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_size_reset_height
+ *
+ * @Description:
+ * Recompute a TrueType size's ascender, descender, and height
+ * when resolutions and character dimensions have been changed.
+ * Used for variation fonts as an iterator function.
+ *
+ * @Input:
+ * ft_size ::
+ * A handle to the target TT_Size object. This function will be called
+ * through a `FT_Size_Reset_Func` pointer which takes `FT_Size`. This
+ * function must take `FT_Size` as a result. The passed `FT_Size` is
+ * expected to point to a `TT_Size`.
+ */
FT_LOCAL_DEF( FT_Error )
- tt_size_reset( TT_Size size,
- FT_Bool only_height )
+ tt_size_reset_height( FT_Size ft_size )
{
- TT_Face face;
- FT_Size_Metrics* size_metrics;
-
-
- face = (TT_Face)size->root.face;
-
- /* nothing to do for CFF2 */
- if ( face->is_cff2 )
- return FT_Err_Ok;
+ TT_Size size = (TT_Size)ft_size;
+ TT_Face face = (TT_Face)size->root.face;
+ FT_Size_Metrics* size_metrics = &size->hinted_metrics;
size->ttmetrics.valid = FALSE;
- size_metrics = &size->hinted_metrics;
-
/* copy the result from base layer */
*size_metrics = size->root.metrics;
@@ -1309,12 +1384,34 @@
size->ttmetrics.valid = TRUE;
- if ( only_height )
- {
- /* we must not recompute the scaling values here since */
- /* `tt_size_reset' was already called (with only_height = 0) */
- return FT_Err_Ok;
- }
+ return FT_Err_Ok;
+ }
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_size_reset
+ *
+ * @Description:
+ * Reset a TrueType size when resolutions and character dimensions
+ * have been changed.
+ *
+ * @Input:
+ * size ::
+ * A handle to the target size object.
+ */
+ FT_LOCAL_DEF( FT_Error )
+ tt_size_reset( TT_Size size )
+ {
+ FT_Error error;
+ TT_Face face = (TT_Face)size->root.face;
+ FT_Size_Metrics* size_metrics = &size->hinted_metrics;
+
+
+ error = tt_size_reset_height( (FT_Size)size );
+ if ( error )
+ return error;
if ( face->header.Flags & 8 )
{
@@ -1348,6 +1445,8 @@
size->ttmetrics.y_ratio = 0x10000L;
}
+ size->widthp = tt_face_get_device_metrics( face, size_metrics->x_ppem, 0 );
+
size->metrics = size_metrics;
#ifdef TT_USE_BYTECODE_INTERPRETER
@@ -1358,20 +1457,21 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_driver_init */
- /* */
- /* <Description> */
- /* Initialize a given TrueType driver object. */
- /* */
- /* <Input> */
- /* driver :: A handle to the target driver object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_driver_init
+ *
+ * @Description:
+ * Initialize a given TrueType driver object.
+ *
+ * @Input:
+ * driver ::
+ * A handle to the target driver object.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_driver_init( FT_Module ttdriver ) /* TT_Driver */
{
@@ -1381,9 +1481,6 @@
TT_Driver driver = (TT_Driver)ttdriver;
driver->interpreter_version = TT_INTERPRETER_VERSION_35;
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- driver->interpreter_version = TT_INTERPRETER_VERSION_38;
-#endif
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
driver->interpreter_version = TT_INTERPRETER_VERSION_40;
#endif
@@ -1398,17 +1495,18 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_driver_done */
- /* */
- /* <Description> */
- /* Finalize a given TrueType driver. */
- /* */
- /* <Input> */
- /* driver :: A handle to the target TrueType driver. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_driver_done
+ *
+ * @Description:
+ * Finalize a given TrueType driver.
+ *
+ * @Input:
+ * driver ::
+ * A handle to the target TrueType driver.
+ */
FT_LOCAL_DEF( void )
tt_driver_done( FT_Module ttdriver ) /* TT_Driver */
{
@@ -1416,20 +1514,21 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_slot_init */
- /* */
- /* <Description> */
- /* Initialize a new slot object. */
- /* */
- /* <InOut> */
- /* slot :: A handle to the slot object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_slot_init
+ *
+ * @Description:
+ * Initialize a new slot object.
+ *
+ * @InOut:
+ * slot ::
+ * A handle to the slot object.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_slot_init( FT_GlyphSlot slot )
{
diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.h b/src/3rdparty/freetype/src/truetype/ttobjs.h
index 38fa30e4e9..40eb37b4c4 100644
--- a/src/3rdparty/freetype/src/truetype/ttobjs.h
+++ b/src/3rdparty/freetype/src/truetype/ttobjs.h
@@ -1,67 +1,66 @@
-/***************************************************************************/
-/* */
-/* ttobjs.h */
-/* */
-/* Objects manager (specification). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttobjs.h
+ *
+ * Objects manager (specification).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef TTOBJS_H_
#define TTOBJS_H_
-#include <ft2build.h>
-#include FT_INTERNAL_OBJECTS_H
-#include FT_INTERNAL_TRUETYPE_TYPES_H
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/tttypes.h>
FT_BEGIN_HEADER
- /*************************************************************************/
- /* */
- /* <Type> */
- /* TT_Driver */
- /* */
- /* <Description> */
- /* A handle to a TrueType driver object. */
- /* */
+ /**************************************************************************
+ *
+ * @Type:
+ * TT_Driver
+ *
+ * @Description:
+ * A handle to a TrueType driver object.
+ */
typedef struct TT_DriverRec_* TT_Driver;
- /*************************************************************************/
- /* */
- /* <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. */
- /* */
+ /**************************************************************************
+ *
+ * @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 */
- /* */
- /* <Description> */
- /* The TrueType graphics state used during bytecode interpretation. */
- /* */
+ /**************************************************************************
+ *
+ * @Struct:
+ * TT_GraphicsState
+ *
+ * @Description:
+ * The TrueType graphics state used during bytecode interpretation.
+ */
typedef struct TT_GraphicsState_
{
FT_UShort rp0;
@@ -113,25 +112,25 @@ FT_BEGIN_HEADER
- /*************************************************************************/
- /* */
- /* EXECUTION SUBTABLES */
- /* */
- /* These sub-tables relate to instruction execution. */
- /* */
- /*************************************************************************/
+ /**************************************************************************
+ *
+ * EXECUTION SUBTABLES
+ *
+ * These sub-tables relate to instruction execution.
+ *
+ */
#define TT_MAX_CODE_RANGES 3
- /*************************************************************************/
- /* */
- /* There can only be 3 active code ranges at once: */
- /* - the Font Program */
- /* - the CVT Program */
- /* - a glyph's instructions set */
- /* */
+ /**************************************************************************
+ *
+ * There can only be 3 active code ranges at once:
+ * - the Font Program
+ * - the CVT Program
+ * - a glyph's instructions set
+ */
typedef enum TT_CodeRange_Tag_
{
tt_coderange_none = 0,
@@ -152,10 +151,10 @@ FT_BEGIN_HEADER
typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
- /*************************************************************************/
- /* */
- /* Defines a function/instruction definition record. */
- /* */
+ /**************************************************************************
+ *
+ * Defines a function/instruction definition record.
+ */
typedef struct TT_DefRecord_
{
FT_Int range; /* in which code range is it located? */
@@ -163,16 +162,14 @@ FT_BEGIN_HEADER
FT_Long end; /* where does it end? */
FT_UInt opc; /* function #, or instruction code */
FT_Bool active; /* is it active? */
- FT_Bool inline_delta; /* is function that defines inline delta? */
- FT_ULong sph_fdef_flags; /* flags to identify special functions */
} TT_DefRecord, *TT_DefArray;
- /*************************************************************************/
- /* */
- /* Subglyph transformation record. */
- /* */
+ /**************************************************************************
+ *
+ * Subglyph transformation record.
+ */
typedef struct TT_Transform_
{
FT_Fixed xx, xy; /* transformation matrix coefficients */
@@ -182,72 +179,72 @@ FT_BEGIN_HEADER
} TT_Transform;
- /*************************************************************************/
- /* */
- /* A note regarding non-squared pixels: */
- /* */
- /* (This text will probably go into some docs at some time; for now, it */
- /* is kept here to explain some definitions in the TT_Size_Metrics */
- /* record). */
- /* */
- /* The CVT is a one-dimensional array containing values that control */
- /* certain important characteristics in a font, like the height of all */
- /* capitals, all lowercase letter, default spacing or stem width/height. */
- /* */
- /* These values are found in FUnits in the font file, and must be scaled */
- /* to pixel coordinates before being used by the CVT and glyph programs. */
- /* Unfortunately, when using distinct x and y resolutions (or distinct x */
- /* and y pointsizes), there are two possible scalings. */
- /* */
- /* A first try was to implement a `lazy' scheme where all values were */
- /* scaled when first used. However, while some values are always used */
- /* in the same direction, some others are used under many different */
- /* circumstances and orientations. */
- /* */
- /* I have found a simpler way to do the same, and it even seems to work */
- /* in most of the cases: */
- /* */
- /* - All CVT values are scaled to the maximum ppem size. */
- /* */
- /* - When performing a read or write in the CVT, a ratio factor is used */
- /* to perform adequate scaling. Example: */
- /* */
- /* x_ppem = 14 */
- /* y_ppem = 10 */
- /* */
- /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
- /* entries are scaled to it. */
- /* */
- /* x_ratio = 1.0 */
- /* y_ratio = y_ppem/ppem (< 1.0) */
- /* */
- /* We compute the current ratio like: */
- /* */
- /* - If projVector is horizontal, */
- /* ratio = x_ratio = 1.0 */
- /* */
- /* - if projVector is vertical, */
- /* ratio = y_ratio */
- /* */
- /* - else, */
- /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
- /* */
- /* Reading a cvt value returns */
- /* ratio * cvt[index] */
- /* */
- /* Writing a cvt value in pixels: */
- /* cvt[index] / ratio */
- /* */
- /* The current ppem is simply */
- /* ratio * ppem */
- /* */
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* Metrics used by the TrueType size and context objects. */
- /* */
+ /**************************************************************************
+ *
+ * A note regarding non-squared pixels:
+ *
+ * (This text will probably go into some docs at some time; for now, it
+ * is kept here to explain some definitions in the TT_Size_Metrics
+ * record).
+ *
+ * The CVT is a one-dimensional array containing values that control
+ * certain important characteristics in a font, like the height of all
+ * capitals, all lowercase letter, default spacing or stem width/height.
+ *
+ * These values are found in FUnits in the font file, and must be scaled
+ * to pixel coordinates before being used by the CVT and glyph programs.
+ * Unfortunately, when using distinct x and y resolutions (or distinct x
+ * and y pointsizes), there are two possible scalings.
+ *
+ * A first try was to implement a `lazy' scheme where all values were
+ * scaled when first used. However, while some values are always used
+ * in the same direction, some others are used under many different
+ * circumstances and orientations.
+ *
+ * I have found a simpler way to do the same, and it even seems to work
+ * in most of the cases:
+ *
+ * - All CVT values are scaled to the maximum ppem size.
+ *
+ * - When performing a read or write in the CVT, a ratio factor is used
+ * to perform adequate scaling. Example:
+ *
+ * x_ppem = 14
+ * y_ppem = 10
+ *
+ * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt
+ * entries are scaled to it.
+ *
+ * x_ratio = 1.0
+ * y_ratio = y_ppem/ppem (< 1.0)
+ *
+ * We compute the current ratio like:
+ *
+ * - If projVector is horizontal,
+ * ratio = x_ratio = 1.0
+ *
+ * - if projVector is vertical,
+ * ratio = y_ratio
+ *
+ * - else,
+ * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 )
+ *
+ * Reading a cvt value returns
+ * ratio * cvt[index]
+ *
+ * Writing a cvt value in pixels:
+ * cvt[index] / ratio
+ *
+ * The current ppem is simply
+ * ratio * ppem
+ *
+ */
+
+
+ /**************************************************************************
+ *
+ * Metrics used by the TrueType size and context objects.
+ */
typedef struct TT_Size_Metrics_
{
/* for non-square pixels */
@@ -268,10 +265,10 @@ FT_BEGIN_HEADER
} TT_Size_Metrics;
- /*************************************************************************/
- /* */
- /* TrueType size class. */
- /* */
+ /**************************************************************************
+ *
+ * TrueType size class.
+ */
typedef struct TT_SizeRec_
{
FT_SizeRec root;
@@ -283,6 +280,8 @@ FT_BEGIN_HEADER
TT_Size_Metrics ttmetrics;
+ FT_Byte* widthp; /* glyph widths from the hdmx table */
+
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
#ifdef TT_USE_BYTECODE_INTERPRETER
@@ -324,10 +323,10 @@ FT_BEGIN_HEADER
} TT_SizeRec;
- /*************************************************************************/
- /* */
- /* TrueType driver class. */
- /* */
+ /**************************************************************************
+ *
+ * TrueType driver class.
+ */
typedef struct TT_DriverRec_
{
FT_DriverRec root;
@@ -348,10 +347,10 @@ FT_BEGIN_HEADER
/* will always use the TT driver to create them. */
- /*************************************************************************/
- /* */
- /* Face functions */
- /* */
+ /**************************************************************************
+ *
+ * Face functions
+ */
FT_LOCAL( FT_Error )
tt_face_init( FT_Stream stream,
FT_Face ttface, /* TT_Face */
@@ -363,10 +362,10 @@ FT_BEGIN_HEADER
tt_face_done( FT_Face ttface ); /* TT_Face */
- /*************************************************************************/
- /* */
- /* Size functions */
- /* */
+ /**************************************************************************
+ *
+ * Size functions
+ */
FT_LOCAL( FT_Error )
tt_size_init( FT_Size ttsize ); /* TT_Size */
@@ -390,14 +389,16 @@ FT_BEGIN_HEADER
#endif /* TT_USE_BYTECODE_INTERPRETER */
FT_LOCAL( FT_Error )
- tt_size_reset( TT_Size size,
- FT_Bool only_height );
+ tt_size_reset_height( FT_Size size );
+
+ FT_LOCAL( FT_Error )
+ tt_size_reset( TT_Size size );
- /*************************************************************************/
- /* */
- /* Driver functions */
- /* */
+ /**************************************************************************
+ *
+ * Driver functions
+ */
FT_LOCAL( FT_Error )
tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
@@ -405,10 +406,10 @@ FT_BEGIN_HEADER
tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
- /*************************************************************************/
- /* */
- /* Slot functions */
- /* */
+ /**************************************************************************
+ *
+ * Slot functions
+ */
FT_LOCAL( FT_Error )
tt_slot_init( FT_GlyphSlot slot );
diff --git a/src/3rdparty/freetype/src/truetype/ttpic.c b/src/3rdparty/freetype/src/truetype/ttpic.c
deleted file mode 100644
index cdbb80639e..0000000000
--- a/src/3rdparty/freetype/src/truetype/ttpic.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/***************************************************************************/
-/* */
-/* ttpic.c */
-/* */
-/* The FreeType position independent code services for truetype module. */
-/* */
-/* Copyright 2009-2018 by */
-/* Oran Agra and Mickey Gabel. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_INTERNAL_OBJECTS_H
-#include "ttpic.h"
-#include "tterrors.h"
-
-
-#ifdef FT_CONFIG_OPTION_PIC
-
- /* forward declaration of PIC init functions from ttdriver.c */
- FT_Error
- FT_Create_Class_tt_services( FT_Library library,
- FT_ServiceDescRec** output_class );
- void
- FT_Destroy_Class_tt_services( FT_Library library,
- FT_ServiceDescRec* clazz );
- void
- FT_Init_Class_tt_service_gx_multi_masters(
- FT_Service_MultiMastersRec* sv_mm );
- void
- FT_Init_Class_tt_service_truetype_glyf(
- FT_Service_TTGlyfRec* sv_ttglyf );
-
-
- void
- tt_driver_class_pic_free( FT_Library library )
- {
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
-
-
- if ( pic_container->truetype )
- {
- TTModulePIC* container = (TTModulePIC*)pic_container->truetype;
-
-
- if ( container->tt_services )
- FT_Destroy_Class_tt_services( library, container->tt_services );
- container->tt_services = NULL;
- FT_FREE( container );
- pic_container->truetype = NULL;
- }
- }
-
-
- FT_Error
- tt_driver_class_pic_init( FT_Library library )
- {
- FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = FT_Err_Ok;
- TTModulePIC* container = NULL;
- FT_Memory memory = library->memory;
-
-
- /* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC( container, sizeof ( *container ) ) )
- return error;
- FT_MEM_SET( container, 0, sizeof ( *container ) );
- pic_container->truetype = container;
-
- /* initialize pointer table - this is how the module usually */
- /* expects this data */
- error = FT_Create_Class_tt_services( library,
- &container->tt_services );
- if ( error )
- goto Exit;
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_Init_Class_tt_service_gx_multi_masters(
- &container->tt_service_gx_multi_masters );
-#endif
- FT_Init_Class_tt_service_truetype_glyf(
- &container->tt_service_truetype_glyf );
-
- Exit:
- if ( error )
- tt_driver_class_pic_free( library );
- return error;
- }
-
-#endif /* FT_CONFIG_OPTION_PIC */
-
-
-/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttpic.h b/src/3rdparty/freetype/src/truetype/ttpic.h
deleted file mode 100644
index df878ae6f1..0000000000
--- a/src/3rdparty/freetype/src/truetype/ttpic.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************/
-/* */
-/* ttpic.h */
-/* */
-/* The FreeType position independent code services for truetype module. */
-/* */
-/* Copyright 2009-2018 by */
-/* Oran Agra and Mickey Gabel. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef TTPIC_H_
-#define TTPIC_H_
-
-
-#include FT_INTERNAL_PIC_H
-
-
-#ifndef FT_CONFIG_OPTION_PIC
-
-#define TT_SERVICES_GET tt_services
-#define TT_SERVICE_GX_MULTI_MASTERS_GET tt_service_gx_multi_masters
-#define TT_SERVICE_METRICS_VARIATIONS_GET tt_service_metrics_variations
-#define TT_SERVICE_TRUETYPE_GLYF_GET tt_service_truetype_glyf
-#define TT_SERVICE_PROPERTIES_GET tt_service_properties
-
-#else /* FT_CONFIG_OPTION_PIC */
-
-#include FT_MULTIPLE_MASTERS_H
-#include FT_SERVICE_MULTIPLE_MASTERS_H
-#include FT_SERVICE_METRICS_VARIATIONS_H
-#include FT_SERVICE_TRUETYPE_GLYF_H
-#include FT_SERVICE_PROPERTIES_H
-
-
-FT_BEGIN_HEADER
-
- typedef struct TTModulePIC_
- {
- FT_ServiceDescRec* tt_services;
-#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_Service_MultiMastersRec tt_service_gx_multi_masters;
- FT_Service_MetricsVariationsRec tt_service_metrics_variations;
-#endif
- FT_Service_TTGlyfRec tt_service_truetype_glyf;
- FT_Service_PropertiesRec tt_service_properties;
-
- } TTModulePIC;
-
-
-#define GET_PIC( lib ) \
- ( (TTModulePIC*)((lib)->pic_container.truetype) )
-#define TT_SERVICES_GET \
- ( GET_PIC( library )->tt_services )
-#define TT_SERVICE_METRICS_VARIATIONS_GET \
- ( GET_PIC( library )->tt_service_metrics_variations )
-#define TT_SERVICE_GX_MULTI_MASTERS_GET \
- ( GET_PIC( library )->tt_service_gx_multi_masters )
-#define TT_SERVICE_TRUETYPE_GLYF_GET \
- ( GET_PIC( library )->tt_service_truetype_glyf )
-#define TT_SERVICE_PROPERTIES_GET \
- ( GET_PIC( library )->tt_service_properties )
-
-
- /* see ttpic.c for the implementation */
- void
- tt_driver_class_pic_free( FT_Library library );
-
- FT_Error
- tt_driver_class_pic_init( FT_Library library );
-
-FT_END_HEADER
-
-#endif /* FT_CONFIG_OPTION_PIC */
-
- /* */
-
-#endif /* TTPIC_H_ */
-
-
-/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttpload.c b/src/3rdparty/freetype/src/truetype/ttpload.c
index d9526ad082..54a64c7b46 100644
--- a/src/3rdparty/freetype/src/truetype/ttpload.c
+++ b/src/3rdparty/freetype/src/truetype/ttpload.c
@@ -1,26 +1,25 @@
-/***************************************************************************/
-/* */
-/* ttpload.c */
-/* */
-/* TrueType-specific tables loader (body). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_OBJECTS_H
-#include FT_INTERNAL_STREAM_H
-#include FT_TRUETYPE_TAGS_H
+/****************************************************************************
+ *
+ * ttpload.c
+ *
+ * TrueType-specific tables loader (body).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/tttags.h>
#include "ttpload.h"
@@ -31,33 +30,35 @@
#include "tterrors.h"
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
+ /**************************************************************************
+ *
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
+ * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
+ * messages during execution.
+ */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_ttpload
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_loca */
- /* */
- /* <Description> */
- /* Load the locations table. */
- /* */
- /* <InOut> */
- /* face :: A handle to the target face object. */
- /* */
- /* <Input> */
- /* stream :: The input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+#define FT_COMPONENT ttpload
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_loca
+ *
+ * @Description:
+ * Load the locations table.
+ *
+ * @InOut:
+ * face ::
+ * A handle to the target face object.
+ *
+ * @Input:
+ * stream ::
+ * The input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_loca( TT_Face face,
FT_Stream stream )
@@ -97,36 +98,23 @@
goto Exit;
}
- if ( face->header.Index_To_Loc_Format != 0 )
- {
- shift = 2;
+ shift = face->header.Index_To_Loc_Format != 0 ? 2 : 1;
- if ( table_len >= 0x40000L )
- {
- FT_TRACE2(( "table too large\n" ));
- table_len = 0x3FFFFL;
- }
- face->num_locations = table_len >> shift;
- }
- else
+ if ( table_len > 0x10000UL << shift )
{
- shift = 1;
-
- if ( table_len >= 0x20000L )
- {
- FT_TRACE2(( "table too large\n" ));
- table_len = 0x1FFFFL;
- }
- face->num_locations = table_len >> shift;
+ FT_TRACE2(( "table too large\n" ));
+ table_len = 0x10000UL << shift;
}
+ face->num_locations = table_len >> shift;
+
if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 )
{
- FT_TRACE2(( "glyph count mismatch! loca: %d, maxp: %d\n",
+ FT_TRACE2(( "glyph count mismatch! loca: %ld, maxp: %ld\n",
face->num_locations - 1, face->root.num_glyphs ));
/* we only handle the case where `maxp' gives a larger value */
- if ( face->num_locations <= (FT_ULong)face->root.num_glyphs )
+ if ( face->num_locations < (FT_ULong)face->root.num_glyphs + 1 )
{
FT_ULong new_loca_len =
( (FT_ULong)face->root.num_glyphs + 1 ) << shift;
@@ -163,7 +151,7 @@
face->num_locations = (FT_ULong)face->root.num_glyphs + 1;
table_len = new_loca_len;
- FT_TRACE2(( "adjusting num_locations to %d\n",
+ FT_TRACE2(( "adjusting num_locations to %ld\n",
face->num_locations ));
}
else
@@ -171,7 +159,7 @@
face->root.num_glyphs = face->num_locations
? (FT_Long)face->num_locations - 1 : 0;
- FT_TRACE2(( "adjusting num_glyphs to %d\n",
+ FT_TRACE2(( "adjusting num_glyphs to %ld\n",
face->root.num_glyphs ));
}
}
@@ -192,10 +180,11 @@
FT_LOCAL_DEF( FT_ULong )
- tt_face_get_location( TT_Face face,
- FT_UInt gindex,
- FT_UInt *asize )
+ tt_face_get_location( FT_Face face, /* TT_Face */
+ FT_UInt gindex,
+ FT_ULong *asize )
{
+ TT_Face ttface = (TT_Face)face;
FT_ULong pos1, pos2;
FT_Byte* p;
FT_Byte* p_limit;
@@ -203,12 +192,12 @@
pos1 = pos2 = 0;
- if ( gindex < face->num_locations )
+ if ( gindex < ttface->num_locations )
{
- if ( face->header.Index_To_Loc_Format != 0 )
+ if ( ttface->header.Index_To_Loc_Format != 0 )
{
- p = face->glyph_locations + gindex * 4;
- p_limit = face->glyph_locations + face->num_locations * 4;
+ p = ttface->glyph_locations + gindex * 4;
+ p_limit = ttface->glyph_locations + ttface->num_locations * 4;
pos1 = FT_NEXT_ULONG( p );
pos2 = pos1;
@@ -218,8 +207,8 @@
}
else
{
- p = face->glyph_locations + gindex * 2;
- p_limit = face->glyph_locations + face->num_locations * 2;
+ p = ttface->glyph_locations + gindex * 2;
+ p_limit = ttface->glyph_locations + ttface->num_locations * 2;
pos1 = FT_NEXT_USHORT( p );
pos2 = pos1;
@@ -233,36 +222,39 @@
}
/* Check broken location data. */
- if ( pos1 > face->glyf_len )
+ if ( pos1 > ttface->glyf_len )
{
FT_TRACE1(( "tt_face_get_location:"
- " too large offset (0x%08lx) found for glyph index %ld,\n"
- " "
+ " too large offset (0x%08lx) found for glyph index %d,\n",
+ pos1, gindex ));
+ FT_TRACE1(( " "
" exceeding the end of `glyf' table (0x%08lx)\n",
- pos1, gindex, face->glyf_len ));
+ ttface->glyf_len ));
*asize = 0;
return 0;
}
- if ( pos2 > face->glyf_len )
+ if ( pos2 > ttface->glyf_len )
{
/* We try to sanitize the last `loca' entry. */
- if ( gindex == face->num_locations - 2 )
+ if ( gindex == ttface->num_locations - 2 )
{
FT_TRACE1(( "tt_face_get_location:"
- " too large size (%ld bytes) found for glyph index %ld,\n"
- " "
+ " too large size (%ld bytes) found for glyph index %d,\n",
+ pos2 - pos1, gindex ));
+ FT_TRACE1(( " "
" truncating at the end of `glyf' table to %ld bytes\n",
- pos2 - pos1, gindex, face->glyf_len - pos1 ));
- pos2 = face->glyf_len;
+ ttface->glyf_len - pos1 ));
+ pos2 = ttface->glyf_len;
}
else
{
FT_TRACE1(( "tt_face_get_location:"
- " too large offset (0x%08lx) found for glyph index %ld,\n"
- " "
+ " too large offset (0x%08lx) found for glyph index %d,\n",
+ pos2, gindex + 1 ));
+ FT_TRACE1(( " "
" exceeding the end of `glyf' table (0x%08lx)\n",
- pos2, gindex + 1, face->glyf_len ));
+ ttface->glyf_len ));
*asize = 0;
return 0;
}
@@ -277,9 +269,9 @@
/* We get (intentionally) a wrong, non-zero result in case the */
/* `glyf' table is missing. */
if ( pos2 >= pos1 )
- *asize = (FT_UInt)( pos2 - pos1 );
+ *asize = (FT_ULong)( pos2 - pos1 );
else
- *asize = (FT_UInt)( face->glyf_len - pos1 );
+ *asize = (FT_ULong)( ttface->glyf_len - pos1 );
return pos1;
}
@@ -297,23 +289,25 @@
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_cvt */
- /* */
- /* <Description> */
- /* Load the control value table into a face object. */
- /* */
- /* <InOut> */
- /* face :: A handle to the target face object. */
- /* */
- /* <Input> */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_cvt
+ *
+ * @Description:
+ * Load the control value table into a face object.
+ *
+ * @InOut:
+ * face ::
+ * A handle to the target face object.
+ *
+ * @Input:
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_cvt( TT_Face face,
FT_Stream stream )
@@ -341,19 +335,19 @@
face->cvt_size = table_len / 2;
- if ( FT_NEW_ARRAY( face->cvt, face->cvt_size ) )
+ if ( FT_QNEW_ARRAY( face->cvt, face->cvt_size ) )
goto Exit;
if ( FT_FRAME_ENTER( face->cvt_size * 2L ) )
goto Exit;
{
- FT_Short* cur = face->cvt;
- FT_Short* limit = cur + face->cvt_size;
+ FT_Int32* cur = face->cvt;
+ FT_Int32* limit = cur + face->cvt_size;
for ( ; cur < limit; cur++ )
- *cur = FT_GET_SHORT();
+ *cur = FT_GET_SHORT() * 64;
}
FT_FRAME_EXIT();
@@ -378,23 +372,25 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_fpgm */
- /* */
- /* <Description> */
- /* Load the font program. */
- /* */
- /* <InOut> */
- /* face :: A handle to the target face object. */
- /* */
- /* <Input> */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_fpgm
+ *
+ * @Description:
+ * Load the font program.
+ *
+ * @InOut:
+ * face ::
+ * A handle to the target face object.
+ *
+ * @Input:
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_fpgm( TT_Face face,
FT_Stream stream )
@@ -423,7 +419,7 @@
if ( FT_FRAME_EXTRACT( table_len, face->font_program ) )
goto Exit;
- FT_TRACE2(( "loaded, %12d bytes\n", face->font_program_size ));
+ FT_TRACE2(( "loaded, %12ld bytes\n", face->font_program_size ));
}
Exit:
@@ -440,23 +436,25 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_prep */
- /* */
- /* <Description> */
- /* Load the cvt program. */
- /* */
- /* <InOut> */
- /* face :: A handle to the target face object. */
- /* */
- /* <Input> */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_prep
+ *
+ * @Description:
+ * Load the cvt program.
+ *
+ * @InOut:
+ * face ::
+ * A handle to the target face object.
+ *
+ * @Input:
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_prep( TT_Face face,
FT_Stream stream )
@@ -484,7 +482,7 @@
if ( FT_FRAME_EXTRACT( table_len, face->cvt_program ) )
goto Exit;
- FT_TRACE2(( "loaded, %12d bytes\n", face->cvt_program_size ));
+ FT_TRACE2(( "loaded, %12ld bytes\n", face->cvt_program_size ));
}
Exit:
@@ -501,22 +499,32 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_face_load_hdmx */
- /* */
- /* <Description> */
- /* Load the `hdmx' table into the face object. */
- /* */
- /* <Input> */
- /* face :: A handle to the target face object. */
- /* */
- /* stream :: A handle to the input stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
+ FT_COMPARE_DEF( int )
+ compare_ppem( const void* a,
+ const void* b )
+ {
+ return **(FT_Byte**)a - **(FT_Byte**)b;
+ }
+
+
+ /**************************************************************************
+ *
+ * @Function:
+ * tt_face_load_hdmx
+ *
+ * @Description:
+ * Load the `hdmx' table into the face object.
+ *
+ * @Input:
+ * face ::
+ * A handle to the target face object.
+ *
+ * stream ::
+ * A handle to the input stream.
+ *
+ * @Return:
+ * FreeType error code. 0 means success.
+ */
FT_LOCAL_DEF( FT_Error )
tt_face_load_hdmx( TT_Face face,
@@ -548,12 +556,6 @@
num_records = FT_NEXT_USHORT( p );
record_size = FT_NEXT_ULONG( p );
- /* The maximum number of bytes in an hdmx device record is the */
- /* maximum number of glyphs + 2; this is 0xFFFF + 2, thus */
- /* explaining why `record_size' is a long (which we read as */
- /* unsigned long for convenience). In practice, two bytes are */
- /* sufficient to hold the size value. */
- /* */
/* There are at least two fonts, HANNOM-A and HANNOM-B version */
/* 2.0 (2005), which get this wrong: The upper two bytes of */
/* the size value are set to 0xFF instead of 0x00. We catch */
@@ -562,32 +564,46 @@
if ( record_size >= 0xFFFF0000UL )
record_size &= 0xFFFFU;
+ FT_TRACE2(( "Hdmx " ));
+
/* The limit for `num_records' is a heuristic value. */
- if ( num_records > 255 ||
- ( num_records > 0 &&
- ( record_size > 0x10001L ||
- record_size < 4 ) ) )
+ if ( num_records > 255 || num_records == 0 )
+ {
+ FT_TRACE2(( "with unreasonable %u records rejected\n", num_records ));
+ goto Fail;
+ }
+
+ /* Out-of-spec tables are rejected. The record size must be */
+ /* equal to the number of glyphs + 2 + 32-bit padding. */
+ if ( (FT_Long)record_size != ( ( face->root.num_glyphs + 2 + 3 ) & ~3 ) )
{
- error = FT_THROW( Invalid_File_Format );
+ FT_TRACE2(( "with record size off by %ld bytes rejected\n",
+ (FT_Long)record_size -
+ ( ( face->root.num_glyphs + 2 + 3 ) & ~3 ) ));
goto Fail;
}
- if ( FT_NEW_ARRAY( face->hdmx_record_sizes, num_records ) )
+ if ( FT_QNEW_ARRAY( face->hdmx_records, num_records ) )
goto Fail;
for ( nn = 0; nn < num_records; nn++ )
{
if ( p + record_size > limit )
break;
-
- face->hdmx_record_sizes[nn] = p[0];
- p += record_size;
+ face->hdmx_records[nn] = p;
+ p += record_size;
}
+ /* The records must be already sorted by ppem but it does not */
+ /* hurt to make sure so that the binary search works later. */
+ ft_qsort( face->hdmx_records, nn, sizeof ( FT_Byte* ), compare_ppem );
+
face->hdmx_record_count = nn;
face->hdmx_table_size = table_size;
face->hdmx_record_size = record_size;
+ FT_TRACE2(( "%ux%lu loaded\n", num_records, record_size ));
+
Exit:
return error;
@@ -605,35 +621,42 @@
FT_Memory memory = stream->memory;
- FT_FREE( face->hdmx_record_sizes );
+ FT_FREE( face->hdmx_records );
FT_FRAME_RELEASE( face->hdmx_table );
}
- /*************************************************************************/
- /* */
- /* Return the advance width table for a given pixel size if it is found */
- /* in the font's `hdmx' table (if any). */
- /* */
+ /**************************************************************************
+ *
+ * Return the advance width table for a given pixel size if it is found
+ * in the font's `hdmx' table (if any). The records must be sorted for
+ * the binary search to work properly.
+ */
FT_LOCAL_DEF( FT_Byte* )
tt_face_get_device_metrics( TT_Face face,
FT_UInt ppem,
FT_UInt gindex )
{
- FT_UInt nn;
- FT_Byte* result = NULL;
- FT_ULong record_size = face->hdmx_record_size;
- FT_Byte* record = face->hdmx_table + 8;
+ FT_UInt min = 0;
+ FT_UInt max = face->hdmx_record_count;
+ FT_UInt mid;
+ FT_Byte* result = NULL;
+
+ while ( min < max )
+ {
+ mid = ( min + max ) >> 1;
- for ( nn = 0; nn < face->hdmx_record_count; nn++ )
- if ( face->hdmx_record_sizes[nn] == ppem )
+ if ( face->hdmx_records[mid][0] > ppem )
+ max = mid;
+ else if ( face->hdmx_records[mid][0] < ppem )
+ min = mid + 1;
+ else
{
- gindex += 2;
- if ( gindex < record_size )
- result = record + nn * record_size + gindex;
+ result = face->hdmx_records[mid] + 2 + gindex;
break;
}
+ }
return result;
}
diff --git a/src/3rdparty/freetype/src/truetype/ttpload.h b/src/3rdparty/freetype/src/truetype/ttpload.h
index fa12527247..ed229fa461 100644
--- a/src/3rdparty/freetype/src/truetype/ttpload.h
+++ b/src/3rdparty/freetype/src/truetype/ttpload.h
@@ -1,27 +1,26 @@
-/***************************************************************************/
-/* */
-/* ttpload.h */
-/* */
-/* TrueType-specific tables loader (specification). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttpload.h
+ *
+ * TrueType-specific tables loader (specification).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef TTPLOAD_H_
#define TTPLOAD_H_
-#include <ft2build.h>
-#include FT_INTERNAL_TRUETYPE_TYPES_H
+#include <freetype/internal/tttypes.h>
FT_BEGIN_HEADER
@@ -32,9 +31,9 @@ FT_BEGIN_HEADER
FT_Stream stream );
FT_LOCAL( FT_ULong )
- tt_face_get_location( TT_Face face,
- FT_UInt gindex,
- FT_UInt *asize );
+ tt_face_get_location( FT_Face face,
+ FT_UInt gindex,
+ FT_ULong *asize );
FT_LOCAL( void )
tt_face_done_loca( TT_Face face );
diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.c b/src/3rdparty/freetype/src/truetype/ttsubpix.c
deleted file mode 100644
index d94bcc8b50..0000000000
--- a/src/3rdparty/freetype/src/truetype/ttsubpix.c
+++ /dev/null
@@ -1,1014 +0,0 @@
-/***************************************************************************/
-/* */
-/* ttsubpix.c */
-/* */
-/* TrueType Subpixel Hinting. */
-/* */
-/* Copyright 2010-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_CALC_H
-#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_SFNT_H
-#include FT_TRUETYPE_TAGS_H
-#include FT_OUTLINE_H
-#include FT_DRIVER_H
-
-#include "ttsubpix.h"
-
-
-#if defined( TT_USE_BYTECODE_INTERPRETER ) && \
- defined( TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY )
-
- /*************************************************************************/
- /* */
- /* These rules affect how the TT Interpreter does hinting, with the */
- /* goal of doing subpixel hinting by (in general) ignoring x moves. */
- /* Some of these rules are fixes that go above and beyond the */
- /* stated techniques in the MS whitepaper on Cleartype, due to */
- /* artifacts in many glyphs. So, these rules make some glyphs render */
- /* better than they do in the MS rasterizer. */
- /* */
- /* "" string or 0 int/char indicates to apply to all glyphs. */
- /* "-" used as dummy placeholders, but any non-matching string works. */
- /* */
- /* Some of this could arguably be implemented in fontconfig, however: */
- /* */
- /* - Fontconfig can't set things on a glyph-by-glyph basis. */
- /* - The tweaks that happen here are very low-level, from an average */
- /* user's point of view and are best implemented in the hinter. */
- /* */
- /* The goal is to make the subpixel hinting techniques as generalized */
- /* as possible across all fonts to prevent the need for extra rules such */
- /* as these. */
- /* */
- /* The rule structure is designed so that entirely new rules can easily */
- /* be added when a new compatibility feature is discovered. */
- /* */
- /* The rule structures could also use some enhancement to handle ranges. */
- /* */
- /* ****************** WORK IN PROGRESS ******************* */
- /* */
-
- /* These are `classes' of fonts that can be grouped together and used in */
- /* rules below. A blank entry "" is required at the end of these! */
-#define FAMILY_CLASS_RULES_SIZE 7
-
- static const SPH_Font_Class FAMILY_CLASS_Rules
- [FAMILY_CLASS_RULES_SIZE] =
- {
- { "MS Legacy Fonts",
- { "Aharoni",
- "Andale Mono",
- "Andalus",
- "Angsana New",
- "AngsanaUPC",
- "Arabic Transparent",
- "Arial Black",
- "Arial Narrow",
- "Arial Unicode MS",
- "Arial",
- "Batang",
- "Browallia New",
- "BrowalliaUPC",
- "Comic Sans MS",
- "Cordia New",
- "CordiaUPC",
- "Courier New",
- "DFKai-SB",
- "David Transparent",
- "David",
- "DilleniaUPC",
- "Estrangelo Edessa",
- "EucrosiaUPC",
- "FangSong_GB2312",
- "Fixed Miriam Transparent",
- "FrankRuehl",
- "Franklin Gothic Medium",
- "FreesiaUPC",
- "Garamond",
- "Gautami",
- "Georgia",
- "Gulim",
- "Impact",
- "IrisUPC",
- "JasmineUPC",
- "KaiTi_GB2312",
- "KodchiangUPC",
- "Latha",
- "Levenim MT",
- "LilyUPC",
- "Lucida Console",
- "Lucida Sans Unicode",
- "MS Gothic",
- "MS Mincho",
- "MV Boli",
- "Mangal",
- "Marlett",
- "Microsoft Sans Serif",
- "Mingliu",
- "Miriam Fixed",
- "Miriam Transparent",
- "Miriam",
- "Narkisim",
- "Palatino Linotype",
- "Raavi",
- "Rod Transparent",
- "Rod",
- "Shruti",
- "SimHei",
- "Simplified Arabic Fixed",
- "Simplified Arabic",
- "Simsun",
- "Sylfaen",
- "Symbol",
- "Tahoma",
- "Times New Roman",
- "Traditional Arabic",
- "Trebuchet MS",
- "Tunga",
- "Verdana",
- "Webdings",
- "Wingdings",
- "",
- },
- },
- { "Core MS Legacy Fonts",
- { "Arial Black",
- "Arial Narrow",
- "Arial Unicode MS",
- "Arial",
- "Comic Sans MS",
- "Courier New",
- "Garamond",
- "Georgia",
- "Impact",
- "Lucida Console",
- "Lucida Sans Unicode",
- "Microsoft Sans Serif",
- "Palatino Linotype",
- "Tahoma",
- "Times New Roman",
- "Trebuchet MS",
- "Verdana",
- "",
- },
- },
- { "Apple Legacy Fonts",
- { "Geneva",
- "Times",
- "Monaco",
- "Century",
- "Chalkboard",
- "Lobster",
- "Century Gothic",
- "Optima",
- "Lucida Grande",
- "Gill Sans",
- "Baskerville",
- "Helvetica",
- "Helvetica Neue",
- "",
- },
- },
- { "Legacy Sans Fonts",
- { "Andale Mono",
- "Arial Unicode MS",
- "Arial",
- "Century Gothic",
- "Comic Sans MS",
- "Franklin Gothic Medium",
- "Geneva",
- "Lucida Console",
- "Lucida Grande",
- "Lucida Sans Unicode",
- "Lucida Sans Typewriter",
- "Microsoft Sans Serif",
- "Monaco",
- "Tahoma",
- "Trebuchet MS",
- "Verdana",
- "",
- },
- },
-
- { "Misc Legacy Fonts",
- { "Dark Courier", "", }, },
- { "Verdana Clones",
- { "DejaVu Sans",
- "Bitstream Vera Sans", "", }, },
- { "Verdana and Clones",
- { "DejaVu Sans",
- "Bitstream Vera Sans",
- "Verdana", "", }, },
- };
-
-
- /* Define this to force natural (i.e. not bitmap-compatible) widths. */
- /* The default leans strongly towards natural widths except for a few */
- /* legacy fonts where a selective combination produces nicer results. */
-/* #define FORCE_NATURAL_WIDTHS */
-
-
- /* Define `classes' of styles that can be grouped together and used in */
- /* rules below. A blank entry "" is required at the end of these! */
-#define STYLE_CLASS_RULES_SIZE 5
-
- static const SPH_Font_Class STYLE_CLASS_Rules
- [STYLE_CLASS_RULES_SIZE] =
- {
- { "Regular Class",
- { "Regular",
- "Book",
- "Medium",
- "Roman",
- "Normal",
- "",
- },
- },
- { "Regular/Italic Class",
- { "Regular",
- "Book",
- "Medium",
- "Italic",
- "Oblique",
- "Roman",
- "Normal",
- "",
- },
- },
- { "Bold/BoldItalic Class",
- { "Bold",
- "Bold Italic",
- "Black",
- "",
- },
- },
- { "Bold/Italic/BoldItalic Class",
- { "Bold",
- "Bold Italic",
- "Black",
- "Italic",
- "Oblique",
- "",
- },
- },
- { "Regular/Bold Class",
- { "Regular",
- "Book",
- "Medium",
- "Normal",
- "Roman",
- "Bold",
- "Black",
- "",
- },
- },
- };
-
-
- /* Force special legacy fixes for fonts. */
-#define COMPATIBILITY_MODE_RULES_SIZE 1
-
- static const SPH_TweakRule COMPATIBILITY_MODE_Rules
- [COMPATIBILITY_MODE_RULES_SIZE] =
- {
- { "Verdana Clones", 0, "", 0 },
- };
-
-
- /* Don't do subpixel (ignore_x_mode) hinting; do normal hinting. */
-#define PIXEL_HINTING_RULES_SIZE 2
-
- static const SPH_TweakRule PIXEL_HINTING_Rules
- [PIXEL_HINTING_RULES_SIZE] =
- {
- /* these characters are almost always safe */
- { "Courier New", 12, "Italic", 'z' },
- { "Courier New", 11, "Italic", 'z' },
- };
-
-
- /* Subpixel hinting ignores SHPIX rules on X. Force SHPIX for these. */
-#define DO_SHPIX_RULES_SIZE 1
-
- static const SPH_TweakRule DO_SHPIX_Rules
- [DO_SHPIX_RULES_SIZE] =
- {
- { "-", 0, "", 0 },
- };
-
-
- /* Skip Y moves that start with a point that is not on a Y pixel */
- /* boundary and don't move that point to a Y pixel boundary. */
-#define SKIP_NONPIXEL_Y_MOVES_RULES_SIZE 4
-
- static const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_Rules
- [SKIP_NONPIXEL_Y_MOVES_RULES_SIZE] =
- {
- /* fix vwxyz thinness*/
- { "Consolas", 0, "", 0 },
- /* Fix thin middle stems */
- { "Core MS Legacy Fonts", 0, "Regular", 0 },
- /* Cyrillic small letter I */
- { "Legacy Sans Fonts", 0, "", 0 },
- /* Fix artifacts with some Regular & Bold */
- { "Verdana Clones", 0, "", 0 },
- };
-
-
-#define SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
-
- static const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions
- [SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
- {
- /* Fixes < and > */
- { "Courier New", 0, "Regular", 0 },
- };
-
-
- /* Skip Y moves that start with a point that is not on a Y pixel */
- /* boundary and don't move that point to a Y pixel boundary. */
-#define SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE 2
-
- static const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_DELTAP_Rules
- [SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE] =
- {
- /* Maintain thickness of diagonal in 'N' */
- { "Times New Roman", 0, "Regular/Bold Class", 'N' },
- { "Georgia", 0, "Regular/Bold Class", 'N' },
- };
-
-
- /* Skip Y moves that move a point off a Y pixel boundary. */
-#define SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE 1
-
- static const SPH_TweakRule SKIP_OFFPIXEL_Y_MOVES_Rules
- [SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE] =
- {
- { "-", 0, "", 0 },
- };
-
-
-#define SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
-
- static const SPH_TweakRule SKIP_OFFPIXEL_Y_MOVES_Rules_Exceptions
- [SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
- {
- { "-", 0, "", 0 },
- };
-
-
- /* Round moves that don't move a point to a Y pixel boundary. */
-#define ROUND_NONPIXEL_Y_MOVES_RULES_SIZE 2
-
- static const SPH_TweakRule ROUND_NONPIXEL_Y_MOVES_Rules
- [ROUND_NONPIXEL_Y_MOVES_RULES_SIZE] =
- {
- /* Droid font instructions don't snap Y to pixels */
- { "Droid Sans", 0, "Regular/Italic Class", 0 },
- { "Droid Sans Mono", 0, "", 0 },
- };
-
-
-#define ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
-
- static const SPH_TweakRule ROUND_NONPIXEL_Y_MOVES_Rules_Exceptions
- [ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
- {
- { "-", 0, "", 0 },
- };
-
-
- /* Allow a Direct_Move along X freedom vector if matched. */
-#define ALLOW_X_DMOVE_RULES_SIZE 1
-
- static const SPH_TweakRule ALLOW_X_DMOVE_Rules
- [ALLOW_X_DMOVE_RULES_SIZE] =
- {
- /* Fixes vanishing diagonal in 4 */
- { "Verdana", 0, "Regular", '4' },
- };
-
-
- /* Return MS rasterizer version 35 if matched. */
-#define RASTERIZER_35_RULES_SIZE 8
-
- static const SPH_TweakRule RASTERIZER_35_Rules
- [RASTERIZER_35_RULES_SIZE] =
- {
- /* This seems to be the only way to make these look good */
- { "Times New Roman", 0, "Regular", 'i' },
- { "Times New Roman", 0, "Regular", 'j' },
- { "Times New Roman", 0, "Regular", 'm' },
- { "Times New Roman", 0, "Regular", 'r' },
- { "Times New Roman", 0, "Regular", 'a' },
- { "Times New Roman", 0, "Regular", 'n' },
- { "Times New Roman", 0, "Regular", 'p' },
- { "Times", 0, "", 0 },
- };
-
-
- /* Don't round to the subpixel grid. Round to pixel grid. */
-#define NORMAL_ROUND_RULES_SIZE 1
-
- static const SPH_TweakRule NORMAL_ROUND_Rules
- [NORMAL_ROUND_RULES_SIZE] =
- {
- /* Fix serif thickness for certain ppems */
- /* Can probably be generalized somehow */
- { "Courier New", 0, "", 0 },
- };
-
-
- /* Skip IUP instructions if matched. */
-#define SKIP_IUP_RULES_SIZE 1
-
- static const SPH_TweakRule SKIP_IUP_Rules
- [SKIP_IUP_RULES_SIZE] =
- {
- { "Arial", 13, "Regular", 'a' },
- };
-
-
- /* Skip MIAP Twilight hack if matched. */
-#define MIAP_HACK_RULES_SIZE 1
-
- static const SPH_TweakRule MIAP_HACK_Rules
- [MIAP_HACK_RULES_SIZE] =
- {
- { "Geneva", 12, "", 0 },
- };
-
-
- /* Skip DELTAP instructions if matched. */
-#define ALWAYS_SKIP_DELTAP_RULES_SIZE 23
-
- static const SPH_TweakRule ALWAYS_SKIP_DELTAP_Rules
- [ALWAYS_SKIP_DELTAP_RULES_SIZE] =
- {
- { "Georgia", 0, "Regular", 'k' },
- /* fix various problems with e in different versions */
- { "Trebuchet MS", 14, "Regular", 'e' },
- { "Trebuchet MS", 13, "Regular", 'e' },
- { "Trebuchet MS", 15, "Regular", 'e' },
- { "Trebuchet MS", 0, "Italic", 'v' },
- { "Trebuchet MS", 0, "Italic", 'w' },
- { "Trebuchet MS", 0, "Regular", 'Y' },
- { "Arial", 11, "Regular", 's' },
- /* prevent problems with '3' and others */
- { "Verdana", 10, "Regular", 0 },
- { "Verdana", 9, "Regular", 0 },
- /* Cyrillic small letter short I */
- { "Legacy Sans Fonts", 0, "", 0x438 },
- { "Legacy Sans Fonts", 0, "", 0x439 },
- { "Arial", 10, "Regular", '6' },
- { "Arial", 0, "Bold/BoldItalic Class", 'a' },
- /* Make horizontal stems consistent with the rest */
- { "Arial", 24, "Bold", 'a' },
- { "Arial", 25, "Bold", 'a' },
- { "Arial", 24, "Bold", 's' },
- { "Arial", 25, "Bold", 's' },
- { "Arial", 34, "Bold", 's' },
- { "Arial", 35, "Bold", 's' },
- { "Arial", 36, "Bold", 's' },
- { "Arial", 25, "Regular", 's' },
- { "Arial", 26, "Regular", 's' },
- };
-
-
- /* Always do DELTAP instructions if matched. */
-#define ALWAYS_DO_DELTAP_RULES_SIZE 1
-
- static const SPH_TweakRule ALWAYS_DO_DELTAP_Rules
- [ALWAYS_DO_DELTAP_RULES_SIZE] =
- {
- { "-", 0, "", 0 },
- };
-
-
- /* Don't allow ALIGNRP after IUP. */
-#define NO_ALIGNRP_AFTER_IUP_RULES_SIZE 1
-
- static const SPH_TweakRule NO_ALIGNRP_AFTER_IUP_Rules
- [NO_ALIGNRP_AFTER_IUP_RULES_SIZE] =
- {
- /* Prevent creation of dents in outline */
- { "-", 0, "", 0 },
- };
-
-
- /* Don't allow DELTAP after IUP. */
-#define NO_DELTAP_AFTER_IUP_RULES_SIZE 1
-
- static const SPH_TweakRule NO_DELTAP_AFTER_IUP_Rules
- [NO_DELTAP_AFTER_IUP_RULES_SIZE] =
- {
- { "-", 0, "", 0 },
- };
-
-
- /* Don't allow CALL after IUP. */
-#define NO_CALL_AFTER_IUP_RULES_SIZE 1
-
- static const SPH_TweakRule NO_CALL_AFTER_IUP_Rules
- [NO_CALL_AFTER_IUP_RULES_SIZE] =
- {
- /* Prevent creation of dents in outline */
- { "-", 0, "", 0 },
- };
-
-
- /* De-embolden these glyphs slightly. */
-#define DEEMBOLDEN_RULES_SIZE 9
-
- static const SPH_TweakRule DEEMBOLDEN_Rules
- [DEEMBOLDEN_RULES_SIZE] =
- {
- { "Courier New", 0, "Bold", 'A' },
- { "Courier New", 0, "Bold", 'W' },
- { "Courier New", 0, "Bold", 'w' },
- { "Courier New", 0, "Bold", 'M' },
- { "Courier New", 0, "Bold", 'X' },
- { "Courier New", 0, "Bold", 'K' },
- { "Courier New", 0, "Bold", 'x' },
- { "Courier New", 0, "Bold", 'z' },
- { "Courier New", 0, "Bold", 'v' },
- };
-
-
- /* Embolden these glyphs slightly. */
-#define EMBOLDEN_RULES_SIZE 2
-
- static const SPH_TweakRule EMBOLDEN_Rules
- [EMBOLDEN_RULES_SIZE] =
- {
- { "Courier New", 0, "Regular", 0 },
- { "Courier New", 0, "Italic", 0 },
- };
-
-
- /* This is a CVT hack that makes thick horizontal stems on 2, 5, 7 */
- /* similar to Windows XP. */
-#define TIMES_NEW_ROMAN_HACK_RULES_SIZE 12
-
- static const SPH_TweakRule TIMES_NEW_ROMAN_HACK_Rules
- [TIMES_NEW_ROMAN_HACK_RULES_SIZE] =
- {
- { "Times New Roman", 16, "Italic", '2' },
- { "Times New Roman", 16, "Italic", '5' },
- { "Times New Roman", 16, "Italic", '7' },
- { "Times New Roman", 16, "Regular", '2' },
- { "Times New Roman", 16, "Regular", '5' },
- { "Times New Roman", 16, "Regular", '7' },
- { "Times New Roman", 17, "Italic", '2' },
- { "Times New Roman", 17, "Italic", '5' },
- { "Times New Roman", 17, "Italic", '7' },
- { "Times New Roman", 17, "Regular", '2' },
- { "Times New Roman", 17, "Regular", '5' },
- { "Times New Roman", 17, "Regular", '7' },
- };
-
-
- /* This fudges distance on 2 to get rid of the vanishing stem issue. */
- /* A real solution to this is certainly welcome. */
-#define COURIER_NEW_2_HACK_RULES_SIZE 15
-
- static const SPH_TweakRule COURIER_NEW_2_HACK_Rules
- [COURIER_NEW_2_HACK_RULES_SIZE] =
- {
- { "Courier New", 10, "Regular", '2' },
- { "Courier New", 11, "Regular", '2' },
- { "Courier New", 12, "Regular", '2' },
- { "Courier New", 13, "Regular", '2' },
- { "Courier New", 14, "Regular", '2' },
- { "Courier New", 15, "Regular", '2' },
- { "Courier New", 16, "Regular", '2' },
- { "Courier New", 17, "Regular", '2' },
- { "Courier New", 18, "Regular", '2' },
- { "Courier New", 19, "Regular", '2' },
- { "Courier New", 20, "Regular", '2' },
- { "Courier New", 21, "Regular", '2' },
- { "Courier New", 22, "Regular", '2' },
- { "Courier New", 23, "Regular", '2' },
- { "Courier New", 24, "Regular", '2' },
- };
-
-
-#ifndef FORCE_NATURAL_WIDTHS
-
- /* Use compatible widths with these glyphs. Compatible widths is always */
- /* on when doing B/W TrueType instructing, but is used selectively here, */
- /* typically on glyphs with 3 or more vertical stems. */
-#define COMPATIBLE_WIDTHS_RULES_SIZE 38
-
- static const SPH_TweakRule COMPATIBLE_WIDTHS_Rules
- [COMPATIBLE_WIDTHS_RULES_SIZE] =
- {
- { "Arial Unicode MS", 12, "Regular Class", 'm' },
- { "Arial Unicode MS", 14, "Regular Class", 'm' },
- /* Cyrillic small letter sha */
- { "Arial", 10, "Regular Class", 0x448 },
- { "Arial", 11, "Regular Class", 'm' },
- { "Arial", 12, "Regular Class", 'm' },
- /* Cyrillic small letter sha */
- { "Arial", 12, "Regular Class", 0x448 },
- { "Arial", 13, "Regular Class", 0x448 },
- { "Arial", 14, "Regular Class", 'm' },
- /* Cyrillic small letter sha */
- { "Arial", 14, "Regular Class", 0x448 },
- { "Arial", 15, "Regular Class", 0x448 },
- { "Arial", 17, "Regular Class", 'm' },
- { "DejaVu Sans", 15, "Regular Class", 0 },
- { "Microsoft Sans Serif", 11, "Regular Class", 0 },
- { "Microsoft Sans Serif", 12, "Regular Class", 0 },
- { "Segoe UI", 11, "Regular Class", 0 },
- { "Monaco", 0, "Regular Class", 0 },
- { "Segoe UI", 12, "Regular Class", 'm' },
- { "Segoe UI", 14, "Regular Class", 'm' },
- { "Tahoma", 11, "Regular Class", 0 },
- { "Times New Roman", 16, "Regular Class", 'c' },
- { "Times New Roman", 16, "Regular Class", 'm' },
- { "Times New Roman", 16, "Regular Class", 'o' },
- { "Times New Roman", 16, "Regular Class", 'w' },
- { "Trebuchet MS", 11, "Regular Class", 0 },
- { "Trebuchet MS", 12, "Regular Class", 0 },
- { "Trebuchet MS", 14, "Regular Class", 0 },
- { "Trebuchet MS", 15, "Regular Class", 0 },
- { "Ubuntu", 12, "Regular Class", 'm' },
- /* Cyrillic small letter sha */
- { "Verdana", 10, "Regular Class", 0x448 },
- { "Verdana", 11, "Regular Class", 0x448 },
- { "Verdana and Clones", 12, "Regular Class", 'i' },
- { "Verdana and Clones", 12, "Regular Class", 'j' },
- { "Verdana and Clones", 12, "Regular Class", 'l' },
- { "Verdana and Clones", 12, "Regular Class", 'm' },
- { "Verdana and Clones", 13, "Regular Class", 'i' },
- { "Verdana and Clones", 13, "Regular Class", 'j' },
- { "Verdana and Clones", 13, "Regular Class", 'l' },
- { "Verdana and Clones", 14, "Regular Class", 'm' },
- };
-
-
- /* Scaling slightly in the x-direction prior to hinting results in */
- /* more visually pleasing glyphs in certain cases. */
- /* This sometimes needs to be coordinated with compatible width rules. */
- /* A value of 1000 corresponds to a scaled value of 1.0. */
-
-#define X_SCALING_RULES_SIZE 50
-
- static const SPH_ScaleRule X_SCALING_Rules[X_SCALING_RULES_SIZE] =
- {
- { "DejaVu Sans", 12, "Regular Class", 'm', 950 },
- { "Verdana and Clones", 12, "Regular Class", 'a', 1100 },
- { "Verdana and Clones", 13, "Regular Class", 'a', 1050 },
- { "Arial", 11, "Regular Class", 'm', 975 },
- { "Arial", 12, "Regular Class", 'm', 1050 },
- /* Cyrillic small letter el */
- { "Arial", 13, "Regular Class", 0x43B, 950 },
- { "Arial", 13, "Regular Class", 'o', 950 },
- { "Arial", 13, "Regular Class", 'e', 950 },
- { "Arial", 14, "Regular Class", 'm', 950 },
- /* Cyrillic small letter el */
- { "Arial", 15, "Regular Class", 0x43B, 925 },
- { "Bitstream Vera Sans", 10, "Regular/Italic Class", 0, 1100 },
- { "Bitstream Vera Sans", 12, "Regular/Italic Class", 0, 1050 },
- { "Bitstream Vera Sans", 16, "Regular Class", 0, 1050 },
- { "Bitstream Vera Sans", 9, "Regular/Italic Class", 0, 1050 },
- { "DejaVu Sans", 12, "Regular Class", 'l', 975 },
- { "DejaVu Sans", 12, "Regular Class", 'i', 975 },
- { "DejaVu Sans", 12, "Regular Class", 'j', 975 },
- { "DejaVu Sans", 13, "Regular Class", 'l', 950 },
- { "DejaVu Sans", 13, "Regular Class", 'i', 950 },
- { "DejaVu Sans", 13, "Regular Class", 'j', 950 },
- { "DejaVu Sans", 10, "Regular/Italic Class", 0, 1100 },
- { "DejaVu Sans", 12, "Regular/Italic Class", 0, 1050 },
- { "Georgia", 10, "", 0, 1050 },
- { "Georgia", 11, "", 0, 1100 },
- { "Georgia", 12, "", 0, 1025 },
- { "Georgia", 13, "", 0, 1050 },
- { "Georgia", 16, "", 0, 1050 },
- { "Georgia", 17, "", 0, 1030 },
- { "Liberation Sans", 12, "Regular Class", 'm', 1100 },
- { "Lucida Grande", 11, "Regular Class", 'm', 1100 },
- { "Microsoft Sans Serif", 11, "Regular Class", 'm', 950 },
- { "Microsoft Sans Serif", 12, "Regular Class", 'm', 1050 },
- { "Segoe UI", 12, "Regular Class", 'H', 1050 },
- { "Segoe UI", 12, "Regular Class", 'm', 1050 },
- { "Segoe UI", 14, "Regular Class", 'm', 1050 },
- { "Tahoma", 11, "Regular Class", 'i', 975 },
- { "Tahoma", 11, "Regular Class", 'l', 975 },
- { "Tahoma", 11, "Regular Class", 'j', 900 },
- { "Tahoma", 11, "Regular Class", 'm', 918 },
- { "Verdana", 10, "Regular/Italic Class", 0, 1100 },
- { "Verdana", 12, "Regular Class", 'm', 975 },
- { "Verdana", 12, "Regular/Italic Class", 0, 1050 },
- { "Verdana", 13, "Regular/Italic Class", 'i', 950 },
- { "Verdana", 13, "Regular/Italic Class", 'j', 950 },
- { "Verdana", 13, "Regular/Italic Class", 'l', 950 },
- { "Verdana", 16, "Regular Class", 0, 1050 },
- { "Verdana", 9, "Regular/Italic Class", 0, 1050 },
- { "Times New Roman", 16, "Regular Class", 'm', 918 },
- { "Trebuchet MS", 11, "Regular Class", 'm', 800 },
- { "Trebuchet MS", 12, "Regular Class", 'm', 800 },
- };
-
-#else
-
-#define COMPATIBLE_WIDTHS_RULES_SIZE 1
-
- static const SPH_TweakRule COMPATIBLE_WIDTHS_Rules
- [COMPATIBLE_WIDTHS_RULES_SIZE] =
- {
- { "-", 0, "", 0 },
- };
-
-
-#define X_SCALING_RULES_SIZE 1
-
- static const SPH_ScaleRule X_SCALING_Rules
- [X_SCALING_RULES_SIZE] =
- {
- { "-", 0, "", 0, 1000 },
- };
-
-#endif /* FORCE_NATURAL_WIDTHS */
-
-
- static FT_Bool
- is_member_of_family_class( const FT_String* detected_font_name,
- const FT_String* rule_font_name )
- {
- FT_UInt i, j;
-
-
- /* Does font name match rule family? */
- if ( ft_strcmp( detected_font_name, rule_font_name ) == 0 )
- return TRUE;
-
- /* Is font name a wildcard ""? */
- if ( ft_strcmp( rule_font_name, "" ) == 0 )
- return TRUE;
-
- /* Is font name contained in a class list? */
- for ( i = 0; i < FAMILY_CLASS_RULES_SIZE; i++ )
- {
- if ( ft_strcmp( FAMILY_CLASS_Rules[i].name, rule_font_name ) == 0 )
- {
- for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
- {
- if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 )
- continue;
- if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j],
- detected_font_name ) == 0 )
- return TRUE;
- }
- }
- }
-
- return FALSE;
- }
-
-
- static FT_Bool
- is_member_of_style_class( const FT_String* detected_font_style,
- const FT_String* rule_font_style )
- {
- FT_UInt i, j;
-
-
- /* Does font style match rule style? */
- if ( ft_strcmp( detected_font_style, rule_font_style ) == 0 )
- return TRUE;
-
- /* Is font style a wildcard ""? */
- if ( ft_strcmp( rule_font_style, "" ) == 0 )
- return TRUE;
-
- /* Is font style contained in a class list? */
- for ( i = 0; i < STYLE_CLASS_RULES_SIZE; i++ )
- {
- if ( ft_strcmp( STYLE_CLASS_Rules[i].name, rule_font_style ) == 0 )
- {
- for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
- {
- if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 )
- continue;
- if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j],
- detected_font_style ) == 0 )
- return TRUE;
- }
- }
- }
-
- return FALSE;
- }
-
-
- FT_LOCAL_DEF( FT_Bool )
- sph_test_tweak( TT_Face face,
- const FT_String* family,
- FT_UInt ppem,
- const FT_String* style,
- FT_UInt glyph_index,
- const SPH_TweakRule* rule,
- FT_UInt num_rules )
- {
- FT_UInt i;
-
-
- /* rule checks may be able to be optimized further */
- for ( i = 0; i < num_rules; i++ )
- {
- if ( family &&
- ( is_member_of_family_class ( family, rule[i].family ) ) )
- if ( rule[i].ppem == 0 ||
- rule[i].ppem == ppem )
- if ( style &&
- is_member_of_style_class ( style, rule[i].style ) )
- if ( rule[i].glyph == 0 ||
- FT_Get_Char_Index( (FT_Face)face,
- rule[i].glyph ) == glyph_index )
- return TRUE;
- }
-
- return FALSE;
- }
-
-
- static FT_UInt
- scale_test_tweak( TT_Face face,
- const FT_String* family,
- FT_UInt ppem,
- const FT_String* style,
- FT_UInt glyph_index,
- const SPH_ScaleRule* rule,
- FT_UInt num_rules )
- {
- FT_UInt i;
-
-
- /* rule checks may be able to be optimized further */
- for ( i = 0; i < num_rules; i++ )
- {
- if ( family &&
- ( is_member_of_family_class ( family, rule[i].family ) ) )
- if ( rule[i].ppem == 0 ||
- rule[i].ppem == ppem )
- if ( style &&
- is_member_of_style_class( style, rule[i].style ) )
- if ( rule[i].glyph == 0 ||
- FT_Get_Char_Index( (FT_Face)face,
- rule[i].glyph ) == glyph_index )
- return rule[i].scale;
- }
-
- return 1000;
- }
-
-
- FT_LOCAL_DEF( FT_UInt )
- sph_test_tweak_x_scaling( TT_Face face,
- const FT_String* family,
- FT_UInt ppem,
- const FT_String* style,
- FT_UInt glyph_index )
- {
- return scale_test_tweak( face, family, ppem, style, glyph_index,
- X_SCALING_Rules, X_SCALING_RULES_SIZE );
- }
-
-
-#define TWEAK_RULES( x ) \
- if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
- x##_Rules, x##_RULES_SIZE ) ) \
- loader->exec->sph_tweak_flags |= SPH_TWEAK_##x;
-
-#define TWEAK_RULES_EXCEPTIONS( x ) \
- if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
- x##_Rules_Exceptions, x##_RULES_EXCEPTIONS_SIZE ) ) \
- loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x;
-
-
- FT_LOCAL_DEF( void )
- sph_set_tweaks( TT_Loader loader,
- FT_UInt glyph_index )
- {
- TT_Face face = loader->face;
- FT_String* family = face->root.family_name;
- FT_UInt ppem = loader->size->metrics->x_ppem;
- FT_String* style = face->root.style_name;
-
-
- /* don't apply rules if style isn't set */
- if ( !face->root.style_name )
- return;
-
-#ifdef SPH_DEBUG_MORE_VERBOSE
- printf( "%s,%d,%s,%c=%d ",
- family, ppem, style, glyph_index, glyph_index );
-#endif
-
- TWEAK_RULES( PIXEL_HINTING );
-
- if ( loader->exec->sph_tweak_flags & SPH_TWEAK_PIXEL_HINTING )
- {
- loader->exec->ignore_x_mode = FALSE;
- return;
- }
-
- TWEAK_RULES( ALLOW_X_DMOVE );
- TWEAK_RULES( ALWAYS_DO_DELTAP );
- TWEAK_RULES( ALWAYS_SKIP_DELTAP );
- TWEAK_RULES( DEEMBOLDEN );
- TWEAK_RULES( DO_SHPIX );
- TWEAK_RULES( EMBOLDEN );
- TWEAK_RULES( MIAP_HACK );
- TWEAK_RULES( NORMAL_ROUND );
- TWEAK_RULES( NO_ALIGNRP_AFTER_IUP );
- TWEAK_RULES( NO_CALL_AFTER_IUP );
- TWEAK_RULES( NO_DELTAP_AFTER_IUP );
- TWEAK_RULES( RASTERIZER_35 );
- TWEAK_RULES( SKIP_IUP );
-
- TWEAK_RULES( SKIP_OFFPIXEL_Y_MOVES );
- TWEAK_RULES_EXCEPTIONS( SKIP_OFFPIXEL_Y_MOVES );
-
- TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES_DELTAP );
-
- TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES );
- TWEAK_RULES_EXCEPTIONS( SKIP_NONPIXEL_Y_MOVES );
-
- TWEAK_RULES( ROUND_NONPIXEL_Y_MOVES );
- TWEAK_RULES_EXCEPTIONS( ROUND_NONPIXEL_Y_MOVES );
-
- if ( loader->exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
- {
- if ( loader->exec->rasterizer_version != TT_INTERPRETER_VERSION_35 )
- {
- loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
- loader->exec->size->cvt_ready = -1;
-
- tt_size_ready_bytecode(
- loader->exec->size,
- FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
- }
- else
- loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
- }
- else
- {
- if ( loader->exec->rasterizer_version !=
- SPH_OPTION_SET_RASTERIZER_VERSION )
- {
- loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
- loader->exec->size->cvt_ready = -1;
-
- tt_size_ready_bytecode(
- loader->exec->size,
- FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
- }
- else
- loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
- }
-
- if ( IS_HINTED( loader->load_flags ) )
- {
- TWEAK_RULES( TIMES_NEW_ROMAN_HACK );
- TWEAK_RULES( COURIER_NEW_2_HACK );
- }
-
- if ( sph_test_tweak( face, family, ppem, style, glyph_index,
- COMPATIBILITY_MODE_Rules, COMPATIBILITY_MODE_RULES_SIZE ) )
- loader->exec->face->sph_compatibility_mode = TRUE;
-
-
- if ( IS_HINTED( loader->load_flags ) )
- {
- if ( sph_test_tweak( face, family, ppem, style, glyph_index,
- COMPATIBLE_WIDTHS_Rules, COMPATIBLE_WIDTHS_RULES_SIZE ) )
- loader->exec->compatible_widths |= TRUE;
- }
- }
-
-#else /* !(TT_USE_BYTECODE_INTERPRETER && */
- /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY) */
-
- /* ANSI C doesn't like empty source files */
- typedef int _tt_subpix_dummy;
-
-#endif /* !(TT_USE_BYTECODE_INTERPRETER && */
- /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY) */
-
-
-/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.h b/src/3rdparty/freetype/src/truetype/ttsubpix.h
deleted file mode 100644
index 1070bb016f..0000000000
--- a/src/3rdparty/freetype/src/truetype/ttsubpix.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/***************************************************************************/
-/* */
-/* ttsubpix.h */
-/* */
-/* TrueType Subpixel Hinting. */
-/* */
-/* Copyright 2010-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
-
-#ifndef TTSUBPIX_H_
-#define TTSUBPIX_H_
-
-#include <ft2build.h>
-#include "ttobjs.h"
-#include "ttinterp.h"
-
-
-FT_BEGIN_HEADER
-
-
-#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
-
- /*************************************************************************/
- /* */
- /* ID flags to identify special functions at FDEF and runtime. */
- /* */
- /* */
-#define SPH_FDEF_INLINE_DELTA_1 0x0000001
-#define SPH_FDEF_INLINE_DELTA_2 0x0000002
-#define SPH_FDEF_DIAGONAL_STROKE 0x0000004
-#define SPH_FDEF_VACUFORM_ROUND_1 0x0000008
-#define SPH_FDEF_TTFAUTOHINT_1 0x0000010
-#define SPH_FDEF_SPACING_1 0x0000020
-#define SPH_FDEF_SPACING_2 0x0000040
-#define SPH_FDEF_TYPEMAN_STROKES 0x0000080
-#define SPH_FDEF_TYPEMAN_DIAGENDCTRL 0x0000100
-
-
- /*************************************************************************/
- /* */
- /* Tweak flags that are set for each glyph by the below rules. */
- /* */
- /* */
-#define SPH_TWEAK_ALLOW_X_DMOVE 0x0000001UL
-#define SPH_TWEAK_ALWAYS_DO_DELTAP 0x0000002UL
-#define SPH_TWEAK_ALWAYS_SKIP_DELTAP 0x0000004UL
-#define SPH_TWEAK_COURIER_NEW_2_HACK 0x0000008UL
-#define SPH_TWEAK_DEEMBOLDEN 0x0000010UL
-#define SPH_TWEAK_DO_SHPIX 0x0000020UL
-#define SPH_TWEAK_EMBOLDEN 0x0000040UL
-#define SPH_TWEAK_MIAP_HACK 0x0000080UL
-#define SPH_TWEAK_NORMAL_ROUND 0x0000100UL
-#define SPH_TWEAK_NO_ALIGNRP_AFTER_IUP 0x0000200UL
-#define SPH_TWEAK_NO_CALL_AFTER_IUP 0x0000400UL
-#define SPH_TWEAK_NO_DELTAP_AFTER_IUP 0x0000800UL
-#define SPH_TWEAK_PIXEL_HINTING 0x0001000UL
-#define SPH_TWEAK_RASTERIZER_35 0x0002000UL
-#define SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES 0x0004000UL
-#define SPH_TWEAK_SKIP_IUP 0x0008000UL
-#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES 0x0010000UL
-#define SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES 0x0020000UL
-#define SPH_TWEAK_TIMES_NEW_ROMAN_HACK 0x0040000UL
-#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP 0x0080000UL
-
-
- FT_LOCAL( FT_Bool )
- sph_test_tweak( TT_Face face,
- const FT_String* family,
- FT_UInt ppem,
- const FT_String* style,
- FT_UInt glyph_index,
- const SPH_TweakRule* rule,
- FT_UInt num_rules );
-
- FT_LOCAL( FT_UInt )
- sph_test_tweak_x_scaling( TT_Face face,
- const FT_String* family,
- FT_UInt ppem,
- const FT_String* style,
- FT_UInt glyph_index );
-
- FT_LOCAL( void )
- sph_set_tweaks( TT_Loader loader,
- FT_UInt glyph_index );
-
-
- /* These macros are defined absent a method for setting them */
-#define SPH_OPTION_BITMAP_WIDTHS FALSE
-#define SPH_OPTION_SET_SUBPIXEL TRUE
-#define SPH_OPTION_SET_GRAYSCALE FALSE
-#define SPH_OPTION_SET_COMPATIBLE_WIDTHS FALSE
-#define SPH_OPTION_SET_RASTERIZER_VERSION 38
-
-#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-
-
-FT_END_HEADER
-
-#endif /* TTSUBPIX_H_ */
-
-
-/* END */