Added FreeType II beta 8.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8247 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
123
src/freetype/autohint/CatharonLicense.txt
Normal file
123
src/freetype/autohint/CatharonLicense.txt
Normal file
@@ -0,0 +1,123 @@
|
||||
The Catharon Open Source LICENSE
|
||||
----------------------------
|
||||
|
||||
2000-Jul-04
|
||||
|
||||
Copyright (C) 2000 by Catharon Productions, Inc.
|
||||
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
This license applies to source files distributed by Catharon
|
||||
Productions, Inc. in several archive packages. This license
|
||||
applies to all files found in such packages which do not fall
|
||||
under their own explicit license.
|
||||
|
||||
This license was inspired by the BSD, Artistic, and IJG
|
||||
(Independent JPEG Group) licenses, which all encourage inclusion
|
||||
and use of free software in commercial and freeware products
|
||||
alike. As a consequence, its main points are that:
|
||||
|
||||
o We don't promise that this software works. However, we are
|
||||
interested in any kind of bug reports. (`as is' distribution)
|
||||
|
||||
o You can use this software for whatever you want, in parts or
|
||||
full form, without having to pay us. (`royalty-free' usage)
|
||||
|
||||
o You may not pretend that you wrote this software. If you use
|
||||
it, or only parts of it, in a program, you must acknowledge
|
||||
somewhere in your documentation that you have used the
|
||||
Catharon Code. (`credits')
|
||||
|
||||
We specifically permit and encourage the inclusion of this
|
||||
software, with or without modifications, in commercial products.
|
||||
We disclaim all warranties covering the packages distributed by
|
||||
Catharon Productions, Inc. and assume no liability related to
|
||||
their use.
|
||||
|
||||
|
||||
Legal Terms
|
||||
===========
|
||||
|
||||
0. Definitions
|
||||
--------------
|
||||
|
||||
Throughout this license, the terms `Catharon Package', `package',
|
||||
and `Catharon Code' refer to the set of files originally
|
||||
distributed by Catharon Productions, Inc.
|
||||
|
||||
`You' refers to the licensee, or person using the project, where
|
||||
`using' is a generic term including compiling the project's source
|
||||
code as well as linking it to form a `program' or `executable'.
|
||||
This program is referred to as `a program using one of the
|
||||
Catharon Packages'.
|
||||
|
||||
This license applies to all files distributed in the original
|
||||
Catharon Package(s), including all source code, binaries and
|
||||
documentation, unless otherwise stated in the file in its
|
||||
original, unmodified form as distributed in the original archive.
|
||||
If you are unsure whether or not a particular file is covered by
|
||||
this license, you must contact us to verify this.
|
||||
|
||||
The Catharon Packages are copyright (C) 2000 by Catharon
|
||||
Productions, Inc. All rights reserved except as specified below.
|
||||
|
||||
1. No Warranty
|
||||
--------------
|
||||
|
||||
THE CATHARON PACKAGES ARE PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OF OR THE INABILITY TO
|
||||
USE THE CATHARON PACKAGE.
|
||||
|
||||
2. Redistribution
|
||||
-----------------
|
||||
|
||||
This license grants a worldwide, royalty-free, perpetual and
|
||||
irrevocable right and license to use, execute, perform, compile,
|
||||
display, copy, create derivative works of, distribute and
|
||||
sublicense the Catharon Packages (in both source and object code
|
||||
forms) and derivative works thereof for any purpose; and to
|
||||
authorize others to exercise some or all of the rights granted
|
||||
herein, subject to the following conditions:
|
||||
|
||||
o Redistribution of source code must retain this license file
|
||||
(`license.txt') unaltered; any additions, deletions or changes
|
||||
to the original files must be clearly indicated in
|
||||
accompanying documentation. The copyright notices of the
|
||||
unaltered, original files must be preserved in all copies of
|
||||
source files.
|
||||
|
||||
o Redistribution in binary form must provide a disclaimer that
|
||||
states that the software is based in part on the work of
|
||||
Catharon Productions, Inc. in the distribution documentation.
|
||||
|
||||
These conditions apply to any software derived from or based on
|
||||
the Catharon Packages, not just the unmodified files. If you use
|
||||
our work, you must acknowledge us. However, no fee need be paid
|
||||
to us.
|
||||
|
||||
3. Advertising
|
||||
--------------
|
||||
|
||||
Neither Catharon Productions, Inc. and contributors nor you shall
|
||||
use the name of the other for commercial, advertising, or
|
||||
promotional purposes without specific prior written permission.
|
||||
|
||||
We suggest, but do not require, that you use the following phrase
|
||||
to refer to this software in your documentation: 'this software is
|
||||
based in part on the Catharon Typography Project'.
|
||||
|
||||
As you have not signed this license, you are not required to
|
||||
accept it. However, as the Catharon Packages are copyrighted
|
||||
material, only this license, or another one contracted with the
|
||||
authors, grants you the right to use, distribute, and modify it.
|
||||
Therefore, by using, distributing, or modifying the Catharon
|
||||
Packages, you indicate that you understand and accept all the
|
||||
terms of this license.
|
||||
|
||||
--- end of license.txt ---
|
||||
137
src/freetype/autohint/ahangles.c
Normal file
137
src/freetype/autohint/ahangles.c
Normal file
@@ -0,0 +1,137 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahangles.h */
|
||||
/* */
|
||||
/* A routine used to compute vector angles with limited accuracy */
|
||||
/* and very high speed (body). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahangles.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahangles.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* the following table has been automatically generated with */
|
||||
/* the `mather.py' Python script */
|
||||
|
||||
const AH_Angle ah_arctan[1L << AH_ATAN_BITS] =
|
||||
{
|
||||
0, 0, 1, 1, 1, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 5,
|
||||
5, 5, 6, 6, 6, 7, 7, 7,
|
||||
8, 8, 8, 9, 9, 9, 10, 10,
|
||||
10, 10, 11, 11, 11, 12, 12, 12,
|
||||
13, 13, 13, 14, 14, 14, 14, 15,
|
||||
15, 15, 16, 16, 16, 17, 17, 17,
|
||||
18, 18, 18, 18, 19, 19, 19, 20,
|
||||
20, 20, 21, 21, 21, 21, 22, 22,
|
||||
22, 23, 23, 23, 24, 24, 24, 24,
|
||||
25, 25, 25, 26, 26, 26, 26, 27,
|
||||
27, 27, 28, 28, 28, 28, 29, 29,
|
||||
29, 30, 30, 30, 30, 31, 31, 31,
|
||||
31, 32, 32, 32, 33, 33, 33, 33,
|
||||
34, 34, 34, 34, 35, 35, 35, 35,
|
||||
36, 36, 36, 36, 37, 37, 37, 38,
|
||||
38, 38, 38, 39, 39, 39, 39, 40,
|
||||
40, 40, 40, 41, 41, 41, 41, 42,
|
||||
42, 42, 42, 42, 43, 43, 43, 43,
|
||||
44, 44, 44, 44, 45, 45, 45, 45,
|
||||
46, 46, 46, 46, 46, 47, 47, 47,
|
||||
47, 48, 48, 48, 48, 48, 49, 49,
|
||||
49, 49, 50, 50, 50, 50, 50, 51,
|
||||
51, 51, 51, 51, 52, 52, 52, 52,
|
||||
52, 53, 53, 53, 53, 53, 54, 54,
|
||||
54, 54, 54, 55, 55, 55, 55, 55,
|
||||
56, 56, 56, 56, 56, 57, 57, 57,
|
||||
57, 57, 57, 58, 58, 58, 58, 58,
|
||||
59, 59, 59, 59, 59, 59, 60, 60,
|
||||
60, 60, 60, 61, 61, 61, 61, 61,
|
||||
61, 62, 62, 62, 62, 62, 62, 63,
|
||||
63, 63, 63, 63, 63, 64, 64, 64
|
||||
};
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
AH_Angle ah_angle( FT_Vector* v )
|
||||
{
|
||||
FT_Pos dx, dy;
|
||||
AH_Angle angle;
|
||||
|
||||
|
||||
dx = v->x;
|
||||
dy = v->y;
|
||||
|
||||
/* check trivial cases */
|
||||
if ( dy == 0 )
|
||||
{
|
||||
angle = 0;
|
||||
if ( dx < 0 )
|
||||
angle = AH_PI;
|
||||
return angle;
|
||||
}
|
||||
else if ( dx == 0 )
|
||||
{
|
||||
angle = AH_HALF_PI;
|
||||
if ( dy < 0 )
|
||||
angle = -AH_HALF_PI;
|
||||
return angle;
|
||||
}
|
||||
|
||||
angle = 0;
|
||||
if ( dx < 0 )
|
||||
{
|
||||
dx = -v->x;
|
||||
dy = -v->y;
|
||||
angle = AH_PI;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
FT_Pos tmp;
|
||||
|
||||
|
||||
tmp = dx;
|
||||
dx = -dy;
|
||||
dy = tmp;
|
||||
angle -= AH_HALF_PI;
|
||||
}
|
||||
|
||||
if ( dx == 0 && dy == 0 )
|
||||
return 0;
|
||||
|
||||
if ( dx == dy )
|
||||
angle += AH_PI / 4;
|
||||
else if ( dx > dy )
|
||||
angle += ah_arctan[FT_DivFix( dy, dx ) >> ( 16 - AH_ATAN_BITS )];
|
||||
else
|
||||
angle += AH_HALF_PI -
|
||||
ah_arctan[FT_DivFix( dx, dy ) >> ( 16 - AH_ATAN_BITS )];
|
||||
|
||||
if ( angle > AH_PI )
|
||||
angle -= AH_2PI;
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
63
src/freetype/autohint/ahangles.h
Normal file
63
src/freetype/autohint/ahangles.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahangles.h */
|
||||
/* */
|
||||
/* A routine used to compute vector angles with limited accuracy */
|
||||
/* and very high speed (specification). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHANGLES_H
|
||||
#define AHANGLES_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
/* PI expressed in ah_angles -- we don't really need an important */
|
||||
/* precision, so 256 should be enough */
|
||||
#define AH_PI 256
|
||||
#define AH_2PI ( AH_PI * 2 )
|
||||
#define AH_HALF_PI ( AH_PI / 2 )
|
||||
#define AH_2PIMASK ( AH_2PI - 1 )
|
||||
|
||||
/* the number of bits used to express an arc tangent; */
|
||||
/* see the structure of the lookup table */
|
||||
#define AH_ATAN_BITS 8
|
||||
|
||||
extern
|
||||
const AH_Angle ah_arctan[1L << AH_ATAN_BITS];
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
AH_Angle ah_angle( FT_Vector* v );
|
||||
|
||||
|
||||
#endif /* AHANGLES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
402
src/freetype/autohint/ahglobal.c
Normal file
402
src/freetype/autohint/ahglobal.c
Normal file
@@ -0,0 +1,402 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahglobal.c */
|
||||
/* */
|
||||
/* Routines used to compute global metrics automatically (body). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahglobal.h"
|
||||
#include "ahglyph.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahglobal.h>
|
||||
#include <autohint/ahglyph.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_TEST_CHARACTERS 12
|
||||
|
||||
static
|
||||
const char* blue_chars[ah_blue_max] =
|
||||
{
|
||||
"THEZOCQS",
|
||||
"HEZLOCUS",
|
||||
"xzroesc",
|
||||
"xzroesc",
|
||||
"pqgjy"
|
||||
};
|
||||
|
||||
|
||||
/* simple insertion sort */
|
||||
static
|
||||
void sort_values( FT_Int count,
|
||||
FT_Pos* table )
|
||||
{
|
||||
FT_Int i, j, swap;
|
||||
|
||||
|
||||
for ( i = 1; i < count; i++ )
|
||||
{
|
||||
for ( j = i; j > 1; j-- )
|
||||
{
|
||||
if ( table[j] > table[j - 1] )
|
||||
break;
|
||||
|
||||
swap = table[j];
|
||||
table[j] = table[j - 1];
|
||||
table[j - 1] = swap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error ah_hinter_compute_blues( AH_Hinter* hinter )
|
||||
{
|
||||
AH_Blue blue;
|
||||
AH_Globals* globals = &hinter->globals->design;
|
||||
FT_Pos flats [MAX_TEST_CHARACTERS];
|
||||
FT_Pos rounds[MAX_TEST_CHARACTERS];
|
||||
FT_Int num_flats;
|
||||
FT_Int num_rounds;
|
||||
|
||||
FT_Face face;
|
||||
FT_GlyphSlot glyph;
|
||||
FT_Error error;
|
||||
FT_CharMap charmap;
|
||||
|
||||
|
||||
face = hinter->face;
|
||||
glyph = face->glyph;
|
||||
|
||||
/* save current charmap */
|
||||
charmap = face->charmap;
|
||||
|
||||
/* do we have a Unicode charmap in there? */
|
||||
error = FT_Select_Charmap( face, ft_encoding_unicode );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* we compute the blues simply by loading each character from the */
|
||||
/* 'blue_chars[blues]' string, then compute its top-most and */
|
||||
/* bottom-most points */
|
||||
|
||||
AH_LOG(( "blue zones computation\n" ));
|
||||
AH_LOG(( "------------------------------------------------\n" ));
|
||||
|
||||
for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ )
|
||||
{
|
||||
const char* p = blue_chars[blue];
|
||||
const char* limit = p + MAX_TEST_CHARACTERS;
|
||||
FT_Pos *blue_ref, *blue_shoot;
|
||||
|
||||
|
||||
AH_LOG(( "blue %3d: ", blue ));
|
||||
|
||||
num_flats = 0;
|
||||
num_rounds = 0;
|
||||
|
||||
for ( ; p < limit; p++ )
|
||||
{
|
||||
FT_UInt glyph_index;
|
||||
FT_Vector* extremum;
|
||||
FT_Vector* points;
|
||||
FT_Vector* point_limit;
|
||||
FT_Vector* point;
|
||||
FT_Bool round;
|
||||
|
||||
|
||||
/* exit if we reach the end of the string */
|
||||
if ( !*p )
|
||||
break;
|
||||
|
||||
AH_LOG(( "`%c'", *p ));
|
||||
|
||||
/* load the character in the face -- skip unknown or empty ones */
|
||||
glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p );
|
||||
if ( glyph_index == 0 )
|
||||
continue;
|
||||
|
||||
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
|
||||
if ( error || glyph->outline.n_points <= 0 )
|
||||
continue;
|
||||
|
||||
/* now compute min or max point indices and coordinates */
|
||||
points = glyph->outline.points;
|
||||
point_limit = points + glyph->outline.n_points;
|
||||
point = points;
|
||||
extremum = point;
|
||||
point++;
|
||||
|
||||
if ( AH_IS_TOP_BLUE( blue ) )
|
||||
{
|
||||
for ( ; point < point_limit; point++ )
|
||||
if ( point->y > extremum->y )
|
||||
extremum = point;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ; point < point_limit; point++ )
|
||||
if ( point->y < extremum->y )
|
||||
extremum = point;
|
||||
}
|
||||
|
||||
AH_LOG(( "%5d", (int)extremum->y ));
|
||||
|
||||
/* now, check whether the point belongs to a straight or round */
|
||||
/* segment; we first need to find in which contour the extremum */
|
||||
/* lies, then see its previous and next points */
|
||||
{
|
||||
FT_Int index = extremum - points;
|
||||
FT_Int n;
|
||||
FT_Int first, last, prev, next, end;
|
||||
FT_Pos dist;
|
||||
|
||||
|
||||
last = -1;
|
||||
first = 0;
|
||||
|
||||
for ( n = 0; n < glyph->outline.n_contours; n++ )
|
||||
{
|
||||
end = glyph->outline.contours[n];
|
||||
if ( end >= index )
|
||||
{
|
||||
last = end;
|
||||
break;
|
||||
}
|
||||
first = end + 1;
|
||||
}
|
||||
|
||||
/* XXX: should never happen! */
|
||||
if ( last < 0 )
|
||||
continue;
|
||||
|
||||
/* now look for the previous and next points that are not on the */
|
||||
/* same Y coordinate. Threshold the `closeness'... */
|
||||
|
||||
prev = index;
|
||||
next = prev;
|
||||
|
||||
do
|
||||
{
|
||||
if ( prev > first )
|
||||
prev--;
|
||||
else
|
||||
prev = last;
|
||||
|
||||
dist = points[prev].y - extremum->y;
|
||||
if ( dist < -5 || dist > 5 )
|
||||
break;
|
||||
|
||||
} while ( prev != index );
|
||||
|
||||
do
|
||||
{
|
||||
if ( next < last )
|
||||
next++;
|
||||
else
|
||||
next = first;
|
||||
|
||||
dist = points[next].y - extremum->y;
|
||||
if ( dist < -5 || dist > 5 )
|
||||
break;
|
||||
|
||||
} while ( next != index );
|
||||
|
||||
/* now, set the `round' flag depending on the segment's kind */
|
||||
round =
|
||||
FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_Curve_Tag_On ||
|
||||
FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On ;
|
||||
|
||||
AH_LOG(( "%c ", round ? 'r' : 'f' ));
|
||||
}
|
||||
|
||||
if ( round )
|
||||
rounds[num_rounds++] = extremum->y;
|
||||
else
|
||||
flats[num_flats++] = extremum->y;
|
||||
}
|
||||
|
||||
AH_LOG(( "\n" ));
|
||||
|
||||
/* we have computed the contents of the `rounds' and `flats' tables, */
|
||||
/* now determine the reference and overshoot position of the blue; */
|
||||
/* we simply take the median value after a simple short */
|
||||
sort_values( num_rounds, rounds );
|
||||
sort_values( num_flats, flats );
|
||||
|
||||
blue_ref = globals->blue_refs + blue;
|
||||
blue_shoot = globals->blue_shoots + blue;
|
||||
if ( num_flats == 0 && num_rounds == 0 )
|
||||
{
|
||||
*blue_ref = -10000;
|
||||
*blue_shoot = -10000;
|
||||
}
|
||||
else if ( num_flats == 0 )
|
||||
{
|
||||
*blue_ref =
|
||||
*blue_shoot = rounds[num_rounds / 2];
|
||||
}
|
||||
else if ( num_rounds == 0 )
|
||||
{
|
||||
*blue_ref =
|
||||
*blue_shoot = flats[num_flats / 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
*blue_ref = flats[num_flats / 2];
|
||||
*blue_shoot = rounds[num_rounds / 2];
|
||||
}
|
||||
|
||||
/* there are sometimes problems: if the overshoot position of top */
|
||||
/* zones is under its reference position, or the opposite for bottom */
|
||||
/* zones. We must thus check everything there and correct the errors */
|
||||
if ( *blue_shoot != *blue_ref )
|
||||
{
|
||||
FT_Pos ref = *blue_ref;
|
||||
FT_Pos shoot = *blue_shoot;
|
||||
FT_Bool over_ref = ( shoot > ref );
|
||||
|
||||
|
||||
if ( AH_IS_TOP_BLUE( blue ) ^ over_ref )
|
||||
*blue_shoot = *blue_ref = ( shoot + ref ) / 2;
|
||||
}
|
||||
|
||||
AH_LOG(( "-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot ));
|
||||
}
|
||||
|
||||
/* reset original face charmap */
|
||||
FT_Set_Charmap( face, charmap );
|
||||
error = 0;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error ah_hinter_compute_widths( AH_Hinter* hinter )
|
||||
{
|
||||
/* scan the array of segments in each direction */
|
||||
AH_Outline* outline = hinter->glyph;
|
||||
AH_Segment* segments;
|
||||
AH_Segment* limit;
|
||||
AH_Globals* globals = &hinter->globals->design;
|
||||
FT_Pos* widths;
|
||||
FT_Int dimension;
|
||||
FT_Int* p_num_widths;
|
||||
FT_Error error = 0;
|
||||
FT_Pos edge_distance_threshold = 32000;
|
||||
|
||||
|
||||
globals->num_widths = 0;
|
||||
globals->num_heights = 0;
|
||||
|
||||
/* For now, compute the standard width and height from the `o' */
|
||||
/* character. I started computing the stem width of the `i' and the */
|
||||
/* stem height of the "-", but it wasn't too good. Moreover, we now */
|
||||
/* have a single character that gives us standard width and height. */
|
||||
{
|
||||
FT_UInt glyph_index;
|
||||
|
||||
|
||||
glyph_index = FT_Get_Char_Index( hinter->face, 'o' );
|
||||
if ( glyph_index == 0 )
|
||||
return 0;
|
||||
|
||||
error = FT_Load_Glyph( hinter->face, glyph_index, FT_LOAD_NO_SCALE );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
error = ah_outline_load( hinter->glyph, hinter->face );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
ah_outline_compute_segments( hinter->glyph );
|
||||
ah_outline_link_segments( hinter->glyph );
|
||||
}
|
||||
|
||||
segments = outline->horz_segments;
|
||||
limit = segments + outline->num_hsegments;
|
||||
widths = globals->heights;
|
||||
p_num_widths = &globals->num_heights;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
AH_Segment* seg = segments;
|
||||
AH_Segment* link;
|
||||
FT_Int num_widths = 0;
|
||||
|
||||
|
||||
for ( ; seg < limit; seg++ )
|
||||
{
|
||||
link = seg->link;
|
||||
/* we only consider stem segments there! */
|
||||
if ( link && link->link == seg && link > seg )
|
||||
{
|
||||
FT_Int dist;
|
||||
|
||||
|
||||
dist = seg->pos - link->pos;
|
||||
if ( dist < 0 )
|
||||
dist = -dist;
|
||||
|
||||
if ( num_widths < 12 )
|
||||
widths[num_widths++] = dist;
|
||||
}
|
||||
}
|
||||
|
||||
sort_values( num_widths, widths );
|
||||
*p_num_widths = num_widths;
|
||||
|
||||
/* we will now try to find the smallest width */
|
||||
if ( num_widths > 0 && widths[0] < edge_distance_threshold )
|
||||
edge_distance_threshold = widths[0];
|
||||
|
||||
segments = outline->vert_segments;
|
||||
limit = segments + outline->num_vsegments;
|
||||
widths = globals->widths;
|
||||
p_num_widths = &globals->num_widths;
|
||||
|
||||
}
|
||||
|
||||
/* Now, compute the edge distance threshold as a fraction of the */
|
||||
/* smallest width in the font. Set it in `hinter.glyph' too! */
|
||||
if ( edge_distance_threshold == 32000 )
|
||||
edge_distance_threshold = 50;
|
||||
|
||||
/* let's try 20% */
|
||||
hinter->glyph->edge_distance_threshold = edge_distance_threshold / 5;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error ah_hinter_compute_globals( AH_Hinter* hinter )
|
||||
{
|
||||
return ah_hinter_compute_widths( hinter ) ||
|
||||
ah_hinter_compute_blues ( hinter );
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
52
src/freetype/autohint/ahglobal.h
Normal file
52
src/freetype/autohint/ahglobal.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahglobal.h */
|
||||
/* */
|
||||
/* Routines used to compute global metrics automatically */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHGLOBAL_H
|
||||
#define AHGLOBAL_H
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h> /* for LOCAL_DEF/LOCAL_FUNC */
|
||||
|
||||
|
||||
#define AH_IS_TOP_BLUE( b ) ( (b) == ah_blue_capital_top || \
|
||||
(b) == ah_blue_small_top )
|
||||
|
||||
|
||||
/* compute global metrics automatically */
|
||||
LOCAL_DEF
|
||||
FT_Error ah_hinter_compute_globals( AH_Hinter* hinter );
|
||||
|
||||
|
||||
#endif /* AHGLOBAL_H */
|
||||
|
||||
|
||||
/* END */
|
||||
1299
src/freetype/autohint/ahglyph.c
Normal file
1299
src/freetype/autohint/ahglyph.c
Normal file
File diff suppressed because it is too large
Load Diff
93
src/freetype/autohint/ahglyph.h
Normal file
93
src/freetype/autohint/ahglyph.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahglyph.h */
|
||||
/* */
|
||||
/* Routines used to load and analyze a given glyph before hinting */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHGLYPH_H
|
||||
#define AHGLYPH_H
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum AH_UV_
|
||||
{
|
||||
ah_uv_fxy,
|
||||
ah_uv_fyx,
|
||||
ah_uv_oxy,
|
||||
ah_uv_oyx,
|
||||
ah_uv_ox,
|
||||
ah_uv_oy,
|
||||
ah_uv_yx,
|
||||
ah_uv_xy /* should always be last! */
|
||||
|
||||
} AH_UV;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_setup_uv( AH_Outline* outline,
|
||||
AH_UV source );
|
||||
|
||||
|
||||
/* AH_Outline functions - they should be typically called in this order */
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error ah_outline_new( FT_Memory memory,
|
||||
AH_Outline** aoutline );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error ah_outline_load( AH_Outline* outline,
|
||||
FT_Face face );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_compute_segments( AH_Outline* outline );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_link_segments( AH_Outline* outline );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_detect_features( AH_Outline* outline );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_compute_blue_edges( AH_Outline* outline,
|
||||
AH_Face_Globals* globals );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_scale_blue_edges( AH_Outline* outline,
|
||||
AH_Face_Globals* globals );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_save( AH_Outline* outline, AH_Loader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_outline_done( AH_Outline* outline );
|
||||
|
||||
|
||||
#endif /* AHGLYPH_H */
|
||||
|
||||
|
||||
/* END */
|
||||
1398
src/freetype/autohint/ahhint.c
Normal file
1398
src/freetype/autohint/ahhint.c
Normal file
File diff suppressed because it is too large
Load Diff
72
src/freetype/autohint/ahhint.h
Normal file
72
src/freetype/autohint/ahhint.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahhint.h */
|
||||
/* */
|
||||
/* Glyph hinter (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHHINT_H
|
||||
#define AHHINT_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahglobal.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahglobal.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define AH_HINT_DEFAULT 0
|
||||
#define AH_HINT_NO_ALIGNMENT 1
|
||||
#define AH_HINT_NO_HORZ_EDGES 0x20000L
|
||||
#define AH_HINT_NO_VERT_EDGES 0x40000L
|
||||
|
||||
|
||||
/* create a new empty hinter object */
|
||||
FT_Error ah_hinter_new( FT_Library library,
|
||||
AH_Hinter** ahinter );
|
||||
|
||||
/* Load a hinted glyph in the hinter */
|
||||
FT_Error ah_hinter_load_glyph( AH_Hinter* hinter,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Size size,
|
||||
FT_UInt glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
/* finalize a hinter object */
|
||||
void ah_hinter_done( AH_Hinter* hinter );
|
||||
|
||||
LOCAL_DEF
|
||||
void ah_hinter_done_face_globals( AH_Face_Globals* globals );
|
||||
|
||||
void ah_hinter_get_global_hints( AH_Hinter* hinter,
|
||||
FT_Face face,
|
||||
void** global_hints,
|
||||
long* global_len );
|
||||
|
||||
void ah_hinter_done_global_hints( AH_Hinter* hinter,
|
||||
void* global_hints );
|
||||
|
||||
|
||||
#endif /* AHHINT_H */
|
||||
|
||||
|
||||
/* END */
|
||||
124
src/freetype/autohint/ahloader.h
Normal file
124
src/freetype/autohint/ahloader.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahloader.h */
|
||||
/* */
|
||||
/* Glyph loader for the auto-hinting module (declaration only). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This defines the AH_GlyphLoader type in two different ways: */
|
||||
/* */
|
||||
/* - If the module is compiled within FreeType 2, the type is simply a */
|
||||
/* typedef to FT_GlyphLoader. */
|
||||
/* */
|
||||
/* - If the module is compiled as a standalone object, AH_GlyphLoader */
|
||||
/* has its own implementation. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHLOADER_H
|
||||
#define AHLOADER_H
|
||||
|
||||
|
||||
#ifdef _STANDALONE_
|
||||
|
||||
typedef struct AH_GlyphLoad_
|
||||
{
|
||||
FT_Outline outline; /* outline */
|
||||
FT_UInt num_subglyphs; /* number of subglyphs */
|
||||
FT_SubGlyph* subglyphs; /* subglyphs */
|
||||
FT_Vector* extra_points; /* extra points table */
|
||||
|
||||
} AH_GlyphLoad;
|
||||
|
||||
|
||||
struct AH_GlyphLoader_
|
||||
{
|
||||
FT_Memory memory;
|
||||
FT_UInt max_points;
|
||||
FT_UInt max_contours;
|
||||
FT_UInt max_subglyphs;
|
||||
FT_Bool use_extra;
|
||||
|
||||
AH_GlyphLoad base;
|
||||
AH_GlyphLoad current;
|
||||
|
||||
void* other; /* for possible future extensions */
|
||||
};
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_New( FT_Memory memory,
|
||||
AH_GlyphLoader** aloader );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Create_Extra( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Done( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Reset( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Rewind( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Check_Points( AH_GlyphLoader* loader,
|
||||
FT_UInt n_points,
|
||||
FT_UInt n_contours );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Check_Subglyphs( AH_GlyphLoader* loader,
|
||||
FT_UInt n_subs );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Prepare( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
void AH_GlyphLoader_Add( AH_GlyphLoader* loader );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error AH_GlyphLoader_Copy_Points( AH_GlyphLoader* target,
|
||||
FT_GlyphLoader* source );
|
||||
|
||||
#else /* _STANDALONE */
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
#define AH_Load FT_GlyphLoad
|
||||
#define AH_Loader FT_GlyphLoader
|
||||
|
||||
#define ah_loader_new FT_GlyphLoader_New
|
||||
#define ah_loader_done FT_GlyphLoader_Done
|
||||
#define ah_loader_reset FT_GlyphLoader_Reset
|
||||
#define ah_loader_rewind FT_GlyphLoader_Rewind
|
||||
#define ah_loader_create_extra FT_GlyphLoader_Create_Extra
|
||||
#define ah_loader_check_points FT_GlyphLoader_Check_Points
|
||||
#define ah_loader_check_subglyphs FT_GlyphLoader_Check_Subglyphs
|
||||
#define ah_loader_prepare FT_GlyphLoader_Prepare
|
||||
#define ah_loader_add FT_GlyphLoader_Add
|
||||
#define ah_loader_copy_points FT_GlyphLoader_Copy_Points
|
||||
|
||||
#endif /* _STANDALONE_ */
|
||||
|
||||
#endif /* AHLOADER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
127
src/freetype/autohint/ahmodule.c
Normal file
127
src/freetype/autohint/ahmodule.c
Normal file
@@ -0,0 +1,127 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahmodule.c */
|
||||
/* */
|
||||
/* Auto-hinting module implementation (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahhint.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahhint.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct FT_AutoHinterRec_
|
||||
{
|
||||
FT_ModuleRec root;
|
||||
AH_Hinter* hinter;
|
||||
|
||||
} FT_AutoHinterRec;
|
||||
|
||||
|
||||
static
|
||||
FT_Error ft_autohinter_init( FT_AutoHinter module )
|
||||
{
|
||||
return ah_hinter_new( module->root.library, &module->hinter );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_done( FT_AutoHinter module )
|
||||
{
|
||||
ah_hinter_done( module->hinter );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error ft_autohinter_load( FT_AutoHinter module,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Size size,
|
||||
FT_UInt glyph_index,
|
||||
FT_ULong load_flags )
|
||||
{
|
||||
return ah_hinter_load_glyph( module->hinter,
|
||||
slot, size, glyph_index, load_flags );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_reset( FT_AutoHinter module,
|
||||
FT_Face face )
|
||||
{
|
||||
UNUSED( module );
|
||||
|
||||
if ( face->autohint.data )
|
||||
ah_hinter_done_face_globals( (AH_Face_Globals*)(face->autohint.data) );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_get_globals( FT_AutoHinter module,
|
||||
FT_Face face,
|
||||
void** global_hints,
|
||||
long* global_len )
|
||||
{
|
||||
ah_hinter_get_global_hints( module->hinter, face,
|
||||
global_hints, global_len );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void ft_autohinter_done_globals( FT_AutoHinter module,
|
||||
void* global_hints )
|
||||
{
|
||||
ah_hinter_done_global_hints( module->hinter, global_hints );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
const FT_AutoHinter_Interface autohinter_interface =
|
||||
{
|
||||
ft_autohinter_reset,
|
||||
ft_autohinter_load,
|
||||
ft_autohinter_get_globals,
|
||||
ft_autohinter_done_globals
|
||||
};
|
||||
|
||||
|
||||
const FT_Module_Class autohint_module_class =
|
||||
{
|
||||
ft_module_hinter,
|
||||
sizeof ( FT_AutoHinterRec ),
|
||||
|
||||
"autohinter",
|
||||
0x10000L, /* version 1.0 of the autohinter */
|
||||
0x20000L, /* requires FreeType 2.0 or above */
|
||||
|
||||
(const void*)&autohinter_interface,
|
||||
|
||||
(FT_Module_Constructor)ft_autohinter_init,
|
||||
(FT_Module_Destructor) ft_autohinter_done,
|
||||
(FT_Module_Requester) 0
|
||||
};
|
||||
|
||||
|
||||
/* END */
|
||||
32
src/freetype/autohint/ahmodule.h
Normal file
32
src/freetype/autohint/ahmodule.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahmodule.h */
|
||||
/* */
|
||||
/* Auto-hinting module (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHMODULE_H
|
||||
#define AHMODULE_H
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Module_Class ) autohint_module_class;
|
||||
|
||||
#endif /* AHMODULE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
889
src/freetype/autohint/ahoptim.c
Normal file
889
src/freetype/autohint/ahoptim.c
Normal file
@@ -0,0 +1,889 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahoptim.c */
|
||||
/* */
|
||||
/* FreeType auto hinting outline optimization (body). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This module is in charge of optimising the outlines produced by the */
|
||||
/* auto-hinter in direct mode. This is required at small pixel sizes in */
|
||||
/* order to ensure coherent spacing, among other things.. */
|
||||
/* */
|
||||
/* The technique used in this module is a simplified simulated */
|
||||
/* annealing. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h> /* for ALLOC_ARRAY() and FREE() */
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahoptim.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahoptim.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* define this macro to use brute force optimisation -- this is slow, */
|
||||
/* but a good way to perfect the distortion function `by hand' through */
|
||||
/* tweaking */
|
||||
#define AH_BRUTE_FORCE
|
||||
|
||||
|
||||
#define xxxAH_DEBUG_OPTIM
|
||||
|
||||
|
||||
#undef LOG
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
|
||||
#define LOG( x ) optim_log##x
|
||||
|
||||
#else
|
||||
|
||||
#define LOG( x )
|
||||
|
||||
#endif /* AH_DEBUG_OPTIM */
|
||||
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FLOAT( x ) ( (float)( (x) / 64.0 ) )
|
||||
|
||||
static
|
||||
void optim_log( const char* fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
vprintf( fmt, ap );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void AH_Dump_Stems( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
AH_Stem* stem;
|
||||
|
||||
|
||||
stem = optimizer->stems;
|
||||
for ( n = 0; n < optimizer->num_stems; n++, stem++ )
|
||||
{
|
||||
LOG(( " %c%2d [%.1f:%.1f]={%.1f:%.1f}="
|
||||
"<%1.f..%1.f> force=%.1f speed=%.1f\n",
|
||||
optimizer->vertical ? 'V' : 'H', n,
|
||||
FLOAT( stem->edge1->opos ), FLOAT( stem->edge2->opos ),
|
||||
FLOAT( stem->edge1->pos ), FLOAT( stem->edge2->pos ),
|
||||
FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
|
||||
FLOAT( stem->force ), FLOAT( stem->velocity ) ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void AH_Dump_Stems2( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
AH_Stem* stem;
|
||||
|
||||
|
||||
stem = optimizer->stems;
|
||||
for ( n = 0; n < optimizer->num_stems; n++, stem++ )
|
||||
{
|
||||
LOG(( " %c%2d [%.1f]=<%1.f..%1.f> force=%.1f speed=%.1f\n",
|
||||
optimizer->vertical ? 'V' : 'H', n,
|
||||
FLOAT( stem->pos ),
|
||||
FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
|
||||
FLOAT( stem->force ), FLOAT( stem->velocity ) ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void AH_Dump_Springs( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
AH_Spring* spring;
|
||||
AH_Stem* stems;
|
||||
|
||||
|
||||
spring = optimizer->springs;
|
||||
stems = optimizer->stems;
|
||||
LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' ));
|
||||
|
||||
for ( n = 0; n < optimizer->num_springs; n++, spring++ )
|
||||
{
|
||||
LOG(( " [%d-%d:%.1f:%1.f:%.1f]",
|
||||
spring->stem1 - stems, spring->stem2 - stems,
|
||||
FLOAT( spring->owidth ),
|
||||
FLOAT( spring->stem2->pos -
|
||||
( spring->stem1->pos + spring->stem1->width ) ),
|
||||
FLOAT( spring->tension ) ));
|
||||
}
|
||||
|
||||
LOG(( "\n" ));
|
||||
}
|
||||
|
||||
#endif /* AH_DEBUG_OPTIM */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** COMPUTE STEMS AND SPRINGS IN AN OUTLINE ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
int valid_stem_segments( AH_Segment* seg1,
|
||||
AH_Segment* seg2 )
|
||||
{
|
||||
return seg1->serif == 0 &&
|
||||
seg2 &&
|
||||
seg2->link == seg1 &&
|
||||
seg1->pos < seg2->pos &&
|
||||
seg1->min_coord <= seg2->max_coord &&
|
||||
seg2->min_coord <= seg1->max_coord;
|
||||
}
|
||||
|
||||
|
||||
/* compute all stems in an outline */
|
||||
static
|
||||
int optim_compute_stems( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Outline* outline = optimizer->outline;
|
||||
FT_Fixed scale;
|
||||
FT_Memory memory = optimizer->memory;
|
||||
FT_Error error = 0;
|
||||
FT_Int dimension;
|
||||
AH_Edge* edges;
|
||||
AH_Edge* edge_limit;
|
||||
AH_Stem** p_stems;
|
||||
FT_Int* p_num_stems;
|
||||
|
||||
|
||||
edges = outline->horz_edges;
|
||||
edge_limit = edges + outline->num_hedges;
|
||||
scale = outline->y_scale;
|
||||
|
||||
p_stems = &optimizer->horz_stems;
|
||||
p_num_stems = &optimizer->num_hstems;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
AH_Stem* stems = 0;
|
||||
FT_Int num_stems = 0;
|
||||
AH_Edge* edge;
|
||||
|
||||
|
||||
/* first of all, count the number of stems in this direction */
|
||||
for ( edge = edges; edge < edge_limit; edge++ )
|
||||
{
|
||||
AH_Segment* seg = edge->first;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
if (valid_stem_segments( seg, seg->link ) )
|
||||
num_stems++;
|
||||
|
||||
seg = seg->edge_next;
|
||||
|
||||
} while ( seg != edge->first );
|
||||
}
|
||||
|
||||
/* now allocate the stems and build their table */
|
||||
if ( num_stems > 0 )
|
||||
{
|
||||
AH_Stem* stem;
|
||||
|
||||
|
||||
if ( ALLOC_ARRAY( stems, num_stems, AH_Stem ) )
|
||||
goto Exit;
|
||||
|
||||
stem = stems;
|
||||
for ( edge = edges; edge < edge_limit; edge++ )
|
||||
{
|
||||
AH_Segment* seg = edge->first;
|
||||
AH_Segment* seg2;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
seg2 = seg->link;
|
||||
if ( valid_stem_segments( seg, seg2 ) )
|
||||
{
|
||||
AH_Edge* edge1 = seg->edge;
|
||||
AH_Edge* edge2 = seg2->edge;
|
||||
|
||||
|
||||
stem->edge1 = edge1;
|
||||
stem->edge2 = edge2;
|
||||
stem->opos = edge1->opos;
|
||||
stem->pos = edge1->pos;
|
||||
stem->owidth = edge2->opos - edge1->opos;
|
||||
stem->width = edge2->pos - edge1->pos;
|
||||
|
||||
/* compute min_coord and max_coord */
|
||||
{
|
||||
FT_Pos min_coord = seg->min_coord;
|
||||
FT_Pos max_coord = seg->max_coord;
|
||||
|
||||
|
||||
if ( seg2->min_coord > min_coord )
|
||||
min_coord = seg2->min_coord;
|
||||
|
||||
if ( seg2->max_coord < max_coord )
|
||||
max_coord = seg2->max_coord;
|
||||
|
||||
stem->min_coord = min_coord;
|
||||
stem->max_coord = max_coord;
|
||||
}
|
||||
|
||||
/* compute minimum and maximum positions for stem -- */
|
||||
/* note that the left-most/bottom-most stem has always */
|
||||
/* a fixed position */
|
||||
if ( stem == stems || edge1->blue_edge || edge2->blue_edge )
|
||||
{
|
||||
/* this stem cannot move; it is snapped to a blue edge */
|
||||
stem->min_pos = stem->pos;
|
||||
stem->max_pos = stem->pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this edge can move; compute its min and max positions */
|
||||
FT_Pos pos1 = stem->opos;
|
||||
FT_Pos pos2 = pos1 + stem->owidth - stem->width;
|
||||
FT_Pos min1 = pos1 & -64;
|
||||
FT_Pos min2 = pos2 & -64;
|
||||
|
||||
|
||||
stem->min_pos = min1;
|
||||
stem->max_pos = min1 + 64;
|
||||
if ( min2 < min1 )
|
||||
stem->min_pos = min2;
|
||||
else
|
||||
stem->max_pos = min2 + 64;
|
||||
|
||||
/* XXX: just to see what it does */
|
||||
stem->max_pos += 64;
|
||||
|
||||
/* just for the case where direct hinting did some */
|
||||
/* incredible things (e.g. blue edge shifts) */
|
||||
if ( stem->min_pos > stem->pos )
|
||||
stem->min_pos = stem->pos;
|
||||
|
||||
if ( stem->max_pos < stem->pos )
|
||||
stem->max_pos = stem->pos;
|
||||
}
|
||||
|
||||
stem->velocity = 0;
|
||||
stem->force = 0;
|
||||
|
||||
stem++;
|
||||
}
|
||||
seg = seg->edge_next;
|
||||
|
||||
} while ( seg != edge->first );
|
||||
}
|
||||
}
|
||||
|
||||
*p_stems = stems;
|
||||
*p_num_stems = num_stems;
|
||||
|
||||
edges = outline->vert_edges;
|
||||
edge_limit = edges + outline->num_vedges;
|
||||
scale = outline->x_scale;
|
||||
|
||||
p_stems = &optimizer->vert_stems;
|
||||
p_num_stems = &optimizer->num_vstems;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
AH_Dump_Stems( optimizer );
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* returns the spring area between two stems, 0 if none */
|
||||
static
|
||||
FT_Pos stem_spring_area( AH_Stem* stem1,
|
||||
AH_Stem* stem2 )
|
||||
{
|
||||
FT_Pos area1 = stem1->max_coord - stem1->min_coord;
|
||||
FT_Pos area2 = stem2->max_coord - stem2->min_coord;
|
||||
FT_Pos min = stem1->min_coord;
|
||||
FT_Pos max = stem1->max_coord;
|
||||
FT_Pos area;
|
||||
|
||||
|
||||
/* order stems */
|
||||
if ( stem2->opos <= stem1->opos + stem1->owidth )
|
||||
return 0;
|
||||
|
||||
if ( min < stem2->min_coord )
|
||||
min = stem2->min_coord;
|
||||
|
||||
if ( max < stem2->max_coord )
|
||||
max = stem2->max_coord;
|
||||
|
||||
area = ( max-min );
|
||||
if ( 2 * area < area1 && 2 * area < area2 )
|
||||
area = 0;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
|
||||
/* compute all springs in an outline */
|
||||
static
|
||||
int optim_compute_springs( AH_Optimizer* optimizer )
|
||||
{
|
||||
/* basically, a spring exists between two stems if most of their */
|
||||
/* surface is aligned */
|
||||
FT_Memory memory = optimizer->memory;
|
||||
|
||||
AH_Stem* stems;
|
||||
AH_Stem* stem_limit;
|
||||
AH_Stem* stem;
|
||||
int dimension;
|
||||
int error = 0;
|
||||
|
||||
FT_Int* p_num_springs;
|
||||
AH_Spring** p_springs;
|
||||
|
||||
|
||||
stems = optimizer->horz_stems;
|
||||
stem_limit = stems + optimizer->num_hstems;
|
||||
|
||||
p_springs = &optimizer->horz_springs;
|
||||
p_num_springs = &optimizer->num_hsprings;
|
||||
|
||||
for ( dimension = 1; dimension >= 0; dimension-- )
|
||||
{
|
||||
FT_Int num_springs = 0;
|
||||
AH_Spring* springs = 0;
|
||||
|
||||
|
||||
/* first of all, count stem springs */
|
||||
for ( stem = stems; stem + 1 < stem_limit; stem++ )
|
||||
{
|
||||
AH_Stem* stem2;
|
||||
|
||||
|
||||
for ( stem2 = stem+1; stem2 < stem_limit; stem2++ )
|
||||
if ( stem_spring_area( stem, stem2 ) )
|
||||
num_springs++;
|
||||
}
|
||||
|
||||
/* then allocate and build the springs table */
|
||||
if ( num_springs > 0 )
|
||||
{
|
||||
AH_Spring* spring;
|
||||
|
||||
|
||||
/* allocate table of springs */
|
||||
if ( ALLOC_ARRAY( springs, num_springs, AH_Spring ) )
|
||||
goto Exit;
|
||||
|
||||
/* fill the springs table */
|
||||
spring = springs;
|
||||
for ( stem = stems; stem+1 < stem_limit; stem++ )
|
||||
{
|
||||
AH_Stem* stem2;
|
||||
FT_Pos area;
|
||||
|
||||
|
||||
for ( stem2 = stem + 1; stem2 < stem_limit; stem2++ )
|
||||
{
|
||||
area = stem_spring_area( stem, stem2 );
|
||||
if ( area )
|
||||
{
|
||||
/* add a new spring here */
|
||||
spring->stem1 = stem;
|
||||
spring->stem2 = stem2;
|
||||
spring->owidth = stem2->opos - ( stem->opos + stem->owidth );
|
||||
spring->tension = 0;
|
||||
|
||||
spring++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*p_num_springs = num_springs;
|
||||
*p_springs = springs;
|
||||
|
||||
stems = optimizer->vert_stems;
|
||||
stem_limit = stems + optimizer->num_vstems;
|
||||
|
||||
p_springs = &optimizer->vert_springs;
|
||||
p_num_springs = &optimizer->num_vsprings;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
AH_Dump_Springs( optimizer );
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** OPTIMIZE THROUGH MY STRANGE SIMULATED ANNEALING ALGO ;-) ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef AH_BRUTE_FORCE
|
||||
|
||||
/* compute all spring tensions */
|
||||
static
|
||||
void optim_compute_tensions( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Spring* spring = optimizer->springs;
|
||||
AH_Spring* limit = spring + optimizer->num_springs;
|
||||
|
||||
|
||||
for ( ; spring < limit; spring++ )
|
||||
{
|
||||
AH_Stem* stem1 = spring->stem1;
|
||||
AH_Stem* stem2 = spring->stem2;
|
||||
FT_Int status;
|
||||
|
||||
FT_Pos width;
|
||||
FT_Pos tension;
|
||||
FT_Pos sign;
|
||||
|
||||
|
||||
/* compute the tension; it simply is -K*(new_width-old_width) */
|
||||
width = stem2->pos - ( stem1->pos + stem1->width );
|
||||
tension = width - spring->owidth;
|
||||
|
||||
sign = 1;
|
||||
if ( tension < 0 )
|
||||
{
|
||||
sign = -1;
|
||||
tension = -tension;
|
||||
}
|
||||
|
||||
if ( width <= 0 )
|
||||
tension = 32000;
|
||||
else
|
||||
tension = ( tension << 10 ) / width;
|
||||
|
||||
tension = -sign * FT_MulFix( tension, optimizer->tension_scale );
|
||||
spring->tension = tension;
|
||||
|
||||
/* now, distribute tension among the englobing stems, if they */
|
||||
/* are able to move */
|
||||
status = 0;
|
||||
if ( stem1->pos <= stem1->min_pos )
|
||||
status |= 1;
|
||||
if ( stem2->pos >= stem2->max_pos )
|
||||
status |= 2;
|
||||
|
||||
if ( !status )
|
||||
tension /= 2;
|
||||
|
||||
if ( ( status & 1 ) == 0 )
|
||||
stem1->force -= tension;
|
||||
|
||||
if ( ( status & 2 ) == 0 )
|
||||
stem2->force += tension;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* compute all stem movements -- returns 0 if nothing moved */
|
||||
static
|
||||
int optim_compute_stem_movements( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Stem* stems = optimizer->stems;
|
||||
AH_Stem* limit = stems + optimizer->num_stems;
|
||||
AH_Stem* stem = stems;
|
||||
int moved = 0;
|
||||
|
||||
|
||||
/* set initial forces to velocity */
|
||||
for ( stem = stems; stem < limit; stem++ )
|
||||
{
|
||||
stem->force = stem->velocity;
|
||||
stem->velocity /= 2; /* XXX: Heuristics */
|
||||
}
|
||||
|
||||
/* compute the sum of forces applied on each stem */
|
||||
optim_compute_tensions( optimizer );
|
||||
|
||||
#ifdef AH_DEBUG_OPTIM
|
||||
AH_Dump_Springs( optimizer );
|
||||
AH_Dump_Stems2( optimizer );
|
||||
#endif
|
||||
|
||||
/* now, see whether something can move */
|
||||
for ( stem = stems; stem < limit; stem++ )
|
||||
{
|
||||
if ( stem->force > optimizer->tension_threshold )
|
||||
{
|
||||
/* there is enough tension to move the stem to the right */
|
||||
if ( stem->pos < stem->max_pos )
|
||||
{
|
||||
stem->pos += 64;
|
||||
stem->velocity = stem->force / 2;
|
||||
moved = 1;
|
||||
}
|
||||
else
|
||||
stem->velocity = 0;
|
||||
}
|
||||
else if ( stem->force < optimizer->tension_threshold )
|
||||
{
|
||||
/* there is enough tension to move the stem to the left */
|
||||
if ( stem->pos > stem->min_pos )
|
||||
{
|
||||
stem->pos -= 64;
|
||||
stem->velocity = stem->force / 2;
|
||||
moved = 1;
|
||||
}
|
||||
else
|
||||
stem->velocity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* return 0 if nothing moved */
|
||||
return moved;
|
||||
}
|
||||
|
||||
#endif /* AH_BRUTE_FORCE */
|
||||
|
||||
|
||||
/* compute current global distortion from springs */
|
||||
static
|
||||
FT_Pos optim_compute_distortion( AH_Optimizer* optimizer )
|
||||
{
|
||||
AH_Spring* spring = optimizer->springs;
|
||||
AH_Spring* limit = spring + optimizer->num_springs;
|
||||
FT_Pos distortion = 0;
|
||||
|
||||
|
||||
for ( ; spring < limit; spring++ )
|
||||
{
|
||||
AH_Stem* stem1 = spring->stem1;
|
||||
AH_Stem* stem2 = spring->stem2;
|
||||
FT_Pos width;
|
||||
|
||||
width = stem2->pos - ( stem1->pos + stem1->width );
|
||||
width -= spring->owidth;
|
||||
if ( width < 0 )
|
||||
width = -width;
|
||||
|
||||
distortion += width;
|
||||
}
|
||||
|
||||
return distortion;
|
||||
}
|
||||
|
||||
|
||||
/* record stems configuration in `best of' history */
|
||||
static
|
||||
void optim_record_configuration( AH_Optimizer* optimizer )
|
||||
{
|
||||
FT_Pos distortion;
|
||||
AH_Configuration* configs = optimizer->configs;
|
||||
AH_Configuration* limit = configs + optimizer->num_configs;
|
||||
AH_Configuration* config;
|
||||
|
||||
|
||||
distortion = optim_compute_distortion( optimizer );
|
||||
LOG(( "config distortion = %.1f ", FLOAT( distortion * 64 ) ));
|
||||
|
||||
/* check that we really need to add this configuration to our */
|
||||
/* sorted history */
|
||||
if ( limit > configs && limit[-1].distortion < distortion )
|
||||
{
|
||||
LOG(( "ejected\n" ));
|
||||
return;
|
||||
}
|
||||
|
||||
/* add new configuration at the end of the table */
|
||||
{
|
||||
int n;
|
||||
|
||||
|
||||
config = limit;
|
||||
if ( optimizer->num_configs < AH_MAX_CONFIGS )
|
||||
optimizer->num_configs++;
|
||||
else
|
||||
config--;
|
||||
|
||||
config->distortion = distortion;
|
||||
|
||||
for ( n = 0; n < optimizer->num_stems; n++ )
|
||||
config->positions[n] = optimizer->stems[n].pos;
|
||||
}
|
||||
|
||||
/* move the current configuration towards the front of the list */
|
||||
/* when necessary -- yes this is slow bubble sort ;-) */
|
||||
while ( config > configs && config[0].distortion < config[-1].distortion )
|
||||
{
|
||||
AH_Configuration temp;
|
||||
|
||||
|
||||
config--;
|
||||
temp = config[0];
|
||||
config[0] = config[1];
|
||||
config[1] = temp;
|
||||
}
|
||||
LOG(( "recorded!\n" ));
|
||||
}
|
||||
|
||||
|
||||
#ifdef AH_BRUTE_FORCE
|
||||
|
||||
/* optimize outline in a single direction */
|
||||
static
|
||||
void optim_compute( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n;
|
||||
FT_Bool moved;
|
||||
|
||||
AH_Stem* stem = optimizer->stems;
|
||||
AH_Stem* limit = stem + optimizer->num_stems;
|
||||
|
||||
|
||||
/* empty, exit */
|
||||
if ( stem >= limit )
|
||||
return;
|
||||
|
||||
optimizer->num_configs = 0;
|
||||
|
||||
stem = optimizer->stems;
|
||||
for ( ; stem < limit; stem++ )
|
||||
stem->pos = stem->min_pos;
|
||||
|
||||
do
|
||||
{
|
||||
/* record current configuration */
|
||||
optim_record_configuration( optimizer );
|
||||
|
||||
/* now change configuration */
|
||||
moved = 0;
|
||||
for ( stem = optimizer->stems; stem < limit; stem++ )
|
||||
{
|
||||
if ( stem->pos < stem->max_pos )
|
||||
{
|
||||
stem->pos += 64;
|
||||
moved = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
stem->pos = stem->min_pos;
|
||||
}
|
||||
} while ( moved );
|
||||
|
||||
/* now, set the best stem positions */
|
||||
for ( n = 0; n < optimizer->num_stems; n++ )
|
||||
{
|
||||
AH_Stem* stem = optimizer->stems + n;
|
||||
FT_Pos pos = optimizer->configs[0].positions[n];
|
||||
|
||||
|
||||
stem->edge1->pos = pos;
|
||||
stem->edge2->pos = pos + stem->width;
|
||||
|
||||
stem->edge1->flags |= ah_edge_done;
|
||||
stem->edge2->flags |= ah_edge_done;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* AH_BRUTE_FORCE */
|
||||
|
||||
/* optimize outline in a single direction */
|
||||
static
|
||||
void optim_compute( AH_Optimizer* optimizer )
|
||||
{
|
||||
int n, counter, counter2;
|
||||
|
||||
|
||||
optimizer->num_configs = 0;
|
||||
optimizer->tension_scale = 0x80000L;
|
||||
optimizer->tension_threshold = 64;
|
||||
|
||||
/* record initial configuration threshold */
|
||||
optim_record_configuration( optimizer );
|
||||
|
||||
counter = 0;
|
||||
for ( counter2 = optimizer->num_stems*8; counter2 >= 0; counter2-- )
|
||||
{
|
||||
if ( counter == 0 )
|
||||
counter = 2 * optimizer->num_stems;
|
||||
|
||||
if ( !optim_compute_stem_movements( optimizer ) )
|
||||
break;
|
||||
|
||||
optim_record_configuration( optimizer );
|
||||
|
||||
counter--;
|
||||
if ( counter == 0 )
|
||||
optimizer->tension_scale /= 2;
|
||||
}
|
||||
|
||||
/* now, set the best stem positions */
|
||||
for ( n = 0; n < optimizer->num_stems; n++ )
|
||||
{
|
||||
AH_Stem* stem = optimizer->stems + n;
|
||||
FT_Pos pos = optimizer->configs[0].positions[n];
|
||||
|
||||
|
||||
stem->edge1->pos = pos;
|
||||
stem->edge2->pos = pos + stem->width;
|
||||
|
||||
stem->edge1->flags |= ah_edge_done;
|
||||
stem->edge2->flags |= ah_edge_done;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AH_BRUTE_FORCE */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** HIGH-LEVEL OPTIMIZER API ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* releases the optimization data */
|
||||
void AH_Optimizer_Done( AH_Optimizer* optimizer )
|
||||
{
|
||||
if ( optimizer )
|
||||
{
|
||||
FT_Memory memory = optimizer->memory;
|
||||
|
||||
|
||||
FREE( optimizer->horz_stems );
|
||||
FREE( optimizer->vert_stems );
|
||||
FREE( optimizer->horz_springs );
|
||||
FREE( optimizer->vert_springs );
|
||||
FREE( optimizer->positions );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* loads the outline into the optimizer */
|
||||
int AH_Optimizer_Init( AH_Optimizer* optimizer,
|
||||
AH_Outline* outline,
|
||||
FT_Memory memory )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
MEM_Set( optimizer, 0, sizeof ( *optimizer ) );
|
||||
optimizer->outline = outline;
|
||||
optimizer->memory = memory;
|
||||
|
||||
LOG(( "initializing new optimizer\n" ));
|
||||
/* compute stems and springs */
|
||||
error = optim_compute_stems ( optimizer ) ||
|
||||
optim_compute_springs( optimizer );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
/* allocate stem positions history and configurations */
|
||||
{
|
||||
int n, max_stems;
|
||||
|
||||
|
||||
max_stems = optimizer->num_hstems;
|
||||
if ( max_stems < optimizer->num_vstems )
|
||||
max_stems = optimizer->num_vstems;
|
||||
|
||||
if ( ALLOC_ARRAY( optimizer->positions,
|
||||
max_stems * AH_MAX_CONFIGS, FT_Pos ) )
|
||||
goto Fail;
|
||||
|
||||
optimizer->num_configs = 0;
|
||||
for ( n = 0; n < AH_MAX_CONFIGS; n++ )
|
||||
optimizer->configs[n].positions = optimizer->positions +
|
||||
n * max_stems;
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
Fail:
|
||||
AH_Optimizer_Done( optimizer );
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* compute optimal outline */
|
||||
void AH_Optimizer_Compute( AH_Optimizer* optimizer )
|
||||
{
|
||||
optimizer->num_stems = optimizer->num_hstems;
|
||||
optimizer->stems = optimizer->horz_stems;
|
||||
optimizer->num_springs = optimizer->num_hsprings;
|
||||
optimizer->springs = optimizer->horz_springs;
|
||||
|
||||
if ( optimizer->num_springs > 0 )
|
||||
{
|
||||
LOG(( "horizontal optimization ------------------------\n" ));
|
||||
optim_compute( optimizer );
|
||||
}
|
||||
|
||||
optimizer->num_stems = optimizer->num_vstems;
|
||||
optimizer->stems = optimizer->vert_stems;
|
||||
optimizer->num_springs = optimizer->num_vsprings;
|
||||
optimizer->springs = optimizer->vert_springs;
|
||||
|
||||
if ( optimizer->num_springs )
|
||||
{
|
||||
LOG(( "vertical optimization --------------------------\n" ));
|
||||
optim_compute( optimizer );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
136
src/freetype/autohint/ahoptim.h
Normal file
136
src/freetype/autohint/ahoptim.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahoptim.h */
|
||||
/* */
|
||||
/* FreeType auto hinting outline optimization (declaration). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHOPTIM_H
|
||||
#define AHOPTIM_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahtypes.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahtypes.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* the maximal number of stem configurations to record */
|
||||
/* during optimization */
|
||||
#define AH_MAX_CONFIGS 8
|
||||
|
||||
|
||||
typedef struct AH_Stem_
|
||||
{
|
||||
FT_Pos pos; /* current position */
|
||||
FT_Pos velocity; /* current velocity */
|
||||
FT_Pos force; /* sum of current forces */
|
||||
FT_Pos width; /* normalized width */
|
||||
|
||||
FT_Pos min_pos; /* minimum grid position */
|
||||
FT_Pos max_pos; /* maximum grid position */
|
||||
|
||||
AH_Edge* edge1; /* left/bottom edge */
|
||||
AH_Edge* edge2; /* right/top edge */
|
||||
|
||||
FT_Pos opos; /* original position */
|
||||
FT_Pos owidth; /* original width */
|
||||
|
||||
FT_Pos min_coord; /* minimum coordinate */
|
||||
FT_Pos max_coord; /* maximum coordinate */
|
||||
|
||||
} AH_Stem;
|
||||
|
||||
|
||||
/* A spring between two stems */
|
||||
typedef struct AH_Spring_
|
||||
{
|
||||
AH_Stem* stem1;
|
||||
AH_Stem* stem2;
|
||||
FT_Pos owidth; /* original width */
|
||||
FT_Pos tension; /* current tension */
|
||||
|
||||
} AH_Spring;
|
||||
|
||||
|
||||
/* A configuration records the position of each stem at a given time */
|
||||
/* as well as the associated distortion */
|
||||
typedef struct AH_Configuration_
|
||||
{
|
||||
FT_Pos* positions;
|
||||
FT_Long distortion;
|
||||
|
||||
} AH_Configuration;
|
||||
|
||||
|
||||
typedef struct AH_Optimizer_
|
||||
{
|
||||
FT_Memory memory;
|
||||
AH_Outline* outline;
|
||||
|
||||
FT_Int num_hstems;
|
||||
AH_Stem* horz_stems;
|
||||
|
||||
FT_Int num_vstems;
|
||||
AH_Stem* vert_stems;
|
||||
|
||||
FT_Int num_hsprings;
|
||||
FT_Int num_vsprings;
|
||||
AH_Spring* horz_springs;
|
||||
AH_Spring* vert_springs;
|
||||
|
||||
FT_Int num_configs;
|
||||
AH_Configuration configs[AH_MAX_CONFIGS];
|
||||
FT_Pos* positions;
|
||||
|
||||
/* during each pass, use these instead */
|
||||
FT_Int num_stems;
|
||||
AH_Stem* stems;
|
||||
|
||||
FT_Int num_springs;
|
||||
AH_Spring* springs;
|
||||
FT_Bool vertical;
|
||||
|
||||
FT_Fixed tension_scale;
|
||||
FT_Pos tension_threshold;
|
||||
|
||||
} AH_Optimizer;
|
||||
|
||||
|
||||
/* loads the outline into the optimizer */
|
||||
int AH_Optimizer_Init( AH_Optimizer* optimizer,
|
||||
AH_Outline* outline,
|
||||
FT_Memory memory );
|
||||
|
||||
|
||||
/* compute optimal outline */
|
||||
void AH_Optimizer_Compute( AH_Optimizer* optimizer );
|
||||
|
||||
|
||||
/* release the optimization data */
|
||||
void AH_Optimizer_Done( AH_Optimizer* optimizer );
|
||||
|
||||
|
||||
#endif /* AHOPTIM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
492
src/freetype/autohint/ahtypes.h
Normal file
492
src/freetype/autohint/ahtypes.h
Normal file
@@ -0,0 +1,492 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ahtypes.h */
|
||||
/* */
|
||||
/* General types and definitions for the auto-hint module */
|
||||
/* (specification only). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AHTYPES_H
|
||||
#define AHTYPES_H
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h> /* for freetype.h + LOCAL_DEF etc. */
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahloader.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahloader.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define xxAH_DEBUG
|
||||
|
||||
|
||||
#ifdef AH_DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define AH_LOG( x ) printf##x
|
||||
|
||||
#else
|
||||
|
||||
#define AH_LOG( x ) do ; while ( 0 ) /* nothing */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** COMPILE-TIME BUILD OPTIONS ****/
|
||||
/**** ****/
|
||||
/**** Toggle these configuration macros to experiment with `features' ****/
|
||||
/**** of the auto-hinter. ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* If this option is defined, only strong interpolation will be used to */
|
||||
/* place the points between edges. Otherwise, `smooth' points are */
|
||||
/* detected and later hinted through weak interpolation to correct some */
|
||||
/* unpleasant artefacts. */
|
||||
/* */
|
||||
#undef AH_OPTION_NO_WEAK_INTERPOLATION
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* If this option is defined, only weak interpolation will be used to */
|
||||
/* place the points between edges. Otherwise, `strong' points are */
|
||||
/* detected and later hinted through strong interpolation to correct */
|
||||
/* some unpleasant artefacts. */
|
||||
/* */
|
||||
#undef AH_OPTION_NO_STRONG_INTERPOLATION
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Undefine this macro if you don't want to hint the metrics. There is */
|
||||
/* no reason to do this (at least for non-CJK scripts), except for */
|
||||
/* experimentation. */
|
||||
/* */
|
||||
#define AH_HINT_METRICS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define this macro if you do not want to insert extra edges at a */
|
||||
/* glyph's x and y extremum (if there isn't one already available). */
|
||||
/* This helps to reduce a number of artefacts and allows hinting of */
|
||||
/* metrics. */
|
||||
/* */
|
||||
#undef AH_OPTION_NO_EXTREMUM_EDGES
|
||||
|
||||
|
||||
/* don't touch for now */
|
||||
#define AH_MAX_WIDTHS 12
|
||||
#define AH_MAX_HEIGHTS 12
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** TYPE DEFINITIONS ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* see agangles.h */
|
||||
typedef FT_Int AH_Angle;
|
||||
|
||||
|
||||
/* hint flags */
|
||||
#define ah_flah_none 0
|
||||
|
||||
/* bezier control points flags */
|
||||
#define ah_flah_conic 1
|
||||
#define ah_flah_cubic 2
|
||||
#define ah_flah_control ( ah_flah_conic | ah_flah_cubic )
|
||||
|
||||
/* extrema flags */
|
||||
#define ah_flah_extrema_x 4
|
||||
#define ah_flah_extrema_y 8
|
||||
|
||||
/* roundness */
|
||||
#define ah_flah_round_x 16
|
||||
#define ah_flah_round_y 32
|
||||
|
||||
/* touched */
|
||||
#define ah_flah_touch_x 64
|
||||
#define ah_flah_touch_y 128
|
||||
|
||||
/* weak interpolation */
|
||||
#define ah_flah_weak_interpolation 256
|
||||
|
||||
typedef FT_Int AH_Flags;
|
||||
|
||||
|
||||
/* edge hint flags */
|
||||
#define ah_edge_normal 0
|
||||
#define ah_edge_round 1
|
||||
#define ah_edge_serif 2
|
||||
#define ah_edge_done 4
|
||||
|
||||
typedef FT_Int AH_Edge_Flags;
|
||||
|
||||
|
||||
/* hint directions -- the values are computed so that two vectors are */
|
||||
/* in opposite directions iff `dir1+dir2 == 0' */
|
||||
#define ah_dir_none 4
|
||||
#define ah_dir_right 1
|
||||
#define ah_dir_left -1
|
||||
#define ah_dir_up 2
|
||||
#define ah_dir_down -2
|
||||
|
||||
typedef FT_Int AH_Direction;
|
||||
|
||||
|
||||
typedef struct AH_Point AH_Point;
|
||||
typedef struct AH_Segment AH_Segment;
|
||||
typedef struct AH_Edge AH_Edge;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Point */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model an outline point to the AH_Outline type. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* flags :: The current point hint flags. */
|
||||
/* */
|
||||
/* ox, oy :: The current original scaled coordinates. */
|
||||
/* */
|
||||
/* fx, fy :: The current coordinates in font units. */
|
||||
/* */
|
||||
/* x, y :: The current hinter coordinates. */
|
||||
/* */
|
||||
/* u, v :: Point coordinates -- meaning varies with context. */
|
||||
/* */
|
||||
/* in_dir :: The direction of the inwards vector (prev->point). */
|
||||
/* */
|
||||
/* out_dir :: The direction of the outwards vector (point->next). */
|
||||
/* */
|
||||
/* in_angle :: The angle of the inwards vector. */
|
||||
/* */
|
||||
/* out_angle :: The angle of the outwards vector. */
|
||||
/* */
|
||||
/* next :: The next point in same contour. */
|
||||
/* */
|
||||
/* prev :: The previous point in same contour. */
|
||||
/* */
|
||||
struct AH_Point
|
||||
{
|
||||
AH_Flags flags; /* point flags used by hinter */
|
||||
FT_Pos ox, oy;
|
||||
FT_Pos fx, fy;
|
||||
FT_Pos x, y;
|
||||
FT_Pos u, v;
|
||||
|
||||
AH_Direction in_dir; /* direction of inwards vector */
|
||||
AH_Direction out_dir; /* direction of outwards vector */
|
||||
|
||||
AH_Angle in_angle;
|
||||
AH_Angle out_angle;
|
||||
|
||||
AH_Point* next; /* next point in contour */
|
||||
AH_Point* prev; /* previous point in contour */
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Segment */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe an edge segment to the auto-hinter. */
|
||||
/* A segment is simply a sequence of successive points located on the */
|
||||
/* same horizontal or vertical `position', in a given direction. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* flags :: The segment edge flags (straight, rounded, etc.). */
|
||||
/* */
|
||||
/* dir :: The segment direction. */
|
||||
/* */
|
||||
/* first :: The first point in the segment. */
|
||||
/* */
|
||||
/* last :: The last point in the segment. */
|
||||
/* */
|
||||
/* contour :: A pointer to the first point of the segment's */
|
||||
/* contour. */
|
||||
/* */
|
||||
/* pos :: The segment position in font units. */
|
||||
/* */
|
||||
/* size :: The segment size. */
|
||||
/* */
|
||||
/* edge :: The edge of the current segment. */
|
||||
/* */
|
||||
/* edge_next :: The next segment on the same edge. */
|
||||
/* */
|
||||
/* link :: The pairing segment for this edge. */
|
||||
/* */
|
||||
/* serif :: The primary segment for serifs. */
|
||||
/* */
|
||||
/* num_linked :: The number of other segments that link to this one. */
|
||||
/* */
|
||||
/* score :: Used to score the segment when selecting them. */
|
||||
/* */
|
||||
struct AH_Segment
|
||||
{
|
||||
AH_Edge_Flags flags;
|
||||
AH_Direction dir;
|
||||
|
||||
AH_Point* first; /* first point in edge segment */
|
||||
AH_Point* last; /* last point in edge segment */
|
||||
AH_Point** contour; /* ptr to first point of segment's contour */
|
||||
|
||||
FT_Pos pos; /* position of segment */
|
||||
FT_Pos min_coord; /* minimum coordinate of segment */
|
||||
FT_Pos max_coord; /* maximum coordinate of segment */
|
||||
|
||||
AH_Edge* edge;
|
||||
AH_Segment* edge_next;
|
||||
|
||||
AH_Segment* link; /* link segment */
|
||||
AH_Segment* serif; /* primary segment for serifs */
|
||||
FT_Pos num_linked; /* number of linked segments */
|
||||
FT_Int score;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Edge */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe an edge, which really is a horizontal */
|
||||
/* or vertical coordinate to be hinted depending on the segments */
|
||||
/* located on it. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* flags :: The segment edge flags (straight, rounded, etc.). */
|
||||
/* */
|
||||
/* dir :: The main segment direction on this edge. */
|
||||
/* */
|
||||
/* first :: The first edge segment. */
|
||||
/* */
|
||||
/* last :: The last edge segment. */
|
||||
/* */
|
||||
/* fpos :: The original edge position in font units. */
|
||||
/* */
|
||||
/* opos :: The original scaled edge position. */
|
||||
/* */
|
||||
/* pos :: The hinted edge position. */
|
||||
/* */
|
||||
/* link :: The linked edge. */
|
||||
/* */
|
||||
/* serif :: The serif edge. */
|
||||
/* */
|
||||
/* num_paired :: The number of other edges that pair to this one. */
|
||||
/* */
|
||||
/* score :: Used to score the edge when selecting them. */
|
||||
/* */
|
||||
/* blue_edge :: Indicate the blue zone edge this edge is related to. */
|
||||
/* Only set for some of the horizontal edges in a Latin */
|
||||
/* font. */
|
||||
/* */
|
||||
struct AH_Edge
|
||||
{
|
||||
AH_Edge_Flags flags;
|
||||
AH_Direction dir;
|
||||
|
||||
AH_Segment* first;
|
||||
AH_Segment* last;
|
||||
|
||||
FT_Pos fpos;
|
||||
FT_Pos opos;
|
||||
FT_Pos pos;
|
||||
|
||||
AH_Edge* link;
|
||||
AH_Edge* serif;
|
||||
FT_Int num_linked;
|
||||
|
||||
FT_Int score;
|
||||
FT_Pos* blue_edge;
|
||||
};
|
||||
|
||||
|
||||
/* an outline as seen by the hinter */
|
||||
typedef struct AH_Outline_
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
AH_Direction vert_major_dir; /* vertical major direction */
|
||||
AH_Direction horz_major_dir; /* horizontal major direction */
|
||||
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
FT_Pos edge_distance_threshold;
|
||||
|
||||
FT_Int max_points;
|
||||
FT_Int num_points;
|
||||
AH_Point* points;
|
||||
|
||||
FT_Int max_contours;
|
||||
FT_Int num_contours;
|
||||
AH_Point** contours;
|
||||
|
||||
FT_Int num_hedges;
|
||||
AH_Edge* horz_edges;
|
||||
|
||||
FT_Int num_vedges;
|
||||
AH_Edge* vert_edges;
|
||||
|
||||
FT_Int num_hsegments;
|
||||
AH_Segment* horz_segments;
|
||||
|
||||
FT_Int num_vsegments;
|
||||
AH_Segment* vert_segments;
|
||||
|
||||
} AH_Outline;
|
||||
|
||||
|
||||
#define ah_blue_capital_top 0 /* THEZOCQS */
|
||||
#define ah_blue_capital_bottom ( ah_blue_capital_top + 1 ) /* HEZLOCUS */
|
||||
#define ah_blue_small_top ( ah_blue_capital_bottom + 1 ) /* xzroesc */
|
||||
#define ah_blue_small_bottom ( ah_blue_small_top + 1 ) /* xzroesc */
|
||||
#define ah_blue_small_minor ( ah_blue_small_bottom + 1 ) /* pqgjy */
|
||||
#define ah_blue_max ( ah_blue_small_minor + 1 )
|
||||
|
||||
typedef FT_Int AH_Blue;
|
||||
|
||||
|
||||
#define ah_hinter_monochrome 1
|
||||
#define ah_hinter_optimize 2
|
||||
|
||||
typedef FT_Int AH_Hinter_Flags;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Globals */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Holds the global metrics for a given font face (be it in design */
|
||||
/* units or scaled pixel values). */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_widths :: The number of widths. */
|
||||
/* */
|
||||
/* num_heights :: The number of heights. */
|
||||
/* */
|
||||
/* widths :: Snap widths, including standard one. */
|
||||
/* */
|
||||
/* heights :: Snap height, including standard one. */
|
||||
/* */
|
||||
/* blue_refs :: The reference positions of blue zones. */
|
||||
/* */
|
||||
/* blue_shoots :: The overshoot positions of blue zones. */
|
||||
/* */
|
||||
typedef struct AH_Globals_
|
||||
{
|
||||
FT_Int num_widths;
|
||||
FT_Int num_heights;
|
||||
|
||||
FT_Pos widths [AH_MAX_WIDTHS];
|
||||
FT_Pos heights[AH_MAX_HEIGHTS];
|
||||
|
||||
FT_Pos blue_refs [ah_blue_max];
|
||||
FT_Pos blue_shoots[ah_blue_max];
|
||||
|
||||
} AH_Globals;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* AH_Face_Globals */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Holds the complete global metrics for a given font face (i.e., the */
|
||||
/* design units version + a scaled version + the current scales */
|
||||
/* used). */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* face :: A handle to the source face object */
|
||||
/* */
|
||||
/* design :: The globals in font design units. */
|
||||
/* */
|
||||
/* scaled :: Scaled globals in sub-pixel values. */
|
||||
/* */
|
||||
/* x_scale :: The current horizontal scale. */
|
||||
/* */
|
||||
/* y_scale :: The current vertical scale. */
|
||||
/* */
|
||||
typedef struct AH_Face_Globals_
|
||||
{
|
||||
FT_Face face;
|
||||
AH_Globals design;
|
||||
AH_Globals scaled;
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
FT_Bool control_overshoot;
|
||||
|
||||
} AH_Face_Globals;
|
||||
|
||||
|
||||
typedef struct AH_Hinter
|
||||
{
|
||||
FT_Memory memory;
|
||||
AH_Hinter_Flags flags;
|
||||
|
||||
FT_Int algorithm;
|
||||
FT_Face face;
|
||||
|
||||
AH_Face_Globals* globals;
|
||||
|
||||
AH_Outline* glyph;
|
||||
|
||||
AH_Loader* loader;
|
||||
FT_Vector pp1;
|
||||
FT_Vector pp2;
|
||||
|
||||
} AH_Hinter;
|
||||
|
||||
|
||||
#endif /* AHTYPES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
43
src/freetype/autohint/autohint.c
Normal file
43
src/freetype/autohint/autohint.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* autohint.c */
|
||||
/* */
|
||||
/* Automatic Hinting wrapper (body only). */
|
||||
/* */
|
||||
/* Copyright 2000 Catharon Productions Inc. */
|
||||
/* Author: David Turner */
|
||||
/* */
|
||||
/* This file is part of the Catharon Typography Project and shall only */
|
||||
/* be used, modified, and distributed under the terms of the Catharon */
|
||||
/* Open Source License that should come with this file under the name */
|
||||
/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/* Note that this license is compatible with the FreeType license. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ahangles.c"
|
||||
#include "ahglyph.c"
|
||||
#include "ahglobal.c"
|
||||
#include "ahhint.c"
|
||||
#include "ahmodule.c"
|
||||
|
||||
#else
|
||||
|
||||
#include <autohint/ahangles.c>
|
||||
#include <autohint/ahglyph.c>
|
||||
#include <autohint/ahglobal.c>
|
||||
#include <autohint/ahhint.c>
|
||||
#include <autohint/ahmodule.c>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* END */
|
||||
78
src/freetype/autohint/mather.py
Normal file
78
src/freetype/autohint/mather.py
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
|
||||
#
|
||||
# autohint math table builder
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 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.
|
||||
|
||||
|
||||
import math
|
||||
|
||||
ag_pi = 256
|
||||
|
||||
def print_arctan( atan_bits ):
|
||||
atan_base = 1 << atan_bits
|
||||
|
||||
print " static AH_Angle ag_arctan[1L << AG_ATAN_BITS] ="
|
||||
print " {"
|
||||
|
||||
count = 0
|
||||
line = " "
|
||||
|
||||
for n in range( atan_base ):
|
||||
comma = ","
|
||||
if ( n == atan_base - 1 ):
|
||||
comma = ""
|
||||
|
||||
angle = math.atan( n * 1.0 / atan_base ) / math.pi * ag_pi
|
||||
line = line + " " + repr( int( angle + 0.5 ) ) + comma
|
||||
count = count + 1;
|
||||
if ( count == 8 ):
|
||||
count = 0
|
||||
print line
|
||||
line = " "
|
||||
|
||||
if ( count > 0 ):
|
||||
print line
|
||||
print " };"
|
||||
|
||||
|
||||
# This routine is not used currently.
|
||||
#
|
||||
def print_sines():
|
||||
print " static FT_Fixed ah_sines[AG_HALF_PI + 1] ="
|
||||
print " {"
|
||||
|
||||
count = 0
|
||||
line = " "
|
||||
|
||||
for n in range( ag_pi / 2 ):
|
||||
sinus = math.sin( n * math.pi / ag_pi )
|
||||
line = line + " " + repr( int( 65536.0 * sinus ) ) + ","
|
||||
count = count + 1
|
||||
if ( count == 8 ):
|
||||
count = 0
|
||||
print line
|
||||
line = " "
|
||||
|
||||
if ( count > 0 ):
|
||||
print line
|
||||
print " 65536"
|
||||
print " };"
|
||||
|
||||
|
||||
print_arctan( 8 )
|
||||
print
|
||||
|
||||
|
||||
# END
|
||||
7
src/freetype/autohint/module.mk
Normal file
7
src/freetype/autohint/module.mk
Normal file
@@ -0,0 +1,7 @@
|
||||
make_module_list: add_autohint_module
|
||||
|
||||
add_autohint_module:
|
||||
$(OPEN_DRIVER)autohint_module_class$(CLOSE_DRIVER)
|
||||
$(ECHO_DRIVER)autohint $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE)
|
||||
|
||||
# EOF
|
||||
77
src/freetype/autohint/rules.mk
Normal file
77
src/freetype/autohint/rules.mk
Normal file
@@ -0,0 +1,77 @@
|
||||
#
|
||||
# FreeType 2 auto-hinter module configuration rules
|
||||
#
|
||||
|
||||
|
||||
# Copyright 2000 Catharon Productions Inc.
|
||||
# Author: David Turner
|
||||
#
|
||||
# This file is part of the Catharon Typography Project and shall only
|
||||
# be used, modified, and distributed under the terms of the Catharon
|
||||
# Open Source License that should come with this file under the name
|
||||
# `CatharonLicense.txt'. By continuing to use, modify, or distribute
|
||||
# this file you indicate that you have read the license and
|
||||
# understand and accept it fully.
|
||||
#
|
||||
# Note that this license is compatible with the FreeType license.
|
||||
|
||||
|
||||
# AUTO driver directory
|
||||
#
|
||||
AUTO_DIR := $(SRC_)autohint
|
||||
AUTO_DIR_ := $(AUTO_DIR)$(SEP)
|
||||
|
||||
|
||||
# compilation flags for the driver
|
||||
#
|
||||
AUTO_COMPILE := $(FT_COMPILE)
|
||||
|
||||
|
||||
# AUTO driver sources (i.e., C files)
|
||||
#
|
||||
AUTO_DRV_SRC := $(AUTO_DIR_)ahangles.c \
|
||||
$(AUTO_DIR_)ahglobal.c \
|
||||
$(AUTO_DIR_)ahglyph.c \
|
||||
$(AUTO_DIR_)ahhint.c \
|
||||
$(AUTO_DIR_)ahmodule.c
|
||||
|
||||
# AUTO driver headers
|
||||
#
|
||||
AUTO_DRV_H := $(AUTO_DRV_SRC:%c=%h) \
|
||||
$(AUTO_DIR_)ahloader.h \
|
||||
$(AUTO_DIR_)ahtypes.h
|
||||
|
||||
|
||||
# AUTO driver object(s)
|
||||
#
|
||||
# AUTO_DRV_OBJ_M is used during `multi' builds.
|
||||
# AUTO_DRV_OBJ_S is used during `single' builds.
|
||||
#
|
||||
AUTO_DRV_OBJ_M := $(AUTO_DRV_SRC:$(AUTO_DIR_)%.c=$(OBJ_)%.$O)
|
||||
AUTO_DRV_OBJ_S := $(OBJ_)autohint.$O
|
||||
|
||||
# AUTO driver source file for single build
|
||||
#
|
||||
AUTO_DRV_SRC_S := $(AUTO_DIR_)autohint.c
|
||||
|
||||
|
||||
# AUTO driver - single object
|
||||
#
|
||||
$(AUTO_DRV_OBJ_S): $(AUTO_DRV_SRC_S) $(AUTO_DRV_SRC) \
|
||||
$(FREETYPE_H) $(AUTO_DRV_H)
|
||||
$(AUTO_COMPILE) $T$@ $(AUTO_DRV_SRC_S)
|
||||
|
||||
|
||||
# AUTO driver - multiple objects
|
||||
#
|
||||
$(OBJ_)%.$O: $(AUTO_DIR_)%.c $(FREETYPE_H) $(AUTO_DRV_H)
|
||||
$(AUTO_COMPILE) $T$@ $<
|
||||
|
||||
|
||||
# update main driver object lists
|
||||
#
|
||||
DRV_OBJS_S += $(AUTO_DRV_OBJ_S)
|
||||
DRV_OBJS_M += $(AUTO_DRV_OBJ_M)
|
||||
|
||||
|
||||
# EOF
|
||||
42
src/freetype/base/ftbase.c
Normal file
42
src/freetype/base/ftbase.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftbase.c */
|
||||
/* */
|
||||
/* Single object library component (body only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ftcalc.c"
|
||||
#include "ftobjs.c"
|
||||
#include "ftstream.c"
|
||||
#include "ftlist.c"
|
||||
#include "ftoutln.c"
|
||||
#include "ftextend.c"
|
||||
#include "ftnames.c"
|
||||
|
||||
#else /* FT_FLAT_COMPILE */
|
||||
|
||||
#include <base/ftcalc.c>
|
||||
#include <base/ftobjs.c>
|
||||
#include <base/ftstream.c>
|
||||
#include <base/ftlist.c>
|
||||
#include <base/ftoutln.c>
|
||||
#include <base/ftextend.c>
|
||||
#include <base/ftnames.c>
|
||||
|
||||
#endif /* FT_FLAT_COMPILE */
|
||||
|
||||
|
||||
/* END */
|
||||
773
src/freetype/base/ftcalc.c
Normal file
773
src/freetype/base/ftcalc.c
Normal file
@@ -0,0 +1,773 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftcalc.c */
|
||||
/* */
|
||||
/* Arithmetic computations (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Support for 1-complement arithmetic has been totally dropped in this */
|
||||
/* release. You can still write your own code if you need it. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Implementing basic computation routines. */
|
||||
/* */
|
||||
/* FT_MulDiv(), FT_MulFix(), and FT_DivFix() are declared in freetype.h. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftcalc.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftobjs.h> /* for ABS() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_calc
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_OLD_CALCS
|
||||
|
||||
static const FT_Long ft_square_roots[63] =
|
||||
{
|
||||
1L, 1L, 2L, 3L, 4L, 5L, 8L, 11L,
|
||||
16L, 22L, 32L, 45L, 64L, 90L, 128L, 181L,
|
||||
256L, 362L, 512L, 724L, 1024L, 1448L, 2048L, 2896L,
|
||||
4096L, 5892L, 8192L, 11585L, 16384L, 23170L, 32768L, 46340L,
|
||||
|
||||
65536L, 92681L, 131072L, 185363L, 262144L, 370727L,
|
||||
524288L, 741455L, 1048576L, 1482910L, 2097152L, 2965820L,
|
||||
4194304L, 5931641L, 8388608L, 11863283L, 16777216L, 23726566L,
|
||||
|
||||
33554432L, 47453132L, 67108864L, 94906265L,
|
||||
134217728L, 189812531L, 268435456L, 379625062L,
|
||||
536870912L, 759250125L, 1073741824L, 1518500250L,
|
||||
2147483647L
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Sqrt32 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Computes the square root of an Int32 integer (which will be */
|
||||
/* handled as an unsigned long value). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* x :: The value to compute the root for. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `sqrt(x)'. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Int32 ) FT_Sqrt32( FT_Int32 x )
|
||||
{
|
||||
FT_ULong val, root, newroot, mask;
|
||||
|
||||
|
||||
root = 0;
|
||||
mask = 0x40000000L;
|
||||
val = (FT_ULong)x;
|
||||
|
||||
do
|
||||
{
|
||||
newroot = root + mask;
|
||||
if ( newroot <= val )
|
||||
{
|
||||
val -= newroot;
|
||||
root = newroot + mask;
|
||||
}
|
||||
|
||||
root >>= 1;
|
||||
mask >>= 2;
|
||||
|
||||
} while ( mask != 0 );
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
|
||||
|
||||
|
||||
#ifdef FT_LONG64
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_MulDiv */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very simple function used to perform the computation `(a*b)/c' */
|
||||
/* with maximal accuracy (it uses a 64-bit intermediate integer */
|
||||
/* whenever necessary). */
|
||||
/* */
|
||||
/* This function isn't necessarily as fast as some processor specific */
|
||||
/* operations, but is at least completely portable. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* b :: The second multiplier. */
|
||||
/* c :: The divisor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*b)/c'. This function never traps when trying to */
|
||||
/* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
|
||||
/* on the signs of `a' and `b'. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Long ) FT_MulDiv( FT_Long a,
|
||||
FT_Long b,
|
||||
FT_Long c )
|
||||
{
|
||||
FT_Int s;
|
||||
|
||||
|
||||
s = 1;
|
||||
if ( a < 0 ) { a = -a; s = -s; }
|
||||
if ( b < 0 ) { b = -b; s = -s; }
|
||||
if ( c < 0 ) { c = -c; s = -s; }
|
||||
|
||||
return s * ( c > 0 ? ( (FT_Int64)a * b + ( c >> 1 ) ) / c
|
||||
: 0x7FFFFFFFL );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_MulFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very simple function used to perform the computation */
|
||||
/* `(a*b)/0x10000' with maximal accuracy. Most of the time this is */
|
||||
/* used to multiply a given value by a 16.16 fixed float factor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* b :: The second multiplier. Use a 16.16 factor here whenever */
|
||||
/* possible (see note below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*b)/0x10000'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function has been optimized for the case where the absolute */
|
||||
/* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
|
||||
/* As this happens mainly when scaling from notional units to */
|
||||
/* fractional pixels in FreeType, it resulted in noticeable speed */
|
||||
/* improvements between versions 2.x and 1.x. */
|
||||
/* */
|
||||
/* As a conclusion, always try to place a 16.16 factor as the */
|
||||
/* _second_ argument of this function; this can make a great */
|
||||
/* difference. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Long ) FT_MulFix( FT_Long a,
|
||||
FT_Long b )
|
||||
{
|
||||
FT_Int s;
|
||||
|
||||
|
||||
s = 1;
|
||||
if ( a < 0 ) { a = -a; s = -s; }
|
||||
if ( b < 0 ) { b = -b; s = -s; }
|
||||
|
||||
return s * (FT_Long)( ( (FT_Int64)a * b + 0x8000 ) >> 16 );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_DivFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very simple function used to perform the computation */
|
||||
/* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */
|
||||
/* used to divide a given value by a 16.16 fixed float factor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* b :: The second multiplier. Use a 16.16 factor here whenever */
|
||||
/* possible (see note below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*0x10000)/b'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The optimization for FT_DivFix() is simple: If (a << 16) fits in */
|
||||
/* 32 bits, then the division is computed directly. Otherwise, we */
|
||||
/* use a specialized version of the old FT_MulDiv64(). */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Long ) FT_DivFix( FT_Long a,
|
||||
FT_Long b )
|
||||
{
|
||||
FT_Int32 s;
|
||||
FT_UInt32 q;
|
||||
|
||||
|
||||
s = a; a = ABS(a);
|
||||
s ^= b; b = ABS(b);
|
||||
|
||||
if ( b == 0 )
|
||||
/* check for division by 0 */
|
||||
q = 0x7FFFFFFFL;
|
||||
else
|
||||
/* compute result directly */
|
||||
q = ( (FT_Int64)a << 16 ) / b;
|
||||
|
||||
return (FT_Int32)( s < 0 ? -q : q );
|
||||
}
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_OLD_CALCS
|
||||
|
||||
/* a helper function for FT_Sqrt64() */
|
||||
|
||||
static
|
||||
int ft_order64( FT_Int64 z )
|
||||
{
|
||||
int j = 0;
|
||||
|
||||
|
||||
while ( z )
|
||||
{
|
||||
z = (unsigned FT_INT64)z >> 1;
|
||||
j++;
|
||||
}
|
||||
return j - 1;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Sqrt64 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Computes the square root of a 64-bit value. That sounds stupid, */
|
||||
/* but it is needed to obtain maximal accuracy in the TrueType */
|
||||
/* bytecode interpreter. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* l :: A 64-bit integer. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The 32-bit square-root. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Int32 ) FT_Sqrt64( FT_Int64 l )
|
||||
{
|
||||
FT_Int64 r, s;
|
||||
|
||||
|
||||
if ( l <= 0 ) return 0;
|
||||
if ( l == 1 ) return 1;
|
||||
|
||||
r = ft_square_roots[ft_order64( l )];
|
||||
|
||||
do
|
||||
{
|
||||
s = r;
|
||||
r = ( r + l / r ) >> 1;
|
||||
|
||||
} while ( r > s || r * r > l );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
|
||||
|
||||
|
||||
#else /* FT_LONG64 */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_MulDiv */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very simple function used to perform the computation `(a*b)/c' */
|
||||
/* with maximal accuracy (it uses a 64-bit intermediate integer */
|
||||
/* whenever necessary). */
|
||||
/* */
|
||||
/* This function isn't necessarily as fast as some processor specific */
|
||||
/* operations, but is at least completely portable. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* b :: The second multiplier. */
|
||||
/* c :: The divisor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*b)/c'. This function never traps when trying to */
|
||||
/* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
|
||||
/* on the signs of `a' and `b'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The FT_MulDiv() function has been optimized thanks to ideas from */
|
||||
/* Graham Asher. The trick is to optimize computation if everything */
|
||||
/* fits within 32 bits (a rather common case). */
|
||||
/* */
|
||||
/* We compute `a*b+c/2', then divide it by `c' (positive values). */
|
||||
/* */
|
||||
/* 46340 is FLOOR(SQRT(2^31-1)). */
|
||||
/* */
|
||||
/* if ( a <= 46340 && b <= 46340 ) then ( a*b <= 0x7FFEA810 ) */
|
||||
/* */
|
||||
/* 0x7FFFFFFF - 0x7FFEA810 = 0x157F0 */
|
||||
/* */
|
||||
/* if ( c < 0x157F0*2 ) then ( a*b+c/2 <= 0x7FFFFFFF ) */
|
||||
/* */
|
||||
/* and 2*0x157F0 = 176096. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Long ) FT_MulDiv( FT_Long a,
|
||||
FT_Long b,
|
||||
FT_Long c )
|
||||
{
|
||||
long s;
|
||||
|
||||
|
||||
if ( a == 0 || b == c )
|
||||
return a;
|
||||
|
||||
s = a; a = ABS( a );
|
||||
s ^= b; b = ABS( b );
|
||||
s ^= c; c = ABS( c );
|
||||
|
||||
if ( a <= 46340 && b <= 46340 && c <= 176095L && c > 0 )
|
||||
{
|
||||
a = ( a * b + ( c >> 1 ) ) / c;
|
||||
}
|
||||
else if ( c > 0 )
|
||||
{
|
||||
FT_Int64 temp, temp2;
|
||||
|
||||
|
||||
FT_MulTo64( a, b, &temp );
|
||||
temp2.hi = (FT_Int32)( c >> 31 );
|
||||
temp2.lo = (FT_UInt32)( c / 2 );
|
||||
FT_Add64( &temp, &temp2, &temp );
|
||||
a = FT_Div64by32( &temp, c );
|
||||
}
|
||||
else
|
||||
a = 0x7FFFFFFFL;
|
||||
|
||||
return ( s < 0 ? -a : a );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_MulFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very simple function used to perform the computation */
|
||||
/* `(a*b)/0x10000' with maximal accuracy. Most of the time, this is */
|
||||
/* used to multiply a given value by a 16.16 fixed float factor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* b :: The second multiplier. Use a 16.16 factor here whenever */
|
||||
/* possible (see note below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*b)/0x10000'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The optimization for FT_MulFix() is different. We could simply be */
|
||||
/* happy by applying the same principles as with FT_MulDiv(), because */
|
||||
/* */
|
||||
/* c = 0x10000 < 176096 */
|
||||
/* */
|
||||
/* However, in most cases, we have a `b' with a value around 0x10000 */
|
||||
/* which is greater than 46340. */
|
||||
/* */
|
||||
/* According to some testing, most cases have `a' < 2048, so a good */
|
||||
/* idea is to use bounds like 2048 and 1048576 (=floor((2^31-1)/2048) */
|
||||
/* for `a' and `b', respectively. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Long ) FT_MulFix( FT_Long a,
|
||||
FT_Long b )
|
||||
{
|
||||
FT_Long s;
|
||||
FT_ULong ua, ub;
|
||||
|
||||
|
||||
if ( a == 0 || b == 0x10000L )
|
||||
return a;
|
||||
|
||||
s = a; a = ABS(a);
|
||||
s ^= b; b = ABS(b);
|
||||
|
||||
ua = (FT_ULong)a;
|
||||
ub = (FT_ULong)b;
|
||||
|
||||
if ( ua <= 2048 && ub <= 1048576L )
|
||||
{
|
||||
ua = ( ua * ub + 0x8000 ) >> 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
FT_ULong al = ua & 0xFFFF;
|
||||
|
||||
|
||||
ua = ( ua >> 16 ) * ub +
|
||||
al * ( ub >> 16 ) +
|
||||
( al * ( ub & 0xFFFF ) >> 16 );
|
||||
}
|
||||
|
||||
return ( s < 0 ? -(FT_Long)ua : ua );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_DivFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very simple function used to perform the computation */
|
||||
/* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */
|
||||
/* used to divide a given value by a 16.16 fixed float factor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* b :: The second multiplier. Use a 16.16 factor here whenever */
|
||||
/* possible (see note below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*0x10000)/b'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The optimization for FT_DivFix() is simple: If (a << 16) fits into */
|
||||
/* 32 bits, then the division is computed directly. Otherwise, we */
|
||||
/* use a specialized version of the old FT_MulDiv64(). */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Long ) FT_DivFix( FT_Long a,
|
||||
FT_Long b )
|
||||
{
|
||||
FT_Int32 s;
|
||||
FT_UInt32 q;
|
||||
|
||||
|
||||
s = a; a = ABS(a);
|
||||
s ^= b; b = ABS(b);
|
||||
|
||||
if ( b == 0 )
|
||||
{
|
||||
/* check for division by 0 */
|
||||
q = 0x7FFFFFFFL;
|
||||
}
|
||||
else if ( ( a >> 16 ) == 0 )
|
||||
{
|
||||
/* compute result directly */
|
||||
q = (FT_UInt32)( a << 16 ) / (FT_UInt32)b;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we need more bits; we have to do it by hand */
|
||||
FT_UInt32 c;
|
||||
|
||||
|
||||
q = ( a / b ) << 16;
|
||||
c = a % b;
|
||||
|
||||
/* we must compute C*0x10000/B: we simply shift C and B so */
|
||||
/* C becomes smaller than 16 bits */
|
||||
while ( c >> 16 )
|
||||
{
|
||||
c >>= 1;
|
||||
b <<= 1;
|
||||
}
|
||||
|
||||
q += ( c << 16 ) / b;
|
||||
}
|
||||
|
||||
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Add64 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Add two Int64 values. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* x :: A pointer to the first value to be added. */
|
||||
/* y :: A pointer to the second value to be added. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* z :: A pointer to the result of `x + y'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Will be wrapped by the ADD_64() macro. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Add64( FT_Int64* x,
|
||||
FT_Int64* y,
|
||||
FT_Int64* z )
|
||||
{
|
||||
register FT_UInt32 lo, hi;
|
||||
|
||||
|
||||
lo = x->lo + y->lo;
|
||||
hi = x->hi + y->hi + ( lo < x->lo );
|
||||
|
||||
z->lo = lo;
|
||||
z->hi = hi;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_MulTo64 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Multiplies two Int32 integers. Returns an Int64 integer. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* x :: The first multiplier. */
|
||||
/* y :: The second multiplier. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* z :: A pointer to the result of `x * y'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Will be wrapped by the MUL_64() macro. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_MulTo64( FT_Int32 x,
|
||||
FT_Int32 y,
|
||||
FT_Int64* z )
|
||||
{
|
||||
FT_Int32 s;
|
||||
|
||||
|
||||
s = x; x = ABS( x );
|
||||
s ^= y; y = ABS( y );
|
||||
|
||||
{
|
||||
FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
|
||||
|
||||
|
||||
lo1 = x & 0x0000FFFF; hi1 = x >> 16;
|
||||
lo2 = y & 0x0000FFFF; hi2 = y >> 16;
|
||||
|
||||
lo = lo1 * lo2;
|
||||
i1 = lo1 * hi2;
|
||||
i2 = lo2 * hi1;
|
||||
hi = hi1 * hi2;
|
||||
|
||||
/* Check carry overflow of i1 + i2 */
|
||||
i1 += i2;
|
||||
if ( i1 < i2 )
|
||||
hi += 1L << 16;
|
||||
|
||||
hi += i1 >> 16;
|
||||
i1 = i1 << 16;
|
||||
|
||||
/* Check carry overflow of i1 + lo */
|
||||
lo += i1;
|
||||
hi += ( lo < i1 );
|
||||
|
||||
z->lo = lo;
|
||||
z->hi = hi;
|
||||
}
|
||||
|
||||
if ( s < 0 )
|
||||
{
|
||||
z->lo = (FT_UInt32)-(FT_Int32)z->lo;
|
||||
z->hi = ~z->hi + !( z->lo );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Div64by32 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Divides an Int64 value by an Int32 value. Returns an Int32 */
|
||||
/* integer. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* x :: A pointer to the dividend. */
|
||||
/* y :: The divisor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `x / y'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Will be wrapped by the DIV_64() macro. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Int32 ) FT_Div64by32( FT_Int64* x,
|
||||
FT_Int32 y )
|
||||
{
|
||||
FT_Int32 s;
|
||||
FT_UInt32 q, r, i, lo;
|
||||
|
||||
|
||||
s = x->hi;
|
||||
if ( s < 0 )
|
||||
{
|
||||
x->lo = (FT_UInt32)-(FT_Int32)x->lo;
|
||||
x->hi = ~x->hi + !( x->lo );
|
||||
}
|
||||
s ^= y; y = ABS( y );
|
||||
|
||||
/* Shortcut */
|
||||
if ( x->hi == 0 )
|
||||
{
|
||||
if ( y > 0 )
|
||||
q = x->lo / y;
|
||||
else
|
||||
q = 0x7FFFFFFFL;
|
||||
|
||||
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
||||
}
|
||||
|
||||
r = x->hi;
|
||||
lo = x->lo;
|
||||
|
||||
if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here */
|
||||
return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
|
||||
/* Return Max/Min Int32 if division overflow. */
|
||||
/* This includes division by zero! */
|
||||
q = 0;
|
||||
for ( i = 0; i < 32; i++ )
|
||||
{
|
||||
r <<= 1;
|
||||
q <<= 1;
|
||||
r |= lo >> 31;
|
||||
|
||||
if ( r >= (FT_UInt32)y )
|
||||
{
|
||||
r -= y;
|
||||
q |= 1;
|
||||
}
|
||||
lo <<= 1;
|
||||
}
|
||||
|
||||
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
||||
}
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_OLD_CALCS
|
||||
|
||||
|
||||
/* two helper functions for FT_Sqrt64() */
|
||||
|
||||
static
|
||||
void FT_Sub64( FT_Int64* x,
|
||||
FT_Int64* y,
|
||||
FT_Int64* z )
|
||||
{
|
||||
register FT_UInt32 lo, hi;
|
||||
|
||||
|
||||
lo = x->lo - y->lo;
|
||||
hi = x->hi - y->hi - ( (FT_Int32)lo < 0 );
|
||||
|
||||
z->lo = lo;
|
||||
z->hi = hi;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int ft_order64( FT_Int64* z )
|
||||
{
|
||||
FT_UInt32 i;
|
||||
int j;
|
||||
|
||||
|
||||
i = z->lo;
|
||||
j = 0;
|
||||
if ( z->hi )
|
||||
{
|
||||
i = z->hi;
|
||||
j = 32;
|
||||
}
|
||||
|
||||
while ( i > 0 )
|
||||
{
|
||||
i >>= 1;
|
||||
j++;
|
||||
}
|
||||
return j - 1;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Sqrt64 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Computes the square root of a 64-bits value. That sounds stupid, */
|
||||
/* but it is needed to obtain maximal accuracy in the TrueType */
|
||||
/* bytecode interpreter. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* z :: A pointer to a 64-bit integer. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The 32-bit square-root. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Int32 ) FT_Sqrt64( FT_Int64* l )
|
||||
{
|
||||
FT_Int64 l2;
|
||||
FT_Int32 r, s;
|
||||
|
||||
|
||||
if ( (FT_Int32)l->hi < 0 ||
|
||||
( l->hi == 0 && l->lo == 0 ) )
|
||||
return 0;
|
||||
|
||||
s = ft_order64( l );
|
||||
if ( s == 0 )
|
||||
return 1;
|
||||
|
||||
r = ft_square_roots[s];
|
||||
do
|
||||
{
|
||||
s = r;
|
||||
r = ( r + FT_Div64by32( l, r ) ) >> 1;
|
||||
FT_MulTo64( r, r, &l2 );
|
||||
FT_Sub64 ( l, &l2, &l2 );
|
||||
|
||||
} while ( r > s || (FT_Int32)l2.hi < 0 );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
|
||||
|
||||
#endif /* FT_LONG64 */
|
||||
|
||||
|
||||
/* END */
|
||||
124
src/freetype/base/ftdebug.c
Normal file
124
src/freetype/base/ftdebug.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftdebug.c */
|
||||
/* */
|
||||
/* Debugging and logging component (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This component contains various macros and functions used to ease the */
|
||||
/* debugging of the FreeType engine. Its main purpose is in assertion */
|
||||
/* checking, tracing, and error detection. */
|
||||
/* */
|
||||
/* There are now three debugging modes: */
|
||||
/* */
|
||||
/* - trace mode */
|
||||
/* */
|
||||
/* Error and trace messages are sent to the log file (which can be the */
|
||||
/* standard error output). */
|
||||
/* */
|
||||
/* - error mode */
|
||||
/* */
|
||||
/* Only error messages are generated. */
|
||||
/* */
|
||||
/* - release mode: */
|
||||
/* */
|
||||
/* No error message is sent or generated. The code is free from any */
|
||||
/* debugging parts. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
char ft_trace_levels[trace_max];
|
||||
#endif
|
||||
|
||||
|
||||
#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
FT_EXPORT_FUNC( void ) FT_Message( const char* fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
vprintf( fmt, ap );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
FT_EXPORT_FUNC( void ) FT_Panic( const char* fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
vprintf( fmt, ap );
|
||||
va_end( ap );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_SetTraceLevel */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Sets the trace level for debugging. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* component :: The component which should be traced. See ftdebug.h */
|
||||
/* for a complete list. If set to `trace_any', all */
|
||||
/* components will be traced. */
|
||||
/* level :: The tracing level. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_SetTraceLevel( FT_Trace component,
|
||||
char level )
|
||||
{
|
||||
if ( component >= trace_max )
|
||||
return;
|
||||
|
||||
/* if component is `trace_any', change _all_ levels at once */
|
||||
if ( component == trace_any )
|
||||
{
|
||||
int n;
|
||||
|
||||
|
||||
for ( n = trace_any; n < trace_max; n++ )
|
||||
ft_trace_levels[n] = level;
|
||||
}
|
||||
else /* otherwise, only change individual component */
|
||||
ft_trace_levels[component] = level;
|
||||
}
|
||||
|
||||
#endif /* FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
|
||||
/* END */
|
||||
332
src/freetype/base/ftextend.c
Normal file
332
src/freetype/base/ftextend.c
Normal file
@@ -0,0 +1,332 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftextend.h */
|
||||
/* */
|
||||
/* FreeType extensions implementation (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This is an updated version of the extension component, now located */
|
||||
/* in the main library's source directory. It allows the dynamic */
|
||||
/* registration/use of various face object extensions through a simple */
|
||||
/* API. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftextend.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_extend
|
||||
|
||||
|
||||
typedef struct FT_Extension_Registry_
|
||||
{
|
||||
FT_Int num_extensions;
|
||||
FT_Long cur_offset;
|
||||
FT_Extension_Class classes[FT_MAX_EXTENSIONS];
|
||||
|
||||
} FT_Extension_Registry;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Init_Extensions */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes the extension component. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* driver :: A handle to the driver object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error FT_Init_Extensions( FT_Driver driver )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Memory memory;
|
||||
FT_Extension_Registry* registry;
|
||||
|
||||
|
||||
memory = driver->root.library->memory;
|
||||
if ( ALLOC( registry, sizeof ( *registry ) ) )
|
||||
return error;
|
||||
|
||||
registry->num_extensions = 0;
|
||||
registry->cur_offset = 0;
|
||||
driver->extensions = registry;
|
||||
|
||||
FT_TRACE2(( "FT_Init_Extensions: success\n" ));
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_Extensions */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes the extension component. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* driver :: A handle to the driver object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error FT_Done_Extensions( FT_Driver driver )
|
||||
{
|
||||
FT_Memory memory = driver->root.memory;
|
||||
|
||||
|
||||
FREE( driver->extensions );
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Register_Extension */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Registers a new extension. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* driver :: A handle to the driver object. */
|
||||
/* class :: A pointer to a class describing the extension. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Register_Extension(
|
||||
FT_Driver driver,
|
||||
FT_Extension_Class* clazz )
|
||||
{
|
||||
FT_Extension_Registry* registry;
|
||||
|
||||
|
||||
if ( !driver )
|
||||
return FT_Err_Invalid_Driver_Handle;
|
||||
|
||||
if ( !clazz )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
registry = (FT_Extension_Registry*)driver->extensions;
|
||||
if ( registry )
|
||||
{
|
||||
FT_Int n = registry->num_extensions;
|
||||
FT_Extension_Class* cur = registry->classes + n;
|
||||
|
||||
|
||||
if ( n >= FT_MAX_EXTENSIONS )
|
||||
return FT_Err_Too_Many_Extensions;
|
||||
|
||||
*cur = *clazz;
|
||||
|
||||
cur->offset = registry->cur_offset;
|
||||
|
||||
registry->num_extensions++;
|
||||
registry->cur_offset +=
|
||||
( cur->size + FT_ALIGNMENT - 1 ) & -FT_ALIGNMENT;
|
||||
|
||||
FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered\n",
|
||||
cur->id ));
|
||||
}
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Extension */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Queries an extension block by an extension ID string. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the face object. */
|
||||
/* extension_id :: An ID string identifying the extension. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* extension_interface :: A generic pointer, usually pointing to a */
|
||||
/* table of functions implementing the */
|
||||
/* extension interface. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A generic pointer to the extension block. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void* ) FT_Get_Extension(
|
||||
FT_Face face,
|
||||
const char* extension_id,
|
||||
void** extension_interface )
|
||||
{
|
||||
FT_Extension_Registry* registry;
|
||||
|
||||
|
||||
if ( !face || !extension_id || !extension_interface )
|
||||
return 0;
|
||||
|
||||
registry = (FT_Extension_Registry*)face->driver->extensions;
|
||||
if ( registry && face->extensions )
|
||||
{
|
||||
FT_Extension_Class* cur = registry->classes;
|
||||
FT_Extension_Class* limit = cur + registry->num_extensions;
|
||||
|
||||
|
||||
for ( ; cur < limit; cur++ )
|
||||
if ( strcmp( cur->id, extension_id ) == 0 )
|
||||
{
|
||||
*extension_interface = cur->interface;
|
||||
|
||||
FT_TRACE1(( "FT_Get_Extension: got `%s'\n", extension_id ));
|
||||
|
||||
return (void*)((char*)face->extensions + cur->offset);
|
||||
}
|
||||
}
|
||||
|
||||
/* could not find the extension id */
|
||||
|
||||
FT_ERROR(( "FT_Get_Extension: couldn't find `%s'\n", extension_id ));
|
||||
|
||||
*extension_interface = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Destroy_Extensions */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroys all extensions within a face object. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Called by the face object destructor. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error FT_Destroy_Extensions( FT_Face face )
|
||||
{
|
||||
FT_Extension_Registry* registry;
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
registry = (FT_Extension_Registry*)face->driver->extensions;
|
||||
if ( registry && face->extensions )
|
||||
{
|
||||
FT_Extension_Class* cur = registry->classes;
|
||||
FT_Extension_Class* limit = cur + registry->num_extensions;
|
||||
|
||||
|
||||
for ( ; cur < limit; cur++ )
|
||||
{
|
||||
char* ext = (char*)face->extensions + cur->offset;
|
||||
|
||||
if ( cur->finalize )
|
||||
cur->finalize( ext, face );
|
||||
}
|
||||
|
||||
memory = face->driver->root.memory;
|
||||
FREE( face->extensions );
|
||||
}
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Create_Extensions */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates an extension object within a face object for all */
|
||||
/* registered extensions. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Called by the face object constructor. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error FT_Create_Extensions( FT_Face face )
|
||||
{
|
||||
FT_Extension_Registry* registry;
|
||||
FT_Memory memory;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
face->extensions = 0;
|
||||
|
||||
/* load extensions registry; exit successfully if none is there */
|
||||
|
||||
registry = (FT_Extension_Registry*)face->driver->extensions;
|
||||
if ( !registry )
|
||||
return FT_Err_Ok;
|
||||
|
||||
memory = face->driver->root.memory;
|
||||
if ( ALLOC( face->extensions, registry->cur_offset ) )
|
||||
return error;
|
||||
|
||||
{
|
||||
FT_Extension_Class* cur = registry->classes;
|
||||
FT_Extension_Class* limit = cur + registry->num_extensions;
|
||||
|
||||
|
||||
for ( ; cur < limit; cur++ )
|
||||
{
|
||||
char* ext = (char*)face->extensions + cur->offset;
|
||||
|
||||
if ( cur->init )
|
||||
{
|
||||
error = cur->init( ext, face );
|
||||
if ( error )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
1184
src/freetype/base/ftglyph.c
Normal file
1184
src/freetype/base/ftglyph.c
Normal file
File diff suppressed because it is too large
Load Diff
155
src/freetype/base/ftinit.c
Normal file
155
src/freetype/base/ftinit.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftinit.c */
|
||||
/* */
|
||||
/* FreeType initialization layer (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The purpose of this file is to implement the following two */
|
||||
/* functions: */
|
||||
/* */
|
||||
/* FT_Add_Default_Modules(): */
|
||||
/* This function is used to add the set of default modules to a */
|
||||
/* fresh new library object. The set is taken from the header file */
|
||||
/* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */
|
||||
/* Build System' for more information. */
|
||||
/* */
|
||||
/* FT_Init_FreeType(): */
|
||||
/* This function creates a system object for the current platform, */
|
||||
/* builds a library out of it, then calls FT_Default_Drivers(). */
|
||||
/* */
|
||||
/* Note that even if FT_Init_FreeType() uses the implementation of the */
|
||||
/* system object defined at build time, client applications are still */
|
||||
/* able to provide their own `ftsystem.c'. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/ftmodule.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_init
|
||||
|
||||
#undef FT_USE_MODULE
|
||||
#define FT_USE_MODULE( x ) extern const FT_Module_Class* x;
|
||||
|
||||
#ifdef macintosh
|
||||
FT_USE_MODULE(fond_driver_class)
|
||||
#endif
|
||||
#include <freetype/config/ftmodule.h>
|
||||
|
||||
#undef FT_USE_MODULE
|
||||
#define FT_USE_MODULE( x ) (const FT_Module_Class*)&x,
|
||||
|
||||
static
|
||||
const FT_Module_Class* ft_default_modules[] =
|
||||
{
|
||||
#ifdef macintosh
|
||||
FT_USE_MODULE(fond_driver_class)
|
||||
#endif
|
||||
#include <freetype/config/ftmodule.h>
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Add_Default_Modules */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Adds the set of default drivers to a given library object. */
|
||||
/* This is only useful when you create a library object with */
|
||||
/* FT_New_Library() (usually to plug a custom memory manager). */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to a new library object. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Add_Default_Modules( FT_Library library )
|
||||
{
|
||||
FT_Error error;
|
||||
const FT_Module_Class** cur;
|
||||
|
||||
|
||||
/* test for valid `library' delayed to FT_Add_Module() */
|
||||
|
||||
cur = ft_default_modules;
|
||||
while ( *cur )
|
||||
{
|
||||
error = FT_Add_Module( library, *cur );
|
||||
/* notify errors, but don't stop */
|
||||
if ( error )
|
||||
{
|
||||
FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = %x\n",
|
||||
(*cur)->module_name, error ));
|
||||
}
|
||||
cur++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Init_FreeType */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a new FreeType library object. The set of drivers */
|
||||
/* that are registered by this function is determined at build time. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* library :: A handle to a new library object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Init_FreeType( FT_Library* library )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
/* First of all, allocate a new system object -- this function is part */
|
||||
/* of the system-specific component, i.e. `ftsystem.c'. */
|
||||
|
||||
memory = FT_New_Memory();
|
||||
if ( !memory )
|
||||
{
|
||||
FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
|
||||
return FT_Err_Unimplemented_Feature;
|
||||
}
|
||||
|
||||
/* build a library out of it, then fill it with the set of */
|
||||
/* default drivers. */
|
||||
|
||||
error = FT_New_Library( memory, library );
|
||||
if ( !error )
|
||||
FT_Add_Default_Modules( *library );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
301
src/freetype/base/ftlist.c
Normal file
301
src/freetype/base/ftlist.c
Normal file
@@ -0,0 +1,301 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftlist.c */
|
||||
/* */
|
||||
/* Generic list support for FreeType (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file implements functions relative to list processing. Its */
|
||||
/* data structures are defined in `freetype/internal/ftlist.h'. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftlist.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_list
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Find */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finds the list node for a given listed object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* data :: The address of the listed object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* List node. NULL if it wasn't found. */
|
||||
/* */
|
||||
BASE_FUNC( FT_ListNode ) FT_List_Find( FT_List list,
|
||||
void* data )
|
||||
{
|
||||
FT_ListNode cur;
|
||||
|
||||
|
||||
cur = list->head;
|
||||
while ( cur )
|
||||
{
|
||||
if ( cur->data == data )
|
||||
return cur;
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
return (FT_ListNode)0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Add */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Appends an element to the end of a list. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* node :: The node to append. */
|
||||
/* */
|
||||
BASE_FUNC( void ) FT_List_Add( FT_List list,
|
||||
FT_ListNode node )
|
||||
{
|
||||
FT_ListNode before = list->tail;
|
||||
|
||||
|
||||
node->next = 0;
|
||||
node->prev = before;
|
||||
|
||||
if ( before )
|
||||
before->next = node;
|
||||
else
|
||||
list->head = node;
|
||||
|
||||
list->tail = node;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Insert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Inserts an element at the head of a list. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to parent list. */
|
||||
/* node :: The node to insert. */
|
||||
/* */
|
||||
BASE_FUNC( void ) FT_List_Insert( FT_List list,
|
||||
FT_ListNode node )
|
||||
{
|
||||
FT_ListNode after = list->head;
|
||||
|
||||
|
||||
node->next = after;
|
||||
node->prev = 0;
|
||||
|
||||
if ( !after )
|
||||
list->tail = node;
|
||||
else
|
||||
after->prev = node;
|
||||
|
||||
list->head = node;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Remove */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Removes a node from a list. This function doesn't check whether */
|
||||
/* the node is in the list! */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* node :: The node to remove. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* */
|
||||
BASE_FUNC( void ) FT_List_Remove( FT_List list,
|
||||
FT_ListNode node )
|
||||
{
|
||||
FT_ListNode before, after;
|
||||
|
||||
|
||||
before = node->prev;
|
||||
after = node->next;
|
||||
|
||||
if ( before )
|
||||
before->next = after;
|
||||
else
|
||||
list->head = after;
|
||||
|
||||
if ( after )
|
||||
after->prev = before;
|
||||
else
|
||||
list->tail = before;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Up */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Moves a node to the head/top of a list. Used to maintain LRU */
|
||||
/* lists. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* node :: The node to move. */
|
||||
/* */
|
||||
BASE_FUNC( void ) FT_List_Up( FT_List list,
|
||||
FT_ListNode node )
|
||||
{
|
||||
FT_ListNode before, after;
|
||||
|
||||
|
||||
before = node->prev;
|
||||
after = node->next;
|
||||
|
||||
/* check whether we are already on top of the list */
|
||||
if ( !before )
|
||||
return;
|
||||
|
||||
before->next = after;
|
||||
|
||||
if ( after )
|
||||
after->prev = before;
|
||||
else
|
||||
list->tail = before;
|
||||
|
||||
node->prev = 0;
|
||||
node->next = list->head;
|
||||
list->head->prev = node;
|
||||
list->head = node;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Iterate */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Parses a list and calls a given iterator function on each element. */
|
||||
/* Note that parsing is stopped as soon as one of the iterator calls */
|
||||
/* returns a non-zero value. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* list :: A handle to the list. */
|
||||
/* iterator :: An interator function, called on each node of the */
|
||||
/* list. */
|
||||
/* user :: A user-supplied field which is passed as the second */
|
||||
/* argument to the iterator. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result (a FreeType error code) of the last iterator call. */
|
||||
/* */
|
||||
BASE_FUNC( FT_Error ) FT_List_Iterate( FT_List list,
|
||||
FT_List_Iterator iterator,
|
||||
void* user )
|
||||
{
|
||||
FT_ListNode cur = list->head;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
while ( cur )
|
||||
{
|
||||
FT_ListNode next = cur->next;
|
||||
|
||||
|
||||
error = iterator( cur, user );
|
||||
if ( error )
|
||||
break;
|
||||
|
||||
cur = next;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Finalize */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroys all elements in the list as well as the list itself. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* list :: A handle to the list. */
|
||||
/* */
|
||||
/* destroy :: A list destructor that will be applied to each element */
|
||||
/* of the list. */
|
||||
/* */
|
||||
/* memory :: The current memory object which handles deallocation. */
|
||||
/* */
|
||||
/* user :: A user-supplied field which is passed as the last */
|
||||
/* argument to the destructor. */
|
||||
/* */
|
||||
BASE_FUNC( void ) FT_List_Finalize( FT_List list,
|
||||
FT_List_Destructor destroy,
|
||||
FT_Memory memory,
|
||||
void* user )
|
||||
{
|
||||
FT_ListNode cur;
|
||||
|
||||
|
||||
cur = list->head;
|
||||
while ( cur )
|
||||
{
|
||||
FT_ListNode next = cur->next;
|
||||
void* data = cur->data;
|
||||
|
||||
|
||||
if ( destroy )
|
||||
destroy( memory, data, user );
|
||||
|
||||
FREE( cur );
|
||||
cur = next;
|
||||
}
|
||||
|
||||
list->head = 0;
|
||||
list->tail = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
176
src/freetype/base/ftmm.c
Normal file
176
src/freetype/base/ftmm.c
Normal file
@@ -0,0 +1,176 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmm.c */
|
||||
/* */
|
||||
/* Multiple Master font support (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/ftmm.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_mm
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Multi_Master */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieves the Multiple Master descriptor of a given font. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* master :: The Multiple Masters descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Get_Multi_Master( FT_Face face,
|
||||
FT_Multi_Master* master )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( !face )
|
||||
return FT_Err_Invalid_Face_Handle;
|
||||
|
||||
error = FT_Err_Invalid_Argument;
|
||||
|
||||
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
|
||||
{
|
||||
FT_Driver driver = face->driver;
|
||||
FT_Get_MM_Func func;
|
||||
|
||||
|
||||
func = (FT_Get_MM_Func)driver->root.clazz->get_interface(
|
||||
FT_MODULE( driver ), "get_mm" );
|
||||
if ( func )
|
||||
error = func( face, master );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_MM_Design_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* For Multiple Masters fonts, choose an interpolated font design */
|
||||
/* through design coordinates. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* num_coords :: The number of design coordinates (must be equal to */
|
||||
/* the number of axes in the font). */
|
||||
/* */
|
||||
/* coords :: The design coordinates. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Set_MM_Design_Coordinates(
|
||||
FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Long* coords )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( !face )
|
||||
return FT_Err_Invalid_Face_Handle;
|
||||
|
||||
error = FT_Err_Invalid_Argument;
|
||||
|
||||
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
|
||||
{
|
||||
FT_Driver driver = face->driver;
|
||||
FT_Set_MM_Design_Func func;
|
||||
|
||||
|
||||
func = (FT_Set_MM_Design_Func)driver->root.clazz->get_interface(
|
||||
FT_MODULE( driver ), "set_mm_design" );
|
||||
if ( func )
|
||||
error = func( face, num_coords, coords );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_MM_Blend_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* For Multiple Masters fonts, choose an interpolated font design */
|
||||
/* through normalized blend coordinates. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* num_coords :: The number of design coordinates (must be equal to */
|
||||
/* the number of axes in the font). */
|
||||
/* */
|
||||
/* coords :: The design coordinates (each one must be between 0 */
|
||||
/* and 1.0). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Set_MM_Blend_Coordinates(
|
||||
FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( !face )
|
||||
return FT_Err_Invalid_Face_Handle;
|
||||
|
||||
error = FT_Err_Invalid_Argument;
|
||||
|
||||
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
|
||||
{
|
||||
FT_Driver driver = face->driver;
|
||||
FT_Set_MM_Blend_Func func;
|
||||
|
||||
|
||||
func = (FT_Set_MM_Blend_Func)driver->root.clazz->get_interface(
|
||||
FT_MODULE( driver ), "set_mm_blend" );
|
||||
if ( func )
|
||||
error = func( face, num_coords, coords );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
70
src/freetype/base/ftnames.c
Normal file
70
src/freetype/base/ftnames.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftnames.c */
|
||||
/* */
|
||||
/* Simple interface to access SFNT name tables (which are used */
|
||||
/* to hold font names, copyright info, notices, etc.). */
|
||||
/* */
|
||||
/* This is _not_ used to retrieve glyph names! */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/ftnames.h>
|
||||
#include <freetype/internal/tttypes.h>
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_SFNT_NAMES
|
||||
|
||||
|
||||
FT_EXPORT_FUNC( FT_UInt ) FT_Get_Sfnt_Name_Count( FT_Face face )
|
||||
{
|
||||
return face && ( FT_IS_SFNT( face ) ? ((TT_Face)face)->num_names : 0 );
|
||||
}
|
||||
|
||||
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Get_Sfnt_Name( FT_Face face,
|
||||
FT_UInt index,
|
||||
FT_SfntName* aname )
|
||||
{
|
||||
FT_Error error = FT_Err_Invalid_Argument;
|
||||
|
||||
|
||||
if ( aname && face && FT_IS_SFNT( face ) )
|
||||
{
|
||||
TT_Face ttface = (TT_Face)face;
|
||||
|
||||
|
||||
if ( index < ttface->num_names )
|
||||
{
|
||||
TT_NameRec* name = ttface->name_table.names + index;
|
||||
|
||||
|
||||
aname->platform_id = name->platformID;
|
||||
aname->encoding_id = name->encodingID;
|
||||
aname->language_id = name->languageID;
|
||||
aname->name_id = name->nameID;
|
||||
aname->string = (FT_Byte*)name->string;
|
||||
aname->string_len = name->stringLength;
|
||||
|
||||
error = FT_Err_Ok;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_SFNT_NAMES */
|
||||
|
||||
|
||||
/* END */
|
||||
3246
src/freetype/base/ftobjs.c
Normal file
3246
src/freetype/base/ftobjs.c
Normal file
File diff suppressed because it is too large
Load Diff
842
src/freetype/base/ftoutln.c
Normal file
842
src/freetype/base/ftoutln.c
Normal file
@@ -0,0 +1,842 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftoutln.c */
|
||||
/* */
|
||||
/* FreeType outline management (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* All functions are declared in freetype.h. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/ftoutln.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_outline
|
||||
|
||||
|
||||
static
|
||||
const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Decompose */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Walks over an outline's structure to decompose it into individual */
|
||||
/* segments and Bezier arcs. This function is also able to emit */
|
||||
/* `move to' and `close to' operations to indicate the start and end */
|
||||
/* of new contours in the outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source target. */
|
||||
/* */
|
||||
/* interface :: A table of `emitters', i.e,. function pointers called */
|
||||
/* during decomposition to indicate path operations. */
|
||||
/* */
|
||||
/* user :: A typeless pointer which is passed to each emitter */
|
||||
/* during the decomposition. It can be used to store */
|
||||
/* the state during the decomposition. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means sucess. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Decompose(
|
||||
FT_Outline* outline,
|
||||
FT_Outline_Funcs* interface,
|
||||
void* user )
|
||||
{
|
||||
#undef SCALED
|
||||
#define SCALED( x ) ( ( (x) << shift ) - delta )
|
||||
|
||||
FT_Vector v_last;
|
||||
FT_Vector v_control;
|
||||
FT_Vector v_start;
|
||||
|
||||
FT_Vector* point;
|
||||
FT_Vector* limit;
|
||||
char* tags;
|
||||
|
||||
FT_Error error;
|
||||
|
||||
FT_Int n; /* index of contour in outline */
|
||||
FT_UInt first; /* index of first point in contour */
|
||||
char tag; /* current point's state */
|
||||
|
||||
FT_Int shift;
|
||||
FT_Pos delta;
|
||||
|
||||
|
||||
if ( !outline || !interface )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
shift = interface->shift;
|
||||
delta = interface->delta;
|
||||
first = 0;
|
||||
|
||||
for ( n = 0; n < outline->n_contours; n++ )
|
||||
{
|
||||
FT_Int last; /* index of last point in contour */
|
||||
|
||||
|
||||
last = outline->contours[n];
|
||||
limit = outline->points + last;
|
||||
|
||||
v_start = outline->points[first];
|
||||
v_last = outline->points[last];
|
||||
|
||||
v_start.x = SCALED( v_start.x ); v_start.y = SCALED( v_start.y );
|
||||
v_last.x = SCALED( v_last.x ); v_last.y = SCALED( v_last.y );
|
||||
|
||||
v_control = v_start;
|
||||
|
||||
point = outline->points + first;
|
||||
tags = outline->tags + first;
|
||||
tag = FT_CURVE_TAG( tags[0] );
|
||||
|
||||
/* A contour cannot start with a cubic control point! */
|
||||
if ( tag == FT_Curve_Tag_Cubic )
|
||||
goto Invalid_Outline;
|
||||
|
||||
/* check first point to determine origin */
|
||||
if ( tag == FT_Curve_Tag_Conic )
|
||||
{
|
||||
/* first point is conic control. Yes, this happens. */
|
||||
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On )
|
||||
{
|
||||
/* start at last point if it is on the curve */
|
||||
v_start = v_last;
|
||||
limit--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if both first and last points are conic, */
|
||||
/* start at their middle and record its position */
|
||||
/* for closure */
|
||||
v_start.x = ( v_start.x + v_last.x ) / 2;
|
||||
v_start.y = ( v_start.y + v_last.y ) / 2;
|
||||
|
||||
v_last = v_start;
|
||||
}
|
||||
point--;
|
||||
tags--;
|
||||
}
|
||||
|
||||
error = interface->move_to( &v_start, user );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
while ( point < limit )
|
||||
{
|
||||
point++;
|
||||
tags++;
|
||||
|
||||
tag = FT_CURVE_TAG( tags[0] );
|
||||
switch ( tag )
|
||||
{
|
||||
case FT_Curve_Tag_On: /* emit a single line_to */
|
||||
{
|
||||
FT_Vector vec;
|
||||
|
||||
|
||||
vec.x = SCALED( point->x );
|
||||
vec.y = SCALED( point->y );
|
||||
|
||||
error = interface->line_to( &vec, user );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
case FT_Curve_Tag_Conic: /* consume conic arcs */
|
||||
v_control.x = SCALED( point->x );
|
||||
v_control.y = SCALED( point->y );
|
||||
|
||||
Do_Conic:
|
||||
if ( point < limit )
|
||||
{
|
||||
FT_Vector vec;
|
||||
FT_Vector v_middle;
|
||||
|
||||
|
||||
point++;
|
||||
tags++;
|
||||
tag = FT_CURVE_TAG( tags[0] );
|
||||
|
||||
vec.x = SCALED( point->x );
|
||||
vec.y = SCALED( point->y );
|
||||
|
||||
if ( tag == FT_Curve_Tag_On )
|
||||
{
|
||||
error = interface->conic_to( &v_control, &vec, user );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( tag != FT_Curve_Tag_Conic )
|
||||
goto Invalid_Outline;
|
||||
|
||||
v_middle.x = ( v_control.x + vec.x ) / 2;
|
||||
v_middle.y = ( v_control.y + vec.y ) / 2;
|
||||
|
||||
error = interface->conic_to( &v_control, &v_middle, user );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
v_control = vec;
|
||||
goto Do_Conic;
|
||||
}
|
||||
|
||||
error = interface->conic_to( &v_control, &v_start, user );
|
||||
goto Close;
|
||||
|
||||
default: /* FT_Curve_Tag_Cubic */
|
||||
{
|
||||
FT_Vector vec1, vec2;
|
||||
|
||||
|
||||
if ( point + 1 > limit ||
|
||||
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
|
||||
goto Invalid_Outline;
|
||||
|
||||
point += 2;
|
||||
tags += 2;
|
||||
|
||||
vec1.x = SCALED( point[-2].x ); vec1.y = SCALED( point[-2].y );
|
||||
vec2.x = SCALED( point[-1].x ); vec2.y = SCALED( point[-1].y );
|
||||
|
||||
if ( point <= limit )
|
||||
{
|
||||
FT_Vector vec;
|
||||
|
||||
|
||||
vec.x = SCALED( point->x );
|
||||
vec.y = SCALED( point->y );
|
||||
|
||||
error = interface->cubic_to( &vec1, &vec2, &vec, user );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
continue;
|
||||
}
|
||||
|
||||
error = interface->cubic_to( &vec1, &vec2, &v_start, user );
|
||||
goto Close;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* close the contour with a line segment */
|
||||
error = interface->line_to( &v_start, user );
|
||||
|
||||
Close:
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
first = last + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Invalid_Outline:
|
||||
return FT_Err_Invalid_Outline;
|
||||
}
|
||||
|
||||
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_New_Internal(
|
||||
FT_Memory memory,
|
||||
FT_UInt numPoints,
|
||||
FT_Int numContours,
|
||||
FT_Outline* outline )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( !outline || !memory )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
*outline = null_outline;
|
||||
|
||||
if ( ALLOC_ARRAY( outline->points, numPoints * 2L, FT_Pos ) ||
|
||||
ALLOC_ARRAY( outline->tags, numPoints, FT_Byte ) ||
|
||||
ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) )
|
||||
goto Fail;
|
||||
|
||||
outline->n_points = (FT_UShort)numPoints;
|
||||
outline->n_contours = (FT_Short)numContours;
|
||||
outline->flags |= ft_outline_owner;
|
||||
|
||||
return FT_Err_Ok;
|
||||
|
||||
Fail:
|
||||
outline->flags |= ft_outline_owner;
|
||||
FT_Outline_Done_Internal( memory, outline );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_New */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates a new outline of a given size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object from where the */
|
||||
/* outline is allocated. Note however that the new */
|
||||
/* outline will NOT necessarily be FREED, when */
|
||||
/* destroying the library, by FT_Done_FreeType(). */
|
||||
/* */
|
||||
/* numPoints :: The maximal number of points within the outline. */
|
||||
/* */
|
||||
/* numContours :: The maximal number of contours within the outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* outline :: A handle to the new outline. NULL in case of */
|
||||
/* error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* No. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The reason why this function takes a `library' parameter is simply */
|
||||
/* to use the library's memory allocator. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_New( FT_Library library,
|
||||
FT_UInt numPoints,
|
||||
FT_Int numContours,
|
||||
FT_Outline* outline )
|
||||
{
|
||||
if ( !library )
|
||||
return FT_Err_Invalid_Library_Handle;
|
||||
|
||||
return FT_Outline_New_Internal( library->memory, numPoints,
|
||||
numContours, outline );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Copies an outline into another one. Both objects must have the */
|
||||
/* same sizes (number of points & number of contours) when this */
|
||||
/* function is called. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Copy( FT_Outline* source,
|
||||
FT_Outline* target )
|
||||
{
|
||||
FT_Int is_owner;
|
||||
|
||||
|
||||
if ( !source || !target ||
|
||||
source->n_points != target->n_points ||
|
||||
source->n_contours != target->n_contours )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
MEM_Copy( target->points, source->points,
|
||||
source->n_points * sizeof ( FT_Vector ) );
|
||||
|
||||
MEM_Copy( target->tags, source->tags,
|
||||
source->n_points * sizeof ( FT_Byte ) );
|
||||
|
||||
MEM_Copy( target->contours, source->contours,
|
||||
source->n_contours * sizeof ( FT_Short ) );
|
||||
|
||||
/* copy all flags, except the `ft_outline_owner' one */
|
||||
is_owner = target->flags & ft_outline_owner;
|
||||
target->flags = source->flags;
|
||||
|
||||
target->flags &= ~ft_outline_owner;
|
||||
target->flags |= is_owner;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Done_Internal( FT_Memory memory,
|
||||
FT_Outline* outline )
|
||||
{
|
||||
if ( outline )
|
||||
{
|
||||
if ( outline->flags & ft_outline_owner )
|
||||
{
|
||||
FREE( outline->points );
|
||||
FREE( outline->tags );
|
||||
FREE( outline->contours );
|
||||
}
|
||||
*outline = null_outline;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
else
|
||||
return FT_Err_Invalid_Argument;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Done */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroys an outline created with FT_Outline_New(). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle of the library object used to allocate the */
|
||||
/* outline. */
|
||||
/* */
|
||||
/* outline :: A pointer to the outline object to be discarded. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* No. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If the outline's `owner' field is not set, only the outline */
|
||||
/* descriptor will be released. */
|
||||
/* */
|
||||
/* The reason why this function takes an `outline' parameter is */
|
||||
/* simply to use FT_Free(). */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Done( FT_Library library,
|
||||
FT_Outline* outline )
|
||||
{
|
||||
/* check for valid `outline' in FT_Outline_Done_Internal() */
|
||||
|
||||
if ( !library )
|
||||
return FT_Err_Invalid_Library_Handle;
|
||||
|
||||
return FT_Outline_Done_Internal( library->memory, outline );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_CBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Returns an outline's `control box'. The control box encloses all */
|
||||
/* the outline's points, including Bezier control points. Though it */
|
||||
/* coincides with the exact bounding box for most glyphs, it can be */
|
||||
/* slightly larger in some situations (like when rotating an outline */
|
||||
/* which contains Bezier outside arcs). */
|
||||
/* */
|
||||
/* Computing the control box is very fast, while getting the bounding */
|
||||
/* box can take much more time as it needs to walk over all segments */
|
||||
/* and arcs in the outline. To get the latter, you can use the */
|
||||
/* `ftbbox' component which is dedicated to this single task. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* cbox :: The outline's control box. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Outline_Get_CBox( FT_Outline* outline,
|
||||
FT_BBox* cbox )
|
||||
{
|
||||
FT_Pos xMin, yMin, xMax, yMax;
|
||||
|
||||
|
||||
if ( outline && cbox )
|
||||
{
|
||||
if ( outline->n_points == 0 )
|
||||
{
|
||||
xMin = 0;
|
||||
yMin = 0;
|
||||
xMax = 0;
|
||||
yMax = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FT_Vector* vec = outline->points;
|
||||
FT_Vector* limit = vec + outline->n_points;
|
||||
|
||||
|
||||
xMin = xMax = vec->x;
|
||||
yMin = yMax = vec->y;
|
||||
vec++;
|
||||
|
||||
for ( ; vec < limit; vec++ )
|
||||
{
|
||||
FT_Pos x, y;
|
||||
|
||||
|
||||
x = vec->x;
|
||||
if ( x < xMin ) xMin = x;
|
||||
if ( x > xMax ) xMax = x;
|
||||
|
||||
y = vec->y;
|
||||
if ( y < yMin ) yMin = y;
|
||||
if ( y > yMax ) yMax = y;
|
||||
}
|
||||
}
|
||||
cbox->xMin = xMin;
|
||||
cbox->xMax = xMax;
|
||||
cbox->yMin = yMin;
|
||||
cbox->yMax = yMax;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Translate */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Applies a simple translation to the points of an outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* xOffset :: The horizontal offset. */
|
||||
/* */
|
||||
/* yOffset :: The vertical offset. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Outline_Translate( FT_Outline* outline,
|
||||
FT_Pos xOffset,
|
||||
FT_Pos yOffset )
|
||||
{
|
||||
FT_UShort n;
|
||||
FT_Vector* vec = outline->points;
|
||||
|
||||
|
||||
for ( n = 0; n < outline->n_points; n++ )
|
||||
{
|
||||
vec->x += xOffset;
|
||||
vec->y += yOffset;
|
||||
vec++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Reverse */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Reverses the drawing direction of an outline. This is used to */
|
||||
/* ensure consistent fill conventions for mirrored glyphs. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This functions toggles the bit flag `ft_outline_reverse_fill' in */
|
||||
/* the outline's `flags' field. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Outline_Reverse( FT_Outline* outline )
|
||||
{
|
||||
FT_UShort n;
|
||||
FT_Int first, last;
|
||||
|
||||
|
||||
first = 0;
|
||||
|
||||
for ( n = 0; n < outline->n_contours; n++ )
|
||||
{
|
||||
last = outline->contours[n];
|
||||
|
||||
/* reverse point table */
|
||||
{
|
||||
FT_Vector* p = outline->points + first;
|
||||
FT_Vector* q = outline->points + last;
|
||||
FT_Vector swap;
|
||||
|
||||
|
||||
while ( p < q )
|
||||
{
|
||||
swap = *p;
|
||||
*p = *q;
|
||||
*q = swap;
|
||||
p++;
|
||||
q--;
|
||||
}
|
||||
}
|
||||
|
||||
/* reverse tags table */
|
||||
{
|
||||
char* p = outline->tags + first;
|
||||
char* q = outline->tags + last;
|
||||
char swap;
|
||||
|
||||
|
||||
while ( p < q )
|
||||
{
|
||||
swap = *p;
|
||||
*p = *q;
|
||||
*q = swap;
|
||||
p++;
|
||||
q--;
|
||||
}
|
||||
}
|
||||
|
||||
first = last + 1;
|
||||
}
|
||||
|
||||
outline->flags ^= ft_outline_reverse_fill;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Render */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Renders an outline within a bitmap using the current scan-convert. */
|
||||
/* This functions uses an FT_Raster_Params structure as an argument, */
|
||||
/* allowing advanced features like direct composition, translucency, */
|
||||
/* etc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* params :: A pointer to a FT_Raster_Params structure used to */
|
||||
/* describe the rendering operation. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* YES. Rendering is synchronized, so that concurrent calls to the */
|
||||
/* scan-line converter will be serialized. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should know what you are doing and how FT_Raster_Params works */
|
||||
/* to use this function. */
|
||||
/* */
|
||||
/* The field `params.source' will be set to `outline' before the scan */
|
||||
/* converter is called, which means that the value you give to it is */
|
||||
/* actually ignored. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Render( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
FT_Raster_Params* params )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Bool update = 0;
|
||||
FT_Renderer renderer;
|
||||
FT_ListNode node;
|
||||
|
||||
|
||||
if ( !library )
|
||||
return FT_Err_Invalid_Library_Handle;
|
||||
|
||||
if ( !params )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
renderer = library->cur_renderer;
|
||||
node = library->renderers.head;
|
||||
|
||||
params->source = (void*)outline;
|
||||
|
||||
error = FT_Err_Cannot_Render_Glyph;
|
||||
while ( renderer )
|
||||
{
|
||||
error = renderer->raster_render( renderer->raster, params );
|
||||
if ( !error || error != FT_Err_Cannot_Render_Glyph )
|
||||
break;
|
||||
|
||||
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
|
||||
/* is unsupported by the current renderer for this glyph image */
|
||||
/* format */
|
||||
|
||||
/* now, look for another renderer that supports the same */
|
||||
/* format */
|
||||
renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline,
|
||||
&node );
|
||||
update = 1;
|
||||
}
|
||||
|
||||
/* if we changed the current renderer for the glyph image format */
|
||||
/* we need to select it as the next current one */
|
||||
if ( !error && update && renderer )
|
||||
FT_Set_Renderer( library, renderer, 0, 0 );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Renders an outline within a bitmap. The outline's image is simply */
|
||||
/* OR-ed to the target bitmap. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* map :: A pointer to the target bitmap descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* YES. Rendering is synchronized, so that concurrent calls to the */
|
||||
/* scan-line converter will be serialized. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does NOT CREATE the bitmap, it only renders an */
|
||||
/* outline image within the one you pass to it! */
|
||||
/* */
|
||||
/* It will use the raster correponding to the default glyph format. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Get_Bitmap( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
FT_Bitmap* bitmap )
|
||||
{
|
||||
FT_Raster_Params params;
|
||||
|
||||
|
||||
if ( !bitmap )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
/* other checks are delayed to FT_Outline_Render() */
|
||||
|
||||
params.target = bitmap;
|
||||
params.flags = 0;
|
||||
|
||||
if ( bitmap->pixel_mode == ft_pixel_mode_grays )
|
||||
params.flags |= ft_raster_flag_aa;
|
||||
|
||||
return FT_Outline_Render( library, outline, ¶ms );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Vector_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Transforms a single vector through a 2x2 matrix. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* vector :: The target vector to transform. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* matrix :: A pointer to the source 2x2 matrix. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The result is undefined if either `vector' or `matrix' is invalid. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Vector_Transform( FT_Vector* vector,
|
||||
FT_Matrix* matrix )
|
||||
{
|
||||
FT_Pos xz, yz;
|
||||
|
||||
|
||||
if ( !vector || !matrix )
|
||||
return;
|
||||
|
||||
xz = FT_MulFix( vector->x, matrix->xx ) +
|
||||
FT_MulFix( vector->y, matrix->xy );
|
||||
|
||||
yz = FT_MulFix( vector->x, matrix->yx ) +
|
||||
FT_MulFix( vector->y, matrix->yy );
|
||||
|
||||
vector->x = xz;
|
||||
vector->y = yz;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Applies a simple 2x2 matrix to all of an outline's points. Useful */
|
||||
/* for applying rotations, slanting, flipping, etc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* matrix :: A pointer to the transformation matrix. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You can use FT_Outline_Translate() if you need to translate the */
|
||||
/* outline's points. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Outline_Transform( FT_Outline* outline,
|
||||
FT_Matrix* matrix )
|
||||
{
|
||||
FT_Vector* vec = outline->points;
|
||||
FT_Vector* limit = vec + outline->n_points;
|
||||
|
||||
|
||||
for ( ; vec < limit; vec++ )
|
||||
FT_Vector_Transform( vec, matrix );
|
||||
}
|
||||
|
||||
/* END */
|
||||
818
src/freetype/base/ftstream.c
Normal file
818
src/freetype/base/ftstream.c
Normal file
@@ -0,0 +1,818 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftstream.c */
|
||||
/* */
|
||||
/* I/O stream support (body). */
|
||||
/* */
|
||||
/* Copyright 2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_stream
|
||||
|
||||
|
||||
BASE_FUNC( void ) FT_New_Memory_Stream( FT_Library library,
|
||||
FT_Byte* base,
|
||||
FT_ULong size,
|
||||
FT_Stream stream )
|
||||
{
|
||||
stream->memory = library->memory;
|
||||
stream->base = base;
|
||||
stream->size = size;
|
||||
stream->pos = 0;
|
||||
stream->cursor = 0;
|
||||
stream->read = 0;
|
||||
stream->close = 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Error ) FT_Seek_Stream( FT_Stream stream,
|
||||
FT_ULong pos )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
stream->pos = pos;
|
||||
|
||||
if ( stream->read )
|
||||
{
|
||||
if ( stream->read( stream, pos, 0, 0 ) )
|
||||
{
|
||||
FT_ERROR(( "FT_Seek_Stream:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
pos, stream->size ));
|
||||
|
||||
error = FT_Err_Invalid_Stream_Operation;
|
||||
}
|
||||
else
|
||||
error = FT_Err_Ok;
|
||||
}
|
||||
/* note that seeking to the first position after the file is valid */
|
||||
else if ( pos > stream->size )
|
||||
{
|
||||
FT_ERROR(( "FT_Seek_Stream:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
pos, stream->size ));
|
||||
|
||||
error = FT_Err_Invalid_Stream_Operation;
|
||||
}
|
||||
|
||||
else
|
||||
error = FT_Err_Ok;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Error ) FT_Skip_Stream( FT_Stream stream,
|
||||
FT_Long distance )
|
||||
{
|
||||
return FT_Seek_Stream( stream, (FT_ULong)( stream->pos + distance ) );
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Long ) FT_Stream_Pos( FT_Stream stream )
|
||||
{
|
||||
return stream->pos;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Error ) FT_Read_Stream( FT_Stream stream,
|
||||
FT_Byte* buffer,
|
||||
FT_ULong count )
|
||||
{
|
||||
return FT_Read_Stream_At( stream, stream->pos, buffer, count );
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Error ) FT_Read_Stream_At( FT_Stream stream,
|
||||
FT_ULong pos,
|
||||
FT_Byte* buffer,
|
||||
FT_ULong count )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
FT_ULong read_bytes;
|
||||
|
||||
|
||||
if ( pos >= stream->size )
|
||||
{
|
||||
FT_ERROR(( "FT_Read_Stream_At:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
pos, stream->size ));
|
||||
|
||||
return FT_Err_Invalid_Stream_Operation;
|
||||
}
|
||||
|
||||
if ( stream->read )
|
||||
read_bytes = stream->read( stream, pos, buffer, count );
|
||||
else
|
||||
{
|
||||
read_bytes = stream->size - pos;
|
||||
if ( read_bytes > count )
|
||||
read_bytes = count;
|
||||
|
||||
MEM_Copy( buffer, stream->base + pos, read_bytes );
|
||||
}
|
||||
|
||||
stream->pos = pos + read_bytes;
|
||||
|
||||
if ( read_bytes < count )
|
||||
{
|
||||
FT_ERROR(( "FT_Read_Stream_At:" ));
|
||||
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
|
||||
count, read_bytes ));
|
||||
|
||||
error = FT_Err_Invalid_Stream_Operation;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Error ) FT_Extract_Frame( FT_Stream stream,
|
||||
FT_ULong count,
|
||||
FT_Byte** pbytes )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = FT_Access_Frame( stream, count );
|
||||
if ( !error )
|
||||
{
|
||||
*pbytes = (FT_Byte*)stream->cursor;
|
||||
|
||||
/* equivalent to FT_Forget_Frame(), with no memory block release */
|
||||
stream->cursor = 0;
|
||||
stream->limit = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( void ) FT_Release_Frame( FT_Stream stream,
|
||||
FT_Byte** pbytes )
|
||||
{
|
||||
if ( stream->read )
|
||||
{
|
||||
FT_Memory memory = stream->memory;
|
||||
|
||||
|
||||
FREE( *pbytes );
|
||||
}
|
||||
*pbytes = 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Error ) FT_Access_Frame( FT_Stream stream,
|
||||
FT_ULong count )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
FT_ULong read_bytes;
|
||||
|
||||
|
||||
/* check for nested frame access */
|
||||
FT_Assert( stream && stream->cursor == 0 );
|
||||
|
||||
if ( stream->read )
|
||||
{
|
||||
/* allocate the frame in memory */
|
||||
FT_Memory memory = stream->memory;
|
||||
|
||||
|
||||
if ( ALLOC( stream->base, count ) )
|
||||
goto Exit;
|
||||
|
||||
/* read it */
|
||||
read_bytes = stream->read( stream, stream->pos,
|
||||
stream->base, count );
|
||||
if ( read_bytes < count )
|
||||
{
|
||||
FT_ERROR(( "FT_Access_Frame:" ));
|
||||
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
|
||||
count, read_bytes ));
|
||||
|
||||
FREE( stream->base );
|
||||
error = FT_Err_Invalid_Stream_Operation;
|
||||
}
|
||||
stream->cursor = stream->base;
|
||||
stream->limit = stream->cursor + count;
|
||||
stream->pos += read_bytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* check current and new position */
|
||||
if ( stream->pos >= stream->size ||
|
||||
stream->pos + count > stream->size )
|
||||
{
|
||||
FT_ERROR(( "FT_Access_Frame:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
|
||||
stream->pos, count, stream->size ));
|
||||
|
||||
error = FT_Err_Invalid_Stream_Operation;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* set cursor */
|
||||
stream->cursor = stream->base + stream->pos;
|
||||
stream->limit = stream->cursor + count;
|
||||
stream->pos += count;
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( void ) FT_Forget_Frame( FT_Stream stream )
|
||||
{
|
||||
/* IMPORTANT: The assertion stream->cursor != 0 was removed, given */
|
||||
/* that it is possible to access a frame of length 0 in */
|
||||
/* some weird fonts (usually, when accessing an array of */
|
||||
/* 0 records, like in some strange kern tables). */
|
||||
/* */
|
||||
/* In this case, the loader code handles the 0-length table */
|
||||
/* gracefully; however, stream.cursor is really set to 0 by the */
|
||||
/* FT_Access_Frame() call, and this is not an error. */
|
||||
/* */
|
||||
FT_Assert( stream );
|
||||
|
||||
if ( stream->read )
|
||||
{
|
||||
FT_Memory memory = stream->memory;
|
||||
|
||||
|
||||
FREE( stream->base );
|
||||
}
|
||||
stream->cursor = 0;
|
||||
stream->limit = 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Char ) FT_Get_Char( FT_Stream stream )
|
||||
{
|
||||
FT_Char result;
|
||||
|
||||
|
||||
FT_Assert( stream && stream->cursor );
|
||||
|
||||
result = 0;
|
||||
if ( stream->cursor < stream->limit )
|
||||
result = *stream->cursor++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Short ) FT_Get_Short( FT_Stream stream )
|
||||
{
|
||||
FT_Byte* p;
|
||||
FT_Short result;
|
||||
|
||||
|
||||
FT_Assert( stream && stream->cursor );
|
||||
|
||||
result = 0;
|
||||
p = stream->cursor;
|
||||
if ( p + 1 < stream->limit )
|
||||
result = NEXT_Short( p );
|
||||
stream->cursor = p;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Short ) FT_Get_ShortLE( FT_Stream stream )
|
||||
{
|
||||
FT_Byte* p;
|
||||
FT_Short result;
|
||||
|
||||
|
||||
FT_Assert( stream && stream->cursor );
|
||||
|
||||
result = 0;
|
||||
p = stream->cursor;
|
||||
if ( p + 1 < stream->limit )
|
||||
result = NEXT_ShortLE( p );
|
||||
stream->cursor = p;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Long ) FT_Get_Offset( FT_Stream stream )
|
||||
{
|
||||
FT_Byte* p;
|
||||
FT_Long result;
|
||||
|
||||
|
||||
FT_Assert( stream && stream->cursor );
|
||||
|
||||
result = 0;
|
||||
p = stream->cursor;
|
||||
if ( p + 2 < stream->limit )
|
||||
result = NEXT_Offset( p );
|
||||
stream->cursor = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Long ) FT_Get_Long( FT_Stream stream )
|
||||
{
|
||||
FT_Byte* p;
|
||||
FT_Long result;
|
||||
|
||||
|
||||
FT_Assert( stream && stream->cursor );
|
||||
|
||||
result = 0;
|
||||
p = stream->cursor;
|
||||
if ( p + 3 < stream->limit )
|
||||
result = NEXT_Long( p );
|
||||
stream->cursor = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Long ) FT_Get_LongLE( FT_Stream stream )
|
||||
{
|
||||
FT_Byte* p;
|
||||
FT_Long result;
|
||||
|
||||
|
||||
FT_Assert( stream && stream->cursor );
|
||||
|
||||
result = 0;
|
||||
p = stream->cursor;
|
||||
if ( p + 3 < stream->limit )
|
||||
result = NEXT_LongLE( p );
|
||||
stream->cursor = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Char ) FT_Read_Char( FT_Stream stream,
|
||||
FT_Error* error )
|
||||
{
|
||||
FT_Byte result = 0;
|
||||
|
||||
|
||||
FT_Assert( stream );
|
||||
|
||||
*error = FT_Err_Ok;
|
||||
|
||||
if ( stream->read )
|
||||
{
|
||||
if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
|
||||
goto Fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( stream->pos < stream->size )
|
||||
result = stream->base[stream->pos];
|
||||
else
|
||||
goto Fail;
|
||||
}
|
||||
stream->pos++;
|
||||
|
||||
return result;
|
||||
|
||||
Fail:
|
||||
*error = FT_Err_Invalid_Stream_Operation;
|
||||
FT_ERROR(( "FT_Read_Char:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
stream->pos, stream->size ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Short ) FT_Read_Short( FT_Stream stream,
|
||||
FT_Error* error )
|
||||
{
|
||||
FT_Byte reads[2];
|
||||
FT_Byte* p = 0;
|
||||
FT_Short result = 0;
|
||||
|
||||
|
||||
FT_Assert( stream );
|
||||
|
||||
*error = FT_Err_Ok;
|
||||
|
||||
if ( stream->pos + 1 < stream->size )
|
||||
{
|
||||
if ( stream->read )
|
||||
{
|
||||
if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
|
||||
goto Fail;
|
||||
|
||||
p = reads;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = stream->base + stream->pos;
|
||||
}
|
||||
|
||||
if ( p )
|
||||
result = NEXT_Short( p );
|
||||
}
|
||||
else
|
||||
goto Fail;
|
||||
|
||||
stream->pos += 2;
|
||||
|
||||
return result;
|
||||
|
||||
Fail:
|
||||
*error = FT_Err_Invalid_Stream_Operation;
|
||||
FT_ERROR(( "FT_Read_Short:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
stream->pos, stream->size ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Short ) FT_Read_ShortLE( FT_Stream stream,
|
||||
FT_Error* error )
|
||||
{
|
||||
FT_Byte reads[2];
|
||||
FT_Byte* p = 0;
|
||||
FT_Short result = 0;
|
||||
|
||||
|
||||
FT_Assert( stream );
|
||||
|
||||
*error = FT_Err_Ok;
|
||||
|
||||
if ( stream->pos + 1 < stream->size )
|
||||
{
|
||||
if ( stream->read )
|
||||
{
|
||||
if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
|
||||
goto Fail;
|
||||
|
||||
p = reads;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = stream->base + stream->pos;
|
||||
}
|
||||
|
||||
if ( p )
|
||||
result = NEXT_ShortLE( p );
|
||||
}
|
||||
else
|
||||
goto Fail;
|
||||
|
||||
stream->pos += 2;
|
||||
|
||||
return result;
|
||||
|
||||
Fail:
|
||||
*error = FT_Err_Invalid_Stream_Operation;
|
||||
FT_ERROR(( "FT_Read_Short:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
stream->pos, stream->size ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Long ) FT_Read_Offset( FT_Stream stream,
|
||||
FT_Error* error )
|
||||
{
|
||||
FT_Byte reads[3];
|
||||
FT_Byte* p = 0;
|
||||
FT_Long result = 0;
|
||||
|
||||
|
||||
FT_Assert( stream );
|
||||
|
||||
*error = FT_Err_Ok;
|
||||
|
||||
if ( stream->pos + 2 < stream->size )
|
||||
{
|
||||
if ( stream->read )
|
||||
{
|
||||
if (stream->read( stream, stream->pos, reads, 3L ) != 3L )
|
||||
goto Fail;
|
||||
|
||||
p = reads;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = stream->base + stream->pos;
|
||||
}
|
||||
|
||||
if ( p )
|
||||
result = NEXT_Offset( p );
|
||||
}
|
||||
else
|
||||
goto Fail;
|
||||
|
||||
stream->pos += 3;
|
||||
|
||||
return result;
|
||||
|
||||
Fail:
|
||||
*error = FT_Err_Invalid_Stream_Operation;
|
||||
FT_ERROR(( "FT_Read_Offset:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
stream->pos, stream->size ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Long ) FT_Read_Long( FT_Stream stream,
|
||||
FT_Error* error )
|
||||
{
|
||||
FT_Byte reads[4];
|
||||
FT_Byte* p = 0;
|
||||
FT_Long result = 0;
|
||||
|
||||
|
||||
FT_Assert( stream );
|
||||
|
||||
*error = FT_Err_Ok;
|
||||
|
||||
if ( stream->pos + 3 < stream->size )
|
||||
{
|
||||
if ( stream->read )
|
||||
{
|
||||
if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
|
||||
goto Fail;
|
||||
|
||||
p = reads;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = stream->base + stream->pos;
|
||||
}
|
||||
|
||||
if ( p )
|
||||
result = NEXT_Long( p );
|
||||
}
|
||||
else
|
||||
goto Fail;
|
||||
|
||||
stream->pos += 4;
|
||||
|
||||
return result;
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "FT_Read_Long:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
stream->pos, stream->size ));
|
||||
*error = FT_Err_Invalid_Stream_Operation;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Long ) FT_Read_LongLE( FT_Stream stream,
|
||||
FT_Error* error )
|
||||
{
|
||||
FT_Byte reads[4];
|
||||
FT_Byte* p = 0;
|
||||
FT_Long result = 0;
|
||||
|
||||
|
||||
FT_Assert( stream );
|
||||
|
||||
*error = FT_Err_Ok;
|
||||
|
||||
if ( stream->pos + 3 < stream->size )
|
||||
{
|
||||
if ( stream->read )
|
||||
{
|
||||
if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
|
||||
goto Fail;
|
||||
|
||||
p = reads;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = stream->base + stream->pos;
|
||||
}
|
||||
|
||||
if ( p )
|
||||
result = NEXT_LongLE( p );
|
||||
}
|
||||
else
|
||||
goto Fail;
|
||||
|
||||
stream->pos += 4;
|
||||
|
||||
return result;
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "FT_Read_Long:" ));
|
||||
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
|
||||
stream->pos, stream->size ));
|
||||
*error = FT_Err_Invalid_Stream_Operation;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BASE_FUNC( FT_Error ) FT_Read_Fields( FT_Stream stream,
|
||||
const FT_Frame_Field* fields,
|
||||
void* structure )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Bool frame_accessed = 0;
|
||||
|
||||
|
||||
if ( !fields || !stream )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
error = FT_Err_Ok;
|
||||
do
|
||||
{
|
||||
FT_ULong value;
|
||||
FT_Int sign_shift;
|
||||
FT_Byte* p;
|
||||
|
||||
|
||||
switch ( fields->value )
|
||||
{
|
||||
case ft_frame_start: /* access a new frame */
|
||||
error = FT_Access_Frame( stream, fields->offset );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
frame_accessed = 1;
|
||||
fields++;
|
||||
continue; /* loop! */
|
||||
|
||||
case ft_frame_bytes: /* read a byte sequence */
|
||||
case ft_frame_skip: /* skip some bytes */
|
||||
{
|
||||
FT_Int len = fields->size;
|
||||
|
||||
|
||||
if ( stream->cursor + len > stream->limit )
|
||||
{
|
||||
error = FT_Err_Invalid_Stream_Operation;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ( fields->value == ft_frame_bytes )
|
||||
{
|
||||
p = (FT_Byte*)structure + fields->offset;
|
||||
MEM_Copy( p, stream->cursor, len );
|
||||
}
|
||||
stream->cursor += len;
|
||||
fields++;
|
||||
continue;
|
||||
}
|
||||
|
||||
case ft_frame_byte:
|
||||
case ft_frame_schar: /* read a single byte */
|
||||
value = GET_Byte();
|
||||
sign_shift = 24;
|
||||
break;
|
||||
|
||||
case ft_frame_short_be:
|
||||
case ft_frame_ushort_be: /* read a 2-byte big-endian short */
|
||||
value = GET_UShort();
|
||||
sign_shift = 16;
|
||||
break;
|
||||
|
||||
case ft_frame_short_le:
|
||||
case ft_frame_ushort_le: /* read a 2-byte little-endian short */
|
||||
{
|
||||
FT_Byte* p;
|
||||
|
||||
|
||||
value = 0;
|
||||
p = stream->cursor;
|
||||
|
||||
if ( p + 1 < stream->limit )
|
||||
{
|
||||
value = ( FT_UShort)p[0] | ((FT_UShort)p[1] << 8 );
|
||||
stream->cursor += 2;
|
||||
}
|
||||
sign_shift = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
case ft_frame_long_be:
|
||||
case ft_frame_ulong_be: /* read a 4-byte big-endian long */
|
||||
value = GET_ULong();
|
||||
sign_shift = 0;
|
||||
break;
|
||||
|
||||
case ft_frame_long_le:
|
||||
case ft_frame_ulong_le: /* read a 4-byte little-endian long */
|
||||
{
|
||||
FT_Byte* p;
|
||||
|
||||
|
||||
value = 0;
|
||||
p = stream->cursor;
|
||||
|
||||
if ( p + 3 < stream->limit )
|
||||
{
|
||||
value = (FT_ULong)p[0] |
|
||||
( (FT_ULong)p[1] << 8 ) |
|
||||
( (FT_ULong)p[2] << 16 ) |
|
||||
( (FT_ULong)p[3] << 24 );
|
||||
stream->cursor += 4;
|
||||
}
|
||||
sign_shift = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case ft_frame_off3_be:
|
||||
case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
|
||||
value = GET_UOffset();
|
||||
sign_shift = 8;
|
||||
break;
|
||||
|
||||
case ft_frame_off3_le:
|
||||
case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
|
||||
{
|
||||
FT_Byte* p;
|
||||
|
||||
|
||||
value = 0;
|
||||
p = stream->cursor;
|
||||
|
||||
if ( p + 2 < stream->limit )
|
||||
{
|
||||
value = (FT_ULong)p[0] |
|
||||
( (FT_ULong)p[1] << 8 ) |
|
||||
( (FT_ULong)p[2] << 16 );
|
||||
stream->cursor += 3;
|
||||
}
|
||||
sign_shift = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
/* otherwise, exit the loop */
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* now, compute the signed value is necessary */
|
||||
if ( fields->value & FT_FRAME_OP_SIGNED )
|
||||
value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift );
|
||||
|
||||
/* finally, store the value in the object */
|
||||
|
||||
p = (FT_Byte*)structure + fields->offset;
|
||||
switch ( fields->size )
|
||||
{
|
||||
case 1:
|
||||
*(FT_Byte*)p = (FT_Byte)value;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(FT_UShort*)p = (FT_UShort)value;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(FT_UInt32*)p = (FT_UInt32)value;
|
||||
break;
|
||||
|
||||
default: /* for 64-bit systems */
|
||||
*(FT_ULong*)p = (FT_ULong)value;
|
||||
}
|
||||
|
||||
/* go to next field */
|
||||
fields++;
|
||||
}
|
||||
while ( 1 );
|
||||
|
||||
Exit:
|
||||
/* close the frame if it was opened by this read */
|
||||
if ( frame_accessed )
|
||||
FT_Forget_Frame( stream );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
299
src/freetype/base/ftsystem.c
Normal file
299
src/freetype/base/ftsystem.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsystem.c */
|
||||
/* */
|
||||
/* ANSI-specific FreeType low-level system interface (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file contains the default interface used by FreeType to access */
|
||||
/* low-level, i.e. memory management, i/o access as well as thread */
|
||||
/* synchronisation. It can be replaced by user-specific routines if */
|
||||
/* necessary. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/ftsystem.h>
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/fttypes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* MEMORY MANAGEMENT INTERFACE */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* It is not necessary to do any error checking for the */
|
||||
/* allocation-related functions. This will be done by the higher level */
|
||||
/* routines like FT_Alloc() or FT_Realloc(). */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_alloc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory allocation function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* size :: The requested size in bytes. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* block :: The address of newly allocated block. */
|
||||
/* */
|
||||
static
|
||||
void* ft_alloc( FT_Memory memory,
|
||||
long size )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_realloc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory reallocation function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* cur_size :: The current size of the allocated memory block. */
|
||||
/* */
|
||||
/* new_size :: The newly requested size in bytes. */
|
||||
/* */
|
||||
/* block :: The current address of the block in memory. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The address of the reallocated memory block. */
|
||||
/* */
|
||||
static
|
||||
void* ft_realloc( FT_Memory memory,
|
||||
long cur_size,
|
||||
long new_size,
|
||||
void* block )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
FT_UNUSED( cur_size );
|
||||
|
||||
return realloc( block, new_size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_free */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The memory release function. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A pointer to the memory object. */
|
||||
/* */
|
||||
/* block :: The address of block in memory to be freed. */
|
||||
/* */
|
||||
static
|
||||
void ft_free( FT_Memory memory,
|
||||
void* block )
|
||||
{
|
||||
FT_UNUSED( memory );
|
||||
|
||||
free( block );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* RESOURCE MANAGEMENT INTERFACE */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_io
|
||||
|
||||
/* We use the macro STREAM_FILE for convenience to extract the */
|
||||
/* system-specific stream handle from a given FreeType stream object */
|
||||
#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_close_stream */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The function to close a stream. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: A pointer to the stream object. */
|
||||
/* */
|
||||
static
|
||||
void ft_close_stream( FT_Stream stream )
|
||||
{
|
||||
fclose( STREAM_FILE( stream ) );
|
||||
|
||||
stream->descriptor.pointer = NULL;
|
||||
stream->size = 0;
|
||||
stream->base = 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* ft_io_stream */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The function to open a stream. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: A pointer to the stream object. */
|
||||
/* */
|
||||
/* offset :: The position in the data stream to start reading. */
|
||||
/* */
|
||||
/* buffer :: The address of buffer to store the read data. */
|
||||
/* */
|
||||
/* count :: The number of bytes to read from the stream. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The number of bytes actually read. */
|
||||
/* */
|
||||
static
|
||||
unsigned long ft_io_stream( FT_Stream stream,
|
||||
unsigned long offset,
|
||||
unsigned char* buffer,
|
||||
unsigned long count )
|
||||
{
|
||||
FILE* file;
|
||||
|
||||
|
||||
file = STREAM_FILE( stream );
|
||||
|
||||
fseek( file, offset, SEEK_SET );
|
||||
|
||||
return (unsigned long)fread( buffer, 1, count, file );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Stream */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates a new stream object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* filepathname :: The name of the stream (usually a file) to be */
|
||||
/* opened. */
|
||||
/* */
|
||||
/* stream :: A pointer to the stream object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_New_Stream( const char* filepathname,
|
||||
FT_Stream stream )
|
||||
{
|
||||
FILE* file;
|
||||
|
||||
|
||||
if ( !stream )
|
||||
return FT_Err_Invalid_Stream_Handle;
|
||||
|
||||
file = fopen( filepathname, "rb" );
|
||||
if ( !file )
|
||||
{
|
||||
FT_ERROR(( "FT_New_Stream:" ));
|
||||
FT_ERROR(( " could not open `%s'\n", filepathname ));
|
||||
|
||||
return FT_Err_Cannot_Open_Resource;
|
||||
}
|
||||
|
||||
fseek( file, 0, SEEK_END );
|
||||
stream->size = ftell( file );
|
||||
fseek( file, 0, SEEK_SET );
|
||||
|
||||
stream->descriptor.pointer = file;
|
||||
stream->pathname.pointer = (char*)filepathname;
|
||||
stream->pos = 0;
|
||||
|
||||
stream->read = ft_io_stream;
|
||||
stream->close = ft_close_stream;
|
||||
|
||||
FT_TRACE1(( "FT_New_Stream:" ));
|
||||
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
|
||||
filepathname, stream->size ));
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Memory */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates a new memory object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A pointer to the new memory object. 0 in case of error. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Memory ) FT_New_Memory( void )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
memory = (FT_Memory)malloc( sizeof ( *memory ) );
|
||||
if ( memory )
|
||||
{
|
||||
memory->user = 0;
|
||||
memory->alloc = ft_alloc;
|
||||
memory->realloc = ft_realloc;
|
||||
memory->free = ft_free;
|
||||
}
|
||||
|
||||
return memory;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
83
src/freetype/base/rules.mk
Normal file
83
src/freetype/base/rules.mk
Normal file
@@ -0,0 +1,83 @@
|
||||
#
|
||||
# FreeType 2 base layer configuration rules
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 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.
|
||||
|
||||
|
||||
# It sets the following variables which are used by the master Makefile
|
||||
# after the call:
|
||||
#
|
||||
# BASE_OBJ_S: The single-object base layer.
|
||||
# BASE_OBJ_M: A list of all objects for a multiple-objects build.
|
||||
# BASE_EXT_OBJ: A list of base layer extensions, i.e., components found
|
||||
# in `freetype/src/base' which are not compiled within the
|
||||
# base layer proper.
|
||||
#
|
||||
# BASE_H is defined in freetype.mk to simplify the dependency rules.
|
||||
|
||||
|
||||
BASE_COMPILE := $(FT_COMPILE) $I$(SRC_)base
|
||||
|
||||
|
||||
# Base layer sources
|
||||
#
|
||||
# ftsystem, ftinit, and ftdebug are handled by freetype.mk
|
||||
#
|
||||
BASE_SRC := $(BASE_)ftcalc.c \
|
||||
$(BASE_)ftextend.c \
|
||||
$(BASE_)ftlist.c \
|
||||
$(BASE_)ftobjs.c \
|
||||
$(BASE_)ftstream.c \
|
||||
$(BASE_)ftoutln.c
|
||||
|
||||
# Base layer `extensions' sources
|
||||
#
|
||||
# An extension is added to the library file (.a or .lib) as a separate
|
||||
# object. It will then be linked to the final executable only if one of its
|
||||
# symbols is used by the application.
|
||||
#
|
||||
BASE_EXT_SRC := $(BASE_)ftglyph.c \
|
||||
$(BASE_)ftmm.c
|
||||
|
||||
# Default extensions objects
|
||||
#
|
||||
BASE_EXT_OBJ := $(BASE_EXT_SRC:$(BASE_)%.c=$(OBJ_)%.$O)
|
||||
|
||||
|
||||
# Base layer object(s)
|
||||
#
|
||||
# BASE_OBJ_M is used during `multi' builds (each base source file compiles
|
||||
# to a single object file).
|
||||
#
|
||||
# BASE_OBJ_S is used during `single' builds (the whole base layer is
|
||||
# compiled as a single object file using ftbase.c).
|
||||
#
|
||||
BASE_OBJ_M := $(BASE_SRC:$(BASE_)%.c=$(OBJ_)%.$O)
|
||||
BASE_OBJ_S := $(OBJ_)ftbase.$O
|
||||
|
||||
# Base layer root source file for single build
|
||||
#
|
||||
BASE_SRC_S := $(BASE_)ftbase.c
|
||||
|
||||
|
||||
# Base layer - single object build
|
||||
#
|
||||
$(BASE_OBJ_S): $(BASE_SRC_S) $(BASE_SRC) $(FREETYPE_H)
|
||||
$(BASE_COMPILE) $T$@ $(BASE_SRC_S)
|
||||
|
||||
|
||||
# Multiple objects build + extensions
|
||||
#
|
||||
$(OBJ_)%.$O: $(BASE_)%.c $(FREETYPE_H)
|
||||
$(BASE_COMPILE) $T$@ $<
|
||||
|
||||
# EOF
|
||||
40
src/freetype/cff/cff.c
Normal file
40
src/freetype/cff/cff.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cff.c */
|
||||
/* */
|
||||
/* FreeType OpenType driver component (body only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2driver.c" /* driver interface */
|
||||
#include "t2parse.c" /* token parser */
|
||||
#include "t2load.c" /* tables loader */
|
||||
#include "t2objs.c" /* object management */
|
||||
#include "t2gload.c" /* glyph loader */
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2driver.c> /* driver interface */
|
||||
#include <cff/t2parse.c> /* token parser */
|
||||
#include <cff/t2load.c> /* tables loader */
|
||||
#include <cff/t2objs.c> /* object management */
|
||||
#include <cff/t2gload.c> /* glyph loader */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* END */
|
||||
7
src/freetype/cff/module.mk
Normal file
7
src/freetype/cff/module.mk
Normal file
@@ -0,0 +1,7 @@
|
||||
make_module_list: add_cff_driver
|
||||
|
||||
add_cff_driver:
|
||||
$(OPEN_DRIVER)cff_driver_class$(CLOSE_DRIVER)
|
||||
$(ECHO_DRIVER)cff $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE)
|
||||
|
||||
# EOF
|
||||
69
src/freetype/cff/rules.mk
Normal file
69
src/freetype/cff/rules.mk
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# FreeType 2 OpenType/CFF driver configuration rules
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 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.
|
||||
|
||||
|
||||
# OpenType driver directory
|
||||
#
|
||||
T2_DIR := $(SRC_)cff
|
||||
T2_DIR_ := $(T2_DIR)$(SEP)
|
||||
|
||||
|
||||
T2_COMPILE := $(FT_COMPILE)
|
||||
|
||||
|
||||
# T2 driver sources (i.e., C files)
|
||||
#
|
||||
T2_DRV_SRC := $(T2_DIR_)t2objs.c \
|
||||
$(T2_DIR_)t2load.c \
|
||||
$(T2_DIR_)t2gload.c \
|
||||
$(T2_DIR_)t2parse.c \
|
||||
$(T2_DIR_)t2driver.c
|
||||
|
||||
# T2 driver headers
|
||||
#
|
||||
T2_DRV_H := $(T2_DRV_SRC:%.c=%.h) \
|
||||
$(T2_DIR_)t2tokens.h
|
||||
|
||||
|
||||
# T2 driver object(s)
|
||||
#
|
||||
# T2_DRV_OBJ_M is used during `multi' builds
|
||||
# T2_DRV_OBJ_S is used during `single' builds
|
||||
#
|
||||
T2_DRV_OBJ_M := $(T2_DRV_SRC:$(T2_DIR_)%.c=$(OBJ_)%.$O)
|
||||
T2_DRV_OBJ_S := $(OBJ_)cff.$O
|
||||
|
||||
# T2 driver source file for single build
|
||||
#
|
||||
T2_DRV_SRC_S := $(T2_DIR_)cff.c
|
||||
|
||||
|
||||
# T2 driver - single object
|
||||
#
|
||||
$(T2_DRV_OBJ_S): $(T2_DRV_SRC_S) $(T2_DRV_SRC) $(FREETYPE_H) $(T2_DRV_H)
|
||||
$(T2_COMPILE) $T$@ $(T2_DRV_SRC_S)
|
||||
|
||||
|
||||
# T2 driver - multiple objects
|
||||
#
|
||||
$(OBJ_)%.$O: $(T2_DIR_)%.c $(FREETYPE_H) $(T2_DRV_H)
|
||||
$(T2_COMPILE) $T$@ $<
|
||||
|
||||
|
||||
# update main driver object lists
|
||||
#
|
||||
DRV_OBJS_S += $(T2_DRV_OBJ_S)
|
||||
DRV_OBJS_M += $(T2_DRV_OBJ_M)
|
||||
|
||||
# EOF
|
||||
377
src/freetype/cff/t2driver.c
Normal file
377
src/freetype/cff/t2driver.c
Normal file
@@ -0,0 +1,377 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2driver.c */
|
||||
/* */
|
||||
/* OpenType font driver implementation (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/ttnameid.h>
|
||||
|
||||
#include <freetype/internal/t2errors.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2driver.h"
|
||||
#include "t2gload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2driver.h>
|
||||
#include <cff/t2gload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_t2driver
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** F A C E S ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#undef PAIR_TAG
|
||||
#define PAIR_TAG( left, right ) ( ( (FT_ULong)left << 16 ) | \
|
||||
(FT_ULong)right )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Get_Kerning */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A driver method used to return the kerning vector between two */
|
||||
/* glyphs of the same face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* left_glyph :: The index of the left glyph in the kern pair. */
|
||||
/* */
|
||||
/* right_glyph :: The index of the right glyph in the kern pair. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* kerning :: The kerning vector. This is in font units for */
|
||||
/* scalable formats, and in pixels for fixed-sizes */
|
||||
/* formats. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Only horizontal layouts (left-to-right & right-to-left) are */
|
||||
/* supported by this function. Other layouts, or more sophisticated */
|
||||
/* kernings, are out of scope of this method (the basic driver */
|
||||
/* interface is meant to be simple). */
|
||||
/* */
|
||||
/* They can be implemented by format-specific interfaces. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Get_Kerning( TT_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
TT_Kern_0_Pair* pair;
|
||||
|
||||
|
||||
if ( !face )
|
||||
return T2_Err_Invalid_Face_Handle;
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
|
||||
if ( face->kern_pairs )
|
||||
{
|
||||
/* there are some kerning pairs in this font file! */
|
||||
FT_ULong search_tag = PAIR_TAG( left_glyph, right_glyph );
|
||||
FT_Long left, right;
|
||||
|
||||
|
||||
left = 0;
|
||||
right = face->num_kern_pairs - 1;
|
||||
|
||||
while ( left <= right )
|
||||
{
|
||||
FT_Int middle = left + ( ( right - left ) >> 1 );
|
||||
FT_ULong cur_pair;
|
||||
|
||||
|
||||
pair = face->kern_pairs + middle;
|
||||
cur_pair = PAIR_TAG( pair->left, pair->right );
|
||||
|
||||
if ( cur_pair == search_tag )
|
||||
goto Found;
|
||||
|
||||
if ( cur_pair < search_tag )
|
||||
left = middle + 1;
|
||||
else
|
||||
right = middle - 1;
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
return T2_Err_Ok;
|
||||
|
||||
Found:
|
||||
kerning->x = pair->value;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
#undef PAIR_TAG
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Load_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A driver method used to load a glyph within a given glyph slot. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* slot :: A handle to the target slot object where the glyph */
|
||||
/* will be loaded. */
|
||||
/* */
|
||||
/* size :: A handle to the source face size at which the glyph */
|
||||
/* must be scaled, loaded, etc. */
|
||||
/* */
|
||||
/* glyph_index :: The index of the glyph in the font file. */
|
||||
/* */
|
||||
/* load_flags :: A flag indicating what to load for this glyph. The */
|
||||
/* FTLOAD_??? constants can be used to control the */
|
||||
/* glyph loading process (e.g., whether the outline */
|
||||
/* should be scaled, whether to load bitmaps or not, */
|
||||
/* whether to hint the outline, etc). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Load_Glyph( T2_GlyphSlot slot,
|
||||
T2_Size size,
|
||||
FT_UShort glyph_index,
|
||||
FT_UInt load_flags )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( !slot )
|
||||
return T2_Err_Invalid_Glyph_Handle;
|
||||
|
||||
/* check whether we want a scaled outline or bitmap */
|
||||
if ( !size )
|
||||
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
||||
|
||||
if ( load_flags & FT_LOAD_NO_SCALE )
|
||||
size = NULL;
|
||||
|
||||
/* reset the size object if necessary */
|
||||
if ( size )
|
||||
{
|
||||
/* these two object must have the same parent */
|
||||
if ( size->face != slot->root.face )
|
||||
return T2_Err_Invalid_Face_Handle;
|
||||
}
|
||||
|
||||
/* now load the glyph outline if necessary */
|
||||
error = T2_Load_Glyph( slot, size, glyph_index, load_flags );
|
||||
|
||||
/* force drop-out mode to 2 - irrelevant now */
|
||||
/* slot->outline.dropout_mode = 2; */
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** C H A R A C T E R M A P P I N G S ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Get_Char_Index */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Uses a charmap to return a given character code's glyph index. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charmap :: A handle to the source charmap object. */
|
||||
/* charcode :: The character code. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Glyph index. 0 means `undefined character code'. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt t2_get_char_index( TT_CharMap charmap,
|
||||
FT_Long charcode )
|
||||
{
|
||||
FT_Error error;
|
||||
T2_Face face;
|
||||
TT_CMapTable* cmap;
|
||||
|
||||
|
||||
cmap = &charmap->cmap;
|
||||
face = (T2_Face)charmap->root.face;
|
||||
|
||||
/* Load table if needed */
|
||||
if ( !cmap->loaded )
|
||||
{
|
||||
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
||||
|
||||
|
||||
error = sfnt->load_charmap( face, cmap, face->root.stream );
|
||||
if ( error )
|
||||
return 0;
|
||||
|
||||
cmap->loaded = TRUE;
|
||||
}
|
||||
|
||||
return ( cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** D R I V E R I N T E R F A C E ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
FT_Module_Interface t2_get_interface( T2_Driver driver,
|
||||
const char* interface )
|
||||
{
|
||||
FT_Module sfnt;
|
||||
|
||||
|
||||
/* we simply pass our request to the `sfnt' module */
|
||||
sfnt = FT_Get_Module( driver->root.root.library, "sfnt" );
|
||||
|
||||
return sfnt ? sfnt->clazz->get_interface( sfnt, interface ) : 0;
|
||||
}
|
||||
|
||||
|
||||
/* The FT_DriverInterface structure is defined in ftdriver.h. */
|
||||
|
||||
const FT_Driver_Class cff_driver_class =
|
||||
{
|
||||
/* begin with the FT_Module_Class fields */
|
||||
{
|
||||
ft_module_font_driver | ft_module_driver_scalable,
|
||||
sizeof( T2_DriverRec ),
|
||||
"cff",
|
||||
0x10000L,
|
||||
0x20000L,
|
||||
|
||||
0, /* module-specific interface */
|
||||
|
||||
(FT_Module_Constructor)T2_Init_Driver,
|
||||
(FT_Module_Destructor) T2_Done_Driver,
|
||||
(FT_Module_Requester) t2_get_interface,
|
||||
},
|
||||
|
||||
/* now the specific driver fields */
|
||||
sizeof( TT_FaceRec ),
|
||||
sizeof( FT_SizeRec ),
|
||||
sizeof( T2_GlyphSlotRec ),
|
||||
|
||||
(FTDriver_initFace) T2_Init_Face,
|
||||
(FTDriver_doneFace) T2_Done_Face,
|
||||
(FTDriver_initSize) 0,
|
||||
(FTDriver_doneSize) 0,
|
||||
(FTDriver_initGlyphSlot)0,
|
||||
(FTDriver_doneGlyphSlot)0,
|
||||
|
||||
(FTDriver_setCharSizes) 0,
|
||||
(FTDriver_setPixelSizes)0,
|
||||
|
||||
(FTDriver_loadGlyph) Load_Glyph,
|
||||
(FTDriver_getCharIndex) t2_get_char_index,
|
||||
|
||||
(FTDriver_getKerning) Get_Kerning,
|
||||
(FTDriver_attachFile) 0,
|
||||
(FTDriver_getAdvances) 0
|
||||
};
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* getDriverClass */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is used when compiling the TrueType driver as a */
|
||||
/* shared library (`.DLL' or `.so'). It will be used by the */
|
||||
/* high-level library of FreeType to retrieve the address of the */
|
||||
/* driver's generic interface. */
|
||||
/* */
|
||||
/* It shouldn't be implemented in a static build, as each driver must */
|
||||
/* have the same function as an exported entry point. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The address of the TrueType's driver generic interface. The */
|
||||
/* format-specific interface can then be retrieved through the method */
|
||||
/* interface->get_format_interface. */
|
||||
/* */
|
||||
EXPORT_FUNC( FT_Driver_Class* ) getDriverClass( void )
|
||||
{
|
||||
return &cff_driver_class;
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
|
||||
|
||||
|
||||
/* END */
|
||||
30
src/freetype/cff/t2driver.h
Normal file
30
src/freetype/cff/t2driver.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2driver.h */
|
||||
/* */
|
||||
/* High-level OpenType driver interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T2DRIVER_H
|
||||
#define T2DRIVER_H
|
||||
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Driver_Class ) cff_driver_class;
|
||||
|
||||
|
||||
#endif /* T2DRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
2045
src/freetype/cff/t2gload.c
Normal file
2045
src/freetype/cff/t2gload.c
Normal file
File diff suppressed because it is too large
Load Diff
213
src/freetype/cff/t2gload.h
Normal file
213
src/freetype/cff/t2gload.h
Normal file
@@ -0,0 +1,213 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2gload.h */
|
||||
/* */
|
||||
/* OpenType Glyph Loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T2GLOAD_H
|
||||
#define T2GLOAD_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2objs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2objs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define T2_MAX_OPERANDS 48
|
||||
#define T2_MAX_SUBRS_CALLS 32
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> */
|
||||
/* T2_Builder */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used during glyph loading to store its outline. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* memory :: The current memory object. */
|
||||
/* */
|
||||
/* face :: The current face object. */
|
||||
/* */
|
||||
/* glyph :: The current glyph slot. */
|
||||
/* */
|
||||
/* current :: The current glyph outline. */
|
||||
/* */
|
||||
/* base :: The base glyph outline. */
|
||||
/* */
|
||||
/* max_points :: maximum points in builder outline */
|
||||
/* */
|
||||
/* max_contours :: Maximal number of contours in builder outline. */
|
||||
/* */
|
||||
/* last :: The last point position. */
|
||||
/* */
|
||||
/* scale_x :: The horizontal scale (FUnits to sub-pixels). */
|
||||
/* */
|
||||
/* scale_y :: The vertical scale (FUnits to sub-pixels). */
|
||||
/* */
|
||||
/* pos_x :: The horizontal translation (if composite glyph). */
|
||||
/* */
|
||||
/* pos_y :: The vertical translation (if composite glyph). */
|
||||
/* */
|
||||
/* left_bearing :: The left side bearing point. */
|
||||
/* */
|
||||
/* advance :: The horizontal advance vector. */
|
||||
/* */
|
||||
/* bbox :: Unused. */
|
||||
/* */
|
||||
/* path_begun :: A flag which indicates that a new path has begun. */
|
||||
/* */
|
||||
/* load_points :: If this flag is not set, no points are loaded. */
|
||||
/* */
|
||||
/* no_recurse :: Set but not used. */
|
||||
/* */
|
||||
/* error :: An error code that is only used to report memory */
|
||||
/* allocation problems. */
|
||||
/* */
|
||||
/* metrics_only :: A boolean indicating that we only want to compute */
|
||||
/* the metrics of a given glyph, not load all of its */
|
||||
/* points. */
|
||||
/* */
|
||||
typedef struct T2_Builder_
|
||||
{
|
||||
FT_Memory memory;
|
||||
TT_Face face;
|
||||
T2_GlyphSlot glyph;
|
||||
FT_GlyphLoader* loader;
|
||||
FT_Outline* base;
|
||||
FT_Outline* current;
|
||||
|
||||
FT_Vector last;
|
||||
|
||||
FT_Fixed scale_x;
|
||||
FT_Fixed scale_y;
|
||||
|
||||
FT_Pos pos_x;
|
||||
FT_Pos pos_y;
|
||||
|
||||
FT_Vector left_bearing;
|
||||
FT_Vector advance;
|
||||
|
||||
FT_BBox bbox; /* bounding box */
|
||||
FT_Bool path_begun;
|
||||
FT_Bool load_points;
|
||||
FT_Bool no_recurse;
|
||||
|
||||
FT_Error error; /* only used for memory errors */
|
||||
FT_Bool metrics_only;
|
||||
|
||||
} T2_Builder;
|
||||
|
||||
|
||||
/* execution context charstring zone */
|
||||
|
||||
typedef struct T2_Decoder_Zone_
|
||||
{
|
||||
FT_Byte* base;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* cursor;
|
||||
|
||||
} T2_Decoder_Zone;
|
||||
|
||||
|
||||
typedef struct T2_Decoder_
|
||||
{
|
||||
T2_Builder builder;
|
||||
CFF_Font* cff;
|
||||
|
||||
FT_Fixed stack[T2_MAX_OPERANDS + 1];
|
||||
FT_Fixed* top;
|
||||
|
||||
T2_Decoder_Zone zones[T2_MAX_SUBRS_CALLS + 1];
|
||||
T2_Decoder_Zone* zone;
|
||||
|
||||
FT_Int flex_state;
|
||||
FT_Int num_flex_vectors;
|
||||
FT_Vector flex_vectors[7];
|
||||
|
||||
FT_Pos glyph_width;
|
||||
FT_Pos nominal_width;
|
||||
|
||||
FT_Bool read_width;
|
||||
FT_Int num_hints;
|
||||
FT_Fixed* buildchar;
|
||||
FT_Int len_buildchar;
|
||||
|
||||
FT_UInt num_locals;
|
||||
FT_UInt num_globals;
|
||||
|
||||
FT_Int locals_bias;
|
||||
FT_Int globals_bias;
|
||||
|
||||
FT_Byte** locals;
|
||||
FT_Byte** globals;
|
||||
|
||||
} T2_Decoder;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Init_Decoder( T2_Decoder* decoder,
|
||||
TT_Face face,
|
||||
T2_Size size,
|
||||
T2_GlyphSlot slot );
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Prepare_Decoder( T2_Decoder* decoder,
|
||||
FT_UInt glyph_index );
|
||||
|
||||
#if 0 /* unused until we support pure CFF fonts */
|
||||
|
||||
/* Compute the maximum advance width of a font through quick parsing */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Compute_Max_Advance( TT_Face face,
|
||||
FT_Int* max_advance );
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Parse_CharStrings( T2_Decoder* decoder,
|
||||
FT_Byte* charstring_base,
|
||||
FT_Int charstring_len );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Load_Glyph( T2_GlyphSlot glyph,
|
||||
T2_Size size,
|
||||
FT_Int glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T2GLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
757
src/freetype/cff/t2load.c
Normal file
757
src/freetype/cff/t2load.c
Normal file
@@ -0,0 +1,757 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2load.c */
|
||||
/* */
|
||||
/* TrueType glyph data/program tables loader (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
#include <freetype/internal/t2errors.h>
|
||||
#include <freetype/tttags.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2load.h"
|
||||
#include "t2parse.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2load.h>
|
||||
#include <cff/t2parse.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_t2load
|
||||
|
||||
|
||||
/* read a CFF offset from memory */
|
||||
static
|
||||
FT_ULong t2_get_offset( FT_Byte* p,
|
||||
FT_Byte off_size )
|
||||
{
|
||||
FT_ULong result;
|
||||
|
||||
|
||||
for ( result = 0; off_size > 0; off_size-- )
|
||||
{
|
||||
result <<= 8;
|
||||
result |= *p++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error t2_new_cff_index( CFF_Index* index,
|
||||
FT_Stream stream,
|
||||
FT_Bool load )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_UShort count;
|
||||
|
||||
|
||||
MEM_Set( index, 0, sizeof ( *index ) );
|
||||
|
||||
index->stream = stream;
|
||||
if ( !READ_UShort( count ) &&
|
||||
count > 0 )
|
||||
{
|
||||
FT_Byte* p;
|
||||
FT_Byte offsize;
|
||||
FT_ULong data_size;
|
||||
FT_ULong* poff;
|
||||
|
||||
|
||||
/* there is at least one element; read the offset size, */
|
||||
/* then access the offset table to compute the index's total size */
|
||||
if ( READ_Byte( offsize ) )
|
||||
goto Exit;
|
||||
|
||||
index->stream = stream;
|
||||
index->count = count;
|
||||
index->off_size = offsize;
|
||||
data_size = (FT_ULong)( count + 1 ) * offsize;
|
||||
|
||||
if ( ALLOC_ARRAY( index->offsets, count + 1, FT_ULong ) ||
|
||||
ACCESS_Frame( data_size ) )
|
||||
goto Exit;
|
||||
|
||||
poff = index->offsets;
|
||||
p = (FT_Byte*)stream->cursor;
|
||||
|
||||
for ( ; (FT_Short)count >= 0; count-- )
|
||||
{
|
||||
poff[0] = t2_get_offset( p, offsize );
|
||||
poff++;
|
||||
p += offsize;
|
||||
}
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
index->data_offset = FILE_Pos();
|
||||
data_size = poff[-1] - 1;
|
||||
|
||||
if ( load )
|
||||
{
|
||||
/* load the data */
|
||||
if ( EXTRACT_Frame( data_size, index->bytes ) )
|
||||
goto Exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* skip the data */
|
||||
(void)FILE_Skip( data_size );
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
if ( error )
|
||||
FREE( index->offsets );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void t2_done_cff_index( CFF_Index* index )
|
||||
{
|
||||
if ( index->stream )
|
||||
{
|
||||
FT_Stream stream = index->stream;
|
||||
FT_Memory memory = stream->memory;
|
||||
|
||||
|
||||
if ( index->bytes )
|
||||
RELEASE_Frame( index->bytes );
|
||||
|
||||
FREE( index->offsets );
|
||||
MEM_Set( index, 0, sizeof ( *index ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error t2_explicit_cff_index( CFF_Index* index,
|
||||
FT_Byte*** table )
|
||||
{
|
||||
FT_Error error = 0;
|
||||
FT_Memory memory = index->stream->memory;
|
||||
FT_UInt n, offset, old_offset;
|
||||
FT_Byte** t;
|
||||
|
||||
|
||||
*table = 0;
|
||||
|
||||
if ( index->count > 0 && !ALLOC_ARRAY( t, index->count + 1, FT_Byte* ) )
|
||||
{
|
||||
old_offset = 1;
|
||||
for ( n = 0; n <= index->count; n++ )
|
||||
{
|
||||
offset = index->offsets[n];
|
||||
if ( !offset )
|
||||
offset = old_offset;
|
||||
|
||||
t[n] = index->bytes + offset - 1;
|
||||
|
||||
old_offset = offset;
|
||||
}
|
||||
*table = t;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Access_Element( CFF_Index* index,
|
||||
FT_UInt element,
|
||||
FT_Byte** pbytes,
|
||||
FT_ULong* pbyte_len )
|
||||
{
|
||||
FT_Error error = 0;
|
||||
|
||||
|
||||
if ( index && index->count > element )
|
||||
{
|
||||
/* compute start and end offsets */
|
||||
FT_ULong off1, off2;
|
||||
|
||||
|
||||
off1 = index->offsets[element];
|
||||
if ( off1 )
|
||||
{
|
||||
do
|
||||
{
|
||||
element++;
|
||||
off2 = index->offsets[element];
|
||||
|
||||
} while ( off2 == 0 && element < index->count );
|
||||
|
||||
if ( !off2 )
|
||||
off1 = 0;
|
||||
}
|
||||
|
||||
/* access element */
|
||||
if ( off1 )
|
||||
{
|
||||
*pbyte_len = off2 - off1;
|
||||
|
||||
if ( index->bytes )
|
||||
{
|
||||
/* this index was completely loaded in memory, that's easy */
|
||||
*pbytes = index->bytes + off1 - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this index is still on disk/file, access it through a frame */
|
||||
FT_Stream stream = index->stream;
|
||||
|
||||
|
||||
if ( FILE_Seek( index->data_offset + off1 - 1 ) ||
|
||||
EXTRACT_Frame( off2 - off1, *pbytes ) )
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* empty index element */
|
||||
*pbytes = 0;
|
||||
*pbyte_len = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
error = T2_Err_Invalid_Argument;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void T2_Forget_Element( CFF_Index* index,
|
||||
FT_Byte** pbytes )
|
||||
{
|
||||
if ( index->bytes == 0 )
|
||||
{
|
||||
FT_Stream stream = index->stream;
|
||||
|
||||
|
||||
RELEASE_Frame( *pbytes );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_String* T2_Get_Name( CFF_Index* index,
|
||||
FT_UInt element )
|
||||
{
|
||||
FT_Memory memory = index->stream->memory;
|
||||
FT_Byte* bytes;
|
||||
FT_ULong byte_len;
|
||||
FT_Error error;
|
||||
FT_String* name = 0;
|
||||
|
||||
|
||||
error = T2_Access_Element( index, element, &bytes, &byte_len );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
if ( !ALLOC( name, byte_len + 1 ) )
|
||||
{
|
||||
MEM_Copy( name, bytes, byte_len );
|
||||
name[byte_len] = 0;
|
||||
}
|
||||
T2_Forget_Element( index, &bytes );
|
||||
|
||||
Exit:
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_String* T2_Get_String( CFF_Index* index,
|
||||
FT_UInt sid,
|
||||
PSNames_Interface* interface )
|
||||
{
|
||||
/* if it is not a standard string, return it */
|
||||
if ( sid > 390 )
|
||||
return T2_Get_Name( index, sid - 390 );
|
||||
|
||||
/* that's a standard string, fetch a copy from the PSName module */
|
||||
{
|
||||
FT_String* name = 0;
|
||||
const char* adobe_name = interface->adobe_std_strings( sid );
|
||||
FT_UInt len;
|
||||
|
||||
|
||||
if ( adobe_name )
|
||||
{
|
||||
FT_Memory memory = index->stream->memory;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
len = (FT_UInt)strlen( adobe_name );
|
||||
if ( !ALLOC( name, len + 1 ) )
|
||||
{
|
||||
MEM_Copy( name, adobe_name, len );
|
||||
name[len] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*** ***/
|
||||
/*** FD Select table support ***/
|
||||
/*** ***/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
void CFF_Done_FD_Select( CFF_FD_Select* select,
|
||||
FT_Stream stream )
|
||||
{
|
||||
if ( select->data )
|
||||
RELEASE_Frame( select->data );
|
||||
|
||||
select->data_size = 0;
|
||||
select->format = 0;
|
||||
select->range_count = 0;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error CFF_Load_FD_Select( CFF_FD_Select* select,
|
||||
FT_UInt num_glyphs,
|
||||
FT_Stream stream,
|
||||
FT_ULong offset )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Byte format;
|
||||
FT_UInt num_ranges;
|
||||
|
||||
|
||||
/* read format */
|
||||
if ( FILE_Seek( offset ) || READ_Byte( format ) )
|
||||
goto Exit;
|
||||
|
||||
select->format = format;
|
||||
select->cache_count = 0; /* clear cache */
|
||||
|
||||
switch ( format )
|
||||
{
|
||||
case 0: /* format 0, that's simple */
|
||||
select->data_size = num_glyphs;
|
||||
goto Load_Data;
|
||||
|
||||
case 3: /* format 3, a tad more complex */
|
||||
if ( READ_UShort( num_ranges ) )
|
||||
goto Exit;
|
||||
|
||||
select->data_size = num_ranges * 3 + 2;
|
||||
|
||||
Load_Data:
|
||||
if ( EXTRACT_Frame( select->data_size, select->data ) )
|
||||
goto Exit;
|
||||
break;
|
||||
|
||||
default: /* hmm... that's wrong */
|
||||
error = T2_Err_Invalid_File_Format;
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Byte CFF_Get_FD( CFF_FD_Select* select,
|
||||
FT_UInt glyph_index )
|
||||
{
|
||||
FT_Byte fd = 0;
|
||||
|
||||
|
||||
switch ( select->format )
|
||||
{
|
||||
case 0:
|
||||
fd = select->data[glyph_index];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* first, compare to cache */
|
||||
if ( (FT_UInt)(glyph_index-select->cache_first) < select->cache_count )
|
||||
{
|
||||
fd = select->cache_fd;
|
||||
break;
|
||||
}
|
||||
|
||||
/* then, lookup the ranges array */
|
||||
{
|
||||
FT_Byte* p = select->data;
|
||||
FT_Byte* p_limit = p + select->data_size;
|
||||
FT_Byte fd2;
|
||||
FT_UInt first, limit;
|
||||
|
||||
|
||||
first = NEXT_UShort( p );
|
||||
do
|
||||
{
|
||||
if ( glyph_index < first )
|
||||
break;
|
||||
|
||||
fd2 = *p++;
|
||||
limit = NEXT_UShort( p );
|
||||
|
||||
if ( glyph_index < limit )
|
||||
{
|
||||
fd = fd2;
|
||||
|
||||
/* update cache */
|
||||
select->cache_first = first;
|
||||
select->cache_count = limit-first;
|
||||
select->cache_fd = fd2;
|
||||
break;
|
||||
}
|
||||
first = limit;
|
||||
|
||||
} while ( p < p_limit );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*** ***/
|
||||
/*** CFF font support ***/
|
||||
/*** ***/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
FT_Error CFF_Load_SubFont( CFF_SubFont* font,
|
||||
CFF_Index* index,
|
||||
FT_UInt font_index,
|
||||
FT_Stream stream,
|
||||
FT_ULong base_offset )
|
||||
{
|
||||
FT_Error error;
|
||||
T2_Parser parser;
|
||||
FT_Byte* dict;
|
||||
FT_ULong dict_len;
|
||||
CFF_Font_Dict* top = &font->font_dict;
|
||||
CFF_Private* priv = &font->private_dict;
|
||||
|
||||
|
||||
T2_Parser_Init( &parser, T2CODE_TOPDICT, &font->font_dict );
|
||||
|
||||
/* set defaults */
|
||||
MEM_Set( top, 0, sizeof ( *top ) );
|
||||
|
||||
top->underline_position = -100;
|
||||
top->underline_thickness = 50;
|
||||
top->charstring_type = 2;
|
||||
top->font_matrix.xx = 0x10000L;
|
||||
top->font_matrix.yy = 0x10000L;
|
||||
top->cid_count = 8720;
|
||||
|
||||
error = T2_Access_Element( index, font_index, &dict, &dict_len ) ||
|
||||
T2_Parser_Run( &parser, dict, dict + dict_len );
|
||||
|
||||
T2_Forget_Element( index, &dict );
|
||||
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* if it is a CID font, we stop there */
|
||||
if ( top->cid_registry )
|
||||
goto Exit;
|
||||
|
||||
/* parse the private dictionary, if any */
|
||||
if ( top->private_offset && top->private_size )
|
||||
{
|
||||
/* set defaults */
|
||||
MEM_Set( priv, 0, sizeof ( *priv ) );
|
||||
|
||||
priv->blue_shift = 7;
|
||||
priv->blue_fuzz = 1;
|
||||
priv->lenIV = -1;
|
||||
priv->expansion_factor = (FT_Fixed)0.06 * 0x10000L;
|
||||
priv->blue_scale = (FT_Fixed)0.039625 * 0x10000L;
|
||||
|
||||
T2_Parser_Init( &parser, T2CODE_PRIVATE, priv );
|
||||
|
||||
if ( FILE_Seek( base_offset + font->font_dict.private_offset ) ||
|
||||
ACCESS_Frame( font->font_dict.private_size ) )
|
||||
goto Exit;
|
||||
|
||||
error = T2_Parser_Run( &parser,
|
||||
(FT_Byte*)stream->cursor,
|
||||
(FT_Byte*)stream->limit );
|
||||
FORGET_Frame();
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* read the local subrs, if any */
|
||||
if ( priv->local_subrs_offset )
|
||||
{
|
||||
if ( FILE_Seek( base_offset + top->private_offset +
|
||||
priv->local_subrs_offset ) )
|
||||
goto Exit;
|
||||
|
||||
error = t2_new_cff_index( &font->local_subrs_index, stream, 1 );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
font->num_local_subrs = font->local_subrs_index.count;
|
||||
error = t2_explicit_cff_index( &font->local_subrs_index,
|
||||
&font->local_subrs );
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void CFF_Done_SubFont( FT_Memory memory,
|
||||
CFF_SubFont* subfont )
|
||||
{
|
||||
if ( subfont )
|
||||
{
|
||||
t2_done_cff_index( &subfont->local_subrs_index );
|
||||
FREE( subfont->local_subrs );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Load_CFF_Font( FT_Stream stream,
|
||||
FT_Int face_index,
|
||||
CFF_Font* font )
|
||||
{
|
||||
static const FT_Frame_Field cff_header_fields[] =
|
||||
{
|
||||
FT_FRAME_START( 4 ),
|
||||
FT_FRAME_BYTE( CFF_Font, version_major ),
|
||||
FT_FRAME_BYTE( CFF_Font, version_minor ),
|
||||
FT_FRAME_BYTE( CFF_Font, header_size ),
|
||||
FT_FRAME_BYTE( CFF_Font, absolute_offsize ),
|
||||
FT_FRAME_END
|
||||
};
|
||||
|
||||
FT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_ULong base_offset;
|
||||
CFF_Font_Dict* dict;
|
||||
|
||||
|
||||
MEM_Set( font, 0, sizeof ( *font ) );
|
||||
font->stream = stream;
|
||||
font->memory = memory;
|
||||
dict = &font->top_font.font_dict;
|
||||
base_offset = FILE_Pos();
|
||||
|
||||
/* read CFF font header */
|
||||
if ( READ_Fields( cff_header_fields, font ) )
|
||||
goto Exit;
|
||||
|
||||
/* check format */
|
||||
if ( font->version_major != 1 ||
|
||||
font->header_size < 4 ||
|
||||
font->absolute_offsize > 4 )
|
||||
{
|
||||
FT_TRACE2(( "[not a CFF font header!]\n" ));
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* skip the rest of the header */
|
||||
(void)FILE_Skip( font->header_size - 4 );
|
||||
|
||||
/* read the name, top dict, string and global subrs index */
|
||||
error = t2_new_cff_index( &font->name_index, stream, 0 ) ||
|
||||
t2_new_cff_index( &font->font_dict_index, stream, 0 ) ||
|
||||
t2_new_cff_index( &font->string_index, stream, 0 ) ||
|
||||
t2_new_cff_index( &font->global_subrs_index, stream, 1 );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* well, we don't really forget the `disabled' fonts... */
|
||||
font->num_faces = font->name_index.count;
|
||||
if ( face_index >= (FT_Int)font->num_faces )
|
||||
{
|
||||
FT_ERROR(( "T2_Load_CFF_Font: incorrect face index = %d\n",
|
||||
face_index ));
|
||||
error = T2_Err_Invalid_Argument;
|
||||
}
|
||||
|
||||
/* in case of a font format check, simply exit now */
|
||||
if ( face_index < 0 )
|
||||
goto Exit;
|
||||
|
||||
/* now, parse the top-level font dictionary */
|
||||
error = CFF_Load_SubFont( &font->top_font,
|
||||
&font->font_dict_index,
|
||||
face_index,
|
||||
stream,
|
||||
base_offset );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* now, check for a CID font */
|
||||
if ( dict->cid_registry )
|
||||
{
|
||||
CFF_Index fd_index;
|
||||
CFF_SubFont* sub;
|
||||
FT_UInt index;
|
||||
|
||||
|
||||
/* this is a CID-keyed font, we must now allocate a table of */
|
||||
/* sub-fonts, then load each of them separately */
|
||||
if ( FILE_Seek( base_offset + dict->cid_fd_array_offset ) )
|
||||
goto Exit;
|
||||
|
||||
error = t2_new_cff_index( &fd_index, stream, 0 );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
if ( fd_index.count > CFF_MAX_CID_FONTS )
|
||||
{
|
||||
FT_ERROR(( "T2_Load_CFF_Font: FD array too large in CID font\n" ));
|
||||
goto Fail_CID;
|
||||
}
|
||||
|
||||
/* allocate & read each font dict independently */
|
||||
font->num_subfonts = fd_index.count;
|
||||
if ( ALLOC_ARRAY( sub, fd_index.count, CFF_SubFont ) )
|
||||
goto Fail_CID;
|
||||
|
||||
/* setup pointer table */
|
||||
for ( index = 0; index < fd_index.count; index++ )
|
||||
font->subfonts[index] = sub + index;
|
||||
|
||||
/* now load each sub font independently */
|
||||
for ( index = 0; index < fd_index.count; index++ )
|
||||
{
|
||||
sub = font->subfonts[index];
|
||||
error = CFF_Load_SubFont( sub, &fd_index, index,
|
||||
stream, base_offset );
|
||||
if ( error )
|
||||
goto Fail_CID;
|
||||
}
|
||||
|
||||
/* now load the FD Select array */
|
||||
error = CFF_Load_FD_Select( &font->fd_select,
|
||||
dict->cid_count,
|
||||
stream,
|
||||
base_offset + dict->cid_fd_select_offset );
|
||||
|
||||
Fail_CID:
|
||||
t2_done_cff_index( &fd_index );
|
||||
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
else
|
||||
font->num_subfonts = 0;
|
||||
|
||||
/* read the charstrings index now */
|
||||
if ( dict->charstrings_offset == 0 )
|
||||
{
|
||||
FT_ERROR(( "T2_Load_CFF_Font: no charstrings offset!\n" ));
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ( FILE_Seek( base_offset + dict->charstrings_offset ) )
|
||||
goto Exit;
|
||||
|
||||
error = t2_new_cff_index( &font->charstrings_index, stream, 0 );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* explicit the global subrs */
|
||||
font->num_global_subrs = font->global_subrs_index.count;
|
||||
font->num_glyphs = font->charstrings_index.count;
|
||||
|
||||
error = t2_explicit_cff_index( &font->global_subrs_index,
|
||||
&font->global_subrs ) ;
|
||||
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* get the font name */
|
||||
font->font_name = T2_Get_Name( &font->name_index, face_index );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void T2_Done_CFF_Font( CFF_Font* font )
|
||||
{
|
||||
FT_Memory memory = font->memory;
|
||||
FT_UInt index;
|
||||
|
||||
|
||||
t2_done_cff_index( &font->global_subrs_index );
|
||||
t2_done_cff_index( &font->string_index );
|
||||
t2_done_cff_index( &font->font_dict_index );
|
||||
t2_done_cff_index( &font->name_index );
|
||||
t2_done_cff_index( &font->charstrings_index );
|
||||
|
||||
/* release font dictionaries */
|
||||
for ( index = 0; index < font->num_subfonts; index++ )
|
||||
CFF_Done_SubFont( memory, font->subfonts[index] );
|
||||
|
||||
CFF_Done_SubFont( memory, &font->top_font );
|
||||
|
||||
CFF_Done_FD_Select( &font->fd_select, font->stream );
|
||||
|
||||
FREE( font->global_subrs );
|
||||
FREE( font->font_name );
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
69
src/freetype/cff/t2load.h
Normal file
69
src/freetype/cff/t2load.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2load.h */
|
||||
/* */
|
||||
/* OpenType glyph data/program tables loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T2LOAD_H
|
||||
#define T2LOAD_H
|
||||
|
||||
#include <freetype/internal/t2types.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LOCAL_DEF
|
||||
FT_String* T2_Get_Name( CFF_Index* index,
|
||||
FT_UInt element );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_String* T2_Get_String( CFF_Index* index,
|
||||
FT_UInt sid,
|
||||
PSNames_Interface* interface );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Access_Element( CFF_Index* index,
|
||||
FT_UInt element,
|
||||
FT_Byte** pbytes,
|
||||
FT_ULong* pbyte_len );
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Forget_Element( CFF_Index* index,
|
||||
FT_Byte** pbytes );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Load_CFF_Font( FT_Stream stream,
|
||||
FT_Int face_index,
|
||||
CFF_Font* font );
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Done_CFF_Font( CFF_Font* font );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Byte CFF_Get_FD( CFF_FD_Select* select,
|
||||
FT_UInt glyph_index );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T2LOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
600
src/freetype/cff/t2objs.c
Normal file
600
src/freetype/cff/t2objs.c
Normal file
@@ -0,0 +1,600 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2objs.c */
|
||||
/* */
|
||||
/* OpenType objects manager (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftcalc.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/ttnameid.h>
|
||||
#include <freetype/tttags.h>
|
||||
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2objs.h"
|
||||
#include "t2load.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2objs.h>
|
||||
#include <cff/t2load.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/t2errors.h>
|
||||
|
||||
#include <string.h> /* for strlen() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* 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_t2objs
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FACE FUNCTIONS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
static
|
||||
FT_String* T2_StrCopy( FT_Memory memory,
|
||||
const FT_String* source )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_String* result = 0;
|
||||
FT_Int len = (FT_Int)strlen( source );
|
||||
|
||||
|
||||
if ( !ALLOC( result, len + 1 ) )
|
||||
{
|
||||
MEM_Copy( result, source, len );
|
||||
result[len] = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* this function is used to build a Unicode charmap from the glyph names */
|
||||
/* in a file */
|
||||
static
|
||||
FT_Error CFF_Build_Unicode_Charmap( T2_Face face,
|
||||
FT_ULong base_offset,
|
||||
PSNames_Interface* psnames )
|
||||
{
|
||||
CFF_Font* font = (CFF_Font*)face->extra.data;
|
||||
FT_Memory memory = FT_FACE_MEMORY(face);
|
||||
FT_UInt n, num_glyphs = face->root.num_glyphs;
|
||||
const char** glyph_names;
|
||||
FT_Error error;
|
||||
CFF_Font_Dict* dict = &font->top_font.font_dict;
|
||||
FT_ULong charset_offset;
|
||||
FT_Byte format;
|
||||
FT_Stream stream = face->root.stream;
|
||||
|
||||
|
||||
charset_offset = dict->charset_offset;
|
||||
if ( !charset_offset )
|
||||
{
|
||||
FT_ERROR(( "CFF.Build_Unicode_Charmap: charset table is missing\n" ));
|
||||
error = T2_Err_Invalid_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* allocate the charmap */
|
||||
if ( ALLOC( face->charmap, ...
|
||||
|
||||
/* seek to charset table and allocate glyph names table */
|
||||
if ( FILE_Seek( base_offset + charset_offset ) ||
|
||||
ALLOC_ARRAY( glyph_names, num_glyphs, const char* ) )
|
||||
goto Exit;
|
||||
|
||||
/* now, read each glyph name and store it in the glyph name table */
|
||||
if ( READ_Byte( format ) )
|
||||
goto Fail;
|
||||
|
||||
switch ( format )
|
||||
{
|
||||
case 0: /* format 0 - one SID per glyph */
|
||||
{
|
||||
const char** gname = glyph_names;
|
||||
const char** limit = gname + num_glyphs;
|
||||
|
||||
if ( ACCESS_Frame( num_glyphs*2 ) )
|
||||
goto Fail;
|
||||
|
||||
for ( ; gname < limit; gname++ )
|
||||
gname[0] = T2_Get_String( &font->string_index,
|
||||
GET_UShort(),
|
||||
psnames );
|
||||
FORGET_Frame();
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: /* format 1 - sequential ranges */
|
||||
case 2: /* format 2 - sequential ranges with 16-bit counts */
|
||||
{
|
||||
const char** gname = glyph_names;
|
||||
const char** limit = gname + num_glyphs;
|
||||
FT_UInt len = 3;
|
||||
|
||||
if (format == 2)
|
||||
len++;
|
||||
|
||||
while (gname < limit)
|
||||
{
|
||||
FT_UInt first;
|
||||
FT_UInt count;
|
||||
|
||||
if ( ACCESS_Frame( len ) )
|
||||
goto Fail;
|
||||
|
||||
first = GET_UShort();
|
||||
if (format == 3)
|
||||
count = GET_UShort();
|
||||
else
|
||||
count = GET_Byte();
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
for ( ; count > 0; count-- )
|
||||
{
|
||||
gname[0] = T2_Get_String( &font->string_index,
|
||||
first,
|
||||
psnames );
|
||||
gname++;
|
||||
first++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: /* unknown charset format! */
|
||||
FT_ERROR(( "CFF: unknown charset format!\n" ));
|
||||
error = T2_Err_Invalid_File_Format;
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
/* all right, the glyph names were loaded, we now need to create */
|
||||
/* the corresponding unicode charmap.. */
|
||||
|
||||
Fail:
|
||||
for ( n = 0; n < num_glyphs; n++ )
|
||||
FREE( glyph_names[n] );
|
||||
|
||||
FREE( glyph_names );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
static
|
||||
FT_Encoding find_encoding( int platform_id,
|
||||
int encoding_id )
|
||||
{
|
||||
typedef struct TEncoding
|
||||
{
|
||||
int platform_id;
|
||||
int encoding_id;
|
||||
FT_Encoding encoding;
|
||||
|
||||
} TEncoding;
|
||||
|
||||
static
|
||||
const TEncoding tt_encodings[] =
|
||||
{
|
||||
{ TT_PLATFORM_ISO, -1, ft_encoding_unicode },
|
||||
|
||||
{ TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode },
|
||||
|
||||
{ TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman },
|
||||
|
||||
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode },
|
||||
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis },
|
||||
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, ft_encoding_gb2312 },
|
||||
{ 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 }
|
||||
};
|
||||
|
||||
const TEncoding *cur, *limit;
|
||||
|
||||
|
||||
cur = tt_encodings;
|
||||
limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
|
||||
|
||||
for ( ; cur < limit; cur++ )
|
||||
{
|
||||
if ( cur->platform_id == platform_id )
|
||||
{
|
||||
if ( cur->encoding_id == encoding_id ||
|
||||
cur->encoding_id == -1 )
|
||||
return cur->encoding;
|
||||
}
|
||||
}
|
||||
|
||||
return ft_encoding_none;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T2_Init_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given OpenType face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: The source font stream. */
|
||||
/* */
|
||||
/* face_index :: The index of the font face in the resource. */
|
||||
/* */
|
||||
/* num_params :: Number of additional generic parameters. Ignored. */
|
||||
/* */
|
||||
/* params :: Additional generic parameters. Ignored. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: The newly built face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Init_Face( FT_Stream stream,
|
||||
T2_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
SFNT_Interface* sfnt;
|
||||
PSNames_Interface* psnames;
|
||||
FT_Bool pure_cff = 1;
|
||||
FT_Bool sfnt_format = 0;
|
||||
|
||||
|
||||
sfnt = (SFNT_Interface*)FT_Get_Module_Interface(
|
||||
face->root.driver->root.library, "sfnt" );
|
||||
if ( !sfnt )
|
||||
goto Bad_Format;
|
||||
|
||||
psnames = (PSNames_Interface*)FT_Get_Module_Interface(
|
||||
face->root.driver->root.library, "psnames" );
|
||||
|
||||
/* create input stream from resource */
|
||||
if ( FILE_Seek( 0 ) )
|
||||
goto Exit;
|
||||
|
||||
/* check that we have a valid OpenType file */
|
||||
error = sfnt->init_face( stream, face, face_index, num_params, params );
|
||||
if ( !error )
|
||||
{
|
||||
if ( face->format_tag != 0x4F54544FL ) /* `OTTO'; OpenType/CFF font */
|
||||
{
|
||||
FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
|
||||
goto Bad_Format;
|
||||
}
|
||||
|
||||
/* If we are performing a simple font format check, exit immediately */
|
||||
if ( face_index < 0 )
|
||||
return T2_Err_Ok;
|
||||
|
||||
sfnt_format = 1;
|
||||
|
||||
/* now, the font can be either an OpenType/CFF font, or a SVG CEF */
|
||||
/* font in the later case; it doesn't have a `head' table */
|
||||
error = face->goto_table( face, TTAG_head, stream, 0 );
|
||||
if ( !error )
|
||||
{
|
||||
pure_cff = 0;
|
||||
|
||||
/* Load font directory */
|
||||
error = sfnt->load_face( stream, face,
|
||||
face_index, num_params, params );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* load the `cmap' table by hand */
|
||||
error = sfnt->load_charmaps( face, stream );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* XXX: for now, we don't load the GPOS table, as OpenType Layout */
|
||||
/* support will be added later to FreeType 2 as a separate module */
|
||||
}
|
||||
|
||||
/* now, load the CFF part of the file */
|
||||
error = face->goto_table( face, TTAG_CFF, stream, 0 );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rewind to start of file; we are going to load a pure-CFF font */
|
||||
(void)FILE_Seek( 0 );
|
||||
error = FT_Err_Ok;
|
||||
}
|
||||
|
||||
/* now load and parse the CFF table in the file */
|
||||
{
|
||||
CFF_Font* cff;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Face root;
|
||||
FT_UInt flags;
|
||||
FT_ULong base_offset;
|
||||
|
||||
|
||||
if ( ALLOC( cff, sizeof ( *cff ) ) )
|
||||
goto Exit;
|
||||
|
||||
base_offset = FILE_Pos();
|
||||
|
||||
face->extra.data = cff;
|
||||
error = T2_Load_CFF_Font( stream, face_index, cff );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* Complement the root flags with some interesting information. */
|
||||
/* Note that this is only necessary for pure CFF and CEF fonts */
|
||||
|
||||
root = &face->root;
|
||||
if ( pure_cff )
|
||||
{
|
||||
CFF_Font_Dict* dict = &cff->top_font.font_dict;
|
||||
|
||||
|
||||
/* we need the `PSNames' module for pure-CFF and CEF formats */
|
||||
if ( !psnames )
|
||||
{
|
||||
FT_ERROR(( "T2_Init_Face:" ));
|
||||
FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
|
||||
FT_ERROR(( " " ));
|
||||
FT_ERROR(( " without the `PSNames' module\n" ));
|
||||
goto Bad_Format;
|
||||
}
|
||||
|
||||
/* compute number of glyphs */
|
||||
if ( dict->cid_registry )
|
||||
root->num_glyphs = dict->cid_count;
|
||||
else
|
||||
root->num_glyphs = cff->charstrings_index.count;
|
||||
|
||||
/* set global bbox, as well as EM size */
|
||||
root->units_per_EM = (FT_UInt)FT_DivFix( 1000L << 16,
|
||||
dict->font_matrix.yy ) >> 16;
|
||||
root->bbox = dict->font_bbox;
|
||||
root->ascender = (FT_Short)root->bbox.yMax;
|
||||
root->descender = (FT_Short)root->bbox.yMin;
|
||||
|
||||
/* retrieve font family & style name */
|
||||
root->family_name = T2_Get_Name( &cff->name_index, face_index );
|
||||
if ( dict->cid_registry )
|
||||
{
|
||||
root->style_name = T2_StrCopy( memory, "Regular" ); /* XXXX */
|
||||
}
|
||||
else
|
||||
{
|
||||
root->style_name = T2_Get_String( &cff->string_index,
|
||||
dict->weight,
|
||||
psnames );
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Compute face flags. */
|
||||
/* */
|
||||
flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
|
||||
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
|
||||
|
||||
if ( sfnt_format )
|
||||
flags |= FT_FACE_FLAG_SFNT;
|
||||
|
||||
/* fixed width font? */
|
||||
if ( dict->is_fixed_pitch )
|
||||
flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
||||
|
||||
/* XXXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
|
||||
#if 0
|
||||
/* kerning available? */
|
||||
if ( face->kern_pairs )
|
||||
flags |= FT_FACE_FLAG_KERNING;
|
||||
#endif
|
||||
|
||||
root->face_flags = flags;
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Compute style flags. */
|
||||
/* */
|
||||
flags = 0;
|
||||
|
||||
if ( dict->italic_angle )
|
||||
flags |= FT_STYLE_FLAG_ITALIC;
|
||||
|
||||
/* XXX: may not be correct */
|
||||
if ( cff->top_font.private_dict.force_bold )
|
||||
flags |= FT_STYLE_FLAG_BOLD;
|
||||
|
||||
root->style_flags = flags;
|
||||
|
||||
/* set the charmaps if any */
|
||||
if ( sfnt_format )
|
||||
{
|
||||
/*****************************************************************/
|
||||
/* */
|
||||
/* Polish the charmaps. */
|
||||
/* */
|
||||
/* Try to set the charmap encoding according to the platform & */
|
||||
/* encoding ID of each charmap. */
|
||||
/* */
|
||||
TT_CharMap charmap;
|
||||
FT_Int n;
|
||||
|
||||
|
||||
charmap = face->charmaps;
|
||||
root->num_charmaps = face->num_charmaps;
|
||||
|
||||
/* allocate table of pointers */
|
||||
if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) )
|
||||
goto Exit;
|
||||
|
||||
for ( n = 0; n < root->num_charmaps; n++, charmap++ )
|
||||
{
|
||||
FT_Int platform = charmap->cmap.platformID;
|
||||
FT_Int encoding = charmap->cmap.platformEncodingID;
|
||||
|
||||
|
||||
charmap->root.face = (FT_Face)face;
|
||||
charmap->root.platform_id = platform;
|
||||
charmap->root.encoding_id = encoding;
|
||||
charmap->root.encoding = find_encoding( platform, encoding );
|
||||
|
||||
/* now, set root->charmap with a unicode charmap */
|
||||
/* wherever available */
|
||||
if ( !root->charmap &&
|
||||
charmap->root.encoding == ft_encoding_unicode )
|
||||
root->charmap = (FT_CharMap)charmap;
|
||||
|
||||
root->charmaps[n] = (FT_CharMap)charmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Bad_Format:
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T2_Done_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A pointer to the face object to destroy. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
void T2_Done_Face( T2_Face face )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
||||
|
||||
|
||||
if ( sfnt )
|
||||
sfnt->done_face( face );
|
||||
|
||||
{
|
||||
CFF_Font* cff = (CFF_Font*)face->extra.data;
|
||||
|
||||
|
||||
if ( cff )
|
||||
{
|
||||
T2_Done_CFF_Font( cff );
|
||||
FREE( face->extra.data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T2_Init_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given OpenType driver object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target driver object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Init_Driver( T2_Driver driver )
|
||||
{
|
||||
/* init extension registry if needed */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
|
||||
return TT_Init_Extensions( driver );
|
||||
|
||||
#else
|
||||
|
||||
FT_UNUSED( driver );
|
||||
|
||||
return T2_Err_Ok;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T2_Done_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given OpenType driver. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target OpenType driver. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void T2_Done_Driver( T2_Driver driver )
|
||||
{
|
||||
/* destroy extensions registry if needed */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
|
||||
TT_Done_Extensions( driver );
|
||||
|
||||
#else
|
||||
|
||||
FT_UNUSED( driver );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
148
src/freetype/cff/t2objs.h
Normal file
148
src/freetype/cff/t2objs.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2objs.h */
|
||||
/* */
|
||||
/* OpenType objects manager (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T2OBJS_H
|
||||
#define T2OBJS_H
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/internal/t2types.h>
|
||||
#include <freetype/internal/t2errors.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T2_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an OpenType driver object. */
|
||||
/* */
|
||||
typedef struct T2_DriverRec_* T2_Driver;
|
||||
|
||||
typedef TT_Face T2_Face;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T2_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an OpenType size object. */
|
||||
/* */
|
||||
typedef FT_Size T2_Size;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T2_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an OpenType glyph slot object. */
|
||||
/* */
|
||||
typedef struct T2_GlyphSlotRec_
|
||||
{
|
||||
FT_GlyphSlotRec root;
|
||||
|
||||
FT_Bool hint;
|
||||
FT_Bool scaled;
|
||||
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
|
||||
} T2_GlyphSlotRec, *T2_GlyphSlot;
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Subglyph transformation record. */
|
||||
/* */
|
||||
typedef struct T2_Transform_
|
||||
{
|
||||
FT_Fixed xx, xy; /* transformation matrix coefficients */
|
||||
FT_Fixed yx, yy;
|
||||
FT_F26Dot6 ox, oy; /* offsets */
|
||||
|
||||
} T2_Transform;
|
||||
|
||||
|
||||
/* this is only used in the case of a pure CFF font with no charmap */
|
||||
typedef struct T2_CharMapRec_
|
||||
{
|
||||
TT_CharMapRec root;
|
||||
PS_Unicodes unicodes;
|
||||
|
||||
} T2_CharMapRec, *T2_CharMap;
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/* */
|
||||
/* TrueType driver class. */
|
||||
/* */
|
||||
typedef struct T2_DriverRec_
|
||||
{
|
||||
FT_DriverRec root;
|
||||
|
||||
void* extension_component;
|
||||
|
||||
} T2_DriverRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Face functions */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Init_Face( FT_Stream stream,
|
||||
T2_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Done_Face( T2_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Driver functions */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Init_Driver( T2_Driver driver );
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Done_Driver( T2_Driver driver );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T2OBJS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
641
src/freetype/cff/t2parse.c
Normal file
641
src/freetype/cff/t2parse.c
Normal file
@@ -0,0 +1,641 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2parse.c */
|
||||
/* */
|
||||
/* OpenType parser (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2parse.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2parse.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/t2errors.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_t2parse
|
||||
|
||||
|
||||
#define T2_Err_Stack_Underflow FT_Err_Invalid_Argument
|
||||
#define T2_Err_Syntax_Error FT_Err_Invalid_Argument
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
t2_kind_none = 0,
|
||||
t2_kind_num,
|
||||
t2_kind_fixed,
|
||||
t2_kind_string,
|
||||
t2_kind_bool,
|
||||
t2_kind_delta,
|
||||
t2_kind_callback,
|
||||
|
||||
t2_kind_max /* do not remove */
|
||||
};
|
||||
|
||||
|
||||
/* now generate handlers for the most simple fields */
|
||||
typedef FT_Error (*T2_Field_Reader)( T2_Parser* parser );
|
||||
|
||||
typedef struct T2_Field_Handler_
|
||||
{
|
||||
int kind;
|
||||
int code;
|
||||
FT_UInt offset;
|
||||
FT_Byte size;
|
||||
T2_Field_Reader reader;
|
||||
FT_UInt array_max;
|
||||
FT_UInt count_offset;
|
||||
|
||||
} T2_Field_Handler;
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void T2_Parser_Init( T2_Parser* parser,
|
||||
FT_UInt code,
|
||||
void* object )
|
||||
{
|
||||
MEM_Set( parser, 0, sizeof ( *parser ) );
|
||||
|
||||
parser->top = parser->stack;
|
||||
parser->object_code = code;
|
||||
parser->object = object;
|
||||
}
|
||||
|
||||
|
||||
/* reads an integer */
|
||||
static
|
||||
FT_Long parse_t2_integer( FT_Byte* start,
|
||||
FT_Byte* limit )
|
||||
{
|
||||
FT_Byte* p = start;
|
||||
FT_Int v = *p++;
|
||||
FT_Long val = 0;
|
||||
|
||||
|
||||
if ( v == 28 )
|
||||
{
|
||||
if ( p + 2 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = (FT_Short)( ( (FT_Int)p[0] << 8 ) | p[1] );
|
||||
p += 2;
|
||||
}
|
||||
else if ( v == 29 )
|
||||
{
|
||||
if ( p + 4 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = ( (FT_Long)p[0] << 24 ) |
|
||||
( (FT_Long)p[1] << 16 ) |
|
||||
( (FT_Long)p[2] << 8 ) |
|
||||
p[3];
|
||||
p += 4;
|
||||
}
|
||||
else if ( v < 247 )
|
||||
{
|
||||
val = v - 139;
|
||||
}
|
||||
else if ( v < 251 )
|
||||
{
|
||||
if ( p + 1 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = ( v - 247 ) * 256 + p[0] + 108;
|
||||
p++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( p + 1 > limit )
|
||||
goto Bad;
|
||||
|
||||
val = -( v - 251 ) * 256 - p[0] - 108;
|
||||
p++;
|
||||
}
|
||||
|
||||
Exit:
|
||||
return val;
|
||||
|
||||
Bad:
|
||||
val = 0;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
/* read a real */
|
||||
static
|
||||
FT_Fixed parse_t2_real( FT_Byte* start,
|
||||
FT_Byte* limit,
|
||||
FT_Int power_ten )
|
||||
{
|
||||
FT_Byte* p = start;
|
||||
FT_Long num, divider, result, exp;
|
||||
FT_Int sign = 0, exp_sign = 0;
|
||||
FT_Byte nib;
|
||||
FT_Byte phase;
|
||||
|
||||
|
||||
result = 0;
|
||||
num = 0;
|
||||
divider = 1;
|
||||
|
||||
/* first of all, read the integer part */
|
||||
phase = 4;
|
||||
p--;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* read one nibble at a time */
|
||||
if ( phase && ++p >= limit )
|
||||
goto Bad;
|
||||
|
||||
nib = ( p[0] >> phase ) & 0xF;
|
||||
phase = 4 - phase;
|
||||
|
||||
if ( nib == 0xE )
|
||||
sign = 1;
|
||||
else if ( nib > 9 )
|
||||
break;
|
||||
else
|
||||
result = result * 10 + nib;
|
||||
}
|
||||
|
||||
/* read decimal part, if any */
|
||||
if ( nib == 0xa )
|
||||
for (;;)
|
||||
{
|
||||
/* read one nibble at a time */
|
||||
if ( !phase && ++p >= limit )
|
||||
goto Bad;
|
||||
|
||||
phase = 4 - phase;
|
||||
nib = ( p[0] >> phase ) & 0xF;
|
||||
|
||||
if ( nib >= 10 )
|
||||
break;
|
||||
|
||||
if (divider < 10000000L)
|
||||
{
|
||||
num = num * 10 + nib;
|
||||
divider *= 10;
|
||||
}
|
||||
}
|
||||
|
||||
/* read exponent, if any */
|
||||
if ( nib == 12 )
|
||||
{
|
||||
exp_sign = 1;
|
||||
nib = 11;
|
||||
}
|
||||
|
||||
if ( nib == 11 )
|
||||
{
|
||||
exp = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* read one nibble at a time */
|
||||
if ( !phase && ++p >= limit )
|
||||
goto Bad;
|
||||
|
||||
phase = 4 - phase;
|
||||
nib = ( p[0] >> phase ) & 0xF;
|
||||
|
||||
if ( nib >= 10 )
|
||||
break;
|
||||
|
||||
exp = exp * 10 + nib;
|
||||
}
|
||||
|
||||
if ( exp_sign )
|
||||
exp = -exp;
|
||||
|
||||
power_ten += exp;
|
||||
}
|
||||
|
||||
/* raise to power of ten if needed */
|
||||
while ( power_ten > 0 )
|
||||
{
|
||||
result = result * 10;
|
||||
num = num * 10;
|
||||
|
||||
power_ten--;
|
||||
}
|
||||
|
||||
while ( power_ten < 0 )
|
||||
{
|
||||
result = result / 10;
|
||||
divider = divider * 10;
|
||||
|
||||
power_ten++;
|
||||
}
|
||||
|
||||
if ( num )
|
||||
result += FT_DivFix( num, divider );
|
||||
|
||||
if ( sign )
|
||||
result = -result;
|
||||
|
||||
Exit:
|
||||
return result;
|
||||
|
||||
Bad:
|
||||
result = 0;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
/* read a number, either integer or real */
|
||||
static
|
||||
FT_Long t2_parse_num( FT_Byte** d )
|
||||
{
|
||||
return ( **d == 30 ? ( parse_t2_real( d[0], d[1], 0 ) >> 16 )
|
||||
: parse_t2_integer( d[0], d[1] ) );
|
||||
}
|
||||
|
||||
|
||||
/* reads a floating point number, either integer or real */
|
||||
static
|
||||
FT_Fixed t2_parse_fixed( FT_Byte** d )
|
||||
{
|
||||
return ( **d == 30 ? parse_t2_real( d[0], d[1], 0 )
|
||||
: parse_t2_integer( d[0], d[1] ) << 16 );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_matrix( T2_Parser* parser )
|
||||
{
|
||||
CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object;
|
||||
FT_Matrix* matrix = &dict->font_matrix;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
|
||||
if ( parser->top >= parser->stack + 4 )
|
||||
{
|
||||
matrix->xx = t2_parse_fixed( data++ );
|
||||
matrix->yx = t2_parse_fixed( data++ );
|
||||
matrix->xy = t2_parse_fixed( data++ );
|
||||
matrix->yy = t2_parse_fixed( data );
|
||||
error = T2_Err_Ok;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_bbox( T2_Parser* parser )
|
||||
{
|
||||
CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object;
|
||||
FT_BBox* bbox = &dict->font_bbox;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
|
||||
if ( parser->top >= parser->stack + 4 )
|
||||
{
|
||||
bbox->xMin = t2_parse_num( data++ );
|
||||
bbox->yMin = t2_parse_num( data++ );
|
||||
bbox->xMax = t2_parse_num( data++ );
|
||||
bbox->yMax = t2_parse_num( data );
|
||||
error = T2_Err_Ok;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_private_dict( T2_Parser* parser )
|
||||
{
|
||||
CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
|
||||
if ( parser->top >= parser->stack + 2 )
|
||||
{
|
||||
dict->private_size = t2_parse_num( data++ );
|
||||
dict->private_offset = t2_parse_num( data );
|
||||
error = T2_Err_Ok;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_cid_ros( T2_Parser* parser )
|
||||
{
|
||||
CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object;
|
||||
FT_Byte** data = parser->stack;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = T2_Err_Stack_Underflow;
|
||||
|
||||
if ( parser->top >= parser->stack + 3 )
|
||||
{
|
||||
dict->cid_registry = (FT_UInt)t2_parse_num( data++ );
|
||||
dict->cid_ordering = (FT_UInt)t2_parse_num( data++ );
|
||||
dict->cid_supplement = (FT_ULong)t2_parse_num( data );
|
||||
error = T2_Err_Ok;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#define T2_FIELD_NUM( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_num )
|
||||
#define T2_FIELD_FIXED( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_fixed )
|
||||
#define T2_FIELD_STRING( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_string )
|
||||
#define T2_FIELD_BOOL( code, name ) \
|
||||
T2_FIELD( code, name, t2_kind_bool )
|
||||
#define T2_FIELD_DELTA( code, name,max ) \
|
||||
T2_FIELD( code, name, t2_kind_delta )
|
||||
|
||||
#define T2_REF( s, f ) ( ((s*)0)->f )
|
||||
|
||||
#define T2_FIELD_CALLBACK( code, name ) \
|
||||
{ \
|
||||
t2_kind_callback, \
|
||||
code | T2CODE, \
|
||||
0, 0, \
|
||||
parse_ ## name, \
|
||||
0, 0 \
|
||||
},
|
||||
|
||||
#undef T2_FIELD
|
||||
#define T2_FIELD( code, name, kind ) \
|
||||
{ \
|
||||
kind, \
|
||||
code | T2CODE, \
|
||||
(FT_UInt)(char*)&T2_REF( T2TYPE, name ), \
|
||||
sizeof( T2_REF( T2TYPE, name ) ), \
|
||||
0, 0, 0 \
|
||||
},
|
||||
|
||||
#undef T2_FIELD_DELTA
|
||||
#define T2_FIELD_DELTA( code, name, max ) \
|
||||
{ \
|
||||
t2_kind_delta, \
|
||||
code | T2CODE, \
|
||||
(FT_UInt)(char*)&T2_REF( T2TYPE, name ), \
|
||||
sizeof( T2_REF( T2TYPE, name )[0] ), \
|
||||
0, \
|
||||
max, \
|
||||
(FT_UInt)(char*)&T2_REF( T2TYPE, num_ ## name ) \
|
||||
},
|
||||
|
||||
#define T2CODE_TOPDICT 0x1000
|
||||
#define T2CODE_PRIVATE 0x2000
|
||||
|
||||
static const T2_Field_Handler t2_field_handlers[] =
|
||||
{
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t2tokens.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cff/t2tokens.h>
|
||||
|
||||
#endif
|
||||
|
||||
{ 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error T2_Parser_Run( T2_Parser* parser,
|
||||
FT_Byte* start,
|
||||
FT_Byte* limit )
|
||||
{
|
||||
FT_Byte* p = start;
|
||||
FT_Error error = T2_Err_Ok;
|
||||
|
||||
|
||||
parser->top = parser->stack;
|
||||
parser->start = start;
|
||||
parser->limit = limit;
|
||||
parser->cursor = start;
|
||||
|
||||
while ( p < limit )
|
||||
{
|
||||
FT_Byte v = *p;
|
||||
|
||||
|
||||
if ( v >= 27 && v != 31 )
|
||||
{
|
||||
/* it's a number; we will push its position on the stack */
|
||||
if ( parser->top - parser->stack >= T2_MAX_STACK_DEPTH )
|
||||
goto Stack_Overflow;
|
||||
|
||||
*parser->top ++ = p;
|
||||
|
||||
/* now, skip it */
|
||||
if ( v == 30 )
|
||||
{
|
||||
/* skip real number */
|
||||
for (;;)
|
||||
{
|
||||
if ( p >= limit )
|
||||
goto Syntax_Error;
|
||||
v = p[0] >> 4;
|
||||
if ( v == 15 )
|
||||
break;
|
||||
v = p[0] & 0xF;
|
||||
if ( v == 15 )
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else if ( v == 28 )
|
||||
p += 2;
|
||||
else if ( v == 29 )
|
||||
p += 4;
|
||||
else if ( v > 246 )
|
||||
p += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is not a number, hence it's an operator. Compute its code */
|
||||
/* and look for it in our current list. */
|
||||
|
||||
FT_UInt code;
|
||||
FT_UInt num_args = (FT_UInt)
|
||||
( parser->top - parser->stack );
|
||||
const T2_Field_Handler* field;
|
||||
|
||||
|
||||
/* first of all, a trivial check */
|
||||
if ( num_args < 1 )
|
||||
goto Stack_Underflow;
|
||||
|
||||
*parser->top = p;
|
||||
code = v;
|
||||
if ( v == 12 )
|
||||
{
|
||||
/* two byte operator */
|
||||
p++;
|
||||
code = 0x100 | p[0];
|
||||
}
|
||||
code = code | parser->object_code;
|
||||
|
||||
for ( field = t2_field_handlers; field->kind; field++ )
|
||||
{
|
||||
if ( field->code == (FT_Int)code )
|
||||
{
|
||||
/* we found our field's handler; read it */
|
||||
FT_Long val;
|
||||
FT_Byte* q = (FT_Byte*)parser->object + field->offset;
|
||||
|
||||
|
||||
switch ( field->kind )
|
||||
{
|
||||
case t2_kind_bool:
|
||||
case t2_kind_string:
|
||||
case t2_kind_num:
|
||||
val = t2_parse_num( parser->stack );
|
||||
goto Store_Number;
|
||||
|
||||
case t2_kind_fixed:
|
||||
val = t2_parse_fixed( parser->stack );
|
||||
|
||||
Store_Number:
|
||||
switch ( field->size )
|
||||
{
|
||||
case 1:
|
||||
*(FT_Byte*)q = (FT_Byte)val;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(FT_Short*)q = (FT_Short)val;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(FT_Int32*)q = (FT_Int)val;
|
||||
break;
|
||||
|
||||
default: /* for 64-bit systems where long is 8 bytes */
|
||||
*(FT_Long*)q = val;
|
||||
}
|
||||
break;
|
||||
|
||||
case t2_kind_delta:
|
||||
{
|
||||
FT_Byte* qcount = (FT_Byte*)parser->object +
|
||||
field->count_offset;
|
||||
|
||||
FT_Long val;
|
||||
FT_Byte** data = parser->stack;
|
||||
|
||||
|
||||
if ( num_args > field->array_max )
|
||||
num_args = field->array_max;
|
||||
|
||||
/* store count */
|
||||
*qcount = (FT_Byte)num_args;
|
||||
|
||||
val = 0;
|
||||
while ( num_args > 0 )
|
||||
{
|
||||
val += t2_parse_num( data++ );
|
||||
switch ( field->size )
|
||||
{
|
||||
case 1:
|
||||
*(FT_Byte*)q = (FT_Byte)val;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(FT_Short*)q = (FT_Short)val;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(FT_Int32*)q = (FT_Int)val;
|
||||
break;
|
||||
|
||||
default: /* for 64-bit systems */
|
||||
*(FT_Long*)q = val;
|
||||
}
|
||||
|
||||
q += field->size;
|
||||
num_args--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* callback */
|
||||
error = field->reader( parser );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
goto Found;
|
||||
}
|
||||
}
|
||||
|
||||
/* this is an unknown operator, or it is unsupported; */
|
||||
/* we will ignore it for now. */
|
||||
|
||||
Found:
|
||||
/* clear stack */
|
||||
parser->top = parser->stack;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Stack_Overflow:
|
||||
error = T2_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
|
||||
Stack_Underflow:
|
||||
error = T2_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
|
||||
Syntax_Error:
|
||||
error = T2_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
70
src/freetype/cff/t2parse.h
Normal file
70
src/freetype/cff/t2parse.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2parse.h */
|
||||
/* */
|
||||
/* OpenType parser (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T2PARSE_H
|
||||
#define T2PARSE_H
|
||||
|
||||
#include <freetype/internal/t2types.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
#define T2_MAX_STACK_DEPTH 96
|
||||
|
||||
#define T2CODE_TOPDICT 0x1000
|
||||
#define T2CODE_PRIVATE 0x2000
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct T2_Parser_
|
||||
{
|
||||
FT_Byte* start;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* cursor;
|
||||
|
||||
FT_Byte* stack[T2_MAX_STACK_DEPTH + 1];
|
||||
FT_Byte** top;
|
||||
|
||||
FT_UInt object_code;
|
||||
void* object;
|
||||
|
||||
} T2_Parser;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void T2_Parser_Init( T2_Parser* parser,
|
||||
FT_UInt code,
|
||||
void* object );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T2_Parser_Run( T2_Parser* parser,
|
||||
FT_Byte* start,
|
||||
FT_Byte* limit );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T2PARSE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
96
src/freetype/cff/t2tokens.h
Normal file
96
src/freetype/cff/t2tokens.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2tokens.h */
|
||||
/* */
|
||||
/* OpenType token definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#undef T2TYPE
|
||||
#undef T2CODE
|
||||
#define T2TYPE CFF_Font_Dict
|
||||
#define T2CODE T2CODE_TOPDICT
|
||||
|
||||
T2_FIELD_STRING ( 0, version )
|
||||
T2_FIELD_STRING ( 1, notice )
|
||||
T2_FIELD_STRING ( 0x100, copyright )
|
||||
T2_FIELD_STRING ( 2, full_name )
|
||||
T2_FIELD_STRING ( 3, family_name )
|
||||
T2_FIELD_STRING ( 4, weight )
|
||||
T2_FIELD_BOOL ( 0x101, is_fixed_pitch )
|
||||
T2_FIELD_FIXED ( 0x102, italic_angle )
|
||||
T2_FIELD_NUM ( 0x103, underline_position )
|
||||
T2_FIELD_NUM ( 0x104, underline_thickness )
|
||||
T2_FIELD_NUM ( 0x105, paint_type )
|
||||
T2_FIELD_NUM ( 0x106, charstring_type )
|
||||
T2_FIELD_CALLBACK( 0x107, font_matrix )
|
||||
T2_FIELD_NUM ( 13, unique_id )
|
||||
T2_FIELD_CALLBACK( 5, font_bbox )
|
||||
T2_FIELD_NUM ( 0x108, stroke_width )
|
||||
T2_FIELD_NUM ( 15, charset_offset )
|
||||
T2_FIELD_NUM ( 16, encoding_offset )
|
||||
T2_FIELD_NUM ( 17, charstrings_offset )
|
||||
T2_FIELD_CALLBACK( 18, private_dict )
|
||||
T2_FIELD_NUM ( 0x114, synthetic_base )
|
||||
T2_FIELD_STRING ( 0x115, postscript )
|
||||
T2_FIELD_STRING ( 0x116, base_font_name )
|
||||
|
||||
#if 0
|
||||
T2_FIELD_DELTA ( 0x117, base_font_blend, 16 )
|
||||
T2_FIELD_CALLBACK( 0x118, multiple_master )
|
||||
T2_FIELD_CALLBACK( 0x119, blend_axit_types )
|
||||
#endif
|
||||
|
||||
T2_FIELD_CALLBACK( 0x11E, cid_ros )
|
||||
T2_FIELD_NUM ( 0x11F, cid_font_version )
|
||||
T2_FIELD_NUM ( 0x120, cid_font_revision )
|
||||
T2_FIELD_NUM ( 0x121, cid_font_type )
|
||||
T2_FIELD_NUM ( 0x122, cid_count )
|
||||
T2_FIELD_NUM ( 0x123, cid_uid_base )
|
||||
T2_FIELD_NUM ( 0x124, cid_fd_array_offset )
|
||||
T2_FIELD_NUM ( 0x125, cid_fd_select_offset )
|
||||
T2_FIELD_STRING ( 0x126, cid_font_name )
|
||||
|
||||
#if 0
|
||||
T2_FIELD_NUM ( 0x127, chameleon )
|
||||
#endif
|
||||
|
||||
|
||||
#undef T2TYPE
|
||||
#undef T2CODE
|
||||
#define T2TYPE CFF_Private
|
||||
#define T2CODE T2CODE_PRIVATE
|
||||
|
||||
T2_FIELD_DELTA( 6, blue_values, 14 )
|
||||
T2_FIELD_DELTA( 7, other_blues, 10 )
|
||||
T2_FIELD_DELTA( 8, family_blues, 14 )
|
||||
T2_FIELD_DELTA( 9, family_other_blues, 10 )
|
||||
T2_FIELD_FIXED( 0x109, blue_scale )
|
||||
T2_FIELD_NUM ( 0x10A, blue_shift )
|
||||
T2_FIELD_NUM ( 0x10B, blue_fuzz )
|
||||
T2_FIELD_NUM ( 10, standard_width )
|
||||
T2_FIELD_NUM ( 11, standard_height )
|
||||
T2_FIELD_DELTA( 0x10C, snap_widths, 13 )
|
||||
T2_FIELD_DELTA( 0x10D, snap_heights, 13 )
|
||||
T2_FIELD_BOOL ( 0x10E, force_bold )
|
||||
T2_FIELD_FIXED( 0x10F, force_bold_threshold )
|
||||
T2_FIELD_NUM ( 0x110, lenIV )
|
||||
T2_FIELD_NUM ( 0x111, language_group )
|
||||
T2_FIELD_FIXED( 0x112, expansion_factor )
|
||||
T2_FIELD_NUM ( 0x113, initial_random_seed )
|
||||
T2_FIELD_NUM ( 19, local_subrs_offset )
|
||||
T2_FIELD_NUM ( 20, default_width )
|
||||
T2_FIELD_NUM ( 21, nominal_width )
|
||||
|
||||
|
||||
/* END */
|
||||
293
src/freetype/cid/cidafm.c
Normal file
293
src/freetype/cid/cidafm.c
Normal file
@@ -0,0 +1,293 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidafm.c */
|
||||
/* */
|
||||
/* AFM support for CID-keyed fonts (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidafm.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidafm.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/t1types.h>
|
||||
#include <freetype/internal/t1errors.h>
|
||||
|
||||
#include <stdlib.h> /* for qsort() */
|
||||
#include <string.h> /* for strcmp() */
|
||||
#include <ctype.h> /* for isalnum() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* 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_cidafm
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void CID_Done_AFM( FT_Memory memory,
|
||||
CID_AFM* afm )
|
||||
{
|
||||
FREE( afm->kern_pairs );
|
||||
afm->num_pairs = 0;
|
||||
}
|
||||
|
||||
|
||||
#undef IS_KERN_PAIR
|
||||
#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' )
|
||||
|
||||
#define IS_ALPHANUM( c ) ( isalnum( c ) || \
|
||||
c == '_' || \
|
||||
c == '.' )
|
||||
|
||||
|
||||
/* read a glyph name and return the equivalent glyph index */
|
||||
static
|
||||
FT_UInt afm_atoindex( FT_Byte** start,
|
||||
FT_Byte* limit,
|
||||
T1_Font* type1 )
|
||||
{
|
||||
FT_Byte* p = *start;
|
||||
FT_Int len;
|
||||
FT_UInt result = 0;
|
||||
char temp[64];
|
||||
|
||||
|
||||
/* skip whitespace */
|
||||
while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) &&
|
||||
p < limit )
|
||||
p++;
|
||||
*start = p;
|
||||
|
||||
/* now, read glyph name */
|
||||
while ( IS_ALPHANUM( *p ) && p < limit )
|
||||
p++;
|
||||
|
||||
len = p - *start;
|
||||
|
||||
if ( len > 0 && len < 64 )
|
||||
{
|
||||
FT_Int n;
|
||||
|
||||
|
||||
/* copy glyph name to intermediate array */
|
||||
MEM_Copy( temp, *start, len );
|
||||
temp[len] = 0;
|
||||
|
||||
/* lookup glyph name in face array */
|
||||
for ( n = 0; n < type1->num_glyphs; n++ )
|
||||
{
|
||||
char* gname = (char*)type1->glyph_names[n];
|
||||
|
||||
|
||||
if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 )
|
||||
{
|
||||
result = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*start = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* read an integer */
|
||||
static
|
||||
int afm_atoi( FT_Byte** start,
|
||||
FT_Byte* limit )
|
||||
{
|
||||
FT_Byte* p = *start;
|
||||
int sum = 0;
|
||||
int sign = 1;
|
||||
|
||||
|
||||
/* skip everything that is not a number */
|
||||
while ( p < limit && !isdigit( *p ) )
|
||||
{
|
||||
sign = 1;
|
||||
if ( *p == '-' )
|
||||
sign = -1;
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
while ( p < limit && isdigit( *p ) )
|
||||
{
|
||||
sum = sum * 10 + ( *p - '0' );
|
||||
p++;
|
||||
}
|
||||
*start = p;
|
||||
|
||||
return sum * sign;
|
||||
}
|
||||
|
||||
|
||||
#undef KERN_INDEX
|
||||
#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
|
||||
|
||||
|
||||
/* compare two kerning pairs */
|
||||
static
|
||||
int compare_kern_pairs( const void* a,
|
||||
const void* b )
|
||||
{
|
||||
CID_Kern_Pair* pair1 = (CID_Kern_Pair*)a;
|
||||
CID_Kern_Pair* pair2 = (CID_Kern_Pair*)b;
|
||||
|
||||
FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 );
|
||||
FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 );
|
||||
|
||||
|
||||
return ( index1 - index2 );
|
||||
}
|
||||
|
||||
|
||||
/* parse an AFM file -- for now, only read the kerning pairs */
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Read_AFM( FT_Face cid_face,
|
||||
FT_Stream stream )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Memory memory = stream->memory;
|
||||
FT_Byte* start;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* p;
|
||||
FT_Int count = 0;
|
||||
CID_Kern_Pair* pair;
|
||||
T1_Font* type1 = &((T1_Face)t1_face)->type1;
|
||||
CID_AFM* afm = 0;
|
||||
|
||||
|
||||
if ( ACCESS_Frame( stream->size ) )
|
||||
return error;
|
||||
|
||||
start = (FT_Byte*)stream->cursor;
|
||||
limit = (FT_Byte*)stream->limit;
|
||||
p = start;
|
||||
|
||||
/* we are now going to count the occurrences of `KP' or `KPX' in */
|
||||
/* the AFM file. */
|
||||
count = 0;
|
||||
for ( p = start; p < limit - 3; p++ )
|
||||
{
|
||||
if ( IS_KERN_PAIR( p ) )
|
||||
count++;
|
||||
}
|
||||
|
||||
/* Actually, kerning pairs are simply optional! */
|
||||
if ( count == 0 )
|
||||
goto Exit;
|
||||
|
||||
/* allocate the pairs */
|
||||
if ( ALLOC( afm, sizeof ( *afm ) ) ||
|
||||
ALLOC_ARRAY( afm->kern_pairs, count, CID_Kern_Pair ) )
|
||||
goto Exit;
|
||||
|
||||
/* now, read each kern pair */
|
||||
pair = afm->kern_pairs;
|
||||
afm->num_pairs = count;
|
||||
|
||||
/* save in face object */
|
||||
((T1_Face)t1_face)->afm_data = afm;
|
||||
|
||||
for ( p = start; p < limit - 3; p++ )
|
||||
{
|
||||
if ( IS_KERN_PAIR( p ) )
|
||||
{
|
||||
FT_Byte* q;
|
||||
|
||||
|
||||
/* skip keyword (`KP' or `KPX') */
|
||||
q = p + 2;
|
||||
if ( *q == 'X' )
|
||||
q++;
|
||||
|
||||
pair->glyph1 = afm_atoindex( &q, limit, type1 );
|
||||
pair->glyph2 = afm_atoindex( &q, limit, type1 );
|
||||
pair->kerning.x = afm_atoi( &q, limit );
|
||||
|
||||
pair->kerning.y = 0;
|
||||
if ( p[2] != 'X' )
|
||||
pair->kerning.y = afm_atoi( &q, limit );
|
||||
|
||||
pair++;
|
||||
}
|
||||
}
|
||||
|
||||
/* now, sort the kern pairs according to their glyph indices */
|
||||
qsort( afm->kern_pairs, count, sizeof ( CID_Kern_Pair ),
|
||||
compare_kern_pairs );
|
||||
|
||||
Exit:
|
||||
if ( error )
|
||||
FREE( afm );
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* find the kerning for a given glyph pair */
|
||||
LOCAL_FUNC
|
||||
void CID_Get_Kerning( CID_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
CID_Kern_Pair *min, *mid, *max;
|
||||
FT_ULong index = KERN_INDEX( glyph1, glyph2 );
|
||||
|
||||
|
||||
/* simple binary search */
|
||||
min = afm->kern_pairs;
|
||||
max = min + afm->num_pairs - 1;
|
||||
|
||||
while ( min <= max )
|
||||
{
|
||||
FT_ULong midi;
|
||||
|
||||
|
||||
mid = min + ( max - min ) / 2;
|
||||
midi = KERN_INDEX( mid->glyph1, mid->glyph2 );
|
||||
if ( midi == index )
|
||||
{
|
||||
*kerning = mid->kerning;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( midi < index )
|
||||
min = mid + 1;
|
||||
else
|
||||
max = mid - 1;
|
||||
}
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
78
src/freetype/cid/cidafm.h
Normal file
78
src/freetype/cid/cidafm.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidafm.h */
|
||||
/* */
|
||||
/* AFM support for CID-keyed fonts (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDAFM_H
|
||||
#define CIDAFM_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidobjs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidobjs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CID_Kern_Pair_
|
||||
{
|
||||
FT_UInt glyph1;
|
||||
FT_UInt glyph2;
|
||||
FT_Vector kerning;
|
||||
|
||||
} CID_Kern_Pair;
|
||||
|
||||
typedef struct CID_AFM_
|
||||
{
|
||||
FT_UInt num_pairs;
|
||||
CID_Kern_Pair* kern_pairs;
|
||||
|
||||
} CID_AFM;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Read_AFM( FT_Face cid_face,
|
||||
FT_Stream stream );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_AFM( FT_Memory memory,
|
||||
CID_AFM* afm );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Get_Kerning( CID_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDAFM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
1558
src/freetype/cid/cidgload.c
Normal file
1558
src/freetype/cid/cidgload.c
Normal file
File diff suppressed because it is too large
Load Diff
198
src/freetype/cid/cidgload.h
Normal file
198
src/freetype/cid/cidgload.h
Normal file
@@ -0,0 +1,198 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidgload.h */
|
||||
/* */
|
||||
/* OpenType Glyph Loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDGLOAD_H
|
||||
#define CIDGLOAD_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidobjs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidobjs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> */
|
||||
/* CID_Builder */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used during glyph loading to store its outline. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* memory :: The current memory object. */
|
||||
/* */
|
||||
/* face :: The current face object. */
|
||||
/* */
|
||||
/* glyph :: The current glyph slot. */
|
||||
/* */
|
||||
/* current :: The current glyph outline. */
|
||||
/* */
|
||||
/* base :: The base glyph outline. */
|
||||
/* */
|
||||
/* max_points :: maximum points in builder outline */
|
||||
/* */
|
||||
/* max_contours :: Maximal number of contours in builder outline. */
|
||||
/* */
|
||||
/* last :: The last point position. */
|
||||
/* */
|
||||
/* scale_x :: The horizontal scale (FUnits to sub-pixels). */
|
||||
/* */
|
||||
/* scale_y :: The vertical scale (FUnits to sub-pixels). */
|
||||
/* */
|
||||
/* pos_x :: The horizontal translation (if composite glyph). */
|
||||
/* */
|
||||
/* pos_y :: The vertical translation (if composite glyph). */
|
||||
/* */
|
||||
/* left_bearing :: The left side bearing point. */
|
||||
/* */
|
||||
/* advance :: The horizontal advance vector. */
|
||||
/* */
|
||||
/* bbox :: Unused. */
|
||||
/* */
|
||||
/* path_begun :: A flag which indicates that a new path has begun. */
|
||||
/* */
|
||||
/* load_points :: If this flag is not set, no points are loaded. */
|
||||
/* */
|
||||
/* no_recurse :: Set but not used. */
|
||||
/* */
|
||||
/* error :: An error code that is only used to report memory */
|
||||
/* allocation problems. */
|
||||
/* */
|
||||
/* metrics_only :: A boolean indicating that we only want to compute */
|
||||
/* the metrics of a given glyph, not load all of its */
|
||||
/* points. */
|
||||
/* */
|
||||
typedef struct CID_Builder_
|
||||
{
|
||||
FT_Memory memory;
|
||||
CID_Face face;
|
||||
CID_GlyphSlot glyph;
|
||||
FT_GlyphLoader* loader;
|
||||
FT_Outline* base;
|
||||
FT_Outline* current;
|
||||
|
||||
FT_Vector last;
|
||||
|
||||
FT_Fixed scale_x;
|
||||
FT_Fixed scale_y;
|
||||
|
||||
FT_Pos pos_x;
|
||||
FT_Pos pos_y;
|
||||
|
||||
FT_Vector left_bearing;
|
||||
FT_Vector advance;
|
||||
|
||||
FT_BBox bbox; /* bounding box */
|
||||
FT_Bool path_begun;
|
||||
FT_Bool load_points;
|
||||
FT_Bool no_recurse;
|
||||
|
||||
FT_Error error; /* only used for memory errors */
|
||||
FT_Bool metrics_only;
|
||||
|
||||
} CID_Builder;
|
||||
|
||||
|
||||
/* execution context charstring zone */
|
||||
|
||||
typedef struct CID_Decoder_Zone_
|
||||
{
|
||||
FT_Byte* base;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* cursor;
|
||||
|
||||
} CID_Decoder_Zone;
|
||||
|
||||
|
||||
typedef struct CID_Decoder_
|
||||
{
|
||||
CID_Builder builder;
|
||||
|
||||
FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
|
||||
FT_Int* top;
|
||||
|
||||
CID_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
|
||||
CID_Decoder_Zone* zone;
|
||||
|
||||
FT_Matrix font_matrix;
|
||||
CID_Subrs* subrs;
|
||||
FT_UInt lenIV;
|
||||
|
||||
FT_Int flex_state;
|
||||
FT_Int num_flex_vectors;
|
||||
FT_Vector flex_vectors[7];
|
||||
|
||||
} CID_Decoder;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Init_Builder( CID_Builder* builder,
|
||||
CID_Face face,
|
||||
CID_Size size,
|
||||
CID_GlyphSlot glyph );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Builder( CID_Builder* builder );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Init_Decoder( CID_Decoder* decoder );
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* Compute the maximum advance width of a font through quick parsing */
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Compute_Max_Advance( CID_Face face,
|
||||
FT_Int* max_advance );
|
||||
|
||||
#endif
|
||||
|
||||
/* This function is exported, because it is used by the T1Dump utility */
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Parse_CharStrings( CID_Decoder* decoder,
|
||||
FT_Byte* charstring_base,
|
||||
FT_Int charstring_len );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Load_Glyph( CID_GlyphSlot glyph,
|
||||
CID_Size size,
|
||||
FT_Int glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDGLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
537
src/freetype/cid/cidload.c
Normal file
537
src/freetype/cid/cidload.c
Normal file
@@ -0,0 +1,537 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidload.c */
|
||||
/* */
|
||||
/* CID-keyed Type1 font loader (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/ftmm.h>
|
||||
|
||||
#include <freetype/internal/t1types.h>
|
||||
#include <freetype/internal/t1errors.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h> /* for isspace(), isalnum() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* 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_cidload
|
||||
|
||||
|
||||
/* read a single offset */
|
||||
LOCAL_FUNC
|
||||
FT_Long cid_get_offset( FT_Byte** start,
|
||||
FT_Byte offsize )
|
||||
{
|
||||
FT_Long result;
|
||||
FT_Byte* p = *start;
|
||||
|
||||
|
||||
for ( result = 0; offsize > 0; offsize-- )
|
||||
{
|
||||
result <<= 8;
|
||||
result |= *p++;
|
||||
}
|
||||
|
||||
*start = p;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void cid_decrypt( FT_Byte* buffer,
|
||||
FT_Int length,
|
||||
FT_UShort seed )
|
||||
{
|
||||
while ( length > 0 )
|
||||
{
|
||||
FT_Byte plain;
|
||||
|
||||
|
||||
plain = ( *buffer ^ ( seed >> 8 ) );
|
||||
seed = ( *buffer + seed ) * 52845 + 22719;
|
||||
*buffer++ = plain;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** TYPE 1 SYMBOL PARSING *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
FT_Error cid_load_keyword( CID_Face face,
|
||||
CID_Loader* loader,
|
||||
const CID_Field_Rec* keyword )
|
||||
{
|
||||
FT_Error error;
|
||||
CID_Parser* parser = &loader->parser;
|
||||
FT_Byte* object;
|
||||
CID_Info* cid = &face->cid;
|
||||
|
||||
|
||||
/* if the keyword has a dedicated callback, call it */
|
||||
if ( keyword->type == t1_field_callback )
|
||||
{
|
||||
error = keyword->reader( face, parser );
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* we must now compute the address of our target object */
|
||||
switch ( keyword->location )
|
||||
{
|
||||
case t1_field_cid_info:
|
||||
object = (FT_Byte*)cid;
|
||||
break;
|
||||
|
||||
case t1_field_font_info:
|
||||
object = (FT_Byte*)&cid->font_info;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
CID_FontDict* dict;
|
||||
|
||||
|
||||
if ( parser->num_dict < 0 )
|
||||
{
|
||||
FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n",
|
||||
keyword->ident ));
|
||||
error = T1_Err_Syntax_Error;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
dict = cid->font_dicts + parser->num_dict;
|
||||
switch ( keyword->location )
|
||||
{
|
||||
case t1_field_private:
|
||||
object = (FT_Byte*)&dict->private_dict;
|
||||
break;
|
||||
|
||||
default:
|
||||
object = (FT_Byte*)dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* now, load the keyword data in the object's field(s) */
|
||||
if ( keyword->type == t1_field_integer_array ||
|
||||
keyword->type == t1_field_fixed_array )
|
||||
error = CID_Load_Field_Table( parser, keyword, object );
|
||||
else
|
||||
error = CID_Load_Field( parser, keyword, object );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_bbox( CID_Face face,
|
||||
CID_Parser* parser )
|
||||
{
|
||||
FT_Short temp[4];
|
||||
FT_BBox* bbox = &face->cid.font_bbox;
|
||||
|
||||
|
||||
(void)CID_ToCoordArray( parser, 4, temp );
|
||||
bbox->xMin = temp[0];
|
||||
bbox->yMin = temp[1];
|
||||
bbox->xMax = temp[2];
|
||||
bbox->yMax = temp[3];
|
||||
|
||||
return T1_Err_Ok; /* this is a callback function; */
|
||||
/* we must return an error code */
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_font_matrix( CID_Face face,
|
||||
CID_Parser* parser )
|
||||
{
|
||||
FT_Matrix* matrix;
|
||||
CID_FontDict* dict;
|
||||
FT_Fixed temp[4];
|
||||
|
||||
|
||||
if ( parser->num_dict >= 0 )
|
||||
{
|
||||
dict = face->cid.font_dicts + parser->num_dict;
|
||||
matrix = &dict->font_matrix;
|
||||
|
||||
(void)CID_ToFixedArray( parser, 4, temp, 3 );
|
||||
matrix->xx = temp[0];
|
||||
matrix->yx = temp[1];
|
||||
matrix->xy = temp[2];
|
||||
matrix->yy = temp[3];
|
||||
}
|
||||
|
||||
return T1_Err_Ok; /* this is a callback function; */
|
||||
/* we must return an error code */
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_fd_array( CID_Face face,
|
||||
CID_Parser* parser )
|
||||
{
|
||||
CID_Info* cid = &face->cid;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Error error = T1_Err_Ok;
|
||||
FT_Long num_dicts;
|
||||
|
||||
|
||||
num_dicts = CID_ToInt( parser );
|
||||
|
||||
if ( !cid->font_dicts )
|
||||
{
|
||||
FT_Int n;
|
||||
|
||||
|
||||
if ( ALLOC_ARRAY( cid->font_dicts, num_dicts, CID_FontDict ) )
|
||||
goto Exit;
|
||||
|
||||
cid->num_dicts = (FT_UInt)num_dicts;
|
||||
|
||||
/* don't forget to set a few defaults */
|
||||
for ( n = 0; n < cid->num_dicts; n++ )
|
||||
{
|
||||
CID_FontDict* dict = cid->font_dicts + n;
|
||||
|
||||
|
||||
/* default value for lenIV */
|
||||
dict->private_dict.lenIV = 4;
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
const CID_Field_Rec t1_field_records[] =
|
||||
{
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidtokens.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidtokens.h>
|
||||
|
||||
#endif
|
||||
|
||||
{ 0, t1_field_cid_info, t1_field_none, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
int is_alpha( char c )
|
||||
{
|
||||
return ( isalnum( c ) ||
|
||||
c == '.' ||
|
||||
c == '_' );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void skip_whitespace( CID_Parser* parser )
|
||||
{
|
||||
FT_Byte* cur = parser->cursor;
|
||||
|
||||
|
||||
while ( cur < parser->limit && isspace( *cur ) )
|
||||
cur++;
|
||||
|
||||
parser->cursor = cur;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_dict( CID_Face face,
|
||||
CID_Loader* loader,
|
||||
FT_Byte* base,
|
||||
FT_Long size )
|
||||
{
|
||||
CID_Parser* parser = &loader->parser;
|
||||
|
||||
|
||||
parser->cursor = base;
|
||||
parser->limit = base + size;
|
||||
parser->error = 0;
|
||||
|
||||
{
|
||||
FT_Byte* cur = base;
|
||||
FT_Byte* limit = cur + size;
|
||||
|
||||
|
||||
for ( ;cur < limit; cur++ )
|
||||
{
|
||||
/* look for `%ADOBeginFontDict' */
|
||||
if ( *cur == '%' && cur + 20 < limit &&
|
||||
strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
|
||||
{
|
||||
cur += 17;
|
||||
|
||||
/* if /FDArray was found, then cid->num_dicts is > 0, and */
|
||||
/* we can start increasing parser->num_dict */
|
||||
if ( face->cid.num_dicts > 0 )
|
||||
parser->num_dict++;
|
||||
}
|
||||
/* look for immediates */
|
||||
else if ( *cur == '/' && cur + 2 < limit )
|
||||
{
|
||||
FT_Byte* cur2;
|
||||
FT_Int len;
|
||||
|
||||
|
||||
cur++;
|
||||
|
||||
cur2 = cur;
|
||||
while ( cur2 < limit && is_alpha( *cur2 ) )
|
||||
cur2++;
|
||||
|
||||
len = cur2 - cur;
|
||||
if ( len > 0 && len < 22 )
|
||||
{
|
||||
/* now compare the immediate name to the keyword table */
|
||||
const CID_Field_Rec* keyword = t1_field_records;
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
FT_Byte* name;
|
||||
|
||||
|
||||
name = (FT_Byte*)keyword->ident;
|
||||
if ( !name )
|
||||
break;
|
||||
|
||||
if ( cur[0] == name[0] &&
|
||||
len == (FT_Int)strlen( (const char*)name ) )
|
||||
{
|
||||
FT_Int n;
|
||||
|
||||
|
||||
for ( n = 1; n < len; n++ )
|
||||
if ( cur[n] != name[n] )
|
||||
break;
|
||||
|
||||
if ( n >= len )
|
||||
{
|
||||
/* we found it - run the parsing callback */
|
||||
parser->cursor = cur2;
|
||||
skip_whitespace( parser );
|
||||
parser->error = cid_load_keyword( face, loader, keyword );
|
||||
if ( parser->error )
|
||||
return parser->error;
|
||||
|
||||
cur = parser->cursor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
keyword++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return parser->error;
|
||||
}
|
||||
|
||||
|
||||
/* read the subrmap and the subrs of each font dict */
|
||||
static
|
||||
FT_Error cid_read_subrs( CID_Face face )
|
||||
{
|
||||
CID_Info* cid = &face->cid;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Stream stream = face->root.stream;
|
||||
FT_Error error;
|
||||
FT_Int n;
|
||||
CID_Subrs* subr;
|
||||
FT_UInt max_offsets = 0;
|
||||
FT_ULong* offsets = 0;
|
||||
|
||||
|
||||
if ( ALLOC_ARRAY( face->subrs, cid->num_dicts, CID_Subrs ) )
|
||||
goto Exit;
|
||||
|
||||
subr = face->subrs;
|
||||
for ( n = 0; n < cid->num_dicts; n++, subr++ )
|
||||
{
|
||||
CID_FontDict* dict = cid->font_dicts + n;
|
||||
FT_UInt count, num_subrs = dict->num_subrs;
|
||||
FT_ULong data_len;
|
||||
FT_Byte* p;
|
||||
|
||||
|
||||
/* reallocate offsets array if needed */
|
||||
if ( num_subrs + 1 > max_offsets )
|
||||
{
|
||||
FT_UInt new_max = ( num_subrs + 1 + 3 ) & -4;
|
||||
|
||||
|
||||
if ( REALLOC_ARRAY( offsets, max_offsets, new_max, FT_ULong ) )
|
||||
goto Fail;
|
||||
|
||||
max_offsets = new_max;
|
||||
}
|
||||
|
||||
/* read the subrmap's offsets */
|
||||
if ( FILE_Seek( cid->data_offset + dict->subrmap_offset ) ||
|
||||
ACCESS_Frame( ( num_subrs + 1 ) * dict->sd_bytes ) )
|
||||
goto Fail;
|
||||
|
||||
p = (FT_Byte*)stream->cursor;
|
||||
for ( count = 0; count <= num_subrs; count++ )
|
||||
offsets[count] = cid_get_offset( &p, (FT_Byte)dict->sd_bytes );
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
/* now, compute the size of subrs charstrings, */
|
||||
/* allocate, and read them */
|
||||
data_len = offsets[num_subrs] - offsets[0];
|
||||
|
||||
if ( ALLOC_ARRAY( subr->code, num_subrs + 1, FT_Byte* ) ||
|
||||
ALLOC( subr->code[0], data_len ) )
|
||||
goto Fail;
|
||||
|
||||
if ( FILE_Seek( cid->data_offset + offsets[0] ) ||
|
||||
FILE_Read( subr->code[0], data_len ) )
|
||||
goto Exit;
|
||||
|
||||
/* set up pointers */
|
||||
for ( count = 1; count <= num_subrs; count++ )
|
||||
{
|
||||
FT_UInt len;
|
||||
|
||||
|
||||
len = offsets[count] - offsets[count - 1];
|
||||
subr->code[count] = subr->code[count - 1] + len;
|
||||
}
|
||||
|
||||
/* decrypt subroutines */
|
||||
for ( count = 0; count < num_subrs; count++ )
|
||||
{
|
||||
FT_UInt len;
|
||||
|
||||
|
||||
len = offsets[count + 1] - offsets[count];
|
||||
cid_decrypt( subr->code[count], len, 4330 );
|
||||
}
|
||||
|
||||
subr->num_subrs = num_subrs;
|
||||
}
|
||||
|
||||
Exit:
|
||||
FREE( offsets );
|
||||
return error;
|
||||
|
||||
Fail:
|
||||
if ( face->subrs )
|
||||
{
|
||||
for ( n = 0; n < cid->num_dicts; n++ )
|
||||
{
|
||||
if ( face->subrs[n].code )
|
||||
FREE( face->subrs[n].code[0] );
|
||||
|
||||
FREE( face->subrs[n].code );
|
||||
}
|
||||
FREE( face->subrs );
|
||||
}
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void t1_init_loader( CID_Loader* loader,
|
||||
CID_Face face )
|
||||
{
|
||||
FT_UNUSED( face );
|
||||
|
||||
MEM_Set( loader, 0, sizeof ( *loader ) );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void t1_done_loader( CID_Loader* loader )
|
||||
{
|
||||
CID_Parser* parser = &loader->parser;
|
||||
|
||||
|
||||
/* finalize parser */
|
||||
CID_Done_Parser( parser );
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Open_Face( CID_Face face )
|
||||
{
|
||||
CID_Loader loader;
|
||||
CID_Parser* parser;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
t1_init_loader( &loader, face );
|
||||
|
||||
parser = &loader.parser;
|
||||
error = CID_New_Parser( parser, face->root.stream, face->root.memory );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
error = parse_dict( face, &loader,
|
||||
parser->postscript,
|
||||
parser->postscript_len );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
face->cid.data_offset = loader.parser.data_offset;
|
||||
error = cid_read_subrs( face );
|
||||
|
||||
Exit:
|
||||
t1_done_loader( &loader );
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
70
src/freetype/cid/cidload.h
Normal file
70
src/freetype/cid/cidload.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidload.h */
|
||||
/* */
|
||||
/* CID-keyed Type1 font loader (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDLOAD_H
|
||||
#define CIDLOAD_H
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidparse.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidparse.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CID_Loader_
|
||||
{
|
||||
CID_Parser parser; /* parser used to read the stream */
|
||||
FT_Int num_chars; /* number of characters in encoding */
|
||||
|
||||
} CID_Loader;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long cid_get_offset( FT_Byte** start,
|
||||
FT_Byte offsize );
|
||||
|
||||
LOCAL_DEF
|
||||
void cid_decrypt( FT_Byte* buffer,
|
||||
FT_Int length,
|
||||
FT_UShort seed );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Open_Face( CID_Face face );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
380
src/freetype/cid/cidobjs.c
Normal file
380
src/freetype/cid/cidobjs.c
Normal file
@@ -0,0 +1,380 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidobjs.c */
|
||||
/* */
|
||||
/* CID objects manager (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidgload.h"
|
||||
#include "cidload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidgload.h>
|
||||
#include <cid/cidload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
||||
/* messages during execution. */
|
||||
/* */
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_cidobjs
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FACE FUNCTIONS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Done_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A pointer to the face object to destroy. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void CID_Done_Face( CID_Face face )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
if ( face )
|
||||
{
|
||||
CID_Info* cid = &face->cid;
|
||||
T1_FontInfo* info = &cid->font_info;
|
||||
|
||||
|
||||
memory = face->root.memory;
|
||||
|
||||
/* release FontInfo strings */
|
||||
FREE( info->version );
|
||||
FREE( info->notice );
|
||||
FREE( info->full_name );
|
||||
FREE( info->family_name );
|
||||
FREE( info->weight );
|
||||
|
||||
/* release font dictionaries */
|
||||
FREE( cid->font_dicts );
|
||||
cid->num_dicts = 0;
|
||||
|
||||
/* release other strings */
|
||||
FREE( cid->cid_font_name );
|
||||
FREE( cid->registry );
|
||||
FREE( cid->ordering );
|
||||
|
||||
face->root.family_name = 0;
|
||||
face->root.style_name = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Init_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given CID face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: The source font stream. */
|
||||
/* */
|
||||
/* face_index :: The index of the font face in the resource. */
|
||||
/* */
|
||||
/* num_params :: Number of additional generic parameters. Ignored. */
|
||||
/* */
|
||||
/* params :: Additional generic parameters. Ignored. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: The newly built face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Init_Face( FT_Stream stream,
|
||||
CID_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
PSNames_Interface* psnames;
|
||||
|
||||
FT_UNUSED( num_params );
|
||||
FT_UNUSED( params );
|
||||
FT_UNUSED( face_index );
|
||||
FT_UNUSED( stream );
|
||||
|
||||
|
||||
face->root.num_faces = 1;
|
||||
|
||||
psnames = (PSNames_Interface*)face->psnames;
|
||||
if ( !psnames )
|
||||
{
|
||||
psnames = (PSNames_Interface*)FT_Get_Module_Interface(
|
||||
FT_FACE_LIBRARY( face ), "psnames" );
|
||||
|
||||
face->psnames = psnames;
|
||||
}
|
||||
|
||||
/* open the tokenizer; this will also check the font format */
|
||||
if ( FILE_Seek( 0 ) )
|
||||
goto Exit;
|
||||
|
||||
error = CID_Open_Face( face );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* if we just wanted to check the format, leave successfully now */
|
||||
if ( face_index < 0 )
|
||||
goto Exit;
|
||||
|
||||
/* check the face index */
|
||||
if ( face_index != 0 )
|
||||
{
|
||||
FT_ERROR(( "CID_Init_Face: invalid face index\n" ));
|
||||
error = T1_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* Now, load the font program into the face object */
|
||||
{
|
||||
/* Init the face object fields */
|
||||
/* Now set up root face fields */
|
||||
{
|
||||
FT_Face root = (FT_Face)&face->root;
|
||||
|
||||
|
||||
root->num_glyphs = face->cid.cid_count;
|
||||
root->num_charmaps = 0;
|
||||
|
||||
root->face_index = face_index;
|
||||
root->face_flags = FT_FACE_FLAG_SCALABLE;
|
||||
|
||||
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
|
||||
|
||||
if ( face->cid.font_info.is_fixed_pitch )
|
||||
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
||||
|
||||
/* XXX: TODO: add kerning with .afm support */
|
||||
|
||||
/* get style name -- be careful, some broken fonts only */
|
||||
/* have a /FontName dictionary entry! */
|
||||
root->family_name = face->cid.font_info.family_name;
|
||||
if ( root->family_name )
|
||||
{
|
||||
char* full = face->cid.font_info.full_name;
|
||||
char* family = root->family_name;
|
||||
|
||||
while ( *family && *full == *family )
|
||||
{
|
||||
family++;
|
||||
full++;
|
||||
}
|
||||
|
||||
root->style_name = ( *full == ' ' ) ? full + 1
|
||||
: (char *)"Regular";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do we have a `/FontName'? */
|
||||
if ( face->cid.cid_font_name )
|
||||
{
|
||||
root->family_name = face->cid.cid_font_name;
|
||||
root->style_name = "Regular";
|
||||
}
|
||||
}
|
||||
|
||||
/* no embedded bitmap support */
|
||||
root->num_fixed_sizes = 0;
|
||||
root->available_sizes = 0;
|
||||
|
||||
root->bbox = face->cid.font_bbox;
|
||||
root->units_per_EM = 1000;
|
||||
root->ascender = (FT_Short)face->cid.font_bbox.yMax;
|
||||
root->descender = -(FT_Short)face->cid.font_bbox.yMin;
|
||||
root->height = ( ( root->ascender + root->descender ) * 12 )
|
||||
/ 10;
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* now compute the maximum advance width */
|
||||
|
||||
root->max_advance_width = face->type1.private_dict.standard_width[0];
|
||||
|
||||
/* compute max advance width for proportional fonts */
|
||||
if ( !face->type1.font_info.is_fixed_pitch )
|
||||
{
|
||||
FT_Int max_advance;
|
||||
|
||||
|
||||
error = CID_Compute_Max_Advance( face, &max_advance );
|
||||
|
||||
/* in case of error, keep the standard width */
|
||||
if ( !error )
|
||||
root->max_advance_width = max_advance;
|
||||
else
|
||||
error = 0; /* clear error */
|
||||
}
|
||||
|
||||
root->max_advance_height = root->height;
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
root->underline_position = face->cid.font_info.underline_position;
|
||||
root->underline_thickness = face->cid.font_info.underline_thickness;
|
||||
|
||||
root->max_points = 0;
|
||||
root->max_contours = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/* charmap support - synthetize unicode charmap when possible */
|
||||
{
|
||||
FT_Face root = &face->root;
|
||||
FT_CharMap charmap = face->charmaprecs;
|
||||
|
||||
|
||||
/* synthesize a Unicode charmap if there is support in the `psnames' */
|
||||
/* module */
|
||||
if ( face->psnames )
|
||||
{
|
||||
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
|
||||
|
||||
|
||||
if ( psnames->unicode_value )
|
||||
{
|
||||
error = psnames->build_unicodes(
|
||||
root->memory,
|
||||
face->type1.num_glyphs,
|
||||
(const char**)face->type1.glyph_names,
|
||||
&face->unicode_map );
|
||||
if ( !error )
|
||||
{
|
||||
root->charmap = charmap;
|
||||
charmap->face = (FT_Face)face;
|
||||
charmap->encoding = ft_encoding_unicode;
|
||||
charmap->platform_id = 3;
|
||||
charmap->encoding_id = 1;
|
||||
charmap++;
|
||||
}
|
||||
|
||||
/* simply clear the error in case of failure (which really */
|
||||
/* means that out of memory or no unicode glyph names) */
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* now, support either the standard, expert, or custom encodings */
|
||||
charmap->face = (FT_Face)face;
|
||||
charmap->platform_id = 7; /* a new platform id for Adobe fonts? */
|
||||
|
||||
switch ( face->type1.encoding_type )
|
||||
{
|
||||
case t1_encoding_standard:
|
||||
charmap->encoding = ft_encoding_adobe_standard;
|
||||
charmap->encoding_id = 0;
|
||||
break;
|
||||
|
||||
case t1_encoding_expert:
|
||||
charmap->encoding = ft_encoding_adobe_expert;
|
||||
charmap->encoding_id = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
charmap->encoding = ft_encoding_adobe_custom;
|
||||
charmap->encoding_id = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
root->charmaps = face->charmaps;
|
||||
root->num_charmaps = charmap - face->charmaprecs + 1;
|
||||
face->charmaps[0] = &face->charmaprecs[0];
|
||||
face->charmaps[1] = &face->charmaprecs[1];
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Init_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given CID driver object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target driver object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error CID_Init_Driver( CID_Driver driver )
|
||||
{
|
||||
FT_UNUSED( driver );
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* CID_Done_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given CID driver. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target CID driver. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
void CID_Done_Driver( CID_Driver driver )
|
||||
{
|
||||
FT_UNUSED( driver );
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
141
src/freetype/cid/cidobjs.h
Normal file
141
src/freetype/cid/cidobjs.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidobjs.h */
|
||||
/* */
|
||||
/* CID objects manager (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDOBJS_H
|
||||
#define CIDOBJS_H
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/internal/t1errors.h>
|
||||
#include <freetype/internal/t1types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* The following structures must be defined by the hinter */
|
||||
typedef struct CID_Size_Hints_ CID_Size_Hints;
|
||||
typedef struct CID_Glyph_Hints_ CID_Glyph_Hints;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 driver object. */
|
||||
/* */
|
||||
typedef struct CID_DriverRec_* CID_Driver;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 size object. */
|
||||
/* */
|
||||
typedef struct CID_SizeRec_* CID_Size;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 glyph slot object. */
|
||||
/* */
|
||||
typedef struct CID_GlyphSlotRec_* CID_GlyphSlot;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* CID_CharMap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 character mapping object. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The Type 1 format doesn't use a charmap but an encoding table. */
|
||||
/* The driver is responsible for making up charmap objects */
|
||||
/* corresponding to these tables. */
|
||||
/* */
|
||||
typedef struct CID_CharMapRec_* CID_CharMap;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* HERE BEGINS THE TYPE 1 SPECIFIC STUFF */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
typedef struct CID_SizeRec_
|
||||
{
|
||||
FT_SizeRec root;
|
||||
FT_Bool valid;
|
||||
|
||||
} CID_SizeRec;
|
||||
|
||||
|
||||
typedef struct CID_GlyphSlotRec_
|
||||
{
|
||||
FT_GlyphSlotRec root;
|
||||
|
||||
FT_Bool hint;
|
||||
FT_Bool scaled;
|
||||
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
|
||||
} CID_GlyphSlotRec;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Init_Face( FT_Stream stream,
|
||||
CID_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Face( CID_Face face );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Init_Driver( CID_Driver driver );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Driver( CID_Driver driver );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDOBJS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
1024
src/freetype/cid/cidparse.c
Normal file
1024
src/freetype/cid/cidparse.c
Normal file
File diff suppressed because it is too large
Load Diff
353
src/freetype/cid/cidparse.h
Normal file
353
src/freetype/cid/cidparse.h
Normal file
@@ -0,0 +1,353 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidparse.h */
|
||||
/* */
|
||||
/* CID-keyed Type1 parser (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDPARSE_H
|
||||
#define CIDPARSE_H
|
||||
|
||||
#include <freetype/internal/t1types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A CID_Table is a simple object used to store an array of objects */
|
||||
/* in a single memory block. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* block :: The address in memory of the growheap's block. This */
|
||||
/* can change between two object adds, due to the use */
|
||||
/* of `realloc()'. */
|
||||
/* */
|
||||
/* cursor :: The current top of the growheap within its block. */
|
||||
/* */
|
||||
/* capacity :: The current size of the heap block. Increments by */
|
||||
/* blocks of 1 kByte. */
|
||||
/* */
|
||||
/* init :: A boolean. Set when the table has been initialized */
|
||||
/* (the table user should set this field). */
|
||||
/* */
|
||||
/* max_elems :: The maximal number of elements in the table. */
|
||||
/* */
|
||||
/* num_elems :: The current number of elements (in use) in the table. */
|
||||
/* */
|
||||
/* elements :: A table of element addresses within the block. */
|
||||
/* */
|
||||
/* lengths :: A table of element sizes within the block. */
|
||||
/* */
|
||||
/* memory :: The memory object used for memory operations */
|
||||
/* (allocation resp. reallocation). */
|
||||
/* */
|
||||
typedef struct CID_Table_
|
||||
{
|
||||
FT_Byte* block; /* current memory block */
|
||||
FT_Int cursor; /* current cursor in memory block */
|
||||
FT_Int capacity; /* current size of memory block */
|
||||
FT_Long init;
|
||||
|
||||
FT_Int max_elems;
|
||||
FT_Int num_elems;
|
||||
FT_Byte** elements; /* addresses of table elements */
|
||||
FT_Int* lengths; /* lengths of table elements */
|
||||
|
||||
FT_Memory memory;
|
||||
|
||||
} CID_Table;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_New_Table( CID_Table* table,
|
||||
FT_Int count,
|
||||
CID_Memory memory );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Add_Table( CID_Table* table,
|
||||
FT_Int index,
|
||||
void* object,
|
||||
FT_Int length );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Release_Table( CID_Table* table );
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_Parser */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A CID_Parser is an object used to parse a Type 1 fonts very */
|
||||
/* quickly. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* stream :: The current input stream. */
|
||||
/* */
|
||||
/* memory :: The current memory object. */
|
||||
/* */
|
||||
/* postscript :: A pointer to the data to be parsed. */
|
||||
/* */
|
||||
/* postscript_len :: The length of the data to be parsed. */
|
||||
/* */
|
||||
/* data_offset :: The start position of the binary data (i.e., the */
|
||||
/* end of the data to be parsed. */
|
||||
/* */
|
||||
/* cursor :: The current parser cursor. */
|
||||
/* */
|
||||
/* limit :: The current parser limit (i.e., the first byte */
|
||||
/* after the current dictionary). */
|
||||
/* */
|
||||
/* error :: The current parsing error. */
|
||||
/* */
|
||||
/* cid :: A structure which holds the information about */
|
||||
/* the current font. */
|
||||
/* */
|
||||
/* num_dict :: The number of font dictionaries. */
|
||||
/* */
|
||||
typedef struct CID_Parser_
|
||||
{
|
||||
FT_Stream stream;
|
||||
FT_Memory memory;
|
||||
|
||||
FT_Byte* postscript;
|
||||
FT_Int postscript_len;
|
||||
|
||||
FT_ULong data_offset;
|
||||
|
||||
FT_Byte* cursor;
|
||||
FT_Byte* limit;
|
||||
FT_Error error;
|
||||
|
||||
CID_Info* cid;
|
||||
FT_Int num_dict;
|
||||
|
||||
} CID_Parser;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_New_Parser( CID_Parser* parser,
|
||||
FT_Stream stream,
|
||||
FT_Memory memory );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Done_Parser( CID_Parser* parser );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* PARSING ROUTINES */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long CID_ToInt( CID_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Int CID_ToCoordArray( CID_Parser* parser,
|
||||
FT_Int max_coords,
|
||||
FT_Short* coords );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Int CID_ToFixedArray( CID_Parser* parser,
|
||||
FT_Int max_values,
|
||||
FT_Fixed* values,
|
||||
FT_Int power_ten );
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_Skip_Spaces( CID_Parser* parser );
|
||||
|
||||
|
||||
/* simple enumeration type used to identify token types */
|
||||
typedef enum CID_Token_Type_
|
||||
{
|
||||
t1_token_none = 0,
|
||||
t1_token_any,
|
||||
t1_token_string,
|
||||
t1_token_array,
|
||||
|
||||
/* do not remove */
|
||||
t1_token_max
|
||||
|
||||
} CID_Token_Type;
|
||||
|
||||
|
||||
/* a simple structure used to identify tokens */
|
||||
typedef struct CID_Token_Rec_
|
||||
{
|
||||
FT_Byte* start; /* first character of token in input stream */
|
||||
FT_Byte* limit; /* first character after the token */
|
||||
CID_Token_Type type; /* type of token */
|
||||
|
||||
} CID_Token_Rec;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void CID_ToToken( CID_Parser* parser,
|
||||
CID_Token_Rec* token );
|
||||
|
||||
|
||||
/* enumeration type used to identify object fields */
|
||||
typedef enum CID_Field_Type_
|
||||
{
|
||||
t1_field_none = 0,
|
||||
t1_field_bool,
|
||||
t1_field_integer,
|
||||
t1_field_fixed,
|
||||
t1_field_string,
|
||||
t1_field_integer_array,
|
||||
t1_field_fixed_array,
|
||||
t1_field_callback,
|
||||
|
||||
/* do not remove */
|
||||
t1_field_max
|
||||
|
||||
} CID_Field_Type;
|
||||
|
||||
typedef enum CID_Field_Location_
|
||||
{
|
||||
t1_field_cid_info,
|
||||
t1_field_font_dict,
|
||||
t1_field_font_info,
|
||||
t1_field_private,
|
||||
|
||||
/* do not remove */
|
||||
t1_field_location_max
|
||||
|
||||
} CID_Field_Location;
|
||||
|
||||
|
||||
typedef FT_Error (*CID_Field_Parser)( CID_Face face,
|
||||
CID_Parser* parser );
|
||||
|
||||
/* structure type used to model object fields */
|
||||
typedef struct CID_Field_Rec_
|
||||
{
|
||||
const char* ident; /* field identifier */
|
||||
CID_Field_Location location;
|
||||
CID_Field_Type type; /* type of field */
|
||||
CID_Field_Parser reader;
|
||||
FT_UInt offset; /* offset of field in object */
|
||||
FT_UInt size; /* size of field in bytes */
|
||||
FT_UInt array_max; /* maximal number of elements for */
|
||||
/* array */
|
||||
FT_UInt count_offset; /* offset of element count for */
|
||||
/* arrays */
|
||||
} CID_Field_Rec;
|
||||
|
||||
|
||||
#define CID_FIELD_REF( s, f ) ( ((s*)0)->f )
|
||||
|
||||
#define CID_NEW_SIMPLE_FIELD( _ident, _type, _fname ) \
|
||||
{ \
|
||||
_ident, T1CODE, _type, \
|
||||
0, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \
|
||||
sizeof ( CID_FIELD_REF( T1TYPE, _fname ) ), \
|
||||
0, 0 \
|
||||
},
|
||||
|
||||
#define CID_NEW_CALLBACK_FIELD( _ident, _reader ) \
|
||||
{ \
|
||||
_ident, T1CODE, t1_field_callback, \
|
||||
_reader, \
|
||||
0, 0, \
|
||||
0, 0 \
|
||||
},
|
||||
|
||||
#define CID_NEW_TABLE_FIELD( _ident, _type, _fname, _max ) \
|
||||
{ \
|
||||
_ident, T1CODE, _type, \
|
||||
0, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \
|
||||
sizeof ( CID_FIELD_REF( T1TYPE, _fname )[0] ), \
|
||||
_max, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, num_ ## _fname ) \
|
||||
},
|
||||
|
||||
#define CID_NEW_TABLE_FIELD2( _ident, _type, _fname, _max ) \
|
||||
{ \
|
||||
_ident, T1CODE, _type, \
|
||||
0, \
|
||||
(FT_UInt)(char*)&CID_FIELD_REF( T1TYPE, _fname ), \
|
||||
sizeof ( CID_FIELD_REF( T1TYPE, _fname )[0] ), \
|
||||
_max, 0 \
|
||||
},
|
||||
|
||||
|
||||
#define CID_FIELD_BOOL( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_bool, _fname )
|
||||
|
||||
#define CID_FIELD_NUM( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_integer, _fname )
|
||||
|
||||
#define CID_FIELD_FIXED( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_fixed, _fname )
|
||||
|
||||
#define CID_FIELD_STRING( _ident, _fname ) \
|
||||
CID_NEW_SIMPLE_FIELD( _ident, t1_field_string, _fname )
|
||||
|
||||
#define CID_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD( _ident, t1_field_integer_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_FIXED_TABLE( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD( _ident, t1_field_fixed_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_NUM_TABLE2( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD2( _ident, t1_field_integer_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_FIXED_TABLE2( _ident, _fname, _fmax ) \
|
||||
CID_NEW_TABLE_FIELD2( _ident, t1_field_fixed_array, \
|
||||
_fname, _fmax )
|
||||
|
||||
#define CID_FIELD_CALLBACK( _ident, _name ) \
|
||||
CID_NEW_CALLBACK_FIELD( _ident, parse_ ## _name )
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Load_Field( CID_Parser* parser,
|
||||
const CID_Field_Rec* field,
|
||||
void* object );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error CID_Load_Field_Table( CID_Parser* parser,
|
||||
const CID_Field_Rec* field,
|
||||
void* object );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CIDPARSE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
259
src/freetype/cid/cidriver.c
Normal file
259
src/freetype/cid/cidriver.c
Normal file
@@ -0,0 +1,259 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidriver.c */
|
||||
/* */
|
||||
/* CID driver interface (body). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidriver.h"
|
||||
#include "cidgload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidriver.h>
|
||||
#include <cid/cidgload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
#include <string.h> /* for strcmp() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* 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_ciddriver
|
||||
|
||||
|
||||
static
|
||||
FT_Module_Interface CID_Get_Interface( FT_Driver driver,
|
||||
const FT_String* interface )
|
||||
{
|
||||
FT_UNUSED( driver );
|
||||
FT_UNUSED( interface );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* unimplemented yet */
|
||||
|
||||
static
|
||||
FT_Error cid_Get_Kerning( T1_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
CID_AFM* afm;
|
||||
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
|
||||
afm = (CID_AFM*)face->afm_data;
|
||||
if ( afm )
|
||||
CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Cid_Get_Char_Index */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Uses a charmap to return a given character code's glyph index. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charmap :: A handle to the source charmap object. */
|
||||
/* */
|
||||
/* charcode :: The character code. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Glyph index. 0 means `undefined character code'. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt CID_Get_Char_Index( FT_CharMap charmap,
|
||||
FT_Long charcode )
|
||||
{
|
||||
T1_Face face;
|
||||
FT_UInt result = 0;
|
||||
PSNames_Interface* psnames;
|
||||
|
||||
|
||||
face = (T1_Face)charmap->face;
|
||||
psnames = (PSNames_Interface*)face->psnames;
|
||||
if ( psnames )
|
||||
switch ( charmap->encoding )
|
||||
{
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Unicode encoding support */
|
||||
/* */
|
||||
case ft_encoding_unicode:
|
||||
/* use the `PSNames' module to synthetize the Unicode charmap */
|
||||
result = psnames->lookup_unicode( &face->unicode_map,
|
||||
(FT_ULong)charcode );
|
||||
|
||||
/* the function returns 0xFFFF if the Unicode charcode has */
|
||||
/* no corresponding glyph. */
|
||||
if ( result == 0xFFFF )
|
||||
result = 0;
|
||||
goto Exit;
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Custom Type 1 encoding */
|
||||
/* */
|
||||
case ft_encoding_adobe_custom:
|
||||
{
|
||||
T1_Encoding* encoding = &face->type1.encoding;
|
||||
|
||||
|
||||
if ( charcode >= encoding->code_first &&
|
||||
charcode <= encoding->code_last )
|
||||
result = encoding->char_index[charcode];
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Adobe Standard & Expert encoding support */
|
||||
/* */
|
||||
default:
|
||||
if ( charcode < 256 )
|
||||
{
|
||||
FT_UInt code;
|
||||
FT_Int n;
|
||||
const char* glyph_name;
|
||||
|
||||
|
||||
code = psnames->adobe_std_encoding[charcode];
|
||||
if ( charmap->encoding == ft_encoding_adobe_expert )
|
||||
code = psnames->adobe_expert_encoding[charcode];
|
||||
|
||||
glyph_name = psnames->adobe_std_strings( code );
|
||||
if ( !glyph_name )
|
||||
break;
|
||||
|
||||
for ( n = 0; n < face->type1.num_glyphs; n++ )
|
||||
{
|
||||
const char* gname = face->type1.glyph_names[n];
|
||||
|
||||
|
||||
if ( gname && gname[0] == glyph_name[0] &&
|
||||
strcmp( gname, glyph_name ) == 0 )
|
||||
{
|
||||
result = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const FT_Driver_Class t1cid_driver_class =
|
||||
{
|
||||
/* first of all, the FT_Module_Class fields */
|
||||
{
|
||||
ft_module_font_driver | ft_module_driver_scalable,
|
||||
sizeof( FT_DriverRec ),
|
||||
"t1cid", /* module name */
|
||||
0x10000L, /* version 1.0 of driver */
|
||||
0x20000L, /* requires FreeType 2.0 */
|
||||
|
||||
0,
|
||||
|
||||
(FT_Module_Constructor)CID_Init_Driver,
|
||||
(FT_Module_Destructor) CID_Done_Driver,
|
||||
(FT_Module_Requester) CID_Get_Interface
|
||||
},
|
||||
|
||||
/* then the other font drivers fields */
|
||||
sizeof( CID_FaceRec ),
|
||||
sizeof( CID_SizeRec ),
|
||||
sizeof( CID_GlyphSlotRec ),
|
||||
|
||||
(FTDriver_initFace) CID_Init_Face,
|
||||
(FTDriver_doneFace) CID_Done_Face,
|
||||
|
||||
(FTDriver_initSize) 0,
|
||||
(FTDriver_doneSize) 0,
|
||||
(FTDriver_initGlyphSlot)0,
|
||||
(FTDriver_doneGlyphSlot)0,
|
||||
|
||||
(FTDriver_setCharSizes) 0,
|
||||
(FTDriver_setPixelSizes)0,
|
||||
|
||||
(FTDriver_loadGlyph) CID_Load_Glyph,
|
||||
(FTDriver_getCharIndex) CID_Get_Char_Index,
|
||||
|
||||
(FTDriver_getKerning) 0,
|
||||
(FTDriver_attachFile) 0,
|
||||
|
||||
(FTDriver_getAdvances) 0
|
||||
};
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* getDriverClass */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is used when compiling the TrueType driver as a */
|
||||
/* shared library (`.DLL' or `.so'). It will be used by the */
|
||||
/* high-level library of FreeType to retrieve the address of the */
|
||||
/* driver's generic interface. */
|
||||
/* */
|
||||
/* It shouldn't be implemented in a static build, as each driver must */
|
||||
/* have the same function as an exported entry point. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The address of the TrueType's driver generic interface. The */
|
||||
/* format-specific interface can then be retrieved through the method */
|
||||
/* interface->get_format_interface. */
|
||||
/* */
|
||||
EXPORT_FUNC( FT_Driver_Class* ) getDriverClass( void )
|
||||
{
|
||||
return &t1cid_driver_class;
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
|
||||
|
||||
|
||||
/* END */
|
||||
29
src/freetype/cid/cidriver.h
Normal file
29
src/freetype/cid/cidriver.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidriver.h */
|
||||
/* */
|
||||
/* High-level CID driver interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef CIDRIVER_H
|
||||
#define CIDRIVER_H
|
||||
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Driver_Class ) t1cid_driver_class;
|
||||
|
||||
#endif /* CIDRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
99
src/freetype/cid/cidtokens.h
Normal file
99
src/freetype/cid/cidtokens.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cidtokens.h */
|
||||
/* */
|
||||
/* CID token definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE CID_Info
|
||||
#define T1CODE t1_field_cid_info
|
||||
|
||||
CID_FIELD_STRING ( "CIDFontName", cid_font_name )
|
||||
CID_FIELD_NUM ( "CIDFontVersion", cid_version )
|
||||
CID_FIELD_NUM ( "CIDFontType", cid_font_type )
|
||||
CID_FIELD_STRING ( "Registry", registry )
|
||||
CID_FIELD_STRING ( "Ordering", ordering )
|
||||
CID_FIELD_NUM ( "Supplement", supplement )
|
||||
CID_FIELD_CALLBACK( "FontBBox", font_bbox )
|
||||
CID_FIELD_NUM ( "UIDBase", uid_base )
|
||||
CID_FIELD_CALLBACK( "FDArray", fd_array )
|
||||
CID_FIELD_NUM ( "CIDMapOffset", cidmap_offset )
|
||||
CID_FIELD_NUM ( "FDBytes", fd_bytes )
|
||||
CID_FIELD_NUM ( "GDBytes", gd_bytes )
|
||||
CID_FIELD_NUM ( "CIDCount", cid_count )
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE T1_FontInfo
|
||||
#define T1CODE t1_field_font_info
|
||||
|
||||
CID_FIELD_STRING( "version", version )
|
||||
CID_FIELD_STRING( "Notice", notice )
|
||||
CID_FIELD_STRING( "FullName", full_name )
|
||||
CID_FIELD_STRING( "FamilyName", family_name )
|
||||
CID_FIELD_STRING( "Weight", weight )
|
||||
CID_FIELD_FIXED ( "ItalicAngle", italic_angle )
|
||||
CID_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch )
|
||||
CID_FIELD_NUM ( "UnderlinePosition", underline_position )
|
||||
CID_FIELD_NUM ( "UnderlineThickness", underline_thickness )
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE CID_FontDict
|
||||
#define T1CODE t1_field_font_dict
|
||||
|
||||
CID_FIELD_CALLBACK( "FontMatrix", font_matrix )
|
||||
CID_FIELD_NUM ( "PaintType", paint_type )
|
||||
CID_FIELD_NUM ( "FontType", font_type )
|
||||
CID_FIELD_NUM ( "SubrMapOffset", subrmap_offset )
|
||||
CID_FIELD_NUM ( "SDBytes", sd_bytes )
|
||||
CID_FIELD_NUM ( "SubrCount", num_subrs )
|
||||
CID_FIELD_NUM ( "lenBuildCharArray", len_buildchar )
|
||||
CID_FIELD_FIXED ( "ForceBoldThreshold", forcebold_threshold )
|
||||
CID_FIELD_FIXED ( "ExpansionFactor", expansion_factor )
|
||||
CID_FIELD_NUM ( "StrokeWidth", stroke_width )
|
||||
|
||||
|
||||
#undef T1TYPE
|
||||
#undef T1CODE
|
||||
#define T1TYPE T1_Private
|
||||
#define T1CODE t1_field_private
|
||||
|
||||
CID_FIELD_NUM ( "UniqueID", unique_id )
|
||||
CID_FIELD_NUM ( "lenIV", lenIV )
|
||||
CID_FIELD_NUM ( "LanguageGroup", language_group )
|
||||
CID_FIELD_NUM ( "password", password )
|
||||
|
||||
CID_FIELD_FIXED ( "BlueScale", blue_scale )
|
||||
CID_FIELD_NUM ( "BlueShift", blue_shift )
|
||||
CID_FIELD_NUM ( "BlueFuzz", blue_fuzz )
|
||||
|
||||
CID_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 )
|
||||
CID_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 )
|
||||
CID_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 )
|
||||
CID_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 )
|
||||
|
||||
CID_FIELD_NUM_TABLE2( "StdHW", standard_width, 1 )
|
||||
CID_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 )
|
||||
CID_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 )
|
||||
|
||||
CID_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 )
|
||||
CID_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 )
|
||||
|
||||
|
||||
/* END */
|
||||
6
src/freetype/cid/module.mk
Normal file
6
src/freetype/cid/module.mk
Normal file
@@ -0,0 +1,6 @@
|
||||
make_module_list: add_type1cid_driver
|
||||
|
||||
add_type1cid_driver:
|
||||
$(OPEN_DRIVER)t1cid_driver_class$(CLOSE_DRIVER)
|
||||
$(ECHO_DRIVER)cid $(ECHO_DRIVER_DESC)Postscript CID-keyed fonts, no known extension$(ECHO_DRIVER_DONE)
|
||||
# EOF
|
||||
69
src/freetype/cid/rules.mk
Normal file
69
src/freetype/cid/rules.mk
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# FreeType 2 CID driver configuration rules
|
||||
#
|
||||
|
||||
|
||||
# Copyright 1996-2000 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.
|
||||
|
||||
|
||||
# CID driver directory
|
||||
#
|
||||
CID_DIR := $(SRC_)cid
|
||||
CID_DIR_ := $(CID_DIR)$(SEP)
|
||||
|
||||
|
||||
CID_COMPILE := $(FT_COMPILE)
|
||||
|
||||
|
||||
# CID driver sources (i.e., C files)
|
||||
#
|
||||
CID_DRV_SRC := $(CID_DIR_)cidparse.c \
|
||||
$(CID_DIR_)cidload.c \
|
||||
$(CID_DIR_)cidriver.c \
|
||||
$(CID_DIR_)cidgload.c \
|
||||
$(CID_DIR_)cidobjs.c
|
||||
|
||||
# CID driver headers
|
||||
#
|
||||
CID_DRV_H := $(CID_DRV_SRC:%.c=%.h) \
|
||||
$(CID_DIR_)cidtokens.h
|
||||
|
||||
|
||||
# CID driver object(s)
|
||||
#
|
||||
# CID_DRV_OBJ_M is used during `multi' builds
|
||||
# CID_DRV_OBJ_S is used during `single' builds
|
||||
#
|
||||
CID_DRV_OBJ_M := $(CID_DRV_SRC:$(CID_DIR_)%.c=$(OBJ_)%.$O)
|
||||
CID_DRV_OBJ_S := $(OBJ_)type1cid.$O
|
||||
|
||||
# CID driver source file for single build
|
||||
#
|
||||
CID_DRV_SRC_S := $(CID_DIR_)type1cid.c
|
||||
|
||||
|
||||
# CID driver - single object
|
||||
#
|
||||
$(CID_DRV_OBJ_S): $(CID_DRV_SRC_S) $(CID_DRV_SRC) $(FREETYPE_H) $(CID_DRV_H)
|
||||
$(CID_COMPILE) $T$@ $(CID_DRV_SRC_S)
|
||||
|
||||
|
||||
# CID driver - multiple objects
|
||||
#
|
||||
$(OBJ_)%.$O: $(CID_DIR_)%.c $(FREETYPE_H) $(CID_DRV_H)
|
||||
$(CID_COMPILE) $T$@ $<
|
||||
|
||||
|
||||
# update main driver object lists
|
||||
#
|
||||
DRV_OBJS_S += $(CID_DRV_OBJ_S)
|
||||
DRV_OBJS_M += $(CID_DRV_OBJ_M)
|
||||
|
||||
# EOF
|
||||
40
src/freetype/cid/type1cid.c
Normal file
40
src/freetype/cid/type1cid.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* cff.c */
|
||||
/* */
|
||||
/* FreeType OpenType driver component (body only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "cidparse.c"
|
||||
#include "cidload.c"
|
||||
#include "cidobjs.c"
|
||||
#include "cidriver.c"
|
||||
#include "cidgload.c"
|
||||
|
||||
#else
|
||||
|
||||
#include <cid/cidparse.c>
|
||||
#include <cid/cidload.c>
|
||||
#include <cid/cidobjs.c>
|
||||
#include <cid/cidriver.c>
|
||||
#include <cid/cidgload.c>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* END */
|
||||
187
src/freetype/freetype/config/ftconfig.h
Normal file
187
src/freetype/freetype/config/ftconfig.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftconfig.h */
|
||||
/* */
|
||||
/* ANSI-specific configuration file (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This header file contains a number of macro definitions that are used */
|
||||
/* by the rest of the engine. Most of the macros here are automatically */
|
||||
/* determined at compile time, and you should not need to change it to */
|
||||
/* port FreeType, except to compile the library with a non-ANSI */
|
||||
/* compiler. */
|
||||
/* */
|
||||
/* Note however that if some specific modifications are needed, we */
|
||||
/* advise you to place a modified copy in your build directory. */
|
||||
/* */
|
||||
/* The build directory is usually `freetype/builds/<system>', and */
|
||||
/* contains system-specific files that are always included first when */
|
||||
/* building the library. */
|
||||
/* */
|
||||
/* This ANSI version should stay in `include/freetype/config'. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTCONFIG_H
|
||||
#define FTCONFIG_H
|
||||
|
||||
|
||||
/* Include the header file containing all developer build options */
|
||||
#include <freetype/config/ftoption.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* PLATFORM-SPECIFIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros can be toggled to suit a specific system. The current */
|
||||
/* ones are defaults used to compile FreeType in an ANSI C environment */
|
||||
/* (16bit compilers are also supported). Copy this file to your own */
|
||||
/* `freetype/builds/<system>' directory, and edit it to port the engine. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* We use <limits.h> values to know the sizes of the types. */
|
||||
#include <limits.h>
|
||||
|
||||
/* The number of bytes in an `int' type. */
|
||||
#if UINT_MAX == 0xFFFFFFFF
|
||||
#define FT_SIZEOF_INT 4
|
||||
#elif UINT_MAX == 0xFFFF
|
||||
#define FT_SIZEOF_INT 2
|
||||
#elif UINT_MAX > 0xFFFFFFFF && UINT_MAX == 0xFFFFFFFFFFFFFFFF
|
||||
#define FT_SIZEOF_INT 8
|
||||
#else
|
||||
#error "Unsupported number of bytes in `int' type!"
|
||||
#endif
|
||||
|
||||
/* The number of bytes in a `long' type. */
|
||||
#if ULONG_MAX == 0xFFFFFFFF
|
||||
#define FT_SIZEOF_LONG 4
|
||||
#elif ULONG_MAX > 0xFFFFFFFF && ULONG_MAX == 0xFFFFFFFFFFFFFFFF
|
||||
#define FT_SIZEOF_LONG 8
|
||||
#else
|
||||
#error "Unsupported number of bytes in `long' type!"
|
||||
#endif
|
||||
|
||||
|
||||
/* Preferred alignment of data */
|
||||
#define FT_ALIGNMENT 8
|
||||
|
||||
|
||||
/* UNUSED is a macro used to indicate that a given parameter is not used */
|
||||
/* -- this is only used to get rid of unpleasant compiler warnings */
|
||||
#ifndef FT_UNUSED
|
||||
#define FT_UNUSED( arg ) ( (arg) = (arg) )
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* AUTOMATIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros are computed from the ones defined above. Don't touch */
|
||||
/* their definition, unless you know precisely what you are doing. No */
|
||||
/* porter should need to mess with them. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* IntN types */
|
||||
/* */
|
||||
/* Used to guarantee the size of some specific integers. */
|
||||
/* */
|
||||
typedef signed short FT_Int16;
|
||||
typedef unsigned short FT_UInt16;
|
||||
|
||||
#if FT_SIZEOF_INT == 4
|
||||
|
||||
typedef signed int FT_Int32;
|
||||
typedef unsigned int FT_UInt32;
|
||||
|
||||
#elif FT_SIZEOF_LONG == 4
|
||||
|
||||
typedef signed long FT_Int32;
|
||||
typedef unsigned long FT_UInt32;
|
||||
|
||||
#else
|
||||
#error "no 32bit type found -- please check your configuration files"
|
||||
#endif
|
||||
|
||||
#if FT_SIZEOF_LONG == 8
|
||||
|
||||
/* FT_LONG64 must be defined if a 64-bit type is available */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Many compilers provide the non-ANSI `long long' 64-bit type. You can */
|
||||
/* activate it by defining the FTCALC_USE_LONG_LONG macro in */
|
||||
/* `ftoption.h'. */
|
||||
/* */
|
||||
/* Note that this will produce many -ansi warnings during library */
|
||||
/* compilation, and that in many cases, the generated code will be */
|
||||
/* neither smaller nor faster! */
|
||||
/* */
|
||||
#ifdef FTCALC_USE_LONG_LONG
|
||||
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long long
|
||||
|
||||
#endif /* FTCALC_USE_LONG_LONG */
|
||||
#endif /* FT_SIZEOF_LONG == 8 */
|
||||
|
||||
|
||||
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
#define LOCAL_DEF static
|
||||
#define LOCAL_FUNC static
|
||||
#else
|
||||
#define LOCAL_DEF extern
|
||||
#define LOCAL_FUNC /* nothing */
|
||||
#endif
|
||||
|
||||
#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT
|
||||
#define BASE_DEF( x ) static x
|
||||
#define BASE_FUNC( x ) static x
|
||||
#else
|
||||
#define BASE_DEF( x ) extern x
|
||||
#define BASE_FUNC( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_DEF
|
||||
#define FT_EXPORT_DEF( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_FUNC
|
||||
#define FT_EXPORT_FUNC( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_VAR
|
||||
#define FT_EXPORT_VAR( x ) extern x
|
||||
#endif
|
||||
|
||||
#endif /* FTCONFIG_H */
|
||||
|
||||
|
||||
/* END */
|
||||
10
src/freetype/freetype/config/ftmodule.h
Normal file
10
src/freetype/freetype/config/ftmodule.h
Normal file
@@ -0,0 +1,10 @@
|
||||
FT_USE_MODULE(autohint_module_class)
|
||||
FT_USE_MODULE(cff_driver_class)
|
||||
FT_USE_MODULE(t1cid_driver_class)
|
||||
FT_USE_MODULE(psnames_module_class)
|
||||
FT_USE_MODULE(ft_raster1_renderer_class)
|
||||
FT_USE_MODULE(sfnt_module_class)
|
||||
FT_USE_MODULE(ft_smooth_renderer_class)
|
||||
FT_USE_MODULE(tt_driver_class)
|
||||
FT_USE_MODULE(t1_driver_class)
|
||||
FT_USE_MODULE(winfnt_driver_class)
|
||||
395
src/freetype/freetype/config/ftoption.h
Normal file
395
src/freetype/freetype/config/ftoption.h
Normal file
@@ -0,0 +1,395 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftoption.h */
|
||||
/* */
|
||||
/* User-selectable configuration macros (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTOPTION_H
|
||||
#define FTOPTION_H
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* USER-SELECTABLE CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros can be toggled by developers to enable or disable */
|
||||
/* certain aspects of FreeType. This is a default file, where all major */
|
||||
/* options are enabled. */
|
||||
/* */
|
||||
/* Note that if some modifications are required for your build, we */
|
||||
/* advise you to put a modified copy of this file in your build */
|
||||
/* directory, rather than modifying it in-place. */
|
||||
/* */
|
||||
/* The build directory is normally `freetype/builds/<system>' and */
|
||||
/* contains build or system-specific files that are included in */
|
||||
/* priority when building the library. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Convenience functions support */
|
||||
/* */
|
||||
/* Some functions of the FreeType 2 API are provided as a convenience */
|
||||
/* for client applications and developers. However, they are not */
|
||||
/* required to build and run the library itself. */
|
||||
/* */
|
||||
/* By defining this configuration macro, you'll disable the */
|
||||
/* compilation of these functions at build time. This can be useful */
|
||||
/* to reduce the library's code size when you don't need any of */
|
||||
/* these functions. */
|
||||
/* */
|
||||
/* All convenience functions are declared as such in their */
|
||||
/* documentation. */
|
||||
/* */
|
||||
#undef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Alternate Glyph Image Format support */
|
||||
/* */
|
||||
/* By default, the glyph images returned by the FreeType glyph loader */
|
||||
/* can either be a pixmap or a vectorial outline defined through */
|
||||
/* Bezier control points. When defining the following configuration */
|
||||
/* macro, some font drivers will be able to register alternate */
|
||||
/* glyph image formats. */
|
||||
/* */
|
||||
/* Unset this macro if you are sure that you will never use a font */
|
||||
/* driver with an alternate glyph format; this will reduce the size of */
|
||||
/* the base layer code. */
|
||||
/* */
|
||||
/* Note that a few Type 1 fonts, as well as Windows `vector' fonts */
|
||||
/* use a vector `plotter' format that isn't supported when this */
|
||||
/* macro is undefined. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_ALTERNATE_GLYPH_FORMATS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Glyph Postscript Names handling */
|
||||
/* */
|
||||
/* By default, FreeType 2 is compiled with the `PSNames' module. This */
|
||||
/* This module is in charge of converting a glyph name string into a */
|
||||
/* Unicode value, or return a Macintosh standard glyph name for the */
|
||||
/* use with the TrueType `post' table. */
|
||||
/* */
|
||||
/* Undefine this macro if you do not want `PSNames' compiled in your */
|
||||
/* build of FreeType. This has the following effects: */
|
||||
/* */
|
||||
/* - The TrueType driver will provide its own set of glyph names, */
|
||||
/* if you build it to support postscript names in the TrueType */
|
||||
/* `post' table. */
|
||||
/* */
|
||||
/* - The Type 1 driver will not be able to synthetize a Unicode */
|
||||
/* charmap out of the glyphs found in the fonts. */
|
||||
/* */
|
||||
/* You would normally undefine this configuration macro when building */
|
||||
/* a version of FreeType that doesn't contain a Type 1 or CFF driver. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Postscript Names to Unicode Values support */
|
||||
/* */
|
||||
/* By default, FreeType 2 is built with the `PSNames' module compiled */
|
||||
/* in. Among other things, the module is used to convert a glyph name */
|
||||
/* into a Unicode value. This is especially useful in order to */
|
||||
/* synthetize on the fly a Unicode charmap from the CFF/Type 1 driver */
|
||||
/* through a big table named the `Adobe Glyph List' (AGL). */
|
||||
/* */
|
||||
/* Undefine this macro if you do not want the Adobe Glyph List */
|
||||
/* compiled in your `PSNames' module. The Type 1 driver will not be */
|
||||
/* able to synthetize a Unicode charmap out of the glyphs found in the */
|
||||
/* fonts. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Many compilers provide the non-ANSI `long long' 64-bit type. You can */
|
||||
/* activate it by defining the FTCALC_USE_LONG_LONG macro. Note that */
|
||||
/* this will produce many -ansi warnings during library compilation, and */
|
||||
/* that in many cases the generated code will not be smaller or faster! */
|
||||
/* */
|
||||
#undef FTCALC_USE_LONG_LONG
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* DLL export compilation */
|
||||
/* */
|
||||
/* When compiling FreeType as a DLL, some systems/compilers need a */
|
||||
/* special keyword in front OR after the return type of function */
|
||||
/* declarations. */
|
||||
/* */
|
||||
/* Two macros are used within the FreeType source code to define */
|
||||
/* exported library functions: FT_EXPORT_DEF and FT_EXPORT_FUNC. */
|
||||
/* */
|
||||
/* FT_EXPORT_DEF( return_type ) */
|
||||
/* */
|
||||
/* is used in a function declaration, as in */
|
||||
/* */
|
||||
/* FT_EXPORT_DEF( FT_Error ) */
|
||||
/* FT_Init_FreeType( FT_Library* alibrary ); */
|
||||
/* */
|
||||
/* */
|
||||
/* FT_EXPORT_FUNC( return_type ) */
|
||||
/* */
|
||||
/* is used in a function definition, as in */
|
||||
/* */
|
||||
/* FT_EXPORT_FUNC( FT_Error ) */
|
||||
/* FT_Init_FreeType( FT_Library* alibrary ) */
|
||||
/* { */
|
||||
/* ... some code ... */
|
||||
/* return FT_Err_Ok; */
|
||||
/* } */
|
||||
/* */
|
||||
/* You can provide your own implementation of FT_EXPORT_DEF and */
|
||||
/* FT_EXPORT_FUNC here if you want. If you leave them undefined, they */
|
||||
/* will be later automatically defined as `extern return_type' to */
|
||||
/* allow normal compilation. */
|
||||
/* */
|
||||
#undef FT_EXPORT_DEF
|
||||
#undef FT_EXPORT_FUNC
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Debug level */
|
||||
/* */
|
||||
/* FreeType can be compiled in debug or trace mode. In debug mode, */
|
||||
/* errors are reported through the `ftdebug' component. In trace */
|
||||
/* mode, additional messages are sent to the standard output during */
|
||||
/* execution. */
|
||||
/* */
|
||||
/* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */
|
||||
/* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */
|
||||
/* */
|
||||
/* Don't define any of these macros to compile in `release' mode! */
|
||||
/* */
|
||||
#define FT_DEBUG_LEVEL_ERROR
|
||||
#define FT_DEBUG_LEVEL_TRACE
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Computation Algorithms */
|
||||
/* */
|
||||
/* Used for debugging, this configuration macro should disappear */
|
||||
/* soon. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_OLD_CALCS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The size in bytes of the render pool used by the scan-line converter */
|
||||
/* to do all of its work. */
|
||||
/* */
|
||||
/* This must be greater than 4kByte. */
|
||||
/* */
|
||||
#define FT_RENDER_POOL_SIZE 16384
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FT_MAX_MODULES */
|
||||
/* */
|
||||
/* The maximum number of modules that can be registered in a single */
|
||||
/* FreeType library object. 16 is the default. */
|
||||
/* */
|
||||
#define FT_MAX_MODULES 16
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FT_MAX_EXTENSIONS */
|
||||
/* */
|
||||
/* The maximum number of extensions that can be registered in a single */
|
||||
/* font driver. 8 is the default. */
|
||||
/* */
|
||||
/* If you don't know what this means, you certainly do not need to */
|
||||
/* change this value. */
|
||||
/* */
|
||||
#define FT_MAX_EXTENSIONS 8
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** S F N T D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */
|
||||
/* embedded bitmaps in all formats using the SFNT module (namely */
|
||||
/* TrueType & OpenType). */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */
|
||||
/* load and enumerate the glyph Postscript names in a TrueType or */
|
||||
/* OpenType file. */
|
||||
/* */
|
||||
/* Note that when you do not compile the `PSNames' module by undefining */
|
||||
/* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */
|
||||
/* contain additional code used to read the PS Names table from a font. */
|
||||
/* */
|
||||
/* (By default, the module uses `PSNames' to extract glyph names.) */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */
|
||||
/* access the internal name table in a SFNT-based format like TrueType */
|
||||
/* or OpenType. The name table contains various strings used to */
|
||||
/* describe the font, like family name, copyright, version, etc. It */
|
||||
/* does not contain any glyph name though. */
|
||||
/* */
|
||||
/* Accessing SFNT names is done through the functions declared in */
|
||||
/* `freetype/ftnames.h'. */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_SFNT_NAMES
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */
|
||||
/* a bytecode interpreter in the TrueType driver. Note that there are */
|
||||
/* important patent issues related to the use of the interpreter. */
|
||||
/* */
|
||||
/* By undefining this, you will only compile the code necessary to load */
|
||||
/* TrueType glyphs without hinting. */
|
||||
/* */
|
||||
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_INTERPRETER_SWITCH to compile the TrueType */
|
||||
/* bytecode interpreter with a huge switch statement, rather than a call */
|
||||
/* table. This results in smaller and faster code for a number of */
|
||||
/* architectures. */
|
||||
/* */
|
||||
/* Note however that on some compiler/processor combinations, undefining */
|
||||
/* this macro will generate faster, though larger, code. */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_INTERPRETER_SWITCH
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_MAX_STACK_DEPTH is the maximal depth of the token stack used by */
|
||||
/* the Type 1 parser (see t1load.c). A minimum of 16 is required. */
|
||||
/* */
|
||||
#define T1_MAX_STACK_DEPTH 16
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_MAX_DICT_DEPTH is the maximal depth of nest dictionaries and */
|
||||
/* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */
|
||||
/* required. */
|
||||
/* */
|
||||
#define T1_MAX_DICT_DEPTH 5
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
|
||||
/* calls during glyph loading. */
|
||||
/* */
|
||||
#define T1_MAX_SUBRS_CALLS 8
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. */
|
||||
/* */
|
||||
#define T1_MAX_CHARSTRINGS_OPERANDS 32
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */
|
||||
/* driver with no hinter. This can be useful to debug the parser. */
|
||||
/* */
|
||||
#undef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define this configuration macro if you want to prevent the */
|
||||
/* compilation of `t1afm', which is in charge of reading Type 1 AFM */
|
||||
/* files into an existing face. Note that if set, the T1 driver will be */
|
||||
/* unable to produce kerning distances. */
|
||||
/* */
|
||||
#undef T1_CONFIG_OPTION_NO_AFM
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define this configuration macro if you want to prevent the */
|
||||
/* compilation of the Multiple Masters font support in the Type 1 */
|
||||
/* driver. */
|
||||
/* */
|
||||
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
|
||||
|
||||
|
||||
#endif /* FTOPTION_H */
|
||||
|
||||
|
||||
/* END */
|
||||
2286
src/freetype/freetype/freetype.h
Normal file
2286
src/freetype/freetype/freetype.h
Normal file
File diff suppressed because it is too large
Load Diff
72
src/freetype/freetype/ftbbox.h
Normal file
72
src/freetype/freetype/ftbbox.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftbbox.h */
|
||||
/* */
|
||||
/* FreeType bbox computation (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This component has a _single_ role: to compute exact outline bounding */
|
||||
/* boxes. */
|
||||
/* */
|
||||
/* It is separated from the rest of the engine for various technical */
|
||||
/* reasons. It may well be integrated in `ftoutln' later. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTBBOX_H
|
||||
#define FTBBOX_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Raster_GetBBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Computes the exact bounding box of an outline. This is slower */
|
||||
/* than computing the control box. However, it uses an advanced */
|
||||
/* algorithm which returns _very_ quickly when the two boxes */
|
||||
/* coincide. Otherwise, the outline Bezier arcs are walked over to */
|
||||
/* extract their extrema. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* bbox :: The outline's exact bounding box. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Raster_GetBBox( FT_Outline* outline,
|
||||
FT_BBox* abbox );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FTBBOX_H */
|
||||
|
||||
|
||||
/* END */
|
||||
166
src/freetype/freetype/fterrors.h
Normal file
166
src/freetype/freetype/fterrors.h
Normal file
@@ -0,0 +1,166 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* fterrors.h */
|
||||
/* */
|
||||
/* FreeType error codes (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file is used to define the FreeType error enumeration constants */
|
||||
/* It can also be used to create an error message table easily with */
|
||||
/* something like: */
|
||||
/* */
|
||||
/* { */
|
||||
/* #undef FTERRORS_H */
|
||||
/* #define FT_ERRORDEF( e, v, s ) { e, s }, */
|
||||
/* #define FT_ERROR_START_LIST { */
|
||||
/* #define FT_ERROR_END_LIST { 0, 0 } }; */
|
||||
/* */
|
||||
/* const struct */
|
||||
/* { */
|
||||
/* int err_code; */
|
||||
/* const char* err_msg */
|
||||
/* } ft_errors[] = */
|
||||
/* */
|
||||
/* #include <freetype/fterrors.h> */
|
||||
/* } */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTERRORS_H
|
||||
#define FTERRORS_H
|
||||
|
||||
|
||||
#ifndef FT_ERRORDEF
|
||||
|
||||
#define FT_ERRORDEF( e, v, s ) e = v,
|
||||
#define FT_ERROR_START_LIST enum {
|
||||
#define FT_ERROR_END_LIST FT_Err_Max };
|
||||
|
||||
#endif /* !FT_ERRORDEF */
|
||||
|
||||
|
||||
#ifdef FT_ERROR_START_LIST
|
||||
FT_ERROR_START_LIST
|
||||
#endif
|
||||
|
||||
FT_ERRORDEF( FT_Err_Ok, 0x0000, \
|
||||
"no error" )
|
||||
FT_ERRORDEF( FT_Err_Cannot_Open_Resource, 0x0001, \
|
||||
"can't open stream" )
|
||||
FT_ERRORDEF( FT_Err_Unknown_File_Format, 0x0002, \
|
||||
"unknown file format" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_File_Format, 0x0003, \
|
||||
"broken file" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Invalid_Argument, 0x0010, \
|
||||
"invalid argument" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Handle, 0x0011, \
|
||||
"invalid object handle" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Glyph_Index, 0x0012, \
|
||||
"invalid glyph index" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Character_Code, 0x0013, \
|
||||
"invalid character code" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Unimplemented_Feature, 0x0020, \
|
||||
"unimplemented feature" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Glyph_Format, 0x0021, \
|
||||
"unsupported glyph image format" )
|
||||
FT_ERRORDEF( FT_Err_Cannot_Render_Glyph, 0x0022, \
|
||||
"cannot render this glyph format" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Invalid_Library_Handle, 0x0030, \
|
||||
"invalid library handle" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Driver_Handle, 0x0031, \
|
||||
"invalid module handle" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Face_Handle, 0x0032, \
|
||||
"invalid face handle" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Size_Handle, 0x0033, \
|
||||
"invalid size handle" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Slot_Handle, 0x0034, \
|
||||
"invalid glyph slot handle" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_CharMap_Handle, 0x0035, \
|
||||
"invalid charmap handle" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Outline, 0x0036, \
|
||||
"invalid outline" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Version, 0x0037, \
|
||||
"invalid FreeType version" )
|
||||
FT_ERRORDEF( FT_Err_Lower_Module_Version, 0x0038, \
|
||||
"module version is too low" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Too_Many_Drivers, 0x0040, \
|
||||
"too many modules" )
|
||||
FT_ERRORDEF( FT_Err_Too_Many_Extensions, 0x0041, \
|
||||
"too many extensions" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Out_Of_Memory, 0x0050, \
|
||||
"out of memory" )
|
||||
FT_ERRORDEF( FT_Err_Unlisted_Object, 0x0051, \
|
||||
"unlisted object" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Invalid_Stream_Handle, 0x0060, \
|
||||
"invalid stream handle" )
|
||||
FT_ERRORDEF( FT_Err_Cannot_Open_Stream, 0x0061, \
|
||||
"cannot open stream" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Stream_Seek, 0x0062, \
|
||||
"invalid stream seek" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Stream_Skip, 0x0063, \
|
||||
"invalid stream skip" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Stream_Read, 0x0064, \
|
||||
"invalid stream read" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Stream_Operation, 0x0065, \
|
||||
"invalid stream operation" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Frame_Operation, 0x0066, \
|
||||
"invalid frame operation" )
|
||||
FT_ERRORDEF( FT_Err_Nested_Frame_Access, 0x0067, \
|
||||
"nested frame access" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Frame_Read, 0x0068, \
|
||||
"invalid frame read" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Invalid_Composite, 0x0070, \
|
||||
"invalid composite glyph" )
|
||||
FT_ERRORDEF( FT_Err_Too_Many_Hints, 0x0071, \
|
||||
"too many hints" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Raster_Uninitialized, 0x0080, \
|
||||
"raster uninitialized" )
|
||||
FT_ERRORDEF( FT_Err_Raster_Corrupted, 0x0081, \
|
||||
"raster corrupted" )
|
||||
FT_ERRORDEF( FT_Err_Raster_Overflow, 0x0082, \
|
||||
"raster overflow" )
|
||||
FT_ERRORDEF( FT_Err_Raster_Negative_Height, 0x0083, \
|
||||
"negative height while rastering" )
|
||||
|
||||
/* range 0x400 - 0x4FF is reserved for TrueType specific stuff */
|
||||
|
||||
/* range 0x500 - 0x5FF is reserved for CFF specific stuff */
|
||||
|
||||
/* range 0x600 - 0x6FF is reserved for Type1 specific stuff */
|
||||
|
||||
#ifdef FT_ERROR_END_LIST
|
||||
FT_ERROR_END_LIST
|
||||
#endif
|
||||
|
||||
|
||||
#undef FT_ERROR_START_LIST
|
||||
#undef FT_ERROR_END_LIST
|
||||
#undef FT_ERRORDEF
|
||||
|
||||
|
||||
#endif /* FTERRORS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
422
src/freetype/freetype/ftglyph.h
Normal file
422
src/freetype/freetype/ftglyph.h
Normal file
@@ -0,0 +1,422 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftglyph.h */
|
||||
/* */
|
||||
/* FreeType convenience functions to handle glyphs (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file contains the definition of several convenience functions */
|
||||
/* that can be used by client applications to easily retrieve glyph */
|
||||
/* bitmaps and outlines from a given face. */
|
||||
/* */
|
||||
/* These functions should be optional if you are writing a font server */
|
||||
/* or text layout engine on top of FreeType. However, they are pretty */
|
||||
/* handy for many other simple uses of the library. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTGLYPH_H
|
||||
#define FTGLYPH_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* forward declaration to a private type */
|
||||
typedef struct FT_Glyph_Class_ FT_Glyph_Class;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_GlyphRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The root glyph structure contains a given glyph image plus its */
|
||||
/* advance width in 16.16 fixed float format. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* library :: A handle to the FreeType library object. */
|
||||
/* */
|
||||
/* clazz :: A pointer to the glyph's class. Private. */
|
||||
/* */
|
||||
/* format :: The format of the glyph's image. */
|
||||
/* */
|
||||
/* advance :: A 16.16 vector that gives the glyph's advance width. */
|
||||
/* */
|
||||
typedef struct FT_GlyphRec_
|
||||
{
|
||||
FT_Library library;
|
||||
const FT_Glyph_Class* clazz;
|
||||
FT_Glyph_Format format;
|
||||
FT_Vector advance;
|
||||
|
||||
} FT_GlyphRec, *FT_Glyph;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_BitmapGlyphRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used for bitmap glyph images. This really is a */
|
||||
/* `sub-class' of `FT_GlyphRec'. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: The root FT_Glyph fields. */
|
||||
/* */
|
||||
/* left :: The left-side bearing, i.e., the horizontal distance */
|
||||
/* from the current pen position to the left border of the */
|
||||
/* glyph bitmap. */
|
||||
/* */
|
||||
/* top :: The top-side bearing, i.e., the vertical distance from */
|
||||
/* the current pen position to the top border of the glyph */
|
||||
/* bitmap. This distance is positive for upwards-y! */
|
||||
/* */
|
||||
/* bitmap :: A descriptor for the bitmap. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You can typecast FT_Glyph to FT_BitmapGlyph if you have */
|
||||
/* glyph->format == ft_glyph_format_bitmap. This lets you access */
|
||||
/* the bitmap's contents easily. */
|
||||
/* */
|
||||
/* The corresponding pixel buffer is always owned by the BitmapGlyph */
|
||||
/* and is thus created and destroyed with it. */
|
||||
/* */
|
||||
typedef struct FT_BitmapGlyphRec_
|
||||
{
|
||||
FT_GlyphRec root;
|
||||
FT_Int left;
|
||||
FT_Int top;
|
||||
FT_Bitmap bitmap;
|
||||
|
||||
} FT_BitmapGlyphRec, *FT_BitmapGlyph;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_OutlineGlyphRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used for outline (vectorial) glyph images. This */
|
||||
/* really is a `sub-class' of `FT_GlyphRec'. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: The root FT_Glyph fields. */
|
||||
/* */
|
||||
/* outline :: A descriptor for the outline. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You can typecast FT_Glyph to FT_OutlineGlyph if you have */
|
||||
/* glyph->format == ft_glyph_format_outline. This lets you access */
|
||||
/* the outline's content easily. */
|
||||
/* */
|
||||
/* As the outline is extracted from a glyph slot, its coordinates are */
|
||||
/* expressed normally in 26.6 pixels, unless the flag */
|
||||
/* FT_LOAD_NO_SCALE was used in FT_Load_Glyph() or FT_Load_Char(). */
|
||||
/* */
|
||||
/* The outline's tables are always owned by the object and are */
|
||||
/* destroyed with it. */
|
||||
/* */
|
||||
typedef struct FT_OutlineGlyphRec_
|
||||
{
|
||||
FT_GlyphRec root;
|
||||
FT_Outline outline;
|
||||
|
||||
} FT_OutlineGlyphRec, *FT_OutlineGlyph;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to extract a glyph image from a slot. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* slot :: A handle to the source glyph slot. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aglyph :: A handle to the glyph object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot,
|
||||
FT_Glyph* aglyph );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to copy a glyph image. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source glyph object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target glyph object. 0 in case of */
|
||||
/* error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Glyph_Copy( FT_Glyph source,
|
||||
FT_Glyph* target );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Transforms a glyph image if its format is scalable. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph :: A handle to the target glyph object. */
|
||||
/* */
|
||||
/* matrix :: A pointer to a 2x2 matrix to apply. */
|
||||
/* */
|
||||
/* delta :: A pointer to a 2d vector to apply. Coordinates are */
|
||||
/* expressed in 1/64th of a pixel. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code (the glyph format is not scalable if it is */
|
||||
/* not zero). */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The 2x2 transformation matrix is also applied to the glyph's */
|
||||
/* advance vector. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Glyph_Transform( FT_Glyph glyph,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
ft_glyph_bbox_pixels = 0,
|
||||
ft_glyph_bbox_subpixels = 1,
|
||||
ft_glyph_bbox_gridfit = 2
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_Get_CBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Returns the glyph image's bounding box. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph :: A handle to the source glyph object. */
|
||||
/* */
|
||||
/* mode :: A set of bit flags that indicate how to interpret the */
|
||||
/* returned bounding box values. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* box :: The glyph bounding box. Coordinates are expressed in */
|
||||
/* 1/64th of pixels if it is grid-fitted. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Coordinates are relative to the glyph origin, using the Y-upwards */
|
||||
/* convention. */
|
||||
/* */
|
||||
/* If `ft_glyph_bbox_subpixels' is set in `mode', the bbox */
|
||||
/* coordinates are returned in 26.6 pixels (i.e. 1/64th of pixels). */
|
||||
/* Otherwise, coordinates are expressed in integer pixels. */
|
||||
/* */
|
||||
/* Note that the maximum coordinates are exclusive, which means that */
|
||||
/* one can compute the width and height of the glyph image (be it in */
|
||||
/* integer or 26.6 pixels) as: */
|
||||
/* */
|
||||
/* width = bbox.xMax - bbox.xMin; */
|
||||
/* height = bbox.yMax - bbox.yMin; */
|
||||
/* */
|
||||
/* Note also that for 26.6 coordinates, if the */
|
||||
/* `ft_glyph_bbox_gridfit' flag is set in `mode;, the coordinates */
|
||||
/* will also be grid-fitted, which corresponds to: */
|
||||
/* */
|
||||
/* bbox.xMin = FLOOR(bbox.xMin); */
|
||||
/* bbox.yMin = FLOOR(bbox.yMin); */
|
||||
/* bbox.xMax = CEILING(bbox.xMax); */
|
||||
/* bbox.yMax = CEILING(bbox.yMax); */
|
||||
/* */
|
||||
/* The default value (0) for `bbox_mode' is `ft_glyph_bbox_pixels'. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Glyph_Get_CBox( FT_Glyph glyph,
|
||||
FT_UInt bbox_mode,
|
||||
FT_BBox* cbox );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_To_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Converts a given glyph object to a bitmap glyph object. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* glyph :: A pointer to a handle to the target glyph. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* render_mode :: A set of bit flags that describe how the data is */
|
||||
/* */
|
||||
/* */
|
||||
/* origin :: A pointer to a vector used to translate the glyph */
|
||||
/* image before rendering. Can be 0 (if no */
|
||||
/* translation). The origin is expressed in */
|
||||
/* 26.6 pixels. */
|
||||
/* */
|
||||
/* destroy :: A boolean that indicates that the original glyph */
|
||||
/* image should be destroyed by this function. It is */
|
||||
/* never destroyed in case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The glyph image is translated with the `origin' vector before */
|
||||
/* rendering. In case of error, it it translated back to its */
|
||||
/* original position and the glyph is left untouched. */
|
||||
/* */
|
||||
/* The first parameter is a pointer to a FT_Glyph handle, that will */
|
||||
/* be replaced by this function. Typically, you would use (omitting */
|
||||
/* error handling): */
|
||||
/* */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_Glyph glyph; */
|
||||
/* FT_BitmapGlyph glyph_bitmap; */
|
||||
/* */
|
||||
/* */
|
||||
/* // load glyph */
|
||||
/* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */
|
||||
/* */
|
||||
/* // extract glyph image */
|
||||
/* error = FT_Get_Glyph( face->glyph, &glyph ); */
|
||||
/* */
|
||||
/* // convert to a bitmap (default render mode + destroy old) */
|
||||
/* if ( glyph->format != ft_glyph_format_bitmap ) */
|
||||
/* { */
|
||||
/* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, */
|
||||
/* 0, 1 ); */
|
||||
/* if ( error ) // glyph unchanged */
|
||||
/* ... */
|
||||
/* } */
|
||||
/* */
|
||||
/* // access bitmap content by typecasting */
|
||||
/* glyph_bitmap = (FT_BitmapGlyph)glyph; */
|
||||
/* */
|
||||
/* // do funny stuff with it, like blitting/drawing */
|
||||
/* ... */
|
||||
/* */
|
||||
/* // discard glyph image (bitmap or not) */
|
||||
/* FT_Done_Glyph( glyph ); */
|
||||
/* } */
|
||||
/* */
|
||||
/* */
|
||||
/* This function will always fail if the glyph's format isn't */
|
||||
/* scalable. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
|
||||
FT_ULong render_mode,
|
||||
FT_Vector* origin,
|
||||
FT_Bool destroy );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroys a given glyph. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph :: A handle to the target glyph object. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Done_Glyph( FT_Glyph glyph );
|
||||
|
||||
|
||||
/* other helpful functions */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Multiply */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Performs the matrix operation `b = a*b'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: A pointer to matrix `a'. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* b :: A pointer to matrix `b'. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The result is undefined if either `a' or `b' is zero. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Matrix_Multiply( FT_Matrix* a,
|
||||
FT_Matrix* b );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Invert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* matrix :: A pointer to the target matrix. Remains untouched in */
|
||||
/* case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FTGLYPH_H */
|
||||
|
||||
|
||||
/* END */
|
||||
1003
src/freetype/freetype/ftimage.h
Normal file
1003
src/freetype/freetype/ftimage.h
Normal file
File diff suppressed because it is too large
Load Diff
175
src/freetype/freetype/ftmm.h
Normal file
175
src/freetype/freetype/ftmm.h
Normal file
@@ -0,0 +1,175 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmm.h */
|
||||
/* */
|
||||
/* FreeType Multiple Master font interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTMM_H
|
||||
#define FTMM_H
|
||||
|
||||
#include <freetype/t1tables.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_MM_Axis */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to model a given axis in design space for */
|
||||
/* Multiple Masters fonts. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* name :: The axis's name. */
|
||||
/* */
|
||||
/* minimum :: The axis's minimum design coordinate. */
|
||||
/* */
|
||||
/* maximum :: The axis's maximum design coordinate. */
|
||||
/* */
|
||||
typedef struct FT_MM_Axis_
|
||||
{
|
||||
FT_String* name;
|
||||
FT_Long minimum;
|
||||
FT_Long maximum;
|
||||
|
||||
} FT_MM_Axis;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Multi_Master */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model the axes and space of a Multiple Masters */
|
||||
/* font. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_axis :: Number of axes. Cannot exceed 4. */
|
||||
/* */
|
||||
/* num_designs :: Number of designs; should ne normally 2^num_axis */
|
||||
/* even though the Type 1 specification strangely */
|
||||
/* allows for intermediate designs to be present. This */
|
||||
/* number cannot exceed 16. */
|
||||
/* */
|
||||
/* axis :: A table of axis descriptors. */
|
||||
/* */
|
||||
typedef struct FT_Multi_Master_
|
||||
{
|
||||
FT_UInt num_axis;
|
||||
FT_UInt num_designs;
|
||||
FT_MM_Axis axis[T1_MAX_MM_AXIS];
|
||||
|
||||
} FT_Multi_Master;
|
||||
|
||||
|
||||
typedef FT_Error (*FT_Get_MM_Func)( FT_Face face,
|
||||
FT_Multi_Master* master );
|
||||
|
||||
typedef FT_Error (*FT_Set_MM_Design_Func)( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Long* coords );
|
||||
|
||||
typedef FT_Error (*FT_Set_MM_Blend_Func)( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Long* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Multi_Master */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieves the Multiple Master descriptor of a given font. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* master :: The Multiple Masters descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Get_Multi_Master( FT_Face face,
|
||||
FT_Multi_Master* master );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_MM_Design_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* For Multiple Masters fonts, choose an interpolated font design */
|
||||
/* through design coordinates. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* num_coords :: The number of design coordinates (must be equal to */
|
||||
/* the number of axes in the font). */
|
||||
/* */
|
||||
/* coords :: The design coordinates. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Set_MM_Design_Coordinates(
|
||||
FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Long* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_MM_Blend_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* For Multiple Masters fonts, choose an interpolated font design */
|
||||
/* through normalized blend coordinates. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* num_coords :: The number of design coordinates (must be equal to */
|
||||
/* the number of axes in the font). */
|
||||
/* */
|
||||
/* coords :: The design coordinates (each one must be between 0 */
|
||||
/* and 1.0). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Set_MM_Blend_Coordinates(
|
||||
FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FTMM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
274
src/freetype/freetype/ftmodule.h
Normal file
274
src/freetype/freetype/ftmodule.h
Normal file
@@ -0,0 +1,274 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmodule.h */
|
||||
/* */
|
||||
/* FreeType modules public interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTMODULE_H
|
||||
#define FTMODULE_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* module bit flags */
|
||||
typedef enum FT_Module_Flags_
|
||||
{
|
||||
ft_module_font_driver = 1, /* this module is a font driver */
|
||||
ft_module_renderer = 2, /* this module is a renderer */
|
||||
ft_module_hinter = 4, /* this module is a glyph hinter */
|
||||
ft_module_styler = 8, /* this module is a styler */
|
||||
|
||||
ft_module_driver_scalable = 0x100, /* the driver supports scalable */
|
||||
/* fonts */
|
||||
ft_module_driver_no_outlines = 0x200, /* the driver does not support */
|
||||
/* vector outlines */
|
||||
ft_module_driver_has_hinter = 0x400 /* the driver provides its own */
|
||||
/* hinter */
|
||||
|
||||
} FT_Module_Flags;
|
||||
|
||||
|
||||
typedef void (*FT_Module_Interface)( void );
|
||||
|
||||
typedef FT_Error (*FT_Module_Constructor)( FT_Module module );
|
||||
|
||||
typedef void (*FT_Module_Destructor)( FT_Module module );
|
||||
|
||||
typedef FT_Module_Interface (*FT_Module_Requester)( FT_Module module,
|
||||
const char* name );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Module_Class */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The module class descriptor. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* module_flags :: Bit flags describing the module. */
|
||||
/* */
|
||||
/* module_size :: The size of one module object/instance in */
|
||||
/* bytes. */
|
||||
/* */
|
||||
/* module_name :: The name of the module. */
|
||||
/* */
|
||||
/* module_version :: The version, as a 16.16 fixed number */
|
||||
/* (major.minor). */
|
||||
/* */
|
||||
/* module_requires :: The version of FreeType this module requires */
|
||||
/* (starts at version 2.0, i.e 0x20000) */
|
||||
/* */
|
||||
/* module_init :: A function used to initialize (not create) a */
|
||||
/* new module object. */
|
||||
/* */
|
||||
/* module_done :: A function used to finalize (not destroy) a */
|
||||
/* given module object */
|
||||
/* */
|
||||
/* get_interface :: Queries a given module for a specific */
|
||||
/* interface by name. */
|
||||
/* */
|
||||
typedef struct FT_Module_Class_
|
||||
{
|
||||
FT_ULong module_flags;
|
||||
FT_Int module_size;
|
||||
const FT_String* module_name;
|
||||
FT_Fixed module_version;
|
||||
FT_Fixed module_requires;
|
||||
|
||||
const void* module_interface;
|
||||
|
||||
FT_Module_Constructor module_init;
|
||||
FT_Module_Destructor module_done;
|
||||
FT_Module_Requester get_interface;
|
||||
|
||||
} FT_Module_Class;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Add_Module */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Adds a new module to a given library instance. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* clazz :: A pointer to class descriptor for the module. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An error will be returned if a module already exists by that name, */
|
||||
/* or if the module requires a version of FreeType that is too great. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Add_Module( FT_Library library,
|
||||
const FT_Module_Class* clazz );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Module */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finds a module by its name. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* module_name :: The module's name (as an ASCII string). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A module handle. 0 if none was found. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should better be familiar with FreeType internals to know */
|
||||
/* which module to look for :-) */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Module ) FT_Get_Module( FT_Library library,
|
||||
const char* module_name );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Remove_Module */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Removes a given module from a library instance. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a library object. */
|
||||
/* */
|
||||
/* module :: A handle to a module object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The module object is destroyed by the function in case of success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Remove_Module( FT_Library library,
|
||||
FT_Module module );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Library */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is used to create a new FreeType library instance */
|
||||
/* from a given memory object. It is thus possible to use libraries */
|
||||
/* with distinct memory allocators within the same program. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A handle to the original memory object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* alibrary :: A pointer to handle of a new library object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_New_Library( FT_Memory memory,
|
||||
FT_Library* library );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_Library */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Discards a given library object. This closes all drivers and */
|
||||
/* discards all resource objects. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the target library. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Done_Library( FT_Library library );
|
||||
|
||||
|
||||
|
||||
typedef void (*FT_DebugHook_Func)( void* arg );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Debug_Hook */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Sets a debug hook function for debugging the interpreter of a font */
|
||||
/* format. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* hook_index :: The index of the debug hook. You should use the */
|
||||
/* values defined in ftobjs.h, e.g. */
|
||||
/* FT_DEBUG_HOOK_TRUETYPE */
|
||||
/* */
|
||||
/* debug_hook :: The function used to debug the interpreter. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Currently, four debug hook slots are available, but only two (for */
|
||||
/* the TrueType and the Type 1 interpreter) are defined. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Set_Debug_Hook( FT_Library library,
|
||||
FT_UInt hook_index,
|
||||
FT_DebugHook_Func debug_hook );
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Add_Default_Modules */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Adds the set of default drivers to a given library object. */
|
||||
/* This is only useful when you create a library object with */
|
||||
/* FT_New_Library() (usually to plug a custom memory manager). */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to a new library object. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Add_Default_Modules( FT_Library library );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTMODULE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
52
src/freetype/freetype/ftnames.h
Normal file
52
src/freetype/freetype/ftnames.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftnames.h */
|
||||
/* */
|
||||
/* Simple interface to access SFNT name tables (which are used */
|
||||
/* to hold font names, copyright info, notices, etc.). */
|
||||
/* */
|
||||
/* This is _not_ used to retrieve glyph names! */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTNAMES_H
|
||||
#define FTNAMES_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
typedef struct FT_SfntName_
|
||||
{
|
||||
FT_UShort platform_id;
|
||||
FT_UShort encoding_id;
|
||||
FT_UShort language_id;
|
||||
FT_UShort name_id;
|
||||
|
||||
FT_Byte* string;
|
||||
FT_UInt string_len; /* in bytes */
|
||||
|
||||
} FT_SfntName;
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_UInt ) FT_Get_Sfnt_Name_Count( FT_Face face );
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Get_Sfnt_Name( FT_Face face,
|
||||
FT_UInt index,
|
||||
FT_SfntName* aname );
|
||||
|
||||
|
||||
#endif /* FTNAMES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
344
src/freetype/freetype/ftoutln.h
Normal file
344
src/freetype/freetype/ftoutln.h
Normal file
@@ -0,0 +1,344 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftoutln.h */
|
||||
/* */
|
||||
/* Support for the FT_Outline type used to store glyph shapes of */
|
||||
/* most scalable font formats (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTOUTLN_H
|
||||
#define FTOUTLN_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Decompose */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Walks over an outline's structure to decompose it into individual */
|
||||
/* segments and Bezier arcs. This function is also able to emit */
|
||||
/* `move to' and `close to' operations to indicate the start and end */
|
||||
/* of new contours in the outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source target. */
|
||||
/* */
|
||||
/* interface :: A table of `emitters', i.e,. function pointers called */
|
||||
/* during decomposition to indicate path operations. */
|
||||
/* */
|
||||
/* user :: A typeless pointer which is passed to each emitter */
|
||||
/* during the decomposition. It can be used to store */
|
||||
/* the state during the decomposition. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means sucess. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_Decompose(
|
||||
FT_Outline* outline,
|
||||
FT_Outline_Funcs* interface,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_New */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates a new outline of a given size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object from where the */
|
||||
/* outline is allocated. Note however that the new */
|
||||
/* outline will NOT necessarily be FREED, when */
|
||||
/* destroying the library, by FT_Done_FreeType(). */
|
||||
/* */
|
||||
/* numPoints :: The maximal number of points within the outline. */
|
||||
/* */
|
||||
/* numContours :: The maximal number of contours within the outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* outline :: A handle to the new outline. NULL in case of */
|
||||
/* error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* No. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The reason why this function takes a `library' parameter is simply */
|
||||
/* to use the library's memory allocator. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_New( FT_Library library,
|
||||
FT_UInt numPoints,
|
||||
FT_Int numContours,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_New_Internal(
|
||||
FT_Memory memory,
|
||||
FT_UInt numPoints,
|
||||
FT_Int numContours,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Done */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroys an outline created with FT_Outline_New(). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle of the library object used to allocate the */
|
||||
/* outline. */
|
||||
/* */
|
||||
/* outline :: A pointer to the outline object to be discarded. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* No. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If the outline's `owner' field is not set, only the outline */
|
||||
/* descriptor will be released. */
|
||||
/* */
|
||||
/* The reason why this function takes an `outline' parameter is */
|
||||
/* simply to use FT_Free(). */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_Done( FT_Library library,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_Done_Internal( FT_Memory memory,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_CBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Returns an outline's `control box'. The control box encloses all */
|
||||
/* the outline's points, including Bezier control points. Though it */
|
||||
/* coincides with the exact bounding box for most glyphs, it can be */
|
||||
/* slightly larger in some situations (like when rotating an outline */
|
||||
/* which contains Bezier outside arcs). */
|
||||
/* */
|
||||
/* Computing the control box is very fast, while getting the bounding */
|
||||
/* box can take much more time as it needs to walk over all segments */
|
||||
/* and arcs in the outline. To get the latter, you can use the */
|
||||
/* `ftbbox' component which is dedicated to this single task. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* cbox :: The outline's control box. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Outline_Get_CBox( FT_Outline* outline,
|
||||
FT_BBox* cbox );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Translate */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Applies a simple translation to the points of an outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* xOffset :: The horizontal offset. */
|
||||
/* */
|
||||
/* yOffset :: The vertical offset. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Outline_Translate( FT_Outline* outline,
|
||||
FT_Pos xOffset,
|
||||
FT_Pos yOffset );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Copies an outline into another one. Both objects must have the */
|
||||
/* same sizes (number of points & number of contours) when this */
|
||||
/* function is called. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_Copy( FT_Outline* source,
|
||||
FT_Outline* target );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Vector_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Transforms a single vector through a 2x2 matrix. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* vector :: The target vector to transform. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* matrix :: A pointer to the source 2x2 matrix. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The result is undefined if either `vector' or `matrix' is invalid. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Outline_Transform( FT_Outline* outline,
|
||||
FT_Matrix* matrix );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Reverse */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Reverses the drawing direction of an outline. This is used to */
|
||||
/* ensure consistent fill conventions for mirrored glyphs. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This functions toggles the bit flag `ft_outline_reverse_fill' in */
|
||||
/* the outline's `flags' field. */
|
||||
/* */
|
||||
/* It shouldn't be used by a normal client application, unless it */
|
||||
/* knows what it is doing. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Outline_Reverse( FT_Outline* outline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Renders an outline within a bitmap. The outline's image is simply */
|
||||
/* OR-ed to the target bitmap. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* map :: A pointer to the target bitmap descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* YES. Rendering is synchronized, so that concurrent calls to the */
|
||||
/* scan-line converter will be serialized. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does NOT CREATE the bitmap, it only renders an */
|
||||
/* outline image within the one you pass to it! */
|
||||
/* */
|
||||
/* It will use the raster correponding to the default glyph format. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_Get_Bitmap( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
FT_Bitmap* bitmap );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Render */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Renders an outline within a bitmap using the current scan-convert. */
|
||||
/* This functions uses an FT_Raster_Params structure as an argument, */
|
||||
/* allowing advanced features like direct composition, translucency, */
|
||||
/* etc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* params :: A pointer to a FT_Raster_Params structure used to */
|
||||
/* describe the rendering operation. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* YES. Rendering is synchronized, so that concurrent calls to the */
|
||||
/* scan-line converter will be serialized. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should know what you are doing and how FT_Raster_Params works */
|
||||
/* to use this function. */
|
||||
/* */
|
||||
/* The field `params.source' will be set to `outline' before the scan */
|
||||
/* converter is called, which means that the value you give to it is */
|
||||
/* actually ignored. */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Outline_Render( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
FT_Raster_Params* params );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTOUTLN_H */
|
||||
|
||||
|
||||
/* END */
|
||||
191
src/freetype/freetype/ftrender.h
Normal file
191
src/freetype/freetype/ftrender.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftrender.h */
|
||||
/* */
|
||||
/* FreeType renderer modules public interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTRENDER_H
|
||||
#define FTRENDER_H
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* create a new glyph object */
|
||||
typedef FT_Error (*FT_Glyph_Init_Func)( FT_Glyph glyph,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
/* destroys a given glyph object */
|
||||
typedef void (*FT_Glyph_Done_Func)( FT_Glyph glyph );
|
||||
|
||||
typedef void (*FT_Glyph_Transform_Func)( FT_Glyph glyph,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
typedef void (*FT_Glyph_BBox_Func)( FT_Glyph glyph,
|
||||
FT_BBox* abbox );
|
||||
|
||||
typedef FT_Error (*FT_Glyph_Copy_Func)( FT_Glyph source,
|
||||
FT_Glyph target );
|
||||
|
||||
typedef FT_Error (*FT_Glyph_Prepare_Func)( FT_Glyph glyph,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
struct FT_Glyph_Class_
|
||||
{
|
||||
FT_UInt glyph_size;
|
||||
FT_Glyph_Format glyph_format;
|
||||
FT_Glyph_Init_Func glyph_init;
|
||||
FT_Glyph_Done_Func glyph_done;
|
||||
FT_Glyph_Copy_Func glyph_copy;
|
||||
FT_Glyph_Transform_Func glyph_transform;
|
||||
FT_Glyph_BBox_Func glyph_bbox;
|
||||
FT_Glyph_Prepare_Func glyph_prepare;
|
||||
};
|
||||
|
||||
|
||||
typedef FT_Error (*FTRenderer_render)( FT_Renderer renderer,
|
||||
FT_GlyphSlot slot,
|
||||
FT_UInt mode,
|
||||
FT_Vector* origin );
|
||||
|
||||
typedef FT_Error (*FTRenderer_transform)( FT_Renderer renderer,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
typedef void (*FTRenderer_getCBox)( FT_Renderer renderer,
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox* cbox );
|
||||
|
||||
typedef FT_Error (*FTRenderer_setMode)( FT_Renderer renderer,
|
||||
FT_ULong mode_tag,
|
||||
FT_Pointer mode_ptr );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Renderer_Class */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The renderer module class descriptor. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: The root FT_Module_Class fields. */
|
||||
/* */
|
||||
/* glyph_format :: The glyph image format this renderer handles. */
|
||||
/* */
|
||||
/* render_glyph :: A method used to render the image that is in a */
|
||||
/* given glyph slot into a bitmap. */
|
||||
/* */
|
||||
/* set_mode :: A method used to pass additional parameters. */
|
||||
/* */
|
||||
/* raster_class :: For `ft_glyph_format_outline' renderers only, this */
|
||||
/* is a pointer to its raster's class. */
|
||||
/* */
|
||||
/* raster :: For `ft_glyph_format_outline' renderers only. this */
|
||||
/* is a pointer to the corresponding raster object, */
|
||||
/* if any. */
|
||||
/* */
|
||||
typedef struct FT_Renderer_Class_
|
||||
{
|
||||
FT_Module_Class root;
|
||||
|
||||
FT_Glyph_Format glyph_format;
|
||||
|
||||
FTRenderer_render render_glyph;
|
||||
FTRenderer_transform transform_glyph;
|
||||
FTRenderer_getCBox get_glyph_cbox;
|
||||
FTRenderer_setMode set_mode;
|
||||
|
||||
FT_Raster_Funcs* raster_class;
|
||||
|
||||
} FT_Renderer_Class;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Renderer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieves the current renderer for a given glyph format. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* format :: The glyph format. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A renderer handle. 0 if none found. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An error will be returned if a module already exists by that name, */
|
||||
/* or if the module requires a version of FreeType that is too great. */
|
||||
/* */
|
||||
/* To add a new renderer, simply use FT_Add_Module(). To retrieve a */
|
||||
/* renderer by its name, use FT_Get_Module(). */
|
||||
/* */
|
||||
FT_EXPORT_DEF( FT_Renderer ) FT_Get_Renderer( FT_Library library,
|
||||
FT_Glyph_Format format );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Renderer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Sets the current renderer to use, and set additional mode. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* renderer :: A handle to the renderer object. */
|
||||
/* */
|
||||
/* num_params :: The number of additional parameters. */
|
||||
/* */
|
||||
/* parameters :: Additional parameters. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* In case of success, the renderer will be used to convert glyph */
|
||||
/* images in the renderer's known format into bitmaps. */
|
||||
/* */
|
||||
/* This doesn't change the current renderer for other formats. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Set_Renderer( FT_Library library,
|
||||
FT_Renderer renderer,
|
||||
FT_UInt num_params,
|
||||
FT_Parameter* parameters );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTRENDER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
101
src/freetype/freetype/ftsystem.h
Normal file
101
src/freetype/freetype/ftsystem.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsystem.h */
|
||||
/* */
|
||||
/* FreeType low-level system interface definition (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTSYSTEM_H
|
||||
#define FTSYSTEM_H
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* M E M O R Y M A N A G E M E N T */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
typedef struct FT_MemoryRec_* FT_Memory;
|
||||
|
||||
|
||||
typedef void* (*FT_Alloc_Func)( FT_Memory memory,
|
||||
long size );
|
||||
|
||||
typedef void (*FT_Free_Func)( FT_Memory memory,
|
||||
void* block );
|
||||
|
||||
typedef void* (*FT_Realloc_Func)( FT_Memory memory,
|
||||
long cur_size,
|
||||
long new_size,
|
||||
void* block );
|
||||
|
||||
|
||||
struct FT_MemoryRec_
|
||||
{
|
||||
void* user;
|
||||
FT_Alloc_Func alloc;
|
||||
FT_Free_Func free;
|
||||
FT_Realloc_Func realloc;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* I / O M A N A G E M E N T */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
typedef union FT_StreamDesc_
|
||||
{
|
||||
long value;
|
||||
void* pointer;
|
||||
|
||||
} FT_StreamDesc;
|
||||
|
||||
|
||||
typedef struct FT_StreamRec_* FT_Stream;
|
||||
|
||||
|
||||
typedef unsigned long (*FT_Stream_IO)( FT_Stream stream,
|
||||
unsigned long offset,
|
||||
unsigned char* buffer,
|
||||
unsigned long count );
|
||||
|
||||
typedef void (*FT_Stream_Close)( FT_Stream stream );
|
||||
|
||||
|
||||
struct FT_StreamRec_
|
||||
{
|
||||
unsigned char* base;
|
||||
unsigned long size;
|
||||
unsigned long pos;
|
||||
|
||||
FT_StreamDesc descriptor;
|
||||
FT_StreamDesc pathname; /* ignored by FreeType -- */
|
||||
/* useful for debugging */
|
||||
FT_Stream_IO read;
|
||||
FT_Stream_Close close;
|
||||
|
||||
FT_Memory memory;
|
||||
unsigned char* cursor;
|
||||
unsigned char* limit;
|
||||
};
|
||||
|
||||
|
||||
#endif /* FTSYSTEM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
400
src/freetype/freetype/fttypes.h
Normal file
400
src/freetype/freetype/fttypes.h
Normal file
@@ -0,0 +1,400 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* fttypes.h */
|
||||
/* */
|
||||
/* FreeType simple types definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTTYPES_H
|
||||
#define FTTYPES_H
|
||||
|
||||
|
||||
#include <freetype/ftsystem.h>
|
||||
#include <freetype/ftimage.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Bool */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef of unsigned char, used for simple booleans. */
|
||||
/* */
|
||||
typedef unsigned char FT_Bool;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_FWord */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A signed 16-bit integer used to store a distance in original font */
|
||||
/* units. */
|
||||
/* */
|
||||
typedef signed short FT_FWord; /* distance in FUnits */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UFWord */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An unsigned 16-bit integer used to store a distance in original */
|
||||
/* font units. */
|
||||
/* */
|
||||
typedef unsigned short FT_UFWord; /* unsigned distance */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Char */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for the _signed_ char type. */
|
||||
/* */
|
||||
typedef signed char FT_Char;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Byte */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for the _unsigned_ char type. */
|
||||
/* */
|
||||
typedef unsigned char FT_Byte;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_String */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for the char type, usually used for strings. */
|
||||
/* */
|
||||
typedef char FT_String;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Short */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for signed short. */
|
||||
/* */
|
||||
typedef signed short FT_Short;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UShort */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for unsigned short. */
|
||||
/* */
|
||||
typedef unsigned short FT_UShort;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Int */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for the int type. */
|
||||
/* */
|
||||
typedef int FT_Int;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UInt */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for the unsigned int type. */
|
||||
/* */
|
||||
typedef unsigned int FT_UInt;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Long */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for signed long. */
|
||||
/* */
|
||||
typedef signed long FT_Long;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_ULong */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for unsigned long. */
|
||||
/* */
|
||||
typedef unsigned long FT_ULong;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_F2Dot14 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A signed 2.14 fixed float type used for unit vectors. */
|
||||
/* */
|
||||
typedef signed short FT_F2Dot14;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_F26Dot6 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A signed 26.6 fixed float type used for vectorial pixel */
|
||||
/* coordinates. */
|
||||
/* */
|
||||
typedef signed long FT_F26Dot6;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Fixed */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This type is used to store 16.16 fixed float values, like scales */
|
||||
/* or matrix coefficients. */
|
||||
/* */
|
||||
typedef signed long FT_Fixed;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Error */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The FreeType error code type. A value of 0 is always interpreted */
|
||||
/* as a successful operation. */
|
||||
/* */
|
||||
typedef int FT_Error;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Pointer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for a typeless pointer. */
|
||||
/* */
|
||||
typedef void* FT_Pointer;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_UnitVector */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to store a 2D vector unit vector. Uses */
|
||||
/* FT_F2Dot14 types. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* x :: Horizontal coordinate. */
|
||||
/* */
|
||||
/* y :: Vertical coordinate. */
|
||||
/* */
|
||||
typedef struct FT_UnitVector_
|
||||
{
|
||||
FT_F2Dot14 x;
|
||||
FT_F2Dot14 y;
|
||||
|
||||
} FT_UnitVector;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Matrix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to store a 2x2 matrix. Coefficients are */
|
||||
/* in 16.16 fixed float format. The computation performed is: */
|
||||
/* */
|
||||
/* { */
|
||||
/* x' = x*xx + y*xy */
|
||||
/* y' = x*yx + y*yy */
|
||||
/* } */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* xx :: Matrix coefficient. */
|
||||
/* */
|
||||
/* xy :: Matrix coefficient. */
|
||||
/* */
|
||||
/* yx :: Matrix coefficient. */
|
||||
/* */
|
||||
/* yy :: Matrix coefficient. */
|
||||
/* */
|
||||
typedef struct FT_Matrix_
|
||||
{
|
||||
FT_Fixed xx, xy;
|
||||
FT_Fixed yx, yy;
|
||||
|
||||
} FT_Matrix;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_BBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to hold an outline's bounding box, i.e., the */
|
||||
/* coordinates of its extrema in the horizontal and vertical */
|
||||
/* directions. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* xMin :: The horizontal minimum (left-most). */
|
||||
/* */
|
||||
/* yMin :: The vertical minimum (bottom-most). */
|
||||
/* */
|
||||
/* xMax :: The horizontal maximum (right-most). */
|
||||
/* */
|
||||
/* yMax :: The vertical maximum (top-most). */
|
||||
/* */
|
||||
typedef struct FT_BBox_
|
||||
{
|
||||
FT_Pos xMin, yMin;
|
||||
FT_Pos xMax, yMax;
|
||||
|
||||
} FT_BBox;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_MAKE_TAG */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro converts four letter tags which are used to label */
|
||||
/* TrueType tables into an unsigned long to be used within FreeType. */
|
||||
/* */
|
||||
#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
|
||||
( ( (FT_ULong)_x1 << 24 ) | \
|
||||
( (FT_ULong)_x2 << 16 ) | \
|
||||
( (FT_ULong)_x3 << 8 ) | \
|
||||
(FT_ULong)_x4 )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* L I S T M A N A G E M E N T */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_ListNode */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Many elements and objects in FreeType are listed through a */
|
||||
/* FT_List record (see FT_ListRec). As its name suggests, a */
|
||||
/* FT_ListNode is a handle to a single list element. */
|
||||
/* */
|
||||
typedef struct FT_ListNodeRec_* FT_ListNode;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_List */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a list record (see FT_ListRec). */
|
||||
/* */
|
||||
typedef struct FT_ListRec_* FT_List;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_ListNodeRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to hold a single list element. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* prev :: The previous element in the list. NULL if first. */
|
||||
/* */
|
||||
/* next :: The next element in the list. NULL if last. */
|
||||
/* */
|
||||
/* data :: A typeless pointer to the listed object. */
|
||||
/* */
|
||||
typedef struct FT_ListNodeRec_
|
||||
{
|
||||
FT_ListNode prev;
|
||||
FT_ListNode next;
|
||||
void* data;
|
||||
|
||||
} FT_ListNodeRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_ListRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to hold a simple doubly-linked list. These are */
|
||||
/* used in many parts of FreeType. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* head :: The head (first element) of doubly-linked list. */
|
||||
/* */
|
||||
/* tail :: The tail (last element) of doubly-linked list. */
|
||||
/* */
|
||||
typedef struct FT_ListRec_
|
||||
{
|
||||
FT_ListNode head;
|
||||
FT_ListNode tail;
|
||||
|
||||
} FT_ListRec;
|
||||
|
||||
|
||||
#define FT_IS_EMPTY( list ) ( (list).head == 0 )
|
||||
|
||||
|
||||
#endif /* FTTYPES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
195
src/freetype/freetype/internal/autohint.h
Normal file
195
src/freetype/freetype/internal/autohint.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* autohint.h */
|
||||
/* */
|
||||
/* High-level `autohint' module-specific interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The auto-hinter is used to load and automatically hint glyphs if a */
|
||||
/* format-specific hinter isn't available. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef AUTOHINT_H
|
||||
#define AUTOHINT_H
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* A small technical note regarding automatic hinting in order to */
|
||||
/* clarify this module interface. */
|
||||
/* */
|
||||
/* An automatic hinter might compute two kinds of data for a given face: */
|
||||
/* */
|
||||
/* - global hints: Usually some metrics that describe global properties */
|
||||
/* of the face. It is computed by scanning more or less */
|
||||
/* agressively the glyphs in the face, and thus can be */
|
||||
/* very slow to compute (even if the size of global */
|
||||
/* hints is really small). */
|
||||
/* */
|
||||
/* - glyph hints: These describe some important features of the glyph */
|
||||
/* outline, as well as how to align them. They are */
|
||||
/* generally much faster to compute than global hints. */
|
||||
/* */
|
||||
/* The current FreeType auto-hinter does a pretty good job while */
|
||||
/* performing fast computations for both global and glyph hints. */
|
||||
/* However, we might be interested in introducing more complex and */
|
||||
/* powerful algorithms in the future, like the one described in the John */
|
||||
/* D. Hobby paper, which unfortunately requires a lot more horsepower. */
|
||||
/* */
|
||||
/* Because a sufficiently sophisticated font management system would */
|
||||
/* typically implement an LRU cache of opened face objects to reduce */
|
||||
/* memory usage, it is a good idea to be able to avoid recomputing */
|
||||
/* global hints every time the same face is re-opened. */
|
||||
/* */
|
||||
/* We thus provide the ability to cache global hints outside of the face */
|
||||
/* object, in order to speed up font re-opening time. Of course, this */
|
||||
/* feature is purely optional, so most client programs won't even notice */
|
||||
/* it. */
|
||||
/* */
|
||||
/* I initially thought that it would be a good idea to cache the glyph */
|
||||
/* hints too. However, my general idea now is that if you really need */
|
||||
/* to cache these too, you are simply in need of a new font format, */
|
||||
/* where all this information could be stored within the font file and */
|
||||
/* decoded on the fly. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
typedef struct FT_AutoHinterRec_ *FT_AutoHinter;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_AutoHinter_Get_Global_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieves the global hints computed for a given face object the */
|
||||
/* resulting data is dissociated from the face and will survive a */
|
||||
/* call to FT_Done_Face(). It must be discarded through the API */
|
||||
/* FT_AutoHinter_Done_Global_Func(). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* hinter :: A handle to the source auto-hinter. */
|
||||
/* */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* global_hints :: A typeless pointer to the global hints. */
|
||||
/* */
|
||||
/* global_len :: The size in bytes of the global hints. */
|
||||
/* */
|
||||
typedef void (*FT_AutoHinter_Get_Global_Func)(
|
||||
FT_AutoHinter hinter,
|
||||
FT_Face face,
|
||||
void** global_hints,
|
||||
long* global_len );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_AutoHinter_Done_Global_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Discards the global hints retrieved through */
|
||||
/* FT_AutoHinter_Get_Global_Func(). This is the only way these hints */
|
||||
/* are freed from memory. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* hinter :: A handle to the auto-hinter module. */
|
||||
/* */
|
||||
/* global :: A pointer to retrieved global hints to discard. */
|
||||
/* */
|
||||
typedef void (*FT_AutoHinter_Done_Global_Func)( FT_AutoHinter hinter,
|
||||
void* global );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_AutoHinter_Reset_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is used to recompute the global metrics in a given */
|
||||
/* font. This is useful when global font data changes (e.g. Multiple */
|
||||
/* Masters fonts where blend coordinates change). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* hinter :: A handle to the source auto-hinter. */
|
||||
/* */
|
||||
/* face :: A handle to the face. */
|
||||
/* */
|
||||
typedef void (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter,
|
||||
FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_AutoHinter_Load_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is used to load, scale, and automatically hint a */
|
||||
/* glyph from a given face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the face. */
|
||||
/* glyph_index :: The glyph index. */
|
||||
/* load_flags :: The load flags. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function is capable of loading composite glyphs by hinting */
|
||||
/* each sub-glyph independently (which improves quality). */
|
||||
/* */
|
||||
/* It will call the font driver with FT_Load_Glyph(), with */
|
||||
/* FT_LOAD_NO_SCALE set. */
|
||||
/* */
|
||||
typedef FT_Error (*FT_AutoHinter_Load_Func)( FT_AutoHinter hinter,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Size size,
|
||||
FT_UInt glyph_index,
|
||||
FT_ULong load_flags );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_AutoHinter_Interface */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The auto-hinter module's interface. */
|
||||
/* */
|
||||
typedef struct FT_AutoHinter_Interface
|
||||
{
|
||||
FT_AutoHinter_Reset_Func reset_face;
|
||||
FT_AutoHinter_Load_Func load_glyph;
|
||||
|
||||
FT_AutoHinter_Get_Global_Func get_global_hints;
|
||||
FT_AutoHinter_Done_Global_Func done_global_hints;
|
||||
|
||||
} FT_AutoHinter_Interface;
|
||||
|
||||
|
||||
#endif /* AUTOHINT_H */
|
||||
|
||||
|
||||
/* END */
|
||||
123
src/freetype/freetype/internal/ftcalc.h
Normal file
123
src/freetype/freetype/internal/ftcalc.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftcalc.h */
|
||||
/* */
|
||||
/* Arithmetic computations (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTCALC_H
|
||||
#define FTCALC_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/config/ftconfig.h> /* for LONG64 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LONG64
|
||||
|
||||
|
||||
typedef INT64 FT_Int64;
|
||||
|
||||
#define ADD_64( x, y, z ) z = (x) + (y)
|
||||
#define MUL_64( x, y, z ) z = (FT_Int64)(x) * (y)
|
||||
|
||||
#define DIV_64( x, y ) ( (x) / (y) )
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_OLD_CALCS
|
||||
|
||||
#define SQRT_64( z ) FT_Sqrt64( z )
|
||||
|
||||
FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64 l );
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
|
||||
|
||||
|
||||
#else /* LONG64 */
|
||||
|
||||
|
||||
typedef struct FT_Int64_
|
||||
{
|
||||
FT_UInt32 lo;
|
||||
FT_UInt32 hi;
|
||||
|
||||
} FT_Int64;
|
||||
|
||||
|
||||
#define ADD_64( x, y, z ) FT_Add64( &x, &y, &z )
|
||||
#define MUL_64( x, y, z ) FT_MulTo64( x, y, &z )
|
||||
#define DIV_64( x, y ) FT_Div64by32( &x, y )
|
||||
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_Add64( FT_Int64* x,
|
||||
FT_Int64* y,
|
||||
FT_Int64* z );
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_MulTo64( FT_Int32 x,
|
||||
FT_Int32 y,
|
||||
FT_Int64* z );
|
||||
|
||||
FT_EXPORT_DEF( FT_Int32 ) FT_Div64by32( FT_Int64* x,
|
||||
FT_Int32 y );
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_OLD_CALCS
|
||||
|
||||
#define SQRT_64( z ) FT_Sqrt64( &z )
|
||||
|
||||
FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x );
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
|
||||
|
||||
|
||||
#endif /* LONG64 */
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_OLD_CALCS
|
||||
|
||||
#define SQRT_32( x ) FT_Sqrt32( x )
|
||||
|
||||
BASE_DEF( FT_Int32 ) FT_Sqrt32( FT_Int32 x );
|
||||
|
||||
#endif /* !FT_CONFIG_OPTION_OLD_CALCS */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
|
||||
#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
|
||||
#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
|
||||
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
|
||||
#define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) )
|
||||
|
||||
#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \
|
||||
: ( -( ( 32 - (x) ) & -64 ) ) )
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FTCALC_H */
|
||||
|
||||
|
||||
/* END */
|
||||
225
src/freetype/freetype/internal/ftdebug.h
Normal file
225
src/freetype/freetype/internal/ftdebug.h
Normal file
@@ -0,0 +1,225 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftdebug.h */
|
||||
/* */
|
||||
/* Debugging and logging component (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTDEBUG_H
|
||||
#define FTDEBUG_H
|
||||
|
||||
#include <freetype/config/ftconfig.h> /* for FT_DEBUG_LEVEL_TRACE, */
|
||||
/* FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* A very stupid pre-processor trick. See K&R version 2 */
|
||||
/* section A12.3 for details... */
|
||||
/* */
|
||||
/* It is also described in the section `Separate */
|
||||
/* Expansion of Macro Arguments' in the info file */
|
||||
/* `cpp.info', describing GNU cpp. */
|
||||
/* */
|
||||
#define FT_CAT( x, y ) x ## y
|
||||
#define FT_XCAT( x, y ) FT_CAT( x, y )
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
|
||||
|
||||
/* note that not all levels are used currently */
|
||||
|
||||
typedef enum FT_Trace_
|
||||
{
|
||||
/* the first level must always be `trace_any' */
|
||||
trace_any = 0,
|
||||
|
||||
/* base components */
|
||||
trace_aaraster, /* anti-aliasing raster (ftgrays.c) */
|
||||
trace_calc, /* calculations (ftcalc.c) */
|
||||
trace_extend, /* extension manager (ftextend.c) */
|
||||
trace_glyph, /* glyph manager (ftglyph.c) */
|
||||
trace_io, /* i/o monitoring (ftsystem.c) */
|
||||
trace_init, /* initialization (ftinit.c) */
|
||||
trace_list, /* list manager (ftlist.c) */
|
||||
trace_memory, /* memory manager (ftobjs.c) */
|
||||
trace_mm, /* MM interface (ftmm.c) */
|
||||
trace_objs, /* base objects (ftobjs.c) */
|
||||
trace_outline, /* outline management (ftoutln.c) */
|
||||
trace_raster, /* rasterizer (ftraster.c) */
|
||||
trace_stream, /* stream manager (ftstream.c) */
|
||||
|
||||
/* SFNT driver components */
|
||||
trace_sfobjs, /* SFNT object handler (sfobjs.c) */
|
||||
trace_ttcmap, /* charmap handler (ttcmap.c) */
|
||||
trace_ttload, /* basic TrueType tables (ttload.c) */
|
||||
trace_ttpost, /* PS table processing (ttpost.c) */
|
||||
trace_ttsbit, /* TrueType sbit handling (ttsbit.c) */
|
||||
|
||||
/* TrueType driver components */
|
||||
trace_ttdriver, /* TT font driver (ttdriver.c) */
|
||||
trace_ttgload, /* TT glyph loader (ttgload.c) */
|
||||
trace_ttinterp, /* bytecode interpreter (ttinterp.c) */
|
||||
trace_ttobjs, /* TT objects manager (ttobjs.c) */
|
||||
trace_ttpload, /* TT data/program loader (ttpload.c) */
|
||||
|
||||
/* Type 1 driver components */
|
||||
trace_t1driver,
|
||||
trace_t1gload,
|
||||
trace_t1hint,
|
||||
trace_t1load,
|
||||
trace_t1objs,
|
||||
|
||||
/* experimental Type 1 driver components */
|
||||
trace_z1driver,
|
||||
trace_z1gload,
|
||||
trace_z1hint,
|
||||
trace_z1load,
|
||||
trace_z1objs,
|
||||
trace_z1parse,
|
||||
|
||||
/* Type 2 driver components */
|
||||
trace_t2driver,
|
||||
trace_t2gload,
|
||||
trace_t2load,
|
||||
trace_t2objs,
|
||||
trace_t2parse,
|
||||
|
||||
/* CID driver components */
|
||||
trace_cidafm,
|
||||
trace_ciddriver,
|
||||
trace_cidgload,
|
||||
trace_cidload,
|
||||
trace_cidobjs,
|
||||
trace_cidparse,
|
||||
|
||||
/* Windows fonts component */
|
||||
trace_winfnt,
|
||||
|
||||
/* the last level must always be `trace_max' */
|
||||
trace_max
|
||||
|
||||
} FT_Trace;
|
||||
|
||||
|
||||
/* declared in ftdebug.c */
|
||||
extern char ft_trace_levels[trace_max];
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* IMPORTANT! */
|
||||
/* */
|
||||
/* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
|
||||
/* value before using any TRACE macro. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define FT_TRACE( level, varformat ) \
|
||||
do \
|
||||
{ \
|
||||
if ( ft_trace_levels[FT_COMPONENT] >= level ) \
|
||||
FT_XCAT( FT_Message, varformat ); \
|
||||
} while ( 0 )
|
||||
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_SetTraceLevel( FT_Trace component,
|
||||
char level );
|
||||
|
||||
|
||||
#elif defined( FT_DEBUG_LEVEL_ERROR )
|
||||
|
||||
|
||||
#define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
|
||||
|
||||
|
||||
#else /* release mode */
|
||||
|
||||
|
||||
#define FT_Assert( condition ) do ; while ( 0 ) /* nothing */
|
||||
|
||||
#define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
|
||||
#define FT_ERROR( varformat ) do ; while ( 0 ) /* nothing */
|
||||
|
||||
|
||||
#endif /* FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define macros and functions that are common to the debug and trace */
|
||||
/* modes. */
|
||||
/* */
|
||||
/* You need vprintf() to be able to compile ftdebug.c. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#if defined( FT_DEBUG_LEVEL_TRACE ) || defined( FT_DEBUG_LEVEL_ERROR )
|
||||
|
||||
|
||||
#include "stdio.h" /* for vprintf() */
|
||||
|
||||
|
||||
#define FT_Assert( condition ) \
|
||||
do \
|
||||
{ \
|
||||
if ( !( condition ) ) \
|
||||
FT_Panic( "assertion failed on line %d of file %s\n", \
|
||||
__LINE__, __FILE__ ); \
|
||||
} while ( 0 )
|
||||
|
||||
/* print a message */
|
||||
FT_EXPORT_DEF( void ) FT_Message( const char* fmt, ... );
|
||||
|
||||
/* print a message and exit */
|
||||
FT_EXPORT_DEF( void ) FT_Panic( const char* fmt, ... );
|
||||
|
||||
#define FT_ERROR( varformat ) FT_XCAT( FT_Message, varformat )
|
||||
|
||||
|
||||
#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* You need two opening resp. closing parentheses! */
|
||||
/* */
|
||||
/* Example: FT_TRACE0(( "Value is %i", foo )) */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
|
||||
#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat )
|
||||
#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat )
|
||||
#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat )
|
||||
#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat )
|
||||
#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat )
|
||||
#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat )
|
||||
#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat )
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTDEBUG_H */
|
||||
|
||||
|
||||
/* END */
|
||||
182
src/freetype/freetype/internal/ftdriver.h
Normal file
182
src/freetype/freetype/internal/ftdriver.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftdriver.h */
|
||||
/* */
|
||||
/* FreeType font driver interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTDRIVER_H
|
||||
#define FTDRIVER_H
|
||||
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
#include <freetype/config/ftconfig.h>
|
||||
|
||||
|
||||
typedef FT_Error (*FTDriver_initFace)( FT_Stream stream,
|
||||
FT_Face face,
|
||||
FT_Int typeface_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* parameters );
|
||||
|
||||
typedef void (*FTDriver_doneFace)( FT_Face face );
|
||||
|
||||
|
||||
typedef FT_Error (*FTDriver_initSize)( FT_Size size );
|
||||
|
||||
typedef void (*FTDriver_doneSize)( FT_Size size );
|
||||
|
||||
|
||||
typedef FT_Error (*FTDriver_initGlyphSlot)( FT_GlyphSlot slot );
|
||||
|
||||
typedef void (*FTDriver_doneGlyphSlot)( FT_GlyphSlot slot );
|
||||
|
||||
|
||||
typedef FT_Error (*FTDriver_setCharSizes)( FT_Size size,
|
||||
FT_F26Dot6 char_width,
|
||||
FT_F26Dot6 char_height,
|
||||
FT_UInt horz_resolution,
|
||||
FT_UInt vert_resolution );
|
||||
|
||||
typedef FT_Error (*FTDriver_setPixelSizes)( FT_Size size,
|
||||
FT_UInt pixel_width,
|
||||
FT_UInt pixel_height );
|
||||
|
||||
typedef FT_Error (*FTDriver_loadGlyph)( FT_GlyphSlot slot,
|
||||
FT_Size size,
|
||||
FT_UInt glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
|
||||
typedef FT_UInt (*FTDriver_getCharIndex)( FT_CharMap charmap,
|
||||
FT_Long charcode );
|
||||
|
||||
typedef FT_Error (*FTDriver_getKerning)( FT_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_Vector* kerning );
|
||||
|
||||
|
||||
typedef FT_Error (*FTDriver_attachFile)( FT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
typedef FT_Error (*FTDriver_getAdvances)( FT_Face face,
|
||||
FT_UInt first,
|
||||
FT_UInt count,
|
||||
FT_Bool vertical,
|
||||
FT_UShort* advances );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Driver_Class */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The font driver class. This structure mostly contains pointers to */
|
||||
/* driver methods. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: The parent module. */
|
||||
/* */
|
||||
/* face_object_size :: The size of a face object in bytes. */
|
||||
/* */
|
||||
/* size_object_size :: The size of a size object in bytes. */
|
||||
/* */
|
||||
/* slot_object_size :: The size of a glyph object in bytes. */
|
||||
/* */
|
||||
/* init_face :: The format-specific face constructor. */
|
||||
/* */
|
||||
/* done_face :: The format-specific face destructor. */
|
||||
/* */
|
||||
/* init_size :: The format-specific size constructor. */
|
||||
/* */
|
||||
/* done_size :: The format-specific size destructor. */
|
||||
/* */
|
||||
/* init_slot :: The format-specific slot constructor. */
|
||||
/* */
|
||||
/* done_slot :: The format-specific slot destructor. */
|
||||
/* */
|
||||
/* set_char_sizes :: A handle to a function used to set the new */
|
||||
/* character size in points + resolution. Can be */
|
||||
/* set to 0 to indicate default behaviour. */
|
||||
/* */
|
||||
/* set_pixel_sizes :: A handle to a function used to set the new */
|
||||
/* character size in pixels. Can be set to 0 to */
|
||||
/* indicate default behaviour. */
|
||||
/* */
|
||||
/* load_glyph :: A function handle to load a given glyph image */
|
||||
/* in a slot. This field is mandatory! */
|
||||
/* */
|
||||
/* get_char_index :: A function handle to return the glyph index of */
|
||||
/* a given character for a given charmap. This */
|
||||
/* field is mandatory! */
|
||||
/* */
|
||||
/* get_kerning :: A function handle to return the unscaled */
|
||||
/* kerning for a given pair of glyphs. Can be */
|
||||
/* set to 0 if the format doesn't support */
|
||||
/* kerning. */
|
||||
/* */
|
||||
/* attach_file :: This function handle is used to read */
|
||||
/* additional data for a face from another */
|
||||
/* file/stream. For example, this can be used to */
|
||||
/* add data from AFM or PFM files on a Type 1 */
|
||||
/* face, or a CIDMap on a CID-keyed face. */
|
||||
/* */
|
||||
/* get_advances :: A function handle used to return the advances */
|
||||
/* of 'count' glyphs, starting at `index'. the */
|
||||
/* `vertical' flags must be set when vertical */
|
||||
/* advances are queried. The advances buffer is */
|
||||
/* caller-allocated. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Most function pointers, with the exception of `load_glyph' and */
|
||||
/* `get_char_index' can be set to 0 to indicate a default behaviour. */
|
||||
/* */
|
||||
typedef struct FT_Driver_Class_
|
||||
{
|
||||
FT_Module_Class root;
|
||||
|
||||
FT_Int face_object_size;
|
||||
FT_Int size_object_size;
|
||||
FT_Int slot_object_size;
|
||||
|
||||
FTDriver_initFace init_face;
|
||||
FTDriver_doneFace done_face;
|
||||
|
||||
FTDriver_initSize init_size;
|
||||
FTDriver_doneSize done_size;
|
||||
|
||||
FTDriver_initGlyphSlot init_slot;
|
||||
FTDriver_doneGlyphSlot done_slot;
|
||||
|
||||
FTDriver_setCharSizes set_char_sizes;
|
||||
FTDriver_setPixelSizes set_pixel_sizes;
|
||||
|
||||
FTDriver_loadGlyph load_glyph;
|
||||
FTDriver_getCharIndex get_char_index;
|
||||
|
||||
FTDriver_getKerning get_kerning;
|
||||
FTDriver_attachFile attach_file;
|
||||
|
||||
FTDriver_getAdvances get_advances;
|
||||
|
||||
} FT_Driver_Class;
|
||||
|
||||
|
||||
#endif /* FTDRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
178
src/freetype/freetype/internal/ftextend.h
Normal file
178
src/freetype/freetype/internal/ftextend.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftextend.h */
|
||||
/* */
|
||||
/* FreeType extensions implementation (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTEXTEND_H
|
||||
#define FTEXTEND_H
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The extensions don't need to be integrated at compile time into the */
|
||||
/* engine, only at link time. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Extension_Initializer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Each new face object can have several extensions associated with */
|
||||
/* it at creation time. This function is used to initialize given */
|
||||
/* extension data for a given face. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* ext :: A typeless pointer to the extension data. */
|
||||
/* */
|
||||
/* face :: A handle to the source face object the extension is */
|
||||
/* associated with. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* In case of error, the initializer should not destroy the extension */
|
||||
/* data, as the finalizer will get called later by the function's */
|
||||
/* caller. */
|
||||
/* */
|
||||
typedef FT_Error (*FT_Extension_Initializer)( void* ext,
|
||||
FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Extension_Finalizer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Each new face object can have several extensions associated with */
|
||||
/* it at creation time. This function is used to finalize given */
|
||||
/* extension data for a given face; it occurs before the face object */
|
||||
/* itself is finalized. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* ext :: A typeless pointer to the extension data. */
|
||||
/* */
|
||||
/* face :: A handle to the source face object the extension is */
|
||||
/* associated with. */
|
||||
/* */
|
||||
typedef void (*FT_Extension_Finalizer)( void* ext,
|
||||
FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Extension_Class */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to describe a given extension to the */
|
||||
/* FreeType base layer. An FT_Extension_Class is used as a parameter */
|
||||
/* for FT_Register_Extension(). */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* id :: The extension's ID. This is a normal C string that */
|
||||
/* is used to uniquely reference the extension's */
|
||||
/* interface. */
|
||||
/* */
|
||||
/* size :: The size in bytes of the extension data that must be */
|
||||
/* associated with each face object. */
|
||||
/* */
|
||||
/* init :: A pointer to the extension data's initializer. */
|
||||
/* */
|
||||
/* finalize :: A pointer to the extension data's finalizer. */
|
||||
/* */
|
||||
/* interface :: This pointer can be anything, but should usually */
|
||||
/* point to a table of function pointers which implement */
|
||||
/* the extension's interface. */
|
||||
/* */
|
||||
/* offset :: This field is set and used within the base layer and */
|
||||
/* should be set to 0 when registering an extension */
|
||||
/* through FT_Register_Extension(). It contains an */
|
||||
/* offset within the face's extension block for the */
|
||||
/* current extension's data. */
|
||||
/* */
|
||||
typedef struct FT_Extension_Class_
|
||||
{
|
||||
const char* id;
|
||||
FT_ULong size;
|
||||
FT_Extension_Initializer init;
|
||||
FT_Extension_Finalizer finalize;
|
||||
void* interface;
|
||||
|
||||
FT_ULong offset;
|
||||
|
||||
} FT_Extension_Class;
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Register_Extension(
|
||||
FT_Driver driver,
|
||||
FT_Extension_Class* clazz );
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
|
||||
|
||||
/* Initialize the extension component */
|
||||
LOCAL_DEF
|
||||
FT_Error FT_Init_Extensions( FT_Library library );
|
||||
|
||||
/* Finalize the extension component */
|
||||
LOCAL_DEF
|
||||
FT_Error FT_Done_Extensions( FT_Library library );
|
||||
|
||||
/* Create an extension within a face object. Called by the */
|
||||
/* face object constructor. */
|
||||
LOCAL_DEF
|
||||
FT_Error FT_Create_Extensions( FT_Face face );
|
||||
|
||||
/* Destroy all extensions within a face object. Called by the */
|
||||
/* face object destructor. */
|
||||
LOCAL_DEF
|
||||
FT_Error FT_Destroy_Extensions( FT_Face face );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* return an extension's data & interface according to its ID */
|
||||
FT_EXPORT_DEF( void* ) FT_Get_Extension(
|
||||
FT_Face face,
|
||||
const char* extension_id,
|
||||
void** extension_interface );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTEXTEND_H */
|
||||
|
||||
|
||||
/* END */
|
||||
113
src/freetype/freetype/internal/ftlist.h
Normal file
113
src/freetype/freetype/internal/ftlist.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftlist.c */
|
||||
/* */
|
||||
/* Generic list support for FreeType (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file implements functions relative to list processing. Its */
|
||||
/* data structures are defined in `freetype.h'. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTLIST_H
|
||||
#define FTLIST_H
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_ListNode ) FT_List_Find( FT_List list,
|
||||
void* data );
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_List_Add( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_List_Insert( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_List_Remove( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_List_Up( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_List_Iterator */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An FT_List iterator function which is called during a list parse */
|
||||
/* by FT_List_Iterate(). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* node :: The current iteration list node. */
|
||||
/* */
|
||||
/* user :: A typeless pointer passed to FT_List_Iterate(). */
|
||||
/* Can be used to point to the iteration's state. */
|
||||
/* */
|
||||
typedef FT_Error (*FT_List_Iterator)( FT_ListNode node,
|
||||
void* user );
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_List_Iterate( FT_List list,
|
||||
FT_List_Iterator iterator,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_List_Destructor */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An FT_List iterator function which is called during a list */
|
||||
/* finalization by FT_List_Finalize() to destroy all elements in a */
|
||||
/* given list. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* system :: The current system object. */
|
||||
/* */
|
||||
/* data :: The current object to destroy. */
|
||||
/* */
|
||||
/* user :: A typeless pointer passed to FT_List_Iterate(). It can */
|
||||
/* be used to point to the iteration's state. */
|
||||
/* */
|
||||
typedef void (*FT_List_Destructor)( FT_Memory memory,
|
||||
void* data,
|
||||
void* user );
|
||||
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_List_Finalize( FT_List list,
|
||||
FT_List_Destructor destroy,
|
||||
FT_Memory memory,
|
||||
void* user );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FTLIST_H */
|
||||
|
||||
|
||||
/* END */
|
||||
127
src/freetype/freetype/internal/ftmemory.h
Normal file
127
src/freetype/freetype/internal/ftmemory.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmemory.h */
|
||||
/* */
|
||||
/* The FreeType memory management macros (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTMEMORY_H
|
||||
#define FTMEMORY_H
|
||||
|
||||
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/fttypes.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_SET_ERROR */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro is used to set an implicit `error' variable to a given */
|
||||
/* expression's value (usually a function call), and convert it to a */
|
||||
/* boolean which is set whenever the value is != 0. */
|
||||
/* */
|
||||
#undef FT_SET_ERROR
|
||||
#define FT_SET_ERROR( expression ) \
|
||||
( ( error = (expression) ) != 0 )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** M E M O R Y ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Alloc( FT_Memory memory,
|
||||
FT_Long size,
|
||||
void** P );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Realloc( FT_Memory memory,
|
||||
FT_Long current,
|
||||
FT_Long size,
|
||||
void** P );
|
||||
|
||||
BASE_DEF( void ) FT_Free( FT_Memory memory,
|
||||
void** P );
|
||||
|
||||
|
||||
|
||||
/* This `#include' is needed by the MEM_xxx() macros; it should be */
|
||||
/* available on all platforms we know of. */
|
||||
#include <string.h>
|
||||
|
||||
#define MEM_Set( dest, byte, count ) memset( dest, byte, count )
|
||||
|
||||
#define MEM_Copy( dest, source, count ) memcpy( dest, source, count )
|
||||
|
||||
#define MEM_Move( dest, source, count ) memmove( dest, source, count )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* We now support closures to produce completely reentrant code. This */
|
||||
/* means the allocation functions now takes an additional argument */
|
||||
/* (`memory'). It is a handle to a given memory object, responsible for */
|
||||
/* all low-level operations, including memory management and */
|
||||
/* synchronisation. */
|
||||
/* */
|
||||
/* In order to keep our code readable and use the same macros in the */
|
||||
/* font drivers and the rest of the library, MEM_Alloc(), ALLOC(), and */
|
||||
/* ALLOC_ARRAY() now use an implicit variable, `memory'. It must be */
|
||||
/* defined at all locations where a memory operation is queried. */
|
||||
/* */
|
||||
#define MEM_Alloc( _pointer_, _size_ ) \
|
||||
FT_Alloc( memory, _size_, (void**)&(_pointer_) )
|
||||
|
||||
#define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \
|
||||
FT_Alloc( memory, (_count_)*sizeof ( _type_ ), \
|
||||
(void**)&(_pointer_) )
|
||||
|
||||
#define MEM_Realloc( _pointer_, _current_, _size_ ) \
|
||||
FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) )
|
||||
|
||||
#define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \
|
||||
FT_Realloc( memory, (_current_)*sizeof ( _type_ ), \
|
||||
(_new_)*sizeof ( _type_ ), (void**)&(_pointer_) )
|
||||
|
||||
#define ALLOC( _pointer_, _size_ ) \
|
||||
FT_SET_ERROR( MEM_Alloc( _pointer_, _size_ ) )
|
||||
|
||||
#define REALLOC( _pointer_, _current_, _size_ ) \
|
||||
FT_SET_ERROR( MEM_Realloc( _pointer_, _current_, _size_ ) )
|
||||
|
||||
#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
|
||||
FT_SET_ERROR( MEM_Alloc( _pointer_, \
|
||||
(_count_)*sizeof ( _type_ ) ) )
|
||||
|
||||
#define REALLOC_ARRAY( _pointer_, _current_, _count_, _type_ ) \
|
||||
FT_SET_ERROR( MEM_Realloc( _pointer_, \
|
||||
(_current_)*sizeof ( _type_ ), \
|
||||
(_count_)*sizeof ( _type_ ) ) )
|
||||
|
||||
#define FREE( _pointer_ ) FT_Free( memory, (void**)&(_pointer_) )
|
||||
|
||||
|
||||
#endif /* FTMEMORY_H */
|
||||
|
||||
|
||||
/* END */
|
||||
532
src/freetype/freetype/internal/ftobjs.h
Normal file
532
src/freetype/freetype/internal/ftobjs.h
Normal file
@@ -0,0 +1,532 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftobjs.h */
|
||||
/* */
|
||||
/* The FreeType private base classes (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file contains the definition of all internal FreeType classes. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTOBJS_H
|
||||
#define FTOBJS_H
|
||||
|
||||
#include <freetype/internal/ftmemory.h>
|
||||
#include <freetype/ftrender.h>
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
#include <freetype/internal/autohint.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Some generic definitions. */
|
||||
/* */
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void*)0
|
||||
#endif
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED( arg ) ( (arg)=(arg) )
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The min and max functions missing in C. As usual, be careful not to */
|
||||
/* write things like MIN( a++, b++ ) to avoid side effects. */
|
||||
/* */
|
||||
#ifndef MIN
|
||||
#define MIN( a, b ) ( (a) < (b) ? (a) : (b) )
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX( a, b ) ( (a) > (b) ? (a) : (b) )
|
||||
#endif
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS( a ) ( (a) < 0 ? -(a) : (a) )
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** M O D U L E S ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_ModuleRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A module object instance. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* clazz :: A pointer to the module's class. */
|
||||
/* */
|
||||
/* library :: A handle to the parent library object. */
|
||||
/* */
|
||||
/* memory :: A handle to the memory manager. */
|
||||
/* */
|
||||
/* generic :: A generic structure for user-level extensibility (?). */
|
||||
/* */
|
||||
typedef struct FT_ModuleRec_
|
||||
{
|
||||
FT_Module_Class* clazz;
|
||||
FT_Library library;
|
||||
FT_Memory memory;
|
||||
FT_Generic generic;
|
||||
|
||||
} FT_ModuleRec;
|
||||
|
||||
|
||||
/* typecast an object to a FT_Module */
|
||||
#define FT_MODULE( x ) ((FT_Module)(x))
|
||||
#define FT_MODULE_CLASS( x ) FT_MODULE(x)->clazz
|
||||
#define FT_MODULE_LIBRARY( x ) FT_MODULE(x)->library
|
||||
#define FT_MODULE_MEMORY( x ) FT_MODULE(x)->memory
|
||||
|
||||
#define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
|
||||
ft_module_font_driver )
|
||||
|
||||
#define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
|
||||
ft_module_renderer )
|
||||
|
||||
#define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
|
||||
ft_module_hinter )
|
||||
|
||||
#define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
|
||||
ft_module_styler )
|
||||
|
||||
#define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_driver_scalable )
|
||||
|
||||
#define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_driver_no_outlines )
|
||||
|
||||
#define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS(x)->module_flags & \
|
||||
ft_module_driver_has_hinter )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Module_Interface */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finds a module and returns its specific interface as a typeless */
|
||||
/* pointer. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* module_name :: The module's name (as an ASCII string). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A module-specific interface if available, 0 otherwise. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should better be familiar with FreeType internals to know */
|
||||
/* which module to look for, and what its interface is :-) */
|
||||
/* */
|
||||
BASE_DEF( const void* ) FT_Get_Module_Interface( FT_Library library,
|
||||
const char* mod_name );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** FACE, SIZE & GLYPH SLOT OBJECTS ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/* a few macros used to perform easy typecasts with minimal brain damage */
|
||||
|
||||
#define FT_FACE( x ) ((FT_Face)(x))
|
||||
#define FT_SIZE( x ) ((FT_Size)(x))
|
||||
#define FT_SLOT( x ) ((FT_GlyphSlot)(x))
|
||||
|
||||
#define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
|
||||
#define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
|
||||
#define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
|
||||
|
||||
#define FT_SIZE_FACE( x ) FT_SIZE( x )->face
|
||||
#define FT_SLOT_FACE( x ) FT_SLOT( x )->face
|
||||
|
||||
#define FT_FACE_SLOT( x ) FT_FACE( x )->glyph
|
||||
#define FT_FACE_SIZE( x ) FT_FACE( x )->size
|
||||
|
||||
|
||||
/* this must be kept exported -- tt will be used later in our own */
|
||||
/* high-level caching font manager called SemTex (way after the */
|
||||
/* 2.0 release though */
|
||||
FT_EXPORT_DEF( FT_Error ) FT_New_Size( FT_Face face,
|
||||
FT_Size* size );
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_Done_Size( FT_Size size );
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_New_GlyphSlot( FT_Face face,
|
||||
FT_GlyphSlot* aslot );
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_Done_GlyphSlot( FT_GlyphSlot slot );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** G L Y P H L O A D E R ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
|
||||
#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
|
||||
#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
|
||||
#define FT_SUBGLYPH_FLAG_SCALE 8
|
||||
#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
|
||||
#define FT_SUBGLYPH_FLAG_2X2 0x80
|
||||
#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
ft_glyph_own_bitmap = 1
|
||||
};
|
||||
|
||||
|
||||
struct FT_SubGlyph_
|
||||
{
|
||||
FT_Int index;
|
||||
FT_UShort flags;
|
||||
FT_Int arg1;
|
||||
FT_Int arg2;
|
||||
FT_Matrix transform;
|
||||
};
|
||||
|
||||
|
||||
typedef struct FT_GlyphLoad_
|
||||
{
|
||||
FT_Outline outline; /* outline */
|
||||
FT_UInt num_subglyphs; /* number of subglyphs */
|
||||
FT_SubGlyph* subglyphs; /* subglyphs */
|
||||
FT_Vector* extra_points; /* extra points table */
|
||||
|
||||
} FT_GlyphLoad;
|
||||
|
||||
|
||||
struct FT_GlyphLoader_
|
||||
{
|
||||
FT_Memory memory;
|
||||
FT_UInt max_points;
|
||||
FT_UInt max_contours;
|
||||
FT_UInt max_subglyphs;
|
||||
FT_Bool use_extra;
|
||||
|
||||
FT_GlyphLoad base;
|
||||
FT_GlyphLoad current;
|
||||
|
||||
void* other; /* for possible future extension? */
|
||||
|
||||
};
|
||||
|
||||
|
||||
BASE_DEF( FT_Error ) FT_GlyphLoader_New( FT_Memory memory,
|
||||
FT_GlyphLoader** aloader );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_GlyphLoader_Create_Extra(
|
||||
FT_GlyphLoader* loader );
|
||||
|
||||
BASE_DEF( void ) FT_GlyphLoader_Done( FT_GlyphLoader* loader );
|
||||
|
||||
BASE_DEF( void ) FT_GlyphLoader_Reset( FT_GlyphLoader* loader );
|
||||
|
||||
BASE_DEF( void ) FT_GlyphLoader_Rewind( FT_GlyphLoader* loader );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_GlyphLoader_Check_Points(
|
||||
FT_GlyphLoader* loader,
|
||||
FT_UInt n_points,
|
||||
FT_UInt n_contours );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_GlyphLoader_Check_Subglyphs(
|
||||
FT_GlyphLoader* loader,
|
||||
FT_UInt n_subs );
|
||||
|
||||
BASE_DEF( void ) FT_GlyphLoader_Prepare( FT_GlyphLoader* loader );
|
||||
|
||||
BASE_DEF( void ) FT_GlyphLoader_Add( FT_GlyphLoader* loader );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_GlyphLoader_Copy_Points( FT_GlyphLoader* target,
|
||||
FT_GlyphLoader* source );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** R E N D E R E R S ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define FT_RENDERER( x ) ((FT_Renderer)( x ))
|
||||
#define FT_GLYPH( x ) ((FT_Glyph)( x ))
|
||||
#define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x ))
|
||||
#define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
|
||||
|
||||
|
||||
typedef struct FT_RendererRec_
|
||||
{
|
||||
FT_ModuleRec root;
|
||||
FT_Renderer_Class* clazz;
|
||||
FT_Glyph_Format glyph_format;
|
||||
const FT_Glyph_Class glyph_class;
|
||||
|
||||
FT_Raster raster;
|
||||
FT_Raster_Render_Func raster_render;
|
||||
FTRenderer_render render;
|
||||
|
||||
} FT_RendererRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** F O N T D R I V E R S ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* typecast a module into a driver easily */
|
||||
#define FT_DRIVER( x ) ((FT_Driver)(x))
|
||||
|
||||
/* typecast a module as a driver, and get its driver class */
|
||||
#define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_DriverRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The root font driver class. A font driver is responsible for */
|
||||
/* managing and loading font files of a given format. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: Contains the fields of the root module class. */
|
||||
/* */
|
||||
/* clazz :: A pointer to the font driver's class. Note that */
|
||||
/* this is NOT root.clazz. `class' wasn't used */
|
||||
/* as it is a reserved word in C++. */
|
||||
/* */
|
||||
/* faces_list :: The list of faces currently opened by this */
|
||||
/* driver. */
|
||||
/* */
|
||||
/* extensions :: A typeless pointer to the driver's extensions */
|
||||
/* registry, if they are supported through the */
|
||||
/* configuration macro FT_CONFIG_OPTION_EXTENSIONS. */
|
||||
/* */
|
||||
/* glyph_loader :: The glyph loader for all faces managed by this */
|
||||
/* driver. This object isn't defined for unscalable */
|
||||
/* formats. */
|
||||
/* */
|
||||
typedef struct FT_DriverRec_
|
||||
{
|
||||
FT_ModuleRec root;
|
||||
FT_Driver_Class* clazz;
|
||||
|
||||
FT_ListRec faces_list;
|
||||
void* extensions;
|
||||
|
||||
FT_GlyphLoader* glyph_loader;
|
||||
|
||||
} FT_DriverRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** L I B R A R I E S ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define FT_DEBUG_HOOK_TRUETYPE 0
|
||||
#define FT_DEBUG_HOOK_TYPE1 1
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_LibraryRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The FreeType library class. This is the root of all FreeType */
|
||||
/* data. Use FT_New_Library() to create a library object, and */
|
||||
/* FT_Done_Library() to discard it and all child objects. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* memory :: The library's memory object. Manages memory */
|
||||
/* allocation. */
|
||||
/* */
|
||||
/* generic :: Client data variable. Used to extend the */
|
||||
/* Library class by higher levels and clients. */
|
||||
/* */
|
||||
/* num_modules :: The number of modules currently registered */
|
||||
/* within this library. This is set to 0 for new */
|
||||
/* libraries. New modules are added through the */
|
||||
/* FT_Add_Module() API function. */
|
||||
/* */
|
||||
/* modules :: A table used to store handles to the currently */
|
||||
/* registered modules. Note that each font driver */
|
||||
/* contains a list of its opened faces. */
|
||||
/* */
|
||||
/* renderers :: The list of renderers currently registered */
|
||||
/* within the library. */
|
||||
/* */
|
||||
/* cur_renderer :: The current outline renderer. This is a */
|
||||
/* shortcut used to avoid parsing the list on */
|
||||
/* each call to FT_Outline_Render(). It is a */
|
||||
/* handle to the current renderer for the */
|
||||
/* ft_glyph_format_outline format. */
|
||||
/* */
|
||||
/* auto_hinter :: XXX */
|
||||
/* */
|
||||
/* raster_pool :: The raster object's render pool. This can */
|
||||
/* ideally be changed dynamically at run-time. */
|
||||
/* */
|
||||
/* raster_pool_size :: The size of the render pool in bytes. */
|
||||
/* */
|
||||
/* debug_hooks :: XXX */
|
||||
/* */
|
||||
typedef struct FT_LibraryRec_
|
||||
{
|
||||
FT_Memory memory; /* library's memory manager */
|
||||
|
||||
FT_Generic generic;
|
||||
|
||||
FT_UInt num_modules;
|
||||
FT_Module modules[FT_MAX_MODULES]; /* module objects */
|
||||
|
||||
FT_ListRec renderers; /* list of renderers */
|
||||
FT_Renderer cur_renderer; /* current outline renderer */
|
||||
FT_Module auto_hinter;
|
||||
|
||||
FT_Byte* raster_pool; /* scan-line conversion */
|
||||
/* render pool */
|
||||
FT_ULong raster_pool_size; /* size of render pool in bytes */
|
||||
|
||||
FT_DebugHook_Func debug_hooks[4];
|
||||
|
||||
} FT_LibraryRec;
|
||||
|
||||
|
||||
BASE_DEF( FT_Renderer ) FT_Lookup_Renderer( FT_Library library,
|
||||
FT_Glyph_Format format,
|
||||
FT_ListNode* node );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Render_Glyph_Internal( FT_Library library,
|
||||
FT_GlyphSlot slot,
|
||||
FT_UInt render_mode );
|
||||
|
||||
typedef FT_Error (*FT_Glyph_Name_Requester)( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_Pointer buffer,
|
||||
FT_UInt buffer_max );
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
|
||||
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) FT_New_Stream( const char* filepathname,
|
||||
FT_Stream astream );
|
||||
|
||||
FT_EXPORT_DEF( void ) FT_Done_Stream( FT_Stream stream );
|
||||
|
||||
FT_EXPORT_DEF( FT_Memory ) FT_New_Memory( void );
|
||||
|
||||
|
||||
#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
|
||||
|
||||
|
||||
/* Define default raster's interface. The default raster is located in */
|
||||
/* `src/base/ftraster.c' */
|
||||
/* */
|
||||
/* Client applications can register new rasters through the */
|
||||
/* FT_Set_Raster() API. */
|
||||
|
||||
#ifndef FT_NO_DEFAULT_RASTER
|
||||
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTOBJS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
361
src/freetype/freetype/internal/ftstream.h
Normal file
361
src/freetype/freetype/internal/ftstream.h
Normal file
@@ -0,0 +1,361 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftstream.h */
|
||||
/* */
|
||||
/* Stream handling(specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTSTREAM_H
|
||||
#define FTSTREAM_H
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* format of an 8-bit frame_op value = [ xxxxx | e | s ] */
|
||||
/* s is set to 1 if the value is signed, */
|
||||
/* e is set to 1 if the value is little-endian */
|
||||
/* xxxxx is a command */
|
||||
|
||||
#define FT_FRAME_OP_SHIFT 2
|
||||
#define FT_FRAME_OP_SIGNED 1
|
||||
#define FT_FRAME_OP_LITTLE 2
|
||||
#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT )
|
||||
|
||||
#define FT_MAKE_FRAME_OP( command, little, sign ) \
|
||||
( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign )
|
||||
|
||||
#define FT_FRAME_OP_END 0
|
||||
#define FT_FRAME_OP_START 1 /* start a new frame */
|
||||
#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */
|
||||
#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */
|
||||
#define FT_FRAME_OP_LONG 4 /* read 4-byte value */
|
||||
#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */
|
||||
#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */
|
||||
|
||||
|
||||
typedef enum FT_Frame_Op_
|
||||
{
|
||||
ft_frame_end = 0,
|
||||
ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ),
|
||||
|
||||
ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ),
|
||||
ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ),
|
||||
|
||||
ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ),
|
||||
ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ),
|
||||
ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ),
|
||||
ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ),
|
||||
|
||||
ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ),
|
||||
ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ),
|
||||
ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ),
|
||||
ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ),
|
||||
|
||||
ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ),
|
||||
ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ),
|
||||
ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ),
|
||||
ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ),
|
||||
|
||||
ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ),
|
||||
ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 )
|
||||
|
||||
} FT_Frame_Op;
|
||||
|
||||
|
||||
typedef struct FT_Frame_Field_
|
||||
{
|
||||
FT_Frame_Op value;
|
||||
char size;
|
||||
FT_UShort offset;
|
||||
|
||||
} FT_Frame_Field;
|
||||
|
||||
|
||||
/* make-up a FT_Frame_Field out of a structure type and a field name */
|
||||
#define FT_FIELD_REF( s, f ) (((s*)0)->f)
|
||||
|
||||
#define FT_FRAME_FIELD( frame_op, struct_type, field ) \
|
||||
{ \
|
||||
frame_op, \
|
||||
sizeof ( FT_FIELD_REF( struct_type,field ) ), \
|
||||
(FT_UShort)(char*)&FT_FIELD_REF( struct_type, field ) \
|
||||
}
|
||||
|
||||
#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 }
|
||||
|
||||
#define FT_FRAME_START( s ) { ft_frame_start, 0, s }
|
||||
#define FT_FRAME_END { ft_frame_end, 0, 0 }
|
||||
|
||||
#define FT_FRAME_LONG( s, f ) FT_FRAME_FIELD( ft_frame_long_be, s, f )
|
||||
#define FT_FRAME_ULONG( s, f ) FT_FRAME_FIELD( ft_frame_ulong_be, s, f )
|
||||
#define FT_FRAME_SHORT( s, f ) FT_FRAME_FIELD( ft_frame_short_be, s, f )
|
||||
#define FT_FRAME_USHORT( s, f ) FT_FRAME_FIELD( ft_frame_ushort_be, s, f )
|
||||
#define FT_FRAME_BYTE( s, f ) FT_FRAME_FIELD( ft_frame_byte, s, f )
|
||||
#define FT_FRAME_CHAR( s, f ) FT_FRAME_FIELD( ft_frame_schar, s, f )
|
||||
|
||||
#define FT_FRAME_LONG_LE( s, f ) FT_FRAME_FIELD( ft_frame_long_le, s, f )
|
||||
#define FT_FRAME_ULONG_LE( s, f ) FT_FRAME_FIELD( ft_frame_ulong_le, s, f )
|
||||
#define FT_FRAME_SHORT_LE( s, f ) FT_FRAME_FIELD( ft_frame_short_le, s, f )
|
||||
#define FT_FRAME_USHORT_LE( s, f ) FT_FRAME_FIELD( ft_frame_ushort_le, s, f )
|
||||
|
||||
#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 }
|
||||
#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 }
|
||||
#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 }
|
||||
|
||||
#define FT_FRAME_BYTES( struct_type, field, count ) \
|
||||
{ \
|
||||
ft_frame_bytes, \
|
||||
count, \
|
||||
(FT_UShort)(char*)&FT_FIELD_REF( struct_type, field ) \
|
||||
}
|
||||
#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 }
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* integer extraction macros -- the `buffer' parameter must ALWAYS be of */
|
||||
/* type `char*' or equivalent (1-byte elements). */
|
||||
/* */
|
||||
#define NEXT_Char( buffer ) \
|
||||
( (signed char)*buffer++ )
|
||||
#define NEXT_Byte( buffer ) \
|
||||
( (unsigned char)*buffer++ )
|
||||
|
||||
#define NEXT_Short( buffer ) \
|
||||
( buffer += 2, \
|
||||
( (short)( (signed char)buffer[-2] << 8 ) | \
|
||||
(unsigned char)buffer[-1] ) )
|
||||
|
||||
#define NEXT_UShort( buffer ) \
|
||||
( (unsigned short)NEXT_Short( buffer ) )
|
||||
|
||||
#define NEXT_Offset( buffer ) \
|
||||
( buffer += 3, \
|
||||
( ( (long)(signed char)buffer[-3] << 16 ) | \
|
||||
( (long)(unsigned char)buffer[-2] << 8 ) | \
|
||||
(long)(unsigned char)buffer[-1] ) )
|
||||
|
||||
#define NEXT_UOffset( buffer ) \
|
||||
( (unsigned long)NEXT_Offset( buffer ) )
|
||||
|
||||
#define NEXT_Long( buffer ) \
|
||||
( buffer += 4, \
|
||||
( ( (long)(signed char)buffer[-4] << 24 ) | \
|
||||
( (long)(unsigned char)buffer[-3] << 16 ) | \
|
||||
( (long)(unsigned char)buffer[-2] << 8 ) | \
|
||||
(long)(unsigned char)buffer[-1] ) )
|
||||
|
||||
#define NEXT_ULong( buffer ) \
|
||||
( (unsigned long)NEXT_Long( buffer ) )
|
||||
|
||||
|
||||
#define NEXT_ShortLE( buffer ) \
|
||||
( buffer += 2, \
|
||||
( (short)( (signed char)buffer[-1] << 8 ) | \
|
||||
(unsigned char)buffer[-2] ) )
|
||||
|
||||
#define NEXT_UShortLE( buffer ) \
|
||||
( (unsigned short)NEXT_ShortLE( buffer ) )
|
||||
|
||||
#define NEXT_OffsetLE( buffer ) \
|
||||
( buffer += 3, \
|
||||
( ( (long)(signed char)buffer[-1] << 16 ) | \
|
||||
( (long)(unsigned char)buffer[-2] << 8 ) | \
|
||||
(long)(unsigned char)buffer[-3] ) )
|
||||
|
||||
#define NEXT_UOffsetLE( buffer ) \
|
||||
( (unsigned long)NEXT_OffsetLE( buffer ) )
|
||||
|
||||
|
||||
#define NEXT_LongLE( buffer ) \
|
||||
( buffer += 4, \
|
||||
( ( (long)(signed char)buffer[-1] << 24 ) | \
|
||||
( (long)(unsigned char)buffer[-2] << 16 ) | \
|
||||
( (long)(unsigned char)buffer[-3] << 8 ) | \
|
||||
(long)(unsigned char)buffer[-4] ) )
|
||||
|
||||
#define NEXT_ULongLE( buffer ) \
|
||||
( (unsigned long)NEXT_LongLE( buffer ) )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Each GET_xxxx() macro uses an implicit `stream' variable. */
|
||||
/* */
|
||||
#define FT_GET_MACRO( func, type ) ( (type)func( stream ) )
|
||||
|
||||
#define GET_Char() FT_GET_MACRO( FT_Get_Char, FT_Char )
|
||||
#define GET_Byte() FT_GET_MACRO( FT_Get_Char, FT_Byte )
|
||||
#define GET_Short() FT_GET_MACRO( FT_Get_Short, FT_Short )
|
||||
#define GET_UShort() FT_GET_MACRO( FT_Get_Short, FT_UShort )
|
||||
#define GET_Offset() FT_GET_MACRO( FT_Get_Offset, FT_Long )
|
||||
#define GET_UOffset() FT_GET_MACRO( FT_Get_Offset, FT_ULong )
|
||||
#define GET_Long() FT_GET_MACRO( FT_Get_Long, FT_Long )
|
||||
#define GET_ULong() FT_GET_MACRO( FT_Get_Long, FT_ULong )
|
||||
#define GET_Tag4() FT_GET_MACRO( FT_Get_Long, FT_ULong )
|
||||
|
||||
#define GET_ShortLE() FT_GET_MACRO( FT_Get_ShortLE, FT_Short )
|
||||
#define GET_UShortLE() FT_GET_MACRO( FT_Get_ShortLE, FT_UShort )
|
||||
#define GET_LongLE() FT_GET_MACRO( FT_Get_LongLE, FT_Short )
|
||||
#define GET_ULongLE() FT_GET_MACRO( FT_Get_LongLE, FT_Short )
|
||||
|
||||
#define FT_READ_MACRO( func, type, var ) \
|
||||
( var = (type)func( stream, &error ), \
|
||||
error != FT_Err_Ok )
|
||||
|
||||
#define READ_Byte( var ) FT_READ_MACRO( FT_Read_Char, FT_Byte, var )
|
||||
#define READ_Char( var ) FT_READ_MACRO( FT_Read_Char, FT_Char, var )
|
||||
#define READ_Short( var ) FT_READ_MACRO( FT_Read_Short, FT_Short, var )
|
||||
#define READ_UShort( var ) FT_READ_MACRO( FT_Read_Short, FT_UShort, var )
|
||||
#define READ_Offset( var ) FT_READ_MACRO( FT_Read_Offset, FT_Long, var )
|
||||
#define READ_UOffset( var ) FT_READ_MACRO( FT_Read_Offset, FT_ULong, var )
|
||||
#define READ_Long( var ) FT_READ_MACRO( FT_Read_Long, FT_Long, var )
|
||||
#define READ_ULong( var ) FT_READ_MACRO( FT_Read_Long, FT_ULong, var )
|
||||
|
||||
#define READ_ShortLE( var ) FT_READ_MACRO( FT_Read_ShortLE, FT_Short, var )
|
||||
#define READ_UShortLE( var ) FT_READ_MACRO( FT_Read_ShortLE, FT_UShort, var )
|
||||
#define READ_LongLE( var ) FT_READ_MACRO( FT_Read_LongLE, FT_Long, var )
|
||||
#define READ_ULongLE( var ) FT_READ_MACRO( FT_Read_LongLE, FT_ULong, var )
|
||||
|
||||
|
||||
BASE_DEF( void ) FT_New_Memory_Stream( FT_Library library,
|
||||
FT_Byte* base,
|
||||
FT_ULong size,
|
||||
FT_Stream stream );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Seek_Stream( FT_Stream stream,
|
||||
FT_ULong pos );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Skip_Stream( FT_Stream stream,
|
||||
FT_Long distance );
|
||||
|
||||
BASE_DEF( FT_Long ) FT_Stream_Pos( FT_Stream stream );
|
||||
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Read_Stream( FT_Stream stream,
|
||||
FT_Byte* buffer,
|
||||
FT_ULong count );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Read_Stream_At( FT_Stream stream,
|
||||
FT_ULong pos,
|
||||
FT_Byte* buffer,
|
||||
FT_ULong count );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Access_Frame( FT_Stream stream,
|
||||
FT_ULong count );
|
||||
|
||||
BASE_DEF( void ) FT_Forget_Frame( FT_Stream stream );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Extract_Frame( FT_Stream stream,
|
||||
FT_ULong count,
|
||||
FT_Byte** pbytes );
|
||||
|
||||
BASE_DEF( void ) FT_Release_Frame( FT_Stream stream,
|
||||
FT_Byte** pbytes );
|
||||
|
||||
BASE_DEF( FT_Char ) FT_Get_Char( FT_Stream stream );
|
||||
|
||||
BASE_DEF( FT_Short ) FT_Get_Short( FT_Stream stream );
|
||||
|
||||
BASE_DEF( FT_Long ) FT_Get_Offset( FT_Stream stream );
|
||||
|
||||
BASE_DEF( FT_Long ) FT_Get_Long( FT_Stream stream );
|
||||
|
||||
BASE_DEF( FT_Short ) FT_Get_ShortLE( FT_Stream stream );
|
||||
|
||||
BASE_DEF( FT_Long ) FT_Get_LongLE( FT_Stream stream );
|
||||
|
||||
|
||||
BASE_DEF( FT_Char ) FT_Read_Char( FT_Stream stream,
|
||||
FT_Error* error );
|
||||
|
||||
BASE_DEF( FT_Short ) FT_Read_Short( FT_Stream stream,
|
||||
FT_Error* error );
|
||||
|
||||
BASE_DEF( FT_Long ) FT_Read_Offset( FT_Stream stream,
|
||||
FT_Error* error );
|
||||
|
||||
BASE_DEF( FT_Long ) FT_Read_Long( FT_Stream stream,
|
||||
FT_Error* error );
|
||||
|
||||
BASE_DEF( FT_Short ) FT_Read_ShortLE( FT_Stream stream,
|
||||
FT_Error* error );
|
||||
|
||||
BASE_DEF( FT_Long ) FT_Read_LongLE( FT_Stream stream,
|
||||
FT_Error* error );
|
||||
|
||||
BASE_DEF( FT_Error ) FT_Read_Fields( FT_Stream stream,
|
||||
const FT_Frame_Field* fields,
|
||||
void* structure );
|
||||
|
||||
|
||||
#define USE_Stream( resource, stream ) \
|
||||
FT_SET_ERROR( FT_Open_Stream( resource, stream ) )
|
||||
|
||||
#define DONE_Stream( stream ) \
|
||||
FT_Done_Stream( stream )
|
||||
|
||||
|
||||
#define ACCESS_Frame( size ) \
|
||||
FT_SET_ERROR( FT_Access_Frame( stream, size ) )
|
||||
|
||||
#define FORGET_Frame() \
|
||||
FT_Forget_Frame( stream )
|
||||
|
||||
#define EXTRACT_Frame( size, bytes ) \
|
||||
FT_SET_ERROR( FT_Extract_Frame( stream, size, \
|
||||
(FT_Byte**)&(bytes) ) )
|
||||
|
||||
#define RELEASE_Frame( bytes ) \
|
||||
FT_Release_Frame( stream, (FT_Byte**)&(bytes) )
|
||||
|
||||
#define FILE_Seek( position ) \
|
||||
FT_SET_ERROR( FT_Seek_Stream( stream, position ) )
|
||||
|
||||
#define FILE_Skip( distance ) \
|
||||
FT_SET_ERROR( FT_Skip_Stream( stream, distance ) )
|
||||
|
||||
#define FILE_Pos() \
|
||||
FT_Stream_Pos( stream )
|
||||
|
||||
#define FILE_Read( buffer, count ) \
|
||||
FT_SET_ERROR( FT_Read_Stream( stream, \
|
||||
(FT_Byte*)buffer, \
|
||||
count ) )
|
||||
|
||||
#define FILE_Read_At( position, buffer, count ) \
|
||||
FT_SET_ERROR( FT_Read_Stream_At( stream, \
|
||||
position, \
|
||||
(FT_Byte*)buffer, \
|
||||
count ) )
|
||||
|
||||
#define READ_Fields( fields, object ) \
|
||||
( ( error = FT_Read_Fields( stream, fields, object ) ) != FT_Err_Ok )
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTSTREAM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
220
src/freetype/freetype/internal/psnames.h
Normal file
220
src/freetype/freetype/internal/psnames.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* psnames.h */
|
||||
/* */
|
||||
/* High-level interface for the `PSNames' module (in charge of */
|
||||
/* various functions related to Postscript glyph names conversion). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PSNAMES_H
|
||||
#define PSNAMES_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* PS_Unicode_Value_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to return the Unicode index corresponding to a */
|
||||
/* given glyph name. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph_name :: The glyph name. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The Unicode character index resp. the non-Unicode value 0xFFFF if */
|
||||
/* the glyph name has no known Unicode meaning. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function is able to map several different glyph names to the */
|
||||
/* same Unicode value, according to the rules defined in the Adobe */
|
||||
/* Glyph List table. */
|
||||
/* */
|
||||
/* This function will not be compiled if the configuration macro */
|
||||
/* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */
|
||||
/* */
|
||||
typedef FT_ULong (*PS_Unicode_Value_Func)( const char* glyph_name );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* PS_Unicode_Index_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to return the glyph index corresponding to a given */
|
||||
/* Unicode value. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* num_glyphs :: The number of glyphs in the face. */
|
||||
/* */
|
||||
/* glyph_names :: An array of glyph name pointers. */
|
||||
/* */
|
||||
/* unicode :: The Unicode value. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The glyph index resp. 0xFFFF if no glyph corresponds to this */
|
||||
/* Unicode value. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function is able to recognize several glyph names per Unicode */
|
||||
/* value, according to the Adobe Glyph List. */
|
||||
/* */
|
||||
/* This function will not be compiled if the configuration macro */
|
||||
/* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */
|
||||
/* */
|
||||
typedef FT_UInt (*PS_Unicode_Index_Func)( FT_UInt num_glyphs,
|
||||
const char** glyph_names,
|
||||
FT_ULong unicode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* PS_Macintosh_Name_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to return the glyph name corresponding to an Apple */
|
||||
/* glyph name index. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* name_index :: The index of the Mac name. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The glyph name, or 0 if the index is invalid. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function will not be compiled if the configuration macro */
|
||||
/* FT_CONFIG_OPTION_POSTSCRIPT_NAMES is undefined. */
|
||||
/* */
|
||||
typedef const char* (*PS_Macintosh_Name_Func)( FT_UInt name_index );
|
||||
|
||||
|
||||
typedef const char* (*PS_Adobe_Std_Strings_Func)( FT_UInt string_index );
|
||||
|
||||
|
||||
typedef struct PS_UniMap_
|
||||
{
|
||||
FT_UInt unicode;
|
||||
FT_UInt glyph_index;
|
||||
|
||||
} PS_UniMap;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PS_Unicodes */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple table used to map Unicode values to glyph indices. It is */
|
||||
/* built by the PS_Build_Unicodes table according to the glyphs */
|
||||
/* present in a font file. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_codes :: The number of glyphs in the font that match a given */
|
||||
/* Unicode value. */
|
||||
/* */
|
||||
/* unicodes :: An array of unicode values, sorted in increasing */
|
||||
/* order. */
|
||||
/* */
|
||||
/* gindex :: An array of glyph indices, corresponding to each */
|
||||
/* Unicode value. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Use the function PS_Lookup_Unicode() to retrieve the glyph index */
|
||||
/* corresponding to a given Unicode character code. */
|
||||
/* */
|
||||
typedef struct PS_Unicodes_
|
||||
{
|
||||
FT_UInt num_maps;
|
||||
PS_UniMap* maps;
|
||||
|
||||
} PS_Unicodes;
|
||||
|
||||
|
||||
typedef FT_Error (*PS_Build_Unicodes_Func)( FT_Memory memory,
|
||||
FT_UInt num_glyphs,
|
||||
const char** glyph_names,
|
||||
PS_Unicodes* unicodes );
|
||||
|
||||
typedef FT_UInt (*PS_Lookup_Unicode_Func)( PS_Unicodes* unicodes,
|
||||
FT_UInt unicode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PSNames_Interface */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This structure defines the PSNames interface. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* unicode_value :: A function used to convert a glyph name */
|
||||
/* into a Unicode character code. */
|
||||
/* */
|
||||
/* build_unicodes :: A function which builds up the Unicode */
|
||||
/* mapping table. */
|
||||
/* */
|
||||
/* lookup_unicode :: A function used to return the glyph index */
|
||||
/* corresponding to a given Unicode */
|
||||
/* character. */
|
||||
/* */
|
||||
/* macintosh_name :: A function used to return the standard */
|
||||
/* Apple glyph Postscript name corresponding */
|
||||
/* to a given string index (used by the */
|
||||
/* TrueType `post' table). */
|
||||
/* */
|
||||
/* adobe_std_strings :: A function that returns a pointer to a */
|
||||
/* Adobe Standard String for a given SID. */
|
||||
/* */
|
||||
/* adobe_std_encoding :: A table of 256 unsigned shorts that maps */
|
||||
/* character codes in the Adobe Standard */
|
||||
/* Encoding to SIDs. */
|
||||
/* */
|
||||
/* adobe_expert_encoding :: A table of 256 unsigned shorts that maps */
|
||||
/* character codes in the Adobe Expert */
|
||||
/* Encoding to SIDs. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* `unicode_value' and `unicode_index' will be set to 0 if the */
|
||||
/* configuration macro FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is */
|
||||
/* undefined. */
|
||||
/* */
|
||||
/* `macintosh_name' will be set to 0 if the configuration macro */
|
||||
/* FT_CONFIG_OPTION_POSTSCRIPT_NAMES is undefined. */
|
||||
/* */
|
||||
typedef struct PSNames_Interface_
|
||||
{
|
||||
PS_Unicode_Value_Func unicode_value;
|
||||
PS_Build_Unicodes_Func build_unicodes;
|
||||
PS_Lookup_Unicode_Func lookup_unicode;
|
||||
PS_Macintosh_Name_Func macintosh_name;
|
||||
|
||||
PS_Adobe_Std_Strings_Func adobe_std_strings;
|
||||
const unsigned short* adobe_std_encoding;
|
||||
const unsigned short* adobe_expert_encoding;
|
||||
|
||||
} PSNames_Interface;
|
||||
|
||||
|
||||
#endif /* PSNAMES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
492
src/freetype/freetype/internal/sfnt.h
Normal file
492
src/freetype/freetype/internal/sfnt.h
Normal file
@@ -0,0 +1,492 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* sfnt.h */
|
||||
/* */
|
||||
/* High-level `sfnt' driver interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SFNT_H
|
||||
#define SFNT_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
#include <freetype/internal/tttypes.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Init_Face_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* First part of the SFNT face object initialization. This will find */
|
||||
/* the face in a SFNT file or collection, and load its format tag in */
|
||||
/* face->format_tag. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: The input stream. */
|
||||
/* */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* face_index :: The index of the TrueType font, if we are opening a */
|
||||
/* collection. */
|
||||
/* */
|
||||
/* num_params :: The number of additional parameters. */
|
||||
/* */
|
||||
/* params :: Optional additional parameters. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The stream cursor must be at the font file's origin. */
|
||||
/* */
|
||||
/* This function recognizes fonts embedded in a `TrueType */
|
||||
/* collection'. */
|
||||
/* */
|
||||
/* Once the format tag has been validated by the font driver, it */
|
||||
/* should then call the TT_Load_Face_Func() callback to read the rest */
|
||||
/* of the SFNT tables in the object. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Init_Face_Func)( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_Face_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Second part of the SFNT face object initialization. This will */
|
||||
/* load the common SFNT tables (head, OS/2, maxp, metrics, etc.) in */
|
||||
/* the face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: The input stream. */
|
||||
/* */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* face_index :: The index of the TrueType font, if we are opening a */
|
||||
/* collection. */
|
||||
/* */
|
||||
/* num_params :: The number of additional parameters. */
|
||||
/* */
|
||||
/* params :: Optional additional parameters. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function must be called after TT_Init_Face_Func(). */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_Face_Func)( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Done_Face_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A callback used to delete the common SFNT data from a face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does NOT destroy the face object. */
|
||||
/* */
|
||||
typedef
|
||||
void (*TT_Done_Face_Func)( TT_Face face );
|
||||
|
||||
|
||||
typedef
|
||||
FT_Module_Interface (*SFNT_Get_Interface_Func)( FT_Module module,
|
||||
const char* interface );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_SFNT_Header_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Loads the header of a SFNT font file. Supports collections. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* stream :: The input stream. */
|
||||
/* */
|
||||
/* face_index :: The index of the TrueType font, if we are opening a */
|
||||
/* collection. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* sfnt :: The SFNT header. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The stream cursor must be at the font file's origin. */
|
||||
/* */
|
||||
/* This function recognizes fonts embedded in a `TrueType */
|
||||
/* collection'. */
|
||||
/* */
|
||||
/* This function checks that the header is valid by looking at the */
|
||||
/* values of `search_range', `entry_selector', and `range_shift'. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_SFNT_Header_Func)( TT_Face face,
|
||||
FT_Stream stream,
|
||||
FT_Long face_index,
|
||||
SFNT_Header* sfnt );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_Directory_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Loads the table directory into a face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* stream :: The input stream. */
|
||||
/* */
|
||||
/* sfnt :: The SFNT header. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The stream cursor must be on the first byte after the 4-byte font */
|
||||
/* format tag. This is the case just after a call to */
|
||||
/* TT_Load_Format_Tag(). */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_Directory_Func)( TT_Face face,
|
||||
FT_Stream stream,
|
||||
SFNT_Header* sfnt );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_Any_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Loads any font table into client memory. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: The face object to look for. */
|
||||
/* */
|
||||
/* tag :: The tag of table to load. Use the value 0 if you want */
|
||||
/* to access the whole font file, else set this parameter */
|
||||
/* to a valid TrueType table tag that you can forge with */
|
||||
/* the MAKE_TT_TAG macro. */
|
||||
/* */
|
||||
/* offset :: The starting offset in the table (or the file if */
|
||||
/* tag == 0). */
|
||||
/* */
|
||||
/* length :: The address of the decision variable: */
|
||||
/* */
|
||||
/* If length == NULL: */
|
||||
/* Loads the whole table. Returns an error if */
|
||||
/* `offset' == 0! */
|
||||
/* */
|
||||
/* If *length == 0: */
|
||||
/* Exits immediately; returning the length of the given */
|
||||
/* table or of the font file, depending on the value of */
|
||||
/* `tag'. */
|
||||
/* */
|
||||
/* If *length != 0: */
|
||||
/* Loads the next `length' bytes of table or font, */
|
||||
/* starting at offset `offset' (in table or font too). */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* buffer :: The address of target buffer. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* TrueType error code. 0 means success. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_Any_Func)( TT_Face face,
|
||||
FT_ULong tag,
|
||||
FT_Long offset,
|
||||
FT_Byte* buffer,
|
||||
FT_ULong* length );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_SBit_Image_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Loads a given glyph sbit image from the font resource. This also */
|
||||
/* returns its metrics. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: The target face object. */
|
||||
/* */
|
||||
/* x_ppem :: The horizontal resolution in points per EM. */
|
||||
/* */
|
||||
/* y_ppem :: The vertical resolution in points per EM. */
|
||||
/* */
|
||||
/* glyph_index :: The current glyph index. */
|
||||
/* */
|
||||
/* stream :: The input stream. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* map :: The target pixmap. */
|
||||
/* */
|
||||
/* metrics :: A big sbit metrics structure for the glyph image. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. Returns an error if no */
|
||||
/* glyph sbit exists for the index. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The `map.buffer' field is always freed before the glyph is loaded. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_SBit_Image_Func)( TT_Face face,
|
||||
FT_Int x_ppem,
|
||||
FT_Int y_ppem,
|
||||
FT_UInt glyph_index,
|
||||
FT_UInt load_flags,
|
||||
FT_Stream stream,
|
||||
FT_Bitmap* map,
|
||||
TT_SBit_Metrics* metrics );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Get_PS_Name_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Gets the PostScript glyph name of a glyph. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* 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> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Get_PS_Name_Func)( TT_Face face,
|
||||
FT_UInt index,
|
||||
FT_String** PSname );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_Metrics_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Loads the horizontal or vertical header in a face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* stream :: The input stream. */
|
||||
/* */
|
||||
/* vertical :: A boolean flag. If set, load vertical metrics. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_Metrics_Func)( TT_Face face,
|
||||
FT_Stream stream,
|
||||
FT_Bool vertical );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_CharMap_Load_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Loads a given TrueType character map into memory. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the parent face object. */
|
||||
/* */
|
||||
/* stream :: A handle to the current stream object. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* cmap :: A pointer to a cmap object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The function assumes that the stream is already in use (i.e., */
|
||||
/* opened). In case of error, all partially allocated tables are */
|
||||
/* released. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_CharMap_Load_Func)( TT_Face face,
|
||||
TT_CMapTable* cmap,
|
||||
FT_Stream input );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_CharMap_Free_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroys a character mapping table. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the parent face object. */
|
||||
/* */
|
||||
/* cmap :: A handle to a cmap object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_CharMap_Free_Func)( TT_Face face,
|
||||
TT_CMapTable* cmap );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Load_Table_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Loads a given TrueType table. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* stream :: The input stream. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The function will use `face->goto_table' to seek the stream to */
|
||||
/* the start of the table. */
|
||||
/* */
|
||||
typedef
|
||||
FT_Error (*TT_Load_Table_Func)( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* TT_Free_Table_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Frees a given TrueType table. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
typedef
|
||||
void (*TT_Free_Table_Func)( TT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* SFNT_Interface */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This structure holds pointers to the functions used to load and */
|
||||
/* free the basic tables that are required in a `sfnt' font file. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* Check the various xxx_Func() descriptions for details. */
|
||||
/* */
|
||||
typedef struct SFNT_Interface_
|
||||
{
|
||||
TT_Goto_Table_Func goto_table;
|
||||
|
||||
TT_Init_Face_Func init_face;
|
||||
TT_Load_Face_Func load_face;
|
||||
TT_Done_Face_Func done_face;
|
||||
SFNT_Get_Interface_Func get_interface;
|
||||
|
||||
TT_Load_Any_Func load_any;
|
||||
TT_Load_SFNT_Header_Func load_sfnt_header;
|
||||
TT_Load_Directory_Func load_directory;
|
||||
|
||||
/* these functions are called by `load_face' but they can also */
|
||||
/* be called from external modules, if there is a need to do so */
|
||||
TT_Load_Table_Func load_header;
|
||||
TT_Load_Metrics_Func load_metrics;
|
||||
TT_Load_Table_Func load_charmaps;
|
||||
TT_Load_Table_Func load_max_profile;
|
||||
TT_Load_Table_Func load_os2;
|
||||
TT_Load_Table_Func load_psnames;
|
||||
|
||||
TT_Load_Table_Func load_names;
|
||||
TT_Free_Table_Func free_names;
|
||||
|
||||
/* optional tables */
|
||||
TT_Load_Table_Func load_hdmx;
|
||||
TT_Free_Table_Func free_hdmx;
|
||||
|
||||
TT_Load_Table_Func load_kerning;
|
||||
TT_Load_Table_Func load_gasp;
|
||||
TT_Load_Table_Func load_pclt;
|
||||
|
||||
/* see `ttsbit.h' */
|
||||
TT_Load_Table_Func load_sbits;
|
||||
TT_Load_SBit_Image_Func load_sbit_image;
|
||||
TT_Free_Table_Func free_sbits;
|
||||
|
||||
/* see `ttpost.h' */
|
||||
TT_Get_PS_Name_Func get_psname;
|
||||
TT_Free_Table_Func free_psnames;
|
||||
|
||||
/* see `ttcmap.h' */
|
||||
TT_CharMap_Load_Func load_charmap;
|
||||
TT_CharMap_Free_Func free_charmap;
|
||||
|
||||
} SFNT_Interface;
|
||||
|
||||
|
||||
#endif /* SFNT_H */
|
||||
|
||||
|
||||
/* END */
|
||||
67
src/freetype/freetype/internal/t1errors.h
Normal file
67
src/freetype/freetype/internal/t1errors.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1errors.h */
|
||||
/* */
|
||||
/* Type 1 error ID definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T1ERRORS_H
|
||||
#define T1ERRORS_H
|
||||
|
||||
|
||||
/************************ error codes declaration **************/
|
||||
|
||||
/* The error codes are grouped into `classes' used to indicate the */
|
||||
/* `level' at which the error happened. */
|
||||
/* */
|
||||
/* The class is given by an error code's high byte. */
|
||||
|
||||
|
||||
/* ------------- Success is always 0 -------- */
|
||||
|
||||
#define T1_Err_Ok FT_Err_Ok
|
||||
|
||||
/* ----------- high level API errors -------- */
|
||||
|
||||
#define T1_Err_Invalid_File_Format FT_Err_Invalid_File_Format
|
||||
#define T1_Err_Invalid_Argument FT_Err_Invalid_Argument
|
||||
#define T1_Err_Invalid_Driver_Handle FT_Err_Invalid_Driver_Handle
|
||||
#define T1_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle
|
||||
#define T1_Err_Invalid_Size_Handle FT_Err_Invalid_Size_Handle
|
||||
#define T1_Err_Invalid_Glyph_Handle FT_Err_Invalid_Slot_Handle
|
||||
#define T1_Err_Invalid_CharMap_Handle FT_Err_Invalid_CharMap_Handle
|
||||
#define T1_Err_Invalid_Glyph_Index FT_Err_Invalid_Glyph_Index
|
||||
|
||||
#define T1_Err_Unimplemented_Feature FT_Err_Unimplemented_Feature
|
||||
|
||||
#define T1_Err_Invalid_Engine FT_Err_Invalid_Driver_Handle
|
||||
|
||||
/* ------------- internal errors ------------ */
|
||||
|
||||
#define T1_Err_Out_Of_Memory FT_Err_Out_Of_Memory
|
||||
#define T1_Err_Unlisted_Object FT_Err_Unlisted_Object
|
||||
|
||||
/* ------------ general glyph outline errors ------ */
|
||||
|
||||
#define T1_Err_Invalid_Composite FT_Err_Invalid_Composite
|
||||
|
||||
#define T1_Err_Syntax_Error FT_Err_Invalid_File_Format
|
||||
#define T1_Err_Stack_Underflow FT_Err_Invalid_File_Format
|
||||
#define T1_Err_Stack_Overflow FT_Err_Invalid_File_Format
|
||||
|
||||
|
||||
#endif /* T1ERRORS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
188
src/freetype/freetype/internal/t1types.h
Normal file
188
src/freetype/freetype/internal/t1types.h
Normal file
@@ -0,0 +1,188 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1types.h */
|
||||
/* */
|
||||
/* Basic Type1/Type2 type definitions and interface (specification */
|
||||
/* only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T1TYPES_H
|
||||
#define T1TYPES_H
|
||||
|
||||
|
||||
#include <freetype/t1tables.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*** ***/
|
||||
/*** ***/
|
||||
/*** REQUIRED TYPE1/TYPE2 TABLES DEFINITIONS ***/
|
||||
/*** ***/
|
||||
/*** ***/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Encoding */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure modeling a custom encoding */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_chars :: The number of character codes in the encoding. */
|
||||
/* Usually 256. */
|
||||
/* */
|
||||
/* code_first :: The lowest valid character code in the encoding. */
|
||||
/* */
|
||||
/* code_last :: The highest valid character code in the encoding. */
|
||||
/* */
|
||||
/* char_index :: An array of corresponding glyph indices. */
|
||||
/* */
|
||||
/* char_name :: An array of corresponding glyph names. */
|
||||
/* */
|
||||
typedef struct T1_Encoding_
|
||||
{
|
||||
FT_Int num_chars;
|
||||
FT_Int code_first;
|
||||
FT_Int code_last;
|
||||
|
||||
FT_UShort* char_index;
|
||||
FT_String** char_name;
|
||||
|
||||
} T1_Encoding;
|
||||
|
||||
|
||||
typedef enum T1_EncodingType_
|
||||
{
|
||||
t1_encoding_none = 0,
|
||||
t1_encoding_array,
|
||||
t1_encoding_standard,
|
||||
t1_encoding_expert
|
||||
|
||||
} T1_EncodingType;
|
||||
|
||||
|
||||
typedef struct T1_Font_
|
||||
{
|
||||
|
||||
/* font info dictionary */
|
||||
T1_FontInfo font_info;
|
||||
|
||||
/* private dictionary */
|
||||
T1_Private private_dict;
|
||||
|
||||
/* top-level dictionary */
|
||||
FT_String* font_name;
|
||||
|
||||
T1_EncodingType encoding_type;
|
||||
T1_Encoding encoding;
|
||||
|
||||
FT_Byte* subrs_block;
|
||||
FT_Byte* charstrings_block;
|
||||
FT_Byte* glyph_names_block;
|
||||
|
||||
FT_Int num_subrs;
|
||||
FT_Byte** subrs;
|
||||
FT_Int* subrs_len;
|
||||
|
||||
FT_Int num_glyphs;
|
||||
FT_String** glyph_names; /* array of glyph names */
|
||||
FT_Byte** charstrings; /* array of glyph charstrings */
|
||||
FT_Int* charstrings_len;
|
||||
|
||||
FT_Byte paint_type;
|
||||
FT_Byte font_type;
|
||||
FT_Matrix font_matrix;
|
||||
FT_BBox font_bbox;
|
||||
FT_Long font_id;
|
||||
|
||||
FT_Int stroke_width;
|
||||
|
||||
} T1_Font;
|
||||
|
||||
|
||||
typedef struct CID_Subrs_
|
||||
{
|
||||
FT_UInt num_subrs;
|
||||
FT_Byte** code;
|
||||
|
||||
} CID_Subrs;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*** ***/
|
||||
/*** ***/
|
||||
/*** ORIGINAL T1_FACE CLASS DEFINITION ***/
|
||||
/*** ***/
|
||||
/*** ***/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This structure/class is defined here because it is common to the */
|
||||
/* following formats: TTF, OpenType-TT, and OpenType-CFF. */
|
||||
/* */
|
||||
/* Note, however, that the classes TT_Size, TT_GlyphSlot, and TT_CharMap */
|
||||
/* are not shared between font drivers, and are thus defined normally in */
|
||||
/* `ttobjs.h'. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
typedef struct T1_FaceRec_* T1_Face;
|
||||
typedef struct CID_FaceRec_* CID_Face;
|
||||
|
||||
|
||||
typedef struct T1_FaceRec_
|
||||
{
|
||||
FT_FaceRec root;
|
||||
T1_Font type1;
|
||||
void* psnames;
|
||||
void* afm_data;
|
||||
FT_CharMapRec charmaprecs[2];
|
||||
FT_CharMap charmaps[2];
|
||||
PS_Unicodes unicode_map;
|
||||
|
||||
/* support for Multiple Masters fonts */
|
||||
T1_Blend* blend;
|
||||
|
||||
} T1_FaceRec;
|
||||
|
||||
|
||||
typedef struct CID_FaceRec_
|
||||
{
|
||||
FT_FaceRec root;
|
||||
void* psnames;
|
||||
CID_Info cid;
|
||||
void* afm_data;
|
||||
CID_Subrs* subrs;
|
||||
|
||||
} CID_FaceRec;
|
||||
|
||||
|
||||
#endif /* T1TYPES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
121
src/freetype/freetype/internal/t2errors.h
Normal file
121
src/freetype/freetype/internal/t2errors.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2errors.h */
|
||||
/* */
|
||||
/* OpenType error ID definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T2ERRORS_H
|
||||
#define T2ERRORS_H
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Error codes declaration */
|
||||
/* */
|
||||
/* The error codes are grouped in `classes' used to indicate the `level' */
|
||||
/* at which the error happened. The class is given by an error code's */
|
||||
/* high byte. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* Success is always 0. */
|
||||
|
||||
#define T2_Err_Ok FT_Err_Ok
|
||||
|
||||
/* High level API errors. */
|
||||
|
||||
#define T2_Err_Invalid_File_Format FT_Err_Invalid_File_Format
|
||||
#define T2_Err_Invalid_Argument FT_Err_Invalid_Argument
|
||||
#define T2_Err_Invalid_Driver_Handle FT_Err_Invalid_Driver_Handle
|
||||
#define T2_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle
|
||||
#define T2_Err_Invalid_Instance_Handle FT_Err_Invalid_Size_Handle
|
||||
#define T2_Err_Invalid_Glyph_Handle FT_Err_Invalid_Slot_Handle
|
||||
#define T2_Err_Invalid_CharMap_Handle FT_Err_Invalid_CharMap_Handle
|
||||
#define T2_Err_Invalid_Glyph_Index FT_Err_Invalid_Glyph_Index
|
||||
|
||||
#define T2_Err_Unimplemented_Feature FT_Err_Unimplemented_Feature
|
||||
|
||||
#define T2_Err_Invalid_Engine FT_Err_Invalid_Driver_Handle
|
||||
|
||||
/* Internal errors. */
|
||||
|
||||
#define T2_Err_Out_Of_Memory FT_Err_Out_Of_Memory
|
||||
#define T2_Err_Unlisted_Object FT_Err_Unlisted_Object
|
||||
|
||||
/* General glyph outline errors. */
|
||||
|
||||
#define T2_Err_Invalid_Composite FT_Err_Invalid_Composite
|
||||
|
||||
/* Bytecode interpreter error codes. */
|
||||
|
||||
/* These error codes are produced by the TrueType */
|
||||
/* bytecode interpreter. They usually indicate a */
|
||||
/* broken font file, a broken glyph within a font */
|
||||
/* file, or a bug in the interpreter! */
|
||||
|
||||
#define T2_Err_Invalid_Opcode 0x500
|
||||
#define T2_Err_Too_Few_Arguments 0x501
|
||||
#define T2_Err_Stack_Overflow 0x502
|
||||
#define T2_Err_Code_Overflow 0x503
|
||||
#define T2_Err_Bad_Argument 0x504
|
||||
#define T2_Err_Divide_By_Zero 0x505
|
||||
#define T2_Err_Storage_Overflow 0x506
|
||||
#define T2_Err_Cvt_Overflow 0x507
|
||||
#define T2_Err_Invalid_Reference 0x508
|
||||
#define T2_Err_Invalid_Distance 0x509
|
||||
#define T2_Err_Interpolate_Twilight 0x50A
|
||||
#define T2_Err_Debug_OpCode 0x50B
|
||||
#define T2_Err_ENDF_In_Exec_Stream 0x50C
|
||||
#define T2_Err_Out_Of_CodeRanges 0x50D
|
||||
#define T2_Err_Nested_DEFS 0x50E
|
||||
#define T2_Err_Invalid_CodeRange 0x50F
|
||||
#define T2_Err_Invalid_Displacement 0x510
|
||||
#define T2_Err_Execution_Too_Long 0x511
|
||||
|
||||
#define T2_Err_Too_Many_Instruction_Defs 0x512
|
||||
#define T2_Err_Too_Many_Function_Defs 0x513
|
||||
|
||||
/* Other TrueType specific error codes. */
|
||||
|
||||
#define T2_Err_Table_Missing 0x520
|
||||
#define T2_Err_Too_Many_Extensions 0x521
|
||||
#define T2_Err_Extensions_Unsupported 0x522
|
||||
#define T2_Err_Invalid_Extension_Id 0x523
|
||||
|
||||
#define T2_Err_No_Vertical_Data 0x524
|
||||
|
||||
#define T2_Err_Max_Profile_Missing 0x530
|
||||
#define T2_Err_Header_Table_Missing 0x531
|
||||
#define T2_Err_Horiz_Header_Missing 0x532
|
||||
#define T2_Err_Locations_Missing 0x533
|
||||
#define T2_Err_Name_Table_Missing 0x534
|
||||
#define T2_Err_CMap_Table_Missing 0x535
|
||||
#define T2_Err_Hmtx_Table_Missing 0x536
|
||||
#define T2_Err_OS2_Table_Missing 0x537
|
||||
#define T2_Err_Post_Table_Missing 0x538
|
||||
|
||||
#define T2_Err_Invalid_Horiz_Metrics 0x540
|
||||
#define T2_Err_Invalid_CharMap_Format 0x541
|
||||
#define T2_Err_Invalid_PPem 0x542
|
||||
#define T2_Err_Invalid_Vert_Metrics 0x543
|
||||
|
||||
#define T2_Err_Could_Not_Find_Context 0x550
|
||||
|
||||
|
||||
#endif /* T2ERRORS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
218
src/freetype/freetype/internal/t2types.h
Normal file
218
src/freetype/freetype/internal/t2types.h
Normal file
@@ -0,0 +1,218 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t2types.h */
|
||||
/* */
|
||||
/* Basic OpenType/CFF type definitions and interface (specification */
|
||||
/* only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T2TYPES_H
|
||||
#define T2TYPES_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CFF_Index */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a CFF Index table. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* stream :: XXX */
|
||||
/* */
|
||||
/* count :: The number of elements in the index. */
|
||||
/* */
|
||||
/* off_size :: The size in bytes of object offsets in index. */
|
||||
/* */
|
||||
/* data_offset :: The position of first data byte in the index's */
|
||||
/* bytes. */
|
||||
/* */
|
||||
/* offsets :: XXX */
|
||||
/* */
|
||||
/* bytes :: If the index is loaded in memory, its bytes. */
|
||||
/* */
|
||||
typedef struct CFF_Index_
|
||||
{
|
||||
FT_Stream stream;
|
||||
FT_UInt count;
|
||||
FT_Byte off_size;
|
||||
FT_ULong data_offset;
|
||||
|
||||
FT_ULong* offsets;
|
||||
FT_Byte* bytes;
|
||||
|
||||
} CFF_Index;
|
||||
|
||||
|
||||
typedef struct CFF_Font_Dict_
|
||||
{
|
||||
FT_UInt version;
|
||||
FT_UInt notice;
|
||||
FT_UInt copyright;
|
||||
FT_UInt full_name;
|
||||
FT_UInt family_name;
|
||||
FT_UInt weight;
|
||||
FT_Bool is_fixed_pitch;
|
||||
FT_Fixed italic_angle;
|
||||
FT_Pos underline_position;
|
||||
FT_Pos underline_thickness;
|
||||
FT_Int paint_type;
|
||||
FT_Int charstring_type;
|
||||
FT_Matrix font_matrix;
|
||||
FT_ULong unique_id;
|
||||
FT_BBox font_bbox;
|
||||
FT_Pos stroke_width;
|
||||
FT_ULong charset_offset;
|
||||
FT_ULong encoding_offset;
|
||||
FT_ULong charstrings_offset;
|
||||
FT_ULong private_offset;
|
||||
FT_ULong private_size;
|
||||
FT_Long synthetic_base;
|
||||
FT_UInt embedded_postscript;
|
||||
FT_UInt base_font_name;
|
||||
FT_UInt postscript;
|
||||
|
||||
/* these should only be used for the top-level font dictionary */
|
||||
FT_UInt cid_registry;
|
||||
FT_UInt cid_ordering;
|
||||
FT_ULong cid_supplement;
|
||||
|
||||
FT_Long cid_font_version;
|
||||
FT_Long cid_font_revision;
|
||||
FT_Long cid_font_type;
|
||||
FT_Long cid_count;
|
||||
FT_ULong cid_uid_base;
|
||||
FT_ULong cid_fd_array_offset;
|
||||
FT_ULong cid_fd_select_offset;
|
||||
FT_UInt cid_font_name;
|
||||
|
||||
} CFF_Font_Dict;
|
||||
|
||||
|
||||
typedef struct CFF_Private_
|
||||
{
|
||||
FT_Byte num_blue_values;
|
||||
FT_Byte num_other_blues;
|
||||
FT_Byte num_family_blues;
|
||||
FT_Byte num_family_other_blues;
|
||||
|
||||
FT_Pos blue_values[14];
|
||||
FT_Pos other_blues[10];
|
||||
FT_Pos family_blues[14];
|
||||
FT_Pos family_other_blues[10];
|
||||
|
||||
FT_Fixed blue_scale;
|
||||
FT_Pos blue_shift;
|
||||
FT_Pos blue_fuzz;
|
||||
FT_Pos standard_width;
|
||||
FT_Pos standard_height;
|
||||
|
||||
FT_Byte num_snap_widths;
|
||||
FT_Byte num_snap_heights;
|
||||
FT_Pos snap_widths[13];
|
||||
FT_Pos snap_heights[13];
|
||||
FT_Bool force_bold;
|
||||
FT_Fixed force_bold_threshold;
|
||||
FT_Int lenIV;
|
||||
FT_Int language_group;
|
||||
FT_Fixed expansion_factor;
|
||||
FT_Long initial_random_seed;
|
||||
FT_ULong local_subrs_offset;
|
||||
FT_Pos default_width;
|
||||
FT_Pos nominal_width;
|
||||
|
||||
} CFF_Private;
|
||||
|
||||
|
||||
typedef struct CFF_FD_Select_
|
||||
{
|
||||
FT_Byte format;
|
||||
FT_UInt range_count;
|
||||
|
||||
/* that's the table, taken from the file `as is' */
|
||||
FT_Byte* data;
|
||||
FT_UInt data_size;
|
||||
|
||||
/* small cache for format 3 only */
|
||||
FT_UInt cache_first;
|
||||
FT_UInt cache_count;
|
||||
FT_Byte cache_fd;
|
||||
|
||||
} CFF_FD_Select;
|
||||
|
||||
|
||||
/* A SubFont packs a font dict and a private dict together. They are */
|
||||
/* needed to support CID-keyed CFF fonts. */
|
||||
typedef struct CFF_SubFont_
|
||||
{
|
||||
CFF_Font_Dict font_dict;
|
||||
CFF_Private private_dict;
|
||||
|
||||
CFF_Index local_subrs_index;
|
||||
FT_UInt num_local_subrs;
|
||||
FT_Byte** local_subrs;
|
||||
|
||||
} CFF_SubFont;
|
||||
|
||||
|
||||
/* maximum number of sub-fonts in a CID-keyed file */
|
||||
#define CFF_MAX_CID_FONTS 16
|
||||
|
||||
|
||||
typedef struct CFF_Font_
|
||||
{
|
||||
FT_Stream stream;
|
||||
FT_Memory memory;
|
||||
FT_UInt num_faces;
|
||||
FT_UInt num_glyphs;
|
||||
|
||||
FT_Byte version_major;
|
||||
FT_Byte version_minor;
|
||||
FT_Byte header_size;
|
||||
FT_Byte absolute_offsize;
|
||||
|
||||
|
||||
CFF_Index name_index;
|
||||
CFF_Index top_dict_index;
|
||||
CFF_Index string_index;
|
||||
CFF_Index global_subrs_index;
|
||||
|
||||
/* we don't load the Encoding and CharSet tables */
|
||||
|
||||
CFF_Index charstrings_index;
|
||||
CFF_Index font_dict_index;
|
||||
CFF_Index private_index;
|
||||
CFF_Index local_subrs_index;
|
||||
|
||||
FT_String* font_name;
|
||||
FT_UInt num_global_subrs;
|
||||
FT_Byte** global_subrs;
|
||||
|
||||
CFF_SubFont top_font;
|
||||
FT_UInt num_subfonts;
|
||||
CFF_SubFont* subfonts[CFF_MAX_CID_FONTS];
|
||||
|
||||
CFF_FD_Select fd_select;
|
||||
|
||||
} CFF_Font;
|
||||
|
||||
|
||||
#endif /* T2TYPES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
121
src/freetype/freetype/internal/tterrors.h
Normal file
121
src/freetype/freetype/internal/tterrors.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* tterrors.h */
|
||||
/* */
|
||||
/* TrueType error ID definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TTERRORS_H
|
||||
#define TTERRORS_H
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Error codes declaration */
|
||||
/* */
|
||||
/* The error codes are grouped in `classes' used to indicate the `level' */
|
||||
/* at which the error happened. The class is given by an error code's */
|
||||
/* high byte. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* Success is always 0. */
|
||||
|
||||
#define TT_Err_Ok FT_Err_Ok
|
||||
|
||||
/* High level API errors. */
|
||||
|
||||
#define TT_Err_Invalid_File_Format FT_Err_Invalid_File_Format
|
||||
#define TT_Err_Invalid_Argument FT_Err_Invalid_Argument
|
||||
#define TT_Err_Invalid_Driver_Handle FT_Err_Invalid_Driver_Handle
|
||||
#define TT_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle
|
||||
#define TT_Err_Invalid_Instance_Handle FT_Err_Invalid_Size_Handle
|
||||
#define TT_Err_Invalid_Glyph_Handle FT_Err_Invalid_Slot_Handle
|
||||
#define TT_Err_Invalid_CharMap_Handle FT_Err_Invalid_CharMap_Handle
|
||||
#define TT_Err_Invalid_Glyph_Index FT_Err_Invalid_Glyph_Index
|
||||
|
||||
#define TT_Err_Unimplemented_Feature FT_Err_Unimplemented_Feature
|
||||
|
||||
#define TT_Err_Invalid_Engine FT_Err_Invalid_Driver_Handle
|
||||
|
||||
/* Internal errors. */
|
||||
|
||||
#define TT_Err_Out_Of_Memory FT_Err_Out_Of_Memory
|
||||
#define TT_Err_Unlisted_Object FT_Err_Unlisted_Object
|
||||
|
||||
/* General glyph outline errors. */
|
||||
|
||||
#define TT_Err_Too_Many_Ins FT_Err_Too_Many_Hints
|
||||
#define TT_Err_Invalid_Composite FT_Err_Invalid_Composite
|
||||
|
||||
/* Bytecode interpreter error codes. */
|
||||
|
||||
/* These error codes are produced by the TrueType */
|
||||
/* bytecode interpreter. They usually indicate a */
|
||||
/* broken font file, a broken glyph within a font */
|
||||
/* file, or a bug in the interpreter! */
|
||||
|
||||
#define TT_Err_Invalid_Opcode 0x400
|
||||
#define TT_Err_Too_Few_Arguments 0x401
|
||||
#define TT_Err_Stack_Overflow 0x402
|
||||
#define TT_Err_Code_Overflow 0x403
|
||||
#define TT_Err_Bad_Argument 0x404
|
||||
#define TT_Err_Divide_By_Zero 0x405
|
||||
#define TT_Err_Storage_Overflow 0x406
|
||||
#define TT_Err_Cvt_Overflow 0x407
|
||||
#define TT_Err_Invalid_Reference 0x408
|
||||
#define TT_Err_Invalid_Distance 0x409
|
||||
#define TT_Err_Interpolate_Twilight 0x40A
|
||||
#define TT_Err_Debug_OpCode 0x40B
|
||||
#define TT_Err_ENDF_In_Exec_Stream 0x40C
|
||||
#define TT_Err_Out_Of_CodeRanges 0x40D
|
||||
#define TT_Err_Nested_DEFS 0x40E
|
||||
#define TT_Err_Invalid_CodeRange 0x40F
|
||||
#define TT_Err_Invalid_Displacement 0x410
|
||||
#define TT_Err_Execution_Too_Long 0x411
|
||||
#define TT_Err_Too_Many_Function_Defs 0x412
|
||||
#define TT_Err_Too_Many_Instruction_Defs 0x413
|
||||
|
||||
/* Other TrueType specific error codes. */
|
||||
|
||||
#define TT_Err_Table_Missing 0x420
|
||||
#define TT_Err_Too_Many_Extensions 0x421
|
||||
#define TT_Err_Extensions_Unsupported 0x422
|
||||
#define TT_Err_Invalid_Extension_Id 0x423
|
||||
|
||||
#define TT_Err_No_Vertical_Data 0x424
|
||||
|
||||
#define TT_Err_Max_Profile_Missing 0x430
|
||||
#define TT_Err_Header_Table_Missing 0x431
|
||||
#define TT_Err_Horiz_Header_Missing 0x432
|
||||
#define TT_Err_Locations_Missing 0x433
|
||||
#define TT_Err_Name_Table_Missing 0x434
|
||||
#define TT_Err_CMap_Table_Missing 0x435
|
||||
#define TT_Err_Hmtx_Table_Missing 0x436
|
||||
#define TT_Err_OS2_Table_Missing 0x437
|
||||
#define TT_Err_Post_Table_Missing 0x438
|
||||
|
||||
#define TT_Err_Invalid_Horiz_Metrics 0x440
|
||||
#define TT_Err_Invalid_CharMap_Format 0x441
|
||||
#define TT_Err_Invalid_PPem 0x442
|
||||
#define TT_Err_Invalid_Vert_Metrics 0x443
|
||||
|
||||
#define TT_Err_Could_Not_Find_Context 0x450
|
||||
|
||||
|
||||
#endif /* TTERRORS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
1582
src/freetype/freetype/internal/tttypes.h
Normal file
1582
src/freetype/freetype/internal/tttypes.h
Normal file
File diff suppressed because it is too large
Load Diff
235
src/freetype/freetype/t1tables.h
Normal file
235
src/freetype/freetype/t1tables.h
Normal file
@@ -0,0 +1,235 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1tables.h */
|
||||
/* */
|
||||
/* Basic Type 1/Type 2 tables definitions and interface (specification */
|
||||
/* only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T1TABLES_H
|
||||
#define T1TABLES_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
/* Note that we separate font data in T1_FontInfo and T1_Private */
|
||||
/* structures in order to support Multiple Master fonts. */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_FontInfo */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a Type1/Type2 FontInfo dictionary. Note */
|
||||
/* that for Multiple Master fonts, each instance has its own */
|
||||
/* FontInfo. */
|
||||
/* */
|
||||
typedef struct T1_FontInfo
|
||||
{
|
||||
FT_String* version;
|
||||
FT_String* notice;
|
||||
FT_String* full_name;
|
||||
FT_String* family_name;
|
||||
FT_String* weight;
|
||||
FT_Long italic_angle;
|
||||
FT_Bool is_fixed_pitch;
|
||||
FT_Short underline_position;
|
||||
FT_UShort underline_thickness;
|
||||
|
||||
} T1_FontInfo;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Private */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a Type1/Type2 FontInfo dictionary. Note */
|
||||
/* that for Multiple Master fonts, each instance has its own Private */
|
||||
/* dict. */
|
||||
/* */
|
||||
typedef struct T1_Private
|
||||
{
|
||||
FT_Int unique_id;
|
||||
FT_Int lenIV;
|
||||
|
||||
FT_Byte num_blue_values;
|
||||
FT_Byte num_other_blues;
|
||||
FT_Byte num_family_blues;
|
||||
FT_Byte num_family_other_blues;
|
||||
|
||||
FT_Short blue_values[14];
|
||||
FT_Short other_blues[10];
|
||||
|
||||
FT_Short family_blues [14];
|
||||
FT_Short family_other_blues[10];
|
||||
|
||||
FT_Fixed blue_scale;
|
||||
FT_Int blue_shift;
|
||||
FT_Int blue_fuzz;
|
||||
|
||||
FT_UShort standard_width[1];
|
||||
FT_UShort standard_height[1];
|
||||
|
||||
FT_Byte num_snap_widths;
|
||||
FT_Byte num_snap_heights;
|
||||
FT_Bool force_bold;
|
||||
FT_Bool round_stem_up;
|
||||
|
||||
FT_Short snap_widths [13]; /* reserve one place for the std */
|
||||
FT_Short snap_heights[13]; /* reserve one place for the std */
|
||||
|
||||
FT_Long language_group;
|
||||
FT_Long password;
|
||||
|
||||
FT_Short min_feature[2];
|
||||
|
||||
} T1_Private;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* T1_Blend_Flags */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A set of flags used to indicate which fields are present in a */
|
||||
/* given blen dictionary (font info or private). Used to support */
|
||||
/* Multiple Masters fonts. */
|
||||
/* */
|
||||
typedef enum
|
||||
{
|
||||
/* required fields in a FontInfo blend dictionary */
|
||||
t1_blend_underline_position = 0,
|
||||
t1_blend_underline_thickness,
|
||||
t1_blend_italic_angle,
|
||||
|
||||
/* required fields in a Private blend dictionary */
|
||||
t1_blend_blue_values,
|
||||
t1_blend_other_blues,
|
||||
t1_blend_standard_width,
|
||||
t1_blend_standard_height,
|
||||
t1_blend_stem_snap_widths,
|
||||
t1_blend_stem_snap_heights,
|
||||
t1_blend_blue_scale,
|
||||
t1_blend_blue_shift,
|
||||
t1_blend_family_blues,
|
||||
t1_blend_family_other_blues,
|
||||
t1_blend_force_bold,
|
||||
|
||||
/* never remove */
|
||||
t1_blend_max
|
||||
|
||||
} T1_Blend_Flags;
|
||||
|
||||
|
||||
/* maximum number of Multiple Masters designs, as defined in the spec */
|
||||
#define T1_MAX_MM_DESIGNS 16
|
||||
|
||||
/* maximum number of Multiple Masters axes, as defined in the spec */
|
||||
#define T1_MAX_MM_AXIS 4
|
||||
|
||||
/* maximum number of elements in a design map */
|
||||
#define T1_MAX_MM_MAP_POINTS 20
|
||||
|
||||
|
||||
/* this structure is used to store the BlendDesignMap entry for an axis */
|
||||
typedef struct T1_DesignMap_
|
||||
{
|
||||
FT_Byte num_points;
|
||||
FT_Fixed* design_points;
|
||||
FT_Fixed* blend_points;
|
||||
|
||||
} T1_DesignMap;
|
||||
|
||||
|
||||
typedef struct T1_Blend_
|
||||
{
|
||||
FT_UInt num_designs;
|
||||
FT_UInt num_axis;
|
||||
|
||||
FT_String* axis_names[T1_MAX_MM_AXIS];
|
||||
FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
|
||||
T1_DesignMap design_map[T1_MAX_MM_AXIS];
|
||||
|
||||
FT_Fixed* weight_vector;
|
||||
FT_Fixed* default_weight_vector;
|
||||
|
||||
T1_FontInfo* font_infos[T1_MAX_MM_DESIGNS + 1];
|
||||
T1_Private* privates [T1_MAX_MM_DESIGNS + 1];
|
||||
|
||||
FT_ULong blend_bitflags;
|
||||
|
||||
} T1_Blend;
|
||||
|
||||
|
||||
typedef struct CID_FontDict_
|
||||
{
|
||||
T1_Private private_dict;
|
||||
|
||||
FT_UInt len_buildchar;
|
||||
FT_Fixed forcebold_threshold;
|
||||
FT_Pos stroke_width;
|
||||
FT_Fixed expansion_factor;
|
||||
|
||||
FT_Byte paint_type;
|
||||
FT_Byte font_type;
|
||||
FT_Matrix font_matrix;
|
||||
|
||||
FT_UInt num_subrs;
|
||||
FT_ULong subrmap_offset;
|
||||
FT_Int sd_bytes;
|
||||
|
||||
} CID_FontDict;
|
||||
|
||||
|
||||
typedef struct CID_Info_
|
||||
{
|
||||
FT_String* cid_font_name;
|
||||
FT_Fixed cid_version;
|
||||
FT_Int cid_font_type;
|
||||
|
||||
FT_String* registry;
|
||||
FT_String* ordering;
|
||||
FT_Int supplement;
|
||||
|
||||
T1_FontInfo font_info;
|
||||
FT_BBox font_bbox;
|
||||
FT_ULong uid_base;
|
||||
|
||||
FT_Int num_xuid;
|
||||
FT_ULong xuid[16];
|
||||
|
||||
|
||||
FT_ULong cidmap_offset;
|
||||
FT_Int fd_bytes;
|
||||
FT_Int gd_bytes;
|
||||
FT_ULong cid_count;
|
||||
|
||||
FT_Int num_dicts;
|
||||
CID_FontDict* font_dicts;
|
||||
|
||||
FT_ULong data_offset;
|
||||
|
||||
} CID_Info;
|
||||
|
||||
|
||||
#endif /* T1TABLES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
698
src/freetype/freetype/ttnameid.h
Normal file
698
src/freetype/freetype/ttnameid.h
Normal file
@@ -0,0 +1,698 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttmakeid.h */
|
||||
/* */
|
||||
/* TrueType name ID definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TTNAMEID_H
|
||||
#define TTNAMEID_H
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values for the `platform' identifier code in the name */
|
||||
/* records of the TTF `name' table. */
|
||||
/* */
|
||||
#define TT_PLATFORM_APPLE_UNICODE 0
|
||||
#define TT_PLATFORM_MACINTOSH 1
|
||||
#define TT_PLATFORM_ISO 2 /* deprecated */
|
||||
#define TT_PLATFORM_MICROSOFT 3
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values of the platform specific encoding identifier field in */
|
||||
/* the name records of the TTF `name' table if the `platform' identifier */
|
||||
/* code is TT_PLATFORM_APPLE_UNICODE. */
|
||||
/* */
|
||||
#define TT_APPLE_ID_DEFAULT 0
|
||||
#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
|
||||
#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
|
||||
#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values of the platform specific encoding identifier field in */
|
||||
/* the name records of the TTF `name' table if the `platform' identifier */
|
||||
/* code is TT_PLATFORM_MACINTOSH. */
|
||||
/* */
|
||||
#define TT_MAC_ID_ROMAN 0
|
||||
#define TT_MAC_ID_JAPANESE 1
|
||||
#define TT_MAC_ID_TRADITIONAL_CHINESE 2
|
||||
#define TT_MAC_ID_KOREAN 3
|
||||
#define TT_MAC_ID_ARABIC 4
|
||||
#define TT_MAC_ID_HEBREW 5
|
||||
#define TT_MAC_ID_GREEK 6
|
||||
#define TT_MAC_ID_RUSSIAN 7
|
||||
#define TT_MAC_ID_RSYMBOL 8
|
||||
#define TT_MAC_ID_DEVANAGARI 9
|
||||
#define TT_MAC_ID_GURMUKHI 10
|
||||
#define TT_MAC_ID_GUJARATI 11
|
||||
#define TT_MAC_ID_ORIYA 12
|
||||
#define TT_MAC_ID_BENGALI 13
|
||||
#define TT_MAC_ID_TAMIL 14
|
||||
#define TT_MAC_ID_TELUGU 15
|
||||
#define TT_MAC_ID_KANNADA 16
|
||||
#define TT_MAC_ID_MALAYALAM 17
|
||||
#define TT_MAC_ID_SINHALESE 18
|
||||
#define TT_MAC_ID_BURMESE 19
|
||||
#define TT_MAC_ID_KHMER 20
|
||||
#define TT_MAC_ID_THAI 21
|
||||
#define TT_MAC_ID_LAOTIAN 22
|
||||
#define TT_MAC_ID_GEORGIAN 23
|
||||
#define TT_MAC_ID_ARMENIAN 24
|
||||
#define TT_MAC_ID_MALDIVIAN 25
|
||||
#define TT_MAC_ID_SIMPLIFIED_CHINESE 25
|
||||
#define TT_MAC_ID_TIBETAN 26
|
||||
#define TT_MAC_ID_MONGOLIAN 27
|
||||
#define TT_MAC_ID_GEEZ 28
|
||||
#define TT_MAC_ID_SLAVIC 29
|
||||
#define TT_MAC_ID_VIETNAMESE 30
|
||||
#define TT_MAC_ID_SINDHI 31
|
||||
#define TT_MAC_ID_UNINTERP 32
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values of the platform specific encoding identifier field in */
|
||||
/* the name records of the TTF `name' table if the `platform' identifier */
|
||||
/* code is TT_PLATFORM_ISO. */
|
||||
/* */
|
||||
/* This use is now deprecated. */
|
||||
/* */
|
||||
#define TT_ISO_ID_7BIT_ASCII 0
|
||||
#define TT_ISO_ID_10646 1
|
||||
#define TT_ISO_ID_8859_1 2
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* possible values of the platform specific encoding identifier field in */
|
||||
/* the name records of the TTF `name' table if the `platform' identifier */
|
||||
/* code is TT_PLATFORM_MICROSOFT. */
|
||||
/* */
|
||||
#define TT_MS_ID_SYMBOL_CS 0
|
||||
#define TT_MS_ID_UNICODE_CS 1
|
||||
#define TT_MS_ID_SJIS 2
|
||||
#define TT_MS_ID_GB2312 3
|
||||
#define TT_MS_ID_BIG_5 4
|
||||
#define TT_MS_ID_WANSUNG 5
|
||||
#define TT_MS_ID_JOHAB 6
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values of the language identifier field in the name records */
|
||||
/* of the TTF `name' table if the `platform' identifier code is */
|
||||
/* TT_PLATFORM_MACINTOSH. */
|
||||
/* */
|
||||
/* The canonical source for the Apple assigned Language ID's is at */
|
||||
/* */
|
||||
/* http://fonts.apple.com/TTRefMan/RM06/Chap6name.html */
|
||||
/* */
|
||||
#define TT_MAC_LANGID_ENGLISH 0
|
||||
#define TT_MAC_LANGID_FRENCH 1
|
||||
#define TT_MAC_LANGID_GERMAN 2
|
||||
#define TT_MAC_LANGID_ITALIAN 3
|
||||
#define TT_MAC_LANGID_DUTCH 4
|
||||
#define TT_MAC_LANGID_SWEDISH 5
|
||||
#define TT_MAC_LANGID_SPANISH 6
|
||||
#define TT_MAC_LANGID_DANISH 7
|
||||
#define TT_MAC_LANGID_PORTUGUESE 8
|
||||
#define TT_MAC_LANGID_NORWEGIAN 9
|
||||
#define TT_MAC_LANGID_HEBREW 10
|
||||
#define TT_MAC_LANGID_JAPANESE 11
|
||||
#define TT_MAC_LANGID_ARABIC 12
|
||||
#define TT_MAC_LANGID_FINNISH 13
|
||||
#define TT_MAC_LANGID_GREEK 14
|
||||
#define TT_MAC_LANGID_ICELANDIC 15
|
||||
#define TT_MAC_LANGID_MALTESE 16
|
||||
#define TT_MAC_LANGID_TURKISH 17
|
||||
#define TT_MAC_LANGID_CROATIAN 18
|
||||
#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19
|
||||
#define TT_MAC_LANGID_URDU 20
|
||||
#define TT_MAC_LANGID_HINDI 21
|
||||
#define TT_MAC_LANGID_THAI 22
|
||||
#define TT_MAC_LANGID_KOREAN 23
|
||||
#define TT_MAC_LANGID_LITHUANIAN 24
|
||||
#define TT_MAC_LANGID_POLISH 25
|
||||
#define TT_MAC_LANGID_HUNGARIAN 26
|
||||
#define TT_MAC_LANGID_ESTONIAN 27
|
||||
#define TT_MAC_LANGID_LETTISH 28
|
||||
#define TT_MAC_LANGID_SAAMISK 29
|
||||
#define TT_MAC_LANGID_FAEROESE 30
|
||||
#define TT_MAC_LANGID_FARSI 31
|
||||
#define TT_MAC_LANGID_RUSSIAN 32
|
||||
#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33
|
||||
#define TT_MAC_LANGID_FLEMISH 34
|
||||
#define TT_MAC_LANGID_IRISH 35
|
||||
#define TT_MAC_LANGID_ALBANIAN 36
|
||||
#define TT_MAC_LANGID_ROMANIAN 37
|
||||
#define TT_MAC_LANGID_CZECH 38
|
||||
#define TT_MAC_LANGID_SLOVAK 39
|
||||
#define TT_MAC_LANGID_SLOVENIAN 40
|
||||
#define TT_MAC_LANGID_YIDDISH 41
|
||||
#define TT_MAC_LANGID_SERBIAN 42
|
||||
#define TT_MAC_LANGID_MACEDONIAN 43
|
||||
#define TT_MAC_LANGID_BULGARIAN 44
|
||||
#define TT_MAC_LANGID_UKRAINIAN 45
|
||||
#define TT_MAC_LANGID_BYELORUSSIAN 46
|
||||
#define TT_MAC_LANGID_UZBEK 47
|
||||
#define TT_MAC_LANGID_KAZAKH 48
|
||||
#define TT_MAC_LANGID_AZERBAIJANI 49
|
||||
#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49
|
||||
#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50
|
||||
#define TT_MAC_LANGID_ARMENIAN 51
|
||||
#define TT_MAC_LANGID_GEORGIAN 52
|
||||
#define TT_MAC_LANGID_MOLDAVIAN 53
|
||||
#define TT_MAC_LANGID_KIRGHIZ 54
|
||||
#define TT_MAC_LANGID_TAJIKI 55
|
||||
#define TT_MAC_LANGID_TURKMEN 56
|
||||
#define TT_MAC_LANGID_MONGOLIAN 57
|
||||
#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57
|
||||
#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58
|
||||
#define TT_MAC_LANGID_PASHTO 59
|
||||
#define TT_MAC_LANGID_KURDISH 60
|
||||
#define TT_MAC_LANGID_KASHMIRI 61
|
||||
#define TT_MAC_LANGID_SINDHI 62
|
||||
#define TT_MAC_LANGID_TIBETAN 63
|
||||
#define TT_MAC_LANGID_NEPALI 64
|
||||
#define TT_MAC_LANGID_SANSKRIT 65
|
||||
#define TT_MAC_LANGID_MARATHI 66
|
||||
#define TT_MAC_LANGID_BENGALI 67
|
||||
#define TT_MAC_LANGID_ASSAMESE 68
|
||||
#define TT_MAC_LANGID_GUJARATI 69
|
||||
#define TT_MAC_LANGID_PUNJABI 70
|
||||
#define TT_MAC_LANGID_ORIYA 71
|
||||
#define TT_MAC_LANGID_MALAYALAM 72
|
||||
#define TT_MAC_LANGID_KANNADA 73
|
||||
#define TT_MAC_LANGID_TAMIL 74
|
||||
#define TT_MAC_LANGID_TELUGU 75
|
||||
#define TT_MAC_LANGID_SINHALESE 76
|
||||
#define TT_MAC_LANGID_BURMESE 77
|
||||
#define TT_MAC_LANGID_KHMER 78
|
||||
#define TT_MAC_LANGID_LAO 79
|
||||
#define TT_MAC_LANGID_VIETNAMESE 80
|
||||
#define TT_MAC_LANGID_INDONESIAN 81
|
||||
#define TT_MAC_LANGID_TAGALOG 82
|
||||
#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83
|
||||
#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84
|
||||
#define TT_MAC_LANGID_AMHARIC 85
|
||||
#define TT_MAC_LANGID_TIGRINYA 86
|
||||
#define TT_MAC_LANGID_GALLA 87
|
||||
#define TT_MAC_LANGID_SOMALI 88
|
||||
#define TT_MAC_LANGID_SWAHILI 89
|
||||
#define TT_MAC_LANGID_RUANDA 90
|
||||
#define TT_MAC_LANGID_RUNDI 91
|
||||
#define TT_MAC_LANGID_CHEWA 92
|
||||
#define TT_MAC_LANGID_MALAGASY 93
|
||||
#define TT_MAC_LANGID_ESPERANTO 94
|
||||
#define TT_MAC_LANGID_WELSH 128
|
||||
#define TT_MAC_LANGID_BASQUE 129
|
||||
#define TT_MAC_LANGID_CATALAN 130
|
||||
#define TT_MAC_LANGID_LATIN 131
|
||||
#define TT_MAC_LANGID_QUECHUA 132
|
||||
#define TT_MAC_LANGID_GUARANI 133
|
||||
#define TT_MAC_LANGID_AYMARA 134
|
||||
#define TT_MAC_LANGID_TATAR 135
|
||||
#define TT_MAC_LANGID_UIGHUR 136
|
||||
#define TT_MAC_LANGID_DZONGKHA 137
|
||||
#define TT_MAC_LANGID_JAVANESE 138
|
||||
#define TT_MAC_LANGID_SUNDANESE 139
|
||||
|
||||
|
||||
#if 0 /* these seem to be errors that have been dropped */
|
||||
|
||||
#define TT_MAC_LANGID_SCOTTISH_GAELIC 140
|
||||
#define TT_MAC_LANGID_IRISH_GAELIC 141
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* The following codes are new as of 2000-03-10 */
|
||||
#define TT_MAC_LANGID_GALICIAN 140
|
||||
#define TT_MAC_LANGID_AFRIKAANS 141
|
||||
#define TT_MAC_LANGID_BRETON 142
|
||||
#define TT_MAC_LANGID_INUKTITUT 143
|
||||
#define TT_MAC_LANGID_SCOTTISH_GAELIC 144
|
||||
#define TT_MAC_LANGID_MANX_GAELIC 145
|
||||
#define TT_MAC_LANGID_IRISH_GAELIC 146
|
||||
#define TT_MAC_LANGID_TONGAN 147
|
||||
#define TT_MAC_LANGID_GREEK_POLYTONIC 148
|
||||
#define TT_MAC_LANGID_GREELANDIC 149
|
||||
#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values of the language identifier field in the name records */
|
||||
/* of the TTF `name' table if the `platform' identifier code is */
|
||||
/* TT_PLATFORM_MICROSOFT. */
|
||||
/* */
|
||||
/* The canonical source for the MS assigned LCID's is at */
|
||||
/* */
|
||||
/* http://www.microsoft.com/typography/OTSPEC/lcid-cp.txt */
|
||||
/* */
|
||||
#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401
|
||||
#define TT_MS_LANGID_ARABIC_IRAQ 0x0801
|
||||
#define TT_MS_LANGID_ARABIC_EGYPT 0x0c01
|
||||
#define TT_MS_LANGID_ARABIC_LIBYA 0x1001
|
||||
#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401
|
||||
#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801
|
||||
#define TT_MS_LANGID_ARABIC_TUNISIA 0x1c01
|
||||
#define TT_MS_LANGID_ARABIC_OMAN 0x2001
|
||||
#define TT_MS_LANGID_ARABIC_YEMEN 0x2401
|
||||
#define TT_MS_LANGID_ARABIC_SYRIA 0x2801
|
||||
#define TT_MS_LANGID_ARABIC_JORDAN 0x2c01
|
||||
#define TT_MS_LANGID_ARABIC_LEBANON 0x3001
|
||||
#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401
|
||||
#define TT_MS_LANGID_ARABIC_UAE 0x3801
|
||||
#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3c01
|
||||
#define TT_MS_LANGID_ARABIC_QATAR 0x4001
|
||||
#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402
|
||||
#define TT_MS_LANGID_CATALAN_SPAIN 0x0403
|
||||
#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404
|
||||
#define TT_MS_LANGID_CHINESE_PRC 0x0804
|
||||
#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0c04
|
||||
#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004
|
||||
#define TT_MS_LANGID_CHINESE_MACAU 0x1404
|
||||
#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405
|
||||
#define TT_MS_LANGID_DANISH_DENMARK 0x0406
|
||||
#define TT_MS_LANGID_GERMAN_GERMANY 0x0407
|
||||
#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807
|
||||
#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0c07
|
||||
#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007
|
||||
#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407
|
||||
#define TT_MS_LANGID_GREEK_GREECE 0x0408
|
||||
#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409
|
||||
#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809
|
||||
#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0c09
|
||||
#define TT_MS_LANGID_ENGLISH_CANADA 0x1009
|
||||
#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409
|
||||
#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809
|
||||
#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1c09
|
||||
#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009
|
||||
#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409
|
||||
#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809
|
||||
#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2c09
|
||||
#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009
|
||||
#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409
|
||||
#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040a
|
||||
#define TT_MS_LANGID_SPANISH_MEXICO 0x080a
|
||||
#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0c0a
|
||||
#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100a
|
||||
#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140a
|
||||
#define TT_MS_LANGID_SPANISH_PANAMA 0x180a
|
||||
#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1c0a
|
||||
#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200a
|
||||
#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240a
|
||||
#define TT_MS_LANGID_SPANISH_PERU 0x280a
|
||||
#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2c0a
|
||||
#define TT_MS_LANGID_SPANISH_ECUADOR 0x300a
|
||||
#define TT_MS_LANGID_SPANISH_CHILE 0x340a
|
||||
#define TT_MS_LANGID_SPANISH_URUGUAY 0x380a
|
||||
#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3c0a
|
||||
#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400a
|
||||
#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440a
|
||||
#define TT_MS_LANGID_SPANISH_HONDURAS 0x480a
|
||||
#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4c0a
|
||||
#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500a
|
||||
#define TT_MS_LANGID_FINNISH_FINLAND 0x040b
|
||||
#define TT_MS_LANGID_FRENCH_FRANCE 0x040c
|
||||
#define TT_MS_LANGID_FRENCH_BELGIUM 0x080c
|
||||
#define TT_MS_LANGID_FRENCH_CANADA 0x0c0c
|
||||
#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100c
|
||||
#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140c
|
||||
#define TT_MS_LANGID_FRENCH_MONACO 0x180c
|
||||
#define TT_MS_LANGID_HEBREW_ISRAEL 0x040d
|
||||
#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040e
|
||||
#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040f
|
||||
#define TT_MS_LANGID_ITALIAN_ITALY 0x0410
|
||||
#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810
|
||||
#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411
|
||||
#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412
|
||||
#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812
|
||||
#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413
|
||||
#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813
|
||||
#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414
|
||||
#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814
|
||||
#define TT_MS_LANGID_POLISH_POLAND 0x0415
|
||||
#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416
|
||||
#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816
|
||||
#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417
|
||||
#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418
|
||||
#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818
|
||||
#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419
|
||||
#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819
|
||||
#define TT_MS_LANGID_CROATIAN_CROATIA 0x041a
|
||||
#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081a
|
||||
#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0c1a
|
||||
#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041b
|
||||
#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041c
|
||||
#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041d
|
||||
#define TT_MS_LANGID_SWEDISH_FINLAND 0x081d
|
||||
#define TT_MS_LANGID_THAI_THAILAND 0x041e
|
||||
#define TT_MS_LANGID_TURKISH_TURKEY 0x041f
|
||||
#define TT_MS_LANGID_URDU_PAKISTAN 0x0420
|
||||
#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421
|
||||
#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422
|
||||
#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423
|
||||
#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424
|
||||
#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425
|
||||
#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426
|
||||
#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427
|
||||
#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827
|
||||
#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0428
|
||||
#define TT_MS_LANGID_FARSI_IRAN 0x0429
|
||||
#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042a
|
||||
#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042b
|
||||
#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042c
|
||||
#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082c
|
||||
#define TT_MS_LANGID_BASQUE_SPAIN 0x042d
|
||||
#define TT_MS_LANGID_SORBIAN_GERMANY 0x042e
|
||||
#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042f
|
||||
#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430
|
||||
#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431
|
||||
#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432
|
||||
#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433
|
||||
#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434
|
||||
#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435
|
||||
#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436
|
||||
#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437
|
||||
#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438
|
||||
#define TT_MS_LANGID_HINDI_INDIA 0x0439
|
||||
#define TT_MS_LANGID_MALTESE_MALTA 0x043a
|
||||
#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b
|
||||
#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c
|
||||
#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c
|
||||
#define TT_MS_LANGID_MALAY_MALAYSIA 0x043e
|
||||
#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083e
|
||||
#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043f
|
||||
#define TT_MS_LANGID_SWAHILI_KENYA 0x0441
|
||||
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443
|
||||
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843
|
||||
#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444
|
||||
#define TT_MS_LANGID_BENGALI_INDIA 0x0445
|
||||
#define TT_MS_LANGID_PUNJABI_INDIA 0x0446
|
||||
#define TT_MS_LANGID_GUJARATI_INDIA 0x0447
|
||||
#define TT_MS_LANGID_ORIYA_INDIA 0x0448
|
||||
#define TT_MS_LANGID_TAMIL_INDIA 0x0449
|
||||
#define TT_MS_LANGID_TELUGU_INDIA 0x044a
|
||||
#define TT_MS_LANGID_KANNADA_INDIA 0x044b
|
||||
#define TT_MS_LANGID_MALAYALAM_INDIA 0x044c
|
||||
#define TT_MS_LANGID_ASSAMESE_INDIA 0x044d
|
||||
#define TT_MS_LANGID_MARATHI_INDIA 0x044e
|
||||
#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f
|
||||
#define TT_MS_LANGID_KONKANI_INDIA 0x0457
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values of the `name' identifier field in the name records of */
|
||||
/* the TTF `name' table. These values are platform independent. */
|
||||
/* */
|
||||
#define TT_NAME_ID_COPYRIGHT 0
|
||||
#define TT_NAME_ID_FONT_FAMILY 1
|
||||
#define TT_NAME_ID_FONT_SUBFAMILY 2
|
||||
#define TT_NAME_ID_UNIQUE_ID 3
|
||||
#define TT_NAME_ID_FULL_NAME 4
|
||||
#define TT_NAME_ID_VERSION_STRING 5
|
||||
#define TT_NAME_ID_PS_NAME 6
|
||||
#define TT_NAME_ID_TRADEMARK 7
|
||||
|
||||
/* the following values are from the OpenType spec */
|
||||
#define TT_NAME_ID_MANUFACTURER 8
|
||||
#define TT_NAME_ID_DESIGNER 9
|
||||
#define TT_NAME_ID_DESCRIPTION 10
|
||||
#define TT_NAME_ID_VENDOR_URL 11
|
||||
#define TT_NAME_ID_DESIGNER_URL 12
|
||||
#define TT_NAME_ID_LICENSE 13
|
||||
#define TT_NAME_ID_LICENSE_URL 14
|
||||
/* number 15 is reserved */
|
||||
#define TT_NAME_ID_PREFERRED_FAMILY 16
|
||||
#define TT_NAME_ID_PREFERRED_SUBFAMILY 17
|
||||
#define TT_NAME_ID_MAC_FULL_NAME 18
|
||||
|
||||
/* The following code is new as of 2000-01-21 */
|
||||
#define TT_NAME_ID_SAMPLE_TEXT 19
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Bit mask values for the Unicode Ranges from the TTF `OS2 ' table. */
|
||||
/* */
|
||||
/* Updated 02-Jul-2000. */
|
||||
/* */
|
||||
|
||||
/* General Scripts Area */
|
||||
|
||||
/* Bit 0 C0 Controls and Basic Latin */
|
||||
#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */
|
||||
/* Bit 1 C1 Controls and Latin-1 Supplement */
|
||||
#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+00A0-U+00FF */
|
||||
/* Bit 2 Latin Extended-A */
|
||||
#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */
|
||||
/* Bit 3 Latin Extended-B */
|
||||
#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */
|
||||
/* Bit 4 IPA Extensions */
|
||||
#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */
|
||||
/* Bit 5 Spacing Modifier Letters */
|
||||
#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */
|
||||
/* Bit 6 Combining Diacritical Marks */
|
||||
#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */
|
||||
/* Bit 7 Greek */
|
||||
#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */
|
||||
/* Bit 8 is reserved (was: Greek Symbols and Coptic) */
|
||||
/* Bit 9 Cyrillic */
|
||||
#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */
|
||||
/* Bit 10 Armenian */
|
||||
#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */
|
||||
/* Bit 11 Hebrew */
|
||||
#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */
|
||||
/* Bit 12 is reserved (was: Hebrew Extended) */
|
||||
/* Bit 13 Arabic */
|
||||
#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */
|
||||
/* Bit 14 is reserved (was: Arabic Extended) */
|
||||
/* Bit 15 Devanagari */
|
||||
#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */
|
||||
/* Bit 16 Bengali */
|
||||
#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */
|
||||
/* Bit 17 Gurmukhi */
|
||||
#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */
|
||||
/* Bit 18 Gujarati */
|
||||
#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */
|
||||
/* Bit 19 Oriya */
|
||||
#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */
|
||||
/* Bit 20 Tamil */
|
||||
#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */
|
||||
/* Bit 21 Telugu */
|
||||
#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */
|
||||
/* Bit 22 Kannada */
|
||||
#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */
|
||||
/* Bit 23 Malayalam */
|
||||
#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */
|
||||
/* Bit 24 Thai */
|
||||
#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */
|
||||
/* Bit 25 Lao */
|
||||
#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */
|
||||
/* Bit 26 Georgian */
|
||||
#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */
|
||||
/* Bit 27 is reserved (was Georgian Extended) */
|
||||
/* Bit 28 Hangul Jamo */
|
||||
#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */
|
||||
/* Bit 29 Latin Extended Additional */
|
||||
#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */
|
||||
/* Bit 30 Greek Extended */
|
||||
#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */
|
||||
|
||||
/* Symbols Area */
|
||||
|
||||
/* Bit 31 General Punctuation */
|
||||
#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */
|
||||
/* Bit 32 Superscripts And Subscripts */
|
||||
#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */
|
||||
/* Bit 33 Currency Symbols */
|
||||
#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */
|
||||
/* Bit 34 Combining Diacritical Marks For Symbols */
|
||||
#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */
|
||||
/* Bit 35 Letterlike Symbols */
|
||||
#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */
|
||||
/* Bit 36 Number Forms */
|
||||
#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */
|
||||
/* Bit 37 Arrows */
|
||||
#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */
|
||||
/* Bit 38 Mathematical Operators */
|
||||
#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */
|
||||
/* Bit 39 Miscellaneous Technical */
|
||||
#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */
|
||||
/* Bit 40 Control Pictures */
|
||||
#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */
|
||||
/* Bit 41 Optical Character Recognition */
|
||||
#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */
|
||||
/* Bit 42 Enclosed Alphanumerics */
|
||||
#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */
|
||||
/* Bit 43 Box Drawing */
|
||||
#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */
|
||||
/* Bit 44 Block Elements */
|
||||
#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */
|
||||
/* Bit 45 Geometric Shapes */
|
||||
#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */
|
||||
/* Bit 46 Miscellaneous Symbols */
|
||||
#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */
|
||||
/* Bit 47 Dingbats */
|
||||
#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */
|
||||
|
||||
/* CJK Phonetics and Symbols Area */
|
||||
|
||||
/* Bit 48 CJK Symbols And Punctuation */
|
||||
#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */
|
||||
/* Bit 49 Hiragana */
|
||||
#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */
|
||||
/* Bit 50 Katakana */
|
||||
#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */
|
||||
/* Bit 51 Bopomofo + Extended Bopomofo */
|
||||
#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */
|
||||
/* U+31A0-U+31BF */
|
||||
/* Bit 52 Hangul Compatibility Jamo */
|
||||
#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */
|
||||
/* Bit 53 CJK Miscellaneous */
|
||||
#define TT_UCR_CJK_MISC (1L << 21) /* U+3190-U+319F */
|
||||
/* Bit 54 Enclosed CJK Letters And Months */
|
||||
#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */
|
||||
/* Bit 55 CJK Compatibility */
|
||||
#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */
|
||||
|
||||
/* Hangul Syllables Area */
|
||||
|
||||
/* Bit 56 Hangul */
|
||||
#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */
|
||||
|
||||
/* Surrogates Area */
|
||||
|
||||
/* Bit 57 Surrogates */
|
||||
#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DFFF */
|
||||
/* Bit 58 is reserved for Unicode SubRanges */
|
||||
|
||||
/* CJK Ideographs Area */
|
||||
|
||||
/* Bit 59 CJK Unified Ideographs + */
|
||||
/* CJK Radical Supplement + */
|
||||
/* Kangxi Radicals + */
|
||||
/* Ideographic Description + */
|
||||
/* CJK Unified Ideographs Extension A */
|
||||
#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */
|
||||
/* U+2E80-U+2EFF */
|
||||
/* U+2F00-U+2FDF */
|
||||
/* U+2FF0-U+2FFF */
|
||||
/* U+34E0-U+4DB5 */
|
||||
|
||||
/* Private Use Area */
|
||||
|
||||
/* Bit 60 Private Use */
|
||||
#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */
|
||||
|
||||
/* Compatibility Area and Specials */
|
||||
|
||||
/* Bit 61 CJK Compatibility Ideographs */
|
||||
#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+F900-U+FAFF */
|
||||
/* Bit 62 Alphabetic Presentation Forms */
|
||||
#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */
|
||||
/* Bit 63 Arabic Presentation Forms-A */
|
||||
#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FDFF */
|
||||
/* Bit 64 Combining Half Marks */
|
||||
#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */
|
||||
/* Bit 65 CJK Compatibility Forms */
|
||||
#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE30-U+FE4F */
|
||||
/* Bit 66 Small Form Variants */
|
||||
#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */
|
||||
/* Bit 67 Arabic Presentation Forms-B */
|
||||
#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFE */
|
||||
/* Bit 68 Halfwidth And Fullwidth Forms */
|
||||
#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */
|
||||
/* Bit 69 Specials */
|
||||
#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */
|
||||
/* Bit 70 Tibetan */
|
||||
#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FCF */
|
||||
/* Bit 71 Syriac */
|
||||
#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */
|
||||
/* Bit 72 Thaana */
|
||||
#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */
|
||||
/* Bit 73 Sinhala */
|
||||
#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */
|
||||
/* Bit 74 Myanmar */
|
||||
#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */
|
||||
/* Bit 75 Ethiopic */
|
||||
#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+12BF */
|
||||
/* Bit 76 Cherokee */
|
||||
#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */
|
||||
/* Bit 77 Canadian Aboriginal Syllabics */
|
||||
#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+14DF */
|
||||
/* Bit 78 Ogham */
|
||||
#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */
|
||||
/* Bit 79 Runic */
|
||||
#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */
|
||||
/* Bit 80 Khmer */
|
||||
#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */
|
||||
/* Bit 81 Mongolian */
|
||||
#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */
|
||||
/* Bit 82 Braille */
|
||||
#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */
|
||||
/* Bit 83 Yi + Yi Radicals */
|
||||
#define TT_UCR_YI (1L << 19) /* U+A000-U+A48C */
|
||||
/* U+A490-U+A4CF */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Some compilers have a very limited length of identifiers. */
|
||||
/* */
|
||||
#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ )
|
||||
#define HAVE_LIMIT_ON_IDENTS
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_LIMIT_ON_IDENTS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Here some alias #defines in order to be clearer. */
|
||||
/* */
|
||||
/* These are not always #defined to stay within the 31 character limit */
|
||||
/* which some compilers have. */
|
||||
/* */
|
||||
/* Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern */
|
||||
/* Borland compilers (read: from BC++ 3.1 on) can increase this limit. */
|
||||
/* If you get a warning with such a compiler, use the -i40 switch. */
|
||||
/* */
|
||||
#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \
|
||||
TT_UCR_ARABIC_PRESENTATIONS_A
|
||||
#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \
|
||||
TT_UCR_ARABIC_PRESENTATIONS_B
|
||||
|
||||
#define TT_UCR_COMBINING_DIACRITICAL_MARKS \
|
||||
TT_UCR_COMBINING_DIACRITICS
|
||||
#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \
|
||||
TT_UCR_COMBINING_DIACRITICS_SYMB
|
||||
|
||||
|
||||
#endif /* !HAVE_LIMIT_ON_IDENTS */
|
||||
|
||||
|
||||
#endif /* TTNAMEID_H */
|
||||
|
||||
|
||||
/* END */
|
||||
583
src/freetype/freetype/tttables.h
Normal file
583
src/freetype/freetype/tttables.h
Normal file
@@ -0,0 +1,583 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* tttables.h */
|
||||
/* */
|
||||
/* Basic SFNT/TrueType tables definitions and interface */
|
||||
/* (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TTTABLES_H
|
||||
#define TTTABLES_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_Header */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType font header table. All */
|
||||
/* fields follow the TrueType specification. */
|
||||
/* */
|
||||
typedef struct TT_Header_
|
||||
{
|
||||
FT_Fixed Table_Version;
|
||||
FT_Fixed Font_Revision;
|
||||
|
||||
FT_Long CheckSum_Adjust;
|
||||
FT_Long Magic_Number;
|
||||
|
||||
FT_UShort Flags;
|
||||
FT_UShort Units_Per_EM;
|
||||
|
||||
FT_Long Created [2];
|
||||
FT_Long Modified[2];
|
||||
|
||||
FT_Short xMin;
|
||||
FT_Short yMin;
|
||||
FT_Short xMax;
|
||||
FT_Short yMax;
|
||||
|
||||
FT_UShort Mac_Style;
|
||||
FT_UShort Lowest_Rec_PPEM;
|
||||
|
||||
FT_Short Font_Direction;
|
||||
FT_Short Index_To_Loc_Format;
|
||||
FT_Short Glyph_Data_Format;
|
||||
|
||||
} TT_Header;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_HoriHeader */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType horizontal header, the `hhea' */
|
||||
/* table, as well as the corresponding horizontal metrics table, */
|
||||
/* i.e., the `hmtx' table. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* Version :: The table version. */
|
||||
/* */
|
||||
/* Ascender :: The font's ascender, i.e., the distance */
|
||||
/* from the baseline to the top-most of all */
|
||||
/* glyph points found in the font. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of the */
|
||||
/* glyphs found in the font (maybe ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoAscender' field */
|
||||
/* of the OS/2 table instead if you want */
|
||||
/* the correct one. */
|
||||
/* */
|
||||
/* Descender :: The font's descender, i.e., the distance */
|
||||
/* from the baseline to the bottom-most of */
|
||||
/* all glyph points found in the font. It */
|
||||
/* is negative. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of the */
|
||||
/* glyphs found in the font (maybe ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoDescender' */
|
||||
/* field of the OS/2 table instead if you */
|
||||
/* want the correct one. */
|
||||
/* */
|
||||
/* Line_Gap :: The font's line gap, i.e., the distance */
|
||||
/* to add to the ascender and descender to */
|
||||
/* get the BTB, i.e., the */
|
||||
/* baseline-to-baseline distance for the */
|
||||
/* font. */
|
||||
/* */
|
||||
/* advance_Width_Max :: This field is the maximum of all advance */
|
||||
/* widths found in the font. It can be */
|
||||
/* used to compute the maximum width of an */
|
||||
/* arbitrary string of text. */
|
||||
/* */
|
||||
/* min_Left_Side_Bearing :: The minimum left side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* min_Right_Side_Bearing :: The minimum right side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* xMax_Extent :: The maximum horizontal extent (i.e., the */
|
||||
/* `width' of a glyph's bounding box) for */
|
||||
/* all glyphs in the font. */
|
||||
/* */
|
||||
/* caret_Slope_Rise :: The rise coefficient of the cursor's */
|
||||
/* slope of the cursor (slope=rise/run). */
|
||||
/* */
|
||||
/* caret_Slope_Run :: The run coefficient of the cursor's */
|
||||
/* slope. */
|
||||
/* */
|
||||
/* Reserved :: 10 reserved bytes. */
|
||||
/* */
|
||||
/* metric_Data_Format :: Always 0. */
|
||||
/* */
|
||||
/* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */
|
||||
/* table -- this value can be smaller than */
|
||||
/* the total number of glyphs in the font. */
|
||||
/* */
|
||||
/* long_metrics :: A pointer into the `hmtx' table. */
|
||||
/* */
|
||||
/* short_metrics :: A pointer into the `hmtx' table. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
|
||||
/* be identical except for the names of their fields which */
|
||||
/* are different. */
|
||||
/* */
|
||||
/* This ensures that a single function in the `ttload' */
|
||||
/* module is able to read both the horizontal and vertical */
|
||||
/* headers. */
|
||||
/* */
|
||||
typedef struct TT_HoriHeader_
|
||||
{
|
||||
FT_Fixed Version;
|
||||
FT_Short Ascender;
|
||||
FT_Short Descender;
|
||||
FT_Short Line_Gap;
|
||||
|
||||
FT_UShort advance_Width_Max; /* advance width maximum */
|
||||
|
||||
FT_Short min_Left_Side_Bearing; /* minimum left-sb */
|
||||
FT_Short min_Right_Side_Bearing; /* minimum right-sb */
|
||||
FT_Short xMax_Extent; /* xmax extents */
|
||||
FT_Short caret_Slope_Rise;
|
||||
FT_Short caret_Slope_Run;
|
||||
FT_Short caret_Offset;
|
||||
|
||||
FT_Short Reserved[4];
|
||||
|
||||
FT_Short metric_Data_Format;
|
||||
FT_UShort number_Of_HMetrics;
|
||||
|
||||
/* The following fields are not defined by the TrueType specification */
|
||||
/* but they're used to connect the metrics header to the relevant */
|
||||
/* `HMTX' table. */
|
||||
|
||||
void* long_metrics;
|
||||
void* short_metrics;
|
||||
|
||||
} TT_HoriHeader;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_VertHeader */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType vertical header, the `vhea' */
|
||||
/* table, as well as the corresponding vertical metrics table, i.e., */
|
||||
/* the `vmtx' table. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* Version :: The table version. */
|
||||
/* */
|
||||
/* Ascender :: The font's ascender, i.e., the distance */
|
||||
/* from the baseline to the top-most of */
|
||||
/* all glyph points found in the font. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of */
|
||||
/* the glyphs found in the font (maybe */
|
||||
/* ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoAscender' */
|
||||
/* field of the OS/2 table instead if you */
|
||||
/* want the correct one. */
|
||||
/* */
|
||||
/* Descender :: The font's descender, i.e., the */
|
||||
/* distance from the baseline to the */
|
||||
/* bottom-most of all glyph points found */
|
||||
/* in the font. It is negative. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of */
|
||||
/* the glyphs found in the font (maybe */
|
||||
/* ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoDescender' */
|
||||
/* field of the OS/2 table instead if you */
|
||||
/* want the correct one. */
|
||||
/* */
|
||||
/* Line_Gap :: The font's line gap, i.e., the distance */
|
||||
/* to add to the ascender and descender to */
|
||||
/* get the BTB, i.e., the */
|
||||
/* baseline-to-baseline distance for the */
|
||||
/* font. */
|
||||
/* */
|
||||
/* advance_Height_Max :: This field is the maximum of all */
|
||||
/* advance heights found in the font. It */
|
||||
/* can be used to compute the maximum */
|
||||
/* height of an arbitrary string of text. */
|
||||
/* */
|
||||
/* min_Top_Side_Bearing :: The minimum top side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* yMax_Extent :: The maximum vertical extent (i.e., the */
|
||||
/* `height' of a glyph's bounding box) for */
|
||||
/* all glyphs in the font. */
|
||||
/* */
|
||||
/* caret_Slope_Rise :: The rise coefficient of the cursor's */
|
||||
/* slope of the cursor (slope=rise/run). */
|
||||
/* */
|
||||
/* caret_Slope_Run :: The run coefficient of the cursor's */
|
||||
/* slope. */
|
||||
/* */
|
||||
/* Reserved :: 10 reserved bytes. */
|
||||
/* */
|
||||
/* metric_Data_Format :: Always 0. */
|
||||
/* */
|
||||
/* number_Of_HMetrics :: Number of VMetrics entries in the */
|
||||
/* `vmtx' table -- this value can be */
|
||||
/* smaller than the total number of glyphs */
|
||||
/* in the font. */
|
||||
/* */
|
||||
/* long_metrics :: A pointer into the `vmtx' table. */
|
||||
/* */
|
||||
/* short_metrics :: A pointer into the `vmtx' table. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */
|
||||
/* be identical except for the names of their fields which */
|
||||
/* are different. */
|
||||
/* */
|
||||
/* This ensures that a single function in the `ttload' */
|
||||
/* module is able to read both the horizontal and vertical */
|
||||
/* headers. */
|
||||
/* */
|
||||
typedef struct TT_VertHeader_
|
||||
{
|
||||
FT_Fixed Version;
|
||||
FT_Short Ascender;
|
||||
FT_Short Descender;
|
||||
FT_Short Line_Gap;
|
||||
|
||||
FT_UShort advance_Height_Max; /* advance height maximum */
|
||||
|
||||
FT_Short min_Top_Side_Bearing; /* minimum left-sb or top-sb */
|
||||
FT_Short min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */
|
||||
FT_Short yMax_Extent; /* xmax or ymax extents */
|
||||
FT_Short caret_Slope_Rise;
|
||||
FT_Short caret_Slope_Run;
|
||||
FT_Short caret_Offset;
|
||||
|
||||
FT_Short Reserved[4];
|
||||
|
||||
FT_Short metric_Data_Format;
|
||||
FT_UShort number_Of_VMetrics;
|
||||
|
||||
/* The following fields are not defined by the TrueType specification */
|
||||
/* but they're used to connect the metrics header to the relevant */
|
||||
/* `HMTX' or `VMTX' table. */
|
||||
|
||||
void* long_metrics;
|
||||
void* short_metrics;
|
||||
|
||||
} TT_VertHeader;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_OS2 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType OS/2 table. This is the long */
|
||||
/* table version. All fields comply to the TrueType specification. */
|
||||
/* */
|
||||
/* Note that we now support old Mac fonts which do not include an */
|
||||
/* OS/2 table. In this case, the `version' field is always set to */
|
||||
/* 0xFFFF. */
|
||||
/* */
|
||||
typedef struct TT_OS2_
|
||||
{
|
||||
FT_UShort version; /* 0x0001 - more or 0xFFFF */
|
||||
FT_Short xAvgCharWidth;
|
||||
FT_UShort usWeightClass;
|
||||
FT_UShort usWidthClass;
|
||||
FT_Short fsType;
|
||||
FT_Short ySubscriptXSize;
|
||||
FT_Short ySubscriptYSize;
|
||||
FT_Short ySubscriptXOffset;
|
||||
FT_Short ySubscriptYOffset;
|
||||
FT_Short ySuperscriptXSize;
|
||||
FT_Short ySuperscriptYSize;
|
||||
FT_Short ySuperscriptXOffset;
|
||||
FT_Short ySuperscriptYOffset;
|
||||
FT_Short yStrikeoutSize;
|
||||
FT_Short yStrikeoutPosition;
|
||||
FT_Short sFamilyClass;
|
||||
|
||||
FT_Byte panose[10];
|
||||
|
||||
FT_ULong ulUnicodeRange1; /* Bits 0-31 */
|
||||
FT_ULong ulUnicodeRange2; /* Bits 32-63 */
|
||||
FT_ULong ulUnicodeRange3; /* Bits 64-95 */
|
||||
FT_ULong ulUnicodeRange4; /* Bits 96-127 */
|
||||
|
||||
FT_Char achVendID[4];
|
||||
|
||||
FT_UShort fsSelection;
|
||||
FT_UShort usFirstCharIndex;
|
||||
FT_UShort usLastCharIndex;
|
||||
FT_Short sTypoAscender;
|
||||
FT_Short sTypoDescender;
|
||||
FT_Short sTypoLineGap;
|
||||
FT_UShort usWinAscent;
|
||||
FT_UShort usWinDescent;
|
||||
|
||||
/* only version 1 tables: */
|
||||
|
||||
FT_ULong ulCodePageRange1; /* Bits 0-31 */
|
||||
FT_ULong ulCodePageRange2; /* Bits 32-63 */
|
||||
|
||||
/* only version 2 tables: */
|
||||
|
||||
FT_Short sxHeight;
|
||||
FT_Short sCapHeight;
|
||||
FT_UShort usDefaultChar;
|
||||
FT_UShort usBreakChar;
|
||||
FT_UShort usMaxContext;
|
||||
|
||||
} TT_OS2;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_Postscript */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType Postscript table. All fields */
|
||||
/* comply to the TrueType table. This structure does not reference */
|
||||
/* the Postscript glyph names, which can be nevertheless accessed */
|
||||
/* with the `ttpost' module. */
|
||||
/* */
|
||||
typedef struct TT_Postscript_
|
||||
{
|
||||
FT_Fixed FormatType;
|
||||
FT_Fixed italicAngle;
|
||||
FT_Short underlinePosition;
|
||||
FT_Short underlineThickness;
|
||||
FT_ULong isFixedPitch;
|
||||
FT_ULong minMemType42;
|
||||
FT_ULong maxMemType42;
|
||||
FT_ULong minMemType1;
|
||||
FT_ULong maxMemType1;
|
||||
|
||||
/* Glyph names follow in the file, but we don't */
|
||||
/* load them by default. See the ttpost.c file. */
|
||||
|
||||
} TT_Postscript;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_PCLT */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType PCLT table. All fields */
|
||||
/* comply to the TrueType table. */
|
||||
/* */
|
||||
typedef struct TT_PCLT_
|
||||
{
|
||||
FT_Fixed Version;
|
||||
FT_ULong FontNumber;
|
||||
FT_UShort Pitch;
|
||||
FT_UShort xHeight;
|
||||
FT_UShort Style;
|
||||
FT_UShort TypeFamily;
|
||||
FT_UShort CapHeight;
|
||||
FT_UShort SymbolSet;
|
||||
FT_Char TypeFace[16];
|
||||
FT_Char CharacterComplement[8];
|
||||
FT_Char FileName[6];
|
||||
FT_Char StrokeWeight;
|
||||
FT_Char WidthType;
|
||||
FT_Byte SerifStyle;
|
||||
FT_Byte Reserved;
|
||||
|
||||
} TT_PCLT;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_MaxProfile */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The maximum profile is a table containing many max values which */
|
||||
/* can be used to pre-allocate arrays. This ensures that no memory */
|
||||
/* allocation occurs during a glyph load. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* version :: The version number. */
|
||||
/* */
|
||||
/* numGlyphs :: The number of glyphs in this TrueType */
|
||||
/* font. */
|
||||
/* */
|
||||
/* maxPoints :: The maximum number of points in a */
|
||||
/* non-composite TrueType glyph. See also */
|
||||
/* the structure element */
|
||||
/* `maxCompositePoints'. */
|
||||
/* */
|
||||
/* maxContours :: The maximum number of contours in a */
|
||||
/* non-composite TrueType glyph. See also */
|
||||
/* the structure element */
|
||||
/* `maxCompositeContours'. */
|
||||
/* */
|
||||
/* maxCompositePoints :: The maximum number of points in a */
|
||||
/* composite TrueType glyph. See also the */
|
||||
/* structure element `maxPoints'. */
|
||||
/* */
|
||||
/* maxCompositeContours :: The maximum number of contours in a */
|
||||
/* composite TrueType glyph. See also the */
|
||||
/* structure element `maxContours'. */
|
||||
/* */
|
||||
/* maxZones :: The maximum number of zones used for */
|
||||
/* glyph hinting. */
|
||||
/* */
|
||||
/* maxTwilightPoints :: The maximum number of points in the */
|
||||
/* twilight zone used for glyph hinting. */
|
||||
/* */
|
||||
/* maxStorage :: The maximum number of elements in the */
|
||||
/* storage area used for glyph hinting. */
|
||||
/* */
|
||||
/* maxFunctionDefs :: The maximum number of function */
|
||||
/* definitions in the TrueType bytecode for */
|
||||
/* this font. */
|
||||
/* */
|
||||
/* maxInstructionDefs :: The maximum number of instruction */
|
||||
/* definitions in the TrueType bytecode for */
|
||||
/* this font. */
|
||||
/* */
|
||||
/* maxStackElements :: The maximum number of stack elements used */
|
||||
/* during bytecode interpretation. */
|
||||
/* */
|
||||
/* maxSizeOfInstructions :: The maximum number of TrueType opcodes */
|
||||
/* used for glyph hinting. */
|
||||
/* */
|
||||
/* maxComponentElements :: An obscure value related to composite */
|
||||
/* glyphs definitions. */
|
||||
/* */
|
||||
/* maxComponentDepth :: An obscure value related to composite */
|
||||
/* glyphs definitions. Probably the maximum */
|
||||
/* number of simple glyphs in a composite. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This structure is only used during font loading. */
|
||||
/* */
|
||||
typedef struct TT_MaxProfile_
|
||||
{
|
||||
FT_Fixed version;
|
||||
FT_UShort numGlyphs;
|
||||
FT_UShort maxPoints;
|
||||
FT_UShort maxContours;
|
||||
FT_UShort maxCompositePoints;
|
||||
FT_UShort maxCompositeContours;
|
||||
FT_UShort maxZones;
|
||||
FT_UShort maxTwilightPoints;
|
||||
FT_UShort maxStorage;
|
||||
FT_UShort maxFunctionDefs;
|
||||
FT_UShort maxInstructionDefs;
|
||||
FT_UShort maxStackElements;
|
||||
FT_UShort maxSizeOfInstructions;
|
||||
FT_UShort maxComponentElements;
|
||||
FT_UShort maxComponentDepth;
|
||||
|
||||
} TT_MaxProfile;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ft_sfnt_head = 0,
|
||||
ft_sfnt_maxp = 1,
|
||||
ft_sfnt_os2 = 2,
|
||||
ft_sfnt_hhea = 3,
|
||||
ft_sfnt_vhea = 4,
|
||||
ft_sfnt_post = 5,
|
||||
ft_sfnt_pclt = 6,
|
||||
|
||||
sfnt_max /* don't remove */
|
||||
|
||||
} FT_Sfnt_Tag;
|
||||
|
||||
|
||||
/* internal use only */
|
||||
typedef void* (*FT_Get_Sfnt_Table_Func)( FT_Face face,
|
||||
FT_Sfnt_Tag tag );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Sfnt_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Returns a pointer to a given SFNT table within a face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source. */
|
||||
/* */
|
||||
/* tag :: The index of the SFNT table. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A type-less pointer to the table. This will be 0 in case of */
|
||||
/* error, or if the corresponding table was not found *OR* loaded */
|
||||
/* from the file. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The table is owned by the face object and disappears with it. */
|
||||
/* */
|
||||
/* This function is only useful to access SFNT tables that are loaded */
|
||||
/* by the sfnt/truetype/opentype drivers. See FT_Sfnt_tag for a */
|
||||
/* list. */
|
||||
/* */
|
||||
/* You can load any table using the (internal) SFNT_Interface */
|
||||
/* structure -- this is available via FT_Get_Module_Interface(). */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void* ) FT_Get_Sfnt_Table( FT_Face face,
|
||||
FT_Sfnt_Tag tag );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* TTTABLES_H */
|
||||
|
||||
|
||||
/* END */
|
||||
66
src/freetype/freetype/tttags.h
Normal file
66
src/freetype/freetype/tttags.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* tttags.h */
|
||||
/* */
|
||||
/* Tags for TrueType tables (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TTAGS_H
|
||||
#define TTAGS_H
|
||||
|
||||
|
||||
#include <freetype/freetype.h> /* for MAKE_TT_TAG() */
|
||||
|
||||
|
||||
#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
|
||||
#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
|
||||
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
|
||||
#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
|
||||
#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
|
||||
#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
|
||||
#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
|
||||
#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
|
||||
#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
|
||||
#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
|
||||
#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
|
||||
#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
|
||||
#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' )
|
||||
#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
|
||||
#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
|
||||
#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
|
||||
#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
|
||||
#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' )
|
||||
#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' )
|
||||
#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
|
||||
#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
|
||||
#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
|
||||
#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
|
||||
#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )
|
||||
#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
|
||||
#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
|
||||
#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
|
||||
#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' )
|
||||
#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' )
|
||||
#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
|
||||
#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' )
|
||||
#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' )
|
||||
#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' )
|
||||
#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
|
||||
#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
|
||||
#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )
|
||||
|
||||
#endif /* TTAGS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
168
src/freetype/ftconfig.h
Normal file
168
src/freetype/ftconfig.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/* ftconfig.h. Generated automatically by configure. */
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftconfig.in */
|
||||
/* */
|
||||
/* UNIX-specific configuration file (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2000 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This header file contains a number of macro definitions that are used */
|
||||
/* by the rest of the engine. Most of the macros here are automatically */
|
||||
/* determined at compile time, and you should not need to change it to */
|
||||
/* port FreeType, except to compile the library with a non-ANSI */
|
||||
/* compiler. */
|
||||
/* */
|
||||
/* Note however that if some specific modifications are needed, we */
|
||||
/* advise you to place a modified copy in your build directory. */
|
||||
/* */
|
||||
/* The build directory is usually `freetype/builds/<system>', and */
|
||||
/* contains system-specific files that are always included first when */
|
||||
/* building the library. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTCONFIG_H
|
||||
#define FTCONFIG_H
|
||||
|
||||
|
||||
/* Include the header file containing all developer build options */
|
||||
#include <freetype/config/ftoption.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* PLATFORM-SPECIFIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros can be toggled to suit a specific system. The current */
|
||||
/* ones are defaults used to compile FreeType in an ANSI C environment */
|
||||
/* (16bit compilers are also supported). Copy this file to your own */
|
||||
/* `freetype/builds/<system>' directory, and edit it to port the engine. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#define FT_SIZEOF_INT SIZEOF_INT
|
||||
#define FT_SIZEOF_LONG SIZEOF_LONG
|
||||
|
||||
|
||||
/* Preferred alignment of data */
|
||||
#define FT_ALIGNMENT 8
|
||||
|
||||
|
||||
/* UNUSED is a macro used to indicate that a given parameter is not used */
|
||||
/* -- this is only used to get rid of unpleasant compiler warnings */
|
||||
#ifndef FT_UNUSED
|
||||
#define FT_UNUSED( arg ) ( (arg) = (arg) )
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* AUTOMATIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros are computed from the ones defined above. Don't touch */
|
||||
/* their definition, unless you know precisely what you are doing. No */
|
||||
/* porter should need to mess with them. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* IntN types */
|
||||
/* */
|
||||
/* Used to guarantee the size of some specific integers. */
|
||||
/* */
|
||||
typedef signed short FT_Int16;
|
||||
typedef unsigned short FT_UInt16;
|
||||
|
||||
#if FT_SIZEOF_INT == 4
|
||||
|
||||
typedef signed int FT_Int32;
|
||||
typedef unsigned int FT_UInt32;
|
||||
|
||||
#elif FT_SIZEOF_LONG == 4
|
||||
|
||||
typedef signed long FT_Int32;
|
||||
typedef unsigned long FT_UInt32;
|
||||
|
||||
#else
|
||||
#error "no 32bit type found -- please check your configuration files"
|
||||
#endif
|
||||
|
||||
#if FT_SIZEOF_LONG == 8
|
||||
|
||||
/* FT_LONG64 must be defined if a 64-bit type is available */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Many compilers provide the non-ANSI `long long' 64-bit type. You can */
|
||||
/* activate it by defining the FTCALC_USE_LONG_LONG macro in */
|
||||
/* `ftoption.h'. */
|
||||
/* */
|
||||
/* Note that this will produce many -ansi warnings during library */
|
||||
/* compilation, and that in many cases, the generated code will be */
|
||||
/* neither smaller nor faster! */
|
||||
/* */
|
||||
#ifdef FTCALC_USE_LONG_LONG
|
||||
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long long
|
||||
|
||||
#endif /* FTCALC_USE_LONG_LONG */
|
||||
#endif /* FT_SIZEOF_LONG == 8 */
|
||||
|
||||
|
||||
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
#define LOCAL_DEF static
|
||||
#define LOCAL_FUNC static
|
||||
#else
|
||||
#define LOCAL_DEF extern
|
||||
#define LOCAL_FUNC /* nothing */
|
||||
#endif
|
||||
|
||||
#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT
|
||||
#define BASE_DEF( x ) static x
|
||||
#define BASE_FUNC( x ) static x
|
||||
#else
|
||||
#define BASE_DEF( x ) extern x
|
||||
#define BASE_FUNC( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_DEF
|
||||
#define FT_EXPORT_DEF( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_FUNC
|
||||
#define FT_EXPORT_FUNC( x ) extern x
|
||||
#endif
|
||||
|
||||
#ifndef FT_EXPORT_VAR
|
||||
#define FT_EXPORT_VAR( x ) extern x
|
||||
#endif
|
||||
|
||||
#endif /* FTCONFIG_H */
|
||||
|
||||
|
||||
/* END */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user