2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* sfobjs.c
|
|
|
|
*
|
|
|
|
* SFNT object management (base).
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "sfobjs.h"
|
|
|
|
#include "ttload.h"
|
2004-08-29 18:50:09 +02:00
|
|
|
#include "ttcmap.h"
|
2005-02-26 01:12:04 +01:00
|
|
|
#include "ttkern.h"
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_INTERNAL_SFNT_H
|
2006-02-15 07:05:52 +01:00
|
|
|
#include FT_INTERNAL_DEBUG_H
|
2001-03-20 15:50:04 +01:00
|
|
|
#include FT_TRUETYPE_IDS_H
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_TRUETYPE_TAGS_H
|
* include/freetype/internal/bdftypes.h: removed obsolete header
* include/freetype/internal/cfftypes.h, src/cff/cfftypes.h,
src/cff/cffload.h, src/cff/cffobjs.h, src/cff/cffparse.h,
include/freetype/internal/services/svbdf.h: moving "cfftypes.h" from
'include/freetype/internal' to 'src/cff' since no other modules needs
to known about these types
* include/freetype/internal/t42types.h,
include/freetype/internal/internal.h, src/type42/t42objs.h,
src/type42/t42drivr.c, src/type42/t42types.h: moving "t42types.h" from
'include/freetype/internal' to 'src/type42' since no other modules needs
to known about these types
* src/gzip/infblock.c: removing compiler warning
* include/freetype/internal/services/svpsinfo.h,
include/freetype/internal/ftserv.h, src/cff/cffdrivr.c,
src/cid/ciddrivr.c, src/type1/t1driver.c, src/type42/t42drivr.c,
src/base/fttype1.c: migrating to FT_SERVICE_ID_POSTSCRIPT_INFO defined
in "svpsinfo.h", removing some sad hacks.
2003-10-29 22:43:52 +01:00
|
|
|
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
|
2010-01-29 15:18:34 +01:00
|
|
|
#include FT_SFNT_NAMES_H
|
2013-08-29 17:53:40 +02:00
|
|
|
#include FT_GZIP_H
|
2016-12-14 19:31:42 +01:00
|
|
|
|
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
#include FT_SERVICE_MULTIPLE_MASTERS_H
|
2016-12-14 20:44:11 +01:00
|
|
|
#include FT_SERVICE_METRICS_VARIATIONS_H
|
2016-12-14 19:31:42 +01:00
|
|
|
#endif
|
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "sferrors.h"
|
2000-05-28 19:15:37 +02:00
|
|
|
|
* include/freetype/config/ftoption.h,
include/freetype/config/ftstdlib.h,
include/freetype/internal/tttypes.h,
src/sfnt/Jamfile, src/sfnt/rules.mk, src/sfnt/sfdriver.c,
src/sfnt/ttbdf.h, src/sfnt/ttbdf.c, src/sfnt/sfobjs.c:
Added support for an embedded 'BDF ' table within SFNT-based
bitmap font files. This is used to store atoms & properties from
the original BDF fonts that were used to generate the font file.
the feature is controled by TT_CONFIG_OPTION_BDF within 'ftoption.h'
and is used to implement FT_Get_BDF_Property for these font files.
At the moment, this is still experimental, the BDF table format isn't
cast into stone yet.
2005-12-14 21:38:15 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_BDF
|
|
|
|
#include "ttbdf.h"
|
|
|
|
#endif
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2005-12-20 13:01:58 +01:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2000-06-12 21:36:41 +02:00
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_sfobjs
|
|
|
|
|
|
|
|
|
2002-03-30 17:32:47 +01:00
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
/* convert a UTF-16 name entry to ASCII */
|
2002-03-30 17:32:47 +01:00
|
|
|
static FT_String*
|
2017-01-25 15:08:41 +01:00
|
|
|
tt_name_ascii_from_utf16( TT_Name entry,
|
|
|
|
FT_Memory memory )
|
2002-03-30 17:32:47 +01:00
|
|
|
{
|
2010-07-12 21:13:22 +02:00
|
|
|
FT_String* string = NULL;
|
2002-03-30 17:32:47 +01:00
|
|
|
FT_UInt len, code, n;
|
2010-07-12 21:13:22 +02:00
|
|
|
FT_Byte* read = (FT_Byte*)entry->string;
|
2006-01-27 15:16:16 +01:00
|
|
|
FT_Error error;
|
2002-03-31 20:48:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
len = (FT_UInt)entry->stringLength / 2;
|
|
|
|
|
2006-01-27 13:11:22 +01:00
|
|
|
if ( FT_NEW_ARRAY( string, len + 1 ) )
|
2002-03-30 17:32:47 +01:00
|
|
|
return NULL;
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-03-30 17:32:47 +01:00
|
|
|
for ( n = 0; n < len; n++ )
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
code = FT_NEXT_USHORT( read );
|
2012-03-14 18:29:57 +01:00
|
|
|
|
|
|
|
if ( code == 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ( code < 32 || code > 127 )
|
2002-03-30 17:32:47 +01:00
|
|
|
code = '?';
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-03-30 17:32:47 +01:00
|
|
|
string[n] = (char)code;
|
|
|
|
}
|
|
|
|
|
2012-03-14 18:29:57 +01:00
|
|
|
string[n] = 0;
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-03-30 17:32:47 +01:00
|
|
|
return string;
|
2002-03-31 20:48:24 +02:00
|
|
|
}
|
2002-03-30 17:32:47 +01:00
|
|
|
|
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
/* convert an Apple Roman or symbol name entry to ASCII */
|
2002-03-30 17:32:47 +01:00
|
|
|
static FT_String*
|
2017-01-25 15:08:41 +01:00
|
|
|
tt_name_ascii_from_other( TT_Name entry,
|
|
|
|
FT_Memory memory )
|
2002-03-30 17:32:47 +01:00
|
|
|
{
|
2010-07-12 21:13:22 +02:00
|
|
|
FT_String* string = NULL;
|
2002-03-30 17:32:47 +01:00
|
|
|
FT_UInt len, code, n;
|
2010-07-12 21:13:22 +02:00
|
|
|
FT_Byte* read = (FT_Byte*)entry->string;
|
2006-01-27 15:16:16 +01:00
|
|
|
FT_Error error;
|
2002-03-31 20:48:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
len = (FT_UInt)entry->stringLength;
|
|
|
|
|
2006-01-27 13:11:22 +01:00
|
|
|
if ( FT_NEW_ARRAY( string, len + 1 ) )
|
2002-03-30 17:32:47 +01:00
|
|
|
return NULL;
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-03-30 17:32:47 +01:00
|
|
|
for ( n = 0; n < len; n++ )
|
|
|
|
{
|
|
|
|
code = *read++;
|
2012-03-14 18:29:57 +01:00
|
|
|
|
|
|
|
if ( code == 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ( code < 32 || code > 127 )
|
2002-03-30 17:32:47 +01:00
|
|
|
code = '?';
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-03-30 17:32:47 +01:00
|
|
|
string[n] = (char)code;
|
|
|
|
}
|
|
|
|
|
2012-03-14 18:29:57 +01:00
|
|
|
string[n] = 0;
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-03-30 17:32:47 +01:00
|
|
|
return string;
|
2002-03-31 20:48:24 +02:00
|
|
|
}
|
2002-03-30 17:32:47 +01:00
|
|
|
|
|
|
|
|
2017-01-25 15:08:41 +01:00
|
|
|
typedef FT_String* (*TT_Name_ConvertFunc)( TT_Name entry,
|
|
|
|
FT_Memory memory );
|
2002-05-28 01:52:01 +02:00
|
|
|
|
2002-05-28 08:03:10 +02:00
|
|
|
|
2015-07-07 14:04:44 +02:00
|
|
|
/* documentation is in sfnt.h */
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2008-11-08 08:20:25 +01:00
|
|
|
tt_face_get_name( TT_Face face,
|
|
|
|
FT_UShort nameid,
|
|
|
|
FT_String** name )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2017-01-25 15:08:41 +01:00
|
|
|
FT_Memory memory = face->root.memory;
|
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
FT_String* result = NULL;
|
|
|
|
FT_UShort n;
|
|
|
|
TT_Name rec;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2017-01-25 15:08:41 +01:00
|
|
|
FT_Int found_apple = -1;
|
|
|
|
FT_Int found_apple_roman = -1;
|
|
|
|
FT_Int found_apple_english = -1;
|
|
|
|
FT_Int found_win = -1;
|
|
|
|
FT_Int found_unicode = -1;
|
2004-06-02 23:22:32 +02:00
|
|
|
|
2017-01-25 15:08:41 +01:00
|
|
|
FT_Bool is_english = 0;
|
|
|
|
|
|
|
|
TT_Name_ConvertFunc convert;
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2002-05-28 08:03:10 +02:00
|
|
|
|
2008-11-08 08:20:25 +01:00
|
|
|
FT_ASSERT( name );
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
rec = face->name_table.names;
|
2002-05-01 10:36:12 +02:00
|
|
|
for ( n = 0; n < face->num_names; n++, rec++ )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
/* According to the OpenType 1.3 specification, only Microsoft or */
|
|
|
|
/* Apple platform IDs might be used in the `name' table. The */
|
|
|
|
/* `Unicode' platform is reserved for the `cmap' table, and the */
|
2010-07-09 05:25:59 +02:00
|
|
|
/* `ISO' one is deprecated. */
|
2002-03-31 20:48:24 +02:00
|
|
|
/* */
|
|
|
|
/* However, the Apple TrueType specification doesn't say the same */
|
|
|
|
/* thing and goes to suggest that all Unicode `name' table entries */
|
|
|
|
/* should be coded in UTF-16 (in big-endian format I suppose). */
|
2002-03-30 17:32:47 +01:00
|
|
|
/* */
|
2002-05-28 01:52:01 +02:00
|
|
|
if ( rec->nameID == nameid && rec->stringLength > 0 )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2002-03-05 17:12:57 +01:00
|
|
|
switch ( rec->platformID )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
case TT_PLATFORM_APPLE_UNICODE:
|
|
|
|
case TT_PLATFORM_ISO:
|
|
|
|
/* there is `languageID' to check there. We should use this */
|
|
|
|
/* field only as a last solution when nothing else is */
|
|
|
|
/* available. */
|
|
|
|
/* */
|
|
|
|
found_unicode = n;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_PLATFORM_MACINTOSH:
|
2006-09-12 15:48:10 +02:00
|
|
|
/* This is a bit special because some fonts will use either */
|
|
|
|
/* an English language id, or a Roman encoding id, to indicate */
|
|
|
|
/* the English version of its font name. */
|
|
|
|
/* */
|
2002-03-31 20:48:24 +02:00
|
|
|
if ( rec->languageID == TT_MAC_LANGID_ENGLISH )
|
2006-09-11 14:00:32 +02:00
|
|
|
found_apple_english = n;
|
|
|
|
else if ( rec->encodingID == TT_MAC_ID_ROMAN )
|
|
|
|
found_apple_roman = n;
|
2002-03-31 20:48:24 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_PLATFORM_MICROSOFT:
|
|
|
|
/* we only take a non-English name when there is nothing */
|
|
|
|
/* else available in the font */
|
|
|
|
/* */
|
|
|
|
if ( found_win == -1 || ( rec->languageID & 0x3FF ) == 0x009 )
|
|
|
|
{
|
|
|
|
switch ( rec->encodingID )
|
2002-03-05 17:12:57 +01:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
case TT_MS_ID_SYMBOL_CS:
|
|
|
|
case TT_MS_ID_UNICODE_CS:
|
|
|
|
case TT_MS_ID_UCS_4:
|
2005-05-10 00:11:36 +02:00
|
|
|
is_english = FT_BOOL( ( rec->languageID & 0x3FF ) == 0x009 );
|
2004-06-02 23:22:32 +02:00
|
|
|
found_win = n;
|
2002-03-05 17:12:57 +01:00
|
|
|
break;
|
2002-03-31 20:48:24 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2002-03-05 17:12:57 +01:00
|
|
|
}
|
2002-03-31 20:48:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
2002-03-05 17:12:57 +01:00
|
|
|
}
|
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2006-09-11 14:00:32 +02:00
|
|
|
found_apple = found_apple_roman;
|
|
|
|
if ( found_apple_english >= 0 )
|
|
|
|
found_apple = found_apple_english;
|
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
/* some fonts contain invalid Unicode or Macintosh formatted entries; */
|
|
|
|
/* we will thus favor names encoded in Windows formats if available */
|
2004-06-02 23:22:32 +02:00
|
|
|
/* (provided it is an English name) */
|
2002-03-31 20:48:24 +02:00
|
|
|
/* */
|
2002-05-28 01:52:01 +02:00
|
|
|
convert = NULL;
|
2004-06-02 23:22:32 +02:00
|
|
|
if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) )
|
2002-03-05 17:12:57 +01:00
|
|
|
{
|
2002-03-30 17:32:47 +01:00
|
|
|
rec = face->name_table.names + found_win;
|
|
|
|
switch ( rec->encodingID )
|
2002-03-05 17:12:57 +01:00
|
|
|
{
|
2006-12-01 09:20:47 +01:00
|
|
|
/* all Unicode strings are encoded using UTF-16BE */
|
2002-03-31 20:48:24 +02:00
|
|
|
case TT_MS_ID_UNICODE_CS:
|
|
|
|
case TT_MS_ID_SYMBOL_CS:
|
2017-01-25 15:08:41 +01:00
|
|
|
convert = tt_name_ascii_from_utf16;
|
2007-01-02 17:58:13 +01:00
|
|
|
break;
|
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
case TT_MS_ID_UCS_4:
|
2007-01-02 20:20:08 +01:00
|
|
|
/* Apparently, if this value is found in a name table entry, it is */
|
|
|
|
/* documented as `full Unicode repertoire'. Experience with the */
|
|
|
|
/* MsGothic font shipped with Windows Vista shows that this really */
|
|
|
|
/* means UTF-16 encoded names (UCS-4 values are only used within */
|
|
|
|
/* charmaps). */
|
2017-01-25 15:08:41 +01:00
|
|
|
convert = tt_name_ascii_from_utf16;
|
2002-03-31 20:48:24 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
}
|
2002-03-30 17:32:47 +01:00
|
|
|
else if ( found_apple >= 0 )
|
|
|
|
{
|
2002-05-28 01:52:01 +02:00
|
|
|
rec = face->name_table.names + found_apple;
|
2017-01-25 15:08:41 +01:00
|
|
|
convert = tt_name_ascii_from_other;
|
2002-03-30 17:32:47 +01:00
|
|
|
}
|
|
|
|
else if ( found_unicode >= 0 )
|
|
|
|
{
|
2002-05-28 01:52:01 +02:00
|
|
|
rec = face->name_table.names + found_unicode;
|
2017-01-25 15:08:41 +01:00
|
|
|
convert = tt_name_ascii_from_utf16;
|
2002-05-28 01:52:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( rec && convert )
|
|
|
|
{
|
2016-12-26 17:08:17 +01:00
|
|
|
if ( !rec->string )
|
2002-05-28 01:52:01 +02:00
|
|
|
{
|
|
|
|
FT_Stream stream = face->name_table.stream;
|
|
|
|
|
|
|
|
|
2004-06-23 17:44:03 +02:00
|
|
|
if ( FT_QNEW_ARRAY ( rec->string, rec->stringLength ) ||
|
2002-05-28 01:52:01 +02:00
|
|
|
FT_STREAM_SEEK( rec->stringOffset ) ||
|
|
|
|
FT_STREAM_READ( rec->string, rec->stringLength ) )
|
|
|
|
{
|
|
|
|
FT_FREE( rec->string );
|
|
|
|
rec->stringLength = 0;
|
|
|
|
result = NULL;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result = convert( rec, memory );
|
2002-03-30 17:32:47 +01:00
|
|
|
}
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-05-28 01:52:01 +02:00
|
|
|
Exit:
|
2008-11-08 08:20:25 +01:00
|
|
|
*name = result;
|
|
|
|
return error;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Encoding
|
2002-03-22 16:02:38 +01:00
|
|
|
sfnt_find_encoding( int platform_id,
|
|
|
|
int encoding_id )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2008-05-29 00:17:28 +02:00
|
|
|
typedef struct TEncoding_
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
|
|
|
int platform_id;
|
|
|
|
int encoding_id;
|
|
|
|
FT_Encoding encoding;
|
|
|
|
|
|
|
|
} TEncoding;
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
static
|
|
|
|
const TEncoding tt_encodings[] =
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
{ TT_PLATFORM_ISO, -1, FT_ENCODING_UNICODE },
|
2000-05-28 19:15:37 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
{ TT_PLATFORM_APPLE_UNICODE, -1, FT_ENCODING_UNICODE },
|
2000-05-28 19:15:37 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
{ TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, FT_ENCODING_APPLE_ROMAN },
|
2000-05-28 19:15:37 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, FT_ENCODING_MS_SYMBOL },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, FT_ENCODING_UNICODE },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE },
|
2003-09-01 09:06:06 +02:00
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, FT_ENCODING_SJIS },
|
2017-01-27 08:45:46 +01:00
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_PRC, FT_ENCODING_PRC },
|
2003-09-01 09:06:06 +02:00
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, FT_ENCODING_BIG5 },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, FT_ENCODING_WANSUNG },
|
|
|
|
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, FT_ENCODING_JOHAB }
|
2000-05-28 19:15:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const TEncoding *cur, *limit;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
cur = tt_encodings;
|
2000-06-05 07:26:15 +02:00
|
|
|
limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( cur->platform_id == platform_id )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( cur->encoding_id == encoding_id ||
|
|
|
|
cur->encoding_id == -1 )
|
2000-05-28 19:15:37 +02:00
|
|
|
return cur->encoding;
|
|
|
|
}
|
|
|
|
}
|
2000-06-05 07:26:15 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
return FT_ENCODING_NONE;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-13 09:28:00 +02:00
|
|
|
#define WRITE_USHORT( p, v ) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
*(p)++ = (FT_Byte)( (v) >> 8 ); \
|
|
|
|
*(p)++ = (FT_Byte)( (v) >> 0 ); \
|
|
|
|
\
|
2013-08-29 17:53:40 +02:00
|
|
|
} while ( 0 )
|
|
|
|
|
2014-06-13 09:28:00 +02:00
|
|
|
#define WRITE_ULONG( p, v ) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
*(p)++ = (FT_Byte)( (v) >> 24 ); \
|
|
|
|
*(p)++ = (FT_Byte)( (v) >> 16 ); \
|
|
|
|
*(p)++ = (FT_Byte)( (v) >> 8 ); \
|
|
|
|
*(p)++ = (FT_Byte)( (v) >> 0 ); \
|
|
|
|
\
|
2013-08-29 21:03:05 +02:00
|
|
|
} while ( 0 )
|
2013-08-29 17:53:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
sfnt_stream_close( FT_Stream stream )
|
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
|
|
|
|
|
|
|
FT_FREE( stream->base );
|
|
|
|
|
|
|
|
stream->size = 0;
|
2015-04-16 05:20:23 +02:00
|
|
|
stream->base = NULL;
|
|
|
|
stream->close = NULL;
|
2013-08-29 17:53:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( int )
|
|
|
|
compare_offsets( const void* a,
|
|
|
|
const void* b )
|
|
|
|
{
|
|
|
|
WOFF_Table table1 = *(WOFF_Table*)a;
|
|
|
|
WOFF_Table table2 = *(WOFF_Table*)b;
|
|
|
|
|
|
|
|
FT_ULong offset1 = table1->Offset;
|
|
|
|
FT_ULong offset2 = table2->Offset;
|
|
|
|
|
|
|
|
|
|
|
|
if ( offset1 > offset2 )
|
|
|
|
return 1;
|
|
|
|
else if ( offset1 < offset2 )
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Replace `face->root.stream' with a stream containing the extracted */
|
2013-08-29 21:03:05 +02:00
|
|
|
/* SFNT of a WOFF font. */
|
2013-08-29 17:53:40 +02:00
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
woff_open_font( FT_Stream stream,
|
|
|
|
TT_Face face )
|
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
|
|
|
|
WOFF_HeaderRec woff;
|
|
|
|
WOFF_Table tables = NULL;
|
|
|
|
WOFF_Table* indices = NULL;
|
|
|
|
|
|
|
|
FT_ULong woff_offset;
|
|
|
|
|
|
|
|
FT_Byte* sfnt = NULL;
|
|
|
|
FT_Stream sfnt_stream = NULL;
|
|
|
|
|
|
|
|
FT_Byte* sfnt_header;
|
|
|
|
FT_ULong sfnt_offset;
|
|
|
|
|
|
|
|
FT_Int nn;
|
|
|
|
FT_ULong old_tag = 0;
|
|
|
|
|
|
|
|
static const FT_Frame_Field woff_header_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WOFF_HeaderRec
|
|
|
|
|
|
|
|
FT_FRAME_START( 44 ),
|
|
|
|
FT_FRAME_ULONG ( signature ),
|
|
|
|
FT_FRAME_ULONG ( flavor ),
|
|
|
|
FT_FRAME_ULONG ( length ),
|
|
|
|
FT_FRAME_USHORT( num_tables ),
|
|
|
|
FT_FRAME_USHORT( reserved ),
|
|
|
|
FT_FRAME_ULONG ( totalSfntSize ),
|
|
|
|
FT_FRAME_USHORT( majorVersion ),
|
|
|
|
FT_FRAME_USHORT( minorVersion ),
|
|
|
|
FT_FRAME_ULONG ( metaOffset ),
|
|
|
|
FT_FRAME_ULONG ( metaLength ),
|
|
|
|
FT_FRAME_ULONG ( metaOrigLength ),
|
|
|
|
FT_FRAME_ULONG ( privOffset ),
|
|
|
|
FT_FRAME_ULONG ( privLength ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
FT_ASSERT( stream == face->root.stream );
|
|
|
|
FT_ASSERT( FT_STREAM_POS() == 0 );
|
|
|
|
|
|
|
|
if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) )
|
|
|
|
return error;
|
|
|
|
|
2013-08-29 21:03:05 +02:00
|
|
|
/* Make sure we don't recurse back here or hit TTC code. */
|
2013-08-29 17:53:40 +02:00
|
|
|
if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf )
|
|
|
|
return FT_THROW( Invalid_Table );
|
|
|
|
|
|
|
|
/* Miscellaneous checks. */
|
|
|
|
if ( woff.length != stream->size ||
|
|
|
|
woff.num_tables == 0 ||
|
|
|
|
44 + woff.num_tables * 20UL >= woff.length ||
|
|
|
|
12 + woff.num_tables * 16UL >= woff.totalSfntSize ||
|
|
|
|
( woff.totalSfntSize & 3 ) != 0 ||
|
|
|
|
( woff.metaOffset == 0 && ( woff.metaLength != 0 ||
|
|
|
|
woff.metaOrigLength != 0 ) ) ||
|
|
|
|
( woff.metaLength != 0 && woff.metaOrigLength == 0 ) ||
|
|
|
|
( woff.privOffset == 0 && woff.privLength != 0 ) )
|
2015-10-21 08:04:29 +02:00
|
|
|
{
|
|
|
|
FT_ERROR(( "woff_font_open: invalid WOFF header\n" ));
|
2013-08-29 17:53:40 +02:00
|
|
|
return FT_THROW( Invalid_Table );
|
2015-10-21 08:04:29 +02:00
|
|
|
}
|
2013-08-29 17:53:40 +02:00
|
|
|
|
2015-10-21 08:04:29 +02:00
|
|
|
/* Don't trust `totalSfntSize' before thorough checks. */
|
|
|
|
if ( FT_ALLOC( sfnt, 12 + woff.num_tables * 16UL ) ||
|
|
|
|
FT_NEW( sfnt_stream ) )
|
2013-08-29 17:53:40 +02:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
sfnt_header = sfnt;
|
|
|
|
|
|
|
|
/* Write sfnt header. */
|
|
|
|
{
|
|
|
|
FT_UInt searchRange, entrySelector, rangeShift, x;
|
|
|
|
|
|
|
|
|
|
|
|
x = woff.num_tables;
|
|
|
|
entrySelector = 0;
|
|
|
|
while ( x )
|
|
|
|
{
|
|
|
|
x >>= 1;
|
|
|
|
entrySelector += 1;
|
|
|
|
}
|
|
|
|
entrySelector--;
|
|
|
|
|
|
|
|
searchRange = ( 1 << entrySelector ) * 16;
|
|
|
|
rangeShift = woff.num_tables * 16 - searchRange;
|
|
|
|
|
|
|
|
WRITE_ULONG ( sfnt_header, woff.flavor );
|
|
|
|
WRITE_USHORT( sfnt_header, woff.num_tables );
|
|
|
|
WRITE_USHORT( sfnt_header, searchRange );
|
|
|
|
WRITE_USHORT( sfnt_header, entrySelector );
|
|
|
|
WRITE_USHORT( sfnt_header, rangeShift );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* While the entries in the sfnt header must be sorted by the */
|
|
|
|
/* tag value, the tables themselves are not. We thus have to */
|
|
|
|
/* sort them by offset and check that they don't overlap. */
|
|
|
|
|
|
|
|
if ( FT_NEW_ARRAY( tables, woff.num_tables ) ||
|
|
|
|
FT_NEW_ARRAY( indices, woff.num_tables ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
FT_TRACE2(( "\n"
|
|
|
|
" tag offset compLen origLen checksum\n"
|
|
|
|
" -------------------------------------------\n" ));
|
|
|
|
|
2013-08-29 21:03:05 +02:00
|
|
|
if ( FT_FRAME_ENTER( 20L * woff.num_tables ) )
|
|
|
|
goto Exit;
|
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
for ( nn = 0; nn < woff.num_tables; nn++ )
|
|
|
|
{
|
|
|
|
WOFF_Table table = tables + nn;
|
|
|
|
|
|
|
|
table->Tag = FT_GET_TAG4();
|
|
|
|
table->Offset = FT_GET_ULONG();
|
|
|
|
table->CompLength = FT_GET_ULONG();
|
|
|
|
table->OrigLength = FT_GET_ULONG();
|
|
|
|
table->CheckSum = FT_GET_ULONG();
|
|
|
|
|
|
|
|
FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n",
|
|
|
|
(FT_Char)( table->Tag >> 24 ),
|
|
|
|
(FT_Char)( table->Tag >> 16 ),
|
|
|
|
(FT_Char)( table->Tag >> 8 ),
|
|
|
|
(FT_Char)( table->Tag ),
|
|
|
|
table->Offset,
|
|
|
|
table->CompLength,
|
|
|
|
table->OrigLength,
|
|
|
|
table->CheckSum ));
|
|
|
|
|
|
|
|
if ( table->Tag <= old_tag )
|
|
|
|
{
|
2013-08-29 21:03:05 +02:00
|
|
|
FT_FRAME_EXIT();
|
2015-10-21 08:04:29 +02:00
|
|
|
|
|
|
|
FT_ERROR(( "woff_font_open: table tags are not sorted\n" ));
|
2013-08-29 17:53:40 +02:00
|
|
|
error = FT_THROW( Invalid_Table );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
old_tag = table->Tag;
|
|
|
|
indices[nn] = table;
|
|
|
|
}
|
|
|
|
|
2013-08-29 21:03:05 +02:00
|
|
|
FT_FRAME_EXIT();
|
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
/* Sort by offset. */
|
|
|
|
|
|
|
|
ft_qsort( indices,
|
|
|
|
woff.num_tables,
|
|
|
|
sizeof ( WOFF_Table ),
|
|
|
|
compare_offsets );
|
|
|
|
|
|
|
|
/* Check offsets and lengths. */
|
|
|
|
|
|
|
|
woff_offset = 44 + woff.num_tables * 20L;
|
|
|
|
sfnt_offset = 12 + woff.num_tables * 16L;
|
|
|
|
|
|
|
|
for ( nn = 0; nn < woff.num_tables; nn++ )
|
|
|
|
{
|
|
|
|
WOFF_Table table = indices[nn];
|
|
|
|
|
|
|
|
|
|
|
|
if ( table->Offset != woff_offset ||
|
2014-11-12 21:06:08 +01:00
|
|
|
table->CompLength > woff.length ||
|
|
|
|
table->Offset > woff.length - table->CompLength ||
|
|
|
|
table->OrigLength > woff.totalSfntSize ||
|
|
|
|
sfnt_offset > woff.totalSfntSize - table->OrigLength ||
|
2013-08-29 17:53:40 +02:00
|
|
|
table->CompLength > table->OrigLength )
|
|
|
|
{
|
2015-10-21 08:04:29 +02:00
|
|
|
FT_ERROR(( "woff_font_open: invalid table offsets\n" ));
|
2013-08-29 17:53:40 +02:00
|
|
|
error = FT_THROW( Invalid_Table );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
table->OrigOffset = sfnt_offset;
|
|
|
|
|
|
|
|
/* The offsets must be multiples of 4. */
|
2015-02-22 12:03:28 +01:00
|
|
|
woff_offset += ( table->CompLength + 3 ) & ~3U;
|
|
|
|
sfnt_offset += ( table->OrigLength + 3 ) & ~3U;
|
2013-08-29 17:53:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Final checks!
|
|
|
|
*
|
|
|
|
* We don't decode and check the metadata block.
|
|
|
|
* We don't check table checksums either.
|
|
|
|
* But other than those, I think we implement all
|
|
|
|
* `MUST' checks from the spec.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( woff.metaOffset )
|
|
|
|
{
|
|
|
|
if ( woff.metaOffset != woff_offset ||
|
|
|
|
woff.metaOffset + woff.metaLength > woff.length )
|
|
|
|
{
|
2015-10-21 08:04:29 +02:00
|
|
|
FT_ERROR(( "woff_font_open:"
|
|
|
|
" invalid `metadata' offset or length\n" ));
|
2013-08-29 17:53:40 +02:00
|
|
|
error = FT_THROW( Invalid_Table );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have padding only ... */
|
|
|
|
woff_offset += woff.metaLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( woff.privOffset )
|
|
|
|
{
|
|
|
|
/* ... if it isn't the last block. */
|
2015-02-22 12:03:28 +01:00
|
|
|
woff_offset = ( woff_offset + 3 ) & ~3U;
|
2013-08-29 17:53:40 +02:00
|
|
|
|
|
|
|
if ( woff.privOffset != woff_offset ||
|
|
|
|
woff.privOffset + woff.privLength > woff.length )
|
|
|
|
{
|
2015-10-21 08:04:29 +02:00
|
|
|
FT_ERROR(( "woff_font_open: invalid `private' offset or length\n" ));
|
2013-08-29 17:53:40 +02:00
|
|
|
error = FT_THROW( Invalid_Table );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No padding for the last block. */
|
|
|
|
woff_offset += woff.privLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( sfnt_offset != woff.totalSfntSize ||
|
|
|
|
woff_offset != woff.length )
|
|
|
|
{
|
2015-10-21 08:04:29 +02:00
|
|
|
FT_ERROR(( "woff_font_open: invalid `sfnt' table structure\n" ));
|
2013-08-29 17:53:40 +02:00
|
|
|
error = FT_THROW( Invalid_Table );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2015-10-21 08:04:29 +02:00
|
|
|
/* Now use `totalSfntSize'. */
|
|
|
|
if ( FT_REALLOC( sfnt,
|
|
|
|
12 + woff.num_tables * 16UL,
|
|
|
|
woff.totalSfntSize ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
sfnt_header = sfnt + 12;
|
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
/* Write the tables. */
|
|
|
|
|
|
|
|
for ( nn = 0; nn < woff.num_tables; nn++ )
|
|
|
|
{
|
|
|
|
WOFF_Table table = tables + nn;
|
|
|
|
|
|
|
|
|
|
|
|
/* Write SFNT table entry. */
|
|
|
|
WRITE_ULONG( sfnt_header, table->Tag );
|
|
|
|
WRITE_ULONG( sfnt_header, table->CheckSum );
|
|
|
|
WRITE_ULONG( sfnt_header, table->OrigOffset );
|
|
|
|
WRITE_ULONG( sfnt_header, table->OrigLength );
|
|
|
|
|
|
|
|
/* Write table data. */
|
|
|
|
if ( FT_STREAM_SEEK( table->Offset ) ||
|
|
|
|
FT_FRAME_ENTER( table->CompLength ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( table->CompLength == table->OrigLength )
|
|
|
|
{
|
|
|
|
/* Uncompressed data; just copy. */
|
|
|
|
ft_memcpy( sfnt + table->OrigOffset,
|
|
|
|
stream->cursor,
|
|
|
|
table->OrigLength );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-03 05:45:38 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_USE_ZLIB
|
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
/* Uncompress with zlib. */
|
|
|
|
FT_ULong output_len = table->OrigLength;
|
|
|
|
|
|
|
|
|
|
|
|
error = FT_Gzip_Uncompress( memory,
|
|
|
|
sfnt + table->OrigOffset, &output_len,
|
|
|
|
stream->cursor, table->CompLength );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
if ( output_len != table->OrigLength )
|
|
|
|
{
|
2015-10-21 08:04:29 +02:00
|
|
|
FT_ERROR(( "woff_font_open: compressed table length mismatch\n" ));
|
2013-08-29 17:53:40 +02:00
|
|
|
error = FT_THROW( Invalid_Table );
|
|
|
|
goto Exit;
|
|
|
|
}
|
2014-04-03 05:45:38 +02:00
|
|
|
|
|
|
|
#else /* !FT_CONFIG_OPTION_USE_ZLIB */
|
|
|
|
|
|
|
|
error = FT_THROW( Unimplemented_Feature );
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
|
2013-08-29 17:53:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FT_FRAME_EXIT();
|
|
|
|
|
|
|
|
/* We don't check whether the padding bytes in the WOFF file are */
|
|
|
|
/* actually '\0'. For the output, however, we do set them properly. */
|
|
|
|
sfnt_offset = table->OrigOffset + table->OrigLength;
|
|
|
|
while ( sfnt_offset & 3 )
|
|
|
|
{
|
|
|
|
sfnt[sfnt_offset] = '\0';
|
|
|
|
sfnt_offset++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ok! Finally ready. Swap out stream and return. */
|
|
|
|
FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize );
|
|
|
|
sfnt_stream->memory = stream->memory;
|
|
|
|
sfnt_stream->close = sfnt_stream_close;
|
|
|
|
|
|
|
|
FT_Stream_Free(
|
|
|
|
face->root.stream,
|
|
|
|
( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
|
|
|
|
|
2013-08-29 21:03:05 +02:00
|
|
|
face->root.stream = sfnt_stream;
|
2013-08-29 17:53:40 +02:00
|
|
|
|
|
|
|
face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
FT_FREE( tables );
|
|
|
|
FT_FREE( indices );
|
|
|
|
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
FT_FREE( sfnt );
|
|
|
|
FT_Stream_Close( sfnt_stream );
|
|
|
|
FT_FREE( sfnt_stream );
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2013-08-29 21:03:05 +02:00
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
#undef WRITE_USHORT
|
|
|
|
#undef WRITE_ULONG
|
|
|
|
|
|
|
|
|
2006-02-14 08:01:29 +01:00
|
|
|
/* Fill in face->ttc_header. If the font is not a TTC, it is */
|
|
|
|
/* synthesized into a TTC with one offset table. */
|
|
|
|
static FT_Error
|
|
|
|
sfnt_open_font( FT_Stream stream,
|
|
|
|
TT_Face face )
|
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_Error error;
|
|
|
|
FT_ULong tag, offset;
|
|
|
|
|
|
|
|
static const FT_Frame_Field ttc_header_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE TTC_HeaderRec
|
|
|
|
|
|
|
|
FT_FRAME_START( 8 ),
|
|
|
|
FT_FRAME_LONG( version ),
|
2011-03-20 07:51:57 +01:00
|
|
|
FT_FRAME_LONG( count ), /* this is ULong in the specs */
|
2006-02-14 08:01:29 +01:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
face->ttc_header.tag = 0;
|
|
|
|
face->ttc_header.version = 0;
|
|
|
|
face->ttc_header.count = 0;
|
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
retry:
|
2006-02-14 08:01:29 +01:00
|
|
|
offset = FT_STREAM_POS();
|
|
|
|
|
|
|
|
if ( FT_READ_ULONG( tag ) )
|
|
|
|
return error;
|
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
if ( tag == TTAG_wOFF )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "sfnt_open_font: file is a WOFF; synthesizing SFNT\n" ));
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( offset ) )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
error = woff_open_font( stream, face );
|
|
|
|
if ( error )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
/* Swap out stream and retry! */
|
|
|
|
stream = face->root.stream;
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2008-10-05 08:08:40 +02:00
|
|
|
if ( tag != 0x00010000UL &&
|
|
|
|
tag != TTAG_ttcf &&
|
|
|
|
tag != TTAG_OTTO &&
|
|
|
|
tag != TTAG_true &&
|
|
|
|
tag != TTAG_typ1 &&
|
2017-09-08 17:59:33 +02:00
|
|
|
tag != TTAG_0xA5kbd &&
|
|
|
|
tag != TTAG_0xA5lst &&
|
2008-10-05 08:08:40 +02:00
|
|
|
tag != 0x00020000UL )
|
Improve tracing.
* src/bdf/bdfdrivr.c (BDF_Face_Done), src/pcf/pcfdrivr.c
(PCF_Face_Done): Remove tracing message.
* src/bdf/bdfdrivr.c (BDF_Face_Init), src/cff/cffobjs.c
(cff_face_init), src/cid/cidobjs.c (cid_face_init),
src/pfr/pfrobjs.c (pfr_face_init), src/sfnt/sfobjs.c
(sfnt_init_face), src/truetype/ttobjs.c (tt_face_init),
src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c
(T42_Face_Init), src/winfonts/winfnt.c (FNT_Face_Init): Add
`greeting' message.
* src/sfnt/sfobjs.c (sfnt_open_font), src/type42/t42objs.c
(T42_Open_Face): Improve tracing.
2011-11-26 20:09:39 +01:00
|
|
|
{
|
|
|
|
FT_TRACE2(( " not a font using the SFNT container format\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unknown_File_Format );
|
Improve tracing.
* src/bdf/bdfdrivr.c (BDF_Face_Done), src/pcf/pcfdrivr.c
(PCF_Face_Done): Remove tracing message.
* src/bdf/bdfdrivr.c (BDF_Face_Init), src/cff/cffobjs.c
(cff_face_init), src/cid/cidobjs.c (cid_face_init),
src/pfr/pfrobjs.c (pfr_face_init), src/sfnt/sfobjs.c
(sfnt_init_face), src/truetype/ttobjs.c (tt_face_init),
src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c
(T42_Face_Init), src/winfonts/winfnt.c (FNT_Face_Init): Add
`greeting' message.
* src/sfnt/sfobjs.c (sfnt_open_font), src/type42/t42objs.c
(T42_Open_Face): Improve tracing.
2011-11-26 20:09:39 +01:00
|
|
|
}
|
2006-02-14 08:01:29 +01:00
|
|
|
|
|
|
|
face->ttc_header.tag = TTAG_ttcf;
|
|
|
|
|
|
|
|
if ( tag == TTAG_ttcf )
|
|
|
|
{
|
|
|
|
FT_Int n;
|
|
|
|
|
|
|
|
|
|
|
|
FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
|
|
|
|
|
|
|
|
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
|
|
|
|
return error;
|
|
|
|
|
2016-12-17 10:02:19 +01:00
|
|
|
FT_TRACE3(( " with %ld subfonts\n",
|
|
|
|
face->ttc_header.count ));
|
|
|
|
|
2011-03-20 07:51:57 +01:00
|
|
|
if ( face->ttc_header.count == 0 )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Table );
|
2011-03-20 07:51:57 +01:00
|
|
|
|
|
|
|
/* a rough size estimate: let's conservatively assume that there */
|
|
|
|
/* is just a single table info in each subfont header (12 + 16*1 = */
|
|
|
|
/* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
|
|
|
|
/* size of the TTC header plus `28*count' bytes for all subfont */
|
|
|
|
/* headers */
|
|
|
|
if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Array_Too_Large );
|
2011-03-20 07:51:57 +01:00
|
|
|
|
2006-02-14 08:01:29 +01:00
|
|
|
/* now read the offsets of each font in the file */
|
|
|
|
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
for ( n = 0; n < face->ttc_header.count; n++ )
|
|
|
|
face->ttc_header.offsets[n] = FT_GET_ULONG();
|
|
|
|
|
|
|
|
FT_FRAME_EXIT();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" ));
|
|
|
|
|
|
|
|
face->ttc_header.version = 1 << 16;
|
|
|
|
face->ttc_header.count = 1;
|
|
|
|
|
2009-02-09 23:20:27 +01:00
|
|
|
if ( FT_NEW( face->ttc_header.offsets ) )
|
2006-02-14 08:01:29 +01:00
|
|
|
return error;
|
|
|
|
|
|
|
|
face->ttc_header.offsets[0] = offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
sfnt_init_face( FT_Stream stream,
|
2001-06-28 01:25:46 +02:00
|
|
|
TT_Face face,
|
2015-08-13 15:22:17 +02:00
|
|
|
FT_Int face_instance_index,
|
2001-06-28 01:25:46 +02:00
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2015-08-13 15:22:17 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_Library library = face->root.driver->root.library;
|
|
|
|
SFNT_Service sfnt;
|
|
|
|
FT_Int face_index;
|
2006-02-14 08:01:29 +01:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* for now, parameters are unused */
|
2000-07-04 20:12:13 +02:00
|
|
|
FT_UNUSED( num_params );
|
|
|
|
FT_UNUSED( params );
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2002-02-28 17:10:29 +01:00
|
|
|
sfnt = (SFNT_Service)face->sfnt;
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( !sfnt )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2002-02-28 17:10:29 +01:00
|
|
|
sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( !sfnt )
|
2011-11-26 13:38:26 +01:00
|
|
|
{
|
|
|
|
FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Missing_Module );
|
2011-11-26 13:38:26 +01:00
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
face->sfnt = sfnt;
|
|
|
|
face->goto_table = sfnt->goto_table;
|
|
|
|
}
|
|
|
|
|
* include/freetype/internal/bdftypes.h: removed obsolete header
* include/freetype/internal/cfftypes.h, src/cff/cfftypes.h,
src/cff/cffload.h, src/cff/cffobjs.h, src/cff/cffparse.h,
include/freetype/internal/services/svbdf.h: moving "cfftypes.h" from
'include/freetype/internal' to 'src/cff' since no other modules needs
to known about these types
* include/freetype/internal/t42types.h,
include/freetype/internal/internal.h, src/type42/t42objs.h,
src/type42/t42drivr.c, src/type42/t42types.h: moving "t42types.h" from
'include/freetype/internal' to 'src/type42' since no other modules needs
to known about these types
* src/gzip/infblock.c: removing compiler warning
* include/freetype/internal/services/svpsinfo.h,
include/freetype/internal/ftserv.h, src/cff/cffdrivr.c,
src/cid/ciddrivr.c, src/type1/t1driver.c, src/type42/t42drivr.c,
src/base/fttype1.c: migrating to FT_SERVICE_ID_POSTSCRIPT_INFO defined
in "svpsinfo.h", removing some sad hacks.
2003-10-29 22:43:52 +01:00
|
|
|
FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2016-12-14 19:31:42 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
if ( !face->mm )
|
|
|
|
{
|
|
|
|
/* we want the MM interface from the `truetype' module only */
|
|
|
|
FT_Module tt_module = FT_Get_Module( library, "truetype" );
|
|
|
|
|
|
|
|
|
|
|
|
face->mm = ft_module_get_service( tt_module,
|
|
|
|
FT_SERVICE_ID_MULTI_MASTERS,
|
|
|
|
0 );
|
|
|
|
}
|
2016-12-14 20:44:11 +01:00
|
|
|
|
2017-01-31 23:06:38 +01:00
|
|
|
if ( !face->var )
|
|
|
|
{
|
|
|
|
/* we want the metrics variations interface */
|
|
|
|
/* from the `truetype' module only */
|
|
|
|
FT_Module tt_module = FT_Get_Module( library, "truetype" );
|
|
|
|
|
|
|
|
|
|
|
|
face->var = ft_module_get_service( tt_module,
|
|
|
|
FT_SERVICE_ID_METRICS_VARIATIONS,
|
|
|
|
0 );
|
|
|
|
}
|
2016-12-14 19:31:42 +01:00
|
|
|
#endif
|
|
|
|
|
Improve tracing.
* src/bdf/bdfdrivr.c (BDF_Face_Done), src/pcf/pcfdrivr.c
(PCF_Face_Done): Remove tracing message.
* src/bdf/bdfdrivr.c (BDF_Face_Init), src/cff/cffobjs.c
(cff_face_init), src/cid/cidobjs.c (cid_face_init),
src/pfr/pfrobjs.c (pfr_face_init), src/sfnt/sfobjs.c
(sfnt_init_face), src/truetype/ttobjs.c (tt_face_init),
src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c
(T42_Face_Init), src/winfonts/winfnt.c (FNT_Face_Init): Add
`greeting' message.
* src/sfnt/sfobjs.c (sfnt_open_font), src/type42/t42objs.c
(T42_Open_Face): Improve tracing.
2011-11-26 20:09:39 +01:00
|
|
|
FT_TRACE2(( "SFNT driver\n" ));
|
|
|
|
|
2006-02-14 08:01:29 +01:00
|
|
|
error = sfnt_open_font( stream, face );
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( error )
|
2006-02-14 08:01:29 +01:00
|
|
|
return error;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2013-08-29 17:53:40 +02:00
|
|
|
/* Stream may have changed in sfnt_open_font. */
|
|
|
|
stream = face->root.stream;
|
|
|
|
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
FT_TRACE2(( "sfnt_init_face: %08p (index %d)\n",
|
|
|
|
face,
|
|
|
|
face_instance_index ));
|
2000-05-29 22:37:41 +02:00
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
face_index = FT_ABS( face_instance_index ) & 0xFFFF;
|
2006-02-14 08:01:29 +01:00
|
|
|
|
2017-01-01 10:43:41 +01:00
|
|
|
/* value -(N+1) requests information on index N */
|
|
|
|
if ( face_instance_index < 0 )
|
|
|
|
face_index--;
|
|
|
|
|
2006-02-14 08:01:29 +01:00
|
|
|
if ( face_index >= face->ttc_header.count )
|
2015-08-13 15:22:17 +02:00
|
|
|
{
|
|
|
|
if ( face_instance_index >= 0 )
|
|
|
|
return FT_THROW( Invalid_Argument );
|
|
|
|
else
|
|
|
|
face_index = 0;
|
|
|
|
}
|
2006-02-14 08:01:29 +01:00
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) )
|
|
|
|
return error;
|
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
/* check whether we have a valid TrueType file */
|
2006-02-14 08:01:29 +01:00
|
|
|
error = sfnt->load_font_dir( face, stream );
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( error )
|
2006-02-14 08:01:29 +01:00
|
|
|
return error;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
{
|
2017-03-17 21:47:54 +01:00
|
|
|
FT_Memory memory = face->root.memory;
|
|
|
|
|
2015-10-11 07:55:25 +02:00
|
|
|
FT_ULong fvar_len;
|
|
|
|
|
|
|
|
FT_ULong version;
|
|
|
|
FT_ULong offset;
|
|
|
|
|
|
|
|
FT_UShort num_axes;
|
|
|
|
FT_UShort axis_size;
|
2015-08-13 15:22:17 +02:00
|
|
|
FT_UShort num_instances;
|
2015-10-11 07:55:25 +02:00
|
|
|
FT_UShort instance_size;
|
|
|
|
|
|
|
|
FT_Int instance_index;
|
2015-08-13 15:22:17 +02:00
|
|
|
|
2017-03-06 20:45:44 +01:00
|
|
|
FT_Byte* default_values = NULL;
|
|
|
|
FT_Byte* instance_values = NULL;
|
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
|
|
|
|
instance_index = FT_ABS( face_instance_index ) >> 16;
|
|
|
|
|
|
|
|
/* test whether current face is a GX font with named instances */
|
|
|
|
if ( face->goto_table( face, TTAG_fvar, stream, &fvar_len ) ||
|
|
|
|
fvar_len < 20 ||
|
2015-10-11 07:55:25 +02:00
|
|
|
FT_READ_ULONG( version ) ||
|
|
|
|
FT_READ_USHORT( offset ) ||
|
2017-03-05 11:32:41 +01:00
|
|
|
FT_STREAM_SKIP( 2 ) /* reserved */ ||
|
2015-10-11 07:55:25 +02:00
|
|
|
FT_READ_USHORT( num_axes ) ||
|
|
|
|
FT_READ_USHORT( axis_size ) ||
|
|
|
|
FT_READ_USHORT( num_instances ) ||
|
|
|
|
FT_READ_USHORT( instance_size ) )
|
|
|
|
{
|
|
|
|
version = 0;
|
2015-10-22 10:17:20 +02:00
|
|
|
offset = 0;
|
2015-10-11 07:55:25 +02:00
|
|
|
num_axes = 0;
|
|
|
|
axis_size = 0;
|
|
|
|
num_instances = 0;
|
|
|
|
instance_size = 0;
|
|
|
|
}
|
|
|
|
|
2016-12-18 15:50:18 +01:00
|
|
|
/* check that the data is bound by the table length */
|
2015-10-11 07:55:25 +02:00
|
|
|
if ( version != 0x00010000UL ||
|
|
|
|
axis_size != 20 ||
|
2016-12-17 13:28:24 +01:00
|
|
|
num_axes == 0 ||
|
2016-12-18 15:50:18 +01:00
|
|
|
/* `num_axes' limit implied by 16-bit `instance_size' */
|
2015-10-11 07:55:25 +02:00
|
|
|
num_axes > 0x3FFE ||
|
2016-12-18 15:50:18 +01:00
|
|
|
!( instance_size == 4 + 4 * num_axes ||
|
|
|
|
instance_size == 6 + 4 * num_axes ) ||
|
2017-03-05 11:32:41 +01:00
|
|
|
/* `num_instances' limit implied by limited range of name IDs */
|
2015-10-11 07:55:25 +02:00
|
|
|
num_instances > 0x7EFF ||
|
|
|
|
offset +
|
|
|
|
axis_size * num_axes +
|
|
|
|
instance_size * num_instances > fvar_len )
|
2016-12-21 19:30:33 +01:00
|
|
|
num_instances = 0;
|
2016-12-18 15:50:18 +01:00
|
|
|
else
|
2016-12-21 19:30:33 +01:00
|
|
|
face->variation_support |= TT_FACE_FLAG_VAR_FVAR;
|
2015-08-13 15:22:17 +02:00
|
|
|
|
2017-03-06 20:45:44 +01:00
|
|
|
/*
|
2018-06-03 09:01:17 +02:00
|
|
|
* As documented in the OpenType specification, an entry for the
|
|
|
|
* default instance may be omitted in the named instance table. In
|
|
|
|
* particular this means that even if there is no named instance
|
|
|
|
* table in the font we actually do have a named instance, namely the
|
|
|
|
* default instance.
|
2017-03-06 20:45:44 +01:00
|
|
|
*
|
2018-06-03 09:01:17 +02:00
|
|
|
* For consistency, we always want the default instance in our list
|
|
|
|
* of named instances. If it is missing, we try to synthesize it
|
|
|
|
* later on. Here, we have to adjust `num_instances' accordingly.
|
2017-03-06 20:45:44 +01:00
|
|
|
*/
|
|
|
|
|
2017-03-20 05:36:41 +01:00
|
|
|
if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) &&
|
2017-03-23 18:37:06 +01:00
|
|
|
!( FT_ALLOC( default_values, num_axes * 4 ) ||
|
|
|
|
FT_ALLOC( instance_values, num_axes * 4 ) ) )
|
2017-03-06 20:45:44 +01:00
|
|
|
{
|
|
|
|
/* the current stream position is 16 bytes after the table start */
|
|
|
|
FT_ULong array_start = FT_STREAM_POS() - 16 + offset;
|
|
|
|
FT_ULong default_value_offset, instance_offset;
|
|
|
|
|
|
|
|
FT_Byte* p;
|
|
|
|
FT_UInt i;
|
|
|
|
|
|
|
|
|
|
|
|
default_value_offset = array_start + 8;
|
|
|
|
p = default_values;
|
|
|
|
|
|
|
|
for ( i = 0; i < num_axes; i++ )
|
|
|
|
{
|
2017-03-23 18:37:06 +01:00
|
|
|
(void)FT_STREAM_READ_AT( default_value_offset, p, 4 );
|
2017-03-06 20:45:44 +01:00
|
|
|
|
|
|
|
default_value_offset += axis_size;
|
2017-03-23 18:37:06 +01:00
|
|
|
p += 4;
|
2017-03-06 20:45:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
instance_offset = array_start + axis_size * num_axes + 4;
|
|
|
|
|
|
|
|
for ( i = 0; i < num_instances; i++ )
|
|
|
|
{
|
|
|
|
(void)FT_STREAM_READ_AT( instance_offset,
|
|
|
|
instance_values,
|
2017-03-23 18:37:06 +01:00
|
|
|
num_axes * 4 );
|
2017-03-06 20:45:44 +01:00
|
|
|
|
2017-03-23 18:37:06 +01:00
|
|
|
if ( !ft_memcmp( default_values, instance_values, num_axes * 4 ) )
|
2017-03-06 20:45:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
instance_offset += instance_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( i == num_instances )
|
|
|
|
{
|
|
|
|
/* no default instance in named instance table; */
|
|
|
|
/* we thus have to synthesize it */
|
|
|
|
num_instances++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_FREE( default_values );
|
|
|
|
FT_FREE( instance_values );
|
|
|
|
|
2017-03-08 15:09:41 +01:00
|
|
|
/* we don't support Multiple Master CFFs yet; */
|
|
|
|
/* note that `glyf' or `CFF2' have precedence */
|
2017-03-07 17:27:58 +01:00
|
|
|
if ( face->goto_table( face, TTAG_glyf, stream, 0 ) &&
|
2017-03-08 15:09:41 +01:00
|
|
|
face->goto_table( face, TTAG_CFF2, stream, 0 ) &&
|
2017-03-07 17:27:58 +01:00
|
|
|
!face->goto_table( face, TTAG_CFF, stream, 0 ) )
|
|
|
|
num_instances = 0;
|
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
/* instance indices in `face_instance_index' start with index 1, */
|
|
|
|
/* thus `>' and not `>=' */
|
|
|
|
if ( instance_index > num_instances )
|
|
|
|
{
|
|
|
|
if ( face_instance_index >= 0 )
|
|
|
|
return FT_THROW( Invalid_Argument );
|
|
|
|
else
|
|
|
|
num_instances = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
face->root.style_flags = (FT_Long)num_instances << 16;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-12-26 00:52:00 +01:00
|
|
|
face->root.num_faces = face->ttc_header.count;
|
2016-07-14 10:25:20 +02:00
|
|
|
face->root.face_index = face_instance_index;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
#define LOAD_( x ) \
|
2013-12-02 09:52:38 +01:00
|
|
|
do \
|
|
|
|
{ \
|
2013-03-14 17:50:49 +01:00
|
|
|
FT_TRACE2(( "`" #x "' " )); \
|
|
|
|
FT_TRACE3(( "-->\n" )); \
|
|
|
|
\
|
|
|
|
error = sfnt->load_ ## x( face, stream ); \
|
|
|
|
\
|
|
|
|
FT_TRACE2(( "%s\n", ( !error ) \
|
|
|
|
? "loaded" \
|
|
|
|
: FT_ERR_EQ( error, Table_Missing ) \
|
|
|
|
? "missing" \
|
|
|
|
: "failed to load" )); \
|
|
|
|
FT_TRACE3(( "\n" )); \
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
} while ( 0 )
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
#define LOADM_( x, vertical ) \
|
2013-12-02 09:52:38 +01:00
|
|
|
do \
|
|
|
|
{ \
|
2013-03-14 17:50:49 +01:00
|
|
|
FT_TRACE2(( "`%s" #x "' ", \
|
|
|
|
vertical ? "vertical " : "" )); \
|
|
|
|
FT_TRACE3(( "-->\n" )); \
|
|
|
|
\
|
|
|
|
error = sfnt->load_ ## x( face, stream, vertical ); \
|
|
|
|
\
|
|
|
|
FT_TRACE2(( "%s\n", ( !error ) \
|
|
|
|
? "loaded" \
|
|
|
|
: FT_ERR_EQ( error, Table_Missing ) \
|
|
|
|
? "missing" \
|
|
|
|
: "failed to load" )); \
|
|
|
|
FT_TRACE3(( "\n" )); \
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
} while ( 0 )
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2012-08-27 05:48:23 +02:00
|
|
|
#define GET_NAME( id, field ) \
|
2013-12-02 09:52:38 +01:00
|
|
|
do \
|
|
|
|
{ \
|
2012-08-27 05:48:23 +02:00
|
|
|
error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
|
|
|
|
if ( error ) \
|
|
|
|
goto Exit; \
|
2008-11-08 08:20:25 +01:00
|
|
|
} while ( 0 )
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
sfnt_load_face( FT_Stream stream,
|
2001-06-28 01:25:46 +02:00
|
|
|
TT_Face face,
|
2015-08-13 15:22:17 +02:00
|
|
|
FT_Int face_instance_index,
|
2001-06-28 01:25:46 +02:00
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2008-10-02 00:46:26 +02:00
|
|
|
FT_Error error;
|
|
|
|
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
|
|
|
FT_Error psnames_error;
|
|
|
|
#endif
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_Bool has_outline;
|
|
|
|
FT_Bool is_apple_sbit;
|
2013-07-19 14:28:28 +02:00
|
|
|
FT_Bool is_apple_sbix;
|
2018-02-17 18:35:15 +01:00
|
|
|
FT_Bool has_CBLC;
|
|
|
|
FT_Bool has_CBDT;
|
2017-01-24 17:00:36 +01:00
|
|
|
FT_Bool ignore_typographic_family = FALSE;
|
|
|
|
FT_Bool ignore_typographic_subfamily = FALSE;
|
2000-11-07 00:07:51 +01:00
|
|
|
|
2002-02-28 17:10:29 +01:00
|
|
|
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
FT_UNUSED( face_instance_index );
|
2000-06-29 05:14:25 +02:00
|
|
|
|
2012-08-27 05:48:23 +02:00
|
|
|
|
2010-01-29 15:18:34 +01:00
|
|
|
/* Check parameters */
|
2011-03-20 07:51:57 +01:00
|
|
|
|
2010-01-29 15:18:34 +01:00
|
|
|
{
|
|
|
|
FT_Int i;
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < num_params; i++ )
|
|
|
|
{
|
2017-01-24 17:00:36 +01:00
|
|
|
if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY )
|
|
|
|
ignore_typographic_family = TRUE;
|
|
|
|
else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY )
|
|
|
|
ignore_typographic_subfamily = TRUE;
|
2010-01-29 15:18:34 +01:00
|
|
|
}
|
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* Load tables */
|
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* We now support two SFNT-based bitmapped font formats. They */
|
|
|
|
/* are recognized easily as they do not include a `glyf' */
|
|
|
|
/* table. */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* The first format comes from Apple, and uses a table named */
|
|
|
|
/* `bhed' instead of `head' to store the font header (using */
|
|
|
|
/* the same format). It also doesn't include horizontal and */
|
|
|
|
/* vertical metrics tables (i.e. `hhea' and `vhea' tables are */
|
|
|
|
/* missing). */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* The other format comes from Microsoft, and is used with */
|
|
|
|
/* WinCE/PocketPC. It looks like a standard TTF, except that */
|
|
|
|
/* it doesn't contain outlines. */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* */
|
|
|
|
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
FT_TRACE2(( "sfnt_load_face: %08p\n\n", face ));
|
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* do we have outlines in there? */
|
2002-07-18 18:38:07 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2016-12-26 17:08:17 +01:00
|
|
|
has_outline = FT_BOOL( face->root.internal->incremental_interface ||
|
|
|
|
tt_face_lookup_table( face, TTAG_glyf ) ||
|
|
|
|
tt_face_lookup_table( face, TTAG_CFF ) ||
|
|
|
|
tt_face_lookup_table( face, TTAG_CFF2 ) );
|
2002-07-18 18:38:07 +02:00
|
|
|
#else
|
2016-12-26 17:08:17 +01:00
|
|
|
has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) ||
|
|
|
|
tt_face_lookup_table( face, TTAG_CFF ) ||
|
|
|
|
tt_face_lookup_table( face, TTAG_CFF2 ) );
|
2002-07-18 18:38:07 +02:00
|
|
|
#endif
|
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
is_apple_sbit = 0;
|
2013-07-19 14:28:28 +02:00
|
|
|
is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
|
|
|
|
|
|
|
|
/* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf'
|
|
|
|
* outline rendered on top. We don't support that yet, so just ignore
|
|
|
|
* the 'glyf' outline and advertise it as a bitmap-only font. */
|
|
|
|
if ( is_apple_sbix )
|
|
|
|
has_outline = FALSE;
|
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* if this font doesn't contain outlines, we try to load */
|
|
|
|
/* a `bhed' table */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
if ( !has_outline && sfnt->load_bhed )
|
|
|
|
{
|
|
|
|
LOAD_( bhed );
|
2006-03-20 17:55:32 +01:00
|
|
|
is_apple_sbit = FT_BOOL( !error );
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
/* load the font header (`head' table) if this isn't an Apple */
|
|
|
|
/* sbit font file */
|
2013-07-19 14:28:28 +02:00
|
|
|
if ( !is_apple_sbit || is_apple_sbix )
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
{
|
|
|
|
LOAD_( head );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2018-02-17 18:35:15 +01:00
|
|
|
has_CBLC = !face->goto_table( face, TTAG_CBLC, stream, 0 );
|
|
|
|
has_CBDT = !face->goto_table( face, TTAG_CBDT, stream, 0 );
|
|
|
|
|
|
|
|
/* Ignore outlines for CBLC/CBDT fonts. */
|
|
|
|
if ( has_CBLC || has_CBDT )
|
|
|
|
has_outline = FALSE;
|
|
|
|
|
2017-08-01 08:24:51 +02:00
|
|
|
/* OpenType 1.8.2 introduced limits to this value; */
|
|
|
|
/* however, they make sense for older SFNT fonts also */
|
|
|
|
if ( face->header.Units_Per_EM < 16 ||
|
|
|
|
face->header.Units_Per_EM > 16384 )
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Table );
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
}
|
2000-08-06 21:48:47 +02:00
|
|
|
|
2002-02-08 07:23:50 +01:00
|
|
|
/* the following tables are often not present in embedded TrueType */
|
|
|
|
/* fonts within PDF documents, so don't check for them. */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOAD_( maxp );
|
|
|
|
LOAD_( cmap );
|
2002-02-27 22:25:47 +01:00
|
|
|
|
2001-12-19 23:26:12 +01:00
|
|
|
/* the following tables are optional in PCL fonts -- */
|
|
|
|
/* don't check for errors */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOAD_( name );
|
|
|
|
LOAD_( post );
|
2008-10-02 00:46:26 +02:00
|
|
|
|
|
|
|
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
psnames_error = error;
|
2008-10-02 00:46:26 +02:00
|
|
|
#endif
|
2000-08-06 21:48:47 +02:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
/* do not load the metrics headers and tables if this is an Apple */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* sbit font file */
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( !is_apple_sbit )
|
2000-08-06 21:48:47 +02:00
|
|
|
{
|
2006-02-14 09:37:03 +01:00
|
|
|
/* load the `hhea' and `hmtx' tables */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOADM_( hhea, 0 );
|
2006-02-14 09:37:03 +01:00
|
|
|
if ( !error )
|
|
|
|
{
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOADM_( hmtx, 0 );
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( FT_ERR_EQ( error, Table_Missing ) )
|
2006-02-14 09:37:03 +01:00
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Hmtx_Table_Missing );
|
2006-02-14 09:37:03 +01:00
|
|
|
|
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
|
|
|
/* If this is an incrementally loaded font and there are */
|
|
|
|
/* overriding metrics, tolerate a missing `hmtx' table. */
|
|
|
|
if ( face->root.internal->incremental_interface &&
|
|
|
|
face->root.internal->incremental_interface->funcs->
|
|
|
|
get_glyph_metrics )
|
|
|
|
{
|
|
|
|
face->horizontal.number_Of_HMetrics = 0;
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2006-02-14 09:37:03 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2013-03-14 17:50:49 +01:00
|
|
|
else if ( FT_ERR_EQ( error, Table_Missing ) )
|
2006-02-14 09:37:03 +01:00
|
|
|
{
|
|
|
|
/* No `hhea' table necessary for SFNT Mac fonts. */
|
|
|
|
if ( face->format_tag == TTAG_true )
|
|
|
|
{
|
2006-02-15 07:05:52 +01:00
|
|
|
FT_TRACE2(( "This is an SFNT Mac font.\n" ));
|
2011-07-03 09:46:32 +02:00
|
|
|
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
has_outline = 0;
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2006-02-14 09:37:03 +01:00
|
|
|
}
|
|
|
|
else
|
2007-04-10 13:51:50 +02:00
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Horiz_Header_Missing );
|
2007-04-10 13:51:50 +02:00
|
|
|
|
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
|
|
|
/* If this is an incrementally loaded font and there are */
|
|
|
|
/* overriding metrics, tolerate a missing `hhea' table. */
|
|
|
|
if ( face->root.internal->incremental_interface &&
|
|
|
|
face->root.internal->incremental_interface->funcs->
|
|
|
|
get_glyph_metrics )
|
|
|
|
{
|
|
|
|
face->horizontal.number_Of_HMetrics = 0;
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2007-04-10 13:51:50 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
2006-02-14 09:37:03 +01:00
|
|
|
}
|
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
if ( error )
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2006-02-14 09:37:03 +01:00
|
|
|
/* try to load the `vhea' and `vmtx' tables */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOADM_( hhea, 1 );
|
2006-02-14 09:37:03 +01:00
|
|
|
if ( !error )
|
|
|
|
{
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOADM_( hmtx, 1 );
|
2006-02-14 09:37:03 +01:00
|
|
|
if ( !error )
|
|
|
|
face->vertical_info = 1;
|
|
|
|
}
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( error && FT_ERR_NEQ( error, Table_Missing ) )
|
2000-11-07 00:07:51 +01:00
|
|
|
goto Exit;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOAD_( os2 );
|
|
|
|
if ( error )
|
|
|
|
{
|
2010-11-18 13:08:52 +01:00
|
|
|
/* we treat the table as missing if there are any errors */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
face->os2.version = 0xFFFFU;
|
|
|
|
}
|
2000-08-06 21:48:47 +02:00
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* the optional tables */
|
|
|
|
|
2008-12-05 19:37:44 +01:00
|
|
|
/* embedded bitmap support */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
if ( sfnt->load_eblc )
|
|
|
|
LOAD_( eblc );
|
2002-03-31 20:48:24 +02:00
|
|
|
|
2018-06-13 08:46:27 +02:00
|
|
|
/* colored glyph support */
|
|
|
|
if ( sfnt->load_cpal )
|
[sfnt] Preliminary support of coloured layer outlines.
This commit enables OpenType's COLR/CPAL table handling; a typical
application are color emojis that can be scaled to any size.
If the color palette does not exist or is invalid, the rendering
step rasterizes the outline instead. The current implementation
assumes that the foreground is black.
Enable this by defining option TT_CONFIG_OPTION_COLOR_LAYERS.
There are still some issues with metrics; additionally, an API to
fetch color layers is missing.
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_COLOR_LAYERS): New macro.
* include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec,
FT_Colr_InternalRec): New structures.
(FT_Slot_InternalRec): Add `color_layers' field.
* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func,
TT_Blend_Colr_Func): New function types.
(SFNT_Interface): Add `load_colr', `free_colr', `load_colr_layer',
and `colr_blend' fields.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add
`colr_and_cpal' field.
* include/freetype/internal/tttags. (TTAG_COLR, TTAG_CPAL): New
macros.
* src/sfnt/ttcolr.c, src/sfnt/ttcolr.h: New files.
* src/base/ftobjs.c (ft_glyphslot_done, FT_Render_Glyph_Internal):
Handle glyph color layers.
* src/sfnt/Jamfile (_sources), src/sfnt/rules.mk (SFNT_DRV_SRC): Add
`ttcolr.c'.
* src/sfnt/sfdriver.c: Include `ttcolr.h'.
(PUT_COLOR_LAYERS): New macro.
Update call to `FT_DEFINE_SFNT_INTERFACE'.
* src/sfnt/sfnt.c: Include `ttcolr.c'.
* src/sfnt/sfobjs.c (sfnt_load_face): Load `COLR' and `CPAL' tables.
(sfnt_done_face): Updated.
* src/truetype/ttgload.c (TT_Load_Glyph): Handle color layers.
2018-05-13 03:25:09 +02:00
|
|
|
{
|
2018-06-13 08:46:27 +02:00
|
|
|
LOAD_( cpal );
|
[sfnt] Preliminary support of coloured layer outlines.
This commit enables OpenType's COLR/CPAL table handling; a typical
application are color emojis that can be scaled to any size.
If the color palette does not exist or is invalid, the rendering
step rasterizes the outline instead. The current implementation
assumes that the foreground is black.
Enable this by defining option TT_CONFIG_OPTION_COLOR_LAYERS.
There are still some issues with metrics; additionally, an API to
fetch color layers is missing.
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_COLOR_LAYERS): New macro.
* include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec,
FT_Colr_InternalRec): New structures.
(FT_Slot_InternalRec): Add `color_layers' field.
* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func,
TT_Blend_Colr_Func): New function types.
(SFNT_Interface): Add `load_colr', `free_colr', `load_colr_layer',
and `colr_blend' fields.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add
`colr_and_cpal' field.
* include/freetype/internal/tttags. (TTAG_COLR, TTAG_CPAL): New
macros.
* src/sfnt/ttcolr.c, src/sfnt/ttcolr.h: New files.
* src/base/ftobjs.c (ft_glyphslot_done, FT_Render_Glyph_Internal):
Handle glyph color layers.
* src/sfnt/Jamfile (_sources), src/sfnt/rules.mk (SFNT_DRV_SRC): Add
`ttcolr.c'.
* src/sfnt/sfdriver.c: Include `ttcolr.h'.
(PUT_COLOR_LAYERS): New macro.
Update call to `FT_DEFINE_SFNT_INTERFACE'.
* src/sfnt/sfnt.c: Include `ttcolr.c'.
* src/sfnt/sfobjs.c (sfnt_load_face): Load `COLR' and `CPAL' tables.
(sfnt_done_face): Updated.
* src/truetype/ttgload.c (TT_Load_Glyph): Handle color layers.
2018-05-13 03:25:09 +02:00
|
|
|
LOAD_( colr );
|
|
|
|
}
|
|
|
|
|
2017-01-03 09:42:41 +01:00
|
|
|
/* consider the pclt, kerning, and gasp tables as optional */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
LOAD_( pclt );
|
|
|
|
LOAD_( gasp );
|
|
|
|
LOAD_( kern );
|
2005-02-26 01:12:04 +01:00
|
|
|
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
face->root.num_glyphs = face->max_profile.numGlyphs;
|
|
|
|
|
2007-10-21 10:12:30 +02:00
|
|
|
/* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
|
|
|
|
/* a WWS-only font face. `WWS' stands for `weight', width', and */
|
|
|
|
/* `slope', a term used by Microsoft's Windows Presentation */
|
* src/sfnt/sfobjs.c (sfnt_load_face): Remove #if 0/#endif guards
since OpenType version 1.5 has been released.
* include/ttnameid.h (TT_NAME_ID_WWS_FAMILY,
TT_NAME_ID_WWS_SUBFAMILY): New macros for OpenType 1.5.
(TT_URC_COPTIC, TT_URC_VAI, TT_URC_NKO, TT_URC_BALINESE,
TT_URC_PHAGSPA, TT_URC_NON_PLANE_0, TT_URC_PHOENICIAN,
TT_URC_TAI_LE, TT_URC_NEW_TAI_LUE, TT_URC_BUGINESE,
TT_URC_GLAGOLITIC, TT_URC_YIJING, TT_URC_SYLOTI_NAGRI,
TT_URC_LINEAR_B, TT_URC_ANCIENT_GREEK_NUMBERS, TT_URC_UGARITIC,
TT_URC_OLD_PERSIAN, TT_URC_SHAVIAN, TT_URC_OSMANYA,
TT_URC_CYPRIOT_SYLLABARY, TT_URC_KHAROSHTHI, TT_URC_TAI_XUAN_JING,
TT_URC_CUNEIFORM, TT_URC_COUNTING_ROD_NUMERALS, TT_URC_SUNDANESE,
TT_URC_LEPCHA, TT_URC_OL_CHIKI, TT_URC_SAURASHTRA, TT_URC_KAYAH_LI,
TT_URC_REJANG, TT_URC_CHAM, TT_URC_ANCIENT_SYMBOLS,
TT_URC_PHAISTOS_DISC, TT_URC_OLD_ANATOLIAN, TT_URC_GAME_TILES): New
macros for OpenType 1.5.
2008-11-08 23:00:55 +01:00
|
|
|
/* Foundation (WPF). This flag has been introduced in version */
|
|
|
|
/* 1.5 of the OpenType specification (May 2008). */
|
2007-10-21 10:12:30 +02:00
|
|
|
|
2010-01-29 18:24:25 +01:00
|
|
|
face->root.family_name = NULL;
|
|
|
|
face->root.style_name = NULL;
|
2007-10-21 10:12:30 +02:00
|
|
|
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
|
|
|
|
{
|
2017-01-24 17:00:36 +01:00
|
|
|
if ( !ignore_typographic_family )
|
|
|
|
GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
|
2010-01-29 18:24:25 +01:00
|
|
|
if ( !face->root.family_name )
|
|
|
|
GET_NAME( FONT_FAMILY, &face->root.family_name );
|
2007-10-21 10:12:30 +02:00
|
|
|
|
2017-01-24 17:00:36 +01:00
|
|
|
if ( !ignore_typographic_subfamily )
|
|
|
|
GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
|
2010-01-29 18:24:25 +01:00
|
|
|
if ( !face->root.style_name )
|
|
|
|
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
|
2007-10-21 10:12:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-08 08:20:25 +01:00
|
|
|
GET_NAME( WWS_FAMILY, &face->root.family_name );
|
2017-01-24 17:00:36 +01:00
|
|
|
if ( !face->root.family_name && !ignore_typographic_family )
|
|
|
|
GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name );
|
2007-10-21 10:12:30 +02:00
|
|
|
if ( !face->root.family_name )
|
2008-11-08 08:20:25 +01:00
|
|
|
GET_NAME( FONT_FAMILY, &face->root.family_name );
|
2007-10-21 10:12:30 +02:00
|
|
|
|
2008-11-08 08:20:25 +01:00
|
|
|
GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
|
2017-01-24 17:00:36 +01:00
|
|
|
if ( !face->root.style_name && !ignore_typographic_subfamily )
|
|
|
|
GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name );
|
2007-10-21 10:12:30 +02:00
|
|
|
if ( !face->root.style_name )
|
2008-11-08 08:20:25 +01:00
|
|
|
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
|
2007-10-21 10:12:30 +02:00
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* now set up root fields */
|
|
|
|
{
|
2009-07-31 17:32:20 +02:00
|
|
|
FT_Face root = &face->root;
|
|
|
|
FT_Long flags = root->face_flags;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Compute face flags.
|
|
|
|
*/
|
2013-07-25 21:53:18 +02:00
|
|
|
if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC ||
|
[sfnt] Preliminary support of coloured layer outlines.
This commit enables OpenType's COLR/CPAL table handling; a typical
application are color emojis that can be scaled to any size.
If the color palette does not exist or is invalid, the rendering
step rasterizes the outline instead. The current implementation
assumes that the foreground is black.
Enable this by defining option TT_CONFIG_OPTION_COLOR_LAYERS.
There are still some issues with metrics; additionally, an API to
fetch color layers is missing.
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_COLOR_LAYERS): New macro.
* include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec,
FT_Colr_InternalRec): New structures.
(FT_Slot_InternalRec): Add `color_layers' field.
* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func,
TT_Blend_Colr_Func): New function types.
(SFNT_Interface): Add `load_colr', `free_colr', `load_colr_layer',
and `colr_blend' fields.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add
`colr_and_cpal' field.
* include/freetype/internal/tttags. (TTAG_COLR, TTAG_CPAL): New
macros.
* src/sfnt/ttcolr.c, src/sfnt/ttcolr.h: New files.
* src/base/ftobjs.c (ft_glyphslot_done, FT_Render_Glyph_Internal):
Handle glyph color layers.
* src/sfnt/Jamfile (_sources), src/sfnt/rules.mk (SFNT_DRV_SRC): Add
`ttcolr.c'.
* src/sfnt/sfdriver.c: Include `ttcolr.h'.
(PUT_COLOR_LAYERS): New macro.
Update call to `FT_DEFINE_SFNT_INTERFACE'.
* src/sfnt/sfnt.c: Include `ttcolr.c'.
* src/sfnt/sfobjs.c (sfnt_load_face): Load `COLR' and `CPAL' tables.
(sfnt_done_face): Updated.
* src/truetype/ttgload.c (TT_Load_Glyph): Handle color layers.
2018-05-13 03:25:09 +02:00
|
|
|
face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ||
|
2018-06-13 08:46:27 +02:00
|
|
|
face->colr )
|
2013-07-25 21:53:18 +02:00
|
|
|
flags |= FT_FACE_FLAG_COLOR; /* color glyphs */
|
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( has_outline == TRUE )
|
2005-10-05 17:18:29 +02:00
|
|
|
flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
|
2000-08-06 21:48:47 +02:00
|
|
|
|
2005-10-05 17:18:29 +02:00
|
|
|
/* The sfnt driver only supports bitmap fonts natively, thus we */
|
|
|
|
/* don't set FT_FACE_FLAG_HINTER. */
|
|
|
|
flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */
|
2000-08-06 21:48:47 +02:00
|
|
|
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-07-19 19:13:03 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( !psnames_error &&
|
2003-12-17 22:57:56 +01:00
|
|
|
face->postscript.FormatType != 0x00030000L )
|
2003-12-10 21:04:50 +01:00
|
|
|
flags |= FT_FACE_FLAG_GLYPH_NAMES;
|
2000-07-19 19:13:03 +02:00
|
|
|
#endif
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* fixed width font? */
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( face->postscript.isFixedPitch )
|
|
|
|
flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* vertical information? */
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( face->vertical_info )
|
|
|
|
flags |= FT_FACE_FLAG_VERTICAL;
|
|
|
|
|
|
|
|
/* kerning available ? */
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( TT_FACE_HAS_KERNING( face ) )
|
2000-05-28 19:15:37 +02:00
|
|
|
flags |= FT_FACE_FLAG_KERNING;
|
|
|
|
|
* src/pcf/pcfdrivr.c: Revert change from 2004-04-17.
* src/pcf/pcfutil.c: Use FT_LOCAL_DEF.
* src/pcf/pcfutil.h: Include FT_CONFIG_CONFIG_H.
Use FT_BEGIN_HEADER and FT_END_HEADER.
Use FT_LOCAL.
2004-04-24 George Williams <gww@silcom.com>
Add support for Apple's distortable font technology (in GX fonts).
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_GX_VAR_SUPPORT): New macro.
* include/freetype/ftmm.h (FT_Var_Axis, FT_Var_Named_Style,
FT_MM_Var): New structures.
(FT_Get_MM_Var, FT_Set_Var_Design_Coordinates,
FT_Set_Var_Blend_Coordinates): New function declarations.
* include/freetype/internal/services/svmm.h (FT_Get_MM_Var_Func,
FT_Set_Var_Design_Func): New typedefs.
Update MultiMasters service.
* include/freetype/internal/tttypes.h
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include FT_MULTIPLE_MASTERS_H.
(GX_Blend) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: New typedef.
(TT_Face) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: New members `doblend'
and `blend'.
* include/freetype/tttags.h (TTAG_avar, TTAG_cvar, TTAG_gvar): New
macros.
* include/freetype/internal/fttrace.h: Add `ttgxvar'.
* src/base/ftmm.c (FT_Get_MM_Var, FT_Set_Var_Design_Coordinates,
FT_Set_Var_Blend_Coordinates): New functions.
* src/sfnt/sfobjs.c (sfnt_load_face)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Set FT_FACE_FLAG_MULTIPLE_MASTERS
flag for GX var fonts.
* src/truetype/ttgxvar.c, src/truetype/ttgxvar.h: New files.
* src/truetype/truetype.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.c.
* src/truetype/ttdriver.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
FT_MULTIPLE_MASTERS_H, FT_SERVICE_MULTIPLE_MASTERS_H, and ttgxvar.h.
(tt_service_gx_multi_masters) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]:
New service.
(tt_services) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Updated.
* src/truetype/ttgload.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.h.
(TT_Process_Simple_Glyph, load_truetype_glyph)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT] :Support GX var fonts.
* src/truetype/ttobjs.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.h.
(tt_done_face) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Call
tt_done_blend.
* src/truetype/ttpload.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.h.
(tt_face_load_cvt) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Call
tt_face_vary_cvt.
* src/truetype/rules.mk (TT_DRV_SRC): Add ttgxvar.c.
* src/type1/t1driver.c (t1_service_multi_masters): Add T1_Get_MM_Var
and T1_Set_Var_Design.
* src/type1/t1load.c (FT_INT_TO_FIXED, FT_FIXED_TO_INT): New macros.
(T1_Get_MM_Var, T1_Set_Var_Design): New functions.
* src/type1/t1load.h (T1_Get_MM_Var, T1_Set_Var_Design): New
function declarations.
2004-04-25 22:15:11 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
|
|
/* Don't bother to load the tables unless somebody asks for them. */
|
|
|
|
/* No need to do work which will (probably) not be used. */
|
2016-12-21 19:30:33 +01:00
|
|
|
if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR )
|
2016-12-18 15:50:18 +01:00
|
|
|
{
|
|
|
|
if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 &&
|
|
|
|
tt_face_lookup_table( face, TTAG_gvar ) != 0 )
|
|
|
|
flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
|
|
|
|
if ( tt_face_lookup_table( face, TTAG_CFF2 ) != 0 )
|
|
|
|
flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
|
|
|
|
}
|
* src/pcf/pcfdrivr.c: Revert change from 2004-04-17.
* src/pcf/pcfutil.c: Use FT_LOCAL_DEF.
* src/pcf/pcfutil.h: Include FT_CONFIG_CONFIG_H.
Use FT_BEGIN_HEADER and FT_END_HEADER.
Use FT_LOCAL.
2004-04-24 George Williams <gww@silcom.com>
Add support for Apple's distortable font technology (in GX fonts).
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_GX_VAR_SUPPORT): New macro.
* include/freetype/ftmm.h (FT_Var_Axis, FT_Var_Named_Style,
FT_MM_Var): New structures.
(FT_Get_MM_Var, FT_Set_Var_Design_Coordinates,
FT_Set_Var_Blend_Coordinates): New function declarations.
* include/freetype/internal/services/svmm.h (FT_Get_MM_Var_Func,
FT_Set_Var_Design_Func): New typedefs.
Update MultiMasters service.
* include/freetype/internal/tttypes.h
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include FT_MULTIPLE_MASTERS_H.
(GX_Blend) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: New typedef.
(TT_Face) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: New members `doblend'
and `blend'.
* include/freetype/tttags.h (TTAG_avar, TTAG_cvar, TTAG_gvar): New
macros.
* include/freetype/internal/fttrace.h: Add `ttgxvar'.
* src/base/ftmm.c (FT_Get_MM_Var, FT_Set_Var_Design_Coordinates,
FT_Set_Var_Blend_Coordinates): New functions.
* src/sfnt/sfobjs.c (sfnt_load_face)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Set FT_FACE_FLAG_MULTIPLE_MASTERS
flag for GX var fonts.
* src/truetype/ttgxvar.c, src/truetype/ttgxvar.h: New files.
* src/truetype/truetype.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.c.
* src/truetype/ttdriver.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
FT_MULTIPLE_MASTERS_H, FT_SERVICE_MULTIPLE_MASTERS_H, and ttgxvar.h.
(tt_service_gx_multi_masters) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]:
New service.
(tt_services) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Updated.
* src/truetype/ttgload.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.h.
(TT_Process_Simple_Glyph, load_truetype_glyph)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT] :Support GX var fonts.
* src/truetype/ttobjs.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.h.
(tt_done_face) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Call
tt_done_blend.
* src/truetype/ttpload.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
ttgxvar.h.
(tt_face_load_cvt) [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Call
tt_face_vary_cvt.
* src/truetype/rules.mk (TT_DRV_SRC): Add ttgxvar.c.
* src/type1/t1driver.c (t1_service_multi_masters): Add T1_Get_MM_Var
and T1_Set_Var_Design.
* src/type1/t1load.c (FT_INT_TO_FIXED, FT_FIXED_TO_INT): New macros.
(T1_Get_MM_Var, T1_Set_Var_Design): New functions.
* src/type1/t1load.h (T1_Get_MM_Var, T1_Set_Var_Design): New
function declarations.
2004-04-25 22:15:11 +02:00
|
|
|
#endif
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
root->face_flags = flags;
|
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Compute style flags.
|
|
|
|
*/
|
2007-10-21 10:12:30 +02:00
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
flags = 0;
|
2003-06-23 21:26:53 +02:00
|
|
|
if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
* src/sfnt/sfobjs.c (sfnt_load_face): Remove #if 0/#endif guards
since OpenType version 1.5 has been released.
* include/ttnameid.h (TT_NAME_ID_WWS_FAMILY,
TT_NAME_ID_WWS_SUBFAMILY): New macros for OpenType 1.5.
(TT_URC_COPTIC, TT_URC_VAI, TT_URC_NKO, TT_URC_BALINESE,
TT_URC_PHAGSPA, TT_URC_NON_PLANE_0, TT_URC_PHOENICIAN,
TT_URC_TAI_LE, TT_URC_NEW_TAI_LUE, TT_URC_BUGINESE,
TT_URC_GLAGOLITIC, TT_URC_YIJING, TT_URC_SYLOTI_NAGRI,
TT_URC_LINEAR_B, TT_URC_ANCIENT_GREEK_NUMBERS, TT_URC_UGARITIC,
TT_URC_OLD_PERSIAN, TT_URC_SHAVIAN, TT_URC_OSMANYA,
TT_URC_CYPRIOT_SYLLABARY, TT_URC_KHAROSHTHI, TT_URC_TAI_XUAN_JING,
TT_URC_CUNEIFORM, TT_URC_COUNTING_ROD_NUMERALS, TT_URC_SUNDANESE,
TT_URC_LEPCHA, TT_URC_OL_CHIKI, TT_URC_SAURASHTRA, TT_URC_KAYAH_LI,
TT_URC_REJANG, TT_URC_CHAM, TT_URC_ANCIENT_SYMBOLS,
TT_URC_PHAISTOS_DISC, TT_URC_OLD_ANATOLIAN, TT_URC_GAME_TILES): New
macros for OpenType 1.5.
2008-11-08 23:00:55 +01:00
|
|
|
/* We have an OS/2 table; use the `fsSelection' field. Bit 9 */
|
|
|
|
/* indicates an oblique font face. This flag has been */
|
|
|
|
/* introduced in version 1.5 of the OpenType specification. */
|
2007-10-21 10:12:30 +02:00
|
|
|
|
|
|
|
if ( face->os2.fsSelection & 512 ) /* bit 9 */
|
|
|
|
flags |= FT_STYLE_FLAG_ITALIC;
|
|
|
|
else if ( face->os2.fsSelection & 1 ) /* bit 0 */
|
2000-11-07 00:07:51 +01:00
|
|
|
flags |= FT_STYLE_FLAG_ITALIC;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2007-10-21 10:12:30 +02:00
|
|
|
if ( face->os2.fsSelection & 32 ) /* bit 5 */
|
2000-11-07 00:07:51 +01:00
|
|
|
flags |= FT_STYLE_FLAG_BOLD;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* this is an old Mac font, use the header field */
|
* src/sfnt/sfobjs.c (sfnt_load_face): Remove #if 0/#endif guards
since OpenType version 1.5 has been released.
* include/ttnameid.h (TT_NAME_ID_WWS_FAMILY,
TT_NAME_ID_WWS_SUBFAMILY): New macros for OpenType 1.5.
(TT_URC_COPTIC, TT_URC_VAI, TT_URC_NKO, TT_URC_BALINESE,
TT_URC_PHAGSPA, TT_URC_NON_PLANE_0, TT_URC_PHOENICIAN,
TT_URC_TAI_LE, TT_URC_NEW_TAI_LUE, TT_URC_BUGINESE,
TT_URC_GLAGOLITIC, TT_URC_YIJING, TT_URC_SYLOTI_NAGRI,
TT_URC_LINEAR_B, TT_URC_ANCIENT_GREEK_NUMBERS, TT_URC_UGARITIC,
TT_URC_OLD_PERSIAN, TT_URC_SHAVIAN, TT_URC_OSMANYA,
TT_URC_CYPRIOT_SYLLABARY, TT_URC_KHAROSHTHI, TT_URC_TAI_XUAN_JING,
TT_URC_CUNEIFORM, TT_URC_COUNTING_ROD_NUMERALS, TT_URC_SUNDANESE,
TT_URC_LEPCHA, TT_URC_OL_CHIKI, TT_URC_SAURASHTRA, TT_URC_KAYAH_LI,
TT_URC_REJANG, TT_URC_CHAM, TT_URC_ANCIENT_SYMBOLS,
TT_URC_PHAISTOS_DISC, TT_URC_OLD_ANATOLIAN, TT_URC_GAME_TILES): New
macros for OpenType 1.5.
2008-11-08 23:00:55 +01:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( face->header.Mac_Style & 1 )
|
|
|
|
flags |= FT_STYLE_FLAG_BOLD;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( face->header.Mac_Style & 2 )
|
|
|
|
flags |= FT_STYLE_FLAG_ITALIC;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
2015-08-13 15:22:17 +02:00
|
|
|
root->style_flags |= flags;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Polish the charmaps.
|
|
|
|
*
|
|
|
|
* Try to set the charmap encoding according to the platform &
|
|
|
|
* encoding ID of each charmap. Emulate Unicode charmap if one
|
|
|
|
* is missing.
|
|
|
|
*/
|
2002-03-22 16:02:38 +01:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
tt_face_build_cmaps( face ); /* ignore errors */
|
2002-03-31 20:48:24 +02:00
|
|
|
|
|
|
|
|
2002-03-22 16:02:38 +01:00
|
|
|
/* set the encoding fields */
|
|
|
|
{
|
2017-06-22 04:52:37 +02:00
|
|
|
FT_Int m;
|
|
|
|
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
|
|
|
FT_Bool has_unicode = FALSE;
|
|
|
|
#endif
|
2002-03-31 20:48:24 +02:00
|
|
|
|
|
|
|
|
2002-03-26 03:38:39 +01:00
|
|
|
for ( m = 0; m < root->num_charmaps; m++ )
|
2002-03-22 16:02:38 +01:00
|
|
|
{
|
2002-03-26 03:38:39 +01:00
|
|
|
FT_CharMap charmap = root->charmaps[m];
|
2002-03-31 20:48:24 +02:00
|
|
|
|
|
|
|
|
2002-03-22 16:02:38 +01:00
|
|
|
charmap->encoding = sfnt_find_encoding( charmap->platform_id,
|
|
|
|
charmap->encoding_id );
|
2017-06-22 04:52:37 +02:00
|
|
|
|
|
|
|
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
|
|
|
|
2017-08-18 03:28:32 +02:00
|
|
|
if ( charmap->encoding == FT_ENCODING_UNICODE ||
|
|
|
|
charmap->encoding == FT_ENCODING_MS_SYMBOL ) /* PUA */
|
2017-06-22 04:52:37 +02:00
|
|
|
has_unicode = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* synthesize Unicode charmap if one is missing */
|
|
|
|
if ( !has_unicode )
|
|
|
|
{
|
|
|
|
FT_CharMapRec cmaprec;
|
|
|
|
|
|
|
|
|
|
|
|
cmaprec.face = root;
|
|
|
|
cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
|
|
|
|
cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
|
|
|
|
cmaprec.encoding = FT_ENCODING_UNICODE;
|
|
|
|
|
|
|
|
|
|
|
|
error = FT_CMap_New( (FT_CMap_Class)&tt_cmap_unicode_class_rec,
|
|
|
|
NULL, &cmaprec, NULL );
|
|
|
|
if ( error &&
|
|
|
|
FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
|
2017-07-01 22:48:32 +02:00
|
|
|
goto Exit;
|
|
|
|
error = FT_Err_Ok;
|
2017-06-22 04:52:37 +02:00
|
|
|
|
|
|
|
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
|
|
|
|
2002-03-22 16:02:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-09 23:20:27 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
|
|
|
|
|
|
|
/*
|
2018-06-03 09:01:17 +02:00
|
|
|
* Now allocate the root array of FT_Bitmap_Size records and
|
|
|
|
* populate them. Unfortunately, it isn't possible to indicate bit
|
|
|
|
* depths in the FT_Bitmap_Size record. This is a design error.
|
2009-02-09 23:20:27 +01:00
|
|
|
*/
|
|
|
|
{
|
2016-09-09 22:11:07 +02:00
|
|
|
FT_UInt count;
|
2009-02-09 23:20:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
count = face->sbit_num_strikes;
|
|
|
|
|
|
|
|
if ( count > 0 )
|
|
|
|
{
|
|
|
|
FT_Memory memory = face->root.stream->memory;
|
|
|
|
FT_UShort em_size = face->header.Units_Per_EM;
|
|
|
|
FT_Short avgwidth = face->os2.xAvgCharWidth;
|
|
|
|
FT_Size_Metrics metrics;
|
|
|
|
|
2016-09-10 08:02:30 +02:00
|
|
|
FT_UInt* sbit_strike_map = NULL;
|
|
|
|
FT_UInt strike_idx, bsize_idx;
|
2016-09-09 22:11:07 +02:00
|
|
|
|
2009-02-09 23:20:27 +01:00
|
|
|
|
|
|
|
if ( em_size == 0 || face->os2.version == 0xFFFFU )
|
|
|
|
{
|
2013-11-21 13:13:12 +01:00
|
|
|
avgwidth = 1;
|
2009-02-09 23:20:27 +01:00
|
|
|
em_size = 1;
|
|
|
|
}
|
|
|
|
|
2016-09-09 22:11:07 +02:00
|
|
|
/* to avoid invalid strike data in the `available_sizes' field */
|
|
|
|
/* of `FT_Face', we map `available_sizes' indices to strike */
|
|
|
|
/* indices */
|
|
|
|
if ( FT_NEW_ARRAY( root->available_sizes, count ) ||
|
2016-09-10 08:02:30 +02:00
|
|
|
FT_NEW_ARRAY( sbit_strike_map, count ) )
|
2009-02-09 23:20:27 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2016-09-09 22:11:07 +02:00
|
|
|
bsize_idx = 0;
|
|
|
|
for ( strike_idx = 0; strike_idx < count; strike_idx++ )
|
2009-02-09 23:20:27 +01:00
|
|
|
{
|
2016-09-09 22:11:07 +02:00
|
|
|
FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx;
|
2009-02-09 23:20:27 +01:00
|
|
|
|
|
|
|
|
2016-09-09 22:11:07 +02:00
|
|
|
error = sfnt->load_strike_metrics( face, strike_idx, &metrics );
|
2009-02-09 23:20:27 +01:00
|
|
|
if ( error )
|
2016-09-10 08:02:30 +02:00
|
|
|
continue;
|
2009-02-09 23:20:27 +01:00
|
|
|
|
|
|
|
bsize->height = (FT_Short)( metrics.height >> 6 );
|
2016-09-09 22:11:07 +02:00
|
|
|
bsize->width = (FT_Short)(
|
|
|
|
( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
|
2009-02-09 23:20:27 +01:00
|
|
|
|
|
|
|
bsize->x_ppem = metrics.x_ppem << 6;
|
|
|
|
bsize->y_ppem = metrics.y_ppem << 6;
|
|
|
|
|
|
|
|
/* assume 72dpi */
|
|
|
|
bsize->size = metrics.y_ppem << 6;
|
2016-09-09 22:11:07 +02:00
|
|
|
|
|
|
|
/* only use strikes with valid PPEM values */
|
|
|
|
if ( bsize->x_ppem && bsize->y_ppem )
|
2016-09-10 08:02:30 +02:00
|
|
|
sbit_strike_map[bsize_idx++] = strike_idx;
|
2009-02-09 23:20:27 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:11:07 +02:00
|
|
|
/* reduce array size to the actually used elements */
|
2016-09-10 08:02:30 +02:00
|
|
|
(void)FT_RENEW_ARRAY( sbit_strike_map, count, bsize_idx );
|
2016-09-09 22:11:07 +02:00
|
|
|
|
2016-09-10 08:02:30 +02:00
|
|
|
/* from now on, all strike indices are mapped */
|
|
|
|
/* using `sbit_strike_map' */
|
|
|
|
if ( bsize_idx )
|
|
|
|
{
|
|
|
|
face->sbit_strike_map = sbit_strike_map;
|
|
|
|
|
|
|
|
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
|
|
|
|
root->num_fixed_sizes = (FT_Int)bsize_idx;
|
|
|
|
}
|
2009-02-09 23:20:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
|
|
|
|
|
|
|
/* a font with no bitmaps and no outlines is scalable; */
|
|
|
|
/* it has only empty glyphs then */
|
|
|
|
if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) )
|
|
|
|
root->face_flags |= FT_FACE_FLAG_SCALABLE;
|
|
|
|
|
2002-03-22 16:02:38 +01:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* Set up metrics.
|
|
|
|
*/
|
2009-02-09 23:20:27 +01:00
|
|
|
if ( FT_IS_SCALABLE( root ) )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-08-06 21:48:47 +02:00
|
|
|
/* XXX What about if outline header is missing */
|
2003-07-01 09:28:55 +02:00
|
|
|
/* (e.g. sfnt wrapped bitmap)? */
|
2000-08-06 21:48:47 +02:00
|
|
|
root->bbox.xMin = face->header.xMin;
|
|
|
|
root->bbox.yMin = face->header.yMin;
|
|
|
|
root->bbox.xMax = face->header.xMax;
|
|
|
|
root->bbox.yMax = face->header.yMax;
|
|
|
|
root->units_per_EM = face->header.Units_Per_EM;
|
|
|
|
|
2000-08-29 18:03:01 +02:00
|
|
|
|
2000-08-29 20:37:25 +02:00
|
|
|
/* XXX: Computing the ascender/descender/height is very different */
|
|
|
|
/* from what the specification tells you. Apparently, we */
|
|
|
|
/* must be careful because */
|
|
|
|
/* */
|
|
|
|
/* - not all fonts have an OS/2 table; in this case, we take */
|
|
|
|
/* the values in the horizontal header. However, these */
|
|
|
|
/* values very often are not reliable. */
|
|
|
|
/* */
|
|
|
|
/* - otherwise, the correct typographic values are in the */
|
|
|
|
/* sTypoAscender, sTypoDescender & sTypoLineGap fields. */
|
|
|
|
/* */
|
2007-01-26 23:18:56 +01:00
|
|
|
/* However, certain fonts have these fields set to 0. */
|
2000-08-29 20:37:25 +02:00
|
|
|
/* Rather, they have usWinAscent & usWinDescent correctly */
|
|
|
|
/* set (but with different values). */
|
|
|
|
/* */
|
|
|
|
/* As an example, Arial Narrow is implemented through four */
|
|
|
|
/* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */
|
|
|
|
/* */
|
|
|
|
/* Strangely, all fonts have the same values in their */
|
|
|
|
/* sTypoXXX fields, except ARIALNB which sets them to 0. */
|
|
|
|
/* */
|
|
|
|
/* On the other hand, they all have different */
|
|
|
|
/* usWinAscent/Descent values -- as a conclusion, the OS/2 */
|
|
|
|
/* table cannot be used to compute the text height reliably! */
|
|
|
|
/* */
|
2000-08-29 18:03:01 +02:00
|
|
|
|
2011-07-07 14:10:39 +02:00
|
|
|
/* The ascender and descender are taken from the `hhea' table. */
|
|
|
|
/* If zero, they are taken from the `OS/2' table. */
|
2000-08-29 18:03:01 +02:00
|
|
|
|
|
|
|
root->ascender = face->horizontal.Ascender;
|
|
|
|
root->descender = face->horizontal.Descender;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2015-02-22 12:03:28 +01:00
|
|
|
root->height = root->ascender - root->descender +
|
|
|
|
face->horizontal.Line_Gap;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2011-07-07 14:10:39 +02:00
|
|
|
if ( !( root->ascender || root->descender ) )
|
2000-08-06 21:48:47 +02:00
|
|
|
{
|
2011-07-07 14:10:39 +02:00
|
|
|
if ( face->os2.version != 0xFFFFU )
|
|
|
|
{
|
|
|
|
if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
|
|
|
|
{
|
|
|
|
root->ascender = face->os2.sTypoAscender;
|
|
|
|
root->descender = face->os2.sTypoDescender;
|
2000-08-29 20:37:25 +02:00
|
|
|
|
2015-02-22 12:03:28 +01:00
|
|
|
root->height = root->ascender - root->descender +
|
|
|
|
face->os2.sTypoLineGap;
|
2011-07-07 14:10:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
root->ascender = (FT_Short)face->os2.usWinAscent;
|
|
|
|
root->descender = -(FT_Short)face->os2.usWinDescent;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2015-02-22 12:03:28 +01:00
|
|
|
root->height = root->ascender - root->descender;
|
2011-07-07 14:10:39 +02:00
|
|
|
}
|
|
|
|
}
|
2000-08-06 21:48:47 +02:00
|
|
|
}
|
2000-08-29 20:37:25 +02:00
|
|
|
|
2015-02-22 12:03:28 +01:00
|
|
|
root->max_advance_width =
|
|
|
|
(FT_Short)face->horizontal.advance_Width_Max;
|
|
|
|
root->max_advance_height =
|
|
|
|
(FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max
|
|
|
|
: root->height );
|
2008-10-12 13:47:29 +02:00
|
|
|
|
2017-12-04 20:43:30 +01:00
|
|
|
/* See https://www.microsoft.com/typography/otspec/post.htm -- */
|
|
|
|
/* Adjust underline position from top edge to centre of */
|
|
|
|
/* stroke to convert TrueType meaning to FreeType meaning. */
|
2008-10-12 13:47:29 +02:00
|
|
|
root->underline_position = face->postscript.underlinePosition -
|
|
|
|
face->postscript.underlineThickness / 2;
|
2000-08-06 21:48:47 +02:00
|
|
|
root->underline_thickness = face->postscript.underlineThickness;
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
}
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
FT_TRACE2(( "sfnt_load_face: done\n" ));
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOAD_
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
#undef LOADM_
|
2008-11-08 08:20:25 +01:00
|
|
|
#undef GET_NAME
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
sfnt_done_face( TT_Face face )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2008-10-02 00:39:05 +02:00
|
|
|
FT_Memory memory;
|
|
|
|
SFNT_Service sfnt;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
2008-10-02 00:39:05 +02:00
|
|
|
if ( !face )
|
|
|
|
return;
|
|
|
|
|
|
|
|
memory = face->root.memory;
|
|
|
|
sfnt = (SFNT_Service)face->sfnt;
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
if ( sfnt )
|
2000-05-28 19:15:37 +02:00
|
|
|
{
|
2000-06-05 07:26:15 +02:00
|
|
|
/* destroy the postscript names table if it is loaded */
|
|
|
|
if ( sfnt->free_psnames )
|
2000-05-28 19:15:37 +02:00
|
|
|
sfnt->free_psnames( face );
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
/* destroy the embedded bitmaps table if it is loaded */
|
Clean up the SFNT_Interface. Table loading functions are now named
after the tables' tags; `hdmx' is TrueType-specific and thus the code
is moved to the truetype module; `get_metrics' is moved here from the
truetype module so that the code can be shared with the cff module.
This pass involves no real changes. That is, the code is moved
verbatim mostly. The only exception is the return value of
`tt_face_get_metrics'.
* include/freetype/internal/sfnt.h, src/sfnt/rules.mk,
src/sfnt/sfdriver.c, src/sfnt/sfnt.c, src/sfnt/sfobjs.c,
src/sfnt/ttload.c, src/sfnt/ttload.h, src/sfnt/ttsbit.c,
src/sfnt/ttsbit.h, src/sfnt/ttsbit0.c: Clean up the SFNT_Interface.
* src/sfnt/ttmtx.c, src/sfnt/ttmtx.h: Metrics-related tables' loading
and parsing code is moved here.
Move `tt_face_get_metrics' here from the truetype module. The return
value is changed from `void' to `FT_Error'.
* include/freetype/internal/fttrace.h: New trace: ttmtx.
* src/truetype/ttpload.c, src/truetype/ttpload.h: `hdmx' loading and
parsing code is moved here.
New function `tt_face_load_prep' splitted from `tt_face_load_fpgm'.
`tt_face_load_fpgm' returns `FT_Err_Ok' if `fpgm' doesn't exist.
* src/cff/cffgload.c, src/cff/cffobjs.c: Update.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Update.
2006-02-14 07:40:10 +01:00
|
|
|
if ( sfnt->free_eblc )
|
|
|
|
sfnt->free_eblc( face );
|
[sfnt] Preliminary support of coloured layer outlines.
This commit enables OpenType's COLR/CPAL table handling; a typical
application are color emojis that can be scaled to any size.
If the color palette does not exist or is invalid, the rendering
step rasterizes the outline instead. The current implementation
assumes that the foreground is black.
Enable this by defining option TT_CONFIG_OPTION_COLOR_LAYERS.
There are still some issues with metrics; additionally, an API to
fetch color layers is missing.
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_COLOR_LAYERS): New macro.
* include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec,
FT_Colr_InternalRec): New structures.
(FT_Slot_InternalRec): Add `color_layers' field.
* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func,
TT_Blend_Colr_Func): New function types.
(SFNT_Interface): Add `load_colr', `free_colr', `load_colr_layer',
and `colr_blend' fields.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add
`colr_and_cpal' field.
* include/freetype/internal/tttags. (TTAG_COLR, TTAG_CPAL): New
macros.
* src/sfnt/ttcolr.c, src/sfnt/ttcolr.h: New files.
* src/base/ftobjs.c (ft_glyphslot_done, FT_Render_Glyph_Internal):
Handle glyph color layers.
* src/sfnt/Jamfile (_sources), src/sfnt/rules.mk (SFNT_DRV_SRC): Add
`ttcolr.c'.
* src/sfnt/sfdriver.c: Include `ttcolr.h'.
(PUT_COLOR_LAYERS): New macro.
Update call to `FT_DEFINE_SFNT_INTERFACE'.
* src/sfnt/sfnt.c: Include `ttcolr.c'.
* src/sfnt/sfobjs.c (sfnt_load_face): Load `COLR' and `CPAL' tables.
(sfnt_done_face): Updated.
* src/truetype/ttgload.c (TT_Load_Glyph): Handle color layers.
2018-05-13 03:25:09 +02:00
|
|
|
|
|
|
|
/* destroy color table data if it is loaded */
|
2018-06-13 08:46:27 +02:00
|
|
|
if ( sfnt->free_cpal )
|
|
|
|
{
|
|
|
|
sfnt->free_cpal( face );
|
[sfnt] Preliminary support of coloured layer outlines.
This commit enables OpenType's COLR/CPAL table handling; a typical
application are color emojis that can be scaled to any size.
If the color palette does not exist or is invalid, the rendering
step rasterizes the outline instead. The current implementation
assumes that the foreground is black.
Enable this by defining option TT_CONFIG_OPTION_COLOR_LAYERS.
There are still some issues with metrics; additionally, an API to
fetch color layers is missing.
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_COLOR_LAYERS): New macro.
* include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec,
FT_Colr_InternalRec): New structures.
(FT_Slot_InternalRec): Add `color_layers' field.
* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func,
TT_Blend_Colr_Func): New function types.
(SFNT_Interface): Add `load_colr', `free_colr', `load_colr_layer',
and `colr_blend' fields.
* include/freetype/internal/tttypes.h (TT_FaceRec): Add
`colr_and_cpal' field.
* include/freetype/internal/tttags. (TTAG_COLR, TTAG_CPAL): New
macros.
* src/sfnt/ttcolr.c, src/sfnt/ttcolr.h: New files.
* src/base/ftobjs.c (ft_glyphslot_done, FT_Render_Glyph_Internal):
Handle glyph color layers.
* src/sfnt/Jamfile (_sources), src/sfnt/rules.mk (SFNT_DRV_SRC): Add
`ttcolr.c'.
* src/sfnt/sfdriver.c: Include `ttcolr.h'.
(PUT_COLOR_LAYERS): New macro.
Update call to `FT_DEFINE_SFNT_INTERFACE'.
* src/sfnt/sfnt.c: Include `ttcolr.c'.
* src/sfnt/sfobjs.c (sfnt_load_face): Load `COLR' and `CPAL' tables.
(sfnt_done_face): Updated.
* src/truetype/ttgload.c (TT_Load_Glyph): Handle color layers.
2018-05-13 03:25:09 +02:00
|
|
|
sfnt->free_colr( face );
|
2018-06-13 08:46:27 +02:00
|
|
|
}
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
* include/freetype/config/ftoption.h,
include/freetype/config/ftstdlib.h,
include/freetype/internal/tttypes.h,
src/sfnt/Jamfile, src/sfnt/rules.mk, src/sfnt/sfdriver.c,
src/sfnt/ttbdf.h, src/sfnt/ttbdf.c, src/sfnt/sfobjs.c:
Added support for an embedded 'BDF ' table within SFNT-based
bitmap font files. This is used to store atoms & properties from
the original BDF fonts that were used to generate the font file.
the feature is controled by TT_CONFIG_OPTION_BDF within 'ftoption.h'
and is used to implement FT_Get_BDF_Property for these font files.
At the moment, this is still experimental, the BDF table format isn't
cast into stone yet.
2005-12-14 21:38:15 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_BDF
|
|
|
|
/* freeing the embedded BDF properties */
|
|
|
|
tt_face_free_bdf_props( face );
|
|
|
|
#endif
|
|
|
|
|
2000-05-28 19:15:37 +02:00
|
|
|
/* freeing the kerning table */
|
2005-02-26 01:12:04 +01:00
|
|
|
tt_face_done_kern( face );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* freeing the collection table */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->ttc_header.offsets );
|
2000-07-19 08:25:56 +02:00
|
|
|
face->ttc_header.count = 0;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* freeing table directory */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->dir_tables );
|
2000-05-28 19:15:37 +02:00
|
|
|
face->num_tables = 0;
|
|
|
|
|
2002-03-22 16:02:38 +01:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_Stream stream = FT_FACE_STREAM( face );
|
|
|
|
|
|
|
|
|
2002-03-22 16:02:38 +01:00
|
|
|
/* simply release the 'cmap' table frame */
|
|
|
|
FT_FRAME_RELEASE( face->cmap_table );
|
|
|
|
face->cmap_size = 0;
|
|
|
|
}
|
|
|
|
|
2016-09-29 13:04:46 +02:00
|
|
|
face->horz_metrics_size = 0;
|
|
|
|
face->vert_metrics_size = 0;
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2016-09-29 13:04:46 +02:00
|
|
|
/* freeing vertical metrics, if any */
|
2000-05-28 19:15:37 +02:00
|
|
|
if ( face->vertical_info )
|
|
|
|
{
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->vertical.long_metrics );
|
|
|
|
FT_FREE( face->vertical.short_metrics );
|
2000-05-28 19:15:37 +02:00
|
|
|
face->vertical_info = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* freeing the gasp table */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->gasp.gaspRanges );
|
2000-05-28 19:15:37 +02:00
|
|
|
face->gasp.numRanges = 0;
|
|
|
|
|
|
|
|
/* freeing the name table */
|
2007-11-01 10:19:44 +01:00
|
|
|
if ( sfnt )
|
|
|
|
sfnt->free_name( face );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* freeing family and style name */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->root.family_name );
|
|
|
|
FT_FREE( face->root.style_name );
|
2000-05-28 19:15:37 +02:00
|
|
|
|
|
|
|
/* freeing sbit size table */
|
2004-05-18 22:16:04 +02:00
|
|
|
FT_FREE( face->root.available_sizes );
|
2016-09-09 22:11:07 +02:00
|
|
|
FT_FREE( face->sbit_strike_map );
|
2000-05-28 19:15:37 +02:00
|
|
|
face->root.num_fixed_sizes = 0;
|
2004-05-18 22:16:04 +02:00
|
|
|
|
|
|
|
FT_FREE( face->postscript_name );
|
2018-08-10 22:24:26 +02:00
|
|
|
|
|
|
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
2017-03-14 21:50:22 +01:00
|
|
|
FT_FREE( face->var_postscript_prefix );
|
2017-03-17 21:47:54 +01:00
|
|
|
#endif
|
2000-05-28 19:15:37 +02:00
|
|
|
|
2018-06-09 23:56:21 +02:00
|
|
|
/* freeing glyph color palette data */
|
2018-06-10 21:37:15 +02:00
|
|
|
FT_FREE( face->palette_data.palette_name_ids );
|
2018-07-02 11:50:04 +02:00
|
|
|
FT_FREE( face->palette_data.palette_flags );
|
2018-06-10 21:37:15 +02:00
|
|
|
FT_FREE( face->palette_data.palette_entry_name_ids );
|
2018-06-12 05:53:58 +02:00
|
|
|
FT_FREE( face->palette );
|
2018-06-09 23:56:21 +02:00
|
|
|
|
2015-04-16 05:20:23 +02:00
|
|
|
face->sfnt = NULL;
|
2000-05-28 19:15:37 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 07:26:15 +02:00
|
|
|
|
|
|
|
/* END */
|