summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/truetype/ttobjs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/truetype/ttobjs.c')
-rw-r--r--src/3rdparty/freetype/src/truetype/ttobjs.c493
1 files changed, 265 insertions, 228 deletions
diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.c b/src/3rdparty/freetype/src/truetype/ttobjs.c
index 6685dc8196..e4775a51ed 100644
--- a/src/3rdparty/freetype/src/truetype/ttobjs.c
+++ b/src/3rdparty/freetype/src/truetype/ttobjs.c
@@ -1,19 +1,19 @@
-/***************************************************************************/
-/* */
-/* 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. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ttobjs.c
+ *
+ * Objects manager (body).
+ *
+ * Copyright (C) 1996-2019 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>
@@ -36,36 +36,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 +88,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,
@@ -143,7 +148,7 @@
/* 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
@@ -566,32 +571,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 */
@@ -743,17 +753,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 */
{
@@ -799,30 +810,32 @@
}
- /*************************************************************************/
- /* */
- /* 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 +912,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,7 +937,22 @@
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, face->cvt[i] / 64.0, size->cvt[i] / 64.0 ));
+ }
+ FT_TRACE6(( "\n" ));
exec = size->context;
@@ -1079,11 +1109,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; /* the same as gray */
}
/* allocate function defs, instruction defs, cvt, and storage area */
@@ -1156,13 +1192,7 @@
if ( size->cvt_ready < 0 )
{
FT_UInt i;
- TT_Face face = (TT_Face)size->root.face;
-
- /* 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++ )
@@ -1191,20 +1221,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 +1255,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,22 +1281,24 @@
}
- /*************************************************************************/
- /* */
- /* <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
+ *
+ * @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.
+ */
FT_LOCAL_DEF( FT_Error )
tt_size_reset( TT_Size size,
FT_Bool only_height )
@@ -1358,20 +1392,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 */
{
@@ -1398,17 +1433,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 +1452,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 )
{