Werner Lemberg pushed to branch wl/pkgconfig-static at FreeType / FreeType
Commits:
-
22a0cccb
by Werner Lemberg at 2022-03-19T06:40:17+01:00
-
7789f2bb
by Ben Wagner at 2022-03-19T06:20:53+00:00
-
d014387a
by Werner Lemberg at 2022-03-19T09:30:45+01:00
-
0c2bdb01
by Werner Lemberg at 2022-03-19T09:37:28+01:00
-
d2c3bbcd
by Werner Lemberg at 2022-03-19T19:31:25+01:00
-
a960be9e
by Ben Wagner at 2022-03-20T07:27:43+00:00
-
fc15ebe0
by Werner Lemberg at 2022-03-21T11:17:28+01:00
-
0574692c
by Steve Lhomme at 2022-03-23T22:46:15-04:00
-
127c1e83
by Carlo Bramini at 2022-03-23T22:53:07-04:00
-
06727a52
by Werner Lemberg at 2022-03-25T06:37:41+00:00
-
907715a6
by Werner Lemberg at 2022-03-25T06:37:41+00:00
-
ac4c1ebf
by Werner Lemberg at 2022-03-25T06:37:41+00:00
-
1949a7ec
by Werner Lemberg at 2022-03-25T06:37:41+00:00
-
a8e4563c
by Werner Lemberg at 2022-03-25T06:37:41+00:00
-
119e404b
by Werner Lemberg at 2022-03-30T18:20:34+00:00
16 changed files:
- builds/unix/configure.raw
- builds/unix/freetype2.in
- builds/unix/unix-def.in
- builds/windows/ftsystem.c
- include/freetype/freetype.h
- include/freetype/ftimage.h
- include/freetype/ftparams.h
- src/base/ftobjs.c
- src/cff/cffgload.c
- src/sfnt/sfobjs.c
- src/sfnt/sfwoff2.c
- src/sfnt/sfwoff2.h
- src/sfnt/ttkern.c
- src/sfnt/ttsbit.c
- src/truetype/ttgload.c
- src/truetype/ttobjs.c
Changes:
... | ... | @@ -985,32 +985,32 @@ fi |
985 | 985 | |
986 | 986 | |
987 | 987 | # entries in Requires.private are separated by commas
|
988 | -REQUIRES_PRIVATE="$zlib_reqpriv, \
|
|
989 | - $bzip2_reqpriv, \
|
|
990 | - $libpng_reqpriv, \
|
|
991 | - $harfbuzz_reqpriv, \
|
|
992 | - $brotli_reqpriv"
|
|
988 | +PKGCONFIG_REQUIRES_PRIVATE="$zlib_reqpriv, \
|
|
989 | + $bzip2_reqpriv, \
|
|
990 | + $libpng_reqpriv, \
|
|
991 | + $harfbuzz_reqpriv, \
|
|
992 | + $brotli_reqpriv"
|
|
993 | 993 | # beautify
|
994 | -REQUIRES_PRIVATE=`echo "$REQUIRES_PRIVATE" \
|
|
995 | - | sed -e 's/^ *//' \
|
|
996 | - -e 's/ *$//' \
|
|
997 | - -e 's/, */,/g' \
|
|
998 | - -e 's/,,*/,/g' \
|
|
999 | - -e 's/^,*//' \
|
|
1000 | - -e 's/,*$//' \
|
|
1001 | - -e 's/,/, /g'`
|
|
1002 | - |
|
1003 | -LIBS_PRIVATE="$zlib_libspriv \
|
|
1004 | - $bzip2_libspriv \
|
|
1005 | - $libpng_libspriv \
|
|
1006 | - $harfbuzz_libspriv \
|
|
1007 | - $brotli_libspriv \
|
|
1008 | - $ft2_extra_libs"
|
|
994 | +PKGCONFIG_REQUIRES_PRIVATE=`echo "$PKGCONFIG_REQUIRES_PRIVATE" \
|
|
995 | + | sed -e 's/^ *//' \
|
|
996 | + -e 's/ *$//' \
|
|
997 | + -e 's/, */,/g' \
|
|
998 | + -e 's/,,*/,/g' \
|
|
999 | + -e 's/^,*//' \
|
|
1000 | + -e 's/,*$//' \
|
|
1001 | + -e 's/,/, /g'`
|
|
1002 | + |
|
1003 | +PKGCONFIG_LIBS_PRIVATE="$zlib_libspriv \
|
|
1004 | + $bzip2_libspriv \
|
|
1005 | + $libpng_libspriv \
|
|
1006 | + $harfbuzz_libspriv \
|
|
1007 | + $brotli_libspriv \
|
|
1008 | + $ft2_extra_libs"
|
|
1009 | 1009 | # beautify
|
1010 | -LIBS_PRIVATE=`echo "$LIBS_PRIVATE" \
|
|
1011 | - | sed -e 's/^ *//' \
|
|
1012 | - -e 's/ *$//' \
|
|
1013 | - -e 's/ */ /g'`
|
|
1010 | +PKGCONFIG_LIBS_PRIVATE=`echo "$PKGCONFIG_LIBS_PRIVATE" \
|
|
1011 | + | sed -e 's/^ *//' \
|
|
1012 | + -e 's/ *$//' \
|
|
1013 | + -e 's/ */ /g'`
|
|
1014 | 1014 | |
1015 | 1015 | LIBSSTATIC_CONFIG="-lfreetype \
|
1016 | 1016 | $zlib_libsstaticconf \
|
... | ... | @@ -1028,10 +1028,28 @@ LIBSSTATIC_CONFIG=`echo "$LIBSSTATIC_CONFIG" \ |
1028 | 1028 | -e 's/ *$//' \
|
1029 | 1029 | -e 's/ */ /g'`
|
1030 | 1030 | |
1031 | +# If FreeType gets installed with `--disable-shared', don't use
|
|
1032 | +# 'private' fields. `pkg-config' only looks into `.pc' files and is
|
|
1033 | +# completely agnostic to whether shared libraries are actually present
|
|
1034 | +# or not. As a consequence, the user had to specify `--static' while
|
|
1035 | +# calling `pkg-config', which configure scripts are normally not
|
|
1036 | +# prepared for.
|
|
1037 | + |
|
1038 | +PKGCONFIG_REQUIRES=
|
|
1039 | +PKGCONFIG_LIBS='-L${libdir} -lfreetype'
|
|
1040 | + |
|
1041 | +if test $enable_shared = "no"; then
|
|
1042 | + PKGCONFIG_REQUIRES="$PKGCONFIG_REQUIRES $PKGCONFIG_REQUIRES_PRIVATE"
|
|
1043 | + PKGCONFIG_REQUIRES_PRIVATE=
|
|
1044 | + PKGCONFIG_LIBS="$PKGCONFIG_LIBS $PKGCONFIG_LIBS_PRIVATE"
|
|
1045 | + PKGCONFIG_LIBS_PRIVATE=
|
|
1046 | +fi
|
|
1031 | 1047 | |
1032 | 1048 | AC_SUBST([ftmac_c])
|
1033 | -AC_SUBST([REQUIRES_PRIVATE])
|
|
1034 | -AC_SUBST([LIBS_PRIVATE])
|
|
1049 | +AC_SUBST([PKGCONFIG_REQUIRES])
|
|
1050 | +AC_SUBST([PKGCONFIG_LIBS])
|
|
1051 | +AC_SUBST([PKGCONFIG_REQUIRES_PRIVATE])
|
|
1052 | +AC_SUBST([PKGCONFIG_LIBS_PRIVATE])
|
|
1035 | 1053 | AC_SUBST([LIBSSTATIC_CONFIG])
|
1036 | 1054 | |
1037 | 1055 | AC_SUBST([hardcode_libdir_flag_spec])
|
... | ... | @@ -7,8 +7,8 @@ Name: FreeType 2 |
7 | 7 | URL: https://freetype.org
|
8 | 8 | Description: A free, high-quality, and portable font engine.
|
9 | 9 | Version: %ft_version%
|
10 | -Requires:
|
|
11 | -Requires.private: %REQUIRES_PRIVATE%
|
|
12 | -Libs: -L${libdir} -lfreetype
|
|
13 | -Libs.private: %LIBS_PRIVATE%
|
|
10 | +Requires: %PKGCONFIG_REQUIRES%
|
|
11 | +Requires.private: %PKGCONFIG_REQUIRES_PRIVATE%
|
|
12 | +Libs: %PKGCONFIG_LIBS%
|
|
13 | +Libs.private: %PKGCONFIG_LIBS_PRIVATE%
|
|
14 | 14 | Cflags: -I${includedir}/freetype2 |
... | ... | @@ -68,12 +68,14 @@ version_info := @version_info@ |
68 | 68 | |
69 | 69 | # Variables needed for `freetype-config' and `freetype.pc'.
|
70 | 70 | #
|
71 | -PKG_CONFIG := @PKG_CONFIG@
|
|
72 | -REQUIRES_PRIVATE := @REQUIRES_PRIVATE@
|
|
73 | -LIBS_PRIVATE := @LIBS_PRIVATE@
|
|
74 | -LIBSSTATIC_CONFIG := @LIBSSTATIC_CONFIG@
|
|
75 | -build_libtool_libs := @build_libtool_libs@
|
|
76 | -ft_version := @ft_version@
|
|
71 | +PKG_CONFIG := @PKG_CONFIG@
|
|
72 | +PKGCONFIG_REQUIRES := @PKGCONFIG_REQUIRES@
|
|
73 | +PKGCONFIG_REQUIRES_PRIVATE := @PKGCONFIG_REQUIRES_PRIVATE@
|
|
74 | +PKGCONFIG_LIBS := @PKGCONFIG_LIBS@
|
|
75 | +PKGCONFIG_LIBS_PRIVATE := @PKGCONFIG_LIBS_PRIVATE@
|
|
76 | +LIBSSTATIC_CONFIG := @LIBSSTATIC_CONFIG@
|
|
77 | +build_libtool_libs := @build_libtool_libs@
|
|
78 | +ft_version := @ft_version@
|
|
77 | 79 | |
78 | 80 | # The directory where all library files are placed.
|
79 | 81 | #
|
... | ... | @@ -137,15 +139,17 @@ prefix_x := $(subst $(space),\\$(space),$(prefix)) |
137 | 139 | |
138 | 140 | $(OBJ_BUILD)/freetype2.pc: $(TOP_DIR)/builds/unix/freetype2.in
|
139 | 141 | rm -f $@ $@.tmp
|
140 | - sed -e 's|%REQUIRES_PRIVATE%|$(REQUIRES_PRIVATE)|' \
|
|
141 | - -e 's|%LIBS_PRIVATE%|$(LIBS_PRIVATE)|' \
|
|
142 | - -e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
|
|
143 | - -e 's|%exec_prefix%|$(exec_prefix_x)|' \
|
|
144 | - -e 's|%ft_version%|$(ft_version)|' \
|
|
145 | - -e 's|%includedir%|$(includedir_x)|' \
|
|
146 | - -e 's|%libdir%|$(libdir_x)|' \
|
|
147 | - -e 's|%prefix%|$(prefix_x)|' \
|
|
148 | - $< \
|
|
142 | + sed -e 's|%PKGCONFIG_REQUIRES%|$(PKGCONFIG_REQUIRES)|' \
|
|
143 | + -e 's|%PKGCONFIG_REQUIRES_PRIVATE%|$(PKGCONFIG_REQUIRES_PRIVATE)|' \
|
|
144 | + -e 's|%PKGCONFIG_LIBS%|$(PKGCONFIG_LIBS)|' \
|
|
145 | + -e 's|%PKGCONFIG_LIBS_PRIVATE%|$(PKGCONFIG_LIBS_PRIVATE)|' \
|
|
146 | + -e 's|%build_libtool_libs%|$(build_libtool_libs)|' \
|
|
147 | + -e 's|%exec_prefix%|$(exec_prefix_x)|' \
|
|
148 | + -e 's|%ft_version%|$(ft_version)|' \
|
|
149 | + -e 's|%includedir%|$(includedir_x)|' \
|
|
150 | + -e 's|%libdir%|$(libdir_x)|' \
|
|
151 | + -e 's|%prefix%|$(prefix_x)|' \
|
|
152 | + $< \
|
|
149 | 153 | > $@.tmp
|
150 | 154 | chmod a-w $@.tmp
|
151 | 155 | mv $@.tmp $@
|
... | ... | @@ -196,25 +196,65 @@ |
196 | 196 | }
|
197 | 197 | |
198 | 198 | |
199 | -#if defined( NTDDI_VERSION ) && NTDDI_VERSION < 0x0A000007 && \
|
|
200 | - defined( WINAPI_FAMILY_PARTITION ) && \
|
|
199 | + /* non-desktop Universal Windows Platform */
|
|
200 | +#if defined( WINAPI_FAMILY_PARTITION ) && \
|
|
201 | 201 | !WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_DESKTOP )
|
202 | 202 | |
203 | 203 | #define PACK_DWORD64( hi, lo ) ( ( (DWORD64)(hi) << 32 ) | (DWORD)(lo) )
|
204 | 204 | |
205 | -#define CreateFileW( a, b, c, d, e, f, g ) \
|
|
206 | - CreateFileFromAppW( a, b, c, d, e, f, g )
|
|
207 | 205 | #define CreateFileMapping( a, b, c, d, e, f ) \
|
208 | 206 | CreateFileMappingFromApp( a, b, c, PACK_DWORD64( d, e ), f )
|
209 | 207 | #define MapViewOfFile( a, b, c, d, e ) \
|
210 | 208 | MapViewOfFileFromApp( a, b, PACK_DWORD64( c, d ), e )
|
211 | 209 | |
212 | -#define UWP_LEGACY
|
|
210 | + FT_LOCAL_DEF( HANDLE )
|
|
211 | + CreateFileA( LPCSTR lpFileName,
|
|
212 | + DWORD dwDesiredAccess,
|
|
213 | + DWORD dwShareMode,
|
|
214 | + LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
|
215 | + DWORD dwCreationDisposition,
|
|
216 | + DWORD dwFlagsAndAttributes,
|
|
217 | + HANDLE hTemplateFile )
|
|
218 | + {
|
|
219 | + int len;
|
|
220 | + LPWSTR lpFileNameW;
|
|
221 | + |
|
222 | + CREATEFILE2_EXTENDED_PARAMETERS createExParams = {
|
|
223 | + sizeof ( CREATEFILE2_EXTENDED_PARAMETERS ),
|
|
224 | + dwFlagsAndAttributes & 0x0000FFFF,
|
|
225 | + dwFlagsAndAttributes & 0xFFF00000,
|
|
226 | + dwFlagsAndAttributes & 0x000F0000,
|
|
227 | + lpSecurityAttributes,
|
|
228 | + hTemplateFile };
|
|
229 | + |
|
230 | + |
|
231 | + /* allocate memory space for converted path name */
|
|
232 | + len = MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
|
|
233 | + lpFileName, -1, NULL, 0 );
|
|
234 | + |
|
235 | + lpFileNameW = (LPWSTR)_alloca( len * sizeof ( WCHAR ) );
|
|
236 | + |
|
237 | + if ( !len || !lpFileNameW )
|
|
238 | + {
|
|
239 | + FT_ERROR(( "FT_Stream_Open: cannot convert file name to LPWSTR\n" ));
|
|
240 | + return INVALID_HANDLE_VALUE;
|
|
241 | + }
|
|
242 | + |
|
243 | + /* now it is safe to do the translation */
|
|
244 | + MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
|
|
245 | + lpFileName, -1, lpFileNameW, len );
|
|
246 | + |
|
247 | + /* open the file */
|
|
248 | + return CreateFile2( lpFileNameW, dwDesiredAccess, dwShareMode,
|
|
249 | + dwCreationDisposition, &createExParams );
|
|
250 | + }
|
|
213 | 251 | |
214 | 252 | #endif
|
215 | 253 | |
216 | 254 | |
217 | -#if defined( _WIN32_WCE ) || defined( UWP_LEGACY )
|
|
255 | +#if defined( _WIN32_WCE )
|
|
256 | + /* malloc.h provides implementation of alloca()/_alloca() */
|
|
257 | + #include <malloc.h>
|
|
218 | 258 | |
219 | 259 | FT_LOCAL_DEF( HANDLE )
|
220 | 260 | CreateFileA( LPCSTR lpFileName,
|
... | ... | @@ -154,6 +154,8 @@ FT_BEGIN_HEADER |
154 | 154 | * FT_FACE_FLAG_EXTERNAL_STREAM
|
155 | 155 | * FT_FACE_FLAG_HINTER
|
156 | 156 | * FT_FACE_FLAG_SVG
|
157 | + * FT_FACE_FLAG_SBIX
|
|
158 | + * FT_FACE_FLAG_SBIX_OVERLAY
|
|
157 | 159 | *
|
158 | 160 | * FT_HAS_HORIZONTAL
|
159 | 161 | * FT_HAS_VERTICAL
|
... | ... | @@ -163,6 +165,8 @@ FT_BEGIN_HEADER |
163 | 165 | * FT_HAS_COLOR
|
164 | 166 | * FT_HAS_MULTIPLE_MASTERS
|
165 | 167 | * FT_HAS_SVG
|
168 | + * FT_HAS_SBIX
|
|
169 | + * FT_HAS_SBIX_OVERLAY
|
|
166 | 170 | *
|
167 | 171 | * FT_IS_SFNT
|
168 | 172 | * FT_IS_SCALABLE
|
... | ... | @@ -227,6 +231,7 @@ FT_BEGIN_HEADER |
227 | 231 | * FT_LOAD_NO_SCALE
|
228 | 232 | * FT_LOAD_NO_HINTING
|
229 | 233 | * FT_LOAD_NO_BITMAP
|
234 | + * FT_LOAD_SBITS_ONLY
|
|
230 | 235 | * FT_LOAD_NO_AUTOHINT
|
231 | 236 | * FT_LOAD_COLOR
|
232 | 237 | *
|
... | ... | @@ -1235,6 +1240,16 @@ FT_BEGIN_HEADER |
1235 | 1240 | *
|
1236 | 1241 | * FT_FACE_FLAG_SVG ::
|
1237 | 1242 | * [Since 2.12] The face has an 'SVG~' OpenType table.
|
1243 | + *
|
|
1244 | + * FT_FACE_FLAG_SBIX ::
|
|
1245 | + * [Since 2.12] The face has an 'sbix' OpenType table *and* outlines.
|
|
1246 | + * For such fonts, @FT_FACE_FLAG_SCALABLE is not set by default to
|
|
1247 | + * retain backward compatibility.
|
|
1248 | + *
|
|
1249 | + * FT_FACE_FLAG_SBIX_OVERLAY ::
|
|
1250 | + * [Since 2.12] The face has an 'sbix' OpenType table where outlines
|
|
1251 | + * should be drawn on top of bitmap strikes.
|
|
1252 | + *
|
|
1238 | 1253 | */
|
1239 | 1254 | #define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
|
1240 | 1255 | #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
|
... | ... | @@ -1253,6 +1268,8 @@ FT_BEGIN_HEADER |
1253 | 1268 | #define FT_FACE_FLAG_COLOR ( 1L << 14 )
|
1254 | 1269 | #define FT_FACE_FLAG_VARIATION ( 1L << 15 )
|
1255 | 1270 | #define FT_FACE_FLAG_SVG ( 1L << 16 )
|
1271 | +#define FT_FACE_FLAG_SBIX ( 1L << 17 )
|
|
1272 | +#define FT_FACE_FLAG_SBIX_OVERLAY ( 1L << 18 )
|
|
1256 | 1273 | |
1257 | 1274 | |
1258 | 1275 | /**************************************************************************
|
... | ... | @@ -1509,6 +1526,107 @@ FT_BEGIN_HEADER |
1509 | 1526 | ( !!( (face)->face_flags & FT_FACE_FLAG_SVG ) )
|
1510 | 1527 | |
1511 | 1528 | |
1529 | + /**************************************************************************
|
|
1530 | + *
|
|
1531 | + * @macro:
|
|
1532 | + * FT_HAS_SBIX
|
|
1533 | + *
|
|
1534 | + * @description:
|
|
1535 | + * A macro that returns true whenever a face object contains an 'sbix'
|
|
1536 | + * OpenType table *and* outline glyphs.
|
|
1537 | + *
|
|
1538 | + * Currently, FreeType only supports bitmap glyphs in PNG format for this
|
|
1539 | + * table (i.e., JPEG and TIFF formats are unsupported, as are
|
|
1540 | + * Apple-specific formats not part of the OpenType specification).
|
|
1541 | + *
|
|
1542 | + * @note:
|
|
1543 | + * For backward compatibility, a font with an 'sbix' table is treated as
|
|
1544 | + * a bitmap-only face. Using @FT_Open_Face with @FT_PARAM_TAG_NO_SBIX,
|
|
1545 | + * an application can switch off 'sbix' handling so that the face is
|
|
1546 | + * treated as an ordinary outline font with scalable outlines.
|
|
1547 | + *
|
|
1548 | + * Here is some pseudo code that roughly illustrates how to implement
|
|
1549 | + * 'sbix' handling according to the OpenType specification.
|
|
1550 | + *
|
|
1551 | + * ```
|
|
1552 | + * if ( FT_HAS_SBIX( face ) )
|
|
1553 | + * {
|
|
1554 | + * // open font as a scalable one without sbix handling
|
|
1555 | + * FT_Face face2;
|
|
1556 | + * FT_Parameter param = { FT_PARAM_TAG_IGNORE_SBIX, NULL };
|
|
1557 | + * FT_Open_Args args = { FT_OPEN_PARAMS | ...,
|
|
1558 | + * ...,
|
|
1559 | + * 1, ¶m };
|
|
1560 | + *
|
|
1561 | + *
|
|
1562 | + * FT_Open_Face( library, &args, 0, &face2 );
|
|
1563 | + *
|
|
1564 | + * <sort `face->available_size` as necessary into
|
|
1565 | + * `preferred_sizes`[*]>
|
|
1566 | + *
|
|
1567 | + * for ( i = 0; i < face->num_fixed_sizes; i++ )
|
|
1568 | + * {
|
|
1569 | + * size = preferred_sizes[i].size;
|
|
1570 | + *
|
|
1571 | + * error = FT_Set_Pixel_Sizes( face, size, size );
|
|
1572 | + * <error handling omitted>
|
|
1573 | + *
|
|
1574 | + * // check whether we have a glyph in a bitmap strike
|
|
1575 | + * error = FT_Load_Glyph( face,
|
|
1576 | + * glyph_index,
|
|
1577 | + * FT_LOAD_SBITS_ONLY |
|
|
1578 | + * FT_LOAD_BITMAP_METRICS_ONLY );
|
|
1579 | + * if ( error == FT_Err_Invalid_Argument )
|
|
1580 | + * continue;
|
|
1581 | + * else if ( error )
|
|
1582 | + * <other error handling omitted>
|
|
1583 | + * else
|
|
1584 | + * break;
|
|
1585 | + * }
|
|
1586 | + *
|
|
1587 | + * if ( i != face->num_fixed_sizes )
|
|
1588 | + * <load embedded bitmap with `FT_Load_Glyph`,
|
|
1589 | + * scale it, display it, etc.>
|
|
1590 | + *
|
|
1591 | + * if ( i == face->num_fixed_sizes ||
|
|
1592 | + * FT_HAS_SBIX_OVERLAY( face ) )
|
|
1593 | + * <use `face2` to load outline glyph with `FT_Load_Glyph`,
|
|
1594 | + * scale it, display it on top of the bitmap, etc.>
|
|
1595 | + * }
|
|
1596 | + * ```
|
|
1597 | + *
|
|
1598 | + * [*] Assuming a target value of 400dpi and available strike sizes 100,
|
|
1599 | + * 200, 300, and 400dpi, a possible order might be [400, 200, 300, 100]:
|
|
1600 | + * scaling 200dpi to 400dpi usually gives better results than scaling
|
|
1601 | + * 300dpi to 400dpi; it is also much faster. However, scaling 100dpi to
|
|
1602 | + * 400dpi can yield a too pixelated result, thus the preference might be
|
|
1603 | + * 300dpi over 100dpi.
|
|
1604 | + *
|
|
1605 | + * @since:
|
|
1606 | + * 2.12
|
|
1607 | + */
|
|
1608 | +#define FT_HAS_SBIX( face ) \
|
|
1609 | + ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX ) )
|
|
1610 | + |
|
1611 | + |
|
1612 | + /**************************************************************************
|
|
1613 | + *
|
|
1614 | + * @macro:
|
|
1615 | + * FT_HAS_SBIX_OVERLAY
|
|
1616 | + *
|
|
1617 | + * @description:
|
|
1618 | + * A macro that returns true whenever a face object contains an 'sbix'
|
|
1619 | + * OpenType table with bit~1 in its `flags` field set, instructing the
|
|
1620 | + * application to overlay the bitmap strike with the corresponding
|
|
1621 | + * outline glyph. See @FT_HAS_SBIX for pseudo code how to use it.
|
|
1622 | + *
|
|
1623 | + * @since:
|
|
1624 | + * 2.12
|
|
1625 | + */
|
|
1626 | +#define FT_HAS_SBIX_OVERLAY( face ) \
|
|
1627 | + ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX_OVERLAY ) )
|
|
1628 | + |
|
1629 | + |
|
1512 | 1630 | /**************************************************************************
|
1513 | 1631 | *
|
1514 | 1632 | * @enum:
|
... | ... | @@ -2976,6 +3094,15 @@ FT_BEGIN_HEADER |
2976 | 3094 | *
|
2977 | 3095 | * @FT_LOAD_NO_SCALE always sets this flag.
|
2978 | 3096 | *
|
3097 | + * FT_LOAD_SBITS_ONLY ::
|
|
3098 | + * [Since 2.12] This is the opposite of @FT_LOAD_NO_BITMAP, more or
|
|
3099 | + * less: @FT_Load_Glyph returns `FT_Err_Invalid_Argument` if the face
|
|
3100 | + * contains a bitmap strike for the given size (or the strike selected
|
|
3101 | + * by @FT_Select_Size) but there is no glyph in the strike.
|
|
3102 | + *
|
|
3103 | + * Note that this load flag was part of FreeType since version 2.0.6
|
|
3104 | + * but previously tagged as internal.
|
|
3105 | + *
|
|
2979 | 3106 | * FT_LOAD_VERTICAL_LAYOUT ::
|
2980 | 3107 | * Load the glyph for vertical text layout. In particular, the
|
2981 | 3108 | * `advance` value in the @FT_GlyphSlotRec structure is set to the
|
... | ... | @@ -3120,6 +3247,7 @@ FT_BEGIN_HEADER |
3120 | 3247 | #define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
|
3121 | 3248 | #define FT_LOAD_MONOCHROME ( 1L << 12 )
|
3122 | 3249 | #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
|
3250 | +#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
|
|
3123 | 3251 | #define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
|
3124 | 3252 | /* Bits 16-19 are used by `FT_LOAD_TARGET_` */
|
3125 | 3253 | #define FT_LOAD_COLOR ( 1L << 20 )
|
... | ... | @@ -3130,7 +3258,6 @@ FT_BEGIN_HEADER |
3130 | 3258 | |
3131 | 3259 | /* used internally only by certain font drivers */
|
3132 | 3260 | #define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
|
3133 | -#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
|
|
3134 | 3261 | #define FT_LOAD_SVG_ONLY ( 1L << 23 )
|
3135 | 3262 | |
3136 | 3263 |
... | ... | @@ -401,11 +401,11 @@ FT_BEGIN_HEADER |
401 | 401 | * information.
|
402 | 402 | *
|
403 | 403 | * FT_OUTLINE_OVERLAP ::
|
404 | - * This flag indicates that this outline contains overlapping contrours
|
|
405 | - * and the anti-aliased renderer should perform oversampling to
|
|
406 | - * mitigate possible artifacts. This flag should _not_ be set for
|
|
407 | - * well designed glyphs without overlaps because it quadruples the
|
|
408 | - * rendering time.
|
|
404 | + * [Since 2.10.3] This flag indicates that this outline contains
|
|
405 | + * overlapping contours and the anti-aliased renderer should perform
|
|
406 | + * oversampling to mitigate possible artifacts. This flag should _not_
|
|
407 | + * be set for well designed glyphs without overlaps because it quadruples
|
|
408 | + * the rendering time.
|
|
409 | 409 | *
|
410 | 410 | * FT_OUTLINE_HIGH_PRECISION ::
|
411 | 411 | * This flag indicates that the scan-line converter should try to
|
... | ... | @@ -112,6 +112,21 @@ FT_BEGIN_HEADER |
112 | 112 | FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
|
113 | 113 | |
114 | 114 | |
115 | + /**************************************************************************
|
|
116 | + *
|
|
117 | + * @enum:
|
|
118 | + * FT_PARAM_TAG_IGNORE_SBIX
|
|
119 | + *
|
|
120 | + * @description:
|
|
121 | + * A tag for @FT_Parameter to make @FT_Open_Face ignore an 'sbix' table
|
|
122 | + * while loading a font. Use this if @FT_FACE_FLAG_SBIX is set and you
|
|
123 | + * want to access the outline glyphs in the font.
|
|
124 | + *
|
|
125 | + */
|
|
126 | +#define FT_PARAM_TAG_IGNORE_SBIX \
|
|
127 | + FT_MAKE_TAG( 'i', 's', 'b', 'x' )
|
|
128 | + |
|
129 | + |
|
115 | 130 | /**************************************************************************
|
116 | 131 | *
|
117 | 132 | * @enum:
|
... | ... | @@ -2527,6 +2527,16 @@ |
2527 | 2527 | #endif
|
2528 | 2528 | |
2529 | 2529 | |
2530 | + /* only use lower 31 bits together with sign bit */
|
|
2531 | + if ( face_index > 0 )
|
|
2532 | + face_index &= 0x7FFFFFFFL;
|
|
2533 | + else
|
|
2534 | + {
|
|
2535 | + face_index = -face_index;
|
|
2536 | + face_index &= 0x7FFFFFFFL;
|
|
2537 | + face_index = -face_index;
|
|
2538 | + }
|
|
2539 | + |
|
2530 | 2540 | #ifdef FT_DEBUG_LEVEL_TRACE
|
2531 | 2541 | FT_TRACE3(( "FT_Open_Face: " ));
|
2532 | 2542 | if ( face_index < 0 )
|
... | ... | @@ -3399,6 +3409,9 @@ |
3399 | 3409 | if ( !face )
|
3400 | 3410 | return FT_THROW( Invalid_Face_Handle );
|
3401 | 3411 | |
3412 | + if ( !face->size )
|
|
3413 | + return FT_THROW( Invalid_Size_Handle );
|
|
3414 | + |
|
3402 | 3415 | if ( !req || req->width < 0 || req->height < 0 ||
|
3403 | 3416 | req->type >= FT_SIZE_REQUEST_TYPE_MAX )
|
3404 | 3417 | return FT_THROW( Invalid_Argument );
|
... | ... | @@ -29,6 +29,14 @@ |
29 | 29 | |
30 | 30 | #include "cfferrs.h"
|
31 | 31 | |
32 | +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
33 | +#define IS_DEFAULT_INSTANCE( _face ) \
|
|
34 | + ( !( FT_IS_NAMED_INSTANCE( _face ) || \
|
|
35 | + FT_IS_VARIATION( _face ) ) )
|
|
36 | +#else
|
|
37 | +#define IS_DEFAULT_INSTANCE( _face ) 1
|
|
38 | +#endif
|
|
39 | + |
|
32 | 40 | |
33 | 41 | /**************************************************************************
|
34 | 42 | *
|
... | ... | @@ -255,8 +263,8 @@ |
255 | 263 | |
256 | 264 | |
257 | 265 | if ( size->strike_index != 0xFFFFFFFFUL &&
|
258 | - sfnt->load_eblc &&
|
|
259 | - ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
|
|
266 | + ( load_flags & FT_LOAD_NO_BITMAP ) == 0 &&
|
|
267 | + IS_DEFAULT_INSTANCE( size->root.face ) )
|
|
260 | 268 | {
|
261 | 269 | TT_SBit_MetricsRec metrics;
|
262 | 270 |
... | ... | @@ -784,17 +784,23 @@ |
784 | 784 | FT_Int num_params,
|
785 | 785 | FT_Parameter* params )
|
786 | 786 | {
|
787 | - FT_Error error;
|
|
787 | + FT_Error error;
|
|
788 | 788 | #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
789 | - FT_Error psnames_error;
|
|
789 | + FT_Error psnames_error;
|
|
790 | 790 | #endif
|
791 | - FT_Bool has_outline;
|
|
792 | - FT_Bool is_apple_sbit;
|
|
793 | - FT_Bool is_apple_sbix;
|
|
794 | - FT_Bool has_CBLC;
|
|
795 | - FT_Bool has_CBDT;
|
|
796 | - FT_Bool ignore_typographic_family = FALSE;
|
|
797 | - FT_Bool ignore_typographic_subfamily = FALSE;
|
|
791 | + |
|
792 | + FT_Bool has_outline;
|
|
793 | + FT_Bool is_apple_sbit;
|
|
794 | + |
|
795 | + FT_Bool has_CBLC;
|
|
796 | + FT_Bool has_CBDT;
|
|
797 | + FT_Bool has_EBLC;
|
|
798 | + FT_Bool has_bloc;
|
|
799 | + FT_Bool has_sbix;
|
|
800 | + |
|
801 | + FT_Bool ignore_typographic_family = FALSE;
|
|
802 | + FT_Bool ignore_typographic_subfamily = FALSE;
|
|
803 | + FT_Bool ignore_sbix = FALSE;
|
|
798 | 804 | |
799 | 805 | SFNT_Service sfnt = (SFNT_Service)face->sfnt;
|
800 | 806 | |
... | ... | @@ -813,6 +819,8 @@ |
813 | 819 | ignore_typographic_family = TRUE;
|
814 | 820 | else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY )
|
815 | 821 | ignore_typographic_subfamily = TRUE;
|
822 | + else if ( params[i].tag == FT_PARAM_TAG_IGNORE_SBIX )
|
|
823 | + ignore_sbix = TRUE;
|
|
816 | 824 | }
|
817 | 825 | }
|
818 | 826 | |
... | ... | @@ -848,14 +856,17 @@ |
848 | 856 | tt_face_lookup_table( face, TTAG_CFF2 ) );
|
849 | 857 | #endif
|
850 | 858 | |
851 | - is_apple_sbit = 0;
|
|
852 | - is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
|
|
859 | + /* check which sbit formats are present */
|
|
860 | + has_CBLC = !face->goto_table( face, TTAG_CBLC, stream, 0 );
|
|
861 | + has_CBDT = !face->goto_table( face, TTAG_CBDT, stream, 0 );
|
|
862 | + has_EBLC = !face->goto_table( face, TTAG_EBLC, stream, 0 );
|
|
863 | + has_bloc = !face->goto_table( face, TTAG_bloc, stream, 0 );
|
|
864 | + has_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
|
|
853 | 865 | |
854 | - /* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf'
|
|
855 | - * outline rendered on top. We don't support that yet, so just ignore
|
|
856 | - * the 'glyf' outline and advertise it as a bitmap-only font. */
|
|
857 | - if ( is_apple_sbix )
|
|
858 | - has_outline = FALSE;
|
|
866 | + is_apple_sbit = FALSE;
|
|
867 | + |
|
868 | + if ( ignore_sbix )
|
|
869 | + has_sbix = FALSE;
|
|
859 | 870 | |
860 | 871 | /* if this font doesn't contain outlines, we try to load */
|
861 | 872 | /* a `bhed' table */
|
... | ... | @@ -867,16 +878,13 @@ |
867 | 878 | |
868 | 879 | /* load the font header (`head' table) if this isn't an Apple */
|
869 | 880 | /* sbit font file */
|
870 | - if ( !is_apple_sbit || is_apple_sbix )
|
|
881 | + if ( !is_apple_sbit || has_sbix )
|
|
871 | 882 | {
|
872 | 883 | LOAD_( head );
|
873 | 884 | if ( error )
|
874 | 885 | goto Exit;
|
875 | 886 | }
|
876 | 887 | |
877 | - has_CBLC = !face->goto_table( face, TTAG_CBLC, stream, 0 );
|
|
878 | - has_CBDT = !face->goto_table( face, TTAG_CBDT, stream, 0 );
|
|
879 | - |
|
880 | 888 | /* Ignore outlines for CBLC/CBDT fonts. */
|
881 | 889 | if ( has_CBLC || has_CBDT )
|
882 | 890 | has_outline = FALSE;
|
... | ... | @@ -986,7 +994,11 @@ |
986 | 994 | /* the optional tables */
|
987 | 995 | |
988 | 996 | /* embedded bitmap support */
|
989 | - if ( sfnt->load_eblc )
|
|
997 | + /* TODO: Replace this clumsy check for all possible sbit tables */
|
|
998 | + /* with something better (for example, by passing a parameter */
|
|
999 | + /* to suppress 'sbix' loading). */
|
|
1000 | + if ( sfnt->load_eblc &&
|
|
1001 | + ( has_CBLC || has_EBLC || has_bloc || has_sbix ) )
|
|
990 | 1002 | LOAD_( eblc );
|
991 | 1003 | |
992 | 1004 | /* colored glyph support */
|
... | ... | @@ -1058,7 +1070,14 @@ |
1058 | 1070 | flags |= FT_FACE_FLAG_COLOR; /* color glyphs */
|
1059 | 1071 | |
1060 | 1072 | if ( has_outline == TRUE )
|
1061 | - flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
|
|
1073 | + {
|
|
1074 | + /* by default (and for backward compatibility) we handle */
|
|
1075 | + /* fonts with an 'sbix' table as bitmap-only */
|
|
1076 | + if ( has_sbix )
|
|
1077 | + flags |= FT_FACE_FLAG_SBIX; /* with 'sbix' bitmaps */
|
|
1078 | + else
|
|
1079 | + flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
|
|
1080 | + }
|
|
1062 | 1081 | |
1063 | 1082 | /* The sfnt driver only supports bitmap fonts natively, thus we */
|
1064 | 1083 | /* don't set FT_FACE_FLAG_HINTER. */
|
... | ... | @@ -1281,7 +1300,8 @@ |
1281 | 1300 | *
|
1282 | 1301 | * Set up metrics.
|
1283 | 1302 | */
|
1284 | - if ( FT_IS_SCALABLE( root ) )
|
|
1303 | + if ( FT_IS_SCALABLE( root ) ||
|
|
1304 | + FT_HAS_SBIX( root ) )
|
|
1285 | 1305 | {
|
1286 | 1306 | /* XXX What about if outline header is missing */
|
1287 | 1307 | /* (e.g. sfnt wrapped bitmap)? */
|
... | ... | @@ -84,6 +84,8 @@ |
84 | 84 | #define BBOX_STREAM 5
|
85 | 85 | #define INSTRUCTION_STREAM 6
|
86 | 86 | |
87 | +#define HAVE_OVERLAP_SIMPLE_BITMAP 0x1
|
|
88 | + |
|
87 | 89 | |
88 | 90 | static void
|
89 | 91 | stream_close( FT_Stream stream )
|
... | ... | @@ -522,6 +524,7 @@ |
522 | 524 | const WOFF2_Point points,
|
523 | 525 | FT_UShort n_contours,
|
524 | 526 | FT_UShort instruction_len,
|
527 | + FT_Bool have_overlap,
|
|
525 | 528 | FT_Byte* dst,
|
526 | 529 | FT_ULong dst_size,
|
527 | 530 | FT_ULong* glyph_size )
|
... | ... | @@ -549,6 +552,9 @@ |
549 | 552 | FT_Int dy = point.y - last_y;
|
550 | 553 | |
551 | 554 | |
555 | + if ( i == 0 && have_overlap )
|
|
556 | + flag |= GLYF_OVERLAP_SIMPLE;
|
|
557 | + |
|
552 | 558 | if ( dx == 0 )
|
553 | 559 | flag |= GLYF_THIS_X_IS_SAME;
|
554 | 560 | else if ( dx > -256 && dx < 256 )
|
... | ... | @@ -833,15 +839,18 @@ |
833 | 839 | |
834 | 840 | FT_UInt num_substreams = 7;
|
835 | 841 | |
842 | + FT_UShort option_flags;
|
|
836 | 843 | FT_UShort num_glyphs;
|
837 | 844 | FT_UShort index_format;
|
838 | 845 | FT_ULong expected_loca_length;
|
839 | 846 | FT_UInt offset;
|
840 | 847 | FT_UInt i;
|
841 | 848 | FT_ULong points_size;
|
842 | - FT_ULong bitmap_length;
|
|
843 | 849 | FT_ULong glyph_buf_size;
|
844 | 850 | FT_ULong bbox_bitmap_offset;
|
851 | + FT_ULong bbox_bitmap_length;
|
|
852 | + FT_ULong overlap_bitmap_offset = 0;
|
|
853 | + FT_ULong overlap_bitmap_length = 0;
|
|
845 | 854 | |
846 | 855 | const FT_ULong glyf_start = *out_offset;
|
847 | 856 | FT_ULong dest_offset = *out_offset;
|
... | ... | @@ -857,15 +866,17 @@ |
857 | 866 | if ( FT_NEW_ARRAY( substreams, num_substreams ) )
|
858 | 867 | goto Fail;
|
859 | 868 | |
860 | - if ( FT_STREAM_SKIP( 4 ) )
|
|
869 | + if ( FT_STREAM_SKIP( 2 ) )
|
|
870 | + goto Fail;
|
|
871 | + if ( FT_READ_USHORT( option_flags ) )
|
|
861 | 872 | goto Fail;
|
862 | 873 | if ( FT_READ_USHORT( num_glyphs ) )
|
863 | 874 | goto Fail;
|
864 | 875 | if ( FT_READ_USHORT( index_format ) )
|
865 | 876 | goto Fail;
|
866 | 877 | |
867 | - FT_TRACE4(( "num_glyphs = %u; index_format = %u\n",
|
|
868 | - num_glyphs, index_format ));
|
|
878 | + FT_TRACE4(( "option_flags = %u; num_glyphs = %u; index_format = %u\n",
|
|
879 | + option_flags, num_glyphs, index_format ));
|
|
869 | 880 | |
870 | 881 | info->num_glyphs = num_glyphs;
|
871 | 882 | |
... | ... | @@ -878,7 +889,7 @@ |
878 | 889 | if ( info->loca_table->dst_length != expected_loca_length )
|
879 | 890 | goto Fail;
|
880 | 891 | |
881 | - offset = ( 2 + num_substreams ) * 4;
|
|
892 | + offset = 2 + 2 + 2 + 2 + ( num_substreams * 4 );
|
|
882 | 893 | if ( offset > info->glyf_table->TransformLength )
|
883 | 894 | goto Fail;
|
884 | 895 | |
... | ... | @@ -901,6 +912,20 @@ |
901 | 912 | offset += substream_size;
|
902 | 913 | }
|
903 | 914 | |
915 | + if ( option_flags & HAVE_OVERLAP_SIMPLE_BITMAP )
|
|
916 | + {
|
|
917 | + /* Size of overlapBitmap = floor((numGlyphs + 7) / 8) */
|
|
918 | + overlap_bitmap_length = ( num_glyphs + 7U ) >> 3;
|
|
919 | + if ( overlap_bitmap_length > info->glyf_table->TransformLength - offset )
|
|
920 | + goto Fail;
|
|
921 | + |
|
922 | + overlap_bitmap_offset = pos + offset;
|
|
923 | + |
|
924 | + FT_TRACE5(( " Overlap bitmap: offset = %lu; size = %lu;\n",
|
|
925 | + overlap_bitmap_offset, overlap_bitmap_length ));
|
|
926 | + offset += overlap_bitmap_length;
|
|
927 | + }
|
|
928 | + |
|
904 | 929 | if ( FT_NEW_ARRAY( loca_values, num_glyphs + 1 ) )
|
905 | 930 | goto Fail;
|
906 | 931 | |
... | ... | @@ -908,8 +933,9 @@ |
908 | 933 | bbox_bitmap_offset = substreams[BBOX_STREAM].offset;
|
909 | 934 | |
910 | 935 | /* Size of bboxBitmap = 4 * floor((numGlyphs + 31) / 32) */
|
911 | - bitmap_length = ( ( num_glyphs + 31U ) >> 5 ) << 2;
|
|
912 | - substreams[BBOX_STREAM].offset += bitmap_length;
|
|
936 | + bbox_bitmap_length = ( ( num_glyphs + 31U ) >> 5 ) << 2;
|
|
937 | + /* bboxStreamSize is the combined size of bboxBitmap and bboxStream. */
|
|
938 | + substreams[BBOX_STREAM].offset += bbox_bitmap_length;
|
|
913 | 939 | |
914 | 940 | glyph_buf_size = WOFF2_DEFAULT_GLYPH_BUF;
|
915 | 941 | if ( FT_NEW_ARRAY( glyph_buf, glyph_buf_size ) )
|
... | ... | @@ -1025,8 +1051,11 @@ |
1025 | 1051 | FT_ULong flag_size;
|
1026 | 1052 | FT_ULong triplet_size;
|
1027 | 1053 | FT_ULong triplet_bytes_used;
|
1028 | - FT_Byte* flags_buf = NULL;
|
|
1029 | - FT_Byte* triplet_buf = NULL;
|
|
1054 | + FT_Bool have_overlap = FALSE;
|
|
1055 | + FT_Byte overlap_bitmap;
|
|
1056 | + FT_ULong overlap_offset;
|
|
1057 | + FT_Byte* flags_buf = NULL;
|
|
1058 | + FT_Byte* triplet_buf = NULL;
|
|
1030 | 1059 | FT_UShort instruction_size;
|
1031 | 1060 | FT_ULong size_needed;
|
1032 | 1061 | FT_Int end_point;
|
... | ... | @@ -1035,6 +1064,17 @@ |
1035 | 1064 | FT_Byte* pointer = NULL;
|
1036 | 1065 | |
1037 | 1066 | |
1067 | + /* Set `have_overlap`. */
|
|
1068 | + if ( overlap_bitmap_offset )
|
|
1069 | + {
|
|
1070 | + overlap_offset = overlap_bitmap_offset + ( i >> 3 );
|
|
1071 | + if ( FT_STREAM_SEEK( overlap_offset ) ||
|
|
1072 | + FT_READ_BYTE( overlap_bitmap ) )
|
|
1073 | + goto Fail;
|
|
1074 | + if ( overlap_bitmap & ( 0x80 >> ( i & 7 ) ) )
|
|
1075 | + have_overlap = TRUE;
|
|
1076 | + }
|
|
1077 | + |
|
1038 | 1078 | if ( FT_NEW_ARRAY( n_points_arr, n_contours ) )
|
1039 | 1079 | goto Fail;
|
1040 | 1080 | |
... | ... | @@ -1155,6 +1195,7 @@ |
1155 | 1195 | points,
|
1156 | 1196 | n_contours,
|
1157 | 1197 | instruction_size,
|
1198 | + have_overlap,
|
|
1158 | 1199 | glyph_buf,
|
1159 | 1200 | glyph_buf_size,
|
1160 | 1201 | &glyph_size ) )
|
... | ... | @@ -56,6 +56,7 @@ FT_BEGIN_HEADER |
56 | 56 | #define GLYF_REPEAT 1 << 3
|
57 | 57 | #define GLYF_THIS_X_IS_SAME 1 << 4
|
58 | 58 | #define GLYF_THIS_Y_IS_SAME 1 << 5
|
59 | +#define GLYF_OVERLAP_SIMPLE 1 << 6
|
|
59 | 60 | |
60 | 61 | /* Other constants */
|
61 | 62 | #define CONTOUR_OFFSET_END_POINT 10
|
... | ... | @@ -190,10 +190,16 @@ |
190 | 190 | FT_Int result = 0;
|
191 | 191 | FT_UInt count, mask;
|
192 | 192 | |
193 | - FT_Byte* p = face->kern_table;
|
|
194 | - FT_Byte* p_limit = p + face->kern_table_size;
|
|
193 | + FT_Byte* p;
|
|
194 | + FT_Byte* p_limit;
|
|
195 | 195 | |
196 | 196 | |
197 | + if ( !face->kern_table )
|
|
198 | + return result;
|
|
199 | + |
|
200 | + p = face->kern_table;
|
|
201 | + p_limit = p + face->kern_table_size;
|
|
202 | + |
|
197 | 203 | p += 4;
|
198 | 204 | mask = 0x0001;
|
199 | 205 |
... | ... | @@ -172,17 +172,8 @@ |
172 | 172 | goto Exit;
|
173 | 173 | }
|
174 | 174 | |
175 | -#ifdef FT_DEBUG_LEVEL_TRACE
|
|
176 | - /* we currently don't support bit 1; however, it is better to */
|
|
177 | - /* draw at least something... */
|
|
178 | 175 | if ( flags == 3 )
|
179 | - {
|
|
180 | - FT_TRACE1(( "tt_face_load_sbit_strikes:"
|
|
181 | - " sbix overlay not supported yet\n" ));
|
|
182 | - FT_TRACE1(( " "
|
|
183 | - " expect bad rendering results\n" ));
|
|
184 | - }
|
|
185 | -#endif
|
|
176 | + face->root.face_flags |= FT_FACE_FLAG_SBIX_OVERLAY;
|
|
186 | 177 | |
187 | 178 | /*
|
188 | 179 | * Count the number of strikes available in the table. We are a bit
|
... | ... | @@ -1580,17 +1571,34 @@ |
1580 | 1571 | |
1581 | 1572 | if ( !error )
|
1582 | 1573 | {
|
1583 | - FT_Short abearing;
|
|
1574 | + FT_Short abearing; /* not used here */
|
|
1584 | 1575 | FT_UShort aadvance;
|
1585 | 1576 | |
1586 | 1577 | |
1587 | 1578 | tt_face_get_metrics( face, FALSE, glyph_index, &abearing, &aadvance );
|
1588 | 1579 | |
1589 | 1580 | metrics->horiBearingX = (FT_Short)originOffsetX;
|
1590 | - metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height );
|
|
1581 | + metrics->vertBearingX = (FT_Short)originOffsetX;
|
|
1582 | + |
|
1583 | + metrics->horiBearingY = (FT_Short)( originOffsetY + metrics->height );
|
|
1584 | + metrics->vertBearingY = (FT_Short)originOffsetY;
|
|
1585 | + |
|
1591 | 1586 | metrics->horiAdvance = (FT_UShort)( aadvance *
|
1592 | 1587 | face->root.size->metrics.x_ppem /
|
1593 | 1588 | face->header.Units_Per_EM );
|
1589 | + |
|
1590 | + if ( face->vertical_info )
|
|
1591 | + tt_face_get_metrics( face, TRUE, glyph_index, &abearing, &aadvance );
|
|
1592 | + else if ( face->os2.version != 0xFFFFU )
|
|
1593 | + aadvance = (FT_UShort)FT_ABS( face->os2.sTypoAscender -
|
|
1594 | + face->os2.sTypoDescender );
|
|
1595 | + else
|
|
1596 | + aadvance = (FT_UShort)FT_ABS( face->horizontal.Ascender -
|
|
1597 | + face->horizontal.Descender );
|
|
1598 | + |
|
1599 | + metrics->vertAdvance = (FT_UShort)( aadvance *
|
|
1600 | + face->root.size->metrics.x_ppem /
|
|
1601 | + face->header.Units_Per_EM );
|
|
1594 | 1602 | }
|
1595 | 1603 | |
1596 | 1604 | return error;
|
... | ... | @@ -2897,8 +2897,12 @@ |
2897 | 2897 | }
|
2898 | 2898 | else
|
2899 | 2899 | {
|
2900 | - if ( FT_IS_SCALABLE( glyph->face ) )
|
|
2900 | + if ( FT_IS_SCALABLE( glyph->face ) ||
|
|
2901 | + FT_HAS_SBIX( glyph->face ) )
|
|
2901 | 2902 | {
|
2903 | + TT_Face face = (TT_Face)glyph->face;
|
|
2904 | + |
|
2905 | + |
|
2902 | 2906 | /* for the bbox we need the header only */
|
2903 | 2907 | (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
|
2904 | 2908 | (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
|
... | ... | @@ -2906,6 +2910,35 @@ |
2906 | 2910 | glyph->linearHoriAdvance = loader.linear;
|
2907 | 2911 | glyph->linearVertAdvance = loader.vadvance;
|
2908 | 2912 | |
2913 | + /* Bitmaps from the 'sbix' table need special treatment: */
|
|
2914 | + /* if there is a glyph contour, the bitmap origin must be */
|
|
2915 | + /* shifted to be relative to the lower left corner of the */
|
|
2916 | + /* glyph bounding box, also taking the left-side bearing */
|
|
2917 | + /* (or top bearing) into account. */
|
|
2918 | + if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX &&
|
|
2919 | + loader.n_contours > 0 )
|
|
2920 | + {
|
|
2921 | + FT_Int bitmap_left;
|
|
2922 | + FT_Int bitmap_top;
|
|
2923 | + |
|
2924 | + |
|
2925 | + if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
|
|
2926 | + {
|
|
2927 | + /* This is a guess, since Apple's CoreText engine doesn't */
|
|
2928 | + /* really do vertical typesetting. */
|
|
2929 | + bitmap_left = loader.bbox.xMin;
|
|
2930 | + bitmap_top = loader.top_bearing;
|
|
2931 | + }
|
|
2932 | + else
|
|
2933 | + {
|
|
2934 | + bitmap_left = loader.left_bearing;
|
|
2935 | + bitmap_top = loader.bbox.yMin;
|
|
2936 | + }
|
|
2937 | + |
|
2938 | + glyph->bitmap_left += FT_MulFix( bitmap_left, x_scale ) >> 6;
|
|
2939 | + glyph->bitmap_top += FT_MulFix( bitmap_top, y_scale ) >> 6;
|
|
2940 | + }
|
|
2941 | + |
|
2909 | 2942 | /* sanity checks: if `xxxAdvance' in the sbit metric */
|
2910 | 2943 | /* structure isn't set, use `linearXXXAdvance' */
|
2911 | 2944 | if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
|
... | ... | @@ -727,7 +727,8 @@ |
727 | 727 | if ( error )
|
728 | 728 | goto Exit;
|
729 | 729 | |
730 | - if ( FT_IS_SCALABLE( ttface ) )
|
|
730 | + if ( FT_IS_SCALABLE( ttface ) ||
|
|
731 | + FT_HAS_SBIX( ttface ) )
|
|
731 | 732 | {
|
732 | 733 | #ifdef FT_CONFIG_OPTION_INCREMENTAL
|
733 | 734 | if ( !ttface->internal->incremental_interface )
|