Issue #1863 - Update freetype2 to 2.13.0.

This commit is contained in:
Job Bautista 2023-04-04 14:09:09 +08:00 committed by roytam1
commit 8a54b4f303
885 changed files with 207490 additions and 81111 deletions

View file

@ -1,19 +0,0 @@
# FreeType 2 src 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) ;
for xx in $(FT2_COMPONENTS)
{
SubInclude FT2_TOP $(FT2_SRC_DIR) $(xx) ;
}
# end of src Jamfile

View file

@ -1,53 +0,0 @@
# FreeType 2 src/autofit Jamfile
#
# Copyright 2003-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 src autofit ;
{
local _sources ;
# define FT2_AUTOFIT2 to enable experimental latin hinter replacement
if $(FT2_AUTOFIT2)
{
CCFLAGS += FT_OPTION_AUTOFIT2 ;
}
if $(FT2_MULTI)
{
_sources = afangles
afblue
afcjk
afdummy
afglobal
afhints
afindic
aflatin
afloader
afmodule
afpic
afranges
afshaper
afwarp
;
if $(FT2_AUTOFIT2)
{
_sources += aflatin2 ;
}
}
else
{
_sources = autofit ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/autofit Jamfile

View file

@ -1,285 +0,0 @@
/***************************************************************************/
/* */
/* afangles.c */
/* */
/* Routines used to compute vector angles with limited accuracy */
/* and very high speed. It also contains sorting routines (body). */
/* */
/* Copyright 2003-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 "aftypes.h"
/*
* We are not using `af_angle_atan' anymore, but we keep the source
* code below just in case...
*/
#if 0
/*
* The trick here is to realize that we don't need a very accurate angle
* approximation. We are going to use the result of `af_angle_atan' to
* only compare the sign of angle differences, or check whether its
* magnitude is very small.
*
* The approximation
*
* dy * PI / (|dx|+|dy|)
*
* should be enough, and much faster to compute.
*/
FT_LOCAL_DEF( AF_Angle )
af_angle_atan( FT_Fixed dx,
FT_Fixed dy )
{
AF_Angle angle;
FT_Fixed ax = dx;
FT_Fixed ay = dy;
if ( ax < 0 )
ax = -ax;
if ( ay < 0 )
ay = -ay;
ax += ay;
if ( ax == 0 )
angle = 0;
else
{
angle = ( AF_ANGLE_PI2 * dy ) / ( ax + ay );
if ( dx < 0 )
{
if ( angle >= 0 )
angle = AF_ANGLE_PI - angle;
else
angle = -AF_ANGLE_PI - angle;
}
}
return angle;
}
#elif 0
/* the following table has been automatically generated with */
/* the `mather.py' Python script */
#define AF_ATAN_BITS 8
static const FT_Byte af_arctan[1L << AF_ATAN_BITS] =
{
0, 0, 1, 1, 1, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 5,
5, 5, 6, 6, 6, 7, 7, 7,
8, 8, 8, 9, 9, 9, 10, 10,
10, 10, 11, 11, 11, 12, 12, 12,
13, 13, 13, 14, 14, 14, 14, 15,
15, 15, 16, 16, 16, 17, 17, 17,
18, 18, 18, 18, 19, 19, 19, 20,
20, 20, 21, 21, 21, 21, 22, 22,
22, 23, 23, 23, 24, 24, 24, 24,
25, 25, 25, 26, 26, 26, 26, 27,
27, 27, 28, 28, 28, 28, 29, 29,
29, 30, 30, 30, 30, 31, 31, 31,
31, 32, 32, 32, 33, 33, 33, 33,
34, 34, 34, 34, 35, 35, 35, 35,
36, 36, 36, 36, 37, 37, 37, 38,
38, 38, 38, 39, 39, 39, 39, 40,
40, 40, 40, 41, 41, 41, 41, 42,
42, 42, 42, 42, 43, 43, 43, 43,
44, 44, 44, 44, 45, 45, 45, 45,
46, 46, 46, 46, 46, 47, 47, 47,
47, 48, 48, 48, 48, 48, 49, 49,
49, 49, 50, 50, 50, 50, 50, 51,
51, 51, 51, 51, 52, 52, 52, 52,
52, 53, 53, 53, 53, 53, 54, 54,
54, 54, 54, 55, 55, 55, 55, 55,
56, 56, 56, 56, 56, 57, 57, 57,
57, 57, 57, 58, 58, 58, 58, 58,
59, 59, 59, 59, 59, 59, 60, 60,
60, 60, 60, 61, 61, 61, 61, 61,
61, 62, 62, 62, 62, 62, 62, 63,
63, 63, 63, 63, 63, 64, 64, 64
};
FT_LOCAL_DEF( AF_Angle )
af_angle_atan( FT_Fixed dx,
FT_Fixed dy )
{
AF_Angle angle;
/* check trivial cases */
if ( dy == 0 )
{
angle = 0;
if ( dx < 0 )
angle = AF_ANGLE_PI;
return angle;
}
else if ( dx == 0 )
{
angle = AF_ANGLE_PI2;
if ( dy < 0 )
angle = -AF_ANGLE_PI2;
return angle;
}
angle = 0;
if ( dx < 0 )
{
dx = -dx;
dy = -dy;
angle = AF_ANGLE_PI;
}
if ( dy < 0 )
{
FT_Pos tmp;
tmp = dx;
dx = -dy;
dy = tmp;
angle -= AF_ANGLE_PI2;
}
if ( dx == 0 && dy == 0 )
return 0;
if ( dx == dy )
angle += AF_ANGLE_PI4;
else if ( dx > dy )
angle += af_arctan[FT_DivFix( dy, dx ) >> ( 16 - AF_ATAN_BITS )];
else
angle += AF_ANGLE_PI2 -
af_arctan[FT_DivFix( dx, dy ) >> ( 16 - AF_ATAN_BITS )];
if ( angle > AF_ANGLE_PI )
angle -= AF_ANGLE_2PI;
return angle;
}
#endif /* 0 */
FT_LOCAL_DEF( void )
af_sort_pos( FT_UInt count,
FT_Pos* table )
{
FT_UInt i, j;
FT_Pos swap;
for ( i = 1; i < count; i++ )
{
for ( j = i; j > 0; j-- )
{
if ( table[j] >= table[j - 1] )
break;
swap = table[j];
table[j] = table[j - 1];
table[j - 1] = swap;
}
}
}
FT_LOCAL_DEF( void )
af_sort_and_quantize_widths( FT_UInt* count,
AF_Width table,
FT_Pos threshold )
{
FT_UInt i, j;
FT_UInt cur_idx;
FT_Pos cur_val;
FT_Pos sum;
AF_WidthRec swap;
if ( *count == 1 )
return;
/* sort */
for ( i = 1; i < *count; i++ )
{
for ( j = i; j > 0; j-- )
{
if ( table[j].org >= table[j - 1].org )
break;
swap = table[j];
table[j] = table[j - 1];
table[j - 1] = swap;
}
}
cur_idx = 0;
cur_val = table[cur_idx].org;
/* compute and use mean values for clusters not larger than */
/* `threshold'; this is very primitive and might not yield */
/* the best result, but normally, using reference character */
/* `o', `*count' is 2, so the code below is fully sufficient */
for ( i = 1; i < *count; i++ )
{
if ( table[i].org - cur_val > threshold ||
i == *count - 1 )
{
sum = 0;
/* fix loop for end of array */
if ( table[i].org - cur_val <= threshold &&
i == *count - 1 )
i++;
for ( j = cur_idx; j < i; j++ )
{
sum += table[j].org;
table[j].org = 0;
}
table[cur_idx].org = sum / (FT_Pos)j;
if ( i < *count - 1 )
{
cur_idx = i + 1;
cur_val = table[cur_idx].org;
}
}
}
cur_idx = 1;
/* compress array to remove zero values */
for ( i = 1; i < *count; i++ )
{
if ( table[i].org )
table[cur_idx++] = table[i];
}
*count = cur_idx;
}
/* END */

View file

@ -1,7 +0,0 @@
/*
* afangles.h
*
* This is a dummy file, used to please the build system. It is never
* included by the auto-fitter sources.
*
*/

View file

@ -1,22 +1,22 @@
/* This file has been generated by the Perl script `afblue.pl', */
/* using data from file `afblue.dat'. */
/***************************************************************************/
/* */
/* afblue.c */
/* */
/* Auto-fitter data for blue strings (body). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afblue.c
*
* Auto-fitter data for blue strings (body).
*
* Copyright (C) 2013-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 "aftypes.h"
@ -134,7 +134,7 @@
'\0',
'\xF0', '\x90', '\x90', '\xA8', ' ', '\xF0', '\x90', '\x90', '\xAA', ' ', '\xF0', '\x90', '\x90', '\xAC', ' ', '\xF0', '\x90', '\x90', '\xBF', ' ', '\xF0', '\x90', '\x91', '\x83', /* 𐐨 𐐪 𐐬 𐐿 𐑃 */
'\0',
'\xE0', '\xA4', '\x95', ' ', '\xE0', '\xA4', '\xAE', ' ', '\xE0', '\xA4', '\x85', ' ', '\xE0', '\xA4', '\x86', ' ', '\xE0', '\xA4', '\xA5', ' ', '\xE0', '\xA4', '\xA7', ' ', '\xE0', '\xA4', '\xAD', ' ', '\xE0', '\xA4', '\xB6', /* क म अ आ थ ध भ श */
'\xE0', '\xA4', '\x95', ' ', '\xE0', '\xA4', '\xA8', ' ', '\xE0', '\xA4', '\xAE', ' ', '\xE0', '\xA4', '\x89', ' ', '\xE0', '\xA4', '\x9B', ' ', '\xE0', '\xA4', '\x9F', ' ', '\xE0', '\xA4', '\xA0', ' ', '\xE0', '\xA4', '\xA1', /* क न म उ छ ट ठ ड */
'\0',
'\xE0', '\xA4', '\x88', ' ', '\xE0', '\xA4', '\x90', ' ', '\xE0', '\xA4', '\x93', ' ', '\xE0', '\xA4', '\x94', ' ', '\xE0', '\xA4', '\xBF', ' ', '\xE0', '\xA5', '\x80', ' ', '\xE0', '\xA5', '\x8B', ' ', '\xE0', '\xA5', '\x8C', /* ई ऐ ओ औ ि ी ो ौ */
'\0',
@ -296,6 +296,24 @@
'\0',
'\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xA7', ' ', '\xE0', '\xB4', '\xB6', ' ', '\xE0', '\xB4', '\x98', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xA5', ' ', '\xE0', '\xB4', '\xB2', /* ട ധ ശ ഘ ച ഥ ല */
'\0',
'\xF0', '\x96', '\xB9', '\x80', ' ', '\xF0', '\x96', '\xB9', '\x81', ' ', '\xF0', '\x96', '\xB9', '\x82', ' ', '\xF0', '\x96', '\xB9', '\x83', ' ', '\xF0', '\x96', '\xB9', '\x8F', ' ', '\xF0', '\x96', '\xB9', '\x9A', ' ', '\xF0', '\x96', '\xB9', '\x9F', /* 𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹟 */
'\0',
'\xF0', '\x96', '\xB9', '\x80', ' ', '\xF0', '\x96', '\xB9', '\x81', ' ', '\xF0', '\x96', '\xB9', '\x82', ' ', '\xF0', '\x96', '\xB9', '\x83', ' ', '\xF0', '\x96', '\xB9', '\x8F', ' ', '\xF0', '\x96', '\xB9', '\x9A', ' ', '\xF0', '\x96', '\xB9', '\x92', ' ', '\xF0', '\x96', '\xB9', '\x93', /* 𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹒 𖹓 */
'\0',
'\xF0', '\x96', '\xB9', '\xA4', ' ', '\xF0', '\x96', '\xB9', '\xAC', ' ', '\xF0', '\x96', '\xB9', '\xA7', ' ', '\xF0', '\x96', '\xB9', '\xB4', ' ', '\xF0', '\x96', '\xB9', '\xB6', ' ', '\xF0', '\x96', '\xB9', '\xBE', /* 𖹤 𖹬 𖹧 𖹴 𖹶 𖹾 */
'\0',
'\xF0', '\x96', '\xB9', '\xA0', ' ', '\xF0', '\x96', '\xB9', '\xA1', ' ', '\xF0', '\x96', '\xB9', '\xA2', ' ', '\xF0', '\x96', '\xB9', '\xB9', ' ', '\xF0', '\x96', '\xB9', '\xB3', ' ', '\xF0', '\x96', '\xB9', '\xAE', /* 𖹠 𖹡 𖹢 𖹹 𖹳 𖹮 */
'\0',
'\xF0', '\x96', '\xB9', '\xA0', ' ', '\xF0', '\x96', '\xB9', '\xA1', ' ', '\xF0', '\x96', '\xB9', '\xA2', ' ', '\xF0', '\x96', '\xB9', '\xB3', ' ', '\xF0', '\x96', '\xB9', '\xAD', ' ', '\xF0', '\x96', '\xB9', '\xBD', /* 𖹠 𖹡 𖹢 𖹳 𖹭 𖹽 */
'\0',
'\xF0', '\x96', '\xB9', '\xA5', ' ', '\xF0', '\x96', '\xB9', '\xA8', ' ', '\xF0', '\x96', '\xB9', '\xA9', /* 𖹥 𖹨 𖹩 */
'\0',
'\xF0', '\x96', '\xBA', '\x80', ' ', '\xF0', '\x96', '\xBA', '\x85', ' ', '\xF0', '\x96', '\xBA', '\x88', ' ', '\xF0', '\x96', '\xBA', '\x84', ' ', '\xF0', '\x96', '\xBA', '\x8D', /* 𖺀 𖺅 𖺈 𖺄 𖺍 */
'\0',
'\xE1', '\xA0', '\xB3', ' ', '\xE1', '\xA0', '\xB4', ' ', '\xE1', '\xA0', '\xB6', ' ', '\xE1', '\xA0', '\xBD', ' ', '\xE1', '\xA1', '\x82', ' ', '\xE1', '\xA1', '\x8A', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xA1', '\xE2', '\x80', '\x8D', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xB3', '\xE2', '\x80', '\x8D', /* ᠳ ᠴ ᠶ ᠽ ᡂ ᡊ ‍ᡡ‍ ‍ᡳ‍ */
'\0',
'\xE1', '\xA1', '\x83', /* ᡃ */
'\0',
'\xE1', '\x80', '\x81', ' ', '\xE1', '\x80', '\x82', ' ', '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\xA5', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* ခ ဂ င ဒ ၥ ၊ ။ */
'\0',
'\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x8E', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x95', ' ', '\xE1', '\x80', '\x97', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* င ဎ ဒ ပ ဗ ၊ ။ */
@ -336,6 +354,12 @@
'\0',
'\xF0', '\x90', '\x92', '\x80', ' ', '\xF0', '\x90', '\x92', '\x82', ' ', '\xF0', '\x90', '\x92', '\x86', ' ', '\xF0', '\x90', '\x92', '\x88', ' ', '\xF0', '\x90', '\x92', '\x8A', ' ', '\xF0', '\x90', '\x92', '\x92', ' ', '\xF0', '\x90', '\x92', '\xA0', ' ', '\xF0', '\x90', '\x92', '\xA9', /* 𐒀 𐒂 𐒆 𐒈 𐒊 𐒒 𐒠 𐒩 */
'\0',
'\xF0', '\x90', '\xB4', '\x83', ' ', '\xF0', '\x90', '\xB4', '\x80', ' ', '\xF0', '\x90', '\xB4', '\x86', ' ', '\xF0', '\x90', '\xB4', '\x96', ' ', '\xF0', '\x90', '\xB4', '\x95', /* 𐴃 𐴀 𐴆 𐴖 𐴕 */
'\0',
'\xF0', '\x90', '\xB4', '\x94', ' ', '\xF0', '\x90', '\xB4', '\x96', ' ', '\xF0', '\x90', '\xB4', '\x95', ' ', '\xF0', '\x90', '\xB4', '\x91', ' ', '\xF0', '\x90', '\xB4', '\x90', /* 𐴔 𐴖 𐴕 𐴑 𐴐 */
'\0',
'\xD9', '\x80', /* ـ */
'\0',
'\xEA', '\xA2', '\x9C', ' ', '\xEA', '\xA2', '\x9E', ' ', '\xEA', '\xA2', '\xB3', ' ', '\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\x96', ' ', '\xEA', '\xA2', '\x92', ' ', '\xEA', '\xA2', '\x9D', ' ', '\xEA', '\xA2', '\x9B', /* ꢜ ꢞ ꢳ ꢂ ꢖ ꢒ ꢝ ꢛ */
'\0',
'\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\xA8', ' ', '\xEA', '\xA2', '\xBA', ' ', '\xEA', '\xA2', '\xA4', ' ', '\xEA', '\xA2', '\x8E', /* ꢂ ꢨ ꢺ ꢤ ꢎ */
@ -484,14 +508,14 @@
{ AF_BLUE_STRING_CHAKMA_BOTTOM, 0 },
{ AF_BLUE_STRING_CHAKMA_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CARIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CARIAN_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
@ -591,6 +615,9 @@
{ AF_BLUE_STRING_HEBREW_BOTTOM, 0 },
{ AF_BLUE_STRING_HEBREW_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_KANNADA_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_KAYAH_LI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_KAYAH_LI_BOTTOM, 0 },
@ -609,9 +636,6 @@
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_KANNADA_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_LAO_BOTTOM, 0 },
@ -649,6 +673,18 @@
{ AF_BLUE_STRING_MALAYALAM_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MONGOLIAN_TOP_BASE, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_MYANMAR_BOTTOM, 0 },
@ -680,6 +716,10 @@
{ AF_BLUE_STRING_OSMANYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_OSMANYA_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_ROHINGYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_ROHINGYA_BOTTOM, 0 },
{ AF_BLUE_STRING_ROHINGYA_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_SAURASHTRA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
@ -707,9 +747,6 @@
{ AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_TELUGU_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_TIFINAGH, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_THAI_BOTTOM, 0 },
@ -719,6 +756,9 @@
{ AF_BLUE_STRING_THAI_LARGE_DESCENDER, 0 },
{ AF_BLUE_STRING_THAI_DIGIT_TOP, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_TIFINAGH, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_VAI_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afblue.c */
/* */
/* Auto-fitter data for blue strings (body). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afblue.c
*
* Auto-fitter data for blue strings (body).
*
* Copyright (C) 2013-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 "aftypes.h"

View file

@ -1,15 +1,15 @@
// afblue.dat
// afblue.dat
//
// Auto-fitter data for blue strings.
// Auto-fitter data for blue strings.
//
// Copyright 2013-2018 by
// David Turner, Robert Wilhelm, and Werner Lemberg.
// Copyright (C) 2013-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 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 contains data specific to blue zones. It gets processed by
@ -203,7 +203,7 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
"𐐨 𐐪 𐐬 𐐿 𐑃"
AF_BLUE_STRING_DEVANAGARI_BASE
"क म अ आ थ ध भ श"
"क न म उ छ ट ठ ड"
AF_BLUE_STRING_DEVANAGARI_TOP
"ई ऐ ओ औ ि ी ो ौ"
// note that some fonts have extreme variation in the height of the
@ -392,6 +392,26 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
AF_BLUE_STRING_MALAYALAM_BOTTOM
"ട ധ ശ ഘ ച ഥ ല"
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP
"𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹟"
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM
"𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹒 𖹓"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP
"𖹤 𖹬 𖹧 𖹴 𖹶 𖹾"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP
"𖹠 𖹡 𖹢 𖹹 𖹳 𖹮"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM
"𖹠 𖹡 𖹢 𖹳 𖹭 𖹽"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER
"𖹥 𖹨 𖹩"
AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP
"𖺀 𖺅 𖺈 𖺄 𖺍"
AF_BLUE_STRING_MONGOLIAN_TOP_BASE
"ᠳ ᠴ ᠶ ᠽ ᡂ ᡊ ‍ᡡ‍ ‍ᡳ‍"
AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE
"ᡃ"
AF_BLUE_STRING_MYANMAR_TOP
"ခ ဂ င ဒ ၥ ၊ ။"
AF_BLUE_STRING_MYANMAR_BOTTOM
@ -438,6 +458,13 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
AF_BLUE_STRING_OSMANYA_BOTTOM
"𐒀 𐒂 𐒆 𐒈 𐒊 𐒒 𐒠 𐒩"
AF_BLUE_STRING_ROHINGYA_TOP
"𐴃 𐴀 𐴆 𐴖 𐴕"
AF_BLUE_STRING_ROHINGYA_BOTTOM
"𐴔 𐴖 𐴕 𐴑 𐴐"
AF_BLUE_STRING_ROHINGYA_JOIN
"ـ"
AF_BLUE_STRING_SAURASHTRA_TOP
"ꢜ ꢞ ꢳ ꢂ ꢖ ꢒ ꢝ ꢛ"
AF_BLUE_STRING_SAURASHTRA_BOTTOM
@ -729,14 +756,14 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CANS
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CARI
{ AF_BLUE_STRING_CARIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
@ -869,6 +896,11 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_HEBREW_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_KNDA
{ AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_KANNADA_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_KALI
{ AF_BLUE_STRING_KAYAH_LI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
@ -893,11 +925,6 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_KNDA
{ AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_KANNADA_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_LAO
{ AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
@ -947,6 +974,22 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_MEDF
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_MONG
{ AF_BLUE_STRING_MONGOLIAN_TOP_BASE, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_MYMR
{ AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
@ -992,6 +1035,12 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_OSMANYA_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_ROHG
{ AF_BLUE_STRING_ROHINGYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_ROHINGYA_BOTTOM, 0 }
{ AF_BLUE_STRING_ROHINGYA_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_SAUR
{ AF_BLUE_STRING_SAURASHTRA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0 }
@ -1033,11 +1082,6 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_TELUGU_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_TFNG
{ AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_TIFINAGH, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_THAI
{ AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
@ -1049,6 +1093,11 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_THAI_DIGIT_TOP, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_TFNG
{ AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_TIFINAGH, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_VAII
{ AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_VAI_BOTTOM, 0 }

View file

@ -1,22 +1,22 @@
/* This file has been generated by the Perl script `afblue.pl', */
/* using data from file `afblue.dat'. */
/***************************************************************************/
/* */
/* afblue.h */
/* */
/* Auto-fitter data for blue strings (specification). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afblue.h
*
* Auto-fitter data for blue strings (specification).
*
* Copyright (C) 2013-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 AFBLUE_H_
@ -212,56 +212,68 @@ FT_BEGIN_HEADER
AF_BLUE_STRING_LISU_BOTTOM = 3506,
AF_BLUE_STRING_MALAYALAM_TOP = 3538,
AF_BLUE_STRING_MALAYALAM_BOTTOM = 3582,
AF_BLUE_STRING_MYANMAR_TOP = 3614,
AF_BLUE_STRING_MYANMAR_BOTTOM = 3646,
AF_BLUE_STRING_MYANMAR_ASCENDER = 3678,
AF_BLUE_STRING_MYANMAR_DESCENDER = 3706,
AF_BLUE_STRING_NKO_TOP = 3738,
AF_BLUE_STRING_NKO_BOTTOM = 3762,
AF_BLUE_STRING_NKO_SMALL_TOP = 3777,
AF_BLUE_STRING_NKO_SMALL_BOTTOM = 3786,
AF_BLUE_STRING_OL_CHIKI = 3798,
AF_BLUE_STRING_OLD_TURKIC_TOP = 3822,
AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 3837,
AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 3857,
AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 3897,
AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 3927,
AF_BLUE_STRING_OSAGE_SMALL_TOP = 3942,
AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 3982,
AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 4022,
AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 4047,
AF_BLUE_STRING_OSMANYA_TOP = 4062,
AF_BLUE_STRING_OSMANYA_BOTTOM = 4102,
AF_BLUE_STRING_SAURASHTRA_TOP = 4142,
AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4174,
AF_BLUE_STRING_SHAVIAN_TOP = 4194,
AF_BLUE_STRING_SHAVIAN_BOTTOM = 4204,
AF_BLUE_STRING_SHAVIAN_DESCENDER = 4229,
AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4239,
AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4274,
AF_BLUE_STRING_SINHALA_TOP = 4289,
AF_BLUE_STRING_SINHALA_BOTTOM = 4321,
AF_BLUE_STRING_SINHALA_DESCENDER = 4353,
AF_BLUE_STRING_SUNDANESE_TOP = 4397,
AF_BLUE_STRING_SUNDANESE_BOTTOM = 4421,
AF_BLUE_STRING_SUNDANESE_DESCENDER = 4453,
AF_BLUE_STRING_TAI_VIET_TOP = 4461,
AF_BLUE_STRING_TAI_VIET_BOTTOM = 4481,
AF_BLUE_STRING_TAMIL_TOP = 4493,
AF_BLUE_STRING_TAMIL_BOTTOM = 4525,
AF_BLUE_STRING_TELUGU_TOP = 4557,
AF_BLUE_STRING_TELUGU_BOTTOM = 4585,
AF_BLUE_STRING_THAI_TOP = 4613,
AF_BLUE_STRING_THAI_BOTTOM = 4637,
AF_BLUE_STRING_THAI_ASCENDER = 4665,
AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4677,
AF_BLUE_STRING_THAI_DESCENDER = 4689,
AF_BLUE_STRING_THAI_LARGE_DESCENDER = 4705,
AF_BLUE_STRING_THAI_DIGIT_TOP = 4713,
AF_BLUE_STRING_TIFINAGH = 4725,
AF_BLUE_STRING_VAI_TOP = 4757,
AF_BLUE_STRING_VAI_BOTTOM = 4789,
af_blue_1_1 = 4820,
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP = 3614,
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM = 3649,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP = 3689,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP = 3719,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM = 3749,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER = 3779,
AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP = 3794,
AF_BLUE_STRING_MONGOLIAN_TOP_BASE = 3819,
AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE = 3863,
AF_BLUE_STRING_MYANMAR_TOP = 3867,
AF_BLUE_STRING_MYANMAR_BOTTOM = 3899,
AF_BLUE_STRING_MYANMAR_ASCENDER = 3931,
AF_BLUE_STRING_MYANMAR_DESCENDER = 3959,
AF_BLUE_STRING_NKO_TOP = 3991,
AF_BLUE_STRING_NKO_BOTTOM = 4015,
AF_BLUE_STRING_NKO_SMALL_TOP = 4030,
AF_BLUE_STRING_NKO_SMALL_BOTTOM = 4039,
AF_BLUE_STRING_OL_CHIKI = 4051,
AF_BLUE_STRING_OLD_TURKIC_TOP = 4075,
AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 4090,
AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 4110,
AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 4150,
AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 4180,
AF_BLUE_STRING_OSAGE_SMALL_TOP = 4195,
AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 4235,
AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 4275,
AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 4300,
AF_BLUE_STRING_OSMANYA_TOP = 4315,
AF_BLUE_STRING_OSMANYA_BOTTOM = 4355,
AF_BLUE_STRING_ROHINGYA_TOP = 4395,
AF_BLUE_STRING_ROHINGYA_BOTTOM = 4420,
AF_BLUE_STRING_ROHINGYA_JOIN = 4445,
AF_BLUE_STRING_SAURASHTRA_TOP = 4448,
AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4480,
AF_BLUE_STRING_SHAVIAN_TOP = 4500,
AF_BLUE_STRING_SHAVIAN_BOTTOM = 4510,
AF_BLUE_STRING_SHAVIAN_DESCENDER = 4535,
AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4545,
AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4580,
AF_BLUE_STRING_SINHALA_TOP = 4595,
AF_BLUE_STRING_SINHALA_BOTTOM = 4627,
AF_BLUE_STRING_SINHALA_DESCENDER = 4659,
AF_BLUE_STRING_SUNDANESE_TOP = 4703,
AF_BLUE_STRING_SUNDANESE_BOTTOM = 4727,
AF_BLUE_STRING_SUNDANESE_DESCENDER = 4759,
AF_BLUE_STRING_TAI_VIET_TOP = 4767,
AF_BLUE_STRING_TAI_VIET_BOTTOM = 4787,
AF_BLUE_STRING_TAMIL_TOP = 4799,
AF_BLUE_STRING_TAMIL_BOTTOM = 4831,
AF_BLUE_STRING_TELUGU_TOP = 4863,
AF_BLUE_STRING_TELUGU_BOTTOM = 4891,
AF_BLUE_STRING_THAI_TOP = 4919,
AF_BLUE_STRING_THAI_BOTTOM = 4943,
AF_BLUE_STRING_THAI_ASCENDER = 4971,
AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4983,
AF_BLUE_STRING_THAI_DESCENDER = 4995,
AF_BLUE_STRING_THAI_LARGE_DESCENDER = 5011,
AF_BLUE_STRING_THAI_DIGIT_TOP = 5019,
AF_BLUE_STRING_TIFINAGH = 5031,
AF_BLUE_STRING_VAI_TOP = 5063,
AF_BLUE_STRING_VAI_BOTTOM = 5095,
af_blue_1_1 = 5126,
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203,
@ -345,34 +357,37 @@ FT_BEGIN_HEADER
AF_BLUE_STRINGSET_GUJR = 112,
AF_BLUE_STRINGSET_GURU = 118,
AF_BLUE_STRINGSET_HEBR = 124,
AF_BLUE_STRINGSET_KALI = 128,
AF_BLUE_STRINGSET_KHMR = 134,
AF_BLUE_STRINGSET_KHMS = 140,
AF_BLUE_STRINGSET_KNDA = 143,
AF_BLUE_STRINGSET_KNDA = 128,
AF_BLUE_STRINGSET_KALI = 131,
AF_BLUE_STRINGSET_KHMR = 137,
AF_BLUE_STRINGSET_KHMS = 143,
AF_BLUE_STRINGSET_LAO = 146,
AF_BLUE_STRINGSET_LATN = 152,
AF_BLUE_STRINGSET_LATB = 159,
AF_BLUE_STRINGSET_LATP = 166,
AF_BLUE_STRINGSET_LISU = 173,
AF_BLUE_STRINGSET_MLYM = 176,
AF_BLUE_STRINGSET_MYMR = 179,
AF_BLUE_STRINGSET_NKOO = 184,
AF_BLUE_STRINGSET_NONE = 189,
AF_BLUE_STRINGSET_OLCK = 190,
AF_BLUE_STRINGSET_ORKH = 193,
AF_BLUE_STRINGSET_OSGE = 196,
AF_BLUE_STRINGSET_OSMA = 204,
AF_BLUE_STRINGSET_SAUR = 207,
AF_BLUE_STRINGSET_SHAW = 210,
AF_BLUE_STRINGSET_SINH = 216,
AF_BLUE_STRINGSET_SUND = 220,
AF_BLUE_STRINGSET_TAML = 224,
AF_BLUE_STRINGSET_TAVT = 227,
AF_BLUE_STRINGSET_TELU = 230,
AF_BLUE_STRINGSET_TFNG = 233,
AF_BLUE_STRINGSET_THAI = 236,
AF_BLUE_STRINGSET_VAII = 244,
af_blue_2_1 = 247,
AF_BLUE_STRINGSET_MEDF = 179,
AF_BLUE_STRINGSET_MONG = 187,
AF_BLUE_STRINGSET_MYMR = 190,
AF_BLUE_STRINGSET_NKOO = 195,
AF_BLUE_STRINGSET_NONE = 200,
AF_BLUE_STRINGSET_OLCK = 201,
AF_BLUE_STRINGSET_ORKH = 204,
AF_BLUE_STRINGSET_OSGE = 207,
AF_BLUE_STRINGSET_OSMA = 215,
AF_BLUE_STRINGSET_ROHG = 218,
AF_BLUE_STRINGSET_SAUR = 222,
AF_BLUE_STRINGSET_SHAW = 225,
AF_BLUE_STRINGSET_SINH = 231,
AF_BLUE_STRINGSET_SUND = 235,
AF_BLUE_STRINGSET_TAML = 239,
AF_BLUE_STRINGSET_TAVT = 242,
AF_BLUE_STRINGSET_TELU = 245,
AF_BLUE_STRINGSET_THAI = 248,
AF_BLUE_STRINGSET_TFNG = 256,
AF_BLUE_STRINGSET_VAII = 259,
af_blue_2_1 = 262,
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
af_blue_2_1_1 = af_blue_2_1 + 2,

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afblue.h */
/* */
/* Auto-fitter data for blue strings (specification). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afblue.h
*
* Auto-fitter data for blue strings (specification).
*
* Copyright (C) 2013-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 AFBLUE_H_

View file

@ -1,33 +1,31 @@
/***************************************************************************/
/* */
/* afcjk.c */
/* */
/* Auto-fitter hinting routines for CJK writing system (body). */
/* */
/* Copyright 2006-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afcjk.c
*
* Auto-fitter hinting routines for CJK writing system (body).
*
* Copyright (C) 2006-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.
*
*/
/*
* The algorithm is based on akito's autohint patch, archived at
* The algorithm is based on akito's autohint patch, archived at
*
* https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/
* https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/
*
*/
#include <ft2build.h>
#include FT_ADVANCES_H
#include FT_INTERNAL_DEBUG_H
#include <freetype/ftadvanc.h>
#include <freetype/internal/ftdebug.h>
#include "afglobal.h"
#include "afpic.h"
#include "aflatin.h"
#include "afcjk.h"
@ -39,19 +37,14 @@
#include "aferrors.h"
#ifdef AF_CONFIG_OPTION_USE_WARPER
#include "afwarp.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_afcjk
#define FT_COMPONENT afcjk
/*************************************************************************/
@ -74,11 +67,11 @@
AF_GlyphHintsRec hints[1];
FT_TRACE5(( "\n"
"cjk standard widths computation (style `%s')\n"
"===================================================\n"
"\n",
FT_TRACE5(( "\n" ));
FT_TRACE5(( "cjk standard widths computation (style `%s')\n",
af_style_names[metrics->root.style_class->style] ));
FT_TRACE5(( "===================================================\n" ));
FT_TRACE5(( "\n" ));
af_glyph_hints_init( hints, face->memory );
@ -92,23 +85,29 @@
AF_CJKMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = metrics->root.globals;
AF_StyleClass style_class = metrics->root.style_class;
AF_ScriptClass script_class = af_script_classes[style_class->script];
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
AF_StyleClass style_class = metrics->root.style_class;
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
void* shaper_buf;
const char* p;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_ULong ch = 0;
#endif
p = script_class->standard_charstring;
p = script_class->standard_charstring;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
/* We check a list of standard characters. The first match wins. */
@ -153,7 +152,7 @@
if ( !glyph_index )
goto Exit;
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
FT_TRACE5(( "standard character: U+%04lX (glyph index %ld)\n",
ch, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
@ -193,10 +192,10 @@
goto Exit;
/*
* We assume that the glyphs selected for the stem width
* computation are `featureless' enough so that the linking
* algorithm works fine without adjustments of its scoring
* function.
* We assume that the glyphs selected for the stem width
* computation are `featureless' enough so that the linking
* algorithm works fine without adjustments of its scoring
* function.
*/
af_latin_hints_link_segments( hints,
0,
@ -256,9 +255,9 @@
dim == AF_DIMENSION_VERT ? "horizontal"
: "vertical" ));
FT_TRACE5(( " %d (standard)", axis->standard_width ));
FT_TRACE5(( " %ld (standard)", axis->standard_width ));
for ( i = 1; i < axis->width_count; i++ )
FT_TRACE5(( " %d", axis->widths[i].org ));
FT_TRACE5(( " %ld", axis->widths[i].org ));
FT_TRACE5(( "\n" ));
}
@ -296,18 +295,27 @@
AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
void* shaper_buf;
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array, computing its */
/* extremum points (depending on the string properties) */
FT_TRACE5(( "cjk blue zones computation\n"
"==========================\n"
"\n" ));
FT_TRACE5(( "cjk blue zones computation\n" ));
FT_TRACE5(( "==========================\n" ));
FT_TRACE5(( "\n" ));
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
{
@ -483,8 +491,8 @@
if ( num_flats == 0 && num_fills == 0 )
{
/*
* we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then
* we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then
*/
FT_TRACE5(( " empty\n" ));
continue;
@ -542,9 +550,8 @@
if ( AF_CJK_IS_TOP_BLUE( bs ) )
blue->flags |= AF_CJK_BLUE_TOP;
FT_TRACE5(( " -> reference = %ld\n"
" overshoot = %ld\n",
*blue_ref, *blue_shoot ));
FT_TRACE5(( " -> reference = %ld\n", *blue_ref ));
FT_TRACE5(( " overshoot = %ld\n", *blue_shoot ));
} /* end for loop */
@ -565,15 +572,25 @@
FT_Bool started = 0, same_width = 1;
FT_Fixed advance = 0, old_advance = 0;
void* shaper_buf;
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
/* in all supported charmaps, digits have character codes 0x30-0x39 */
const char digits[] = "0 1 2 3 4 5 6 7 8 9";
const char* p;
p = digits;
p = digits;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
while ( *p )
{
@ -633,7 +650,7 @@
af_cjk_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
face->charmap = oldmap;
return FT_Err_Ok;
}
@ -704,7 +721,7 @@
delta2 = FT_MulFix( delta2, scale );
FT_TRACE5(( "delta: %d", delta1 ));
FT_TRACE5(( "delta: %ld", delta1 ));
if ( delta2 < 32 )
delta2 = 0;
#if 0
@ -713,20 +730,22 @@
#endif
else
delta2 = FT_PIX_ROUND( delta2 );
FT_TRACE5(( "/%d\n", delta2 ));
FT_TRACE5(( "/%ld\n", delta2 ));
if ( delta1 < 0 )
delta2 = -delta2;
blue->shoot.fit = blue->ref.fit - delta2;
FT_TRACE5(( ">> active cjk blue zone %c%d[%ld/%ld]:\n"
" ref: cur=%.2f fit=%.2f\n"
" shoot: cur=%.2f fit=%.2f\n",
FT_TRACE5(( ">> active cjk blue zone %c%d[%ld/%ld]:\n",
( dim == AF_DIMENSION_HORZ ) ? 'H' : 'V',
nn, blue->ref.org, blue->shoot.org,
blue->ref.cur / 64.0, blue->ref.fit / 64.0,
blue->shoot.cur / 64.0, blue->shoot.fit / 64.0 ));
nn, blue->ref.org, blue->shoot.org ));
FT_TRACE5(( " ref: cur=%.2f fit=%.2f\n",
(double)blue->ref.cur / 64,
(double)blue->ref.fit / 64 ));
FT_TRACE5(( " shoot: cur=%.2f fit=%.2f\n",
(double)blue->shoot.cur / 64,
(double)blue->shoot.fit / 64 ));
blue->flags |= AF_CJK_BLUE_ACTIVE;
}
@ -782,7 +801,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
FT_Error error;
AF_Segment seg;
@ -826,7 +845,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
AF_Direction major_dir = axis->major_dir;
AF_Segment seg1, seg2;
FT_Pos len_threshold;
@ -890,11 +909,11 @@
}
/*
* now compute the `serif' segments
* now compute the `serif' segments
*
* In Hanzi, some strokes are wider on one or both of the ends.
* We either identify the stems on the ends as serifs or remove
* the linkage, depending on the length of the stems.
* In Hanzi, some strokes are wider on one or both of the ends.
* We either identify the stems on the ends as serifs or remove
* the linkage, depending on the length of the stems.
*
*/
@ -988,7 +1007,7 @@
AF_CJKAxis laxis = &((AF_CJKMetrics)hints->metrics)->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
AF_Segment seg;
FT_Fixed scale;
@ -1000,21 +1019,21 @@
scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
: hints->y_scale;
/*********************************************************************/
/* */
/* We begin by generating a sorted table of edges for the current */
/* direction. To do so, we simply scan each segment and try to find */
/* an edge in our table that corresponds to its position. */
/* */
/* If no edge is found, we create and insert a new edge in the */
/* sorted table. Otherwise, we simply add the segment to the edge's */
/* list which is then processed in the second step to compute the */
/* edge's properties. */
/* */
/* Note that the edges table is sorted along the segment/edge */
/* position. */
/* */
/*********************************************************************/
/**********************************************************************
*
* We begin by generating a sorted table of edges for the current
* direction. To do so, we simply scan each segment and try to find
* an edge in our table that corresponds to its position.
*
* If no edge is found, we create and insert a new edge in the
* sorted table. Otherwise, we simply add the segment to the edge's
* list which is then processed in the second step to compute the
* edge's properties.
*
* Note that the edges table is sorted along the segment/edge
* position.
*
*/
edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold,
scale );
@ -1027,7 +1046,7 @@
{
AF_Edge found = NULL;
FT_Pos best = 0xFFFFU;
FT_Int ee;
FT_UInt ee;
/* look for an edge corresponding to the segment */
@ -1114,17 +1133,17 @@
}
}
/******************************************************************/
/* */
/* Good, we now compute each edge's properties according to the */
/* segments found on its position. Basically, these are */
/* */
/* - the edge's main direction */
/* - stem edge, serif edge or both (which defaults to stem then) */
/* - rounded edge, straight or both (which defaults to straight) */
/* - link for edge */
/* */
/******************************************************************/
/*******************************************************************
*
* Good, we now compute each edge's properties according to the
* segments found on its position. Basically, these are
*
* - the edge's main direction
* - stem edge, serif edge or both (which defaults to stem then)
* - rounded edge, straight or both (which defaults to straight)
* - link for edge
*
*/
/* first of all, set the `edge' field in each segment -- this is */
/* required in order to compute edge links */
@ -1136,7 +1155,7 @@
*/
{
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
AF_Edge edge;
@ -1160,6 +1179,8 @@
seg = edge->first;
if ( !seg )
goto Skip_Loop;
do
{
@ -1174,7 +1195,7 @@
/* check for links -- if seg->serif is set, then seg->link must */
/* be ignored */
is_serif = (FT_Bool)( seg->serif && seg->serif->edge != edge );
is_serif = FT_BOOL( seg->serif && seg->serif->edge != edge );
if ( seg->link || is_serif )
{
@ -1215,13 +1236,14 @@
edge2->flags |= AF_EDGE_SERIF;
}
else
edge->link = edge2;
edge->link = edge2;
}
seg = seg->edge_next;
} while ( seg != edge->first );
Skip_Loop:
/* set the round/straight flags */
edge->flags = AF_EDGE_NORMAL;
@ -1271,7 +1293,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edge = axis->edges;
AF_Edge edge_limit = edge + axis->num_edges;
AF_Edge edge_limit = FT_OFFSET( edge, axis->num_edges );
AF_CJKAxis cjk = &metrics->axis[dim];
FT_Fixed scale = cjk->scale;
FT_Pos best_dist0; /* initial threshold */
@ -1364,8 +1386,8 @@
af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
/*
* correct x_scale and y_scale when needed, since they may have
* been modified af_cjk_scale_dim above
* correct x_scale and y_scale when needed, since they may have
* been modified af_cjk_scale_dim above
*/
hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
@ -1375,30 +1397,25 @@
/* compute flags depending on render mode, etc. */
mode = metrics->root.scaler.render_mode;
#if 0 /* AF_CONFIG_OPTION_USE_WARPER */
if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
#endif
scaler_flags = hints->scaler_flags;
other_flags = 0;
/*
* We snap the width of vertical stems for the monochrome and
* horizontal LCD rendering targets only.
* We snap the width of vertical stems for the monochrome and
* horizontal LCD rendering targets only.
*/
if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD )
other_flags |= AF_LATIN_HINTS_HORZ_SNAP;
/*
* We snap the width of horizontal stems for the monochrome and
* vertical LCD rendering targets only.
* We snap the width of horizontal stems for the monochrome and
* vertical LCD rendering targets only.
*/
if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V )
other_flags |= AF_LATIN_HINTS_VERT_SNAP;
/*
* We adjust stems to full pixels unless in `light' or `lcd' mode.
* We adjust stems to full pixels unless in `light' or `lcd' mode.
*/
if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
@ -1408,12 +1425,6 @@
scaler_flags |= AF_SCALER_FLAG_NO_ADVANCE;
#ifdef AF_CONFIG_OPTION_USE_WARPER
/* get (global) warper flag */
if ( !metrics->root.globals->module->warping )
scaler_flags |= AF_SCALER_FLAG_NO_WARPER;
#endif
hints->scaler_flags = scaler_flags;
hints->other_flags = other_flags;
@ -1617,11 +1628,13 @@
stem_edge->pos = base_edge->pos + fitted_width;
FT_TRACE5(( " CJKLINK: edge %d @%d (opos=%.2f) linked to %.2f,"
FT_TRACE5(( " CJKLINK: edge %ld @%d (opos=%.2f) linked to %.2f,"
" dist was %.2f, now %.2f\n",
stem_edge - hints->axis[dim].edges, stem_edge->fpos,
stem_edge->opos / 64.0, stem_edge->pos / 64.0,
dist / 64.0, fitted_width / 64.0 ));
(double)stem_edge->opos / 64,
(double)stem_edge->pos / 64,
(double)dist / 64,
(double)fitted_width / 64 ));
}
@ -1789,7 +1802,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
FT_PtrDist n_edges;
AF_Edge edge;
AF_Edge anchor = NULL;
@ -1839,10 +1852,10 @@
continue;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " CJKBLUE: edge %d @%d (opos=%.2f) snapped to %.2f,"
FT_TRACE5(( " CJKBLUE: edge %ld @%d (opos=%.2f) snapped to %.2f,"
" was %.2f\n",
edge1 - edges, edge1->fpos, edge1->opos / 64.0,
blue->fit / 64.0, edge1->pos / 64.0 ));
edge1 - edges, edge1->fpos, (double)edge1->opos / 64,
(double)blue->fit / 64, (double)edge1->pos / 64 ));
num_actions++;
#endif
@ -1903,7 +1916,7 @@
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge )
{
FT_TRACE5(( "ASSERTION FAILED for edge %d\n", edge2-edges ));
FT_TRACE5(( "ASSERTION FAILED for edge %ld\n", edge2-edges ));
af_cjk_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
@ -2015,8 +2028,8 @@
#if 0
printf( "stem (%d,%d) adjusted (%.1f,%.1f)\n",
edge - edges, edge2 - edges,
( edge->pos - edge->opos ) / 64.0,
( edge2->pos - edge2->opos ) / 64.0 );
(double)( edge->pos - edge->opos ) / 64,
(double)( edge2->pos - edge2->opos ) / 64 );
#endif
anchor = edge;
@ -2094,8 +2107,8 @@
goto Exit;
/*
* now hint the remaining edges (serifs and single) in order
* to complete our processing
* now hint the remaining edges (serifs and single) in order
* to complete our processing
*/
for ( edge = edges; edge < edge_limit; edge++ )
{
@ -2168,7 +2181,7 @@
{
AF_AxisHints axis = & hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
AF_Edge edge;
FT_Bool snapping;
@ -2296,25 +2309,6 @@
if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) )
{
#ifdef AF_CONFIG_OPTION_USE_WARPER
if ( dim == AF_DIMENSION_HORZ &&
metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL &&
AF_HINTS_DO_WARP( hints ) )
{
AF_WarperRec warper;
FT_Fixed scale;
FT_Pos delta;
af_warper_compute( &warper, hints, (AF_Dimension)dim,
&scale, &delta );
af_glyph_hints_scale_dim( hints, (AF_Dimension)dim,
scale, delta );
continue;
}
#endif /* AF_CONFIG_OPTION_USE_WARPER */
af_cjk_hint_edges( hints, (AF_Dimension)dim );
af_cjk_align_edge_points( hints, (AF_Dimension)dim );
af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afcjk.h */
/* */
/* Auto-fitter hinting routines for CJK writing system (specification). */
/* */
/* Copyright 2006-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afcjk.h
*
* Auto-fitter hinting routines for CJK writing system (specification).
*
* Copyright (C) 2006-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 AFCJK_H_
@ -41,9 +41,9 @@ FT_BEGIN_HEADER
/*
* CJK glyphs tend to fill the square. So we have both vertical and
* horizontal blue zones. But some glyphs have flat bounding strokes that
* leave some space between neighbour glyphs.
* CJK glyphs tend to fill the square. So we have both vertical and
* horizontal blue zones. But some glyphs have flat bounding strokes that
* leave some space between neighbour glyphs.
*/
#define AF_CJK_IS_TOP_BLUE( b ) \

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afcover.h */
/* */
/* Auto-fitter coverages (specification only). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afcover.h
*
* Auto-fitter coverages (specification only).
*
* Copyright (C) 2013-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 header file can be included multiple times. */

View file

@ -1,20 +1,20 @@
/***************************************************************************/
/* */
/* afdummy.c */
/* */
/* Auto-fitter dummy routines to be used if no hinting should be */
/* performed (body). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afdummy.c
*
* Auto-fitter dummy routines to be used if no hinting should be
* performed (body).
*
* Copyright (C) 2003-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 "afdummy.h"
@ -38,13 +38,15 @@
static FT_Error
af_dummy_hints_apply( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline )
af_dummy_hints_apply( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
AF_StyleMetrics metrics )
{
FT_Error error;
FT_UNUSED( glyph_index );
FT_UNUSED( metrics );
error = af_glyph_hints_reload( hints, outline );

View file

@ -1,20 +1,20 @@
/***************************************************************************/
/* */
/* afdummy.h */
/* */
/* Auto-fitter dummy routines to be used if no hinting should be */
/* performed (specification). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afdummy.h
*
* Auto-fitter dummy routines to be used if no hinting should be
* performed (specification).
*
* Copyright (C) 2003-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 AFDUMMY_H_

View file

@ -1,32 +1,32 @@
/***************************************************************************/
/* */
/* aferrors.h */
/* */
/* Autofitter error codes (specification only). */
/* */
/* Copyright 2005-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* aferrors.h
*
* Autofitter error codes (specification only).
*
* Copyright (C) 2005-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 Autofitter error enumeration */
/* constants. */
/* */
/*************************************************************************/
/**************************************************************************
*
* This file is used to define the Autofitter error enumeration
* constants.
*
*/
#ifndef AFERRORS_H_
#define AFERRORS_H_
#include FT_MODULE_ERRORS_H
#include <freetype/ftmoderr.h>
#undef FTERRORS_H_
@ -34,7 +34,7 @@
#define FT_ERR_PREFIX AF_Err_
#define FT_ERR_BASE FT_Mod_Err_Autofit
#include FT_ERRORS_H
#include <freetype/fterrors.h>
#endif /* AFERRORS_H_ */

View file

@ -1,44 +1,39 @@
/***************************************************************************/
/* */
/* afglobal.c */
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afglobal.c
*
* Auto-fitter routines to compute global hinting values (body).
*
* Copyright (C) 2003-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 "afglobal.h"
#include "afranges.h"
#include "afshaper.h"
#include FT_INTERNAL_DEBUG_H
#include "afws-decl.h"
#include <freetype/internal/ftdebug.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_afglobal
#define FT_COMPONENT afglobal
/* get writing system specific header files */
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) /* empty */
#include "afwrtsys.h"
#include "aferrors.h"
#include "afpic.h"
#undef SCRIPT
@ -67,8 +62,6 @@
#include "afstyles.h"
#ifndef FT_CONFIG_OPTION_PIC
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
&af_ ## ws ## _writing_system_class,
@ -77,7 +70,7 @@
af_writing_system_classes[] =
{
#include "afwrtsys.h"
#include "afws-iter.h"
NULL /* do not remove */
};
@ -110,8 +103,6 @@
NULL /* do not remove */
};
#endif /* !FT_CONFIG_OPTION_PIC */
#ifdef FT_DEBUG_LEVEL_TRACE
@ -138,13 +129,13 @@
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_UShort* gstyles = globals->glyph_styles;
FT_UInt ss;
FT_UShort ss;
FT_UShort dflt = 0xFFFFU; /* a non-valid value */
FT_UInt i;
FT_UInt dflt = ~0U; /* a non-valid value */
/* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
for ( i = 0; i < (FT_UInt)globals->glyph_count; i++ )
for ( i = 0; i < globals->glyph_count; i++ )
gstyles[i] = AF_STYLE_UNASSIGNED;
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
@ -159,12 +150,12 @@
}
/* scan each style in a Unicode charmap */
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class =
AF_STYLE_CLASSES_GET[ss];
af_style_classes[ss];
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[style_class->script];
af_script_classes[style_class->script];
AF_Script_UniRange range;
@ -172,13 +163,12 @@
continue;
/*
* Scan all Unicode points in the range and set the corresponding
* glyph style index.
* Scan all Unicode points in the range and set the corresponding
* glyph style index.
*/
if ( style_class->coverage == AF_COVERAGE_DEFAULT )
{
if ( (FT_UInt)style_class->script ==
globals->module->default_script )
if ( style_class->script == globals->module->default_script )
dflt = ss;
for ( range = script_class->script_uni_ranges;
@ -192,9 +182,9 @@
gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 &&
gindex < (FT_ULong)globals->glyph_count &&
gindex < globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
gstyles[gindex] = (FT_UShort)ss;
gstyles[gindex] = ss;
for (;;)
{
@ -203,9 +193,9 @@
if ( gindex == 0 || charcode > range->last )
break;
if ( gindex < (FT_ULong)globals->glyph_count &&
if ( gindex < globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
gstyles[gindex] = (FT_UShort)ss;
gstyles[gindex] = ss;
}
}
@ -220,9 +210,9 @@
gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 &&
gindex < (FT_ULong)globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
if ( gindex != 0 &&
gindex < globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == ss )
gstyles[gindex] |= AF_NONBASE;
for (;;)
@ -232,8 +222,8 @@
if ( gindex == 0 || charcode > range->last )
break;
if ( gindex < (FT_ULong)globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
if ( gindex < globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == ss )
gstyles[gindex] |= AF_NONBASE;
}
}
@ -246,9 +236,9 @@
}
/* handle the remaining default OpenType features ... */
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
AF_StyleClass style_class = af_style_classes[ss];
if ( style_class->coverage == AF_COVERAGE_DEFAULT )
@ -256,7 +246,7 @@
}
/* ... and finally the default OpenType features of the default script */
af_shaper_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles, 1 );
af_shaper_get_coverage( globals, af_style_classes[dflt], gstyles, 1 );
/* mark ASCII digits */
for ( i = 0x30; i <= 0x39; i++ )
@ -264,18 +254,18 @@
FT_UInt gindex = FT_Get_Char_Index( face, i );
if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
if ( gindex != 0 && gindex < globals->glyph_count )
gstyles[gindex] |= AF_DIGIT;
}
Exit:
/*
* By default, all uncovered glyphs are set to the fallback style.
* XXX: Shouldn't we disable hinting or do something similar?
* By default, all uncovered glyphs are set to the fallback style.
* XXX: Shouldn't we disable hinting or do something similar?
*/
if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED )
{
FT_Long nn;
FT_UInt nn;
for ( nn = 0; nn < globals->glyph_count; nn++ )
@ -290,16 +280,16 @@
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE4(( "\n"
"style coverage\n"
"==============\n"
"\n" ));
FT_TRACE4(( "\n" ));
FT_TRACE4(( "style coverage\n" ));
FT_TRACE4(( "==============\n" ));
FT_TRACE4(( "\n" ));
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
AF_StyleClass style_class = af_style_classes[ss];
FT_UInt count = 0;
FT_Long idx;
FT_UInt idx;
FT_TRACE4(( "%s:\n", af_style_names[style_class->style] ));
@ -327,7 +317,7 @@
#endif /* FT_DEBUG_LEVEL_TRACE */
FT_Set_Charmap( face, old_charmap );
face->charmap = old_charmap;
return error;
}
@ -346,13 +336,15 @@
/* we allocate an AF_FaceGlobals structure together */
/* with the glyph_styles array */
if ( FT_ALLOC( globals,
sizeof ( *globals ) +
(FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
if ( FT_QALLOC( globals,
sizeof ( *globals ) +
(FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
goto Exit;
FT_ZERO( &globals->metrics );
globals->face = face;
globals->glyph_count = face->num_glyphs;
globals->glyph_count = (FT_UInt)face->num_glyphs;
/* right after the globals structure come the glyph styles */
globals->glyph_styles = (FT_UShort*)( globals + 1 );
globals->module = module;
@ -364,7 +356,7 @@
globals->scale_down_factor = 0;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
globals->hb_font = hb_ft_font_create( face, NULL );
globals->hb_font = hb_ft_font_create_( face, NULL );
globals->hb_buf = hb_buffer_create();
#endif
@ -397,9 +389,9 @@
if ( globals->metrics[nn] )
{
AF_StyleClass style_class =
AF_STYLE_CLASSES_GET[nn];
af_style_classes[nn];
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
af_writing_system_classes[style_class->writing_system];
if ( writing_system_class->style_metrics_done )
@ -436,7 +428,7 @@
FT_Error error = FT_Err_Ok;
if ( gindex >= (FT_ULong)globals->glyph_count )
if ( gindex >= globals->glyph_count )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
@ -448,8 +440,9 @@
style = (AF_Style)( globals->glyph_styles[gindex] &
AF_STYLE_UNASSIGNED );
style_class = AF_STYLE_CLASSES_GET[style];
writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET
Again:
style_class = af_style_classes[style];
writing_system_class = af_writing_system_classes
[style_class->writing_system];
metrics = globals->metrics[style];
@ -475,6 +468,20 @@
writing_system_class->style_metrics_done( metrics );
FT_FREE( metrics );
/* internal error code -1 indicates */
/* that no blue zones have been found */
if ( error == -1 )
{
style = (AF_Style)( globals->glyph_styles[gindex] &
AF_STYLE_UNASSIGNED );
/* IMPORTANT: Clear the error code, see
* https://gitlab.freedesktop.org/freetype/freetype/-/issues/1063
*/
error = FT_Err_Ok;
goto Again;
}
goto Exit;
}
}
@ -493,10 +500,10 @@
af_face_globals_is_digit( AF_FaceGlobals globals,
FT_UInt gindex )
{
if ( gindex < (FT_ULong)globals->glyph_count )
return (FT_Bool)( globals->glyph_styles[gindex] & AF_DIGIT );
if ( gindex < globals->glyph_count )
return FT_BOOL( globals->glyph_styles[gindex] & AF_DIGIT );
return (FT_Bool)0;
return FT_BOOL( 0 );
}

View file

@ -1,20 +1,20 @@
/***************************************************************************/
/* */
/* afglobal.h */
/* */
/* Auto-fitter routines to compute global hinting values */
/* (specification). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afglobal.h
*
* Auto-fitter routines to compute global hinting values
* (specification).
*
* Copyright (C) 2003-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 AFGLOBAL_H_
@ -60,8 +60,8 @@ FT_BEGIN_HEADER
/*
* Default values and flags for both autofitter globals (found in
* AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
* Default values and flags for both autofitter globals (found in
* AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
*/
/* index of fallback style in `af_style_classes' */
@ -98,14 +98,14 @@ FT_BEGIN_HEADER
/*
* Note that glyph_styles[] maps each glyph to an index into the
* `af_style_classes' array.
* Note that glyph_styles[] maps each glyph to an index into the
* `af_style_classes' array.
*
*/
typedef struct AF_FaceGlobalsRec_
{
FT_Face face;
FT_Long glyph_count; /* same as face->num_glyphs */
FT_UInt glyph_count; /* unsigned face->num_glyphs */
FT_UShort* glyph_styles;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
@ -140,8 +140,8 @@ FT_BEGIN_HEADER
/*
* model the global hints data for a given face, decomposed into
* style-specific items
* model the global hints data for a given face, decomposed into
* style-specific items
*/
FT_LOCAL( FT_Error )
@ -158,7 +158,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
af_face_globals_free( AF_FaceGlobals globals );
FT_LOCAL_DEF( FT_Bool )
FT_LOCAL( FT_Bool )
af_face_globals_is_digit( AF_FaceGlobals globals,
FT_UInt gindex );

View file

@ -1,37 +1,135 @@
/***************************************************************************/
/* */
/* afhints.c */
/* */
/* Auto-fitter hinting routines (body). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afhints.c
*
* Auto-fitter hinting routines (body).
*
* Copyright (C) 2003-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 "afhints.h"
#include "aferrors.h"
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.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_afhints
#define FT_COMPONENT afhints
FT_LOCAL_DEF( void )
af_sort_pos( FT_UInt count,
FT_Pos* table )
{
FT_UInt i, j;
FT_Pos swap;
for ( i = 1; i < count; i++ )
{
for ( j = i; j > 0; j-- )
{
if ( table[j] >= table[j - 1] )
break;
swap = table[j];
table[j] = table[j - 1];
table[j - 1] = swap;
}
}
}
FT_LOCAL_DEF( void )
af_sort_and_quantize_widths( FT_UInt* count,
AF_Width table,
FT_Pos threshold )
{
FT_UInt i, j;
FT_UInt cur_idx;
FT_Pos cur_val;
FT_Pos sum;
AF_WidthRec swap;
if ( *count == 1 )
return;
/* sort */
for ( i = 1; i < *count; i++ )
{
for ( j = i; j > 0; j-- )
{
if ( table[j].org >= table[j - 1].org )
break;
swap = table[j];
table[j] = table[j - 1];
table[j - 1] = swap;
}
}
cur_idx = 0;
cur_val = table[cur_idx].org;
/* compute and use mean values for clusters not larger than */
/* `threshold'; this is very primitive and might not yield */
/* the best result, but normally, using reference character */
/* `o', `*count' is 2, so the code below is fully sufficient */
for ( i = 1; i < *count; i++ )
{
if ( table[i].org - cur_val > threshold ||
i == *count - 1 )
{
sum = 0;
/* fix loop for end of array */
if ( table[i].org - cur_val <= threshold &&
i == *count - 1 )
i++;
for ( j = cur_idx; j < i; j++ )
{
sum += table[j].org;
table[j].org = 0;
}
table[cur_idx].org = sum / (FT_Pos)j;
if ( i < *count - 1 )
{
cur_idx = i + 1;
cur_val = table[cur_idx].org;
}
}
}
cur_idx = 1;
/* compress array to remove zero values */
for ( i = 1; i < *count; i++ )
{
if ( table[i].org )
table[cur_idx++] = table[i];
}
*count = cur_idx;
}
/* Get new segment for given axis. */
FT_LOCAL_DEF( FT_Error )
@ -53,9 +151,9 @@
}
else if ( axis->num_segments >= axis->max_segments )
{
FT_Int old_max = axis->max_segments;
FT_Int new_max = old_max;
FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
FT_UInt old_max = axis->max_segments;
FT_UInt new_max = old_max;
FT_UInt big_max = FT_INT_MAX / sizeof ( *segment );
if ( old_max >= big_max )
@ -95,7 +193,7 @@
/* Get new edge for given axis, direction, and position, */
/* without initializing the edge itself. */
FT_LOCAL( FT_Error )
FT_LOCAL_DEF( FT_Error )
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
AF_Direction dir,
@ -118,9 +216,9 @@
}
else if ( axis->num_edges >= axis->max_edges )
{
FT_Int old_max = axis->max_edges;
FT_Int new_max = old_max;
FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
FT_UInt old_max = axis->max_edges;
FT_UInt new_max = old_max;
FT_UInt big_max = FT_INT_MAX / sizeof ( *edge );
if ( old_max >= big_max )
@ -297,6 +395,19 @@
}
static int
af_get_strong_edge_index( AF_GlyphHints hints,
AF_Edge* strong_edges,
int dimension )
{
AF_AxisHints axis = &hints->axis[dimension];
AF_Edge edges = axis->edges;
return AF_INDEX_NUM( strong_edges[dimension], edges );
}
#ifdef __cplusplus
extern "C" {
#endif
@ -317,8 +428,10 @@
{
AF_DUMP(( " index hedge hseg vedge vseg flags "
/* " XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXX" */
" xorg yorg xscale yscale xfit yfit" ));
" xorg yorg xscale yscale xfit yfit "
/* " XXXXX XXXXX XXXX.XX XXXX.XX XXXX.XX XXXX.XX" */
" hbef haft vbef vaft" ));
/* " XXXXX XXXXX XXXXX XXXXX" */
}
else
AF_DUMP(( " (none)\n" ));
@ -330,6 +443,7 @@
int segment_idx_1 = af_get_segment_index( hints, point_idx, 1 );
char buf1[16], buf2[16], buf3[16], buf4[16];
char buf5[16], buf6[16], buf7[16], buf8[16];
/* insert extra newline at the beginning of a contour */
@ -340,7 +454,8 @@
}
AF_DUMP(( " %5d %5s %5s %5s %5s %s"
" %5d %5d %7.2f %7.2f %7.2f %7.2f\n",
" %5d %5d %7.2f %7.2f %7.2f %7.2f"
" %5s %5s %5s %5s\n",
point_idx,
af_print_idx( buf1,
af_get_edge_index( hints, segment_idx_1, 1 ) ),
@ -356,10 +471,23 @@
point->fx,
point->fy,
point->ox / 64.0,
point->oy / 64.0,
point->x / 64.0,
point->y / 64.0 ));
(double)point->ox / 64,
(double)point->oy / 64,
(double)point->x / 64,
(double)point->y / 64,
af_print_idx( buf5, af_get_strong_edge_index( hints,
point->before,
1 ) ),
af_print_idx( buf6, af_get_strong_edge_index( hints,
point->after,
1 ) ),
af_print_idx( buf7, af_get_strong_edge_index( hints,
point->before,
0 ) ),
af_print_idx( buf8, af_get_strong_edge_index( hints,
point->after,
0 ) ) ));
}
AF_DUMP(( "\n" ));
}
@ -469,7 +597,7 @@
FT_Error
af_glyph_hints_get_num_segments( AF_GlyphHints hints,
FT_Int dimension,
FT_Int* num_segments )
FT_UInt* num_segments )
{
AF_Dimension dim;
AF_AxisHints axis;
@ -495,7 +623,7 @@
FT_Error
af_glyph_hints_get_segment_offset( AF_GlyphHints hints,
FT_Int dimension,
FT_Int idx,
FT_UInt idx,
FT_Pos *offset,
FT_Bool *is_blue,
FT_Pos *blue_offset )
@ -512,14 +640,14 @@
axis = &hints->axis[dim];
if ( idx < 0 || idx >= axis->num_segments )
if ( idx >= axis->num_segments )
return FT_THROW( Invalid_Argument );
seg = &axis->segments[idx];
*offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->fx
: seg->first->fy;
if ( seg->edge )
*is_blue = (FT_Bool)( seg->edge->blue_edge != 0 );
*is_blue = FT_BOOL( seg->edge->blue_edge );
else
*is_blue = FALSE;
@ -558,19 +686,19 @@
/*
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
* since they have a constant X coordinate.
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
* since they have a constant X coordinate.
*/
if ( dimension == AF_DIMENSION_HORZ )
AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
"vertical",
65536.0 * 64.0 / hints->x_scale,
10.0 * hints->x_scale / 65536.0 / 64.0 ));
65536 * 64 / (double)hints->x_scale,
10 * (double)hints->x_scale / 65536 / 64 ));
else
AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
"horizontal",
65536.0 * 64.0 / hints->y_scale,
10.0 * hints->y_scale / 65536.0 / 64.0 ));
65536 * 64 / (double)hints->y_scale,
10 * (double)hints->y_scale / 65536 / 64 ));
if ( axis->num_edges )
{
@ -586,14 +714,14 @@
AF_DUMP(( " %5d %7.2f %5s %4s %5s"
" %c %7.2f %7.2f %11s\n",
AF_INDEX_NUM( edge, edges ),
(int)edge->opos / 64.0,
(double)(int)edge->opos / 64,
af_dir_str( (AF_Direction)edge->dir ),
af_print_idx( buf1, AF_INDEX_NUM( edge->link, edges ) ),
af_print_idx( buf2, AF_INDEX_NUM( edge->serif, edges ) ),
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0,
(double)edge->opos / 64,
(double)edge->pos / 64,
af_edge_flags_to_string( edge->flags ) ));
AF_DUMP(( "\n" ));
}
@ -681,8 +809,8 @@
memory = hints->memory;
/*
* note that we don't need to free the segment and edge
* buffers since they are really within the hints->points array
* note that we don't need to free the segment and edge
* buffers since they are really within the hints->points array
*/
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
@ -734,7 +862,7 @@
{
FT_Error error = FT_Err_Ok;
AF_Point points;
FT_UInt old_max, new_max;
FT_Int old_max, new_max;
FT_Fixed x_scale = hints->x_scale;
FT_Fixed y_scale = hints->y_scale;
FT_Pos x_delta = hints->x_delta;
@ -751,8 +879,8 @@
hints->axis[1].num_edges = 0;
/* first of all, reallocate the contours array if necessary */
new_max = (FT_UInt)outline->n_contours;
old_max = (FT_UInt)hints->max_contours;
new_max = outline->n_contours;
old_max = hints->max_contours;
if ( new_max <= AF_CONTOURS_EMBEDDED )
{
@ -767,21 +895,21 @@
if ( hints->contours == hints->embedded.contours )
hints->contours = NULL;
new_max = ( new_max + 3 ) & ~3U; /* round up to a multiple of 4 */
new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
goto Exit;
hints->max_contours = (FT_Int)new_max;
hints->max_contours = new_max;
}
/*
* then reallocate the points arrays if necessary --
* note that we reserve two additional point positions, used to
* hint metrics appropriately
* then reallocate the points arrays if necessary --
* note that we reserve two additional point positions, used to
* hint metrics appropriately
*/
new_max = (FT_UInt)( outline->n_points + 2 );
old_max = (FT_UInt)hints->max_points;
new_max = outline->n_points + 2;
old_max = hints->max_points;
if ( new_max <= AF_POINTS_EMBEDDED )
{
@ -796,12 +924,12 @@
if ( hints->points == hints->embedded.points )
hints->points = NULL;
new_max = ( new_max + 2 + 7 ) & ~7U; /* round up to a multiple of 8 */
new_max = ( new_max + 2 + 7 ) & ~7; /* round up to a multiple of 8 */
if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
goto Exit;
hints->max_points = (FT_Int)new_max;
hints->max_points = new_max;
}
hints->num_points = outline->n_points;
@ -825,9 +953,6 @@
hints->x_delta = x_delta;
hints->y_delta = y_delta;
hints->xmin_delta = 0;
hints->xmax_delta = 0;
points = hints->points;
if ( hints->num_points == 0 )
goto Exit;
@ -898,6 +1023,14 @@
prev = end;
}
}
#ifdef FT_DEBUG_AUTOFIT
point->before[0] = NULL;
point->before[1] = NULL;
point->after[0] = NULL;
point->after[1] = NULL;
#endif
}
}
@ -918,15 +1051,15 @@
{
/*
* Compute directions of `in' and `out' vectors.
* Compute directions of `in' and `out' vectors.
*
* Note that distances between points that are very near to each
* other are accumulated. In other words, the auto-hinter either
* prepends the small vectors between near points to the first
* non-near vector, or the sum of small vector lengths exceeds a
* threshold, thus `grouping' the small vectors. All intermediate
* points are tagged as weak; the directions are adjusted also to
* be equal to the accumulated one.
* Note that distances between points that are very near to each
* other are accumulated. In other words, the auto-hinter either
* prepends the small vectors between near points to the first
* non-near vector, or the sum of small vector lengths exceeds a
* threshold, thus `grouping' the small vectors. All intermediate
* points are tagged as weak; the directions are adjusted also to
* be equal to the accumulated one.
*/
FT_Int near_limit2 = 2 * near_limit - 1;
@ -956,12 +1089,12 @@
out_y = point->fy - prev->fy;
/*
* We use Taxicab metrics to measure the vector length.
* We use Taxicab metrics to measure the vector length.
*
* Note that the accumulated distances so far could have the
* opposite direction of the distance measured here. For this
* reason we use `near_limit2' for the comparison to get a
* non-near point even in the worst case.
* Note that the accumulated distances so far could have the
* opposite direction of the distance measured here. For this
* reason we use `near_limit2' for the comparison to get a
* non-near point even in the worst case.
*/
if ( FT_ABS( out_x ) + FT_ABS( out_y ) >= near_limit2 )
break;
@ -979,11 +1112,11 @@
curr = first;
/*
* We abuse the `u' and `v' fields to store index deltas to the
* next and previous non-near point, respectively.
* We abuse the `u' and `v' fields to store index deltas to the
* next and previous non-near point, respectively.
*
* To avoid problems with not having non-near points, we point to
* `first' by default as the next non-near point.
* To avoid problems with not having non-near points, we point to
* `first' by default as the next non-near point.
*
*/
curr->u = (FT_Pos)( first - curr );
@ -1035,12 +1168,12 @@
}
/*
* The next step is to `simplify' an outline's topology so that we
* can identify local extrema more reliably: A series of
* non-horizontal or non-vertical vectors pointing into the same
* quadrant are handled as a single, long vector. From a
* topological point of the view, the intermediate points are of no
* interest and thus tagged as weak.
* The next step is to `simplify' an outline's topology so that we
* can identify local extrema more reliably: A series of
* non-horizontal or non-vertical vectors pointing into the same
* quadrant are handled as a single, long vector. From a
* topological point of the view, the intermediate points are of no
* interest and thus tagged as weak.
*/
for ( point = points; point < point_limit; point++ )
@ -1080,9 +1213,9 @@
}
/*
* Finally, check for remaining weak points. Everything else not
* collected in edges so far is then implicitly classified as strong
* points.
* Finally, check for remaining weak points. Everything else not
* collected in edges so far is then implicitly classified as strong
* points.
*/
for ( point = points; point < point_limit; point++ )
@ -1183,7 +1316,7 @@
{
AF_AxisHints axis = & hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
AF_Segment seg;
@ -1260,7 +1393,7 @@
AF_Point point_limit = points + hints->num_points;
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
FT_UInt touch_flag;
@ -1309,6 +1442,12 @@
if ( delta >= 0 )
{
u = edge->pos - ( edge->opos - ou );
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = edge;
point->after[dim] = NULL;
#endif
goto Store_Point;
}
@ -1318,6 +1457,12 @@
if ( delta >= 0 )
{
u = edge->pos + ( ou - edge->opos );
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = NULL;
point->after[dim] = edge;
#endif
goto Store_Point;
}
@ -1364,6 +1509,12 @@
{
/* we are on the edge */
u = edge->pos;
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = NULL;
point->after[dim] = NULL;
#endif
goto Store_Point;
}
}
@ -1374,6 +1525,11 @@
AF_Edge after = edges + min + 0;
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = before;
point->after[dim] = after;
#endif
/* assert( before && after && before != after ) */
if ( before->scale == 0 )
before->scale = FT_DivFix( after->pos - before->pos,
@ -1627,33 +1783,4 @@
}
#ifdef AF_CONFIG_OPTION_USE_WARPER
/* Apply (small) warp scale and warp delta for given dimension. */
FT_LOCAL_DEF( void )
af_glyph_hints_scale_dim( AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed scale,
FT_Pos delta )
{
AF_Point points = hints->points;
AF_Point points_limit = points + hints->num_points;
AF_Point point;
if ( dim == AF_DIMENSION_HORZ )
{
for ( point = points; point < points_limit; point++ )
point->x = FT_MulFix( point->fx, scale ) + delta;
}
else
{
for ( point = points; point < points_limit; point++ )
point->y = FT_MulFix( point->fy, scale ) + delta;
}
}
#endif /* AF_CONFIG_OPTION_USE_WARPER */
/* END */

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afhints.h */
/* */
/* Auto-fitter hinting routines (specification). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afhints.h
*
* Auto-fitter hinting routines (specification).
*
* Copyright (C) 2003-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 AFHINTS_H_
@ -21,13 +21,11 @@
#include "aftypes.h"
#define xxAF_SORT_SEGMENTS
FT_BEGIN_HEADER
/*
* The definition of outline glyph hints. These are shared by all
* writing system analysis routines (until now).
* The definition of outline glyph hints. These are shared by all
* writing system analysis routines (until now).
*/
typedef enum AF_Dimension_
@ -56,153 +54,153 @@ FT_BEGIN_HEADER
/*
* The following explanations are mostly taken from the article
* The following explanations are mostly taken from the article
*
* Real-Time Grid Fitting of Typographic Outlines
* Real-Time Grid Fitting of Typographic Outlines
*
* by David Turner and Werner Lemberg
* by David Turner and Werner Lemberg
*
* https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
* https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
*
* with appropriate updates.
* with appropriate updates.
*
*
* Segments
* Segments
*
* `af_{cjk,latin,...}_hints_compute_segments' are the functions to
* find segments in an outline.
* `af_{cjk,latin,...}_hints_compute_segments' are the functions to
* find segments in an outline.
*
* A segment is a series of at least two consecutive points that are
* approximately aligned along a coordinate axis. The analysis to do
* so is specific to a writing system.
* A segment is a series of at least two consecutive points that are
* approximately aligned along a coordinate axis. The analysis to do
* so is specific to a writing system.
*
*
* Edges
* Edges
*
* `af_{cjk,latin,...}_hints_compute_edges' are the functions to find
* edges.
* `af_{cjk,latin,...}_hints_compute_edges' are the functions to find
* edges.
*
* As soon as segments are defined, the auto-hinter groups them into
* edges. An edge corresponds to a single position on the main
* dimension that collects one or more segments (allowing for a small
* threshold).
* As soon as segments are defined, the auto-hinter groups them into
* edges. An edge corresponds to a single position on the main
* dimension that collects one or more segments (allowing for a small
* threshold).
*
* As an example, the `latin' writing system first tries to grid-fit
* edges, then to align segments on the edges unless it detects that
* they form a serif.
* As an example, the `latin' writing system first tries to grid-fit
* edges, then to align segments on the edges unless it detects that
* they form a serif.
*
*
* A H
* | |
* | |
* | |
* | |
* C | | F
* +------<-----+ +-----<------+
* | B G |
* | |
* | |
* +--------------->------------------+
* D E
* A H
* | |
* | |
* | |
* | |
* C | | F
* +------<-----+ +-----<------+
* | B G |
* | |
* | |
* +--------------->------------------+
* D E
*
*
* Stems
* Stems
*
* Stems are detected by `af_{cjk,latin,...}_hint_edges'.
* Stems are detected by `af_{cjk,latin,...}_hint_edges'.
*
* Segments need to be `linked' to other ones in order to detect stems.
* A stem is made of two segments that face each other in opposite
* directions and that are sufficiently close to each other. Using
* vocabulary from the TrueType specification, stem segments form a
* `black distance'.
* Segments need to be `linked' to other ones in order to detect stems.
* A stem is made of two segments that face each other in opposite
* directions and that are sufficiently close to each other. Using
* vocabulary from the TrueType specification, stem segments form a
* `black distance'.
*
* In the above ASCII drawing, the horizontal segments are BC, DE, and
* FG; the vertical segments are AB, CD, EF, and GH.
* In the above ASCII drawing, the horizontal segments are BC, DE, and
* FG; the vertical segments are AB, CD, EF, and GH.
*
* Each segment has at most one `best' candidate to form a black
* distance, or no candidate at all. Notice that two distinct segments
* can have the same candidate, which frequently means a serif.
* Each segment has at most one `best' candidate to form a black
* distance, or no candidate at all. Notice that two distinct segments
* can have the same candidate, which frequently means a serif.
*
* A stem is recognized by the following condition:
* A stem is recognized by the following condition:
*
* best segment_1 = segment_2 && best segment_2 = segment_1
* best segment_1 = segment_2 && best segment_2 = segment_1
*
* The best candidate is stored in field `link' in structure
* `AF_Segment'.
* The best candidate is stored in field `link' in structure
* `AF_Segment'.
*
* In the above ASCII drawing, the best candidate for both AB and CD is
* GH, while the best candidate for GH is AB. Similarly, the best
* candidate for EF and GH is AB, while the best candidate for AB is
* GH.
* In the above ASCII drawing, the best candidate for both AB and CD is
* GH, while the best candidate for GH is AB. Similarly, the best
* candidate for EF and GH is AB, while the best candidate for AB is
* GH.
*
* The detection and handling of stems is dependent on the writing
* system.
* The detection and handling of stems is dependent on the writing
* system.
*
*
* Serifs
* Serifs
*
* Serifs are detected by `af_{cjk,latin,...}_hint_edges'.
* Serifs are detected by `af_{cjk,latin,...}_hint_edges'.
*
* In comparison to a stem, a serif (as handled by the auto-hinter
* module that takes care of the `latin' writing system) has
* In comparison to a stem, a serif (as handled by the auto-hinter
* module that takes care of the `latin' writing system) has
*
* best segment_1 = segment_2 && best segment_2 != segment_1
* best segment_1 = segment_2 && best segment_2 != segment_1
*
* where segment_1 corresponds to the serif segment (CD and EF in the
* above ASCII drawing).
* where segment_1 corresponds to the serif segment (CD and EF in the
* above ASCII drawing).
*
* The best candidate is stored in field `serif' in structure
* `AF_Segment' (and `link' is set to NULL).
* The best candidate is stored in field `serif' in structure
* `AF_Segment' (and `link' is set to NULL).
*
*
* Touched points
* Touched points
*
* A point is called `touched' if it has been processed somehow by the
* auto-hinter. It basically means that it shouldn't be moved again
* (or moved only under certain constraints to preserve the already
* applied processing).
* A point is called `touched' if it has been processed somehow by the
* auto-hinter. It basically means that it shouldn't be moved again
* (or moved only under certain constraints to preserve the already
* applied processing).
*
*
* Flat and round segments
* Flat and round segments
*
* Segments are `round' or `flat', depending on the series of points
* that define them. A segment is round if the next and previous point
* of an extremum (which can be either a single point or sequence of
* points) are both conic or cubic control points. Otherwise, a
* segment with an extremum is flat.
* Segments are `round' or `flat', depending on the series of points
* that define them. A segment is round if the next and previous point
* of an extremum (which can be either a single point or sequence of
* points) are both conic or cubic control points. Otherwise, a
* segment with an extremum is flat.
*
*
* Strong Points
* Strong Points
*
* Experience has shown that points not part of an edge need to be
* interpolated linearly between their two closest edges, even if these
* are not part of the contour of those particular points. Typical
* candidates for this are
* Experience has shown that points not part of an edge need to be
* interpolated linearly between their two closest edges, even if these
* are not part of the contour of those particular points. Typical
* candidates for this are
*
* - angle points (i.e., points where the `in' and `out' direction
* differ greatly)
* - angle points (i.e., points where the `in' and `out' direction
* differ greatly)
*
* - inflection points (i.e., where the `in' and `out' angles are the
* same, but the curvature changes sign) [currently, such points
* aren't handled specially in the auto-hinter]
* - inflection points (i.e., where the `in' and `out' angles are the
* same, but the curvature changes sign) [currently, such points
* aren't handled specially in the auto-hinter]
*
* `af_glyph_hints_align_strong_points' is the function that takes
* care of such situations; it is equivalent to the TrueType `IP'
* hinting instruction.
* `af_glyph_hints_align_strong_points' is the function that takes
* care of such situations; it is equivalent to the TrueType `IP'
* hinting instruction.
*
*
* Weak Points
* Weak Points
*
* Other points in the outline must be interpolated using the
* coordinates of their previous and next unfitted contour neighbours.
* These are called `weak points' and are touched by the function
* `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP'
* hinting instruction. Typical candidates are control points and
* points on the contour without a major direction.
* Other points in the outline must be interpolated using the
* coordinates of their previous and next unfitted contour neighbours.
* These are called `weak points' and are touched by the function
* `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP'
* hinting instruction. Typical candidates are control points and
* points on the contour without a major direction.
*
* The major effect is to reduce possible distortion caused by
* alignment of edges and strong points, thus weak points are processed
* after strong points.
* The major effect is to reduce possible distortion caused by
* alignment of edges and strong points, thus weak points are processed
* after strong points.
*/
@ -252,6 +250,12 @@ FT_BEGIN_HEADER
AF_Point next; /* next point in contour */
AF_Point prev; /* previous point in contour */
#ifdef FT_DEBUG_AUTOFIT
/* track `before' and `after' edges for strong points */
AF_Edge before[2];
AF_Edge after[2];
#endif
} AF_PointRec;
@ -304,15 +308,12 @@ FT_BEGIN_HEADER
typedef struct AF_AxisHintsRec_
{
FT_Int num_segments; /* number of used segments */
FT_Int max_segments; /* number of allocated segments */
FT_UInt num_segments; /* number of used segments */
FT_UInt max_segments; /* number of allocated segments */
AF_Segment segments; /* segments array */
#ifdef AF_SORT_SEGMENTS
FT_Int mid_segments;
#endif
FT_Int num_edges; /* number of used edges */
FT_Int max_edges; /* number of allocated edges */
FT_UInt num_edges; /* number of used edges */
FT_UInt max_edges; /* number of allocated edges */
AF_Edge edges; /* edges array */
AF_Direction major_dir; /* either vertical or horizontal */
@ -356,9 +357,6 @@ FT_BEGIN_HEADER
/* implementations */
AF_StyleMetrics metrics;
FT_Pos xmin_delta; /* used for warping */
FT_Pos xmax_delta;
/* Two arrays to avoid allocation penalty. */
/* The `embedded' structure must be the last element! */
struct
@ -377,14 +375,14 @@ FT_BEGIN_HEADER
#ifdef FT_DEBUG_AUTOFIT
#define AF_HINTS_DO_HORIZONTAL( h ) \
( !_af_debug_disable_horz_hints && \
( !af_debug_disable_horz_hints_ && \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL ) )
#define AF_HINTS_DO_VERTICAL( h ) \
( !_af_debug_disable_vert_hints && \
( !af_debug_disable_vert_hints_ && \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) )
#define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
#define AF_HINTS_DO_BLUES( h ) ( !af_debug_disable_blue_hints_ )
#else /* !FT_DEBUG_AUTOFIT */
@ -402,10 +400,6 @@ FT_BEGIN_HEADER
#define AF_HINTS_DO_ADVANCE( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
#define AF_HINTS_DO_WARP( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_WARPER )
FT_LOCAL( AF_Direction )
af_direction_compute( FT_Pos dx,
@ -453,14 +447,6 @@ FT_BEGIN_HEADER
af_glyph_hints_align_weak_points( AF_GlyphHints hints,
AF_Dimension dim );
#ifdef AF_CONFIG_OPTION_USE_WARPER
FT_LOCAL( void )
af_glyph_hints_scale_dim( AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed scale,
FT_Pos delta );
#endif
FT_LOCAL( void )
af_glyph_hints_done( AF_GlyphHints hints );

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afindic.c */
/* */
/* Auto-fitter hinting routines for Indic writing system (body). */
/* */
/* Copyright 2007-2018 by */
/* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afindic.c
*
* Auto-fitter hinting routines for Indic writing system (body).
*
* Copyright (C) 2007-2023 by
* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
*
* 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 "aftypes.h"
@ -27,11 +27,6 @@
#include "aferrors.h"
#ifdef AF_CONFIG_OPTION_USE_WARPER
#include "afwarp.h"
#endif
static FT_Error
af_indic_metrics_init( AF_CJKMetrics metrics,
FT_Face face )
@ -54,8 +49,7 @@
af_cjk_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
face->charmap = oldmap;
return FT_Err_Ok;
}

View file

@ -1,20 +1,20 @@
/***************************************************************************/
/* */
/* afindic.h */
/* */
/* Auto-fitter hinting routines for Indic writing system */
/* (specification). */
/* */
/* Copyright 2007-2018 by */
/* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afindic.h
*
* Auto-fitter hinting routines for Indic writing system
* (specification).
*
* Copyright (C) 2007-2023 by
* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
*
* 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 AFINDIC_H_

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,20 @@
/***************************************************************************/
/* */
/* aflatin.h */
/* */
/* Auto-fitter hinting routines for latin writing system */
/* (specification). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* aflatin.h
*
* Auto-fitter hinting routines for latin writing system
* (specification).
*
* Copyright (C) 2003-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 AFLATIN_H_
@ -45,9 +45,9 @@ FT_BEGIN_HEADER
/*
* The following declarations could be embedded in the file `aflatin.c';
* they have been made semi-public to allow alternate writing system
* hinters to re-use some of them.
* The following declarations could be embedded in the file `aflatin.c';
* they have been made semi-public to allow alternate writing system
* hinters to re-use some of them.
*/
@ -161,8 +161,8 @@ FT_BEGIN_HEADER
/*
* The next functions shouldn't normally be exported. However, other
* writing systems might like to use these functions as-is.
* The next functions shouldn't normally be exported. However, other
* writing systems might like to use these functions as-is.
*/
FT_LOCAL( FT_Error )
af_latin_hints_compute_segments( AF_GlyphHints hints,

File diff suppressed because it is too large Load diff

View file

@ -1,46 +0,0 @@
/* ATTENTION: This file doesn't compile. It is only here as a reference */
/* of an alternative latin hinting algorithm that was always */
/* marked as experimental. */
/***************************************************************************/
/* */
/* aflatin2.h */
/* */
/* Auto-fitter hinting routines for latin writing system */
/* (specification). */
/* */
/* Copyright 2003-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 AFLATIN2_H_
#define AFLATIN2_H_
#include "afhints.h"
FT_BEGIN_HEADER
/* the `latin' writing system */
AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin2_writing_system_class )
/* */
FT_END_HEADER
#endif /* AFLATIN_H_ */
/* END */

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afloader.c */
/* */
/* Auto-fitter glyph loading routines (body). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afloader.c
*
* Auto-fitter glyph loading routines (body).
*
* Copyright (C) 2003-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 "afglobal.h"
@ -21,9 +21,8 @@
#include "afhints.h"
#include "aferrors.h"
#include "afmodule.h"
#include "afpic.h"
#include FT_INTERNAL_CALC_H
#include <freetype/internal/ftcalc.h>
/* Initialize glyph loader. */
@ -106,7 +105,6 @@
globals->stem_darkening_for_ppem;
FT_Fixed em_size = af_intToFixed( face->units_per_EM );
FT_Fixed em_ratio = FT_DivFix( af_intToFixed( 1000 ), em_size );
FT_Matrix scale_down_matrix = { 0x10000L, 0, 0, 0x10000L };
@ -119,12 +117,12 @@
}
/*
* We depend on the writing system (script analyzers) to supply
* standard widths for the script of the glyph we are looking at. If
* it can't deliver, stem darkening is disabled.
* We depend on the writing system (script analyzers) to supply
* standard widths for the script of the glyph we are looking at. If
* it can't deliver, stem darkening is disabled.
*/
writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_metrics->style_class->writing_system];
af_writing_system_classes[style_metrics->style_class->writing_system];
if ( writing_system_class->style_metrics_getstdw )
writing_system_class->style_metrics_getstdw( style_metrics,
@ -143,12 +141,11 @@
darken_by_font_units_x =
af_intToFixed( af_loader_compute_darkening( loader,
face,
stdVW ) );
darken_x = FT_DivFix( FT_MulFix( darken_by_font_units_x,
size_metrics->x_scale ),
em_ratio );
af_loader_compute_darkening( loader,
face,
stdVW ) ;
darken_x = FT_MulFix( darken_by_font_units_x,
size_metrics->x_scale );
globals->standard_vertical_width = stdVW;
globals->stem_darkening_for_ppem = size_metrics->x_ppem;
@ -162,34 +159,33 @@
darken_by_font_units_y =
af_intToFixed( af_loader_compute_darkening( loader,
face,
stdHW ) );
darken_y = FT_DivFix( FT_MulFix( darken_by_font_units_y,
size_metrics->y_scale ),
em_ratio );
af_loader_compute_darkening( loader,
face,
stdHW ) ;
darken_y = FT_MulFix( darken_by_font_units_y,
size_metrics->y_scale );
globals->standard_horizontal_width = stdHW;
globals->stem_darkening_for_ppem = size_metrics->x_ppem;
globals->darken_y = af_fixedToInt( darken_y );
/*
* Scale outlines down on the Y-axis to keep them inside their blue
* zones. The stronger the emboldening, the stronger the downscaling
* (plus heuristical padding to prevent outlines still falling out
* their zones due to rounding).
* Scale outlines down on the Y-axis to keep them inside their blue
* zones. The stronger the emboldening, the stronger the downscaling
* (plus heuristical padding to prevent outlines still falling out
* their zones due to rounding).
*
* Reason: `FT_Outline_Embolden' works by shifting the rightmost
* points of stems farther to the right, and topmost points farther
* up. This positions points on the Y-axis outside their
* pre-computed blue zones and leads to distortion when applying the
* hints in the code further below. Code outside this emboldening
* block doesn't know we are presenting it with modified outlines the
* analyzer didn't see!
* Reason: `FT_Outline_Embolden' works by shifting the rightmost
* points of stems farther to the right, and topmost points farther
* up. This positions points on the Y-axis outside their
* pre-computed blue zones and leads to distortion when applying the
* hints in the code further below. Code outside this emboldening
* block doesn't know we are presenting it with modified outlines the
* analyzer didn't see!
*
* An unfortunate side effect of downscaling is that the emboldening
* effect is slightly decreased. The loss becomes more pronounced
* versus the CFF driver at smaller sizes, e.g., at 9ppem and below.
* An unfortunate side effect of downscaling is that the emboldening
* effect is slightly decreased. The loss becomes more pronounced
* versus the CFF driver at smaller sizes, e.g., at 9ppem and below.
*/
globals->scale_down_factor =
FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ),
@ -232,13 +228,6 @@
AF_StyleClass style_class;
AF_WritingSystemClass writing_system_class;
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = loader->globals;
#endif
if ( !size )
return FT_THROW( Invalid_Size_Handle );
FT_ZERO( &scaler );
@ -282,13 +271,13 @@
}
/*
* TODO: This code currently doesn't support fractional advance widths,
* i.e., placing hinted glyphs at anything other than integer
* x-positions. This is only relevant for the warper code, which
* scales and shifts glyphs to optimize blackness of stems (hinting on
* the x-axis by nature places things on pixel integers, hinting on the
* y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta
* values of the scaler would need to be adjusted.
* TODO: This code currently doesn't support fractional advance widths,
* i.e., placing hinted glyphs at anything other than integer
* x-positions. This is only relevant for the warper code, which
* scales and shifts glyphs to optimize blackness of stems (hinting on
* the x-axis by nature places things on pixel integers, hinting on the
* y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta
* values of the scaler would need to be adjusted.
*/
scaler.face = face;
scaler.x_scale = size_internal->autohint_metrics.x_scale;
@ -305,17 +294,11 @@
if ( error )
goto Exit;
#ifdef FT_OPTION_AUTOFIT2
/* XXX: undocumented hook to activate the latin2 writing system. */
if ( load_flags & ( 1UL << 20 ) )
style_options = AF_STYLE_LTN2_DFLT;
#endif
/*
* Glyphs (really code points) are assigned to scripts. Script
* analysis is done lazily: For each glyph that passes through here,
* the corresponding script analyzer is called, but returns immediately
* if it has been run already.
* Glyphs (really code points) are assigned to scripts. Script
* analysis is done lazily: For each glyph that passes through here,
* the corresponding script analyzer is called, but returns immediately
* if it has been run already.
*/
error = af_face_globals_get_metrics( loader->globals, glyph_index,
style_options, &style_metrics );
@ -324,7 +307,7 @@
style_class = style_metrics->style_class;
writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
af_writing_system_classes[style_class->writing_system];
loader->metrics = style_metrics;
@ -342,11 +325,11 @@
}
/*
* Do the main work of `af_loader_load_glyph'. Note that we never have
* to deal with composite glyphs as those get loaded into
* FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function.
* In the rare cases where FT_LOAD_NO_RECURSE is set, it implies
* FT_LOAD_NO_SCALE and as such the auto-hinter is never called.
* Do the main work of `af_loader_load_glyph'. Note that we never have
* to deal with composite glyphs as those get loaded into
* FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function.
* In the rare cases where FT_LOAD_NO_RECURSE is set, it implies
* FT_LOAD_NO_SCALE and as such the auto-hinter is never called.
*/
load_flags |= FT_LOAD_NO_SCALE |
FT_LOAD_IGNORE_TRANSFORM |
@ -358,26 +341,26 @@
goto Exit;
/*
* Apply stem darkening (emboldening) here before hints are applied to
* the outline. Glyphs are scaled down proportionally to the
* emboldening so that curve points don't fall outside their
* precomputed blue zones.
* Apply stem darkening (emboldening) here before hints are applied to
* the outline. Glyphs are scaled down proportionally to the
* emboldening so that curve points don't fall outside their
* precomputed blue zones.
*
* Any emboldening done by the font driver (e.g., the CFF driver)
* doesn't reach here because the autohinter loads the unprocessed
* glyphs in font units for analysis (functions `af_*_metrics_init_*')
* and then above to prepare it for the rasterizers by itself,
* independently of the font driver. So emboldening must be done here,
* within the autohinter.
* Any emboldening done by the font driver (e.g., the CFF driver)
* doesn't reach here because the autohinter loads the unprocessed
* glyphs in font units for analysis (functions `af_*_metrics_init_*')
* and then above to prepare it for the rasterizers by itself,
* independently of the font driver. So emboldening must be done here,
* within the autohinter.
*
* All glyphs to be autohinted pass through here one by one. The
* standard widths can therefore change from one glyph to the next,
* depending on what script a glyph is assigned to (each script has its
* own set of standard widths and other metrics). The darkening amount
* must therefore be recomputed for each size and
* `standard_{vertical,horizontal}_width' change.
* All glyphs to be autohinted pass through here one by one. The
* standard widths can therefore change from one glyph to the next,
* depending on what script a glyph is assigned to (each script has its
* own set of standard widths and other metrics). The darkening amount
* must therefore be recomputed for each size and
* `standard_{vertical,horizontal}_width' change.
*
* Ignore errors and carry on without emboldening.
* Ignore errors and carry on without emboldening.
*
*/
@ -426,35 +409,39 @@
/* now load the slot image into the auto-outline */
/* and run the automatic hinting process */
if ( writing_system_class->style_hints_apply )
writing_system_class->style_hints_apply( glyph_index,
hints,
&gloader->base.outline,
style_metrics );
{
error = writing_system_class->style_hints_apply(
glyph_index,
hints,
&gloader->base.outline,
style_metrics );
if ( error )
goto Exit;
}
/* we now need to adjust the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
if ( scaler.render_mode != FT_RENDER_MODE_LIGHT )
{
FT_Pos old_rsb, old_lsb, new_lsb;
FT_Pos pp1x_uh, pp2x_uh;
AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ];
AF_Edge edge1 = axis->edges; /* leftmost edge */
AF_Edge edge2 = edge1 +
axis->num_edges - 1; /* rightmost edge */
if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
{
old_rsb = loader->pp2.x - edge2->opos;
AF_Edge edge1 = axis->edges; /* leftmost edge */
AF_Edge edge2 = edge1 +
axis->num_edges - 1; /* rightmost edge */
FT_Pos old_rsb = loader->pp2.x - edge2->opos;
/* loader->pp1.x is always zero at this point of time */
old_lsb = edge1->opos /* - loader->pp1.x */;
new_lsb = edge1->pos;
FT_Pos old_lsb = edge1->opos; /* - loader->pp1.x */
FT_Pos new_lsb = edge1->pos;
/* remember unhinted values to later account */
/* for rounding errors */
pp1x_uh = new_lsb - old_lsb;
pp2x_uh = edge2->pos + old_rsb;
FT_Pos pp1x_uh = new_lsb - old_lsb;
FT_Pos pp2x_uh = edge2->pos + old_rsb;
/* prefer too much space over too little space */
/* for very small sizes */
@ -483,8 +470,8 @@
FT_Pos pp2x = loader->pp2.x;
loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta );
loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta );
loader->pp1.x = FT_PIX_ROUND( pp1x );
loader->pp2.x = FT_PIX_ROUND( pp2x );
slot->lsb_delta = loader->pp1.x - pp1x;
slot->rsb_delta = loader->pp2.x - pp2x;
@ -595,7 +582,7 @@
*
* XXX: Currently a crude adaption of the original algorithm. Do better?
*/
FT_LOCAL_DEF( FT_Int32 )
FT_LOCAL_DEF( FT_Fixed )
af_loader_compute_darkening( AF_Loader loader,
FT_Face face,
FT_Pos standard_width )
@ -714,7 +701,7 @@
}
/* Convert darken_amount from per 1000 em to true character space. */
return af_fixedToInt( FT_DivFix( darken_amount, em_ratio ) );
return FT_DivFix( darken_amount, em_ratio );
}

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afloader.h */
/* */
/* Auto-fitter glyph loading routines (specification). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afloader.h
*
* Auto-fitter glyph loading routines (specification).
*
* Copyright (C) 2003-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 AFLOADER_H_
@ -27,11 +27,11 @@
FT_BEGIN_HEADER
/*
* The autofitter module's (global) data structure to communicate with
* actual fonts. If necessary, `local' data like the current face, the
* current face's auto-hint data, or the current glyph's parameters
* relevant to auto-hinting are `swapped in'. Cf. functions like
* `af_loader_reset' and `af_loader_load_g'.
* The autofitter module's (global) data structure to communicate with
* actual fonts. If necessary, `local' data like the current face, the
* current face's auto-hint data, or the current glyph's parameters
* relevant to auto-hinting are `swapped in'. Cf. functions like
* `af_loader_reset' and `af_loader_load_g'.
*/
typedef struct AF_LoaderRec_
@ -75,7 +75,7 @@ FT_BEGIN_HEADER
FT_UInt gindex,
FT_Int32 load_flags );
FT_LOCAL_DEF( FT_Int32 )
FT_LOCAL( FT_Fixed )
af_loader_compute_darkening( AF_Loader loader,
FT_Face face,
FT_Pos standard_width );

View file

@ -1,26 +1,25 @@
/***************************************************************************/
/* */
/* afmodule.c */
/* */
/* Auto-fitter module implementation (body). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afmodule.c
*
* Auto-fitter module implementation (body).
*
* Copyright (C) 2003-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 "afglobal.h"
#include "afmodule.h"
#include "afloader.h"
#include "aferrors.h"
#include "afpic.h"
#ifdef FT_DEBUG_AUTOFIT
@ -44,30 +43,30 @@
#endif
int _af_debug_disable_horz_hints;
int _af_debug_disable_vert_hints;
int _af_debug_disable_blue_hints;
int af_debug_disable_horz_hints_;
int af_debug_disable_vert_hints_;
int af_debug_disable_blue_hints_;
/* we use a global object instead of a local one for debugging */
AF_GlyphHintsRec _af_debug_hints_rec[1];
static AF_GlyphHintsRec af_debug_hints_rec_[1];
void* _af_debug_hints = _af_debug_hints_rec;
void* af_debug_hints_ = af_debug_hints_rec_;
#endif
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_DRIVER_H
#include FT_SERVICE_PROPERTIES_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/ftdriver.h>
#include <freetype/internal/services/svprop.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_afmodule
#define FT_COMPONENT afmodule
static FT_Error
@ -104,19 +103,6 @@
}
#ifdef FT_CONFIG_OPTION_PIC
#undef AF_SCRIPT_CLASSES_GET
#define AF_SCRIPT_CLASSES_GET \
( GET_PIC( ft_module->library )->af_script_classes )
#undef AF_STYLE_CLASSES_GET
#define AF_STYLE_CLASSES_GET \
( GET_PIC( ft_module->library )->af_style_classes )
#endif
static FT_Error
af_property_set( FT_Module ft_module,
const char* property_name,
@ -133,8 +119,8 @@
if ( !ft_strcmp( property_name, "fallback-script" ) )
{
FT_UInt* fallback_script;
FT_UInt ss;
AF_Script* fallback_script;
FT_UInt ss;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
@ -142,28 +128,28 @@
return FT_THROW( Invalid_Argument );
#endif
fallback_script = (FT_UInt*)value;
fallback_script = (AF_Script*)value;
/* We translate the fallback script to a fallback style that uses */
/* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */
/* coverage value. */
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
AF_StyleClass style_class = af_style_classes[ss];
if ( (FT_UInt)style_class->script == *fallback_script &&
style_class->coverage == AF_COVERAGE_DEFAULT )
if ( style_class->script == *fallback_script &&
style_class->coverage == AF_COVERAGE_DEFAULT )
{
module->fallback_style = ss;
break;
}
}
if ( !AF_STYLE_CLASSES_GET[ss] )
if ( !af_style_classes[ss] )
{
FT_TRACE0(( "af_property_set: Invalid value %d for property `%s'\n",
fallback_script, property_name ));
FT_TRACE2(( "af_property_set: Invalid value %d for property `%s'\n",
*fallback_script, property_name ));
return FT_THROW( Invalid_Argument );
}
@ -171,7 +157,7 @@
}
else if ( !ft_strcmp( property_name, "default-script" ) )
{
FT_UInt* default_script;
AF_Script* default_script;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
@ -179,7 +165,7 @@
return FT_THROW( Invalid_Argument );
#endif
default_script = (FT_UInt*)value;
default_script = (AF_Script*)value;
module->default_script = *default_script;
@ -204,35 +190,6 @@
return error;
}
#ifdef AF_CONFIG_OPTION_USE_WARPER
else if ( !ft_strcmp( property_name, "warping" ) )
{
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
long w = ft_strtol( s, NULL, 10 );
if ( w == 0 )
module->warping = 0;
else if ( w == 1 )
module->warping = 1;
else
return FT_THROW( Invalid_Argument );
}
else
#endif
{
FT_Bool* warping = (FT_Bool*)value;
module->warping = *warping;
}
return error;
}
#endif /* AF_CONFIG_OPTION_USE_WARPER */
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params;
@ -321,7 +278,7 @@
return error;
}
FT_TRACE0(( "af_property_set: missing property `%s'\n",
FT_TRACE2(( "af_property_set: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
@ -334,11 +291,6 @@
{
FT_Error error = FT_Err_Ok;
AF_Module module = (AF_Module)ft_module;
FT_UInt fallback_style = module->fallback_style;
FT_UInt default_script = module->default_script;
#ifdef AF_CONFIG_OPTION_USE_WARPER
FT_Bool warping = module->warping;
#endif
if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
@ -355,9 +307,9 @@
}
else if ( !ft_strcmp( property_name, "fallback-script" ) )
{
FT_UInt* val = (FT_UInt*)value;
AF_Script* val = (AF_Script*)value;
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[fallback_style];
AF_StyleClass style_class = af_style_classes[module->fallback_style];
*val = style_class->script;
@ -366,10 +318,10 @@
}
else if ( !ft_strcmp( property_name, "default-script" ) )
{
FT_UInt* val = (FT_UInt*)value;
AF_Script* val = (AF_Script*)value;
*val = default_script;
*val = module->default_script;
return error;
}
@ -385,17 +337,6 @@
return error;
}
#ifdef AF_CONFIG_OPTION_USE_WARPER
else if ( !ft_strcmp( property_name, "warping" ) )
{
FT_Bool* val = (FT_Bool*)value;
*val = warping;
return error;
}
#endif /* AF_CONFIG_OPTION_USE_WARPER */
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params = module->darken_params;
@ -424,7 +365,7 @@
return error;
}
FT_TRACE0(( "af_property_get: missing property `%s'\n",
FT_TRACE2(( "af_property_get: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
@ -440,28 +381,16 @@
FT_DEFINE_SERVICEDESCREC1(
af_services,
FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET )
FT_SERVICE_ID_PROPERTIES, &af_service_properties )
FT_CALLBACK_DEF( FT_Module_Interface )
af_get_interface( FT_Module module,
const char* module_interface )
{
/* AF_SERVICES_GET dereferences `library' in PIC mode */
#ifdef FT_CONFIG_OPTION_PIC
FT_Library library;
if ( !module )
return NULL;
library = module->library;
if ( !library )
return NULL;
#else
FT_UNUSED( module );
#endif
return ft_service_list_lookup( AF_SERVICES_GET, module_interface );
return ft_service_list_lookup( af_services, module_interface );
}
@ -473,9 +402,6 @@
module->fallback_style = AF_STYLE_FALLBACK;
module->default_script = AF_SCRIPT_DEFAULT;
#ifdef AF_CONFIG_OPTION_USE_WARPER
module->warping = 0;
#endif
module->no_stem_darkening = TRUE;
module->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
@ -497,8 +423,8 @@
FT_UNUSED( ft_module );
#ifdef FT_DEBUG_AUTOFIT
if ( _af_debug_hints_rec->memory )
af_glyph_hints_done( _af_debug_hints_rec );
if ( af_debug_hints_rec_->memory )
af_glyph_hints_done( af_debug_hints_rec_ );
#endif
}
@ -517,7 +443,7 @@
/* in debug mode, we use a global object that survives this routine */
AF_GlyphHints hints = _af_debug_hints_rec;
AF_GlyphHints hints = af_debug_hints_rec_;
AF_LoaderRec loader[1];
FT_UNUSED( size );
@ -533,7 +459,7 @@
glyph_index, load_flags );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( ft_trace_levels[FT_COMPONENT] )
if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] )
{
#endif
af_glyph_hints_dump_points( hints, 0 );
@ -576,8 +502,8 @@
NULL, /* reset_face */
NULL, /* get_global_hints */
NULL, /* done_global_hints */
(FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph ) /* load_glyph */
(FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph /* load_glyph */
)
FT_DEFINE_MODULE(
autofit_module_class,
@ -589,7 +515,7 @@
0x10000L, /* version 1.0 of the autofitter */
0x20000L, /* requires FreeType 2.0 or above */
(const void*)&AF_INTERFACE_GET,
(const void*)&af_autofitter_interface,
(FT_Module_Constructor)af_autofitter_init, /* module_init */
(FT_Module_Destructor) af_autofitter_done, /* module_done */

View file

@ -1,35 +1,34 @@
/***************************************************************************/
/* */
/* afmodule.h */
/* */
/* Auto-fitter module implementation (specification). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afmodule.h
*
* Auto-fitter module implementation (specification).
*
* Copyright (C) 2003-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 AFMODULE_H_
#define AFMODULE_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_MODULE_H
#include <freetype/internal/ftobjs.h>
#include <freetype/ftmodapi.h>
FT_BEGIN_HEADER
/*
* This is the `extended' FT_Module structure that holds the
* autofitter's global data.
* This is the `extended' FT_Module structure that holds the
* autofitter's global data.
*/
typedef struct AF_ModuleRec_
@ -37,16 +36,14 @@ FT_BEGIN_HEADER
FT_ModuleRec root;
FT_UInt fallback_style;
FT_UInt default_script;
#ifdef AF_CONFIG_OPTION_USE_WARPER
FT_Bool warping;
#endif
AF_Script default_script;
FT_Bool no_stem_darkening;
FT_Int darken_params[8];
} AF_ModuleRec, *AF_Module;
FT_DECLARE_AUTOHINTER_INTERFACE( af_autofitter_interface )
FT_DECLARE_MODULE( autofit_module_class )

View file

@ -1,152 +0,0 @@
/***************************************************************************/
/* */
/* afpic.c */
/* */
/* The FreeType position independent code services for autofit 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 "afpic.h"
#include "afglobal.h"
#include "aferrors.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from afmodule.c */
FT_Error
FT_Create_Class_af_services( FT_Library library,
FT_ServiceDescRec** output_class );
void
FT_Destroy_Class_af_services( FT_Library library,
FT_ServiceDescRec* clazz );
void
FT_Init_Class_af_service_properties( FT_Service_PropertiesRec* clazz );
void FT_Init_Class_af_autofitter_interface(
FT_Library library,
FT_AutoHinter_InterfaceRec* clazz );
/* forward declaration of PIC init functions from writing system classes */
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) /* empty */
#include "afwrtsys.h"
void
autofit_module_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->autofit )
{
AFModulePIC* container = (AFModulePIC*)pic_container->autofit;
if ( container->af_services )
FT_Destroy_Class_af_services( library,
container->af_services );
container->af_services = NULL;
FT_FREE( container );
pic_container->autofit = NULL;
}
}
FT_Error
autofit_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_UInt ss;
FT_Error error = FT_Err_Ok;
AFModulePIC* 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->autofit = container;
/* initialize pointer table - */
/* this is how the module usually expects this data */
error = FT_Create_Class_af_services( library,
&container->af_services );
if ( error )
goto Exit;
FT_Init_Class_af_service_properties( &container->af_service_properties );
for ( ss = 0; ss < AF_WRITING_SYSTEM_MAX; ss++ )
container->af_writing_system_classes[ss] =
&container->af_writing_system_classes_rec[ss];
container->af_writing_system_classes[AF_WRITING_SYSTEM_MAX] = NULL;
for ( ss = 0; ss < AF_SCRIPT_MAX; ss++ )
container->af_script_classes[ss] =
&container->af_script_classes_rec[ss];
container->af_script_classes[AF_SCRIPT_MAX] = NULL;
for ( ss = 0; ss < AF_STYLE_MAX; ss++ )
container->af_style_classes[ss] =
&container->af_style_classes_rec[ss];
container->af_style_classes[AF_STYLE_MAX] = NULL;
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
FT_Init_Class_af_ ## ws ## _writing_system_class( \
&container->af_writing_system_classes_rec[ss++] );
ss = 0;
#include "afwrtsys.h"
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, sss ) \
FT_Init_Class_af_ ## s ## _script_class( \
&container->af_script_classes_rec[ss++] );
ss = 0;
#include "afscript.h"
#undef STYLE
#define STYLE( s, S, d, ws, sc, bss, c ) \
FT_Init_Class_af_ ## s ## _style_class( \
&container->af_style_classes_rec[ss++] );
ss = 0;
#include "afstyles.h"
FT_Init_Class_af_autofitter_interface(
library, &container->af_autofitter_interface );
Exit:
if ( error )
autofit_module_class_pic_free( library );
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */

View file

@ -1,105 +0,0 @@
/***************************************************************************/
/* */
/* afpic.h */
/* */
/* The FreeType position independent code services for autofit 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 AFPIC_H_
#define AFPIC_H_
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define AF_SERVICES_GET af_services
#define AF_SERVICE_PROPERTIES_GET af_service_properties
#define AF_WRITING_SYSTEM_CLASSES_GET af_writing_system_classes
#define AF_SCRIPT_CLASSES_GET af_script_classes
#define AF_STYLE_CLASSES_GET af_style_classes
#define AF_INTERFACE_GET af_autofitter_interface
#else /* FT_CONFIG_OPTION_PIC */
/* some include files required for members of AFModulePIC */
#include FT_SERVICE_PROPERTIES_H
#include "aftypes.h"
FT_BEGIN_HEADER
typedef struct AFModulePIC_
{
FT_ServiceDescRec* af_services;
FT_Service_PropertiesRec af_service_properties;
AF_WritingSystemClass af_writing_system_classes
[AF_WRITING_SYSTEM_MAX + 1];
AF_WritingSystemClassRec af_writing_system_classes_rec
[AF_WRITING_SYSTEM_MAX];
AF_ScriptClass af_script_classes
[AF_SCRIPT_MAX + 1];
AF_ScriptClassRec af_script_classes_rec
[AF_SCRIPT_MAX];
AF_StyleClass af_style_classes
[AF_STYLE_MAX + 1];
AF_StyleClassRec af_style_classes_rec
[AF_STYLE_MAX];
FT_AutoHinter_InterfaceRec af_autofitter_interface;
} AFModulePIC;
#define GET_PIC( lib ) \
( (AFModulePIC*)( (lib)->pic_container.autofit ) )
#define AF_SERVICES_GET \
( GET_PIC( library )->af_services )
#define AF_SERVICE_PROPERTIES_GET \
( GET_PIC( library )->af_service_properties )
#define AF_WRITING_SYSTEM_CLASSES_GET \
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_writing_system_classes )
#define AF_SCRIPT_CLASSES_GET \
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_script_classes )
#define AF_STYLE_CLASSES_GET \
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_style_classes )
#define AF_INTERFACE_GET \
( GET_PIC( library )->af_autofitter_interface )
/* see afpic.c for the implementation */
void
autofit_module_class_pic_free( FT_Library library );
FT_Error
autofit_module_class_pic_init( FT_Library library );
FT_END_HEADER
#endif /* FT_CONFIG_OPTION_PIC */
/* */
#endif /* AFPIC_H_ */
/* END */

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afranges.c */
/* */
/* Auto-fitter Unicode script ranges (body). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afranges.c
*
* Auto-fitter Unicode script ranges (body).
*
* Copyright (C) 2013-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 "afranges.h"
@ -664,6 +664,33 @@
};
const AF_Script_UniRangeRec af_medf_uniranges[] =
{
AF_UNIRANGE_REC( 0x16E40, 0x16E9F ), /* Medefaidrin */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_medf_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mong_uniranges[] =
{
AF_UNIRANGE_REC( 0x1800, 0x18AF ), /* Mongolian */
AF_UNIRANGE_REC( 0x11660, 0x1167F ), /* Mongolian Supplement */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mong_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x1885, 0x1886 ),
AF_UNIRANGE_REC( 0x18A9, 0x18A9 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mymr_uniranges[] =
{
AF_UNIRANGE_REC( 0x1000, 0x109F ), /* Myanmar */
@ -763,6 +790,18 @@
};
const AF_Script_UniRangeRec af_rohg_uniranges[] =
{
AF_UNIRANGE_REC( 0x10D00, 0x10D3F ), /* Hanifi Rohingya */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_rohg_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_saur_uniranges[] =
{
AF_UNIRANGE_REC( 0xA880, 0xA8DF ), /* Saurashtra */

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afranges.h */
/* */
/* Auto-fitter Unicode script ranges (specification). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afranges.h
*
* Auto-fitter Unicode script ranges (specification).
*
* Copyright (C) 2013-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 AFRANGES_H_

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afscript.h */
/* */
/* Auto-fitter scripts (specification only). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afscript.h
*
* Auto-fitter scripts (specification only).
*
* Copyright (C) 2013-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.
*
*/
/* The following part can be included multiple times. */
@ -243,6 +243,18 @@
HINTING_BOTTOM_TO_TOP,
"\xE0\xB4\xA0 \xE0\xB4\xB1" ) /* റ */
SCRIPT( medf, MEDF,
"Medefaidrin",
HB_SCRIPT_MEDEFAIDRIN,
HINTING_BOTTOM_TO_TOP,
"\xF0\x96\xB9\xA1 \xF0\x96\xB9\x9B \xF0\x96\xB9\xAF" ) /* 𖹡 𖹛 𖹯 */
SCRIPT( mong, MONG,
"Mongolian",
HB_SCRIPT_MONGOLIAN,
HINTING_TOP_TO_BOTTOM,
"\xE1\xA1\x82 \xE1\xA0\xAA" ) /* ᡂ ᠪ */
SCRIPT( mymr, MYMR,
"Myanmar",
HB_SCRIPT_MYANMAR,
@ -285,6 +297,12 @@
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\x92\x86 \xF0\x90\x92\xA0" ) /* 𐒆 𐒠 */
SCRIPT( rohg, ROHG,
"Hanifi Rohingya",
HB_SCRIPT_HANIFI_ROHINGYA,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\xB4\xB0" ) /* 𐴰 */
SCRIPT( saur, SAUR,
"Saurashtra",
HB_SCRIPT_SAURASHTRA,

View file

@ -1,24 +1,23 @@
/***************************************************************************/
/* */
/* afshaper.c */
/* */
/* HarfBuzz interface for accessing OpenType features (body). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afshaper.c
*
* HarfBuzz interface for accessing OpenType features (body).
*
* Copyright (C) 2013-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_FREETYPE_H
#include FT_ADVANCES_H
#include <freetype/freetype.h>
#include <freetype/ftadvanc.h>
#include "afglobal.h"
#include "aftypes.h"
#include "afshaper.h"
@ -26,14 +25,14 @@
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
/*************************************************************************/
/* */
/* 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_afshaper
#define FT_COMPONENT afshaper
/*
@ -133,13 +132,24 @@
/* Convert a HarfBuzz script tag into the corresponding OpenType */
/* tag or tags -- some Indic scripts like Devanagari have an old */
/* and a new set of features. */
hb_ot_tags_from_script( script,
&script_tags[0],
&script_tags[1] );
{
unsigned int tags_count = 3;
hb_tag_t tags[3];
/* `hb_ot_tags_from_script' usually returns HB_OT_TAG_DEFAULT_SCRIPT */
/* as the second tag. We change that to HB_TAG_NONE except for the */
/* default script. */
hb_ot_tags_from_script_and_language( script,
HB_LANGUAGE_INVALID,
&tags_count,
tags,
NULL,
NULL );
script_tags[0] = tags_count > 0 ? tags[0] : HB_TAG_NONE;
script_tags[1] = tags_count > 1 ? tags[1] : HB_TAG_NONE;
script_tags[2] = tags_count > 2 ? tags[2] : HB_TAG_NONE;
}
/* If the second tag is HB_OT_TAG_DEFAULT_SCRIPT, change that to */
/* HB_TAG_NONE except for the default script. */
if ( default_script )
{
if ( script_tags[0] == HB_TAG_NONE )
@ -158,9 +168,6 @@
/* HarfBuzz maps them to `DFLT', which we don't want to handle here */
if ( script_tags[0] == HB_OT_TAG_DEFAULT_SCRIPT )
goto Exit;
if ( script_tags[1] == HB_OT_TAG_DEFAULT_SCRIPT )
script_tags[1] = HB_TAG_NONE;
}
gsub_lookups = hb_set_create();
@ -174,9 +181,9 @@
if ( hb_set_is_empty( gsub_lookups ) )
goto Exit; /* nothing to do */
FT_TRACE4(( "GSUB lookups (style `%s'):\n"
" ",
FT_TRACE4(( "GSUB lookups (style `%s'):\n",
af_style_names[style_class->style] ));
FT_TRACE4(( " " ));
#ifdef FT_DEBUG_LEVEL_TRACE
count = 0;
@ -203,12 +210,13 @@
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !count )
FT_TRACE4(( " (none)" ));
FT_TRACE4(( "\n\n" ));
FT_TRACE4(( "\n" ));
FT_TRACE4(( "\n" ));
#endif
FT_TRACE4(( "GPOS lookups (style `%s'):\n"
" ",
FT_TRACE4(( "GPOS lookups (style `%s'):\n",
af_style_names[style_class->style] ));
FT_TRACE4(( " " ));
gpos_lookups = hb_set_create();
hb_ot_layout_collect_lookups( face,
@ -243,7 +251,8 @@
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !count )
FT_TRACE4(( " (none)" ));
FT_TRACE4(( "\n\n" ));
FT_TRACE4(( "\n" ));
FT_TRACE4(( "\n" ));
#endif
/*
@ -354,8 +363,10 @@
{
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !( count % 10 ) )
FT_TRACE4(( "\n"
" " ));
{
FT_TRACE4(( "\n" ));
FT_TRACE4(( " " ));
}
FT_TRACE4(( " %d", idx ));
count++;
@ -377,9 +388,12 @@
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !count )
FT_TRACE4(( "\n"
" (none)" ));
FT_TRACE4(( "\n\n" ));
{
FT_TRACE4(( "\n" ));
FT_TRACE4(( " (none)" ));
}
FT_TRACE4(( "\n" ));
FT_TRACE4(( "\n" ));
#endif
Exit:
@ -591,14 +605,9 @@
void*
af_shaper_buf_create( FT_Face face )
{
FT_Error error;
FT_Memory memory = face->memory;
FT_ULong* buf;
FT_UNUSED( face );
FT_MEM_ALLOC( buf, sizeof ( FT_ULong ) );
return (void*)buf;
return NULL;
}
@ -606,10 +615,8 @@
af_shaper_buf_destroy( FT_Face face,
void* buf )
{
FT_Memory memory = face->memory;
FT_FREE( buf );
FT_UNUSED( face );
FT_UNUSED( buf );
}

View file

@ -1,34 +1,33 @@
/***************************************************************************/
/* */
/* afshaper.h */
/* */
/* HarfBuzz interface for accessing OpenType features (specification). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afshaper.h
*
* HarfBuzz interface for accessing OpenType features (specification).
*
* Copyright (C) 2013-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 AFSHAPER_H_
#define AFSHAPER_H_
#include <ft2build.h>
#include FT_FREETYPE_H
#include <freetype/freetype.h>
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
#include <hb.h>
#include <hb-ot.h>
#include <hb-ft.h>
#include "ft-hb.h"
#endif

View file

@ -1,19 +1,19 @@
/***************************************************************************/
/* */
/* afstyles.h */
/* */
/* Auto-fitter styles (specification only). */
/* */
/* Copyright 2013-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* afstyles.h
*
* Auto-fitter styles (specification only).
*
* Copyright (C) 2013-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.
*
*/
/* The following part can be included multiple times. */
@ -299,15 +299,6 @@
AF_BLUE_STRINGSET_LATP,
AF_COVERAGE_DEFAULT )
#ifdef FT_OPTION_AUTOFIT2
STYLE( ltn2_dflt, LTN2_DFLT,
"Latin 2 default style",
AF_WRITING_SYSTEM_LATIN2,
AF_SCRIPT_LATN,
AF_BLUE_STRINGSET_LATN,
AF_COVERAGE_DEFAULT )
#endif
STYLE( lisu_dflt, LISU_DFLT,
"Lisu default style",
AF_WRITING_SYSTEM_LATIN,
@ -322,6 +313,20 @@
AF_BLUE_STRINGSET_MLYM,
AF_COVERAGE_DEFAULT )
STYLE( medf_dflt, MEDF_DFLT,
"Medefaidrin default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_MEDF,
AF_BLUE_STRINGSET_MEDF,
AF_COVERAGE_DEFAULT )
STYLE( mong_dflt, MONG_DFLT,
"Mongolian default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_MONG,
AF_BLUE_STRINGSET_MONG,
AF_COVERAGE_DEFAULT )
STYLE( mymr_dflt, MYMR_DFLT,
"Myanmar default style",
AF_WRITING_SYSTEM_LATIN,
@ -371,6 +376,13 @@
AF_BLUE_STRINGSET_OSMA,
AF_COVERAGE_DEFAULT )
STYLE( rohg_dflt, ROHG_DFLT,
"Hanifi Rohingya default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_ROHG,
AF_BLUE_STRINGSET_ROHG,
AF_COVERAGE_DEFAULT )
STYLE( saur_dflt, SAUR_DFLT,
"Saurashtra default style",
AF_WRITING_SYSTEM_LATIN,

View file

@ -1,30 +1,30 @@
/***************************************************************************/
/* */
/* aftypes.h */
/* */
/* Auto-fitter types (specification only). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* aftypes.h
*
* Auto-fitter types (specification only).
*
* Copyright (C) 2003-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.
*
*/
/*************************************************************************
*
* The auto-fitter is a complete rewrite of the old auto-hinter.
* Its main feature is the ability to differentiate between different
* writing systems and scripts in order to apply specific rules.
* The auto-fitter is a complete rewrite of the old auto-hinter.
* Its main feature is the ability to differentiate between different
* writing systems and scripts in order to apply specific rules.
*
* The code has also been compartmentalized into several entities that
* should make algorithmic experimentation easier than with the old
* code.
* The code has also been compartmentalized into several entities that
* should make algorithmic experimentation easier than with the old
* code.
*
*************************************************************************/
@ -32,12 +32,11 @@
#ifndef AFTYPES_H_
#define AFTYPES_H_
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include <freetype/freetype.h>
#include <freetype/ftoutln.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include "afblue.h"
@ -58,10 +57,10 @@ FT_BEGIN_HEADER
#ifdef FT_DEBUG_AUTOFIT
extern int _af_debug_disable_horz_hints;
extern int _af_debug_disable_vert_hints;
extern int _af_debug_disable_blue_hints;
extern void* _af_debug_hints;
extern int af_debug_disable_horz_hints_;
extern int af_debug_disable_vert_hints_;
extern int af_debug_disable_blue_hints_;
extern void* af_debug_hints_;
#endif /* FT_DEBUG_AUTOFIT */
@ -93,65 +92,9 @@ extern void* _af_debug_hints;
FT_Pos threshold );
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** A N G L E T Y P E S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* The auto-fitter doesn't need a very high angular accuracy;
* this allows us to speed up some computations considerably with a
* light Cordic algorithm (see afangles.c).
*/
typedef FT_Int AF_Angle;
#define AF_ANGLE_PI 256
#define AF_ANGLE_2PI ( AF_ANGLE_PI * 2 )
#define AF_ANGLE_PI2 ( AF_ANGLE_PI / 2 )
#define AF_ANGLE_PI4 ( AF_ANGLE_PI / 4 )
#if 0
/*
* compute the angle of a given 2-D vector
*/
FT_LOCAL( AF_Angle )
af_angle_atan( FT_Pos dx,
FT_Pos dy );
/*
* compute `angle2 - angle1'; the result is always within
* the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
*/
FT_LOCAL( AF_Angle )
af_angle_diff( AF_Angle angle1,
AF_Angle angle2 );
#endif /* 0 */
#define AF_ANGLE_DIFF( result, angle1, angle2 ) \
FT_BEGIN_STMNT \
AF_Angle _delta = (angle2) - (angle1); \
\
\
while ( _delta <= -AF_ANGLE_PI ) \
_delta += AF_ANGLE_2PI; \
\
while ( _delta > AF_ANGLE_PI ) \
_delta -= AF_ANGLE_2PI; \
\
result = _delta; \
FT_END_STMNT
/* opaque handle to glyph-specific hints -- see `afhints.h' for more
* details
* opaque handle to glyph-specific hints -- see `afhints.h' for more
* details
*/
typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
@ -165,25 +108,24 @@ extern void* _af_debug_hints;
/*************************************************************************/
/*
* A scaler models the target pixel device that will receive the
* auto-hinted glyph image.
* A scaler models the target pixel device that will receive the
* auto-hinted glyph image.
*/
#define AF_SCALER_FLAG_NO_HORIZONTAL 1U /* disable horizontal hinting */
#define AF_SCALER_FLAG_NO_VERTICAL 2U /* disable vertical hinting */
#define AF_SCALER_FLAG_NO_ADVANCE 4U /* disable advance hinting */
#define AF_SCALER_FLAG_NO_WARPER 8U /* disable warper */
typedef struct AF_ScalerRec_
{
FT_Face face; /* source font face */
FT_Fixed x_scale; /* from font units to 1/64th device pixels */
FT_Fixed y_scale; /* from font units to 1/64th device pixels */
FT_Pos x_delta; /* in 1/64th device pixels */
FT_Pos y_delta; /* in 1/64th device pixels */
FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
FT_UInt32 flags; /* additional control flags, see above */
FT_Face face; /* source font face */
FT_Fixed x_scale; /* from font units to 1/64 device pixels */
FT_Fixed y_scale; /* from font units to 1/64 device pixels */
FT_Pos x_delta; /* in 1/64 device pixels */
FT_Pos y_delta; /* in 1/64 device pixels */
FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
FT_UInt32 flags; /* additional control flags, see above */
} AF_ScalerRec, *AF_Scaler;
@ -197,8 +139,9 @@ extern void* _af_debug_hints;
typedef struct AF_StyleMetricsRec_* AF_StyleMetrics;
/* This function parses an FT_Face to compute global metrics for
* a specific style.
/*
* This function parses an FT_Face to compute global metrics for
* a specific style.
*/
typedef FT_Error
(*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics metrics,
@ -237,25 +180,24 @@ extern void* _af_debug_hints;
/*************************************************************************/
/*
* For the auto-hinter, a writing system consists of multiple scripts that
* can be handled similarly *in a typographical way*; the relationship is
* not based on history. For example, both the Greek and the unrelated
* Armenian scripts share the same features like ascender, descender,
* x-height, etc. Essentially, a writing system is covered by a
* submodule of the auto-fitter; it contains
* For the auto-hinter, a writing system consists of multiple scripts that
* can be handled similarly *in a typographical way*; the relationship is
* not based on history. For example, both the Greek and the unrelated
* Armenian scripts share the same features like ascender, descender,
* x-height, etc. Essentially, a writing system is covered by a
* submodule of the auto-fitter; it contains
*
* - a specific global analyzer that computes global metrics specific to
* the script (based on script-specific characters to identify ascender
* height, x-height, etc.),
* - a specific global analyzer that computes global metrics specific to
* the script (based on script-specific characters to identify ascender
* height, x-height, etc.),
*
* - a specific glyph analyzer that computes segments and edges for each
* glyph covered by the script,
* - a specific glyph analyzer that computes segments and edges for each
* glyph covered by the script,
*
* - a specific grid-fitting algorithm that distorts the scaled glyph
* outline according to the results of the glyph analyzer.
* - a specific grid-fitting algorithm that distorts the scaled glyph
* outline according to the results of the glyph analyzer.
*/
#define AFWRTSYS_H_ /* don't load header files */
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
AF_WRITING_SYSTEM_ ## WS,
@ -264,14 +206,12 @@ extern void* _af_debug_hints;
typedef enum AF_WritingSystem_
{
#include "afwrtsys.h"
#include "afws-iter.h"
AF_WRITING_SYSTEM_MAX /* do not remove */
} AF_WritingSystem;
#undef AFWRTSYS_H_
typedef struct AF_WritingSystemClassRec_
{
@ -300,12 +240,12 @@ extern void* _af_debug_hints;
/*************************************************************************/
/*
* Each script is associated with two sets of Unicode ranges to test
* whether the font face supports the script, and which non-base
* characters the script contains.
* Each script is associated with two sets of Unicode ranges to test
* whether the font face supports the script, and which non-base
* characters the script contains.
*
* We use four-letter script tags from the OpenType specification,
* extended by `NONE', which indicates `no script'.
* We use four-letter script tags from the OpenType specification,
* extended by `NONE', which indicates `no script'.
*/
#undef SCRIPT
@ -361,41 +301,41 @@ extern void* _af_debug_hints;
/*************************************************************************/
/*
* Usually, a font contains more glyphs than can be addressed by its
* character map.
* Usually, a font contains more glyphs than can be addressed by its
* character map.
*
* In the PostScript font world, encoding vectors specific to a given
* task are used to select such glyphs, and these glyphs can be often
* recognized by having a suffix in its glyph names. For example, a
* superscript glyph `A' might be called `A.sup'. Unfortunately, this
* naming scheme is not standardized and thus unusable for us.
* In the PostScript font world, encoding vectors specific to a given
* task are used to select such glyphs, and these glyphs can be often
* recognized by having a suffix in its glyph names. For example, a
* superscript glyph `A' might be called `A.sup'. Unfortunately, this
* naming scheme is not standardized and thus unusable for us.
*
* In the OpenType world, a better solution was invented, namely
* `features', which cleanly separate a character's input encoding from
* the corresponding glyph's appearance, and which don't use glyph names
* at all. For our purposes, and slightly generalized, an OpenType
* feature is a name of a mapping that maps character codes to
* non-standard glyph indices (features get used for other things also).
* For example, the `sups' feature provides superscript glyphs, thus
* mapping character codes like `A' or `B' to superscript glyph
* representation forms. How this mapping happens is completely
* uninteresting to us.
* In the OpenType world, a better solution was invented, namely
* `features', which cleanly separate a character's input encoding from
* the corresponding glyph's appearance, and which don't use glyph names
* at all. For our purposes, and slightly generalized, an OpenType
* feature is a name of a mapping that maps character codes to
* non-standard glyph indices (features get used for other things also).
* For example, the `sups' feature provides superscript glyphs, thus
* mapping character codes like `A' or `B' to superscript glyph
* representation forms. How this mapping happens is completely
* uninteresting to us.
*
* For the auto-hinter, a `coverage' represents all glyphs of an OpenType
* feature collected in a set (as listed below) that can be hinted
* together. To continue the above example, superscript glyphs must not
* be hinted together with normal glyphs because the blue zones
* completely differ.
* For the auto-hinter, a `coverage' represents all glyphs of an OpenType
* feature collected in a set (as listed below) that can be hinted
* together. To continue the above example, superscript glyphs must not
* be hinted together with normal glyphs because the blue zones
* completely differ.
*
* Note that FreeType itself doesn't compute coverages; it only provides
* the glyphs addressable by the default Unicode character map. Instead,
* we use the HarfBuzz library (if available), which has many functions
* exactly for this purpose.
* Note that FreeType itself doesn't compute coverages; it only provides
* the glyphs addressable by the default Unicode character map. Instead,
* we use the HarfBuzz library (if available), which has many functions
* exactly for this purpose.
*
* AF_COVERAGE_DEFAULT is special: It should cover everything that isn't
* listed separately (including the glyphs addressable by the character
* map). In case HarfBuzz isn't available, it exactly covers the glyphs
* addressable by the character map.
* AF_COVERAGE_DEFAULT is special: It should cover everything that isn't
* listed separately (including the glyphs addressable by the character
* map). In case HarfBuzz isn't available, it exactly covers the glyphs
* addressable by the character map.
*
*/
@ -423,8 +363,8 @@ extern void* _af_debug_hints;
/*************************************************************************/
/*
* The topmost structure for modelling the auto-hinter glyph input data
* is a `style class', grouping everything together.
* The topmost structure for modelling the auto-hinter glyph input data
* is a `style class', grouping everything together.
*/
#undef STYLE
@ -486,8 +426,6 @@ extern void* _af_debug_hints;
/* Declare and define vtables for classes */
#ifndef FT_CONFIG_OPTION_PIC
#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
FT_CALLBACK_TABLE const AF_WritingSystemClassRec \
writing_system_class;
@ -562,87 +500,9 @@ extern void* _af_debug_hints;
coverage \
};
#else /* FT_CONFIG_OPTION_PIC */
#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
FT_LOCAL( void ) \
FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac );
#define AF_DEFINE_WRITING_SYSTEM_CLASS( \
writing_system_class, \
system, \
m_size, \
m_init, \
m_scale, \
m_done, \
m_stdw, \
h_init, \
h_apply ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ) \
{ \
ac->writing_system = system; \
\
ac->style_metrics_size = m_size; \
\
ac->style_metrics_init = m_init; \
ac->style_metrics_scale = m_scale; \
ac->style_metrics_done = m_done; \
ac->style_metrics_getstdw = m_stdw; \
\
ac->style_hints_init = h_init; \
ac->style_hints_apply = h_apply; \
}
#define AF_DECLARE_SCRIPT_CLASS( script_class ) \
FT_LOCAL( void ) \
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac );
#define AF_DEFINE_SCRIPT_CLASS( \
script_class, \
script_, \
ranges, \
nonbase_ranges, \
top_to_bottom, \
std_charstring ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
{ \
ac->script = script_; \
ac->script_uni_ranges = ranges; \
ac->script_uni_nonbase_ranges = nonbase_ranges; \
ac->top_to_bottom_hinting = top_to_bottom; \
ac->standard_charstring = std_charstring; \
}
#define AF_DECLARE_STYLE_CLASS( style_class ) \
FT_LOCAL( void ) \
FT_Init_Class_ ## style_class( AF_StyleClassRec* ac );
#define AF_DEFINE_STYLE_CLASS( \
style_class, \
style_, \
writing_system_, \
script_, \
blue_stringset_, \
coverage_ ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## style_class( AF_StyleClassRec* ac ) \
{ \
ac->style = style_; \
ac->writing_system = writing_system_; \
ac->script = script_; \
ac->blue_stringset = blue_stringset_; \
ac->coverage = coverage_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* AFTYPES_H_ */

View file

@ -1,373 +0,0 @@
/***************************************************************************/
/* */
/* afwarp.c */
/* */
/* Auto-fitter warping algorithm (body). */
/* */
/* Copyright 2006-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. */
/* */
/***************************************************************************/
/*
* The idea of the warping code is to slightly scale and shift a glyph
* within a single dimension so that as much of its segments are aligned
* (more or less) on the grid. To find out the optimal scaling and
* shifting value, various parameter combinations are tried and scored.
*/
#include "afwarp.h"
#ifdef AF_CONFIG_OPTION_USE_WARPER
/*************************************************************************/
/* */
/* 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_afwarp
/* The weights cover the range 0/64 - 63/64 of a pixel. Obviously, */
/* values around a half pixel (which means exactly between two grid */
/* lines) gets the worst weight. */
#if 1
static const AF_WarpScore
af_warper_weights[64] =
{
35, 32, 30, 25, 20, 15, 12, 10, 5, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, -1, -2, -5, -8,-10,-10,-20,-20,-30,-30,
-30,-30,-20,-20,-10,-10, -8, -5, -2, -1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 5, 10, 12, 15, 20, 25, 30, 32,
};
#else
static const AF_WarpScore
af_warper_weights[64] =
{
30, 20, 10, 5, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, -1, -2, -2, -5, -5,-10,-10,-15,-20,
-20,-15,-15,-10,-10, -5, -5, -2, -2, -1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4, 5, 10, 20,
};
#endif
/* Score segments for a given `scale' and `delta' in the range */
/* `xx1' to `xx2', and store the best result in `warper'. If */
/* the new best score is equal to the old one, prefer the */
/* value with a smaller distortion (around `base_distort'). */
static void
af_warper_compute_line_best( AF_Warper warper,
FT_Fixed scale,
FT_Pos delta,
FT_Pos xx1,
FT_Pos xx2,
AF_WarpScore base_distort,
AF_Segment segments,
FT_Int num_segments )
{
FT_Int idx_min, idx_max, idx0;
FT_Int nn;
AF_WarpScore scores[65];
for ( nn = 0; nn < 65; nn++ )
scores[nn] = 0;
idx0 = xx1 - warper->t1;
/* compute minimum and maximum indices */
{
FT_Pos xx1min = warper->x1min;
FT_Pos xx1max = warper->x1max;
FT_Pos w = xx2 - xx1;
if ( xx1min + w < warper->x2min )
xx1min = warper->x2min - w;
if ( xx1max + w > warper->x2max )
xx1max = warper->x2max - w;
idx_min = xx1min - warper->t1;
idx_max = xx1max - warper->t1;
if ( idx_min < 0 || idx_min > idx_max || idx_max > 64 )
{
FT_TRACE5(( "invalid indices:\n"
" min=%d max=%d, xx1=%ld xx2=%ld,\n"
" x1min=%ld x1max=%ld, x2min=%ld x2max=%ld\n",
idx_min, idx_max, xx1, xx2,
warper->x1min, warper->x1max,
warper->x2min, warper->x2max ));
return;
}
}
for ( nn = 0; nn < num_segments; nn++ )
{
FT_Pos len = segments[nn].max_coord - segments[nn].min_coord;
FT_Pos y0 = FT_MulFix( segments[nn].pos, scale ) + delta;
FT_Pos y = y0 + ( idx_min - idx0 );
FT_Int idx;
/* score the length of the segments for the given range */
for ( idx = idx_min; idx <= idx_max; idx++, y++ )
scores[idx] += af_warper_weights[y & 63] * len;
}
/* find best score */
{
FT_Int idx;
for ( idx = idx_min; idx <= idx_max; idx++ )
{
AF_WarpScore score = scores[idx];
AF_WarpScore distort = base_distort + ( idx - idx0 );
if ( score > warper->best_score ||
( score == warper->best_score &&
distort < warper->best_distort ) )
{
warper->best_score = score;
warper->best_distort = distort;
warper->best_scale = scale;
warper->best_delta = delta + ( idx - idx0 );
}
}
}
}
/* Compute optimal scaling and delta values for a given glyph and */
/* dimension. */
FT_LOCAL_DEF( void )
af_warper_compute( AF_Warper warper,
AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed *a_scale,
FT_Pos *a_delta )
{
AF_AxisHints axis;
AF_Point points;
FT_Fixed org_scale;
FT_Pos org_delta;
FT_Int nn, num_points, num_segments;
FT_Int X1, X2;
FT_Int w;
AF_WarpScore base_distort;
AF_Segment segments;
/* get original scaling transformation */
if ( dim == AF_DIMENSION_VERT )
{
org_scale = hints->y_scale;
org_delta = hints->y_delta;
}
else
{
org_scale = hints->x_scale;
org_delta = hints->x_delta;
}
warper->best_scale = org_scale;
warper->best_delta = org_delta;
warper->best_score = FT_INT_MIN;
warper->best_distort = 0;
axis = &hints->axis[dim];
segments = axis->segments;
num_segments = axis->num_segments;
points = hints->points;
num_points = hints->num_points;
*a_scale = org_scale;
*a_delta = org_delta;
/* get X1 and X2, minimum and maximum in original coordinates */
if ( num_segments < 1 )
return;
#if 1
X1 = X2 = points[0].fx;
for ( nn = 1; nn < num_points; nn++ )
{
FT_Int X = points[nn].fx;
if ( X < X1 )
X1 = X;
if ( X > X2 )
X2 = X;
}
#else
X1 = X2 = segments[0].pos;
for ( nn = 1; nn < num_segments; nn++ )
{
FT_Int X = segments[nn].pos;
if ( X < X1 )
X1 = X;
if ( X > X2 )
X2 = X;
}
#endif
if ( X1 >= X2 )
return;
warper->x1 = FT_MulFix( X1, org_scale ) + org_delta;
warper->x2 = FT_MulFix( X2, org_scale ) + org_delta;
warper->t1 = AF_WARPER_FLOOR( warper->x1 );
warper->t2 = AF_WARPER_CEIL( warper->x2 );
/* examine a half pixel wide range around the maximum coordinates */
warper->x1min = warper->x1 & ~31;
warper->x1max = warper->x1min + 32;
warper->x2min = warper->x2 & ~31;
warper->x2max = warper->x2min + 32;
if ( warper->x1max > warper->x2 )
warper->x1max = warper->x2;
if ( warper->x2min < warper->x1 )
warper->x2min = warper->x1;
warper->w0 = warper->x2 - warper->x1;
if ( warper->w0 <= 64 )
{
warper->x1max = warper->x1;
warper->x2min = warper->x2;
}
/* examine (at most) a pixel wide range around the natural width */
warper->wmin = warper->x2min - warper->x1max;
warper->wmax = warper->x2max - warper->x1min;
#if 1
/* some heuristics to reduce the number of widths to be examined */
{
int margin = 16;
if ( warper->w0 <= 128 )
{
margin = 8;
if ( warper->w0 <= 96 )
margin = 4;
}
if ( warper->wmin < warper->w0 - margin )
warper->wmin = warper->w0 - margin;
if ( warper->wmax > warper->w0 + margin )
warper->wmax = warper->w0 + margin;
}
if ( warper->wmin < warper->w0 * 3 / 4 )
warper->wmin = warper->w0 * 3 / 4;
if ( warper->wmax > warper->w0 * 5 / 4 )
warper->wmax = warper->w0 * 5 / 4;
#else
/* no scaling, just translation */
warper->wmin = warper->wmax = warper->w0;
#endif
for ( w = warper->wmin; w <= warper->wmax; w++ )
{
FT_Fixed new_scale;
FT_Pos new_delta;
FT_Pos xx1, xx2;
/* compute min and max positions for given width, */
/* assuring that they stay within the coordinate ranges */
xx1 = warper->x1;
xx2 = warper->x2;
if ( w >= warper->w0 )
{
xx1 -= w - warper->w0;
if ( xx1 < warper->x1min )
{
xx2 += warper->x1min - xx1;
xx1 = warper->x1min;
}
}
else
{
xx1 -= w - warper->w0;
if ( xx1 > warper->x1max )
{
xx2 -= xx1 - warper->x1max;
xx1 = warper->x1max;
}
}
if ( xx1 < warper->x1 )
base_distort = warper->x1 - xx1;
else
base_distort = xx1 - warper->x1;
if ( xx2 < warper->x2 )
base_distort += warper->x2 - xx2;
else
base_distort += xx2 - warper->x2;
/* give base distortion a greater weight while scoring */
base_distort *= 10;
new_scale = org_scale + FT_DivFix( w - warper->w0, X2 - X1 );
new_delta = xx1 - FT_MulFix( X1, new_scale );
af_warper_compute_line_best( warper, new_scale, new_delta, xx1, xx2,
base_distort,
segments, num_segments );
}
{
FT_Fixed best_scale = warper->best_scale;
FT_Pos best_delta = warper->best_delta;
hints->xmin_delta = FT_MulFix( X1, best_scale - org_scale )
+ best_delta;
hints->xmax_delta = FT_MulFix( X2, best_scale - org_scale )
+ best_delta;
*a_scale = best_scale;
*a_delta = best_delta;
}
}
#else /* !AF_CONFIG_OPTION_USE_WARPER */
/* ANSI C doesn't like empty source files */
typedef int _af_warp_dummy;
#endif /* !AF_CONFIG_OPTION_USE_WARPER */
/* END */

View file

@ -1,64 +0,0 @@
/***************************************************************************/
/* */
/* afwarp.h */
/* */
/* Auto-fitter warping algorithm (specification). */
/* */
/* Copyright 2006-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 AFWARP_H_
#define AFWARP_H_
#include "afhints.h"
FT_BEGIN_HEADER
#define AF_WARPER_SCALE
#define AF_WARPER_FLOOR( x ) ( (x) & ~FT_TYPEOF( x )63 )
#define AF_WARPER_CEIL( x ) AF_WARPER_FLOOR( (x) + 63 )
typedef FT_Int32 AF_WarpScore;
typedef struct AF_WarperRec_
{
FT_Pos x1, x2;
FT_Pos t1, t2;
FT_Pos x1min, x1max;
FT_Pos x2min, x2max;
FT_Pos w0, wmin, wmax;
FT_Fixed best_scale;
FT_Pos best_delta;
AF_WarpScore best_score;
AF_WarpScore best_distort;
} AF_WarperRec, *AF_Warper;
FT_LOCAL( void )
af_warper_compute( AF_Warper warper,
AF_GlyphHints hints,
AF_Dimension dim,
FT_Fixed *a_scale,
FT_Fixed *a_delta );
FT_END_HEADER
#endif /* AFWARP_H_ */
/* END */

View file

@ -1,52 +0,0 @@
/***************************************************************************/
/* */
/* afwrtsys.h */
/* */
/* Auto-fitter writing systems (specification only). */
/* */
/* Copyright 2013-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 AFWRTSYS_H_
#define AFWRTSYS_H_
/* Since preprocessor directives can't create other preprocessor */
/* directives, we have to include the header files manually. */
#include "afdummy.h"
#include "aflatin.h"
#include "afcjk.h"
#include "afindic.h"
#ifdef FT_OPTION_AUTOFIT2
#include "aflatin2.h"
#endif
#endif /* AFWRTSYS_H_ */
/* The following part can be included multiple times. */
/* Define `WRITING_SYSTEM' as needed. */
/* Add new writing systems here. The arguments are the writing system */
/* name in lowercase and uppercase, respectively. */
WRITING_SYSTEM( dummy, DUMMY )
WRITING_SYSTEM( latin, LATIN )
WRITING_SYSTEM( cjk, CJK )
WRITING_SYSTEM( indic, INDIC )
#ifdef FT_OPTION_AUTOFIT2
WRITING_SYSTEM( latin2, LATIN2 )
#endif
/* END */

View file

@ -0,0 +1,33 @@
/****************************************************************************
*
* afws-decl.h
*
* Auto-fitter writing system declarations (specification only).
*
* Copyright (C) 2013-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 AFWS_DECL_H_
#define AFWS_DECL_H_
/* Since preprocessor directives can't create other preprocessor */
/* directives, we have to include the header files manually. */
#include "afdummy.h"
#include "aflatin.h"
#include "afcjk.h"
#include "afindic.h"
#endif /* AFWS_DECL_H_ */
/* END */

View file

@ -0,0 +1,31 @@
/****************************************************************************
*
* afws-iter.h
*
* Auto-fitter writing systems iterator (specification only).
*
* Copyright (C) 2013-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 header may be included multiple times. */
/* Define `WRITING_SYSTEM' as needed. */
/* Add new writing systems here. The arguments are the writing system */
/* name in lowercase and uppercase, respectively. */
WRITING_SYSTEM( dummy, DUMMY )
WRITING_SYSTEM( latin, LATIN )
WRITING_SYSTEM( cjk, CJK )
WRITING_SYSTEM( indic, INDIC )
/* END */

View file

@ -1,25 +1,24 @@
/***************************************************************************/
/* */
/* autofit.c */
/* */
/* Auto-fitter module (body). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* autofit.c
*
* Auto-fitter module (body).
*
* Copyright (C) 2003-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 "afangles.c"
#include "ft-hb.c"
#include "afblue.c"
#include "afcjk.c"
#include "afdummy.c"
@ -27,13 +26,10 @@
#include "afhints.c"
#include "afindic.c"
#include "aflatin.c"
#include "aflatin2.c"
#include "afloader.c"
#include "afmodule.c"
#include "afpic.c"
#include "afranges.c"
#include "afshaper.c"
#include "afwarp.c"
/* END */

View file

@ -0,0 +1,115 @@
/*
* Copyright © 2009, 2023 Red Hat, Inc.
* Copyright © 2015 Google, Inc.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Red Hat Author(s): Behdad Esfahbod, Matthias Clasen
* Google Author(s): Behdad Esfahbod
*/
#include <freetype/freetype.h>
#include <freetype/tttables.h>
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
#include "ft-hb.h"
/* The following three functions are a more or less verbatim
* copy of corresponding HarfBuzz code from hb-ft.cc
*/
static hb_blob_t *
hb_ft_reference_table_ (hb_face_t *face, hb_tag_t tag, void *user_data)
{
FT_Face ft_face = (FT_Face) user_data;
FT_Byte *buffer;
FT_ULong length = 0;
FT_Error error;
FT_UNUSED (face);
/* Note: FreeType like HarfBuzz uses the NONE tag for fetching the entire blob */
error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length);
if (error)
return NULL;
buffer = (FT_Byte *) ft_smalloc (length);
if (!buffer)
return NULL;
error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length);
if (error)
{
free (buffer);
return NULL;
}
return hb_blob_create ((const char *) buffer, length,
HB_MEMORY_MODE_WRITABLE,
buffer, ft_sfree);
}
static hb_face_t *
hb_ft_face_create_ (FT_Face ft_face,
hb_destroy_func_t destroy)
{
hb_face_t *face;
if (!ft_face->stream->read) {
hb_blob_t *blob;
blob = hb_blob_create ((const char *) ft_face->stream->base,
(unsigned int) ft_face->stream->size,
HB_MEMORY_MODE_READONLY,
ft_face, destroy);
face = hb_face_create (blob, ft_face->face_index);
hb_blob_destroy (blob);
} else {
face = hb_face_create_for_tables (hb_ft_reference_table_, ft_face, destroy);
}
hb_face_set_index (face, ft_face->face_index);
hb_face_set_upem (face, ft_face->units_per_EM);
return face;
}
FT_LOCAL_DEF(hb_font_t *)
hb_ft_font_create_ (FT_Face ft_face,
hb_destroy_func_t destroy)
{
hb_font_t *font;
hb_face_t *face;
face = hb_ft_face_create_ (ft_face, destroy);
font = hb_font_create (face);
hb_face_destroy (face);
return font;
}
#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
/* ANSI C doesn't like empty source files */
typedef int _ft_hb_dummy;
#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
/* END */

View file

@ -0,0 +1,48 @@
/*
* Copyright © 2009, 2023 Red Hat, Inc.
* Copyright © 2015 Google, Inc.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Red Hat Author(s): Behdad Esfahbod, Matthias Clasen
* Google Author(s): Behdad Esfahbod
*/
#ifndef FT_HB_H
#define FT_HB_H
#include <hb.h>
#include <freetype/internal/compiler-macros.h>
#include <freetype/freetype.h>
FT_BEGIN_HEADER
FT_LOCAL(hb_font_t *)
hb_ft_font_create_ (FT_Face ft_face,
hb_destroy_func_t destroy);
FT_END_HEADER
#endif /* FT_HB_H */
/* END */

View file

@ -3,7 +3,7 @@
#
# Copyright 2003-2018 by
# Copyright (C) 2003-2023 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View file

@ -3,7 +3,7 @@
#
# Copyright 2003-2018 by
# Copyright (C) 2003-2023 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -28,8 +28,7 @@ AUTOF_COMPILE := $(CC) $(ANSIFLAGS) \
# AUTOF driver sources (i.e., C files)
#
AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
$(AUTOF_DIR)/afblue.c \
AUTOF_DRV_SRC := $(AUTOF_DIR)/afblue.c \
$(AUTOF_DIR)/afcjk.c \
$(AUTOF_DIR)/afdummy.c \
$(AUTOF_DIR)/afglobal.c \
@ -38,20 +37,20 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
$(AUTOF_DIR)/aflatin.c \
$(AUTOF_DIR)/afloader.c \
$(AUTOF_DIR)/afmodule.c \
$(AUTOF_DIR)/afpic.c \
$(AUTOF_DIR)/afranges.c \
$(AUTOF_DIR)/afshaper.c \
$(AUTOF_DIR)/afwarp.c
$(AUTOF_DIR)/ft-hb.c
# AUTOF driver headers
#
AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \
$(AUTOF_DIR)/afcover.h \
$(AUTOF_DIR)/aferrors.h \
$(AUTOF_DIR)/afscript.h \
$(AUTOF_DIR)/afstyles.h \
$(AUTOF_DIR)/aftypes.h \
$(AUTOF_DIR)/afwrtsys.h
AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \
$(AUTOF_DIR)/afcover.h \
$(AUTOF_DIR)/aferrors.h \
$(AUTOF_DIR)/afscript.h \
$(AUTOF_DIR)/afstyles.h \
$(AUTOF_DIR)/aftypes.h \
$(AUTOF_DIR)/afws-decl.h \
$(AUTOF_DIR)/afws-iter.h
# AUTOF driver object(s)

View file

@ -1,89 +0,0 @@
# FreeType 2 src/base 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) base ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = basepic
ftadvanc
ftcalc
ftdbgmem
ftfntfmt
ftgloadr
fthash
ftlcdfil
ftobjs
ftoutln
ftpic
ftpsprop
ftrfork
ftsnames
ftstream
fttrigon
ftutil
;
}
else
{
_sources = ftbase ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# Add the optional/replaceable files.
#
{
local _sources = ftapi
ftbbox
ftbdf
ftbitmap
ftcid
ftdebug
ftfstype
ftgasp
ftglyph
ftgxval
ftinit
ftmm
ftotval
ftpatent
ftpfr
ftstroke
ftsynth
ftsystem
fttype1
ftwinfnt
;
Library $(FT2_LIB) : $(_sources).c ;
}
# Add Macintosh-specific file to the library when necessary.
#
if $(MAC)
{
Library $(FT2_LIB) : ftmac.c ;
}
else if $(OS) = MACOSX
{
if $(FT2_MULTI)
{
Library $(FT2_LIB) : ftmac.c ;
}
}
# end of src/base Jamfile

View file

@ -1,108 +0,0 @@
/***************************************************************************/
/* */
/* basepic.c */
/* */
/* The FreeType position independent code services for base. */
/* */
/* 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 "basepic.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftglyph.c */
void
FT_Init_Class_ft_outline_glyph_class( FT_Glyph_Class* clazz );
void
FT_Init_Class_ft_bitmap_glyph_class( FT_Glyph_Class* clazz );
#ifdef FT_CONFIG_OPTION_MAC_FONTS
/* forward declaration of PIC init function from ftrfork.c */
/* (not modularized) */
void
FT_Init_Table_ft_raccess_guess_table( ft_raccess_guess_rec* record );
#endif
/* forward declaration of PIC init functions from ftinit.c */
FT_Error
ft_create_default_module_classes( FT_Library library );
void
ft_destroy_default_module_classes( FT_Library library );
void
ft_base_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->base )
{
/* destroy default module classes */
/* (in case FT_Add_Default_Modules was used) */
ft_destroy_default_module_classes( library );
FT_FREE( pic_container->base );
pic_container->base = NULL;
}
}
FT_Error
ft_base_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
BasePIC* 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->base = container;
/* initialize default modules list and pointers */
error = ft_create_default_module_classes( library );
if ( error )
goto Exit;
/* initialize pointer table - */
/* this is how the module usually expects this data */
FT_Init_Class_ft_outline_glyph_class(
&container->ft_outline_glyph_class );
FT_Init_Class_ft_bitmap_glyph_class(
&container->ft_bitmap_glyph_class );
#ifdef FT_CONFIG_OPTION_MAC_FONTS
FT_Init_Table_ft_raccess_guess_table(
(ft_raccess_guess_rec*)&container->ft_raccess_guess_table );
#endif
Exit:
if ( error )
ft_base_pic_free( library );
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */

View file

@ -1,91 +0,0 @@
/***************************************************************************/
/* */
/* basepic.h */
/* */
/* The FreeType position independent code services for base. */
/* */
/* 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 BASEPIC_H_
#define BASEPIC_H_
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class
#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class
#define FT_DEFAULT_MODULES_GET ft_default_modules
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
#define FT_RACCESS_GUESS_TABLE_GET ft_raccess_guess_table
#endif
#else /* FT_CONFIG_OPTION_PIC */
#include FT_GLYPH_H
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
#include FT_INTERNAL_RFORK_H
#endif
FT_BEGIN_HEADER
typedef struct BasePIC_
{
FT_Module_Class** default_module_classes;
FT_Glyph_Class ft_outline_glyph_class;
FT_Glyph_Class ft_bitmap_glyph_class;
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
ft_raccess_guess_rec ft_raccess_guess_table[FT_RACCESS_N_RULES];
#endif
} BasePIC;
#define GET_PIC( lib ) ( (BasePIC*)( (lib)->pic_container.base ) )
#define FT_OUTLINE_GLYPH_CLASS_GET \
( &GET_PIC( library )->ft_outline_glyph_class )
#define FT_BITMAP_GLYPH_CLASS_GET \
( &GET_PIC( library )->ft_bitmap_glyph_class )
#define FT_DEFAULT_MODULES_GET \
( GET_PIC( library )->default_module_classes )
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
#define FT_RACCESS_GUESS_TABLE_GET \
( GET_PIC( library )->ft_raccess_guess_table )
#endif
/* see basepic.c for the implementation */
void
ft_base_pic_free( FT_Library library );
FT_Error
ft_base_pic_init( FT_Library library );
FT_END_HEADER
#endif /* FT_CONFIG_OPTION_PIC */
/* */
#endif /* BASEPIC_H_ */
/* END */

View file

@ -1,30 +1,29 @@
/***************************************************************************/
/* */
/* ftadvanc.c */
/* */
/* Quick computation of advance widths (body). */
/* */
/* Copyright 2008-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftadvanc.c
*
* Quick computation of advance widths (body).
*
* Copyright (C) 2008-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_ADVANCES_H
#include FT_INTERNAL_OBJECTS_H
#include <freetype/ftadvanc.h>
#include <freetype/internal/ftobjs.h>
static FT_Error
_ft_face_scale_advances( FT_Face face,
ft_face_scale_advances_( FT_Face face,
FT_Fixed* advances,
FT_UInt count,
FT_Int32 flags )
@ -97,7 +96,7 @@
error = func( face, gindex, 1, flags, padvance );
if ( !error )
return _ft_face_scale_advances( face, padvance, 1, flags );
return ft_face_scale_advances_( face, padvance, 1, flags );
if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;
@ -143,7 +142,7 @@
{
error = func( face, start, count, flags, padvances );
if ( !error )
return _ft_face_scale_advances( face, padvances, count, flags );
return ft_face_scale_advances_( face, padvances, count, flags );
if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;

View file

@ -1,121 +0,0 @@
/***************************************************************************/
/* */
/* ftapi.c */
/* */
/* The FreeType compatibility functions (body). */
/* */
/* Copyright 2002-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_LIST_H
#include FT_OUTLINE_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TABLES_H
#include FT_OUTLINE_H
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** C O M P A T I B I L I T Y ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* backward compatibility API */
FT_BASE_DEF( void )
FT_New_Memory_Stream( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Stream stream )
{
FT_UNUSED( library );
FT_Stream_OpenMemory( stream, base, size );
}
FT_BASE_DEF( FT_Error )
FT_Seek_Stream( FT_Stream stream,
FT_ULong pos )
{
return FT_Stream_Seek( stream, pos );
}
FT_BASE_DEF( FT_Error )
FT_Skip_Stream( FT_Stream stream,
FT_Long distance )
{
return FT_Stream_Skip( stream, distance );
}
FT_BASE_DEF( FT_Error )
FT_Read_Stream( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count )
{
return FT_Stream_Read( stream, buffer, count );
}
FT_BASE_DEF( FT_Error )
FT_Read_Stream_At( FT_Stream stream,
FT_ULong pos,
FT_Byte* buffer,
FT_ULong count )
{
return FT_Stream_ReadAt( stream, pos, buffer, count );
}
FT_BASE_DEF( FT_Error )
FT_Extract_Frame( FT_Stream stream,
FT_ULong count,
FT_Byte** pbytes )
{
return FT_Stream_ExtractFrame( stream, count, pbytes );
}
FT_BASE_DEF( void )
FT_Release_Frame( FT_Stream stream,
FT_Byte** pbytes )
{
FT_Stream_ReleaseFrame( stream, pbytes );
}
FT_BASE_DEF( FT_Error )
FT_Access_Frame( FT_Stream stream,
FT_ULong count )
{
return FT_Stream_EnterFrame( stream, count );
}
FT_BASE_DEF( void )
FT_Forget_Frame( FT_Stream stream )
{
FT_Stream_ExitFrame( stream );
}
/* END */

View file

@ -1,28 +1,28 @@
/***************************************************************************/
/* */
/* ftbase.c */
/* */
/* Single object library 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftbase.c
*
* Single object library 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.
*
*/
#include <ft2build.h>
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include "basepic.c"
#include "ftadvanc.c"
#include "ftcalc.c"
#include "ftcolor.c"
#include "ftdbgmem.c"
#include "fterrors.c"
#include "ftfntfmt.c"
#include "ftgloadr.c"
#include "fthash.c"
@ -30,7 +30,6 @@
#include "ftmac.c"
#include "ftobjs.c"
#include "ftoutln.c"
#include "ftpic.c"
#include "ftpsprop.c"
#include "ftrfork.c"
#include "ftsnames.c"

View file

@ -1,32 +1,36 @@
/***************************************************************************/
/* */
/* ftbase.h */
/* */
/* Private functions used in the `base' module (specification). */
/* */
/* Copyright 2008-2018 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftbase.h
*
* Private functions used in the `base' module (specification).
*
* Copyright (C) 2008-2023 by
* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
*
* 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 FTBASE_H_
#define FTBASE_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include <freetype/internal/ftobjs.h>
FT_BEGIN_HEADER
FT_DECLARE_GLYPH( ft_bitmap_glyph_class )
FT_DECLARE_GLYPH( ft_outline_glyph_class )
FT_DECLARE_GLYPH( ft_svg_glyph_class )
#ifdef FT_CONFIG_OPTION_MAC_FONTS
/* MacOS resource fork cannot exceed 16MB at least for Carbon code; */

View file

@ -1,37 +1,36 @@
/***************************************************************************/
/* */
/* ftbbox.c */
/* */
/* FreeType bbox computation (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftbbox.c
*
* FreeType bbox computation (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.
*
*/
/*************************************************************************/
/* */
/* This component has a _single_ role: to compute exact outline bounding */
/* boxes. */
/* */
/*************************************************************************/
/**************************************************************************
*
* This component has a _single_ role: to compute exact outline bounding
* boxes.
*
*/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include <freetype/internal/ftdebug.h>
#include FT_BBOX_H
#include FT_IMAGE_H
#include FT_OUTLINE_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_OBJECTS_H
#include <freetype/ftbbox.h>
#include <freetype/ftimage.h>
#include <freetype/ftoutln.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftobjs.h>
typedef struct TBBox_Rec_
@ -61,26 +60,28 @@
( p->y < bbox.yMin || p->y > bbox.yMax )
/*************************************************************************/
/* */
/* <Function> */
/* BBox_Move_To */
/* */
/* <Description> */
/* This function is used as a `move_to' emitter during */
/* FT_Outline_Decompose(). It simply records the destination point */
/* in `user->last'. We also update bbox in case contour starts with */
/* an implicit `on' point. */
/* */
/* <Input> */
/* to :: A pointer to the destination vector. */
/* */
/* <InOut> */
/* user :: A pointer to the current walk context. */
/* */
/* <Return> */
/* Always 0. Needed for the interface only. */
/* */
/**************************************************************************
*
* @Function:
* BBox_Move_To
*
* @Description:
* This function is used as a `move_to' emitter during
* FT_Outline_Decompose(). It simply records the destination point
* in `user->last'. We also update bbox in case contour starts with
* an implicit `on' point.
*
* @Input:
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* A pointer to the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*/
static int
BBox_Move_To( FT_Vector* to,
TBBox_Rec* user )
@ -93,26 +94,28 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* BBox_Line_To */
/* */
/* <Description> */
/* This function is used as a `line_to' emitter during */
/* FT_Outline_Decompose(). It simply records the destination point */
/* in `user->last'; no further computations are necessary because */
/* bbox already contains both explicit ends of the line segment. */
/* */
/* <Input> */
/* to :: A pointer to the destination vector. */
/* */
/* <InOut> */
/* user :: A pointer to the current walk context. */
/* */
/* <Return> */
/* Always 0. Needed for the interface only. */
/* */
/**************************************************************************
*
* @Function:
* BBox_Line_To
*
* @Description:
* This function is used as a `line_to' emitter during
* FT_Outline_Decompose(). It simply records the destination point
* in `user->last'; no further computations are necessary because
* bbox already contains both explicit ends of the line segment.
*
* @Input:
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* A pointer to the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*/
static int
BBox_Line_To( FT_Vector* to,
TBBox_Rec* user )
@ -123,28 +126,33 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* BBox_Conic_Check */
/* */
/* <Description> */
/* Find the extrema of a 1-dimensional conic Bezier curve and update */
/* a bounding range. This version uses direct computation, as it */
/* doesn't need square roots. */
/* */
/* <Input> */
/* y1 :: The start coordinate. */
/* */
/* y2 :: The coordinate of the control point. */
/* */
/* y3 :: The end coordinate. */
/* */
/* <InOut> */
/* min :: The address of the current minimum. */
/* */
/* max :: The address of the current maximum. */
/* */
/**************************************************************************
*
* @Function:
* BBox_Conic_Check
*
* @Description:
* Find the extrema of a 1-dimensional conic Bezier curve and update
* a bounding range. This version uses direct computation, as it
* doesn't need square roots.
*
* @Input:
* y1 ::
* The start coordinate.
*
* y2 ::
* The coordinate of the control point.
*
* y3 ::
* The end coordinate.
*
* @InOut:
* min ::
* The address of the current minimum.
*
* max ::
* The address of the current maximum.
*/
static void
BBox_Conic_Check( FT_Pos y1,
FT_Pos y2,
@ -168,32 +176,35 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* BBox_Conic_To */
/* */
/* <Description> */
/* This function is used as a `conic_to' emitter during */
/* FT_Outline_Decompose(). It checks a conic Bezier curve with the */
/* current bounding box, and computes its extrema if necessary to */
/* update it. */
/* */
/* <Input> */
/* control :: A pointer to a control point. */
/* */
/* to :: A pointer to the destination vector. */
/* */
/* <InOut> */
/* user :: The address of the current walk context. */
/* */
/* <Return> */
/* Always 0. Needed for the interface only. */
/* */
/* <Note> */
/* In the case of a non-monotonous arc, we compute directly the */
/* extremum coordinates, as it is sufficiently fast. */
/* */
/**************************************************************************
*
* @Function:
* BBox_Conic_To
*
* @Description:
* This function is used as a `conic_to' emitter during
* FT_Outline_Decompose(). It checks a conic Bezier curve with the
* current bounding box, and computes its extrema if necessary to
* update it.
*
* @Input:
* control ::
* A pointer to a control point.
*
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* The address of the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*
* @Note:
* In the case of a non-monotonous arc, we compute directly the
* extremum coordinates, as it is sufficiently fast.
*/
static int
BBox_Conic_To( FT_Vector* control,
FT_Vector* to,
@ -222,30 +233,36 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* BBox_Cubic_Check */
/* */
/* <Description> */
/* Find the extrema of a 1-dimensional cubic Bezier curve and */
/* update a bounding range. This version uses iterative splitting */
/* because it is faster than the exact solution with square roots. */
/* */
/* <Input> */
/* p1 :: The start coordinate. */
/* */
/* p2 :: The coordinate of the first control point. */
/* */
/* p3 :: The coordinate of the second control point. */
/* */
/* p4 :: The end coordinate. */
/* */
/* <InOut> */
/* min :: The address of the current minimum. */
/* */
/* max :: The address of the current maximum. */
/* */
/**************************************************************************
*
* @Function:
* BBox_Cubic_Check
*
* @Description:
* Find the extrema of a 1-dimensional cubic Bezier curve and
* update a bounding range. This version uses iterative splitting
* because it is faster than the exact solution with square roots.
*
* @Input:
* p1 ::
* The start coordinate.
*
* p2 ::
* The coordinate of the first control point.
*
* p3 ::
* The coordinate of the second control point.
*
* p4 ::
* The end coordinate.
*
* @InOut:
* min ::
* The address of the current minimum.
*
* max ::
* The address of the current maximum.
*/
static FT_Pos
cubic_peak( FT_Pos q1,
FT_Pos q2,
@ -276,10 +293,10 @@
if ( shift > 2 )
shift = 2;
q1 <<= shift;
q2 <<= shift;
q3 <<= shift;
q4 <<= shift;
q1 *= 1 << shift;
q2 *= 1 << shift;
q3 *= 1 << shift;
q4 *= 1 << shift;
}
else
{
@ -301,9 +318,9 @@
q2 = q2 + q1;
q4 = q4 + q3;
q3 = q3 + q2;
q4 = ( q4 + q3 ) / 8;
q3 = q3 / 4;
q2 = q2 / 2;
q4 = ( q4 + q3 ) >> 3;
q3 = q3 >> 2;
q2 = q2 >> 1;
}
else /* second half */
{
@ -312,9 +329,9 @@
q3 = q3 + q4;
q1 = q1 + q2;
q2 = q2 + q3;
q1 = ( q1 + q2 ) / 8;
q2 = q2 / 4;
q3 = q3 / 2;
q1 = ( q1 + q2 ) >> 3;
q2 = q2 >> 2;
q3 = q3 >> 1;
}
/* check whether either end reached the maximum */
@ -361,34 +378,38 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* BBox_Cubic_To */
/* */
/* <Description> */
/* This function is used as a `cubic_to' emitter during */
/* FT_Outline_Decompose(). It checks a cubic Bezier curve with the */
/* current bounding box, and computes its extrema if necessary to */
/* update it. */
/* */
/* <Input> */
/* control1 :: A pointer to the first control point. */
/* */
/* control2 :: A pointer to the second control point. */
/* */
/* to :: A pointer to the destination vector. */
/* */
/* <InOut> */
/* user :: The address of the current walk context. */
/* */
/* <Return> */
/* Always 0. Needed for the interface only. */
/* */
/* <Note> */
/* In the case of a non-monotonous arc, we don't compute directly */
/* extremum coordinates, we subdivide instead. */
/* */
/**************************************************************************
*
* @Function:
* BBox_Cubic_To
*
* @Description:
* This function is used as a `cubic_to' emitter during
* FT_Outline_Decompose(). It checks a cubic Bezier curve with the
* current bounding box, and computes its extrema if necessary to
* update it.
*
* @Input:
* control1 ::
* A pointer to the first control point.
*
* control2 ::
* A pointer to the second control point.
*
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* The address of the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*
* @Note:
* In the case of a non-monotonous arc, we don't compute directly
* extremum coordinates, we subdivide instead.
*/
static int
BBox_Cubic_To( FT_Vector* control1,
FT_Vector* control2,
@ -490,12 +511,6 @@
FT_Error error;
TBBox_Rec user;
#ifdef FT_CONFIG_OPTION_PIC
FT_Outline_Funcs bbox_interface;
Init_Class_bbox_interface( &bbox_interface );
#endif
user.bbox = bbox;

View file

@ -1,26 +1,25 @@
/***************************************************************************/
/* */
/* ftbdf.c */
/* */
/* FreeType API for accessing BDF-specific strings (body). */
/* */
/* Copyright 2002-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftbdf.c
*
* FreeType API for accessing BDF-specific strings (body).
*
* Copyright (C) 2002-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_INTERNAL_OBJECTS_H
#include FT_SERVICE_BDF_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svbdf.h>
/* documentation is in ftbdf.h */

View file

@ -1,31 +1,40 @@
/***************************************************************************/
/* */
/* ftbitmap.c */
/* */
/* FreeType utility functions for bitmaps (body). */
/* */
/* Copyright 2004-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftbitmap.c
*
* FreeType utility functions for bitmaps (body).
*
* Copyright (C) 2004-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_BITMAP_H
#include FT_IMAGE_H
#include FT_INTERNAL_OBJECTS_H
#include <freetype/ftbitmap.h>
#include <freetype/ftimage.h>
#include <freetype/internal/ftobjs.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.
*/
#undef FT_COMPONENT
#define FT_COMPONENT bitmap
static
const FT_Bitmap null_bitmap = { 0, 0, 0, 0, 0, 0, 0, 0 };
const FT_Bitmap null_bitmap = { 0, 0, 0, NULL, 0, 0, 0, NULL };
/* documentation is in ftbitmap.h */
@ -57,11 +66,8 @@
{
FT_Memory memory;
FT_Error error = FT_Err_Ok;
FT_Int pitch;
FT_ULong size;
FT_Int source_pitch_sign, target_pitch_sign;
FT_Int pitch;
FT_Int flip;
if ( !library )
@ -73,53 +79,29 @@
if ( source == target )
return FT_Err_Ok;
source_pitch_sign = source->pitch < 0 ? -1 : 1;
target_pitch_sign = target->pitch < 0 ? -1 : 1;
if ( !source->buffer )
{
*target = *source;
if ( source_pitch_sign != target_pitch_sign )
target->pitch = -target->pitch;
return FT_Err_Ok;
}
flip = ( source->pitch < 0 && target->pitch > 0 ) ||
( source->pitch > 0 && target->pitch < 0 );
memory = library->memory;
pitch = source->pitch;
FT_FREE( target->buffer );
*target = *source;
if ( flip )
target->pitch = -target->pitch;
if ( !source->buffer )
return FT_Err_Ok;
pitch = source->pitch;
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)pitch * source->rows;
if ( target->buffer )
{
FT_Int target_pitch = target->pitch;
FT_ULong target_size;
if ( target_pitch < 0 )
target_pitch = -target_pitch;
target_size = (FT_ULong)target_pitch * target->rows;
if ( target_size != size )
(void)FT_QREALLOC( target->buffer, target_size, size );
}
else
(void)FT_QALLOC( target->buffer, size );
FT_MEM_QALLOC_MULT( target->buffer, target->rows, pitch );
if ( !error )
{
unsigned char *p;
p = target->buffer;
*target = *source;
target->buffer = p;
if ( source_pitch_sign == target_pitch_sign )
FT_MEM_COPY( target->buffer, source->buffer, size );
else
if ( flip )
{
/* take care of bitmap flow */
FT_UInt i;
@ -137,6 +119,9 @@
t -= pitch;
}
}
else
FT_MEM_COPY( target->buffer, source->buffer,
(FT_Long)source->rows * pitch );
}
return error;
@ -471,7 +456,7 @@
* A gamma of 2.2 is fair to assume. And then, we need to
* undo the premultiplication too.
*
* https://accessibility.kde.org/hsl-adjusted.php
* http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html#SideNotes
*
* We do the computation with integers only, applying a gamma of 2.0.
* We guarantee 32-bit arithmetic to avoid overflow but the resulting
@ -479,9 +464,9 @@
*
*/
l = ( 4732UL /* 0.0722 * 65536 */ * bgra[0] * bgra[0] +
46871UL /* 0.7152 * 65536 */ * bgra[1] * bgra[1] +
13933UL /* 0.2126 * 65536 */ * bgra[2] * bgra[2] ) >> 16;
l = ( 4731UL /* 0.072186 * 65536 */ * bgra[0] * bgra[0] +
46868UL /* 0.715158 * 65536 */ * bgra[1] * bgra[1] +
13937UL /* 0.212656 * 65536 */ * bgra[2] * bgra[2] ) >> 16;
/*
* Final transparency can be determined as follows.
@ -533,39 +518,31 @@
case FT_PIXEL_MODE_LCD_V:
case FT_PIXEL_MODE_BGRA:
{
FT_Int pad, old_target_pitch, target_pitch;
FT_ULong old_size;
FT_Int width = (FT_Int)source->width;
FT_Int neg = ( target->pitch == 0 && source->pitch < 0 ) ||
target->pitch < 0;
old_target_pitch = target->pitch;
if ( old_target_pitch < 0 )
old_target_pitch = -old_target_pitch;
old_size = target->rows * (FT_UInt)old_target_pitch;
FT_Bitmap_Done( library, target );
target->pixel_mode = FT_PIXEL_MODE_GRAY;
target->rows = source->rows;
target->width = source->width;
pad = 0;
if ( alignment > 0 )
if ( alignment )
{
pad = (FT_Int)source->width % alignment;
if ( pad != 0 )
pad = alignment - pad;
FT_Int rem = width % alignment;
if ( rem )
width = alignment > 0 ? width - rem + alignment
: width - rem - alignment;
}
target_pitch = (FT_Int)source->width + pad;
if ( target_pitch > 0 &&
(FT_ULong)target->rows > FT_ULONG_MAX / (FT_ULong)target_pitch )
return FT_THROW( Invalid_Argument );
if ( FT_QREALLOC( target->buffer,
old_size, target->rows * (FT_UInt)target_pitch ) )
if ( FT_QALLOC_MULT( target->buffer, target->rows, width ) )
return error;
target->pitch = target->pitch < 0 ? -target_pitch : target_pitch;
target->pitch = neg ? -width : width;
}
break;
@ -783,6 +760,338 @@
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Blend( FT_Library library,
const FT_Bitmap* source_,
const FT_Vector source_offset_,
FT_Bitmap* target,
FT_Vector *atarget_offset,
FT_Color color )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory;
FT_Bitmap source_bitmap;
const FT_Bitmap* source;
FT_Vector source_offset;
FT_Vector target_offset;
FT_Bool free_source_bitmap = 0;
FT_Bool free_target_bitmap_on_error = 0;
FT_Pos source_llx, source_lly, source_urx, source_ury;
FT_Pos target_llx, target_lly, target_urx, target_ury;
FT_Pos final_llx, final_lly, final_urx, final_ury;
unsigned int final_rows, final_width;
long x, y;
if ( !library || !target || !source_ || !atarget_offset )
return FT_THROW( Invalid_Argument );
memory = library->memory;
if ( !( target->pixel_mode == FT_PIXEL_MODE_NONE ||
( target->pixel_mode == FT_PIXEL_MODE_BGRA &&
target->buffer ) ) )
return FT_THROW( Invalid_Argument );
if ( source_->pixel_mode == FT_PIXEL_MODE_NONE )
return FT_Err_Ok; /* nothing to do */
/* pitches must have the same sign */
if ( target->pixel_mode == FT_PIXEL_MODE_BGRA &&
( source_->pitch ^ target->pitch ) < 0 )
return FT_THROW( Invalid_Argument );
if ( !( source_->width && source_->rows ) )
return FT_Err_Ok; /* nothing to do */
/* assure integer pixel offsets */
source_offset.x = FT_PIX_FLOOR( source_offset_.x );
source_offset.y = FT_PIX_FLOOR( source_offset_.y );
target_offset.x = FT_PIX_FLOOR( atarget_offset->x );
target_offset.y = FT_PIX_FLOOR( atarget_offset->y );
/* get source bitmap dimensions */
source_llx = source_offset.x;
if ( FT_LONG_MIN + (FT_Pos)( source_->rows << 6 ) + 64 > source_offset.y )
{
FT_TRACE5((
"FT_Bitmap_Blend: y coordinate overflow in source bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
source_lly = source_offset.y - ( source_->rows << 6 );
if ( FT_LONG_MAX - (FT_Pos)( source_->width << 6 ) - 64 < source_llx )
{
FT_TRACE5((
"FT_Bitmap_Blend: x coordinate overflow in source bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
source_urx = source_llx + ( source_->width << 6 );
source_ury = source_offset.y;
/* get target bitmap dimensions */
if ( target->width && target->rows )
{
target_llx = target_offset.x;
if ( FT_LONG_MIN + (FT_Pos)( target->rows << 6 ) > target_offset.y )
{
FT_TRACE5((
"FT_Bitmap_Blend: y coordinate overflow in target bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
target_lly = target_offset.y - ( target->rows << 6 );
if ( FT_LONG_MAX - (FT_Pos)( target->width << 6 ) < target_llx )
{
FT_TRACE5((
"FT_Bitmap_Blend: x coordinate overflow in target bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
target_urx = target_llx + ( target->width << 6 );
target_ury = target_offset.y;
}
else
{
target_llx = FT_LONG_MAX;
target_lly = FT_LONG_MAX;
target_urx = FT_LONG_MIN;
target_ury = FT_LONG_MIN;
}
/* compute final bitmap dimensions */
final_llx = FT_MIN( source_llx, target_llx );
final_lly = FT_MIN( source_lly, target_lly );
final_urx = FT_MAX( source_urx, target_urx );
final_ury = FT_MAX( source_ury, target_ury );
final_width = ( final_urx - final_llx ) >> 6;
final_rows = ( final_ury - final_lly ) >> 6;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( "FT_Bitmap_Blend:\n" ));
FT_TRACE5(( " source bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
source_llx / 64, source_lly / 64,
source_urx / 64, source_ury / 64,
source_->width, source_->rows ));
if ( target->width && target->rows )
FT_TRACE5(( " target bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
target_llx / 64, target_lly / 64,
target_urx / 64, target_ury / 64,
target->width, target->rows ));
else
FT_TRACE5(( " target bitmap: empty\n" ));
if ( final_width && final_rows )
FT_TRACE5(( " final bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
final_llx / 64, final_lly / 64,
final_urx / 64, final_ury / 64,
final_width, final_rows ));
else
FT_TRACE5(( " final bitmap: empty\n" ));
#endif /* FT_DEBUG_LEVEL_TRACE */
if ( !( final_width && final_rows ) )
return FT_Err_Ok; /* nothing to do */
/* for blending, set offset vector of final bitmap */
/* temporarily to (0,0) */
source_llx -= final_llx;
source_lly -= final_lly;
if ( target->width && target->rows )
{
target_llx -= final_llx;
target_lly -= final_lly;
}
/* set up target bitmap */
if ( target->pixel_mode == FT_PIXEL_MODE_NONE )
{
/* create new empty bitmap */
target->width = final_width;
target->rows = final_rows;
target->pixel_mode = FT_PIXEL_MODE_BGRA;
target->pitch = (int)final_width * 4;
target->num_grays = 256;
if ( FT_LONG_MAX / target->pitch < (int)target->rows )
{
FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
final_width, final_rows ));
return FT_THROW( Invalid_Argument );
}
if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) )
return error;
free_target_bitmap_on_error = 1;
}
else if ( target->width != final_width ||
target->rows != final_rows )
{
/* adjust old bitmap to enlarged size */
int pitch, new_pitch;
unsigned char* buffer = NULL;
pitch = target->pitch;
if ( pitch < 0 )
pitch = -pitch;
new_pitch = (int)final_width * 4;
if ( FT_LONG_MAX / new_pitch < (int)final_rows )
{
FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
final_width, final_rows ));
return FT_THROW( Invalid_Argument );
}
/* TODO: provide an in-buffer solution for large bitmaps */
/* to avoid allocation of a new buffer */
if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) )
goto Error;
/* copy data to new buffer */
x = target_llx >> 6;
y = target_lly >> 6;
/* the bitmap flow is from top to bottom, */
/* but y is measured from bottom to top */
if ( target->pitch < 0 )
{
/* XXX */
}
else
{
unsigned char* p =
target->buffer;
unsigned char* q =
buffer +
( final_rows - y - target->rows ) * new_pitch +
x * 4;
unsigned char* limit_p =
p + pitch * (int)target->rows;
while ( p < limit_p )
{
FT_MEM_COPY( q, p, pitch );
p += pitch;
q += new_pitch;
}
}
FT_FREE( target->buffer );
target->width = final_width;
target->rows = final_rows;
if ( target->pitch < 0 )
target->pitch = -new_pitch;
else
target->pitch = new_pitch;
target->buffer = buffer;
}
/* adjust source bitmap if necessary */
if ( source_->pixel_mode != FT_PIXEL_MODE_GRAY )
{
FT_Bitmap_Init( &source_bitmap );
error = FT_Bitmap_Convert( library, source_, &source_bitmap, 1 );
if ( error )
goto Error;
source = &source_bitmap;
free_source_bitmap = 1;
}
else
source = source_;
/* do blending; the code below returns pre-multiplied channels, */
/* similar to what FreeType gets from `CBDT' tables */
x = source_llx >> 6;
y = source_lly >> 6;
/* the bitmap flow is from top to bottom, */
/* but y is measured from bottom to top */
if ( target->pitch < 0 )
{
/* XXX */
}
else
{
unsigned char* p =
source->buffer;
unsigned char* q =
target->buffer +
( target->rows - y - source->rows ) * target->pitch +
x * 4;
unsigned char* limit_p =
p + source->pitch * (int)source->rows;
while ( p < limit_p )
{
unsigned char* r = p;
unsigned char* s = q;
unsigned char* limit_r = r + source->width;
while ( r < limit_r )
{
int aa = *r++;
int fa = color.alpha * aa / 255;
int fb = color.blue * fa / 255;
int fg = color.green * fa / 255;
int fr = color.red * fa / 255;
int ba2 = 255 - fa;
int bb = s[0];
int bg = s[1];
int br = s[2];
int ba = s[3];
*s++ = (unsigned char)( bb * ba2 / 255 + fb );
*s++ = (unsigned char)( bg * ba2 / 255 + fg );
*s++ = (unsigned char)( br * ba2 / 255 + fr );
*s++ = (unsigned char)( ba * ba2 / 255 + fa );
}
p += source->pitch;
q += target->pitch;
}
}
atarget_offset->x = final_llx;
atarget_offset->y = final_lly + ( final_rows << 6 );
Error:
if ( error && free_target_bitmap_on_error )
FT_Bitmap_Done( library, target );
if ( free_source_bitmap )
FT_Bitmap_Done( library, &source_bitmap );
return error;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )

View file

@ -1,43 +1,42 @@
/***************************************************************************/
/* */
/* ftcalc.c */
/* */
/* Arithmetic computations (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftcalc.c
*
* Arithmetic computations (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.
*
*/
/*************************************************************************/
/* */
/* Support for 1-complement arithmetic has been totally dropped in this */
/* release. You can still write your own code if you need it. */
/* */
/*************************************************************************/
/**************************************************************************
*
* Support for 1-complement arithmetic has been totally dropped in this
* release. You can still write your own code if you need it.
*
*/
/*************************************************************************/
/* */
/* Implementing basic computation routines. */
/* */
/* FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(), */
/* and FT_FloorFix() are declared in freetype.h. */
/* */
/*************************************************************************/
/**************************************************************************
*
* Implementing basic computation routines.
*
* FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(),
* and FT_FloorFix() are declared in freetype.h.
*
*/
#include <ft2build.h>
#include FT_GLYPH_H
#include FT_TRIGONOMETRY_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include <freetype/ftglyph.h>
#include <freetype/fttrigon.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_MULFIX_ASSEMBLER
@ -46,7 +45,7 @@
/* we need to emulate a 64-bit data type if a real one isn't available */
#ifndef FT_LONG64
#ifndef FT_INT64
typedef struct FT_Int64_
{
@ -55,17 +54,17 @@
} FT_Int64;
#endif /* !FT_LONG64 */
#endif /* !FT_INT64 */
/*************************************************************************/
/* */
/* 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_calc
#define FT_COMPONENT calc
/* transfer sign, leaving a positive number; */
@ -80,7 +79,7 @@
FT_END_STMNT
/* The following three functions are available regardless of whether */
/* FT_LONG64 is defined. */
/* FT_INT64 is defined. */
/* documentation is in freetype.h */
@ -110,7 +109,7 @@
#ifndef FT_MSB
FT_BASE_DEF ( FT_Int )
FT_BASE_DEF( FT_Int )
FT_MSB( FT_UInt32 z )
{
FT_Int shift = 0;
@ -165,7 +164,7 @@
}
#ifdef FT_LONG64
#ifdef FT_INT64
/* documentation is in freetype.h */
@ -273,7 +272,7 @@
}
#else /* !FT_LONG64 */
#else /* !FT_INT64 */
static void
@ -516,10 +515,10 @@
#elif 0
/*
* This code is nonportable. See comment below.
* This code is nonportable. See comment below.
*
* However, on a platform where right-shift of a signed quantity fills
* the leftmost bits by copying the sign bit, it might be faster.
* However, on a platform where right-shift of a signed quantity fills
* the leftmost bits by copying the sign bit, it might be faster.
*/
FT_Long sa, sb;
@ -527,22 +526,22 @@
/*
* This is a clever way of converting a signed number `a' into its
* absolute value (stored back into `a') and its sign. The sign is
* stored in `sa'; 0 means `a' was positive or zero, and -1 means `a'
* was negative. (Similarly for `b' and `sb').
* This is a clever way of converting a signed number `a' into its
* absolute value (stored back into `a') and its sign. The sign is
* stored in `sa'; 0 means `a' was positive or zero, and -1 means `a'
* was negative. (Similarly for `b' and `sb').
*
* Unfortunately, it doesn't work (at least not portably).
* Unfortunately, it doesn't work (at least not portably).
*
* It makes the assumption that right-shift on a negative signed value
* fills the leftmost bits by copying the sign bit. This is wrong.
* According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
* the result of right-shift of a negative signed value is
* implementation-defined. At least one implementation fills the
* leftmost bits with 0s (i.e., it is exactly the same as an unsigned
* right shift). This means that when `a' is negative, `sa' ends up
* with the value 1 rather than -1. After that, everything else goes
* wrong.
* It makes the assumption that right-shift on a negative signed value
* fills the leftmost bits by copying the sign bit. This is wrong.
* According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
* the result of right-shift of a negative signed value is
* implementation-defined. At least one implementation fills the
* leftmost bits with 0s (i.e., it is exactly the same as an unsigned
* right shift). This means that when `a' is negative, `sa' ends up
* with the value 1 rather than -1. After that, everything else goes
* wrong.
*/
sa = ( a_ >> ( sizeof ( a_ ) * 8 - 1 ) );
a = ( a_ ^ sa ) - sa;
@ -652,7 +651,7 @@
}
#endif /* !FT_LONG64 */
#endif /* !FT_INT64 */
/* documentation is in ftglyph.h */
@ -701,8 +700,8 @@
if ( !delta )
return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */
matrix->xy = - FT_DivFix( matrix->xy, delta );
matrix->yx = - FT_DivFix( matrix->yx, delta );
matrix->xy = -FT_DivFix( matrix->xy, delta );
matrix->yx = -FT_DivFix( matrix->yx, delta );
xx = matrix->xx;
yy = matrix->yy;
@ -745,6 +744,76 @@
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Bool )
FT_Matrix_Check( const FT_Matrix* matrix )
{
FT_Matrix m;
FT_Fixed val[4];
FT_Fixed nonzero_minval, maxval;
FT_Fixed temp1, temp2;
FT_UInt i;
if ( !matrix )
return 0;
val[0] = FT_ABS( matrix->xx );
val[1] = FT_ABS( matrix->xy );
val[2] = FT_ABS( matrix->yx );
val[3] = FT_ABS( matrix->yy );
/*
* To avoid overflow, we ensure that each value is not larger than
*
* int(sqrt(2^31 / 4)) = 23170 ;
*
* we also check that no value becomes zero if we have to scale.
*/
maxval = 0;
nonzero_minval = FT_LONG_MAX;
for ( i = 0; i < 4; i++ )
{
if ( val[i] > maxval )
maxval = val[i];
if ( val[i] && val[i] < nonzero_minval )
nonzero_minval = val[i];
}
/* we only handle 32bit values */
if ( maxval > 0x7FFFFFFFL )
return 0;
if ( maxval > 23170 )
{
FT_Fixed scale = FT_DivFix( maxval, 23170 );
if ( !FT_DivFix( nonzero_minval, scale ) )
return 0; /* value range too large */
m.xx = FT_DivFix( matrix->xx, scale );
m.xy = FT_DivFix( matrix->xy, scale );
m.yx = FT_DivFix( matrix->yx, scale );
m.yy = FT_DivFix( matrix->yy, scale );
}
else
m = *matrix;
temp1 = FT_ABS( m.xx * m.yy - m.xy * m.yx );
temp2 = m.xx * m.xx + m.xy * m.xy + m.yx * m.yx + m.yy * m.yy;
if ( temp1 == 0 ||
temp2 / temp1 > 50 )
return 0;
return 1;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( void )
@ -913,9 +982,13 @@
FT_Pos out_x,
FT_Pos out_y )
{
#ifdef FT_LONG64
/* we silently ignore overflow errors since such large values */
/* lead to even more (harmless) rendering errors later on */
FT_Int64 delta = (FT_Int64)in_x * out_y - (FT_Int64)in_y * out_x;
#ifdef FT_INT64
FT_Int64 delta = SUB_INT64( MUL_INT64( in_x, out_y ),
MUL_INT64( in_y, out_x ) );
return ( delta > 0 ) - ( delta < 0 );
@ -925,8 +998,6 @@
FT_Int result;
/* we silently ignore overflow errors, since such large values */
/* lead to even more (harmless) rendering errors later on */
if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L &&
ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L )
{
@ -1014,4 +1085,71 @@
}
FT_BASE_DEF( FT_Int32 )
FT_MulAddFix( FT_Fixed* s,
FT_Int32* f,
FT_UInt count )
{
FT_UInt i;
FT_Int64 temp;
#ifndef FT_INT64
FT_Int64 halfUnit;
#endif
#ifdef FT_INT64
temp = 0;
for ( i = 0; i < count; ++i )
temp += (FT_Int64)s[i] * f[i];
return ( temp + 0x8000 ) >> 16;
#else
temp.hi = 0;
temp.lo = 0;
for ( i = 0; i < count; ++i )
{
FT_Int64 multResult;
FT_Int sign = 1;
FT_UInt32 carry = 0;
FT_UInt32 scalar;
FT_UInt32 factor;
scalar = (FT_UInt32)s[i];
factor = (FT_UInt32)f[i];
FT_MOVE_SIGN( s[i], scalar, sign );
FT_MOVE_SIGN( f[i], factor, sign );
ft_multo64( scalar, factor, &multResult );
if ( sign < 0 )
{
/* Emulated `FT_Int64` negation. */
carry = ( multResult.lo == 0 );
multResult.lo = ~multResult.lo + 1;
multResult.hi = ~multResult.hi + carry;
}
FT_Add64( &temp, &multResult, &temp );
}
/* Round value. */
halfUnit.hi = 0;
halfUnit.lo = 0x8000;
FT_Add64( &temp, &halfUnit, &temp );
return (FT_Int32)( ( (FT_Int32)( temp.hi & 0xFFFF ) << 16 ) |
( temp.lo >> 16 ) );
#endif /* !FT_INT64 */
}
/* END */

View file

@ -1,25 +1,24 @@
/***************************************************************************/
/* */
/* ftcid.c */
/* */
/* FreeType API for accessing CID font information. */
/* */
/* Copyright 2007-2018 by */
/* Derek Clegg and Michael Toftdal. */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftcid.c
*
* FreeType API for accessing CID font information.
*
* Copyright (C) 2007-2023 by
* Derek Clegg and Michael Toftdal.
*
* 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_CID_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_CID_H
#include <freetype/ftcid.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svcid.h>
/* documentation is in ftcid.h */

View file

@ -0,0 +1,156 @@
/****************************************************************************
*
* ftcolor.c
*
* FreeType's glyph color management (body).
*
* Copyright (C) 2018-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/sfnt.h>
#include <freetype/internal/tttypes.h>
#include <freetype/ftcolor.h>
#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
static
const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL };
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Data_Get( FT_Face face,
FT_Palette_Data *apalette_data )
{
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !apalette_data)
return FT_THROW( Invalid_Argument );
if ( FT_IS_SFNT( face ) )
*apalette_data = ( (TT_Face)face )->palette_data;
else
*apalette_data = null_palette_data;
return FT_Err_Ok;
}
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Select( FT_Face face,
FT_UShort palette_index,
FT_Color* *apalette )
{
FT_Error error;
TT_Face ttface;
SFNT_Service sfnt;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !FT_IS_SFNT( face ) )
{
if ( apalette )
*apalette = NULL;
return FT_Err_Ok;
}
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
error = sfnt->set_palette( ttface, palette_index );
if ( error )
return error;
ttface->palette_index = palette_index;
if ( apalette )
*apalette = ttface->palette;
return FT_Err_Ok;
}
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Set_Foreground_Color( FT_Face face,
FT_Color foreground_color )
{
TT_Face ttface;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !FT_IS_SFNT( face ) )
return FT_Err_Ok;
ttface = (TT_Face)face;
ttface->foreground_color = foreground_color;
ttface->have_foreground_color = 1;
return FT_Err_Ok;
}
#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Data_Get( FT_Face face,
FT_Palette_Data *apalette_data )
{
FT_UNUSED( face );
FT_UNUSED( apalette_data );
return FT_THROW( Unimplemented_Feature );
}
FT_EXPORT_DEF( FT_Error )
FT_Palette_Select( FT_Face face,
FT_UShort palette_index,
FT_Color* *apalette )
{
FT_UNUSED( face );
FT_UNUSED( palette_index );
FT_UNUSED( apalette );
return FT_THROW( Unimplemented_Feature );
}
FT_EXPORT_DEF( FT_Error )
FT_Palette_Set_Foreground_Color( FT_Face face,
FT_Color foreground_color )
{
FT_UNUSED( face );
FT_UNUSED( foreground_color );
return FT_THROW( Unimplemented_Feature );
}
#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */
/* END */

View file

@ -1,28 +1,28 @@
/***************************************************************************/
/* */
/* ftdbgmem.c */
/* */
/* Memory debugger (body). */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftdbgmem.c
*
* Memory debugger (body).
*
* 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.
*
*/
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_MEMORY_H
#include FT_SYSTEM_H
#include FT_ERRORS_H
#include FT_TYPES_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/ftsystem.h>
#include <freetype/fterrors.h>
#include <freetype/fttypes.h>
#ifdef FT_DEBUG_MEMORY
@ -35,8 +35,8 @@
#include FT_CONFIG_STANDARD_LIBRARY_H
FT_BASE_DEF( const char* ) _ft_debug_file = NULL;
FT_BASE_DEF( long ) _ft_debug_lineno = 0;
FT_BASE_DEF( const char* ) ft_debug_file_ = NULL;
FT_BASE_DEF( long ) ft_debug_lineno_ = 0;
extern void
FT_DumpMemory( FT_Memory memory );
@ -50,9 +50,9 @@
#define FT_MEM_VAL( addr ) ( (FT_PtrDist)(FT_Pointer)( addr ) )
/*
* This structure holds statistics for a single allocation/release
* site. This is useful to know where memory operations happen the
* most.
* This structure holds statistics for a single allocation/release
* site. This is useful to know where memory operations happen the
* most.
*/
typedef struct FT_MemSourceRec_
{
@ -76,17 +76,17 @@
/*
* We don't need a resizable array for the memory sources because
* their number is pretty limited within FreeType.
* We don't need a resizable array for the memory sources because
* their number is pretty limited within FreeType.
*/
#define FT_MEM_SOURCE_BUCKETS 128
/*
* This structure holds information related to a single allocated
* memory block. If KEEPALIVE is defined, blocks that are freed by
* FreeType are never released to the system. Instead, their `size'
* field is set to `-size'. This is mainly useful to detect double
* frees, at the price of a large memory footprint during execution.
* This structure holds information related to a single allocated
* memory block. If KEEPALIVE is defined, blocks that are freed by
* FreeType are never released to the system. Instead, their `size'
* field is set to `-size'. This is mainly useful to detect double
* frees, at the price of a large memory footprint during execution.
*/
typedef struct FT_MemNodeRec_
{
@ -106,8 +106,8 @@
/*
* The global structure, containing compound statistics and all hash
* tables.
* The global structure, containing compound statistics and all hash
* tables.
*/
typedef struct FT_MemTableRec_
{
@ -146,8 +146,8 @@
/*
* Prime numbers are ugly to handle. It would be better to implement
* L-Hashing, which is 10% faster and doesn't require divisions.
* Prime numbers are ugly to handle. It would be better to implement
* L-Hashing, which is 10% faster and doesn't require divisions.
*/
static const FT_Int ft_mem_primes[] =
{
@ -302,46 +302,6 @@
}
static FT_MemTable
ft_mem_table_new( FT_Memory memory )
{
FT_MemTable table;
table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
if ( !table )
goto Exit;
FT_ZERO( table );
table->size = FT_MEM_SIZE_MIN;
table->nodes = 0;
table->memory = memory;
table->memory_user = memory->user;
table->alloc = memory->alloc;
table->realloc = memory->realloc;
table->free = memory->free;
table->buckets = (FT_MemNode *)
memory->alloc(
memory,
table->size * (FT_Long)sizeof ( FT_MemNode ) );
if ( table->buckets )
FT_ARRAY_ZERO( table->buckets, table->size );
else
{
memory->free( memory, table );
table = NULL;
}
Exit:
return table;
}
static void
ft_mem_table_destroy( FT_MemTable table )
{
@ -350,8 +310,6 @@
FT_Long leaks = 0;
FT_DumpMemory( table->memory );
/* remove all blocks from the table, revealing leaked ones */
for ( i = 0; i < table->size; i++ )
{
@ -413,8 +371,6 @@
printf( "FreeType: maximum memory footprint = %ld\n",
table->alloc_max );
ft_mem_table_free( table, table );
if ( leak_count > 0 )
ft_mem_debug_panic(
"FreeType: %ld bytes of memory leaked in %ld blocks\n",
@ -459,8 +415,8 @@
/* cast to FT_PtrDist first since void* can be larger */
/* than FT_UInt32 and GCC 4.1.1 emits a warning */
hash = (FT_UInt32)(FT_PtrDist)(void*)_ft_debug_file +
(FT_UInt32)( 5 * _ft_debug_lineno );
hash = (FT_UInt32)(FT_PtrDist)(void*)ft_debug_file_ +
(FT_UInt32)( 5 * ft_debug_lineno_ );
pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS];
for (;;)
@ -469,8 +425,8 @@
if ( !node )
break;
if ( node->file_name == _ft_debug_file &&
node->line_no == _ft_debug_lineno )
if ( node->file_name == ft_debug_file_ &&
node->line_no == ft_debug_lineno_ )
goto Exit;
pnode = &node->link;
@ -481,8 +437,8 @@
ft_mem_debug_panic(
"not enough memory to perform memory debugging\n" );
node->file_name = _ft_debug_file;
node->line_no = _ft_debug_lineno;
node->file_name = ft_debug_file_;
node->line_no = ft_debug_lineno_;
node->cur_blocks = 0;
node->max_blocks = 0;
@ -539,7 +495,7 @@
"org=%s:%d new=%s:%d\n",
node->address, node->size,
FT_FILENAME( node->source->file_name ), node->source->line_no,
FT_FILENAME( _ft_debug_file ), _ft_debug_lineno );
FT_FILENAME( ft_debug_file_ ), ft_debug_lineno_ );
}
}
@ -621,10 +577,12 @@
if ( node->size < 0 )
ft_mem_debug_panic(
"freeing memory block at %p more than once at (%s:%ld)\n"
"block allocated at (%s:%ld) and released at (%s:%ld)",
"freeing memory block at %p more than once\n"
" at (%s:%ld)!\n"
" Block was allocated at (%s:%ld)\n"
" and released at (%s:%ld).",
address,
FT_FILENAME( _ft_debug_file ), _ft_debug_lineno,
FT_FILENAME( ft_debug_file_ ), ft_debug_lineno_,
FT_FILENAME( node->source->file_name ), node->source->line_no,
FT_FILENAME( node->free_file_name ), node->free_line_no );
@ -646,8 +604,8 @@
/* we simply invert the node's size to indicate that the node */
/* was freed. */
node->size = -node->size;
node->free_file_name = _ft_debug_file;
node->free_line_no = _ft_debug_lineno;
node->free_file_name = ft_debug_file_;
node->free_line_no = ft_debug_lineno_;
}
else
{
@ -669,7 +627,7 @@
ft_mem_debug_panic(
"trying to free unknown block at %p in (%s:%ld)\n",
address,
FT_FILENAME( _ft_debug_file ), _ft_debug_lineno );
FT_FILENAME( ft_debug_file_ ), ft_debug_lineno_ );
}
}
@ -703,8 +661,8 @@
table->alloc_count++;
}
_ft_debug_file = "<unknown>";
_ft_debug_lineno = 0;
ft_debug_file_ = "<unknown>";
ft_debug_lineno_ = 0;
return (FT_Pointer)block;
}
@ -719,8 +677,8 @@
if ( !block )
ft_mem_debug_panic( "trying to free NULL in (%s:%ld)",
FT_FILENAME( _ft_debug_file ),
_ft_debug_lineno );
FT_FILENAME( ft_debug_file_ ),
ft_debug_lineno_ );
ft_mem_table_remove( table, (FT_Byte*)block, 0 );
@ -729,8 +687,8 @@
table->alloc_count--;
_ft_debug_file = "<unknown>";
_ft_debug_lineno = 0;
ft_debug_file_ = "<unknown>";
ft_debug_lineno_ = 0;
}
@ -745,8 +703,8 @@
FT_Pointer new_block;
FT_Long delta;
const char* file_name = FT_FILENAME( _ft_debug_file );
FT_Long line_no = _ft_debug_lineno;
const char* file_name = FT_FILENAME( ft_debug_file_ );
FT_Long line_no = ft_debug_lineno_;
/* unlikely, but possible */
@ -809,8 +767,8 @@
ft_mem_table_remove( table, (FT_Byte*)block, delta );
_ft_debug_file = "<unknown>";
_ft_debug_lineno = 0;
ft_debug_file_ = "<unknown>";
ft_debug_lineno_ = 0;
if ( !table->keep_alive )
ft_mem_table_free( table, block );
@ -819,17 +777,30 @@
}
extern FT_Int
extern void
ft_mem_debug_init( FT_Memory memory )
{
FT_MemTable table;
FT_Int result = 0;
if ( ft_getenv( "FT2_DEBUG_MEMORY" ) )
if ( !ft_getenv( "FT2_DEBUG_MEMORY" ) )
return;
table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
if ( table )
{
table = ft_mem_table_new( memory );
if ( table )
FT_ZERO( table );
table->memory = memory;
table->memory_user = memory->user;
table->alloc = memory->alloc;
table->realloc = memory->realloc;
table->free = memory->free;
ft_mem_table_resize( table );
if ( table->size )
{
const char* p;
@ -874,33 +845,36 @@
if ( keep_alive > 0 )
table->keep_alive = 1;
}
result = 1;
}
else
memory->free( memory, table );
}
return result;
}
extern void
ft_mem_debug_done( FT_Memory memory )
{
FT_MemTable table = (FT_MemTable)memory->user;
if ( table )
if ( memory->free == ft_mem_debug_free )
{
FT_MemTable table = (FT_MemTable)memory->user;
FT_DumpMemory( memory );
ft_mem_table_destroy( table );
memory->free = table->free;
memory->realloc = table->realloc;
memory->alloc = table->alloc;
memory->user = table->memory_user;
ft_mem_table_destroy( table );
memory->user = NULL;
memory->free( memory, table );
}
}
static int
FT_COMPARE_DEF( int )
ft_mem_source_compare( const void* p1,
const void* p2 )
{
@ -920,11 +894,9 @@
extern void
FT_DumpMemory( FT_Memory memory )
{
FT_MemTable table = (FT_MemTable)memory->user;
if ( table )
if ( memory->free == ft_mem_debug_free )
{
FT_MemTable table = (FT_MemTable)memory->user;
FT_MemSource* bucket = table->sources;
FT_MemSource* limit = bucket + FT_MEM_SOURCE_BUCKETS;
FT_MemSource* sources;

View file

@ -1,49 +1,94 @@
/***************************************************************************/
/* */
/* ftdebug.c */
/* */
/* Debugging and logging component (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftdebug.c
*
* Debugging and logging component (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.
*
*/
/*************************************************************************/
/* */
/* This component contains various macros and functions used to ease the */
/* debugging of the FreeType engine. Its main purpose is in assertion */
/* checking, tracing, and error detection. */
/* */
/* There are now three debugging modes: */
/* */
/* - trace mode */
/* */
/* Error and trace messages are sent to the log file (which can be the */
/* standard error output). */
/* */
/* - error mode */
/* */
/* Only error messages are generated. */
/* */
/* - release mode: */
/* */
/* No error message is sent or generated. The code is free from any */
/* debugging parts. */
/* */
/*************************************************************************/
/**************************************************************************
*
* This component contains various macros and functions used to ease the
* debugging of the FreeType engine. Its main purpose is in assertion
* checking, tracing, and error detection.
*
* There are now three debugging modes:
*
* - trace mode
*
* Error and trace messages are sent to the log file (which can be the
* standard error output).
*
* - error mode
*
* Only error messages are generated.
*
* - release mode:
*
* No error message is sent or generated. The code is free from any
* debugging parts.
*
*/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_DEBUG_H
#include <freetype/freetype.h>
#include <freetype/ftlogging.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_DEBUG_LOGGING
/**************************************************************************
*
* Variables used to control logging.
*
* 1. `ft_default_trace_level` stores the value of trace levels, which are
* provided to FreeType using the `FT2_DEBUG` environment variable.
*
* 2. `ft_fileptr` stores the `FILE*` handle.
*
* 3. `ft_component` is a string that holds the name of `FT_COMPONENT`.
*
* 4. The flag `ft_component_flag` prints the name of `FT_COMPONENT` along
* with the actual log message if set to true.
*
* 5. The flag `ft_timestamp_flag` prints time along with the actual log
* message if set to ture.
*
* 6. `ft_have_newline_char` is used to differentiate between a log
* message with and without a trailing newline character.
*
* 7. `ft_custom_trace_level` stores the custom trace level value, which
* is provided by the user at run-time.
*
* We use `static` to avoid 'unused variable' warnings.
*
*/
static const char* ft_default_trace_level = NULL;
static FILE* ft_fileptr = NULL;
static const char* ft_component = NULL;
static FT_Bool ft_component_flag = FALSE;
static FT_Bool ft_timestamp_flag = FALSE;
static FT_Bool ft_have_newline_char = TRUE;
static const char* ft_custom_trace_level = NULL;
/* declared in ftdebug.h */
dlg_handler ft_default_log_handler = NULL;
FT_Custom_Log_Handler custom_output_handler = NULL;
#endif /* FT_DEBUG_LOGGING */
#ifdef FT_DEBUG_LEVEL_ERROR
@ -87,9 +132,19 @@
int line,
const char* file )
{
#if 0
/* activating the code in this block makes FreeType very chatty */
fprintf( stderr,
"%s:%d: error 0x%02x: %s\n",
file,
line,
error,
FT_Error_String( error ) );
#else
FT_UNUSED( error );
FT_UNUSED( line );
FT_UNUSED( file );
#endif
return 0;
}
@ -97,19 +152,25 @@
#endif /* FT_DEBUG_LEVEL_ERROR */
#ifdef FT_DEBUG_LEVEL_TRACE
/* array of trace levels, initialized to 0 */
int ft_trace_levels[trace_count];
/* array of trace levels, initialized to 0; */
/* this gets adjusted at run-time */
static int ft_trace_levels_enabled[trace_count];
/* array of trace levels, always initialized to 0 */
static int ft_trace_levels_disabled[trace_count];
/* a pointer to either `ft_trace_levels_enabled' */
/* or `ft_trace_levels_disabled' */
int* ft_trace_levels;
/* define array of trace toggle names */
#define FT_TRACE_DEF( x ) #x ,
static const char* ft_trace_toggles[trace_count + 1] =
{
#include FT_INTERNAL_TRACE_H
#include <freetype/internal/fttrace.h>
NULL
};
@ -140,30 +201,57 @@
}
/*************************************************************************/
/* */
/* Initialize the tracing sub-system. This is done by retrieving the */
/* value of the `FT2_DEBUG' environment variable. It must be a list of */
/* toggles, separated by spaces, `;', or `,'. Example: */
/* */
/* export FT2_DEBUG="any:3 memory:7 stream:5" */
/* */
/* This requests that all levels be set to 3, except the trace level for */
/* the memory and stream components which are set to 7 and 5, */
/* respectively. */
/* */
/* See the file `include/freetype/internal/fttrace.h' for details of */
/* the available toggle names. */
/* */
/* The level must be between 0 and 7; 0 means quiet (except for serious */
/* runtime errors), and 7 means _very_ verbose. */
/* */
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Trace_Disable( void )
{
ft_trace_levels = ft_trace_levels_disabled;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Trace_Enable( void )
{
ft_trace_levels = ft_trace_levels_enabled;
}
/**************************************************************************
*
* Initialize the tracing sub-system. This is done by retrieving the
* value of the `FT2_DEBUG' environment variable. It must be a list of
* toggles, separated by spaces, `;', or `,'. Example:
*
* export FT2_DEBUG="any:3 memory:7 stream:5"
*
* This requests that all levels be set to 3, except the trace level for
* the memory and stream components which are set to 7 and 5,
* respectively.
*
* See the file `include/freetype/internal/fttrace.h' for details of
* the available toggle names.
*
* The level must be between 0 and 7; 0 means quiet (except for serious
* runtime errors), and 7 means _very_ verbose.
*/
FT_BASE_DEF( void )
ft_debug_init( void )
{
const char* ft2_debug = ft_getenv( "FT2_DEBUG" );
const char* ft2_debug = NULL;
#ifdef FT_DEBUG_LOGGING
if ( ft_custom_trace_level != NULL )
ft2_debug = ft_custom_trace_level;
else
ft2_debug = ft_default_trace_level;
#else
ft2_debug = ft_getenv( "FT2_DEBUG" );
#endif
if ( ft2_debug )
{
const char* p = ft2_debug;
@ -176,6 +264,49 @@
if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
continue;
#ifdef FT_DEBUG_LOGGING
/* check extra arguments for logging */
if ( *p == '-' )
{
const char* r = ++p;
if ( *r == 'v' )
{
const char* s = ++r;
ft_component_flag = TRUE;
if ( *s == 't' )
{
ft_timestamp_flag = TRUE;
p++;
}
p++;
}
else if ( *r == 't' )
{
const char* s = ++r;
ft_timestamp_flag = TRUE;
if ( *s == 'v' )
{
ft_component_flag = TRUE;
p++;
}
p++;
}
}
#endif /* FT_DEBUG_LOGGING */
/* read toggle name, followed by ':' */
q = p;
while ( *p && *p != ':' )
@ -223,14 +354,16 @@
{
/* special case for `any' */
for ( n = 0; n < trace_count; n++ )
ft_trace_levels[n] = level;
ft_trace_levels_enabled[n] = level;
}
else
ft_trace_levels[found] = level;
ft_trace_levels_enabled[found] = level;
}
}
}
}
ft_trace_levels = ft_trace_levels_enabled;
}
@ -260,7 +393,252 @@
}
FT_BASE_DEF( void )
FT_Trace_Disable( void )
{
/* nothing */
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Trace_Enable( void )
{
/* nothing */
}
#endif /* !FT_DEBUG_LEVEL_TRACE */
#ifdef FT_DEBUG_LOGGING
/**************************************************************************
*
* Initialize and de-initialize 'dlg' library.
*
*/
FT_BASE_DEF( void )
ft_logging_init( void )
{
ft_default_log_handler = ft_log_handler;
ft_default_trace_level = ft_getenv( "FT2_DEBUG" );
if ( ft_getenv( "FT_LOGGING_FILE" ) )
ft_fileptr = ft_fopen( ft_getenv( "FT_LOGGING_FILE" ), "w" );
else
ft_fileptr = stderr;
ft_debug_init();
/* Set the default output handler for 'dlg'. */
dlg_set_handler( ft_default_log_handler, NULL );
}
FT_BASE_DEF( void )
ft_logging_deinit( void )
{
if ( ft_fileptr != stderr )
ft_fclose( ft_fileptr );
}
/**************************************************************************
*
* An output log handler for FreeType.
*
*/
FT_BASE_DEF( void )
ft_log_handler( const struct dlg_origin* origin,
const char* string,
void* data )
{
char features_buf[128];
char* bufp = features_buf;
FT_UNUSED( data );
if ( ft_have_newline_char )
{
const char* features = NULL;
size_t features_length = 0;
#define FEATURES_TIMESTAMP "[%h:%m] "
#define FEATURES_COMPONENT "[%t] "
#define FEATURES_TIMESTAMP_COMPONENT "[%h:%m %t] "
if ( ft_timestamp_flag && ft_component_flag )
{
features = FEATURES_TIMESTAMP_COMPONENT;
features_length = sizeof ( FEATURES_TIMESTAMP_COMPONENT );
}
else if ( ft_timestamp_flag )
{
features = FEATURES_TIMESTAMP;
features_length = sizeof ( FEATURES_TIMESTAMP );
}
else if ( ft_component_flag )
{
features = FEATURES_COMPONENT;
features_length = sizeof ( FEATURES_COMPONENT );
}
if ( ft_component_flag || ft_timestamp_flag )
{
ft_strncpy( features_buf, features, features_length );
bufp += features_length - 1;
}
if ( ft_component_flag )
{
size_t tag_length = ft_strlen( *origin->tags );
size_t i;
/* To vertically align tracing messages we compensate the */
/* different FT_COMPONENT string lengths by inserting an */
/* appropriate amount of space characters. */
for ( i = 0;
i < FT_MAX_TRACE_LEVEL_LENGTH - tag_length;
i++ )
*bufp++ = ' ';
}
}
/* Finally add the format string for the tracing message. */
*bufp++ = '%';
*bufp++ = 'c';
*bufp = '\0';
dlg_generic_outputf_stream( ft_fileptr,
(const char*)features_buf,
origin,
string,
dlg_default_output_styles,
true );
if ( ft_strrchr( string, '\n' ) )
ft_have_newline_char = TRUE;
else
ft_have_newline_char = FALSE;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
ft_add_tag( const char* tag )
{
ft_component = tag;
dlg_add_tag( tag, NULL );
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
ft_remove_tag( const char* tag )
{
dlg_remove_tag( tag, NULL );
}
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Trace_Set_Level( const char* level )
{
ft_component_flag = FALSE;
ft_timestamp_flag = FALSE;
ft_custom_trace_level = level;
ft_debug_init();
}
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Trace_Set_Default_Level( void )
{
ft_component_flag = FALSE;
ft_timestamp_flag = FALSE;
ft_custom_trace_level = NULL;
ft_debug_init();
}
/**************************************************************************
*
* Functions to handle a custom log handler.
*
*/
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
{
custom_output_handler = handler;
}
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Set_Default_Log_Handler( void )
{
custom_output_handler = NULL;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Logging_Callback( const char* fmt,
... )
{
va_list ap;
va_start( ap, fmt );
custom_output_handler( ft_component, fmt, ap );
va_end( ap );
}
#else /* !FT_DEBUG_LOGGING */
FT_EXPORT_DEF( void )
FT_Trace_Set_Level( const char* level )
{
FT_UNUSED( level );
}
FT_EXPORT_DEF( void )
FT_Trace_Set_Default_Level( void )
{
/* nothing */
}
FT_EXPORT_DEF( void )
FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
{
FT_UNUSED( handler );
}
FT_EXPORT_DEF( void )
FT_Set_Default_Log_Handler( void )
{
/* nothing */
}
#endif /* !FT_DEBUG_LOGGING */
/* END */

View file

@ -0,0 +1,45 @@
/****************************************************************************
*
* fterrors.c
*
* FreeType API for error code handling.
*
* Copyright (C) 2018-2023 by
* Armin Hasitzka, 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/fterrors.h>
/* documentation is in fterrors.h */
FT_EXPORT_DEF( const char* )
FT_Error_String( FT_Error error_code )
{
if ( error_code < 0 ||
error_code >= FT_ERR_CAT( FT_ERR_PREFIX, Max ) )
return NULL;
#if defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || \
defined( FT_DEBUG_LEVEL_ERROR )
#undef FTERRORS_H_
#define FT_ERROR_START_LIST switch ( FT_ERROR_BASE( error_code ) ) {
#define FT_ERRORDEF( e, v, s ) case v: return s;
#define FT_ERROR_END_LIST }
#include <freetype/fterrors.h>
#endif /* defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || ... */
return NULL;
}

View file

@ -1,25 +1,24 @@
/***************************************************************************/
/* */
/* ftfntfmt.c */
/* */
/* FreeType utility file for font formats (body). */
/* */
/* Copyright 2002-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftfntfmt.c
*
* FreeType utility file for font formats (body).
*
* Copyright (C) 2002-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_FONT_FORMATS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_FONT_FORMAT_H
#include <freetype/ftfntfmt.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svfntfmt.h>
/* documentation is in ftfntfmt.h */

View file

@ -1,25 +1,24 @@
/***************************************************************************/
/* */
/* ftfstype.c */
/* */
/* FreeType utility file to access FSType data (body). */
/* */
/* Copyright 2008-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftfstype.c
*
* FreeType utility file to access FSType data (body).
*
* Copyright (C) 2008-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_TYPE1_TABLES_H
#include FT_TRUETYPE_TABLES_H
#include FT_INTERNAL_SERVICE_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include <freetype/t1tables.h>
#include <freetype/tttables.h>
#include <freetype/internal/ftserv.h>
#include <freetype/internal/services/svpsinfo.h>
/* documentation is in freetype.h */

View file

@ -1,24 +1,23 @@
/***************************************************************************/
/* */
/* ftgasp.c */
/* */
/* Access of TrueType's `gasp' table (body). */
/* */
/* Copyright 2007-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftgasp.c
*
* Access of TrueType's `gasp' table (body).
*
* Copyright (C) 2007-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_GASP_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include <freetype/ftgasp.h>
#include <freetype/internal/tttypes.h>
FT_EXPORT_DEF( FT_Int )

View file

@ -1,29 +1,28 @@
/***************************************************************************/
/* */
/* ftgloadr.c */
/* */
/* The FreeType glyph loader (body). */
/* */
/* Copyright 2002-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftgloadr.c
*
* The FreeType glyph loader (body).
*
* Copyright (C) 2002-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 FT_INTERNAL_GLYPH_LOADER_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_OBJECTS_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftgloadr.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/internal/ftobjs.h>
#undef FT_COMPONENT
#define FT_COMPONENT trace_gloader
#define FT_COMPONENT gloader
/*************************************************************************/
@ -38,31 +37,31 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* The glyph loader is a simple object which is used to load a set of */
/* glyphs easily. It is critical for the correct loading of composites. */
/* */
/* Ideally, one can see it as a stack of abstract `glyph' objects. */
/* */
/* loader.base Is really the bottom of the stack. It describes a */
/* single glyph image made of the juxtaposition of */
/* several glyphs (those `in the stack'). */
/* */
/* loader.current Describes the top of the stack, on which a new */
/* glyph can be loaded. */
/* */
/* Rewind Clears the stack. */
/* Prepare Set up `loader.current' for addition of a new glyph */
/* image. */
/* Add Add the `current' glyph image to the `base' one, */
/* and prepare for another one. */
/* */
/* The glyph loader is now a base object. Each driver used to */
/* re-implement it in one way or the other, which wasted code and */
/* energy. */
/* */
/*************************************************************************/
/**************************************************************************
*
* The glyph loader is a simple object which is used to load a set of
* glyphs easily. It is critical for the correct loading of composites.
*
* Ideally, one can see it as a stack of abstract `glyph' objects.
*
* loader.base Is really the bottom of the stack. It describes a
* single glyph image made of the juxtaposition of
* several glyphs (those `in the stack').
*
* loader.current Describes the top of the stack, on which a new
* glyph can be loaded.
*
* Rewind Clears the stack.
* Prepare Set up `loader.current' for addition of a new glyph
* image.
* Add Add the `current' glyph image to the `base' one,
* and prepare for another one.
*
* The glyph loader is now a base object. Each driver used to
* re-implement it in one way or the other, which wasted code and
* energy.
*
*/
/* create a new glyph loader */
@ -93,18 +92,19 @@
base->outline.n_points = 0;
base->outline.n_contours = 0;
base->outline.flags = 0;
base->num_subglyphs = 0;
*current = *base;
}
/* reset the glyph loader, frees all allocated tables */
/* and starts from zero */
/* reset glyph loader, free all allocated tables, */
/* and start from zero */
FT_BASE_DEF( void )
FT_GlyphLoader_Reset( FT_GlyphLoader loader )
{
FT_Memory memory = loader->memory;
FT_Memory memory = loader->memory;
FT_FREE( loader->base.outline.points );
@ -129,7 +129,7 @@
{
if ( loader )
{
FT_Memory memory = loader->memory;
FT_Memory memory = loader->memory;
FT_GlyphLoader_Reset( loader );
@ -146,9 +146,9 @@
FT_Outline* current = &loader->current.outline;
current->points = base->points + base->n_points;
current->tags = base->tags + base->n_points;
current->contours = base->contours + base->n_contours;
current->points = FT_OFFSET( base->points, base->n_points );
current->tags = FT_OFFSET( base->tags, base->n_points );
current->contours = FT_OFFSET( base->contours, base->n_contours );
/* handle extra points table - if any */
if ( loader->use_extra )
@ -169,6 +169,10 @@
FT_Memory memory = loader->memory;
if ( loader->max_points == 0 ||
loader->base.extra_points != NULL )
return FT_Err_Ok;
if ( !FT_NEW_ARRAY( loader->base.extra_points, 2 * loader->max_points ) )
{
loader->use_extra = 1;
@ -189,7 +193,7 @@
FT_GlyphLoad current = &loader->current;
current->subglyphs = base->subglyphs + base->num_subglyphs;
current->subglyphs = FT_OFFSET( base->subglyphs, base->num_subglyphs );
}
@ -208,9 +212,13 @@
FT_Outline* current = &loader->current.outline;
FT_Bool adjust = 0;
FT_UInt new_max, old_max;
FT_UInt new_max, old_max, min_new_max;
error = FT_GlyphLoader_CreateExtra( loader );
if ( error )
goto Exit;
/* check points & tags */
new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points +
n_points;
@ -218,10 +226,18 @@
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 8 );
if ( new_max > FT_OUTLINE_POINTS_MAX )
return FT_THROW( Array_Too_Large );
{
error = FT_THROW( Array_Too_Large );
goto Exit;
}
min_new_max = old_max + ( old_max >> 1 );
if ( new_max < min_new_max )
new_max = min_new_max;
new_max = FT_PAD_CEIL( new_max, 8 );
if ( new_max > FT_OUTLINE_POINTS_MAX )
new_max = FT_OUTLINE_POINTS_MAX;
if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
@ -244,16 +260,28 @@
loader->max_points = new_max;
}
error = FT_GlyphLoader_CreateExtra( loader );
if ( error )
goto Exit;
/* check contours */
old_max = loader->max_contours;
new_max = (FT_UInt)base->n_contours + (FT_UInt)current->n_contours +
n_contours;
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 4 );
if ( new_max > FT_OUTLINE_CONTOURS_MAX )
return FT_THROW( Array_Too_Large );
{
error = FT_THROW( Array_Too_Large );
goto Exit;
}
min_new_max = old_max + ( old_max >> 1 );
if ( new_max < min_new_max )
new_max = min_new_max;
new_max = FT_PAD_CEIL( new_max, 4 );
if ( new_max > FT_OUTLINE_CONTOURS_MAX )
new_max = FT_OUTLINE_CONTOURS_MAX;
if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
goto Exit;
@ -361,46 +389,4 @@
}
FT_BASE_DEF( FT_Error )
FT_GlyphLoader_CopyPoints( FT_GlyphLoader target,
FT_GlyphLoader source )
{
FT_Error error;
FT_UInt num_points = (FT_UInt)source->base.outline.n_points;
FT_UInt num_contours = (FT_UInt)source->base.outline.n_contours;
error = FT_GlyphLoader_CheckPoints( target, num_points, num_contours );
if ( !error )
{
FT_Outline* out = &target->base.outline;
FT_Outline* in = &source->base.outline;
FT_ARRAY_COPY( out->points, in->points,
num_points );
FT_ARRAY_COPY( out->tags, in->tags,
num_points );
FT_ARRAY_COPY( out->contours, in->contours,
num_contours );
/* do we need to copy the extra points? */
if ( target->use_extra && source->use_extra )
{
FT_ARRAY_COPY( target->base.extra_points, source->base.extra_points,
num_points );
FT_ARRAY_COPY( target->base.extra_points2, source->base.extra_points2,
num_points );
}
out->n_points = (short)num_points;
out->n_contours = (short)num_contours;
FT_GlyphLoader_Adjust_Points( target );
}
return error;
}
/* END */

View file

@ -1,51 +1,52 @@
/***************************************************************************/
/* */
/* ftglyph.c */
/* */
/* FreeType convenience functions to handle glyphs (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftglyph.c
*
* FreeType convenience functions to handle glyphs (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.
*
*/
/*************************************************************************/
/* */
/* This file contains the definition of several convenience functions */
/* that can be used by client applications to easily retrieve glyph */
/* bitmaps and outlines from a given face. */
/* */
/* These functions should be optional if you are writing a font server */
/* or text layout engine on top of FreeType. However, they are pretty */
/* handy for many other simple uses of the library. */
/* */
/*************************************************************************/
/**************************************************************************
*
* This file contains the definition of several convenience functions
* that can be used by client applications to easily retrieve glyph
* bitmaps and outlines from a given face.
*
* These functions should be optional if you are writing a font server
* or text layout engine on top of FreeType. However, they are pretty
* handy for many other simple uses of the library.
*
*/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include <freetype/internal/ftdebug.h>
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
#include FT_INTERNAL_OBJECTS_H
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
#include <freetype/ftbitmap.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/otsvg.h>
#include "basepic.h"
#include "ftbase.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_glyph
#define FT_COMPONENT glyph
/*************************************************************************/
@ -77,7 +78,7 @@
/* do lazy copying whenever possible */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
glyph->bitmap = slot->bitmap;
glyph->bitmap = slot->bitmap;
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
else
@ -277,6 +278,240 @@
)
#ifdef FT_CONFIG_OPTION_SVG
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** FT_SvgGlyph support ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
FT_CALLBACK_DEF( FT_Error )
ft_svg_glyph_init( FT_Glyph svg_glyph,
FT_GlyphSlot slot )
{
FT_ULong doc_length;
FT_SVG_Document document;
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_GLYPH( glyph )->library->memory;
if ( slot->format != FT_GLYPH_FORMAT_SVG )
{
error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
if ( slot->other == NULL )
{
error = FT_THROW( Invalid_Slot_Handle );
goto Exit;
}
document = (FT_SVG_Document)slot->other;
if ( document->svg_document_length == 0 )
{
error = FT_THROW( Invalid_Slot_Handle );
goto Exit;
}
/* allocate a new document */
doc_length = document->svg_document_length;
if ( FT_QALLOC( glyph->svg_document, doc_length ) )
goto Exit;
glyph->svg_document_length = doc_length;
glyph->glyph_index = slot->glyph_index;
glyph->metrics = document->metrics;
glyph->units_per_EM = document->units_per_EM;
glyph->start_glyph_id = document->start_glyph_id;
glyph->end_glyph_id = document->end_glyph_id;
glyph->transform = document->transform;
glyph->delta = document->delta;
/* copy the document into glyph */
FT_MEM_COPY( glyph->svg_document, document->svg_document, doc_length );
Exit:
return error;
}
FT_CALLBACK_DEF( void )
ft_svg_glyph_done( FT_Glyph svg_glyph )
{
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Memory memory = svg_glyph->library->memory;
/* just free the memory */
FT_FREE( glyph->svg_document );
}
FT_CALLBACK_DEF( FT_Error )
ft_svg_glyph_copy( FT_Glyph svg_source,
FT_Glyph svg_target )
{
FT_SvgGlyph source = (FT_SvgGlyph)svg_source;
FT_SvgGlyph target = (FT_SvgGlyph)svg_target;
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_GLYPH( source )->library->memory;
if ( svg_source->format != FT_GLYPH_FORMAT_SVG )
{
error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
if ( source->svg_document_length == 0 )
{
error = FT_THROW( Invalid_Slot_Handle );
goto Exit;
}
target->glyph_index = source->glyph_index;
target->svg_document_length = source->svg_document_length;
target->metrics = source->metrics;
target->units_per_EM = source->units_per_EM;
target->start_glyph_id = source->start_glyph_id;
target->end_glyph_id = source->end_glyph_id;
target->transform = source->transform;
target->delta = source->delta;
/* allocate space for the SVG document */
if ( FT_QALLOC( target->svg_document, target->svg_document_length ) )
goto Exit;
/* copy the document */
FT_MEM_COPY( target->svg_document,
source->svg_document,
target->svg_document_length );
Exit:
return error;
}
FT_CALLBACK_DEF( void )
ft_svg_glyph_transform( FT_Glyph svg_glyph,
const FT_Matrix* _matrix,
const FT_Vector* _delta )
{
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Matrix* matrix = (FT_Matrix*)_matrix;
FT_Vector* delta = (FT_Vector*)_delta;
FT_Matrix tmp_matrix;
FT_Vector tmp_delta;
FT_Matrix a, b;
FT_Pos x, y;
if ( !matrix )
{
tmp_matrix.xx = 0x10000;
tmp_matrix.xy = 0;
tmp_matrix.yx = 0;
tmp_matrix.yy = 0x10000;
matrix = &tmp_matrix;
}
if ( !delta )
{
tmp_delta.x = 0;
tmp_delta.y = 0;
delta = &tmp_delta;
}
a = glyph->transform;
b = *matrix;
FT_Matrix_Multiply( &b, &a );
x = ADD_LONG( ADD_LONG( FT_MulFix( matrix->xx, glyph->delta.x ),
FT_MulFix( matrix->xy, glyph->delta.y ) ),
delta->x );
y = ADD_LONG( ADD_LONG( FT_MulFix( matrix->yx, glyph->delta.x ),
FT_MulFix( matrix->yy, glyph->delta.y ) ),
delta->y );
glyph->delta.x = x;
glyph->delta.y = y;
glyph->transform = a;
}
FT_CALLBACK_DEF( FT_Error )
ft_svg_glyph_prepare( FT_Glyph svg_glyph,
FT_GlyphSlot slot )
{
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Error error = FT_Err_Ok;
FT_Memory memory = svg_glyph->library->memory;
FT_SVG_Document document = NULL;
if ( FT_NEW( document ) )
return error;
document->svg_document = glyph->svg_document;
document->svg_document_length = glyph->svg_document_length;
document->metrics = glyph->metrics;
document->units_per_EM = glyph->units_per_EM;
document->start_glyph_id = glyph->start_glyph_id;
document->end_glyph_id = glyph->end_glyph_id;
document->transform = glyph->transform;
document->delta = glyph->delta;
slot->format = FT_GLYPH_FORMAT_SVG;
slot->glyph_index = glyph->glyph_index;
slot->other = document;
return error;
}
FT_DEFINE_GLYPH(
ft_svg_glyph_class,
sizeof ( FT_SvgGlyphRec ),
FT_GLYPH_FORMAT_SVG,
ft_svg_glyph_init, /* FT_Glyph_InitFunc glyph_init */
ft_svg_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
ft_svg_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
ft_svg_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */
NULL, /* FT_Glyph_GetBBoxFunc glyph_bbox */
ft_svg_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
)
#endif /* FT_CONFIG_OPTION_SVG */
/*************************************************************************/
/*************************************************************************/
/**** ****/
@ -359,37 +594,34 @@
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Glyph( FT_GlyphSlot slot,
FT_Glyph *aglyph )
FT_EXPORT( FT_Error )
FT_New_Glyph( FT_Library library,
FT_Glyph_Format format,
FT_Glyph *aglyph )
{
FT_Library library;
FT_Error error;
FT_Glyph glyph;
const FT_Glyph_Class* clazz = NULL;
if ( !slot )
return FT_THROW( Invalid_Slot_Handle );
library = slot->library;
if ( !aglyph )
if ( !library || !aglyph )
return FT_THROW( Invalid_Argument );
/* if it is a bitmap, that's easy :-) */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
clazz = FT_BITMAP_GLYPH_CLASS_GET;
if ( format == FT_GLYPH_FORMAT_BITMAP )
clazz = &ft_bitmap_glyph_class;
/* if it is an outline */
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
clazz = FT_OUTLINE_GLYPH_CLASS_GET;
else if ( format == FT_GLYPH_FORMAT_OUTLINE )
clazz = &ft_outline_glyph_class;
#ifdef FT_CONFIG_OPTION_SVG
/* if it is an SVG glyph */
else if ( format == FT_GLYPH_FORMAT_SVG )
clazz = &ft_svg_glyph_class;
#endif
else
{
/* try to find a renderer that supports the glyph image format */
FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 );
FT_Renderer render = FT_Lookup_Renderer( library, format, 0 );
if ( render )
@ -397,13 +629,31 @@
}
if ( !clazz )
{
error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
return FT_THROW( Invalid_Glyph_Format );
/* create FT_Glyph object */
error = ft_new_glyph( library, clazz, &glyph );
return ft_new_glyph( library, clazz, aglyph );
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Glyph( FT_GlyphSlot slot,
FT_Glyph *aglyph )
{
FT_Error error;
FT_Glyph glyph;
if ( !slot )
return FT_THROW( Invalid_Slot_Handle );
if ( !aglyph )
return FT_THROW( Invalid_Argument );
/* create FT_Glyph object */
error = FT_New_Glyph( slot->library, slot->format, &glyph );
if ( error )
goto Exit;
@ -427,12 +677,15 @@
glyph->advance.y = slot->advance.y * 1024;
/* now import the image from the glyph slot */
error = clazz->glyph_init( glyph, slot );
error = glyph->clazz->glyph_init( glyph, slot );
Exit2:
/* if an error occurred, destroy the glyph */
if ( error )
{
FT_Done_Glyph( glyph );
*aglyph = NULL;
}
else
*aglyph = glyph;
@ -444,9 +697,9 @@
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_Transform( FT_Glyph glyph,
FT_Matrix* matrix,
FT_Vector* delta )
FT_Glyph_Transform( FT_Glyph glyph,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
@ -505,8 +758,8 @@
{
acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
acbox->xMax = FT_PIX_CEIL( acbox->xMax );
acbox->yMax = FT_PIX_CEIL( acbox->yMax );
acbox->xMax = FT_PIX_CEIL_LONG( acbox->xMax );
acbox->yMax = FT_PIX_CEIL_LONG( acbox->yMax );
}
/* convert to integer pixels if needed */
@ -524,10 +777,10 @@
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_Render_Mode render_mode,
FT_Vector* origin,
FT_Bool destroy )
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_Render_Mode render_mode,
const FT_Vector* origin,
FT_Bool destroy )
{
FT_GlyphSlotRec dummy;
FT_GlyphSlot_InternalRec dummy_internal;
@ -536,7 +789,6 @@
FT_BitmapGlyph bitmap = NULL;
const FT_Glyph_Class* clazz;
/* FT_BITMAP_GLYPH_CLASS_GET dereferences `library' in PIC mode */
FT_Library library;
@ -553,7 +805,7 @@
goto Bad;
/* when called with a bitmap glyph, do nothing and return successfully */
if ( clazz == FT_BITMAP_GLYPH_CLASS_GET )
if ( clazz == &ft_bitmap_glyph_class )
goto Exit;
if ( !clazz->glyph_prepare )
@ -569,7 +821,7 @@
dummy.format = clazz->glyph_format;
/* create result bitmap glyph */
error = ft_new_glyph( library, FT_BITMAP_GLYPH_CLASS_GET, &b );
error = ft_new_glyph( library, &ft_bitmap_glyph_class, &b );
if ( error )
goto Exit;
bitmap = (FT_BitmapGlyph)b;
@ -577,7 +829,7 @@
#if 1
/* if `origin' is set, translate the glyph image */
if ( origin )
FT_Glyph_Transform( glyph, 0, origin );
FT_Glyph_Transform( glyph, NULL, origin );
#else
FT_UNUSED( origin );
#endif
@ -587,6 +839,16 @@
if ( !error )
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
#ifdef FT_CONFIG_OPTION_SVG
if ( clazz == &ft_svg_glyph_class )
{
FT_Memory memory = library->memory;
FT_FREE( dummy.other );
}
#endif
#if 1
if ( !destroy && origin )
{
@ -595,7 +857,7 @@
v.x = -origin->x;
v.y = -origin->y;
FT_Glyph_Transform( glyph, 0, &v );
FT_Glyph_Transform( glyph, NULL, &v );
}
#endif

View file

@ -1,35 +1,34 @@
/***************************************************************************/
/* */
/* ftgxval.c */
/* */
/* FreeType API for validating TrueTypeGX/AAT tables (body). */
/* */
/* Copyright 2004-2018 by */
/* Masatake YAMATO, Redhat K.K, */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftgxval.c
*
* FreeType API for validating TrueTypeGX/AAT tables (body).
*
* Copyright (C) 2004-2023 by
* Masatake YAMATO, Redhat K.K,
* 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.
*
*/
/***************************************************************************/
/* */
/* gxvalid is derived from both gxlayout module and otvalid module. */
/* Development of gxlayout is supported by the Information-technology */
/* Promotion Agency(IPA), Japan. */
/* */
/***************************************************************************/
/****************************************************************************
*
* gxvalid is derived from both gxlayout module and otvalid module.
* Development of gxlayout is supported by the Information-technology
* Promotion Agency(IPA), Japan.
*
*/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include <freetype/internal/ftdebug.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_GX_VALIDATE_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svgxval.h>
/* documentation is in ftgxval.h */

View file

@ -1,10 +1,10 @@
/***************************************************************************/
/* */
/* fthash.c */
/* */
/* Hashing functions (body). */
/* */
/***************************************************************************/
/****************************************************************************
*
* fthash.c
*
* Hashing functions (body).
*
*/
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
@ -30,18 +30,17 @@
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*************************************************************************/
/* */
/* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */
/* */
/* taken from Mark Leisher's xmbdfed package */
/* */
/*************************************************************************/
/**************************************************************************
*
* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50
*
* taken from Mark Leisher's xmbdfed package
*
*/
#include <ft2build.h>
#include FT_INTERNAL_HASH_H
#include FT_INTERNAL_MEMORY_H
#include <freetype/internal/fthash.h>
#include <freetype/internal/ftmemory.h>
#define INITIAL_HT_SIZE 241
@ -244,7 +243,7 @@
nn = *bp;
if ( !nn )
{
if ( FT_NEW( nn ) )
if ( FT_QNEW( nn ) )
goto Exit;
*bp = nn;

View file

@ -1,61 +1,57 @@
/***************************************************************************/
/* */
/* ftinit.c */
/* */
/* FreeType initialization layer (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftinit.c
*
* FreeType initialization layer (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.
*
*/
/*************************************************************************/
/* */
/* The purpose of this file is to implement the following two */
/* functions: */
/* */
/* FT_Add_Default_Modules(): */
/* This function is used to add the set of default modules to a */
/* fresh new library object. The set is taken from the header file */
/* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */
/* Build System' for more information. */
/* */
/* FT_Init_FreeType(): */
/* This function creates a system object for the current platform, */
/* builds a library out of it, then calls FT_Default_Drivers(). */
/* */
/* Note that even if FT_Init_FreeType() uses the implementation of the */
/* system object defined at build time, client applications are still */
/* able to provide their own `ftsystem.c'. */
/* */
/*************************************************************************/
/**************************************************************************
*
* The purpose of this file is to implement the following two
* functions:
*
* FT_Add_Default_Modules():
* This function is used to add the set of default modules to a
* fresh new library object. The set is taken from the header file
* `freetype/config/ftmodule.h'. See the document `FreeType 2.0
* Build System' for more information.
*
* FT_Init_FreeType():
* This function creates a system object for the current platform,
* builds a library out of it, then calls FT_Default_Drivers().
*
* Note that even if FT_Init_FreeType() uses the implementation of the
* system object defined at build time, client applications are still
* able to provide their own `ftsystem.c'.
*
*/
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_MODULE_H
#include "basepic.h"
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/ftmodapi.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_init
#ifndef FT_CONFIG_OPTION_PIC
#define FT_COMPONENT init
#undef FT_USE_MODULE
@ -78,120 +74,6 @@
};
#else /* FT_CONFIG_OPTION_PIC */
#ifdef __cplusplus
#define FT_EXTERNC extern "C"
#else
#define FT_EXTERNC extern
#endif
/* declare the module's class creation/destruction functions */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) \
FT_EXTERNC FT_Error \
FT_Create_Class_ ## x( FT_Library library, \
FT_Module_Class* *output_class ); \
FT_EXTERNC void \
FT_Destroy_Class_ ## x( FT_Library library, \
FT_Module_Class* clazz );
#include FT_CONFIG_MODULES_H
/* count all module classes */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) MODULE_CLASS_ ## x,
enum
{
#include FT_CONFIG_MODULES_H
FT_NUM_MODULE_CLASSES
};
/* destroy all module classes */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) \
if ( classes[i] ) \
{ \
FT_Destroy_Class_ ## x( library, classes[i] ); \
} \
i++;
FT_BASE_DEF( void )
ft_destroy_default_module_classes( FT_Library library )
{
FT_Module_Class* *classes;
FT_Memory memory;
FT_UInt i;
BasePIC* pic_container = (BasePIC*)library->pic_container.base;
if ( !pic_container->default_module_classes )
return;
memory = library->memory;
classes = pic_container->default_module_classes;
i = 0;
#include FT_CONFIG_MODULES_H
FT_FREE( classes );
pic_container->default_module_classes = NULL;
}
/* initialize all module classes and the pointer table */
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) \
error = FT_Create_Class_ ## x( library, &clazz ); \
if ( error ) \
goto Exit; \
classes[i++] = clazz;
FT_BASE_DEF( FT_Error )
ft_create_default_module_classes( FT_Library library )
{
FT_Error error;
FT_Memory memory;
FT_Module_Class* *classes = NULL;
FT_Module_Class* clazz;
FT_UInt i;
BasePIC* pic_container = (BasePIC*)library->pic_container.base;
memory = library->memory;
pic_container->default_module_classes = NULL;
if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) *
( FT_NUM_MODULE_CLASSES + 1 ) ) )
return error;
/* initialize all pointers to 0, especially the last one */
for ( i = 0; i < FT_NUM_MODULE_CLASSES; i++ )
classes[i] = NULL;
classes[FT_NUM_MODULE_CLASSES] = NULL;
i = 0;
#include FT_CONFIG_MODULES_H
Exit:
if ( error )
ft_destroy_default_module_classes( library );
else
pic_container->default_module_classes = classes;
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( void )
@ -201,16 +83,10 @@
const FT_Module_Class* const* cur;
/* FT_DEFAULT_MODULES_GET dereferences `library' in PIC mode */
#ifdef FT_CONFIG_OPTION_PIC
if ( !library )
return;
#endif
/* GCC 4.6 warns the type difference:
* FT_Module_Class** != const FT_Module_Class* const*
*/
cur = (const FT_Module_Class* const*)FT_DEFAULT_MODULES_GET;
cur = (const FT_Module_Class* const*)ft_default_modules;
/* test for valid `library' delayed to FT_Add_Module() */
while ( *cur )
@ -300,6 +176,9 @@
module_name,
property_name,
property_value );
if ( !*p )
break;
}
}
@ -323,6 +202,10 @@
FT_Memory memory;
#ifdef FT_DEBUG_LOGGING
ft_logging_init();
#endif
/* check of `alibrary' delayed to `FT_New_Library' */
/* First of all, allocate a new system object -- this function is part */
@ -369,6 +252,10 @@
/* discard memory manager */
FT_Done_Memory( memory );
#ifdef FT_DEBUG_LOGGING
ft_logging_deinit();
#endif
return FT_Err_Ok;
}

View file

@ -1,27 +1,26 @@
/***************************************************************************/
/* */
/* ftlcdfil.c */
/* */
/* FreeType API for color filtering of subpixel bitmap glyphs (body). */
/* */
/* Copyright 2006-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftlcdfil.c
*
* FreeType API for color filtering of subpixel bitmap glyphs (body).
*
* Copyright (C) 2006-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_LCD_FILTER_H
#include FT_IMAGE_H
#include FT_INTERNAL_OBJECTS_H
#include <freetype/ftlcdfil.h>
#include <freetype/ftimage.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
@ -33,10 +32,10 @@
/* add padding according to filter weights */
FT_BASE_DEF (void)
ft_lcd_padding( FT_Pos* Min,
FT_Pos* Max,
FT_GlyphSlot slot )
FT_BASE_DEF( void )
ft_lcd_padding( FT_BBox* cbox,
FT_GlyphSlot slot,
FT_Render_Mode mode )
{
FT_Byte* lcd_weights;
FT_Bitmap_LcdFilterFunc lcd_filter_func;
@ -56,10 +55,20 @@
if ( lcd_filter_func == ft_lcd_filter_fir )
{
*Min -= lcd_weights[0] ? 43 :
lcd_weights[1] ? 22 : 0;
*Max += lcd_weights[4] ? 43 :
lcd_weights[3] ? 22 : 0;
if ( mode == FT_RENDER_MODE_LCD )
{
cbox->xMin -= lcd_weights[0] ? 43 :
lcd_weights[1] ? 22 : 0;
cbox->xMax += lcd_weights[4] ? 43 :
lcd_weights[3] ? 22 : 0;
}
else if ( mode == FT_RENDER_MODE_LCD_V )
{
cbox->yMin -= lcd_weights[0] ? 43 :
lcd_weights[1] ? 22 : 0;
cbox->yMax += lcd_weights[4] ? 43 :
lcd_weights[3] ? 22 : 0;
}
}
}
@ -67,13 +76,13 @@
/* FIR filter used by the default and light filters */
FT_BASE_DEF( void )
ft_lcd_filter_fir( FT_Bitmap* bitmap,
FT_Render_Mode mode,
FT_LcdFiveTapFilter weights )
{
FT_UInt width = (FT_UInt)bitmap->width;
FT_UInt height = (FT_UInt)bitmap->rows;
FT_Int pitch = bitmap->pitch;
FT_Byte* origin = bitmap->buffer;
FT_Byte mode = bitmap->pixel_mode;
/* take care of bitmap flow */
@ -81,7 +90,7 @@
origin += pitch * (FT_Int)( height - 1 );
/* horizontal in-place FIR filter */
if ( mode == FT_RENDER_MODE_LCD && width >= 2 )
if ( mode == FT_PIXEL_MODE_LCD && width >= 2 )
{
FT_Byte* line = origin;
@ -124,7 +133,7 @@
}
/* vertical in-place FIR filter */
else if ( mode == FT_RENDER_MODE_LCD_V && height >= 2 )
else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 2 )
{
FT_Byte* column = origin;
@ -173,13 +182,13 @@
/* intra-pixel filter used by the legacy filter */
static void
_ft_lcd_filter_legacy( FT_Bitmap* bitmap,
FT_Render_Mode mode,
FT_Byte* weights )
{
FT_UInt width = (FT_UInt)bitmap->width;
FT_UInt height = (FT_UInt)bitmap->rows;
FT_Int pitch = bitmap->pitch;
FT_Byte* origin = bitmap->buffer;
FT_Byte mode = bitmap->pixel_mode;
static const unsigned int filters[3][3] =
{
@ -196,7 +205,7 @@
origin += pitch * (FT_Int)( height - 1 );
/* horizontal in-place intra-pixel filter */
if ( mode == FT_RENDER_MODE_LCD && width >= 3 )
if ( mode == FT_PIXEL_MODE_LCD && width >= 3 )
{
FT_Byte* line = origin;
@ -233,7 +242,7 @@
}
}
}
else if ( mode == FT_RENDER_MODE_LCD_V && height >= 3 )
else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 3 )
{
FT_Byte* column = origin;
@ -275,6 +284,8 @@
#endif /* USE_LEGACY */
/* documentation in ftlcdfil.h */
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilterWeights( FT_Library library,
unsigned char *weights )
@ -292,6 +303,8 @@
}
/* documentation in ftlcdfil.h */
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )
@ -341,18 +354,41 @@
return FT_Err_Ok;
}
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdGeometry( FT_Library library,
FT_Vector sub[3] )
{
FT_UNUSED( library );
FT_UNUSED( sub );
return FT_THROW( Unimplemented_Feature );
}
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
/* add padding according to accommodate outline shifts */
FT_BASE_DEF (void)
ft_lcd_padding( FT_Pos* Min,
FT_Pos* Max,
FT_GlyphSlot slot )
/* add padding to accommodate outline shifts */
FT_BASE_DEF( void )
ft_lcd_padding( FT_BBox* cbox,
FT_GlyphSlot slot,
FT_Render_Mode mode )
{
FT_UNUSED( slot );
FT_Vector* sub = slot->library->lcd_geometry;
*Min -= 21;
*Max += 21;
if ( mode == FT_RENDER_MODE_LCD )
{
cbox->xMin -= FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
cbox->xMax -= FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
cbox->yMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
cbox->yMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
}
else if ( mode == FT_RENDER_MODE_LCD_V )
{
cbox->xMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
cbox->xMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
cbox->yMin += FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
cbox->yMax += FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
}
}
@ -377,6 +413,24 @@
return FT_THROW( Unimplemented_Feature );
}
/* documentation in ftlcdfil.h */
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdGeometry( FT_Library library,
FT_Vector sub[3] )
{
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !sub )
return FT_THROW( Invalid_Argument );
ft_memcpy( library->lcd_geometry, sub, 3 * sizeof( FT_Vector ) );
return FT_Err_Ok;
}
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */

View file

@ -1,23 +1,23 @@
/***************************************************************************/
/* */
/* ftmac.c */
/* */
/* Mac FOND support. Written by just@letterror.com. */
/* Heavily modified by mpsuzuki, George Williams, and Sean McBride. */
/* */
/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */
/* classic platforms built by MPW. */
/* */
/* Copyright 1996-2018 by */
/* Just van Rossum, 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftmac.c
*
* Mac FOND support. Written by just@letterror.com.
* Heavily modified by mpsuzuki, George Williams, and Sean McBride.
*
* This file is for Mac OS X only; see builds/mac/ftoldmac.c for
* classic platforms built by MPW.
*
* Copyright (C) 1996-2023 by
* Just van Rossum, 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.
*
*/
/*
@ -65,10 +65,10 @@
*/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_STREAM_H
#include <freetype/freetype.h>
#include <freetype/tttags.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include "ftbase.h"
@ -106,7 +106,7 @@
/* Don't want warnings about our own use of deprecated functions. */
#define FT_DEPRECATED_ATTRIBUTE
#include FT_MAC_H
#include <freetype/ftmac.h>
#ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
@ -315,7 +315,7 @@
NULL, NULL, NULL ) )
return ( OSType ) 0;
return ((FInfo *)(info.finderInfo))->fdType;
return ( (FInfo *)( info.finderInfo ) )->fdType;
}
@ -463,7 +463,7 @@
if ( ps_name_len != 0 )
{
ft_memcpy(ps_name, names[0] + 1, ps_name_len);
ft_memcpy( ps_name, names[0] + 1, ps_name_len );
ps_name[ps_name_len] = 0;
}
if ( style->indexes[face_index] > 1 &&
@ -561,7 +561,7 @@
if ( lwfn_file_name[0] )
{
err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
buff, sizeof ( buff ) );
buff, sizeof ( buff ) );
if ( !err )
have_lwfn = 1;
}
@ -632,7 +632,7 @@
old_total_size = total_size;
}
if ( FT_ALLOC( buffer, (FT_Long)total_size ) )
if ( FT_QALLOC( buffer, (FT_Long)total_size ) )
goto Error;
/* Second pass: append all POST data to the buffer, add PFB fields. */
@ -753,7 +753,7 @@
if ( FT_MAC_RFORK_MAX_LEN < sfnt_size )
return FT_THROW( Array_Too_Large );
if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
if ( FT_QALLOC( sfnt_data, (FT_Long)sfnt_size ) )
{
ReleaseResource( sfnt );
return error;
@ -954,17 +954,17 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* FT_New_Face */
/* */
/* <Description> */
/* This is the Mac-specific implementation of FT_New_Face. In */
/* addition to the standard FT_New_Face() functionality, it also */
/* accepts pathnames to Mac suitcase files. For further */
/* documentation see the original FT_New_Face() in freetype.h. */
/* */
/**************************************************************************
*
* @Function:
* FT_New_Face
*
* @Description:
* This is the Mac-specific implementation of FT_New_Face. In
* addition to the standard FT_New_Face() functionality, it also
* accepts pathnames to Mac suitcase files. For further
* documentation see the original FT_New_Face() in freetype.h.
*/
FT_EXPORT_DEF( FT_Error )
FT_New_Face( FT_Library library,
const char* pathname,
@ -995,17 +995,18 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* FT_New_Face_From_FSRef */
/* */
/* <Description> */
/* FT_New_Face_From_FSRef is identical to FT_New_Face except it */
/* accepts an FSRef instead of a path. */
/* */
/* This function is deprecated because Carbon data types (FSRef) */
/* are not cross-platform, and thus not suitable for the FreeType API. */
/**************************************************************************
*
* @Function:
* FT_New_Face_From_FSRef
*
* @Description:
* FT_New_Face_From_FSRef is identical to FT_New_Face except it
* accepts an FSRef instead of a path.
*
* This function is deprecated because Carbon data types (FSRef)
* are not cross-platform, and thus not suitable for the FreeType API.
*/
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FSRef( FT_Library library,
const FSRef* ref,
@ -1040,16 +1041,17 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* FT_New_Face_From_FSSpec */
/* */
/* <Description> */
/* FT_New_Face_From_FSSpec is identical to FT_New_Face except it */
/* accepts an FSSpec instead of a path. */
/* */
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
/**************************************************************************
*
* @Function:
* FT_New_Face_From_FSSpec
*
* @Description:
* FT_New_Face_From_FSSpec is identical to FT_New_Face except it
* accepts an FSSpec instead of a path.
*
* This function is deprecated because FSSpec is deprecated in Mac OS X
*/
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FSSpec( FT_Library library,
const FSSpec* spec,

View file

@ -1,38 +1,37 @@
/***************************************************************************/
/* */
/* ftmm.c */
/* */
/* Multiple Master font support (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftmm.c
*
* Multiple Master font support (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_MULTIPLE_MASTERS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
#include FT_SERVICE_METRICS_VARIATIONS_H
#include <freetype/ftmm.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svmm.h>
#include <freetype/internal/services/svmetric.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_mm
#define FT_COMPONENT mm
static FT_Error
@ -199,6 +198,67 @@
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_MM_WeightVector( FT_Face face,
FT_UInt len,
FT_Fixed* weightvector )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( len && !weightvector )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->set_mm_weightvector )
error = service->set_mm_weightvector( face, len, weightvector );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_MM_WeightVector( FT_Face face,
FT_UInt* len,
FT_Fixed* weightvector )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( len && !weightvector )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm_weightvector )
error = service->get_mm_weightvector( face, len, weightvector );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )

File diff suppressed because it is too large Load diff

View file

@ -1,26 +1,25 @@
/***************************************************************************/
/* */
/* ftotval.c */
/* */
/* FreeType API for validating OpenType tables (body). */
/* */
/* Copyright 2004-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftotval.c
*
* FreeType API for validating OpenType tables (body).
*
* Copyright (C) 2004-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_INTERNAL_OBJECTS_H
#include FT_SERVICE_OPENTYPE_VALIDATE_H
#include FT_OPENTYPE_VALIDATE_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svotval.h>
#include <freetype/ftotval.h>
/* documentation is in ftotval.h */

View file

@ -1,44 +1,36 @@
/***************************************************************************/
/* */
/* ftoutln.c */
/* */
/* FreeType outline management (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftoutln.c
*
* FreeType outline management (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.
*
*/
/*************************************************************************/
/* */
/* All functions are declared in freetype.h. */
/* */
/*************************************************************************/
#include <freetype/ftoutln.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/fttrigon.h>
#include <ft2build.h>
#include FT_OUTLINE_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_DEBUG_H
#include FT_TRIGONOMETRY_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_outline
#define FT_COMPONENT outline
static
@ -53,8 +45,7 @@
void* user )
{
#undef SCALED
#define SCALED( x ) ( ( (x) < 0 ? -( -(x) << shift ) \
: ( (x) << shift ) ) - delta )
#define SCALED( x ) ( (x) * ( 1L << shift ) - delta )
FT_Vector v_last;
FT_Vector v_control;
@ -139,7 +130,7 @@
}
FT_TRACE5(( " move to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
(double)v_start.x / 64, (double)v_start.y / 64 ));
error = func_interface->move_to( &v_start, user );
if ( error )
goto Exit;
@ -161,7 +152,7 @@
vec.y = SCALED( point->y );
FT_TRACE5(( " line to (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0 ));
(double)vec.x / 64, (double)vec.y / 64 ));
error = func_interface->line_to( &vec, user );
if ( error )
goto Exit;
@ -190,8 +181,10 @@
{
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
(double)vec.x / 64,
(double)vec.y / 64,
(double)v_control.x / 64,
(double)v_control.y / 64 ));
error = func_interface->conic_to( &v_control, &vec, user );
if ( error )
goto Exit;
@ -206,8 +199,10 @@
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_middle.x / 64.0, v_middle.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
(double)v_middle.x / 64,
(double)v_middle.y / 64,
(double)v_control.x / 64,
(double)v_control.y / 64 ));
error = func_interface->conic_to( &v_control, &v_middle, user );
if ( error )
goto Exit;
@ -218,8 +213,10 @@
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
(double)v_start.x / 64,
(double)v_start.y / 64,
(double)v_control.x / 64,
(double)v_control.y / 64 ));
error = func_interface->conic_to( &v_control, &v_start, user );
goto Close;
@ -251,9 +248,12 @@
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
(double)vec.x / 64,
(double)vec.y / 64,
(double)vec1.x / 64,
(double)vec1.y / 64,
(double)vec2.x / 64,
(double)vec2.y / 64 ));
error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
if ( error )
goto Exit;
@ -262,9 +262,12 @@
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
(double)v_start.x / 64,
(double)v_start.y / 64,
(double)vec1.x / 64,
(double)vec1.y / 64,
(double)vec2.x / 64,
(double)vec2.y / 64 ));
error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
goto Close;
}
@ -273,7 +276,7 @@
/* close the contour with a line segment */
FT_TRACE5(( " line to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
(double)v_start.x / 64, (double)v_start.y / 64 ));
error = func_interface->line_to( &v_start, user );
Close:
@ -283,7 +286,7 @@
first = (FT_UInt)last + 1;
}
FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
FT_TRACE5(( "FT_Outline_Decompose: Done\n" ));
return FT_Err_Ok;
Invalid_Outline:
@ -296,14 +299,22 @@
}
FT_EXPORT_DEF( FT_Error )
FT_Outline_New_Internal( FT_Memory memory,
FT_UInt numPoints,
FT_Int numContours,
FT_Outline *anoutline )
{
FT_Error error;
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_New( FT_Library library,
FT_UInt numPoints,
FT_Int numContours,
FT_Outline *anoutline )
{
FT_Error error;
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
memory = library->memory;
if ( !anoutline || !memory )
return FT_THROW( Invalid_Argument );
@ -330,28 +341,12 @@
Fail:
anoutline->flags |= FT_OUTLINE_OWNER;
FT_Outline_Done_Internal( memory, anoutline );
FT_Outline_Done( library, anoutline );
return error;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_New( FT_Library library,
FT_UInt numPoints,
FT_Int numContours,
FT_Outline *anoutline )
{
if ( !library )
return FT_THROW( Invalid_Library_Handle );
return FT_Outline_New_Internal( library->memory, numPoints,
numContours, anoutline );
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
@ -436,13 +431,23 @@
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Done_Internal( FT_Memory memory,
FT_Outline* outline )
FT_Outline_Done( FT_Library library,
FT_Outline* outline )
{
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !outline )
return FT_THROW( Invalid_Outline );
memory = library->memory;
if ( !memory )
return FT_THROW( Invalid_Argument );
@ -458,21 +463,6 @@
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Done( FT_Library library,
FT_Outline* outline )
{
/* check for valid `outline' in FT_Outline_Done_Internal() */
if ( !library )
return FT_THROW( Invalid_Library_Handle );
return FT_Outline_Done_Internal( library->memory, outline );
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
@ -619,6 +609,7 @@
FT_Error error;
FT_Renderer renderer;
FT_ListNode node;
FT_BBox cbox;
if ( !library )
@ -630,11 +621,26 @@
if ( !params )
return FT_THROW( Invalid_Argument );
FT_Outline_Get_CBox( outline, &cbox );
if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
return FT_THROW( Invalid_Outline );
renderer = library->cur_renderer;
node = library->renderers.head;
params->source = (void*)outline;
/* preset clip_box for direct mode */
if ( params->flags & FT_RASTER_FLAG_DIRECT &&
!( params->flags & FT_RASTER_FLAG_CLIP ) )
{
params->clip_box.xMin = cbox.xMin >> 6;
params->clip_box.yMin = cbox.yMin >> 6;
params->clip_box.xMax = ( cbox.xMax + 63 ) >> 6;
params->clip_box.yMax = ( cbox.yMax + 63 ) >> 6;
}
error = FT_ERR( Cannot_Render_Glyph );
while ( renderer )
{
@ -716,7 +722,7 @@
FT_Vector* limit;
if ( !outline || !matrix )
if ( !outline || !matrix || !outline->points )
return;
vec = outline->points;
@ -911,9 +917,9 @@
FT_Pos xstrength,
FT_Pos ystrength )
{
FT_Vector* points;
FT_Int c, first, last;
FT_Int orientation;
FT_Vector* points;
FT_Int c, first, last;
FT_Orientation orientation;
if ( !outline )
@ -1044,7 +1050,7 @@
FT_EXPORT_DEF( FT_Orientation )
FT_Outline_Get_Orientation( FT_Outline* outline )
{
FT_BBox cbox;
FT_BBox cbox = { 0, 0, 0, 0 };
FT_Int xshift, yshift;
FT_Vector* points;
FT_Vector v_prev, v_cur;
@ -1066,6 +1072,11 @@
if ( cbox.xMin == cbox.xMax || cbox.yMin == cbox.yMax )
return FT_ORIENTATION_NONE;
/* Reject values large outlines. */
if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
return FT_ORIENTATION_NONE;
xshift = FT_MSB( (FT_UInt32)( FT_ABS( cbox.xMax ) |
FT_ABS( cbox.xMin ) ) ) - 14;
xshift = FT_MAX( xshift, 0 );
@ -1090,7 +1101,8 @@
v_cur.y = points[n].y >> yshift;
area = ADD_LONG( area,
( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ) );
MUL_LONG( v_cur.y - v_prev.y,
v_cur.x + v_prev.x ) );
v_prev = v_cur;
}

View file

@ -1,28 +1,27 @@
/***************************************************************************/
/* */
/* ftpatent.c */
/* */
/* FreeType API for checking patented TrueType bytecode instructions */
/* (body). Obsolete, retained for backward compatibility. */
/* */
/* Copyright 2007-2018 by */
/* David Turner. */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftpatent.c
*
* FreeType API for checking patented TrueType bytecode instructions
* (body). Obsolete, retained for backward compatibility.
*
* Copyright (C) 2007-2023 by
* David Turner.
*
* 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_TRUETYPE_TAGS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_STREAM_H
#include FT_SERVICE_SFNT_H
#include FT_SERVICE_TRUETYPE_GLYF_H
#include <freetype/freetype.h>
#include <freetype/tttags.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/services/svsfnt.h>
#include <freetype/internal/services/svttglyf.h>
/* documentation is in freetype.h */

View file

@ -1,25 +1,24 @@
/***************************************************************************/
/* */
/* ftpfr.c */
/* */
/* FreeType API for accessing PFR-specific data (body). */
/* */
/* Copyright 2002-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftpfr.c
*
* FreeType API for accessing PFR-specific data (body).
*
* Copyright (C) 2002-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_INTERNAL_OBJECTS_H
#include FT_SERVICE_PFR_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svpfr.h>
/* check the format */

View file

@ -1,55 +0,0 @@
/***************************************************************************/
/* */
/* ftpic.c */
/* */
/* The FreeType position independent code services (body). */
/* */
/* 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 "basepic.h"
#ifdef FT_CONFIG_OPTION_PIC
/* documentation is in ftpic.h */
FT_BASE_DEF( FT_Error )
ft_pic_container_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error;
FT_MEM_SET( pic_container, 0, sizeof ( *pic_container ) );
error = ft_base_pic_init( library );
if ( error )
return error;
return FT_Err_Ok;
}
/* Destroy the contents of the container. */
FT_BASE_DEF( void )
ft_pic_container_destroy( FT_Library library )
{
ft_base_pic_free( library );
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */

View file

@ -1,38 +1,37 @@
/***************************************************************************/
/* */
/* ftpsprop.c */
/* */
/* Get and set properties of PostScript drivers (body). */
/* See `ftdriver.h' for available properties. */
/* */
/* Copyright 2017-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftpsprop.c
*
* Get and set properties of PostScript drivers (body).
* See `ftdriver.h' for available properties.
*
* Copyright (C) 2017-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_DRIVER_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_POSTSCRIPT_PROPS_H
#include <freetype/ftdriver.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/psaux.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftpsprop.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_psprops
#define FT_COMPONENT psprops
FT_BASE_CALLBACK_DEF( FT_Error )
@ -165,9 +164,9 @@
driver->hinting_engine = *hinting_engine;
else
error = FT_ERR( Unimplemented_Feature );
return error;
}
return error;
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
@ -221,7 +220,7 @@
return error;
}
FT_TRACE0(( "ps_property_set: missing property `%s'\n",
FT_TRACE2(( "ps_property_set: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
@ -276,7 +275,7 @@
return error;
}
FT_TRACE0(( "ps_property_get: missing property `%s'\n",
FT_TRACE2(( "ps_property_get: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}

View file

@ -1,38 +1,37 @@
/***************************************************************************/
/* */
/* ftrfork.c */
/* */
/* Embedded resource forks accessor (body). */
/* */
/* Copyright 2004-2018 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */
/* derived from ftobjs.c. */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftrfork.c
*
* Embedded resource forks accessor (body).
*
* Copyright (C) 2004-2023 by
* Masatake YAMATO and Redhat K.K.
*
* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are
* derived from ftobjs.c.
*
* 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.
*
*/
/***************************************************************************/
/* Development of the code in this file is support of */
/* Information-technology Promotion Agency, Japan. */
/***************************************************************************/
/****************************************************************************
* Development of the code in this file is support of
* Information-technology Promotion Agency, Japan.
*/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_RFORK_H
#include "basepic.h"
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftrfork.h>
#include "ftbase.h"
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
#define FT_COMPONENT raccess
/*************************************************************************/
@ -168,16 +167,11 @@
}
static int
ft_raccess_sort_ref_by_id( FT_RFork_Ref* a,
FT_RFork_Ref* b )
FT_COMPARE_DEF( int )
ft_raccess_sort_ref_by_id( const void* a,
const void* b )
{
if ( a->res_id < b->res_id )
return -1;
else if ( a->res_id > b->res_id )
return 1;
else
return 0;
return ( (FT_RFork_Ref*)a )->res_id - ( (FT_RFork_Ref*)b )->res_id;
}
@ -240,7 +234,7 @@
(char)( 0xFF & ( tag_internal >> 16 ) ),
(char)( 0xFF & ( tag_internal >> 8 ) ),
(char)( 0xFF & ( tag_internal >> 0 ) ) ));
FT_TRACE3(( " : subcount=%d, suboffset=0x%04x\n",
FT_TRACE3(( " : subcount=%d, suboffset=0x%04lx\n",
subcnt, rpos ));
if ( tag_internal == tag )
@ -257,7 +251,7 @@
if ( error )
return error;
if ( FT_NEW_ARRAY( ref, *count ) )
if ( FT_QNEW_ARRAY( ref, *count ) )
return error;
for ( j = 0; j < *count; j++ )
@ -286,7 +280,7 @@
ref[j].offset = temp & 0xFFFFFFL;
FT_TRACE3(( " [%d]:"
" resource_id=0x%04x, offset=0x%08x\n",
" resource_id=0x%04x, offset=0x%08lx\n",
j, (FT_UShort)ref[j].res_id, ref[j].offset ));
}
@ -295,18 +289,17 @@
ft_qsort( ref,
(size_t)*count,
sizeof ( FT_RFork_Ref ),
( int(*)(const void*,
const void*) )ft_raccess_sort_ref_by_id );
ft_raccess_sort_ref_by_id );
FT_TRACE3(( " -- sort resources by their ids --\n" ));
for ( j = 0; j < *count; j++ )
FT_TRACE3(( " [%d]:"
" resource_id=0x%04x, offset=0x%08x\n",
" resource_id=0x%04x, offset=0x%08lx\n",
j, ref[j].res_id, ref[j].offset ));
}
if ( FT_NEW_ARRAY( offsets_internal, *count ) )
if ( FT_QNEW_ARRAY( offsets_internal, *count ) )
goto Exit;
/* XXX: duplicated reference ID,
@ -409,17 +402,17 @@
FT_Long *result_offset );
CONST_FT_RFORK_RULE_ARRAY_BEGIN(ft_raccess_guess_table,
ft_raccess_guess_rec)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_double, apple_double)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_single, apple_single)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_ufs_export, darwin_ufs_export)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_newvfs, darwin_newvfs)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_hfsplus, darwin_hfsplus)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(vfat, vfat)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_cap, linux_cap)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_double, linux_double)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_netatalk, linux_netatalk)
CONST_FT_RFORK_RULE_ARRAY_BEGIN( ft_raccess_guess_table,
ft_raccess_guess_rec )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( apple_double, apple_double )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( apple_single, apple_single )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( darwin_ufs_export, darwin_ufs_export )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( darwin_newvfs, darwin_newvfs )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( darwin_hfsplus, darwin_hfsplus )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( vfat, vfat )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( linux_cap, linux_cap )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( linux_double, linux_double )
CONST_FT_RFORK_RULE_ARRAY_ENTRY( linux_netatalk, linux_netatalk )
CONST_FT_RFORK_RULE_ARRAY_END
@ -438,7 +431,7 @@
static FT_Error
raccess_guess_linux_double_from_file_name( FT_Library library,
char * file_name,
char* file_name,
FT_Long *result_offset );
static char *
@ -468,10 +461,10 @@
if ( errors[i] )
continue;
errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library,
stream, base_name,
&(new_names[i]),
&(offsets[i]) );
errors[i] = ft_raccess_guess_table[i].func( library,
stream, base_name,
&(new_names[i]),
&(offsets[i]) );
}
return;
@ -488,7 +481,7 @@
if ( rule_index >= FT_RACCESS_N_RULES )
return FT_RFork_Rule_invalid;
return FT_RACCESS_GUESS_TABLE_GET[rule_index].type;
return ft_raccess_guess_table[rule_index].type;
}
@ -609,7 +602,7 @@
if ( base_file_len + 6 > FT_INT_MAX )
return FT_THROW( Array_Too_Large );
if ( FT_ALLOC( newpath, base_file_len + 6 ) )
if ( FT_QALLOC( newpath, base_file_len + 6 ) )
return error;
FT_MEM_COPY( newpath, base_file_name, base_file_len );
@ -645,7 +638,7 @@
if ( base_file_len + 18 > FT_INT_MAX )
return FT_THROW( Array_Too_Large );
if ( FT_ALLOC( newpath, base_file_len + 18 ) )
if ( FT_QALLOC( newpath, base_file_len + 18 ) )
return error;
FT_MEM_COPY( newpath, base_file_name, base_file_len );
@ -847,7 +840,7 @@
{
FT_Open_Args args2;
FT_Stream stream2;
char * nouse = NULL;
char* nouse = NULL;
FT_Error error;
@ -875,13 +868,11 @@
const char* tmp;
const char* slash;
size_t new_length;
FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
FT_Error error;
new_length = ft_strlen( original_name ) + ft_strlen( insertion );
if ( FT_ALLOC( new_name, new_length + 1 ) )
if ( FT_QALLOC( new_name, new_length + 1 ) )
return NULL;
tmp = ft_strrchr( original_name, '/' );
@ -909,9 +900,9 @@
#else /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
/*************************************************************************/
/* Dummy function; just sets errors */
/*************************************************************************/
/**************************************************************************
* Dummy function; just sets errors
*/
FT_BASE_DEF( void )
FT_Raccess_Guess( FT_Library library,

View file

@ -1,30 +1,29 @@
/***************************************************************************/
/* */
/* ftsnames.c */
/* */
/* Simple interface to access SFNT name tables (which are used */
/* to hold font names, copyright info, notices, etc.) (body). */
/* */
/* This is _not_ used to retrieve glyph names! */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftsnames.c
*
* Simple interface to access SFNT name tables (which are used
* to hold font names, copyright info, notices, etc.) (body).
*
* This is _not_ used to retrieve glyph names!
*
* 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_SFNT_NAMES_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_INTERNAL_STREAM_H
#include <freetype/ftsnames.h>
#include <freetype/internal/tttypes.h>
#include <freetype/internal/ftstream.h>
#ifdef TT_CONFIG_OPTION_SFNT_NAMES
@ -66,7 +65,7 @@
FT_Stream stream = face->stream;
if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
FT_STREAM_SEEK( entry->stringOffset ) ||
FT_STREAM_READ( entry->string, entry->stringLength ) )
{
@ -122,7 +121,7 @@
FT_Stream stream = face->stream;
if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
FT_STREAM_SEEK( entry->stringOffset ) ||
FT_STREAM_READ( entry->string, entry->stringLength ) )
{
@ -142,7 +141,45 @@
}
#endif /* TT_CONFIG_OPTION_SFNT_NAMES */
#else /* !TT_CONFIG_OPTION_SFNT_NAMES */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Sfnt_Name_Count( FT_Face face )
{
FT_UNUSED( face );
return 0;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_Name( FT_Face face,
FT_UInt idx,
FT_SfntName *aname )
{
FT_UNUSED( face );
FT_UNUSED( idx );
FT_UNUSED( aname );
return FT_THROW( Unimplemented_Feature );
}
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_LangTag( FT_Face face,
FT_UInt langID,
FT_SfntLangTag *alangTag )
{
FT_UNUSED( face );
FT_UNUSED( langID );
FT_UNUSED( alangTag );
return FT_THROW( Unimplemented_Feature );
}
#endif /* !TT_CONFIG_OPTION_SFNT_NAMES */
/* END */

View file

@ -1,34 +1,33 @@
/***************************************************************************/
/* */
/* ftstream.c */
/* */
/* I/O stream support (body). */
/* */
/* Copyright 2000-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftstream.c
*
* I/O stream support (body).
*
* Copyright (C) 2000-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_STREAM_H
#include FT_INTERNAL_DEBUG_H
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftdebug.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_stream
#define FT_COMPONENT stream
FT_BASE_DEF( void )
@ -62,7 +61,7 @@
if ( stream->read )
{
if ( stream->read( stream, pos, 0, 0 ) )
if ( stream->read( stream, pos, NULL, 0 ) )
{
FT_ERROR(( "FT_Stream_Seek:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
@ -219,13 +218,14 @@
{
FT_Memory memory = stream->memory;
#ifdef FT_DEBUG_MEMORY
ft_mem_free( memory, *pbytes );
*pbytes = NULL;
#else
FT_FREE( *pbytes );
#endif
}
*pbytes = NULL;
}
@ -238,6 +238,8 @@
FT_ULong read_bytes;
FT_TRACE7(( "FT_Stream_EnterFrame: %ld bytes\n", count ));
/* check for nested frame access */
FT_ASSERT( stream && stream->cursor == 0 );
@ -259,7 +261,7 @@
}
#ifdef FT_DEBUG_MEMORY
/* assume _ft_debug_file and _ft_debug_lineno are already set */
/* assume `ft_debug_file_` and `ft_debug_lineno_` are already set */
stream->base = (unsigned char*)ft_mem_qalloc( memory,
(FT_Long)count,
&error );
@ -281,8 +283,9 @@
FT_FREE( stream->base );
error = FT_THROW( Invalid_Stream_Operation );
}
stream->cursor = stream->base;
stream->limit = stream->cursor + count;
stream->limit = FT_OFFSET( stream->cursor, count );
stream->pos += read_bytes;
}
else
@ -321,13 +324,16 @@
/* In this case, the loader code handles the 0-length table */
/* gracefully; however, stream.cursor is really set to 0 by the */
/* FT_Stream_EnterFrame() call, and this is not an error. */
/* */
FT_TRACE7(( "FT_Stream_ExitFrame\n" ));
FT_ASSERT( stream );
if ( stream->read )
{
FT_Memory memory = stream->memory;
#ifdef FT_DEBUG_MEMORY
ft_mem_free( memory, stream->base );
stream->base = NULL;
@ -335,32 +341,33 @@
FT_FREE( stream->base );
#endif
}
stream->cursor = NULL;
stream->limit = NULL;
}
FT_BASE_DEF( FT_Char )
FT_Stream_GetChar( FT_Stream stream )
FT_BASE_DEF( FT_Byte )
FT_Stream_GetByte( FT_Stream stream )
{
FT_Char result;
FT_Byte result;
FT_ASSERT( stream && stream->cursor );
result = 0;
if ( stream->cursor < stream->limit )
result = (FT_Char)*stream->cursor++;
result = *stream->cursor++;
return result;
}
FT_BASE_DEF( FT_UShort )
FT_BASE_DEF( FT_UInt16 )
FT_Stream_GetUShort( FT_Stream stream )
{
FT_Byte* p;
FT_UShort result;
FT_UInt16 result;
FT_ASSERT( stream && stream->cursor );
@ -375,11 +382,11 @@
}
FT_BASE_DEF( FT_UShort )
FT_BASE_DEF( FT_UInt16 )
FT_Stream_GetUShortLE( FT_Stream stream )
{
FT_Byte* p;
FT_UShort result;
FT_UInt16 result;
FT_ASSERT( stream && stream->cursor );
@ -394,11 +401,11 @@
}
FT_BASE_DEF( FT_ULong )
FT_BASE_DEF( FT_UInt32 )
FT_Stream_GetUOffset( FT_Stream stream )
{
FT_Byte* p;
FT_ULong result;
FT_UInt32 result;
FT_ASSERT( stream && stream->cursor );
@ -412,11 +419,11 @@
}
FT_BASE_DEF( FT_ULong )
FT_BASE_DEF( FT_UInt32 )
FT_Stream_GetULong( FT_Stream stream )
{
FT_Byte* p;
FT_ULong result;
FT_UInt32 result;
FT_ASSERT( stream && stream->cursor );
@ -430,11 +437,11 @@
}
FT_BASE_DEF( FT_ULong )
FT_BASE_DEF( FT_UInt32 )
FT_Stream_GetULongLE( FT_Stream stream )
{
FT_Byte* p;
FT_ULong result;
FT_UInt32 result;
FT_ASSERT( stream && stream->cursor );
@ -448,8 +455,8 @@
}
FT_BASE_DEF( FT_Char )
FT_Stream_ReadChar( FT_Stream stream,
FT_BASE_DEF( FT_Byte )
FT_Stream_ReadByte( FT_Stream stream,
FT_Error* error )
{
FT_Byte result = 0;
@ -457,47 +464,46 @@
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->read )
if ( stream->pos < stream->size )
{
if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
goto Fail;
if ( stream->read )
{
if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
goto Fail;
}
else
result = stream->base[stream->pos];
}
else
{
if ( stream->pos < stream->size )
result = stream->base[stream->pos];
else
goto Fail;
}
goto Fail;
stream->pos++;
return (FT_Char)result;
*error = FT_Err_Ok;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadChar:"
FT_ERROR(( "FT_Stream_ReadByte:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
return result;
}
FT_BASE_DEF( FT_UShort )
FT_BASE_DEF( FT_UInt16 )
FT_Stream_ReadUShort( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[2];
FT_Byte* p = 0;
FT_UShort result = 0;
FT_Byte* p;
FT_UInt16 result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 1 < stream->size )
{
if ( stream->read )
@ -518,6 +524,8 @@
stream->pos += 2;
*error = FT_Err_Ok;
return result;
Fail:
@ -526,23 +534,21 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
return result;
}
FT_BASE_DEF( FT_UShort )
FT_BASE_DEF( FT_UInt16 )
FT_Stream_ReadUShortLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[2];
FT_Byte* p = 0;
FT_UShort result = 0;
FT_Byte* p;
FT_UInt16 result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 1 < stream->size )
{
if ( stream->read )
@ -563,6 +569,8 @@
stream->pos += 2;
*error = FT_Err_Ok;
return result;
Fail:
@ -571,7 +579,7 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
return result;
}
@ -580,14 +588,12 @@
FT_Error* error )
{
FT_Byte reads[3];
FT_Byte* p = 0;
FT_Byte* p;
FT_ULong result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 2 < stream->size )
{
if ( stream->read )
@ -608,6 +614,8 @@
stream->pos += 3;
*error = FT_Err_Ok;
return result;
Fail:
@ -616,23 +624,21 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
return result;
}
FT_BASE_DEF( FT_ULong )
FT_BASE_DEF( FT_UInt32 )
FT_Stream_ReadULong( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[4];
FT_Byte* p = 0;
FT_ULong result = 0;
FT_Byte* p;
FT_UInt32 result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 3 < stream->size )
{
if ( stream->read )
@ -653,6 +659,8 @@
stream->pos += 4;
*error = FT_Err_Ok;
return result;
Fail:
@ -661,23 +669,21 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
return result;
}
FT_BASE_DEF( FT_ULong )
FT_BASE_DEF( FT_UInt32 )
FT_Stream_ReadULongLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[4];
FT_Byte* p = 0;
FT_ULong result = 0;
FT_Byte* p;
FT_UInt32 result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 3 < stream->size )
{
if ( stream->read )
@ -698,6 +704,8 @@
stream->pos += 4;
*error = FT_Err_Ok;
return result;
Fail:
@ -706,7 +714,7 @@
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
return result;
}

View file

@ -1,38 +1,32 @@
/***************************************************************************/
/* */
/* ftstroke.c */
/* */
/* FreeType path stroker (body). */
/* */
/* Copyright 2002-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftstroke.c
*
* FreeType path stroker (body).
*
* Copyright (C) 2002-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_STROKER_H
#include FT_TRIGONOMETRY_H
#include FT_OUTLINE_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include "basepic.h"
#include <freetype/ftstroke.h>
#include <freetype/fttrigon.h>
#include <freetype/ftoutln.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
/* declare an extern to access `ft_outline_glyph_class' globally */
/* allocated in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */
/* macro to access it when FT_CONFIG_OPTION_PIC is defined */
#ifndef FT_CONFIG_OPTION_PIC
/* declare an extern to access `ft_outline_glyph_class' globally */
/* allocated in `ftglyph.c' */
FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class;
#endif
/* documentation is in ftstroke.h */
@ -91,16 +85,18 @@
base[4].x = base[2].x;
b = base[1].x;
a = base[3].x = ( base[2].x + b ) / 2;
b = base[1].x = ( base[0].x + b ) / 2;
base[2].x = ( a + b ) / 2;
a = base[0].x + base[1].x;
b = base[1].x + base[2].x;
base[3].x = b >> 1;
base[2].x = ( a + b ) >> 2;
base[1].x = a >> 1;
base[4].y = base[2].y;
b = base[1].y;
a = base[3].y = ( base[2].y + b ) / 2;
b = base[1].y = ( base[0].y + b ) / 2;
base[2].y = ( a + b ) / 2;
a = base[0].y + base[1].y;
b = base[1].y + base[2].y;
base[3].y = b >> 1;
base[2].y = ( a + b ) >> 2;
base[1].y = a >> 1;
}
@ -158,28 +154,32 @@
static void
ft_cubic_split( FT_Vector* base )
{
FT_Pos a, b, c, d;
FT_Pos a, b, c;
base[6].x = base[3].x;
c = base[1].x;
d = base[2].x;
base[1].x = a = ( base[0].x + c ) / 2;
base[5].x = b = ( base[3].x + d ) / 2;
c = ( c + d ) / 2;
base[2].x = a = ( a + c ) / 2;
base[4].x = b = ( b + c ) / 2;
base[3].x = ( a + b ) / 2;
a = base[0].x + base[1].x;
b = base[1].x + base[2].x;
c = base[2].x + base[3].x;
base[5].x = c >> 1;
c += b;
base[4].x = c >> 2;
base[1].x = a >> 1;
a += b;
base[2].x = a >> 2;
base[3].x = ( a + c ) >> 3;
base[6].y = base[3].y;
c = base[1].y;
d = base[2].y;
base[1].y = a = ( base[0].y + c ) / 2;
base[5].y = b = ( base[3].y + d ) / 2;
c = ( c + d ) / 2;
base[2].y = a = ( a + c ) / 2;
base[4].y = b = ( b + c ) / 2;
base[3].y = ( a + b ) / 2;
a = base[0].y + base[1].y;
b = base[1].y + base[2].y;
c = base[2].y + base[3].y;
base[5].y = c >> 1;
c += b;
base[4].y = c >> 2;
base[1].y = a >> 1;
a += b;
base[2].y = a >> 2;
base[3].y = ( a + c ) >> 3;
}
@ -372,6 +372,7 @@
/* it contains the `adjusted' starting coordinates */
border->num_points = --count;
border->points[start] = border->points[count];
border->tags[start] = border->tags[count];
if ( reverse )
{
@ -436,8 +437,8 @@
}
else
{
/* don't add zero-length lineto */
if ( border->num_points > 0 &&
/* don't add zero-length lineto, but always add moveto */
if ( border->num_points > (FT_UInt)border->start &&
FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) &&
FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) )
return error;
@ -538,63 +539,52 @@
FT_Angle angle_start,
FT_Angle angle_diff )
{
FT_Angle total, angle, step, rotate, next, theta;
FT_Vector a, b, a2, b2;
FT_Fixed length;
FT_Fixed coef;
FT_Vector a0, a1, a2, a3;
FT_Int i, arcs = 1;
FT_Error error = FT_Err_Ok;
/* compute start point */
FT_Vector_From_Polar( &a, radius, angle_start );
a.x += center->x;
a.y += center->y;
/* number of cubic arcs to draw */
while ( angle_diff > FT_ARC_CUBIC_ANGLE * arcs ||
-angle_diff > FT_ARC_CUBIC_ANGLE * arcs )
arcs++;
total = angle_diff;
angle = angle_start;
rotate = ( angle_diff >= 0 ) ? FT_ANGLE_PI2 : -FT_ANGLE_PI2;
/* control tangents */
coef = FT_Tan( angle_diff / ( 4 * arcs ) );
coef += coef / 3;
while ( total != 0 )
/* compute start and first control point */
FT_Vector_From_Polar( &a0, radius, angle_start );
a1.x = FT_MulFix( -a0.y, coef );
a1.y = FT_MulFix( a0.x, coef );
a0.x += center->x;
a0.y += center->y;
a1.x += a0.x;
a1.y += a0.y;
for ( i = 1; i <= arcs; i++ )
{
step = total;
if ( step > FT_ARC_CUBIC_ANGLE )
step = FT_ARC_CUBIC_ANGLE;
/* compute end and second control point */
FT_Vector_From_Polar( &a3, radius,
angle_start + i * angle_diff / arcs );
a2.x = FT_MulFix( a3.y, coef );
a2.y = FT_MulFix( -a3.x, coef );
else if ( step < -FT_ARC_CUBIC_ANGLE )
step = -FT_ARC_CUBIC_ANGLE;
next = angle + step;
theta = step;
if ( theta < 0 )
theta = -theta;
theta >>= 1;
/* compute end point */
FT_Vector_From_Polar( &b, radius, next );
b.x += center->x;
b.y += center->y;
/* compute first and second control points */
length = FT_MulDiv( radius, FT_Sin( theta ) * 4,
( 0x10000L + FT_Cos( theta ) ) * 3 );
FT_Vector_From_Polar( &a2, length, angle + rotate );
a2.x += a.x;
a2.y += a.y;
FT_Vector_From_Polar( &b2, length, next - rotate );
b2.x += b.x;
b2.y += b.y;
a3.x += center->x;
a3.y += center->y;
a2.x += a3.x;
a2.y += a3.y;
/* add cubic arc */
error = ft_stroke_border_cubicto( border, &a2, &b2, &b );
error = ft_stroke_border_cubicto( border, &a1, &a2, &a3 );
if ( error )
break;
/* process the rest of the arc ?? */
a = b;
total -= step;
angle = next;
/* a0 = a3; */
a1.x = a3.x - a2.x + a3.x;
a1.y = a3.y - a2.y + a3.y;
}
return error;
@ -932,55 +922,40 @@
error = ft_stroker_arcto( stroker, side );
}
else if ( stroker->line_cap == FT_STROKER_LINECAP_SQUARE )
else
{
/* add a square cap */
FT_Vector delta, delta2;
FT_Angle rotate = FT_SIDE_TO_ROTATE( side );
/* add a square or butt cap */
FT_Vector middle, delta;
FT_Fixed radius = stroker->radius;
FT_StrokeBorder border = stroker->borders + side;
FT_Vector_From_Polar( &delta2, radius, angle + rotate );
FT_Vector_From_Polar( &delta, radius, angle );
/* compute middle point and first angle point */
FT_Vector_From_Polar( &middle, radius, angle );
delta.x = side ? middle.y : -middle.y;
delta.y = side ? -middle.x : middle.x;
delta.x += stroker->center.x + delta2.x;
delta.y += stroker->center.y + delta2.y;
if ( stroker->line_cap == FT_STROKER_LINECAP_SQUARE )
{
middle.x += stroker->center.x;
middle.y += stroker->center.y;
}
else /* FT_STROKER_LINECAP_BUTT */
{
middle.x = stroker->center.x;
middle.y = stroker->center.y;
}
delta.x += middle.x;
delta.y += middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
FT_Vector_From_Polar( &delta2, radius, angle - rotate );
FT_Vector_From_Polar( &delta, radius, angle );
delta.x += delta2.x + stroker->center.x;
delta.y += delta2.y + stroker->center.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
else if ( stroker->line_cap == FT_STROKER_LINECAP_BUTT )
{
/* add a butt ending */
FT_Vector delta;
FT_Angle rotate = FT_SIDE_TO_ROTATE( side );
FT_Fixed radius = stroker->radius;
FT_StrokeBorder border = stroker->borders + side;
FT_Vector_From_Polar( &delta, radius, angle + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
FT_Vector_From_Polar( &delta, radius, angle - rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
/* compute second angle point */
delta.x = middle.x - delta.x + middle.x;
delta.y = middle.y - delta.y + middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
@ -998,7 +973,8 @@
{
FT_StrokeBorder border = stroker->borders + side;
FT_Angle phi, theta, rotate;
FT_Fixed length, thcos;
FT_Fixed length;
FT_Vector sigma = { 0, 0 };
FT_Vector delta;
FT_Error error = FT_Err_Ok;
FT_Bool intersect; /* use intersection of lines? */
@ -1017,10 +993,13 @@
else
{
/* compute minimum required length of lines */
FT_Fixed min_length = ft_pos_abs( FT_MulFix( stroker->radius,
FT_Tan( theta ) ) );
FT_Fixed min_length;
FT_Vector_Unit( &sigma, theta );
min_length =
ft_pos_abs( FT_MulDiv( stroker->radius, sigma.y, sigma.x ) );
intersect = FT_BOOL( min_length &&
stroker->line_length >= min_length &&
line_length >= min_length );
@ -1038,13 +1017,11 @@
else
{
/* compute median angle */
phi = stroker->angle_in + theta;
phi = stroker->angle_in + theta + rotate;
thcos = FT_Cos( theta );
length = FT_DivFix( stroker->radius, sigma.x );
length = FT_DivFix( stroker->radius, thcos );
FT_Vector_From_Polar( &delta, length, phi + rotate );
FT_Vector_From_Polar( &delta, length, phi );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
}
@ -1071,10 +1048,10 @@
else
{
/* this is a mitered (pointed) or beveled (truncated) corner */
FT_Fixed sigma = 0, radius = stroker->radius;
FT_Angle theta = 0, phi = 0;
FT_Fixed thcos = 0;
FT_Bool bevel, fixed_bevel;
FT_Fixed radius = stroker->radius;
FT_Vector sigma = { 0, 0 };
FT_Angle theta = 0, phi = 0;
FT_Bool bevel, fixed_bevel;
rotate = FT_SIDE_TO_ROTATE( side );
@ -1085,26 +1062,20 @@
fixed_bevel =
FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_MITER_VARIABLE );
/* check miter limit first */
if ( !bevel )
{
theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out ) / 2;
if ( theta == FT_ANGLE_PI )
{
theta = rotate;
phi = stroker->angle_in;
}
else
{
theta /= 2;
phi = stroker->angle_in + theta + rotate;
}
if ( theta == FT_ANGLE_PI2 )
theta = -rotate;
thcos = FT_Cos( theta );
sigma = FT_MulFix( stroker->miter_limit, thcos );
phi = stroker->angle_in + theta + rotate;
FT_Vector_From_Polar( &sigma, stroker->miter_limit, theta );
/* is miter limit exceeded? */
if ( sigma < 0x10000L )
if ( sigma.x < 0x10000L )
{
/* don't create variable bevels for very small deviations; */
/* FT_Sin(x) = 0 for x <= 57 */
@ -1131,36 +1102,34 @@
border->movable = FALSE;
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
else /* variable bevel */
else /* variable bevel or clipped miter */
{
/* the miter is truncated */
FT_Vector middle, delta;
FT_Fixed length;
FT_Fixed coef;
/* compute middle point */
/* compute middle point and first angle point */
FT_Vector_From_Polar( &middle,
FT_MulFix( radius, stroker->miter_limit ),
phi );
coef = FT_DivFix( 0x10000L - sigma.x, sigma.y );
delta.x = FT_MulFix( middle.y, coef );
delta.y = FT_MulFix( -middle.x, coef );
middle.x += stroker->center.x;
middle.y += stroker->center.y;
/* compute first angle point */
length = FT_MulDiv( radius, 0x10000L - sigma,
ft_pos_abs( FT_Sin( theta ) ) );
FT_Vector_From_Polar( &delta, length, phi + rotate );
delta.x += middle.x;
delta.y += middle.y;
delta.x += middle.x;
delta.y += middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
/* compute second angle point */
FT_Vector_From_Polar( &delta, length, phi - rotate );
delta.x += middle.x;
delta.y += middle.y;
delta.x = middle.x - delta.x + middle.x;
delta.y = middle.y - delta.y + middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
@ -1187,7 +1156,7 @@
FT_Vector delta;
length = FT_DivFix( stroker->radius, thcos );
length = FT_MulDiv( stroker->radius, stroker->miter_limit, sigma.x );
FT_Vector_From_Polar( &delta, length, phi );
delta.x += stroker->center.x;
@ -1560,7 +1529,8 @@
stroker->angle_in = angle_out;
}
stroker->center = *to;
stroker->center = *to;
stroker->line_length = 0;
Exit:
return error;
@ -1776,7 +1746,8 @@
stroker->angle_in = angle_out;
}
stroker->center = *to;
stroker->center = *to;
stroker->line_length = 0;
Exit:
return error;
@ -1929,13 +1900,9 @@
}
else
{
FT_Angle turn;
FT_Int inside_side;
/* close the path if needed */
if ( stroker->center.x != stroker->subpath_start.x ||
stroker->center.y != stroker->subpath_start.y )
if ( !FT_IS_SMALL( stroker->center.x - stroker->subpath_start.x ) ||
!FT_IS_SMALL( stroker->center.y - stroker->subpath_start.y ) )
{
error = FT_Stroker_LineTo( stroker, &stroker->subpath_start );
if ( error )
@ -1944,29 +1911,11 @@
/* process the corner */
stroker->angle_out = stroker->subpath_angle;
turn = FT_Angle_Diff( stroker->angle_in,
stroker->angle_out );
/* no specific corner processing is required if the turn is 0 */
if ( turn != 0 )
{
/* when we turn to the right, the inside side is 0 */
/* otherwise, the inside side is 1 */
inside_side = ( turn < 0 );
error = ft_stroker_inside( stroker,
inside_side,
stroker->subpath_line_length );
if ( error )
goto Exit;
/* process the outside side */
error = ft_stroker_outside( stroker,
!inside_side,
stroker->subpath_line_length );
if ( error )
goto Exit;
}
error = ft_stroker_process_corner( stroker,
stroker->subpath_line_length );
if ( error )
goto Exit;
/* then end our two subpaths */
ft_stroke_border_close( stroker->borders + 0, FALSE );
@ -2087,8 +2036,8 @@
/* documentation is in ftstroke.h */
/*
* The following is very similar to FT_Outline_Decompose, except
* that we do support opened paths, and do not scale the outline.
* The following is very similar to FT_Outline_Decompose, except
* that we do support opened paths, and do not scale the outline.
*/
FT_EXPORT_DEF( FT_Error )
FT_Stroker_ParseOutline( FT_Stroker stroker,
@ -2306,17 +2255,12 @@
FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
/* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
FT_Library library = stroker->library;
FT_UNUSED( library );
if ( !pglyph )
goto Exit;
glyph = *pglyph;
if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
goto Exit;
{
@ -2386,17 +2330,12 @@
FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
/* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
FT_Library library = stroker->library;
FT_UNUSED( library );
if ( !pglyph )
goto Exit;
glyph = *pglyph;
if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
goto Exit;
{

View file

@ -1,37 +1,36 @@
/***************************************************************************/
/* */
/* ftsynth.c */
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
/* Copyright 2000-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftsynth.c
*
* FreeType synthesizing code for emboldening and slanting (body).
*
* Copyright (C) 2000-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_SYNTHESIS_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
#include <freetype/ftsynth.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/ftoutln.h>
#include <freetype/ftbitmap.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_synth
#define FT_COMPONENT synth
/*************************************************************************/
@ -46,6 +45,18 @@
FT_EXPORT_DEF( void )
FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
{
/* Value '0x0366A' corresponds to a shear angle of about 12 degrees. */
FT_GlyphSlot_Slant( slot, 0x0366A, 0 );
}
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
FT_GlyphSlot_Slant( FT_GlyphSlot slot,
FT_Fixed xslant,
FT_Fixed yslant )
{
FT_Matrix transform;
FT_Outline* outline;
@ -62,13 +73,11 @@
/* we don't touch the advance width */
/* For italic, simply apply a shear transform, with an angle */
/* of about 12 degrees. */
/* For italic, simply apply a shear transform */
transform.xx = 0x10000L;
transform.yx = 0x00000L;
transform.yx = -yslant;
transform.xy = 0x0366AL;
transform.xy = xslant;
transform.yy = 0x10000L;
FT_Outline_Transform( outline, &transform );
@ -130,7 +139,7 @@
if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
{
FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
FT_TRACE1(( "too strong emboldening parameter ystr=%d\n", ystr ));
FT_TRACE1(( "too strong emboldening parameter ystr=%ld\n", ystr ));
return;
}
error = FT_GlyphSlot_Own_Bitmap( slot );

View file

@ -1,70 +1,72 @@
/***************************************************************************/
/* */
/* ftsystem.c */
/* */
/* ANSI-specific FreeType low-level system interface (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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftsystem.c
*
* ANSI-specific FreeType low-level system interface (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.
*
*/
/*************************************************************************/
/* */
/* This file contains the default interface used by FreeType to access */
/* low-level, i.e. memory management, i/o access as well as thread */
/* synchronisation. It can be replaced by user-specific routines if */
/* necessary. */
/* */
/*************************************************************************/
/**************************************************************************
*
* This file contains the default interface used by FreeType to access
* low-level, i.e. memory management, i/o access as well as thread
* synchronisation. It can be replaced by user-specific routines if
* necessary.
*
*/
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_SYSTEM_H
#include FT_ERRORS_H
#include FT_TYPES_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/ftsystem.h>
#include <freetype/fterrors.h>
#include <freetype/fttypes.h>
/*************************************************************************/
/* */
/* MEMORY MANAGEMENT INTERFACE */
/* */
/*************************************************************************/
/**************************************************************************
*
* MEMORY MANAGEMENT INTERFACE
*
*/
/*************************************************************************/
/* */
/* It is not necessary to do any error checking for the */
/* allocation-related functions. This will be done by the higher level */
/* routines like ft_mem_alloc() or ft_mem_realloc(). */
/* */
/*************************************************************************/
/**************************************************************************
*
* It is not necessary to do any error checking for the
* allocation-related functions. This will be done by the higher level
* routines like ft_mem_alloc() or ft_mem_realloc().
*
*/
/*************************************************************************/
/* */
/* <Function> */
/* ft_alloc */
/* */
/* <Description> */
/* The memory allocation function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* size :: The requested size in bytes. */
/* */
/* <Return> */
/* The address of newly allocated block. */
/* */
/**************************************************************************
*
* @Function:
* ft_alloc
*
* @Description:
* The memory allocation function.
*
* @Input:
* memory ::
* A pointer to the memory object.
*
* size ::
* The requested size in bytes.
*
* @Return:
* The address of newly allocated block.
*/
FT_CALLBACK_DEF( void* )
ft_alloc( FT_Memory memory,
long size )
@ -75,26 +77,30 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_realloc */
/* */
/* <Description> */
/* The memory reallocation function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* cur_size :: The current size of the allocated memory block. */
/* */
/* new_size :: The newly requested size in bytes. */
/* */
/* block :: The current address of the block in memory. */
/* */
/* <Return> */
/* The address of the reallocated memory block. */
/* */
/**************************************************************************
*
* @Function:
* ft_realloc
*
* @Description:
* The memory reallocation function.
*
* @Input:
* memory ::
* A pointer to the memory object.
*
* cur_size ::
* The current size of the allocated memory block.
*
* new_size ::
* The newly requested size in bytes.
*
* block ::
* The current address of the block in memory.
*
* @Return:
* The address of the reallocated memory block.
*/
FT_CALLBACK_DEF( void* )
ft_realloc( FT_Memory memory,
long cur_size,
@ -108,19 +114,21 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_free */
/* */
/* <Description> */
/* The memory release function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* block :: The address of block in memory to be freed. */
/* */
/**************************************************************************
*
* @Function:
* ft_free
*
* @Description:
* The memory release function.
*
* @Input:
* memory ::
* A pointer to the memory object.
*
* block ::
* The address of block in memory to be freed.
*/
FT_CALLBACK_DEF( void )
ft_free( FT_Memory memory,
void* block )
@ -131,39 +139,40 @@
}
/*************************************************************************/
/* */
/* RESOURCE MANAGEMENT INTERFACE */
/* */
/*************************************************************************/
/**************************************************************************
*
* RESOURCE MANAGEMENT INTERFACE
*
*/
#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
/*************************************************************************/
/* */
/* 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_io
#define FT_COMPONENT io
/* We use the macro STREAM_FILE for convenience to extract the */
/* system-specific stream handle from a given FreeType stream object */
#define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer )
/*************************************************************************/
/* */
/* <Function> */
/* ft_ansi_stream_close */
/* */
/* <Description> */
/* The function to close a stream. */
/* */
/* <Input> */
/* stream :: A pointer to the stream object. */
/* */
/**************************************************************************
*
* @Function:
* ft_ansi_stream_close
*
* @Description:
* The function to close a stream.
*
* @Input:
* stream ::
* A pointer to the stream object.
*/
FT_CALLBACK_DEF( void )
ft_ansi_stream_close( FT_Stream stream )
{
@ -175,28 +184,32 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_ansi_stream_io */
/* */
/* <Description> */
/* The function to open a stream. */
/* */
/* <Input> */
/* stream :: A pointer to the stream object. */
/* */
/* offset :: The position in the data stream to start reading. */
/* */
/* buffer :: The address of buffer to store the read data. */
/* */
/* count :: The number of bytes to read from the stream. */
/* */
/* <Return> */
/* The number of bytes actually read. If `count' is zero (this is, */
/* the function is used for seeking), a non-zero return value */
/* indicates an error. */
/* */
/**************************************************************************
*
* @Function:
* ft_ansi_stream_io
*
* @Description:
* The function to open a stream.
*
* @Input:
* stream ::
* A pointer to the stream object.
*
* offset ::
* The position in the data stream to start reading.
*
* buffer ::
* The address of buffer to store the read data.
*
* count ::
* The number of bytes to read from the stream.
*
* @Return:
* The number of bytes actually read. If `count' is zero (this is,
* the function is used for seeking), a non-zero return value
* indicates an error.
*/
FT_CALLBACK_DEF( unsigned long )
ft_ansi_stream_io( FT_Stream stream,
unsigned long offset,
@ -262,7 +275,7 @@
stream->close = ft_ansi_stream_close;
FT_TRACE1(( "FT_Stream_Open:" ));
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
filepathname, stream->size ));
return FT_Err_Ok;

View file

@ -1,38 +1,37 @@
/***************************************************************************/
/* */
/* fttrigon.c */
/* */
/* FreeType trigonometric functions (body). */
/* */
/* 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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* fttrigon.c
*
* FreeType trigonometric functions (body).
*
* 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 is a fixed-point CORDIC implementation of trigonometric */
/* functions as well as transformations between Cartesian and polar */
/* coordinates. The angles are represented as 16.16 fixed-point values */
/* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that */
/* only vectors longer than 2^16*180/pi (or at least 22 bits) on a */
/* discrete Cartesian grid can have the same or better angular */
/* resolution. Therefore, to maintain this precision, some functions */
/* require an interim upscaling of the vectors, whereas others operate */
/* with 24-bit long vectors directly. */
/* */
/*************************************************************************/
/**************************************************************************
*
* This is a fixed-point CORDIC implementation of trigonometric
* functions as well as transformations between Cartesian and polar
* coordinates. The angles are represented as 16.16 fixed-point values
* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that
* only vectors longer than 2^16*180/pi (or at least 22 bits) on a
* discrete Cartesian grid can have the same or better angular
* resolution. Therefore, to maintain this precision, some functions
* require an interim upscaling of the vectors, whereas others operate
* with 24-bit long vectors directly.
*
*/
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CALC_H
#include FT_TRIGONOMETRY_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/fttrigon.h>
/* the Cordic shrink factor 0.858785336480436 * 2^32 */
@ -54,7 +53,7 @@
};
#ifdef FT_LONG64
#ifdef FT_INT64
/* multiply a given value by the CORDIC shrink factor */
static FT_Fixed
@ -77,7 +76,7 @@
return s < 0 ? -val : val;
}
#else /* !FT_LONG64 */
#else /* !FT_INT64 */
/* multiply a given value by the CORDIC shrink factor */
static FT_Fixed
@ -126,7 +125,7 @@
return s < 0 ? -val : val;
}
#endif /* !FT_LONG64 */
#endif /* !FT_INT64 */
/* undefined and never called for zero vector */
@ -325,10 +324,10 @@
FT_EXPORT_DEF( FT_Fixed )
FT_Tan( FT_Angle angle )
{
FT_Vector v;
FT_Vector v = { 1 << 24, 0 };
FT_Vector_Unit( &v, angle );
ft_trig_pseudo_rotate( &v, angle );
return FT_DivFix( v.y, v.x );
}
@ -372,14 +371,6 @@
}
/* these macros return 0 for positive numbers,
and -1 for negative ones */
#define FT_SIGN_LONG( x ) ( (x) >> ( FT_SIZEOF_LONG * 8 - 1 ) )
#define FT_SIGN_INT( x ) ( (x) >> ( FT_SIZEOF_INT * 8 - 1 ) )
#define FT_SIGN_INT32( x ) ( (x) >> 31 )
#define FT_SIGN_INT16( x ) ( (x) >> 15 )
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( void )
@ -408,8 +399,8 @@
FT_Int32 half = (FT_Int32)1L << ( shift - 1 );
vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift;
vec->y = ( v.y + half + FT_SIGN_LONG( v.y ) ) >> shift;
vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift;
vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift;
}
else
{

View file

@ -1,26 +1,25 @@
/***************************************************************************/
/* */
/* fttype1.c */
/* */
/* FreeType utility file for PS names support (body). */
/* */
/* Copyright 2002-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* fttype1.c
*
* FreeType utility file for PS names support (body).
*
* Copyright (C) 2002-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 FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_SERVICE_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftserv.h>
#include <freetype/internal/services/svpsinfo.h>
/* documentation is in t1tables.h */

View file

@ -1,36 +1,35 @@
/***************************************************************************/
/* */
/* ftutil.c */
/* */
/* FreeType utility file for memory and list management (body). */
/* */
/* Copyright 2002-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftutil.c
*
* FreeType utility file for memory and list management (body).
*
* Copyright (C) 2002-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 FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_OBJECTS_H
#include FT_LIST_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/ftlist.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_memory
#define FT_COMPONENT memory
/*************************************************************************/
@ -54,7 +53,7 @@
FT_Error error;
FT_Pointer block = ft_mem_qalloc( memory, size, &error );
if ( !error && size > 0 )
if ( !error && block && size > 0 )
FT_MEM_ZERO( block, size );
*p_error = error;
@ -101,7 +100,7 @@
block = ft_mem_qrealloc( memory, item_size,
cur_count, new_count, block, &error );
if ( !error && new_count > cur_count )
if ( !error && block && new_count > cur_count )
FT_MEM_ZERO( (char*)block + cur_count * item_size,
( new_count - cur_count ) * item_size );
@ -185,7 +184,7 @@
FT_Pointer p = ft_mem_qalloc( memory, (FT_Long)size, &error );
if ( !error && address )
if ( !error && address && size > 0 )
ft_memcpy( p, address, size );
*p_error = error;
@ -236,7 +235,7 @@
/*************************************************************************/
#undef FT_COMPONENT
#define FT_COMPONENT trace_list
#define FT_COMPONENT list
/* documentation is in ftlist.h */

View file

@ -4,7 +4,7 @@
/* */
/* FreeType VERSIONINFO resource for Windows DLLs. */
/* */
/* Copyright 2018 by */
/* Copyright (C) 2018-2023 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -18,8 +18,8 @@
#include<windows.h>
#define FT_VERSION 2,9,1,0
#define FT_VERSION_STR "2.9.1"
#define FT_VERSION 2,13,0,0
#define FT_VERSION_STR "2.13.0"
VS_VERSION_INFO VERSIONINFO
FILEVERSION FT_VERSION
@ -28,7 +28,7 @@ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#endif
#ifdef _DLL
#ifdef DLL_EXPORT
FILETYPE VFT_DLL
#define FT_FILENAME "freetype.dll"
#else
@ -38,14 +38,14 @@ FILETYPE VFT_STATIC_LIB
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "The FreeType Project"
VALUE "FileDescription", "Font Rendering Library"
VALUE "FileVersion", FT_VERSION_STR
VALUE "ProductName", "FreeType"
VALUE "ProductVersion", FT_VERSION_STR
VALUE "LegalCopyright", "\251 2018 The FreeType Project www.freetype.org. All rights reserved."
VALUE "LegalCopyright", L"\x00A9 2000-2023 The FreeType Project www.freetype.org. All rights reserved."
VALUE "InternalName", "freetype"
VALUE "OriginalFilename", FT_FILENAME
END
@ -56,6 +56,6 @@ BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a "language,codepage" combination supported by the file. */
VALUE "Translation", 0x409, 1252
VALUE "Translation", 0x409, 1200
END
END

View file

@ -1,26 +1,25 @@
/***************************************************************************/
/* */
/* ftwinfnt.c */
/* */
/* FreeType API for accessing Windows FNT specific info (body). */
/* */
/* Copyright 2003-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. */
/* */
/***************************************************************************/
/****************************************************************************
*
* ftwinfnt.c
*
* FreeType API for accessing Windows FNT specific info (body).
*
* Copyright (C) 2003-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 FT_WINFONTS_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_WINFNT_H
#include <freetype/internal/ftdebug.h>
#include <freetype/ftwinfnt.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svwinfnt.h>
/* documentation is in ftwinfnt.h */

View file

@ -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,
@ -36,17 +36,17 @@ BASE_COMPILE := $(CC) $(ANSIFLAGS) \
# All files listed here should be included in `ftbase.c' (for a `single'
# build).
#
BASE_SRC := $(BASE_DIR)/basepic.c \
$(BASE_DIR)/ftadvanc.c \
BASE_SRC := $(BASE_DIR)/ftadvanc.c \
$(BASE_DIR)/ftcalc.c \
$(BASE_DIR)/ftcolor.c \
$(BASE_DIR)/ftdbgmem.c \
$(BASE_DIR)/fterrors.c \
$(BASE_DIR)/ftfntfmt.c \
$(BASE_DIR)/ftgloadr.c \
$(BASE_DIR)/fthash.c \
$(BASE_DIR)/ftlcdfil.c \
$(BASE_DIR)/ftobjs.c \
$(BASE_DIR)/ftoutln.c \
$(BASE_DIR)/ftpic.c \
$(BASE_DIR)/ftpsprop.c \
$(BASE_DIR)/ftrfork.c \
$(BASE_DIR)/ftsnames.c \
@ -60,8 +60,7 @@ ifneq ($(ftmac_c),)
endif
# for simplicity, we also handle `md5.c' (which gets included by `ftobjs.h')
BASE_H := $(BASE_DIR)/basepic.h \
$(BASE_DIR)/ftbase.h \
BASE_H := $(BASE_DIR)/ftbase.h \
$(BASE_DIR)/md5.c \
$(BASE_DIR)/md5.h

View file

@ -1,31 +0,0 @@
# FreeType 2 src/bdf Jamfile
#
# Copyright 2002-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) bdf ;
{
local _sources ;
if $(FT2_MULTI)
{
_sources = bdfdrivr
bdflib
;
}
else
{
_sources = bdf ;
}
Library $(FT2_LIB) : $(_sources).c ;
}
# end of src/bdf Jamfile

View file

@ -13,7 +13,7 @@ This code implements a BDF driver for the FreeType library, following the
Adobe Specification V 2.2. The specification of the BDF font format is
available from Adobe's web site:
https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5005.BDF_Spec.pdf
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5005.BDF_Spec.pdf
Many good bitmap fonts in bdf format come with XFree86 (www.XFree86.org).
They do not define vertical metrics, because the X Consortium BDF
@ -23,6 +23,10 @@ specification has removed them.
Encodings
*********
[This section is out of date, retained for historical reasons. BDF
properties can be retrieved with `FT_Get_BDF_Property`, character set ID
values with `FT_Get_BDF_Charset_ID`.]
The variety of encodings that accompanies bdf fonts appears to encompass the
small set defined in freetype.h. On the other hand, two properties that
specify encoding and registry are usually defined in bdf fonts.

View file

@ -26,7 +26,6 @@ THE SOFTWARE.
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "bdflib.c"
#include "bdfdrivr.c"

View file

@ -30,10 +30,9 @@
* Based on bdf.h,v 1.16 2000/03/16 20:08:51 mleisher
*/
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_HASH_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/fthash.h>
FT_BEGIN_HEADER
@ -51,11 +50,11 @@ FT_BEGIN_HEADER
/* end of bdfP.h */
/*************************************************************************/
/* */
/* BDF font options macros and types. */
/* */
/*************************************************************************/
/**************************************************************************
*
* BDF font options macros and types.
*
*/
#define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */
@ -93,11 +92,11 @@ FT_BEGIN_HEADER
void* client_data );
/*************************************************************************/
/* */
/* BDF font property macros and types. */
/* */
/*************************************************************************/
/**************************************************************************
*
* BDF font property macros and types.
*
*/
#define BDF_ATOM 1
@ -109,9 +108,9 @@ FT_BEGIN_HEADER
/* There are a set of defaults and each font has their own. */
typedef struct bdf_property_t_
{
char* name; /* Name of the property. */
int format; /* Format of the property. */
int builtin; /* A builtin property. */
const char* name; /* Name of the property. */
int format; /* Format of the property. */
int builtin; /* A builtin property. */
union
{
char* atom;
@ -123,11 +122,11 @@ FT_BEGIN_HEADER
} bdf_property_t;
/*************************************************************************/
/* */
/* BDF font metric and glyph types. */
/* */
/*************************************************************************/
/**************************************************************************
*
* BDF font metric and glyph types.
*
*/
typedef struct bdf_bbx_t_
@ -147,7 +146,7 @@ FT_BEGIN_HEADER
typedef struct bdf_glyph_t_
{
char* name; /* Glyph name. */
long encoding; /* Glyph encoding. */
unsigned long encoding; /* Glyph encoding. */
unsigned short swidth; /* Scalable width. */
unsigned short dwidth; /* Device width. */
bdf_bbx_t bbx; /* Glyph bounding box. */
@ -158,20 +157,6 @@ FT_BEGIN_HEADER
} bdf_glyph_t;
typedef struct bdf_glyphlist_t_
{
unsigned short pad; /* Pad to 4-byte boundary. */
unsigned short bpp; /* Bits per pixel. */
long start; /* Beginning encoding value of glyphs. */
long end; /* Ending encoding value of glyphs. */
bdf_glyph_t* glyphs; /* Glyphs themselves. */
unsigned long glyphs_size; /* Glyph structures allocated. */
unsigned long glyphs_used; /* Glyph structures used. */
bdf_bbx_t bbx; /* Overall bounding box of glyphs. */
} bdf_glyphlist_t;
typedef struct bdf_font_t_
{
char* name; /* Name of the font. */
@ -185,7 +170,7 @@ FT_BEGIN_HEADER
unsigned short monowidth; /* Logical width for monowidth font. */
long default_char; /* Encoding of the default glyph. */
unsigned long default_char; /* Encoding of the default glyph. */
long font_ascent; /* Font ascent. */
long font_descent; /* Font descent. */
@ -205,16 +190,8 @@ FT_BEGIN_HEADER
char* comments; /* Font comments. */
unsigned long comments_len; /* Length of comment string. */
bdf_glyphlist_t overflow; /* Storage used for glyph insertion. */
void* internal; /* Internal data for the font. */
/* The size of the next two arrays must be in sync with the */
/* size of the `have' array in the `bdf_parse_t' structure. */
unsigned long nmod[34816]; /* Bitmap indicating modified glyphs. */
unsigned long umod[34816]; /* Bitmap indicating modified */
/* unencoded glyphs. */
unsigned short modified; /* Boolean indicating font modified. */
unsigned short bpp; /* Bits per pixel. */
FT_Memory memory;
@ -226,11 +203,11 @@ FT_BEGIN_HEADER
} bdf_font_t;
/*************************************************************************/
/* */
/* Types for load/save callbacks. */
/* */
/*************************************************************************/
/**************************************************************************
*
* Types for load/save callbacks.
*
*/
/* Error codes. */
@ -247,11 +224,11 @@ FT_BEGIN_HEADER
#define BDF_INVALID_LINE -100
/*************************************************************************/
/* */
/* BDF font API. */
/* */
/*************************************************************************/
/**************************************************************************
*
* BDF font API.
*
*/
FT_LOCAL( FT_Error )
bdf_load_font( FT_Stream stream,

View file

@ -24,16 +24,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H
#include FT_BDF_H
#include FT_TRUETYPE_IDS_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/ftbdf.h>
#include <freetype/ttnameid.h>
#include FT_SERVICE_BDF_H
#include FT_SERVICE_FONT_FORMAT_H
#include <freetype/internal/services/svbdf.h>
#include <freetype/internal/services/svfntfmt.h>
#include "bdf.h"
#include "bdfdrivr.h"
@ -41,14 +40,14 @@ THE SOFTWARE.
#include "bdferror.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_bdfdriver
#define FT_COMPONENT bdfdriver
typedef struct BDF_CMapRec_
@ -93,21 +92,18 @@ THE SOFTWARE.
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings;
FT_ULong min, max, mid; /* num_encodings */
FT_UShort result = 0; /* encodings->glyph */
FT_ULong min = 0;
FT_ULong max = cmap->num_encodings;
FT_ULong mid = ( min + max ) >> 1;
min = 0;
max = cmap->num_encodings;
while ( min < max )
{
FT_ULong code;
FT_ULong code = encodings[mid].enc;
mid = ( min + max ) >> 1;
code = (FT_ULong)encodings[mid].enc;
if ( charcode == code )
{
/* increase glyph index by 1 -- */
@ -120,6 +116,11 @@ THE SOFTWARE.
max = mid;
else
min = mid + 1;
/* reasonable prediction in a continuous block */
mid += charcode - code;
if ( mid >= max || mid < min )
mid = ( min + max ) >> 1;
}
return result;
@ -132,22 +133,19 @@ THE SOFTWARE.
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings;
FT_ULong min, max, mid; /* num_encodings */
FT_UShort result = 0; /* encodings->glyph */
FT_ULong charcode = *acharcode + 1;
FT_ULong min = 0;
FT_ULong max = cmap->num_encodings;
FT_ULong mid = ( min + max ) >> 1;
min = 0;
max = cmap->num_encodings;
while ( min < max )
{
FT_ULong code; /* same as BDF_encoding_el.enc */
FT_ULong code = encodings[mid].enc;
mid = ( min + max ) >> 1;
code = (FT_ULong)encodings[mid].enc;
if ( charcode == code )
{
/* increase glyph index by 1 -- */
@ -160,19 +158,25 @@ THE SOFTWARE.
max = mid;
else
min = mid + 1;
/* prediction in a continuous block */
mid += charcode - code;
if ( mid >= max || mid < min )
mid = ( min + max ) >> 1;
}
charcode = 0;
if ( min < cmap->num_encodings )
{
charcode = (FT_ULong)encodings[min].enc;
charcode = encodings[min].enc;
result = encodings[min].glyph + 1;
}
Exit:
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "bdf_cmap_char_next: charcode 0x%x > 32bit API" ));
FT_TRACE1(( "bdf_cmap_char_next: charcode 0x%lx > 32bit API",
charcode ));
*acharcode = 0;
/* XXX: result should be changed to indicate an overflow error */
}
@ -204,13 +208,13 @@ THE SOFTWARE.
bdf_font_t* font = bdf->bdffont;
bdf_property_t* prop;
char* strings[4] = { NULL, NULL, NULL, NULL };
size_t nn, len, lengths[4];
const char* strings[4] = { NULL, NULL, NULL, NULL };
size_t lengths[4], nn, len;
face->style_flags = 0;
prop = bdf_get_font_property( font, (char *)"SLANT" );
prop = bdf_get_font_property( font, "SLANT" );
if ( prop && prop->format == BDF_ATOM &&
prop->value.atom &&
( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||
@ -218,30 +222,30 @@ THE SOFTWARE.
{
face->style_flags |= FT_STYLE_FLAG_ITALIC;
strings[2] = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
? (char *)"Oblique"
: (char *)"Italic";
? "Oblique"
: "Italic";
}
prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" );
prop = bdf_get_font_property( font, "WEIGHT_NAME" );
if ( prop && prop->format == BDF_ATOM &&
prop->value.atom &&
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
{
face->style_flags |= FT_STYLE_FLAG_BOLD;
strings[1] = (char *)"Bold";
strings[1] = "Bold";
}
prop = bdf_get_font_property( font, (char *)"SETWIDTH_NAME" );
prop = bdf_get_font_property( font, "SETWIDTH_NAME" );
if ( prop && prop->format == BDF_ATOM &&
prop->value.atom && *(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
strings[3] = (char *)(prop->value.atom);
strings[3] = (const char *)(prop->value.atom);
prop = bdf_get_font_property( font, (char *)"ADD_STYLE_NAME" );
prop = bdf_get_font_property( font, "ADD_STYLE_NAME" );
if ( prop && prop->format == BDF_ATOM &&
prop->value.atom && *(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
strings[0] = (char *)(prop->value.atom);
strings[0] = (const char *)(prop->value.atom);
for ( len = 0, nn = 0; nn < 4; nn++ )
{
@ -255,7 +259,7 @@ THE SOFTWARE.
if ( len == 0 )
{
strings[0] = (char *)"Regular";
strings[0] = "Regular";
lengths[0] = ft_strlen( strings[0] );
len = lengths[0] + 1;
}
@ -264,14 +268,14 @@ THE SOFTWARE.
char* s;
if ( FT_ALLOC( face->style_name, len ) )
if ( FT_QALLOC( face->style_name, len ) )
return error;
s = face->style_name;
for ( nn = 0; nn < 4; nn++ )
{
char* src = strings[nn];
const char* src = strings[nn];
len = lengths[nn];
@ -390,10 +394,10 @@ THE SOFTWARE.
bdf_property_t* prop = NULL;
FT_TRACE4(( " number of glyphs: allocated %d (used %d)\n",
FT_TRACE4(( " number of glyphs: allocated %ld (used %ld)\n",
font->glyphs_size,
font->glyphs_used ));
FT_TRACE4(( " number of unencoded glyphs: allocated %d (used %d)\n",
FT_TRACE4(( " number of unencoded glyphs: allocated %ld (used %ld)\n",
font->unencoded_size,
font->unencoded_used ));
@ -401,8 +405,7 @@ THE SOFTWARE.
bdfface->face_index = 0;
bdfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_FAST_GLYPHS;
FT_FACE_FLAG_HORIZONTAL;
prop = bdf_get_font_property( font, "SPACING" );
if ( prop && prop->format == BDF_ATOM &&
@ -431,7 +434,7 @@ THE SOFTWARE.
bdfface->num_glyphs = (FT_Long)( font->glyphs_size + 1 );
bdfface->num_fixed_sizes = 1;
if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
if ( FT_NEW( bdfface->available_sizes ) )
goto Exit;
{
@ -440,19 +443,17 @@ THE SOFTWARE.
long value;
FT_ZERO( bsize );
/* sanity checks */
if ( font->font_ascent > 0x7FFF || font->font_ascent < -0x7FFF )
{
font->font_ascent = font->font_ascent < 0 ? -0x7FFF : 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping font ascent to value %d\n",
FT_TRACE0(( "BDF_Face_Init: clamping font ascent to value %ld\n",
font->font_ascent ));
}
if ( font->font_descent > 0x7FFF || font->font_descent < -0x7FFF )
{
font->font_descent = font->font_descent < 0 ? -0x7FFF : 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping font descent to value %d\n",
FT_TRACE0(( "BDF_Face_Init: clamping font descent to value %ld\n",
font->font_descent ));
}
@ -478,7 +479,7 @@ THE SOFTWARE.
else
{
/* this is a heuristical value */
bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 );
bsize->width = ( bsize->height * 2 + 1 ) / 3;
}
prop = bdf_get_font_property( font, "POINT_SIZE" );
@ -493,7 +494,7 @@ THE SOFTWARE.
prop->value.l < -0x504C2L )
{
bsize->size = 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n",
FT_TRACE0(( "BDF_Face_Init: clamping point size to value %ld\n",
bsize->size ));
}
else
@ -506,7 +507,7 @@ THE SOFTWARE.
if ( font->point_size > 0x7FFF )
{
bsize->size = 0x7FFF;
FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n",
FT_TRACE0(( "BDF_Face_Init: clamping point size to value %ld\n",
bsize->size ));
}
else
@ -528,7 +529,7 @@ THE SOFTWARE.
if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF )
{
bsize->y_ppem = 0x7FFF << 6;
FT_TRACE0(( "BDF_Face_Init: clamping pixel size to value %d\n",
FT_TRACE0(( "BDF_Face_Init: clamping pixel size to value %ld\n",
bsize->y_ppem ));
}
else
@ -597,14 +598,14 @@ THE SOFTWARE.
unsigned long n;
if ( FT_NEW_ARRAY( face->en_table, font->glyphs_size ) )
if ( FT_QNEW_ARRAY( face->en_table, font->glyphs_size ) )
goto Exit;
face->default_glyph = 0;
for ( n = 0; n < font->glyphs_size; n++ )
{
(face->en_table[n]).enc = cur[n].encoding;
FT_TRACE4(( " idx %d, val 0x%lX\n", n, cur[n].encoding ));
FT_TRACE4(( " idx %ld, val 0x%lX\n", n, cur[n].encoding ));
(face->en_table[n]).glyph = (FT_UShort)n;
if ( cur[n].encoding == font->default_char )
@ -613,7 +614,7 @@ THE SOFTWARE.
face->default_glyph = (FT_UInt)n;
else
FT_TRACE1(( "BDF_Face_Init:"
" idx %d is too large for this system\n", n ));
" idx %ld is too large for this system\n", n ));
}
}
}
@ -814,7 +815,7 @@ THE SOFTWARE.
bitmap->rows = glyph.bbx.height;
bitmap->width = glyph.bbx.width;
if ( glyph.bpr > FT_INT_MAX )
FT_TRACE1(( "BDF_Glyph_Load: too large pitch %d is truncated\n",
FT_TRACE1(( "BDF_Glyph_Load: too large pitch %ld is truncated\n",
glyph.bpr ));
bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */
@ -863,7 +864,7 @@ THE SOFTWARE.
/*
*
* BDF SERVICE
* BDF SERVICE
*
*/
@ -891,7 +892,8 @@ THE SOFTWARE.
if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
{
FT_TRACE1(( "bdf_get_bdf_property:"
" too large integer 0x%x is truncated\n" ));
" too large integer 0x%lx is truncated\n",
prop->value.l ));
}
aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
aproperty->u.integer = (FT_Int32)prop->value.l;
@ -901,7 +903,8 @@ THE SOFTWARE.
if ( prop->value.ul > 0xFFFFFFFFUL )
{
FT_TRACE1(( "bdf_get_bdf_property:"
" too large cardinal 0x%x is truncated\n" ));
" too large cardinal 0x%lx is truncated\n",
prop->value.ul ));
}
aproperty->type = BDF_PROPERTY_TYPE_CARDINAL;
aproperty->u.cardinal = (FT_UInt32)prop->value.ul;
@ -939,7 +942,7 @@ THE SOFTWARE.
/*
*
* SERVICES LIST
* SERVICES LIST
*
*/

View file

@ -28,22 +28,17 @@ THE SOFTWARE.
#ifndef BDFDRIVR_H_
#define BDFDRIVR_H_
#include <ft2build.h>
#include FT_INTERNAL_DRIVER_H
#include <freetype/internal/ftdrv.h>
#include "bdf.h"
FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_PIC
#error "this module does not support PIC yet"
#endif
typedef struct BDF_encoding_el_
{
FT_Long enc;
FT_ULong enc;
FT_UShort glyph;
} BDF_encoding_el;
@ -60,9 +55,6 @@ FT_BEGIN_HEADER
BDF_encoding_el* en_table;
FT_CharMap charmap_handle;
FT_CharMapRec charmap; /* a single charmap per face */
FT_UInt default_glyph;
} BDF_FaceRec, *BDF_Face;

Some files were not shown because too many files have changed in this diff Show more