1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ttpost.c */
|
|
|
|
/* */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* Postcript name table processing for TrueType and OpenType fonts */
|
|
|
|
/* (body). */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* Copyright 1996-2000 by */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The post table is not completely loaded by the core engine. This */
|
|
|
|
/* file loads the missing PS glyph names and implements an API to access */
|
|
|
|
/* them. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
2000-05-11 20:23:52 +02:00
|
|
|
#include <freetype/internal/ftstream.h>
|
|
|
|
#include <freetype/internal/tterrors.h>
|
|
|
|
#include <freetype/tttags.h>
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
#include <ttpost.h>
|
|
|
|
#include <ttload.h>
|
|
|
|
|
2000-06-12 21:36:41 +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. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_ttpost
|
|
|
|
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
/* If this configuration macro is defined, we rely on the `psnames' */
|
|
|
|
/* module to grab the glyph names. */
|
|
|
|
|
2000-02-10 20:14:48 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
2000-06-05 16:32:32 +02:00
|
|
|
|
2000-05-11 20:23:52 +02:00
|
|
|
#include <freetype/internal/psnames.h>
|
2000-02-10 20:14:48 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
#define MAC_NAME( x ) ( (FT_String*)psnames->macintosh_name( x ) )
|
2000-06-05 16:32:32 +02:00
|
|
|
|
|
|
|
#else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
2000-02-10 20:14:48 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
/* Otherwise, we ignore the `psnames' module, and provide our own */
|
|
|
|
/* table of Mac names. Thus, it is possible to build a version of */
|
|
|
|
/* FreeType without the Type 1 driver & PSNames module. */
|
2000-02-10 20:14:48 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
#define MAC_NAME( x ) TT_Post_Default_Names[x]
|
2000-02-10 20:14:48 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* the 258 default Mac PS glyph names */
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_String* TT_Post_Default_Names[258] =
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
/* 0 */
|
2000-02-10 20:14:48 +01:00
|
|
|
".notdef", ".null", "CR", "space", "exclam",
|
|
|
|
"quotedbl", "numbersign", "dollar", "percent", "ampersand",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 10 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"quotesingle", "parenleft", "parenright", "asterisk", "plus",
|
|
|
|
"comma", "hyphen", "period", "slash", "zero",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 20 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"one", "two", "three", "four", "five",
|
|
|
|
"six", "seven", "eight", "nine", "colon",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 30 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"semicolon", "less", "equal", "greater", "question",
|
|
|
|
"at", "A", "B", "C", "D",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 40 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"E", "F", "G", "H", "I",
|
|
|
|
"J", "K", "L", "M", "N",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 50 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"O", "P", "Q", "R", "S",
|
|
|
|
"T", "U", "V", "W", "X",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 60 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"Y", "Z", "bracketleft", "backslash", "bracketright",
|
|
|
|
"asciicircum", "underscore", "grave", "a", "b",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 70 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"c", "d", "e", "f", "g",
|
|
|
|
"h", "i", "j", "k", "l",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 80 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"m", "n", "o", "p", "q",
|
|
|
|
"r", "s", "t", "u", "v",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 90 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"w", "x", "y", "z", "braceleft",
|
|
|
|
"bar", "braceright", "asciitilde", "Adieresis", "Aring",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 100 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis",
|
|
|
|
"aacute", "agrave", "acircumflex", "adieresis", "atilde",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 110 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"aring", "ccedilla", "eacute", "egrave", "ecircumflex",
|
|
|
|
"edieresis", "iacute", "igrave", "icircumflex", "idieresis",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 120 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"ntilde", "oacute", "ograve", "ocircumflex", "odieresis",
|
|
|
|
"otilde", "uacute", "ugrave", "ucircumflex", "udieresis",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 130 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"dagger", "degree", "cent", "sterling", "section",
|
|
|
|
"bullet", "paragraph", "germandbls", "registered", "copyright",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 140 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"trademark", "acute", "dieresis", "notequal", "AE",
|
|
|
|
"Oslash", "infinity", "plusminus", "lessequal", "greaterequal",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 150 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"yen", "mu", "partialdiff", "summation", "product",
|
|
|
|
"pi", "integral", "ordfeminine", "ordmasculine", "Omega",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 160 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"ae", "oslash", "questiondown", "exclamdown", "logicalnot",
|
|
|
|
"radical", "florin", "approxequal", "Delta", "guillemotleft",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 170 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde",
|
|
|
|
"Otilde", "OE", "oe", "endash", "emdash",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 180 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide",
|
|
|
|
"lozenge", "ydieresis", "Ydieresis", "fraction", "currency",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 190 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl",
|
|
|
|
"periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 200 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute",
|
|
|
|
"Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 210 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave",
|
|
|
|
"dotlessi", "circumflex", "tilde", "macron", "breve",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 220 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek",
|
|
|
|
"caron", "Lslash", "lslash", "Scaron", "scaron",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 230 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"Zcaron", "zcaron", "brokenbar", "Eth", "eth",
|
|
|
|
"Yacute", "yacute", "Thorn", "thorn", "minus",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 240 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf",
|
|
|
|
"onequarter", "threequarters", "franc", "Gbreve", "gbreve",
|
1999-12-17 00:11:37 +01:00
|
|
|
/* 250 */
|
2000-02-10 20:14:48 +01:00
|
|
|
"Idot", "Scedilla", "scedilla", "Cacute", "cacute",
|
|
|
|
"Ccaron", "ccaron", "dmacron",
|
1999-12-17 00:11:37 +01:00
|
|
|
};
|
2000-06-05 16:32:32 +02:00
|
|
|
|
|
|
|
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
static
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error Load_Format_20( TT_Face face,
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Stream stream )
|
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int num_glyphs;
|
|
|
|
FT_Int num_names;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort* glyph_indices = 0;
|
|
|
|
FT_Char** name_strings = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( READ_UShort( num_glyphs ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* UNDOCUMENTED! The number of glyphs in this table can be smaller */
|
|
|
|
/* than the value in the maxp table (cf. cyberbit.ttf). */
|
|
|
|
|
|
|
|
/* There already exist fonts which have more than 32768 glyph names */
|
|
|
|
/* in this table, so the test for this threshold has been dropped. */
|
|
|
|
|
|
|
|
if ( num_glyphs > face->root.num_glyphs )
|
|
|
|
{
|
|
|
|
error = TT_Err_Invalid_File_Format;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* load the indices */
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
if ( ALLOC_ARRAY ( glyph_indices, num_glyphs, FT_UShort ) ||
|
1999-12-17 00:11:37 +01:00
|
|
|
ACCESS_Frame( num_glyphs * 2L ) )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
for ( n = 0; n < num_glyphs; n++ )
|
|
|
|
glyph_indices[n] = GET_UShort();
|
|
|
|
|
|
|
|
FORGET_Frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute number of names stored in table */
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
num_names = 0;
|
|
|
|
|
|
|
|
for ( n = 0; n < num_glyphs; n++ )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int index;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
index = glyph_indices[n];
|
|
|
|
if ( index >= 258 )
|
|
|
|
{
|
|
|
|
index -= 257;
|
|
|
|
if ( index > num_names )
|
|
|
|
num_names = index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now load the name strings */
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
if ( ALLOC_ARRAY( name_strings, num_names, FT_Char* ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
for ( n = 0; n < num_names; n++ )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt len;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( READ_Byte ( len ) ||
|
2000-06-16 21:34:52 +02:00
|
|
|
ALLOC_ARRAY( name_strings[n], len+1, FT_Char ) ||
|
1999-12-17 00:11:37 +01:00
|
|
|
FILE_Read ( name_strings[n], len ) )
|
|
|
|
goto Fail1;
|
|
|
|
|
|
|
|
name_strings[n][len] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all right, set table fields and exit successfuly */
|
|
|
|
{
|
|
|
|
TT_Post_20* table = &face->postscript_names.names.format_20;
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
table->num_glyphs = num_glyphs;
|
|
|
|
table->num_names = num_names;
|
|
|
|
table->glyph_indices = glyph_indices;
|
|
|
|
table->glyph_names = name_strings;
|
|
|
|
}
|
|
|
|
return TT_Err_Ok;
|
|
|
|
|
|
|
|
|
|
|
|
Fail1:
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
for ( n = 0; n < num_names; n++ )
|
|
|
|
FREE( name_strings[n] );
|
|
|
|
}
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
FREE( name_strings );
|
|
|
|
FREE( glyph_indices );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error Load_Format_25( TT_Face face,
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Stream stream )
|
|
|
|
{
|
|
|
|
FT_Memory memory = stream->memory;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int num_glyphs;
|
|
|
|
FT_Char* offset_table = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* UNDOCUMENTED! This value appears only in the Apple TT specs. */
|
|
|
|
if ( READ_UShort( num_glyphs ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* check the number of glyphs */
|
|
|
|
if ( num_glyphs > face->root.num_glyphs || num_glyphs > 258 )
|
|
|
|
{
|
|
|
|
error = TT_Err_Invalid_File_Format;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ALLOC ( offset_table, num_glyphs ) ||
|
|
|
|
FILE_Read( offset_table, num_glyphs ) )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
/* now check the offset table */
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
for ( n = 0; n < num_glyphs; n++ )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Long index = (FT_Long)n + offset_table[n];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( index < 0 || index > num_glyphs )
|
|
|
|
{
|
|
|
|
error = TT_Err_Invalid_File_Format;
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OK, set table fields and exit successfuly */
|
|
|
|
{
|
|
|
|
TT_Post_25* table = &face->postscript_names.names.format_25;
|
|
|
|
|
|
|
|
|
|
|
|
table->num_glyphs = num_glyphs;
|
|
|
|
table->offsets = offset_table;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TT_Err_Ok;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
FREE( offset_table );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error Load_Post_Names( TT_Face face )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Stream stream;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* get a stream for the face's resource */
|
|
|
|
stream = face->root.stream;
|
|
|
|
|
|
|
|
/* seek to the beginning of the PS names table */
|
|
|
|
error = face->goto_table( face, TTAG_post, stream, 0 );
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* now read postscript table */
|
|
|
|
switch ( face->postscript.FormatType )
|
|
|
|
{
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00020000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
error = Load_Format_20( face, stream );
|
|
|
|
break;
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00028000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
error = Load_Format_25( face, stream );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = TT_Err_Invalid_File_Format;
|
|
|
|
}
|
|
|
|
|
|
|
|
face->postscript_names.loaded = 1;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOCAL_FUNC
|
|
|
|
void TT_Free_Post_Names( TT_Face face )
|
|
|
|
{
|
|
|
|
FT_Memory memory = face->root.memory;
|
|
|
|
TT_Post_Names* names = &face->postscript_names;
|
|
|
|
|
|
|
|
|
|
|
|
if ( names->loaded )
|
|
|
|
{
|
|
|
|
switch ( face->postscript.FormatType )
|
|
|
|
{
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00020000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_Post_20* table = &names->names.format_20;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UInt n;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
FREE( table->glyph_indices );
|
|
|
|
table->num_glyphs = 0;
|
|
|
|
|
|
|
|
for ( n = 0; n < table->num_names; n++ )
|
|
|
|
FREE( table->glyph_names[n] );
|
|
|
|
|
|
|
|
FREE( table->glyph_names );
|
|
|
|
table->num_names = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00028000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_Post_25* table = &names->names.format_25;
|
|
|
|
|
|
|
|
|
|
|
|
FREE( table->offsets );
|
|
|
|
table->num_glyphs = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
names->loaded = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Get_PS_Name */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Gets the PostScript glyph name of a glyph. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* face :: A handle to the parent face. */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* index :: The glyph index. */
|
|
|
|
/* */
|
|
|
|
/* PSname :: The address of a string pointer. Will be NULL in case */
|
|
|
|
/* of error, otherwise it is a pointer to the glyph name. */
|
|
|
|
/* */
|
|
|
|
/* You must not modify the returned string! */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
/* TrueType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-12 14:17:15 +02:00
|
|
|
LOCAL_FUNC
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error TT_Get_PS_Name( TT_Face face,
|
|
|
|
FT_UInt index,
|
|
|
|
FT_String** PSname )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
2000-02-10 20:14:48 +01:00
|
|
|
TT_Post_Names* names;
|
2000-06-05 16:32:32 +02:00
|
|
|
|
2000-02-22 14:34:26 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
2000-02-10 20:14:48 +01:00
|
|
|
PSNames_Interface* psnames;
|
2000-02-22 14:34:26 +01:00
|
|
|
#endif
|
2000-06-05 16:32:32 +02:00
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( !face )
|
|
|
|
return TT_Err_Invalid_Face_Handle;
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
if ( index >= (FT_UInt)face->root.num_glyphs )
|
1999-12-17 00:11:37 +01:00
|
|
|
return TT_Err_Invalid_Glyph_Index;
|
|
|
|
|
2000-02-22 14:34:26 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
2000-02-10 20:14:48 +01:00
|
|
|
psnames = (PSNames_Interface*)face->psnames;
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( !psnames )
|
2000-02-10 20:14:48 +01:00
|
|
|
return TT_Err_Unimplemented_Feature;
|
2000-02-22 14:34:26 +01:00
|
|
|
#endif
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
names = &face->postscript_names;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* `.notdef' by default */
|
2000-06-05 16:32:32 +02:00
|
|
|
*PSname = MAC_NAME( 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
switch ( face->postscript.FormatType )
|
|
|
|
{
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00010000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( index < 258 ) /* paranoid checking */
|
2000-06-05 16:32:32 +02:00
|
|
|
*PSname = MAC_NAME( index );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00020000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_Post_20* table = &names->names.format_20;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !names->loaded )
|
|
|
|
{
|
|
|
|
error = Load_Post_Names( face );
|
|
|
|
if ( error )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( index < table->num_glyphs )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort name_index = table->glyph_indices[index];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( name_index < 258 )
|
2000-06-05 16:32:32 +02:00
|
|
|
*PSname = MAC_NAME( name_index );
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
2000-06-16 21:34:52 +02:00
|
|
|
*PSname = (FT_String*)table->glyph_names[name_index - 258];
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00028000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
TT_Post_25* table = &names->names.format_25;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !names->loaded )
|
|
|
|
{
|
|
|
|
error = Load_Post_Names( face );
|
|
|
|
if ( error )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( index < table->num_glyphs ) /* paranoid checking */
|
|
|
|
{
|
|
|
|
index += table->offsets[index];
|
2000-06-05 16:32:32 +02:00
|
|
|
*PSname = MAC_NAME( index );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
case 0x00030000L:
|
1999-12-17 00:11:37 +01:00
|
|
|
break; /* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
return TT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|