mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
More freetype cleanup
svn path=/trunk/; revision=2240
This commit is contained in:
@@ -1,137 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,63 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,402 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,52 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,93 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,72 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,124 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,127 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,32 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,889 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 ); FIXME */
|
||||
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 */
|
||||
@@ -1,136 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,492 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,45 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,42 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,293 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,78 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,198 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,537 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,70 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,380 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,141 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,353 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,259 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,29 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,99 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,44 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,773 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,124 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 ); FIXME */
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
FT_EXPORT_FUNC( void ) FT_Panic( const char* fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
/* vprintf( fmt, ap ); FIXME */
|
||||
va_end( ap );
|
||||
|
||||
/* exit( EXIT_FAILURE ); FIXME */
|
||||
}
|
||||
|
||||
|
||||
#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 */
|
||||
@@ -1,332 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,52 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftgrays.h */
|
||||
/* */
|
||||
/* FreeType smooth renderer declaration */
|
||||
/* */
|
||||
/* 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 FTGRAYS_H
|
||||
#define FTGRAYS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _STANDALONE_
|
||||
#include "ftimage.h"
|
||||
#else
|
||||
#include <freetype/ftimage.h>
|
||||
#endif
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* To make ftgrays.h independent from configuration files we check */
|
||||
/* whether FT_EXPORT_DEF has been defined already. */
|
||||
/* */
|
||||
/* On some systems and compilers (Win32 mostly), an extra keyword is */
|
||||
/* necessary to compile the library as a DLL. */
|
||||
/* */
|
||||
#ifndef FT_EXPORT_VAR
|
||||
#define FT_EXPORT_VAR( x ) extern x
|
||||
#endif
|
||||
|
||||
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_grays_raster;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FTGRAYS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,155 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,301 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,176 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,70 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,842 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,50 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftraster.h */
|
||||
/* */
|
||||
/* The FreeType glyph rasterizer (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 FTRASTER_H
|
||||
#define FTRASTER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <freetype/ftimage.h>
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Uncomment the following line if you are using ftraster.c as a */
|
||||
/* standalone module, fully independent of FreeType. */
|
||||
/* */
|
||||
/* #define _STANDALONE_ */
|
||||
|
||||
#ifndef FT_EXPORT_VAR
|
||||
#define FT_EXPORT_VAR( x ) extern x
|
||||
#endif
|
||||
|
||||
FT_EXPORT_VAR( FT_Raster_Funcs ) ft_standard_raster;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FTRASTER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,275 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftrend1.c */
|
||||
/* */
|
||||
/* The FreeType glyph rasterizer 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ftrend1.h"
|
||||
#include "ftraster.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <raster1/ftrend1.h>
|
||||
#include <raster1/ftraster.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* initialize renderer -- init its raster */
|
||||
static
|
||||
FT_Error ft_raster1_init( FT_Renderer render )
|
||||
{
|
||||
FT_Library library = FT_MODULE_LIBRARY( render );
|
||||
|
||||
|
||||
render->clazz->raster_class->raster_reset( render->raster,
|
||||
library->raster_pool,
|
||||
library->raster_pool_size );
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/* set render-specific mode */
|
||||
static
|
||||
FT_Error ft_raster1_set_mode( FT_Renderer render,
|
||||
FT_ULong mode_tag,
|
||||
FT_Pointer data )
|
||||
{
|
||||
/* we simply pass it to the raster */
|
||||
return render->clazz->raster_class->raster_set_mode( render->raster,
|
||||
mode_tag,
|
||||
data );
|
||||
}
|
||||
|
||||
|
||||
/* transform a given glyph image */
|
||||
static
|
||||
FT_Error ft_raster1_transform( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
if ( slot->format != render->glyph_format )
|
||||
{
|
||||
error = FT_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ( matrix )
|
||||
FT_Outline_Transform( &slot->outline, matrix );
|
||||
|
||||
if ( delta )
|
||||
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* return the glyph's control box */
|
||||
static
|
||||
void ft_raster1_get_cbox( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox* cbox )
|
||||
{
|
||||
MEM_Set( cbox, 0, sizeof ( *cbox ) );
|
||||
|
||||
if ( slot->format == render->glyph_format )
|
||||
FT_Outline_Get_CBox( &slot->outline, cbox );
|
||||
}
|
||||
|
||||
|
||||
/* convert a slot's glyph image into a bitmap */
|
||||
static
|
||||
FT_Error ft_raster1_render( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_UInt mode,
|
||||
FT_Vector* origin )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Outline* outline;
|
||||
FT_BBox cbox;
|
||||
FT_UInt width, height, pitch;
|
||||
FT_Bitmap* bitmap;
|
||||
FT_Memory memory;
|
||||
|
||||
FT_Raster_Params params;
|
||||
|
||||
|
||||
/* check glyph image format */
|
||||
if ( slot->format != render->glyph_format )
|
||||
{
|
||||
error = FT_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* check rendering mode */
|
||||
if ( mode != ft_render_mode_mono )
|
||||
{
|
||||
/* raster1 is only capable of producing monochrome bitmaps */
|
||||
if ( render->clazz == &ft_raster1_renderer_class )
|
||||
return FT_Err_Cannot_Render_Glyph;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* raster5 is only capable of producing 5-gray-levels bitmaps */
|
||||
if ( render->clazz == &ft_raster5_renderer_class )
|
||||
return FT_Err_Cannot_Render_Glyph;
|
||||
}
|
||||
|
||||
outline = &slot->outline;
|
||||
|
||||
/* translate the outline to the new origin if needed */
|
||||
if ( origin )
|
||||
FT_Outline_Translate( outline, origin->x, origin->y );
|
||||
|
||||
/* compute the control box, and grid fit it */
|
||||
FT_Outline_Get_CBox( outline, &cbox );
|
||||
|
||||
cbox.xMin &= -64;
|
||||
cbox.yMin &= -64;
|
||||
cbox.xMax = ( cbox.xMax + 63 ) & -64;
|
||||
cbox.yMax = ( cbox.yMax + 63 ) & -64;
|
||||
|
||||
width = ( cbox.xMax - cbox.xMin ) >> 6;
|
||||
height = ( cbox.yMax - cbox.yMin ) >> 6;
|
||||
bitmap = &slot->bitmap;
|
||||
memory = render->root.memory;
|
||||
|
||||
/* release old bitmap buffer */
|
||||
if ( slot->flags & ft_glyph_own_bitmap )
|
||||
{
|
||||
FREE( bitmap->buffer );
|
||||
slot->flags &= ~ft_glyph_own_bitmap;
|
||||
}
|
||||
|
||||
/* allocate new one, depends on pixel format */
|
||||
if ( !( mode & ft_render_mode_mono ) )
|
||||
{
|
||||
/* we pad to 32 bits, only for backwards compatibility with FT 1.x */
|
||||
pitch = ( width + 3 ) & -4;
|
||||
bitmap->pixel_mode = ft_pixel_mode_grays;
|
||||
bitmap->num_grays = 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
pitch = ( width + 7 ) >> 3;
|
||||
bitmap->pixel_mode = ft_pixel_mode_mono;
|
||||
}
|
||||
|
||||
bitmap->width = width;
|
||||
bitmap->rows = height;
|
||||
bitmap->pitch = pitch;
|
||||
|
||||
if ( ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
|
||||
goto Exit;
|
||||
|
||||
slot->flags |= ft_glyph_own_bitmap;
|
||||
|
||||
/* translate outline to render it into the bitmap */
|
||||
FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin );
|
||||
|
||||
/* set up parameters */
|
||||
params.target = bitmap;
|
||||
params.source = outline;
|
||||
params.flags = 0;
|
||||
|
||||
if ( bitmap->pixel_mode == ft_pixel_mode_grays )
|
||||
params.flags |= ft_raster_flag_aa;
|
||||
|
||||
/* render outline into the bitmap */
|
||||
error = render->raster_render( render->raster, ¶ms );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
slot->format = ft_glyph_format_bitmap;
|
||||
slot->bitmap_left = cbox.xMin >> 6;
|
||||
slot->bitmap_top = cbox.yMax >> 6;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
const FT_Renderer_Class ft_raster1_renderer_class =
|
||||
{
|
||||
{
|
||||
ft_module_renderer,
|
||||
sizeof( FT_RendererRec ),
|
||||
|
||||
"raster1",
|
||||
0x10000L,
|
||||
0x20000L,
|
||||
|
||||
0, /* module specific interface */
|
||||
|
||||
(FT_Module_Constructor)ft_raster1_init,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) 0
|
||||
},
|
||||
|
||||
ft_glyph_format_outline,
|
||||
|
||||
(FTRenderer_render) ft_raster1_render,
|
||||
(FTRenderer_transform)ft_raster1_transform,
|
||||
(FTRenderer_getCBox) ft_raster1_get_cbox,
|
||||
(FTRenderer_setMode) ft_raster1_set_mode,
|
||||
|
||||
(FT_Raster_Funcs*) &ft_standard_raster
|
||||
};
|
||||
|
||||
|
||||
/* this renderer is _NOT_ part of the default modules, you'll need */
|
||||
/* to register it by hand in your application. It should only be */
|
||||
/* used for backwards-compatibility with FT 1.x anyway. */
|
||||
const FT_Renderer_Class ft_raster5_renderer_class =
|
||||
{
|
||||
{
|
||||
ft_module_renderer,
|
||||
sizeof( FT_RendererRec ),
|
||||
|
||||
"raster5",
|
||||
0x10000L,
|
||||
0x20000L,
|
||||
|
||||
0, /* module specific interface */
|
||||
|
||||
(FT_Module_Constructor)ft_raster1_init,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) 0
|
||||
},
|
||||
|
||||
ft_glyph_format_outline,
|
||||
|
||||
(FTRenderer_render) ft_raster1_render,
|
||||
(FTRenderer_transform)ft_raster1_transform,
|
||||
(FTRenderer_getCBox) ft_raster1_get_cbox,
|
||||
(FTRenderer_setMode) ft_raster1_set_mode,
|
||||
|
||||
(FT_Raster_Funcs*) &ft_standard_raster
|
||||
};
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,37 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftrend1.h */
|
||||
/* */
|
||||
/* The FreeType glyph rasterizer 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 FTREND1_H
|
||||
#define FTREND1_H
|
||||
|
||||
#include <freetype/ftrender.h>
|
||||
|
||||
|
||||
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster1_renderer_class;
|
||||
|
||||
/* this renderer is _NOT_ part of the default modules, you'll need */
|
||||
/* to register it by hand in your application. It should only be */
|
||||
/* used for backwards-compatibility with FT 1.x anyway. */
|
||||
/* */
|
||||
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster5_renderer_class;
|
||||
|
||||
|
||||
#endif /* FTREND1_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,223 +0,0 @@
|
||||
// ReactOS adjustments:
|
||||
// * pitch rounded up to DWORD
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsmooth.c */
|
||||
/* */
|
||||
/* Anti-aliasing renderer interface (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/ftobjs.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ftsmooth.h"
|
||||
#include "ftgrays.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <smooth/ftsmooth.h>
|
||||
#include <smooth/ftgrays.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* initialize renderer -- init its raster */
|
||||
static
|
||||
FT_Error ft_smooth_init( FT_Renderer render )
|
||||
{
|
||||
FT_Library library = FT_MODULE_LIBRARY( render );
|
||||
|
||||
|
||||
render->clazz->raster_class->raster_reset( render->raster,
|
||||
library->raster_pool,
|
||||
library->raster_pool_size );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* sets render-specific mode */
|
||||
static
|
||||
FT_Error ft_smooth_set_mode( FT_Renderer render,
|
||||
FT_ULong mode_tag,
|
||||
FT_Pointer data )
|
||||
{
|
||||
/* we simply pass it to the raster */
|
||||
return render->clazz->raster_class->raster_set_mode( render->raster,
|
||||
mode_tag,
|
||||
data );
|
||||
}
|
||||
|
||||
/* transform a given glyph image */
|
||||
static
|
||||
FT_Error ft_smooth_transform( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
if ( slot->format != render->glyph_format )
|
||||
{
|
||||
error = FT_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ( matrix )
|
||||
FT_Outline_Transform( &slot->outline, matrix );
|
||||
|
||||
if ( delta )
|
||||
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* return the glyph's control box */
|
||||
static
|
||||
void ft_smooth_get_cbox( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox* cbox )
|
||||
{
|
||||
MEM_Set( cbox, 0, sizeof ( *cbox ) );
|
||||
|
||||
if ( slot->format == render->glyph_format )
|
||||
FT_Outline_Get_CBox( &slot->outline, cbox );
|
||||
}
|
||||
|
||||
|
||||
/* convert a slot's glyph image into a bitmap */
|
||||
static
|
||||
FT_Error ft_smooth_render( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_UInt mode,
|
||||
FT_Vector* origin )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Outline* outline;
|
||||
FT_BBox cbox;
|
||||
FT_UInt width, height, pitch;
|
||||
FT_Bitmap* bitmap;
|
||||
FT_Memory memory;
|
||||
|
||||
FT_Raster_Params params;
|
||||
|
||||
|
||||
/* check glyph image format */
|
||||
if ( slot->format != render->glyph_format )
|
||||
{
|
||||
error = FT_Err_Invalid_Argument;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
/* check mode */
|
||||
if ( mode != ft_render_mode_normal )
|
||||
return FT_Err_Cannot_Render_Glyph;
|
||||
|
||||
outline = &slot->outline;
|
||||
|
||||
/* translate the outline to the new origin if needed */
|
||||
if ( origin )
|
||||
FT_Outline_Translate( outline, origin->x, origin->y );
|
||||
|
||||
/* compute the control box, and grid fit it */
|
||||
FT_Outline_Get_CBox( outline, &cbox );
|
||||
|
||||
cbox.xMin &= -64;
|
||||
cbox.yMin &= -64;
|
||||
cbox.xMax = ( cbox.xMax + 63 ) & -64;
|
||||
cbox.yMax = ( cbox.yMax + 63 ) & -64;
|
||||
|
||||
width = ( cbox.xMax - cbox.xMin ) >> 6;
|
||||
height = ( cbox.yMax - cbox.yMin ) >> 6;
|
||||
bitmap = &slot->bitmap;
|
||||
memory = render->root.memory;
|
||||
|
||||
/* release old bitmap buffer */
|
||||
if ( slot->flags & ft_glyph_own_bitmap )
|
||||
{
|
||||
FREE( bitmap->buffer );
|
||||
slot->flags &= ~ft_glyph_own_bitmap;
|
||||
}
|
||||
|
||||
/* allocate new one, depends on pixel format */
|
||||
pitch = ((width) + 3) & ~3; // round up to DWORD (adjusted for use by ReactOS' win32k)
|
||||
bitmap->pixel_mode = ft_pixel_mode_grays;
|
||||
bitmap->num_grays = 256;
|
||||
bitmap->width = width;
|
||||
bitmap->rows = height;
|
||||
bitmap->pitch = pitch;
|
||||
|
||||
if ( ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
|
||||
goto Exit;
|
||||
|
||||
slot->flags |= ft_glyph_own_bitmap;
|
||||
|
||||
/* translate outline to render it into the bitmap */
|
||||
FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin );
|
||||
|
||||
/* set up parameters */
|
||||
params.target = bitmap;
|
||||
params.source = outline;
|
||||
params.flags = ft_raster_flag_aa;
|
||||
|
||||
/* render outline into the bitmap */
|
||||
error = render->raster_render( render->raster, ¶ms );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
slot->format = ft_glyph_format_bitmap;
|
||||
slot->bitmap_left = cbox.xMin >> 6;
|
||||
slot->bitmap_top = cbox.yMax >> 6;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
const FT_Renderer_Class ft_smooth_renderer_class =
|
||||
{
|
||||
{
|
||||
ft_module_renderer,
|
||||
sizeof( FT_RendererRec ),
|
||||
|
||||
"smooth",
|
||||
0x10000L,
|
||||
0x20000L,
|
||||
|
||||
0, /* module specific interface */
|
||||
|
||||
(FT_Module_Constructor)ft_smooth_init,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) 0
|
||||
},
|
||||
|
||||
ft_glyph_format_outline,
|
||||
|
||||
(FTRenderer_render) ft_smooth_render,
|
||||
(FTRenderer_transform)ft_smooth_transform,
|
||||
(FTRenderer_getCBox) ft_smooth_get_cbox,
|
||||
(FTRenderer_setMode) ft_smooth_set_mode,
|
||||
|
||||
(FT_Raster_Funcs*) &ft_grays_raster
|
||||
};
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,35 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsmooth.h */
|
||||
/* */
|
||||
/* Anti-aliasing renderer 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 FTSMOOTH_H
|
||||
#define FTSMOOTH_H
|
||||
|
||||
#include <freetype/ftrender.h>
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_NO_STD_RASTER
|
||||
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_std_renderer_class;
|
||||
#endif
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_NO_SMOOTH_RASTER
|
||||
FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_renderer_class;
|
||||
#endif
|
||||
|
||||
#endif /* FTSMOOTH_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,818 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,313 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 <ddk/ntddk.h>
|
||||
|
||||
#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 )
|
||||
{
|
||||
PVOID newmem;
|
||||
FT_UNUSED( memory );
|
||||
|
||||
/* return malloc( size ); */
|
||||
|
||||
return ExAllocatePool(NonPagedPool, 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 ); */
|
||||
ExFreePool(block);
|
||||
return ExAllocatePool(NonPagedPool, 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 ); */
|
||||
ExFreePool(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 )
|
||||
{
|
||||
DbgPrint("ftsystem.c: UNIMPLEMENTED CALL\n");
|
||||
/* fclose( STREAM_FILE( stream ) ); FIXME */
|
||||
|
||||
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 );
|
||||
|
||||
DbgPrint("ftsystem.c: UNIMPLEMENTED CALL\n");
|
||||
/* fseek( file, offset, SEEK_SET ); FIXME */
|
||||
|
||||
/* return (unsigned long)fread( buffer, 1, count, file ); FIXME */
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <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; FIXME */
|
||||
|
||||
|
||||
DbgPrint("ftsystem.c: UNIMPLEMENTED CALL\n");
|
||||
|
||||
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; FIXME */
|
||||
|
||||
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 ) ); FIXME */
|
||||
|
||||
memory = ExAllocatePool(NonPagedPool, sizeof(*memory));
|
||||
|
||||
if ( memory )
|
||||
{
|
||||
memory->user = 0;
|
||||
memory->alloc = ft_alloc;
|
||||
memory->realloc = ft_realloc;
|
||||
memory->free = ft_free;
|
||||
}
|
||||
|
||||
return memory;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,322 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* psmodule.c */
|
||||
/* */
|
||||
/* PSNames module 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/internal/psnames.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "psmodule.h"
|
||||
#include "pstables.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <psnames/psmodule.h>
|
||||
#include <psnames/pstables.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h> /* for qsort() */
|
||||
#include <string.h> /* for strcmp(), strncpy() */
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
|
||||
|
||||
|
||||
/* return the Unicode value corresponding to a given glyph. Note that */
|
||||
/* we do deal with glyph variants by detecting a non-initial dot in */
|
||||
/* the name, as in `A.swash' or `e.final', etc. */
|
||||
/* */
|
||||
static
|
||||
FT_ULong PS_Unicode_Value( const char* glyph_name )
|
||||
{
|
||||
FT_Int n;
|
||||
char first = glyph_name[0];
|
||||
char temp[64];
|
||||
|
||||
|
||||
/* if the name begins with `uni', then the glyph name may be a */
|
||||
/* hard-coded unicode character code. */
|
||||
if ( glyph_name[0] == 'u' &&
|
||||
glyph_name[1] == 'n' &&
|
||||
glyph_name[2] == 'i' )
|
||||
{
|
||||
/* determine whether the next four characters following are */
|
||||
/* hexadecimal. */
|
||||
|
||||
/* XXX: Add code to deal with ligatures, i.e. glyph names like */
|
||||
/* `uniXXXXYYYYZZZZ'... */
|
||||
|
||||
FT_Int count;
|
||||
FT_ULong value = 0;
|
||||
const char* p = glyph_name + 4;
|
||||
|
||||
|
||||
for ( count = 4; count > 0; count--, p++ )
|
||||
{
|
||||
char c = *p;
|
||||
unsigned char d;
|
||||
|
||||
|
||||
d = (unsigned char)c - '0';
|
||||
if ( d >= 10 )
|
||||
{
|
||||
d = (unsigned char)c - 'A';
|
||||
if ( d >= 6 )
|
||||
d = 16;
|
||||
else
|
||||
d += 10;
|
||||
}
|
||||
|
||||
/* exit if a non-uppercase hexadecimal character was found */
|
||||
if ( d >= 16 )
|
||||
break;
|
||||
|
||||
value = ( value << 4 ) + d;
|
||||
|
||||
if ( count == 0 )
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/* look for a non-initial dot in the glyph name in order to */
|
||||
/* sort-out variants like `A.swash', `e.final', etc. */
|
||||
{
|
||||
const char* p;
|
||||
int len;
|
||||
|
||||
|
||||
p = glyph_name;
|
||||
|
||||
while ( *p && *p != '.' )
|
||||
p++;
|
||||
|
||||
len = p - glyph_name;
|
||||
|
||||
if ( *p && len < 64 )
|
||||
{
|
||||
strncpy( temp, glyph_name, len );
|
||||
temp[len] = 0;
|
||||
glyph_name = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/* now, look up the glyph in the Adobe Glyph List */
|
||||
for ( n = 0; n < NUM_ADOBE_GLYPHS; n++ )
|
||||
{
|
||||
const char* name = t1_standard_glyphs[n];
|
||||
|
||||
|
||||
if ( first == name[0] && strcmp( glyph_name, name ) == 0 )
|
||||
return names_to_unicode[n];
|
||||
}
|
||||
|
||||
/* not found, there is probably no Unicode value for this glyph name */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* qsort callback to sort the unicode map */
|
||||
static
|
||||
int compare_uni_maps( const void* a,
|
||||
const void* b )
|
||||
{
|
||||
PS_UniMap* map1 = (PS_UniMap*)a;
|
||||
PS_UniMap* map2 = (PS_UniMap*)b;
|
||||
|
||||
|
||||
return ( map1->unicode - map2->unicode );
|
||||
}
|
||||
|
||||
|
||||
/* Builds a table that maps Unicode values to glyph indices */
|
||||
static
|
||||
FT_Error PS_Build_Unicode_Table( FT_Memory memory,
|
||||
FT_UInt num_glyphs,
|
||||
const char** glyph_names,
|
||||
PS_Unicodes* table )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
/* we first allocate the table */
|
||||
table->num_maps = 0;
|
||||
table->maps = 0;
|
||||
|
||||
if ( !ALLOC_ARRAY( table->maps, num_glyphs, PS_UniMap ) )
|
||||
{
|
||||
FT_UInt n;
|
||||
FT_UInt count;
|
||||
PS_UniMap* map;
|
||||
FT_ULong uni_char;
|
||||
|
||||
|
||||
map = table->maps;
|
||||
|
||||
for ( n = 0; n < num_glyphs; n++ )
|
||||
{
|
||||
const char* gname = glyph_names[n];
|
||||
|
||||
|
||||
if ( gname )
|
||||
{
|
||||
uni_char = PS_Unicode_Value( gname );
|
||||
|
||||
if ( uni_char && uni_char != 0xFFFF )
|
||||
{
|
||||
map->unicode = uni_char;
|
||||
map->glyph_index = n;
|
||||
map++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* now, compress the table a bit */
|
||||
count = map - table->maps;
|
||||
|
||||
if ( count > 0 && REALLOC( table->maps,
|
||||
num_glyphs * sizeof ( PS_UniMap ),
|
||||
count * sizeof ( PS_UniMap ) ) )
|
||||
count = 0;
|
||||
|
||||
if ( count == 0 )
|
||||
{
|
||||
FREE( table->maps );
|
||||
if ( !error )
|
||||
error = FT_Err_Invalid_Argument; /* no unicode chars here! */
|
||||
}
|
||||
else
|
||||
/* sort the table in increasing order of unicode values */
|
||||
qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps );
|
||||
|
||||
table->num_maps = count;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_UInt PS_Lookup_Unicode( PS_Unicodes* table,
|
||||
FT_ULong unicode )
|
||||
{
|
||||
PS_UniMap *min, *max, *mid;
|
||||
|
||||
|
||||
/* perform a binary search on the table */
|
||||
|
||||
min = table->maps;
|
||||
max = min + table->num_maps - 1;
|
||||
|
||||
while ( min <= max )
|
||||
{
|
||||
mid = min + ( max - min ) / 2;
|
||||
if ( mid->unicode == unicode )
|
||||
return mid->glyph_index;
|
||||
|
||||
if ( min == max )
|
||||
break;
|
||||
|
||||
if ( mid->unicode < unicode )
|
||||
min = mid + 1;
|
||||
else
|
||||
max = mid - 1;
|
||||
}
|
||||
|
||||
return 0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
|
||||
|
||||
|
||||
static
|
||||
const char* PS_Macintosh_Name( FT_UInt name_index )
|
||||
{
|
||||
if ( name_index >= 258 )
|
||||
name_index = 0;
|
||||
|
||||
return standard_glyph_names[mac_standard_names[name_index]];
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
const char* PS_Standard_Strings( FT_UInt sid )
|
||||
{
|
||||
return ( sid < NUM_STD_GLYPHS ? t1_standard_glyphs[sid] : 0 );
|
||||
}
|
||||
|
||||
|
||||
static const PSNames_Interface psnames_interface =
|
||||
{
|
||||
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
|
||||
|
||||
(PS_Unicode_Value_Func) PS_Unicode_Value,
|
||||
(PS_Build_Unicodes_Func) PS_Build_Unicode_Table,
|
||||
(PS_Lookup_Unicode_Func) PS_Lookup_Unicode,
|
||||
|
||||
#else
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
|
||||
|
||||
(PS_Macintosh_Name_Func) PS_Macintosh_Name,
|
||||
(PS_Adobe_Std_Strings_Func)PS_Standard_Strings,
|
||||
|
||||
t1_standard_encoding,
|
||||
t1_expert_encoding
|
||||
};
|
||||
|
||||
|
||||
#endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */
|
||||
|
||||
|
||||
const FT_Module_Class psnames_module_class =
|
||||
{
|
||||
0, /* this is not a font driver, nor a renderer */
|
||||
sizeof( FT_ModuleRec ),
|
||||
|
||||
"psnames", /* driver name */
|
||||
0x10000L, /* driver version */
|
||||
0x20000L, /* driver requires FreeType 2 or above */
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
|
||||
0,
|
||||
#else
|
||||
(void*)&psnames_interface, /* module specific interface */
|
||||
#endif
|
||||
|
||||
(FT_Module_Constructor)0,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) 0
|
||||
};
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,29 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* psmodule.h */
|
||||
/* */
|
||||
/* High-level PSNames module 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 PSDRIVER_H
|
||||
#define PSDRIVER_H
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class;
|
||||
|
||||
#endif /* PSDRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,24 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* psnames.c */
|
||||
/* */
|
||||
/* FreeType PSNames module 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
|
||||
|
||||
#include "psmodule.c"
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* raster1.c */
|
||||
/* */
|
||||
/* FreeType monochrome rasterer module 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 "ftraster.c"
|
||||
#include "ftrend1.c"
|
||||
|
||||
#else
|
||||
|
||||
#include <raster1/ftraster.c>
|
||||
#include <raster1/ftrend1.c>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,225 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* sfdriver.c */
|
||||
/* */
|
||||
/* High-level SFNT 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "sfdriver.h"
|
||||
#include "ttload.h"
|
||||
#include "ttsbit.h"
|
||||
#include "ttpost.h"
|
||||
#include "ttcmap.h"
|
||||
#include "sfobjs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <sfnt/sfdriver.h>
|
||||
#include <sfnt/ttload.h>
|
||||
#include <sfnt/ttsbit.h>
|
||||
#include <sfnt/ttpost.h>
|
||||
#include <sfnt/ttcmap.h>
|
||||
#include <sfnt/sfobjs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <string.h> /* for strcmp() */
|
||||
|
||||
|
||||
static
|
||||
void* get_sfnt_table( TT_Face face,
|
||||
FT_Sfnt_Tag tag )
|
||||
{
|
||||
void* table;
|
||||
|
||||
|
||||
switch ( tag )
|
||||
{
|
||||
case ft_sfnt_head:
|
||||
table = &face->header;
|
||||
break;
|
||||
|
||||
case ft_sfnt_hhea:
|
||||
table = &face->horizontal;
|
||||
break;
|
||||
|
||||
case ft_sfnt_vhea:
|
||||
table = face->vertical_info ? &face->vertical : 0;
|
||||
break;
|
||||
|
||||
case ft_sfnt_os2:
|
||||
table = face->os2.version == 0xFFFF ? 0 : &face->os2;
|
||||
break;
|
||||
|
||||
case ft_sfnt_post:
|
||||
table = &face->postscript;
|
||||
break;
|
||||
|
||||
case ft_sfnt_maxp:
|
||||
table = &face->max_profile;
|
||||
break;
|
||||
|
||||
case ft_sfnt_pclt:
|
||||
table = face->pclt.Version ? &face->pclt : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
table = 0;
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
|
||||
|
||||
static
|
||||
FT_Error get_sfnt_glyph_name( TT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_Pointer buffer,
|
||||
FT_UInt buffer_max )
|
||||
{
|
||||
FT_String* gname;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = TT_Get_PS_Name( face, glyph_index, &gname );
|
||||
if ( !error && buffer_max > 0 )
|
||||
{
|
||||
FT_UInt len = strlen( gname );
|
||||
|
||||
|
||||
if ( len >= buffer_max )
|
||||
len = buffer_max - 1;
|
||||
|
||||
MEM_Copy( buffer, gname, len );
|
||||
((FT_Byte*)buffer)[len] = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
||||
|
||||
|
||||
static
|
||||
FT_Module_Interface SFNT_Get_Interface( FT_Module module,
|
||||
const char* interface )
|
||||
{
|
||||
FT_UNUSED( module );
|
||||
|
||||
if ( strcmp( interface, "get_sfnt" ) == 0 )
|
||||
return (FT_Module_Interface)get_sfnt_table;
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
if ( strcmp( interface, "glyph_name" ) == 0 )
|
||||
return (FT_Module_Interface)get_sfnt_glyph_name;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
const SFNT_Interface sfnt_interface =
|
||||
{
|
||||
TT_Goto_Table,
|
||||
|
||||
SFNT_Init_Face,
|
||||
SFNT_Load_Face,
|
||||
SFNT_Done_Face,
|
||||
SFNT_Get_Interface,
|
||||
|
||||
TT_Load_Any,
|
||||
TT_Load_SFNT_Header,
|
||||
TT_Load_Directory,
|
||||
|
||||
TT_Load_Header,
|
||||
TT_Load_Metrics_Header,
|
||||
TT_Load_CMap,
|
||||
TT_Load_MaxProfile,
|
||||
TT_Load_OS2,
|
||||
TT_Load_PostScript,
|
||||
|
||||
TT_Load_Names,
|
||||
TT_Free_Names,
|
||||
|
||||
TT_Load_Hdmx,
|
||||
TT_Free_Hdmx,
|
||||
|
||||
TT_Load_Kern,
|
||||
TT_Load_Gasp,
|
||||
TT_Load_PCLT,
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
|
||||
/* see `ttsbit.h' */
|
||||
TT_Load_SBit_Strikes,
|
||||
TT_Load_SBit_Image,
|
||||
TT_Free_SBit_Strikes,
|
||||
|
||||
#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
|
||||
/* see `ttpost.h' */
|
||||
TT_Get_PS_Name,
|
||||
TT_Free_Post_Names,
|
||||
|
||||
#else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
||||
|
||||
0,
|
||||
0,
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
||||
|
||||
/* see `ttcmap.h' */
|
||||
TT_CharMap_Load,
|
||||
TT_CharMap_Free,
|
||||
};
|
||||
|
||||
|
||||
const
|
||||
FT_Module_Class sfnt_module_class =
|
||||
{
|
||||
0, /* not a font driver or renderer */
|
||||
sizeof( FT_ModuleRec ),
|
||||
|
||||
"sfnt", /* driver name */
|
||||
0x10000L, /* driver version 1.0 */
|
||||
0x20000L, /* driver requires FreeType 2.0 or higher */
|
||||
|
||||
(const void*)&sfnt_interface, /* module specific interface */
|
||||
|
||||
(FT_Module_Constructor)0,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) SFNT_Get_Interface
|
||||
};
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,29 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* sfdriver.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 SFDRIVER_H
|
||||
#define SFDRIVER_H
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Module_Class ) sfnt_module_class;
|
||||
|
||||
#endif /* SFDRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,59 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* sfnt.c */
|
||||
/* */
|
||||
/* Single object library component. */
|
||||
/* */
|
||||
/* 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 "ttload.c"
|
||||
#include "ttcmap.c"
|
||||
#include "sfobjs.c"
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
#include "ttsbit.c"
|
||||
#endif
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
#include "ttpost.c"
|
||||
#endif
|
||||
|
||||
#include "sfdriver.c"
|
||||
|
||||
#else /* FT_FLAT_COMPILE */
|
||||
|
||||
#include <sfnt/ttload.c>
|
||||
#include <sfnt/ttcmap.c>
|
||||
#include <sfnt/sfobjs.c>
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
#include <sfnt/ttsbit.c>
|
||||
#endif
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
#include <sfnt/ttpost.c>
|
||||
#endif
|
||||
|
||||
#include <sfnt/sfdriver.c>
|
||||
|
||||
#endif /* FT_FLAT_COMPILE */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,561 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* sfobjs.c */
|
||||
/* */
|
||||
/* SFNT object management (base). */
|
||||
/* */
|
||||
/* 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 "sfobjs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <sfnt/sfobjs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
#include <freetype/ttnameid.h>
|
||||
#include <freetype/internal/tterrors.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_sfobjs
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Get_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Returns a given ENGLISH name record in ASCII. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* nameid :: The name id of the name record to return. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Character string. NULL if no name is present. */
|
||||
/* */
|
||||
static
|
||||
FT_String* Get_Name( TT_Face face,
|
||||
FT_UShort nameid )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_UShort n;
|
||||
TT_NameRec* rec;
|
||||
FT_Bool wide_chars = 1;
|
||||
|
||||
|
||||
rec = face->name_table.names;
|
||||
for ( n = 0; n < face->name_table.numNameRecords; n++, rec++ )
|
||||
{
|
||||
if ( rec->nameID == nameid )
|
||||
{
|
||||
/* found the name -- now create an ASCII string from it */
|
||||
FT_Bool found = 0;
|
||||
|
||||
|
||||
/* test for Microsoft English language */
|
||||
if ( rec->platformID == TT_PLATFORM_MICROSOFT &&
|
||||
rec->encodingID <= TT_MS_ID_UNICODE_CS &&
|
||||
( rec->languageID & 0x3FF ) == 0x009 )
|
||||
found = 1;
|
||||
|
||||
/* test for Apple Unicode encoding */
|
||||
else if ( rec->platformID == TT_PLATFORM_APPLE_UNICODE )
|
||||
found = 1;
|
||||
|
||||
/* test for Apple Roman */
|
||||
else if ( rec->platformID == TT_PLATFORM_MACINTOSH &&
|
||||
rec->languageID == TT_MAC_ID_ROMAN )
|
||||
{
|
||||
found = 1;
|
||||
wide_chars = 0;
|
||||
}
|
||||
|
||||
/* found a Unicode name */
|
||||
if ( found )
|
||||
{
|
||||
FT_String* string;
|
||||
FT_UInt len;
|
||||
|
||||
|
||||
if ( wide_chars )
|
||||
{
|
||||
FT_UInt m;
|
||||
|
||||
|
||||
len = (FT_UInt)rec->stringLength / 2;
|
||||
if ( MEM_Alloc( string, len + 1 ) )
|
||||
return NULL;
|
||||
|
||||
for ( m = 0; m < len; m ++ )
|
||||
string[m] = rec->string[2 * m + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
len = rec->stringLength;
|
||||
if ( MEM_Alloc( string, len + 1 ) )
|
||||
return NULL;
|
||||
|
||||
MEM_Copy( string, rec->string, len );
|
||||
}
|
||||
|
||||
string[len] = '\0';
|
||||
return string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error SFNT_Init_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Library library = face->root.driver->root.library;
|
||||
SFNT_Interface* sfnt;
|
||||
SFNT_Header sfnt_header;
|
||||
|
||||
/* for now, parameters are unused */
|
||||
FT_UNUSED( num_params );
|
||||
FT_UNUSED( params );
|
||||
|
||||
sfnt = (SFNT_Interface*)face->sfnt;
|
||||
if ( !sfnt )
|
||||
{
|
||||
sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
|
||||
if ( !sfnt )
|
||||
{
|
||||
error = FT_Err_Invalid_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
face->sfnt = sfnt;
|
||||
face->goto_table = sfnt->goto_table;
|
||||
}
|
||||
|
||||
if ( !face->psnames )
|
||||
{
|
||||
face->psnames = (PSNames_Interface*)
|
||||
FT_Get_Module_Interface( library, "psnames" );
|
||||
}
|
||||
|
||||
/* check that we have a valid TrueType file */
|
||||
error = sfnt->load_sfnt_header( face, stream, face_index, &sfnt_header );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
face->format_tag = sfnt_header.format_tag;
|
||||
face->num_tables = sfnt_header.num_tables;
|
||||
|
||||
/* Load font directory */
|
||||
error = sfnt->load_directory( face, stream, &sfnt_header );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
face->root.num_faces = face->ttc_header.count;
|
||||
if ( face->root.num_faces < 1 )
|
||||
face->root.num_faces = 1;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#undef LOAD_
|
||||
#define LOAD_( x ) ( ( error = sfnt->load_##x( face, stream ) ) \
|
||||
!= TT_Err_Ok )
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Error SFNT_Load_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
||||
|
||||
FT_UNUSED( face_index );
|
||||
FT_UNUSED( num_params );
|
||||
FT_UNUSED( params );
|
||||
|
||||
|
||||
/* Load tables */
|
||||
if ( LOAD_( header ) ||
|
||||
LOAD_( max_profile ) ||
|
||||
|
||||
/* load the `hhea' & `hmtx' tables at once */
|
||||
( error = sfnt->load_metrics( face, stream, 0 ) ) != TT_Err_Ok ||
|
||||
|
||||
/* try to load the `vhea' & `vmtx' at once if present */
|
||||
( error = sfnt->load_metrics( face, stream, 1 ) ) != TT_Err_Ok ||
|
||||
|
||||
LOAD_( charmaps ) ||
|
||||
LOAD_( names ) ||
|
||||
LOAD_( os2 ) ||
|
||||
LOAD_( psnames ) )
|
||||
goto Exit;
|
||||
|
||||
/* the optional tables */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
/* embedded bitmap support. */
|
||||
if ( sfnt->load_sbits && LOAD_( sbits ) )
|
||||
goto Exit;
|
||||
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
||||
|
||||
if ( LOAD_( hdmx ) ||
|
||||
LOAD_( gasp ) ||
|
||||
LOAD_( kerning ) ||
|
||||
LOAD_( pclt ) )
|
||||
goto Exit;
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
if ( ( error = TT_Extension_Create( face ) ) != TT_Err_Ok )
|
||||
goto Exit;
|
||||
#endif
|
||||
|
||||
face->root.family_name = Get_Name( face, TT_NAME_ID_FONT_FAMILY );
|
||||
face->root.style_name = Get_Name( face, TT_NAME_ID_FONT_SUBFAMILY );
|
||||
|
||||
/* now set up root fields */
|
||||
{
|
||||
FT_Face root = &face->root;
|
||||
FT_Int flags;
|
||||
TT_CharMap charmap;
|
||||
FT_Int n;
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
memory = root->memory;
|
||||
|
||||
/*********************************************************************/
|
||||
/* */
|
||||
/* Compute face flags. */
|
||||
/* */
|
||||
flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
|
||||
FT_FACE_FLAG_SFNT | /* SFNT file format */
|
||||
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
/* might need more polish to detect the presence of a Postscript */
|
||||
/* name table in the font */
|
||||
flags |= FT_FACE_FLAG_GLYPH_NAMES;
|
||||
#endif
|
||||
|
||||
/* fixed width font? */
|
||||
if ( face->postscript.isFixedPitch )
|
||||
flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
||||
|
||||
/* vertical information? */
|
||||
if ( face->vertical_info )
|
||||
flags |= FT_FACE_FLAG_VERTICAL;
|
||||
|
||||
/* kerning available ? */
|
||||
if ( face->kern_pairs )
|
||||
flags |= FT_FACE_FLAG_KERNING;
|
||||
|
||||
root->face_flags = flags;
|
||||
|
||||
/*********************************************************************/
|
||||
/* */
|
||||
/* Compute style flags. */
|
||||
/* */
|
||||
flags = 0;
|
||||
|
||||
if ( face->os2.version != 0xFFFF )
|
||||
{
|
||||
/* we have an OS/2 table; use the `fsSelection' field */
|
||||
if ( face->os2.fsSelection & 1 )
|
||||
flags |= FT_STYLE_FLAG_ITALIC;
|
||||
|
||||
if ( face->os2.fsSelection & 32 )
|
||||
flags |= FT_STYLE_FLAG_BOLD;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this is an old Mac font, use the header field */
|
||||
if ( face->header.Mac_Style & 1 )
|
||||
flags |= FT_STYLE_FLAG_BOLD;
|
||||
|
||||
if ( face->header.Mac_Style & 2 )
|
||||
flags |= FT_STYLE_FLAG_ITALIC;
|
||||
}
|
||||
|
||||
root->style_flags = flags;
|
||||
|
||||
/*********************************************************************/
|
||||
/* */
|
||||
/* Polish the charmaps. */
|
||||
/* */
|
||||
/* Try to set the charmap encoding according to the platform & */
|
||||
/* encoding ID of each charmap. */
|
||||
/* */
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
|
||||
if ( face->num_sbit_strikes )
|
||||
{
|
||||
root->num_fixed_sizes = face->num_sbit_strikes;
|
||||
if ( ALLOC_ARRAY( root->available_sizes,
|
||||
face->num_sbit_strikes,
|
||||
FT_Bitmap_Size ) )
|
||||
return error;
|
||||
|
||||
for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
|
||||
{
|
||||
root->available_sizes[n].width =
|
||||
face->sbit_strikes[n].x_ppem;
|
||||
root->available_sizes[n].height =
|
||||
face->sbit_strikes[n].y_ppem;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
||||
|
||||
{
|
||||
root->num_fixed_sizes = 0;
|
||||
root->available_sizes = 0;
|
||||
}
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
||||
|
||||
/*********************************************************************/
|
||||
/* */
|
||||
/* Set up metrics. */
|
||||
/* */
|
||||
root->bbox.xMin = face->header.xMin;
|
||||
root->bbox.yMin = face->header.yMin;
|
||||
root->bbox.xMax = face->header.xMax;
|
||||
root->bbox.yMax = face->header.yMax;
|
||||
root->units_per_EM = face->header.Units_Per_EM;
|
||||
|
||||
/* The ascender/descender/height are computed from the OS/2 table */
|
||||
/* when found. Otherwise, they're taken from the horizontal header. */
|
||||
if ( face->os2.version != 0xFFFF )
|
||||
{
|
||||
root->ascender = face->os2.sTypoAscender;
|
||||
root->descender = -face->os2.sTypoDescender;
|
||||
root->height = root->ascender + root->descender +
|
||||
face->os2.sTypoLineGap;
|
||||
}
|
||||
else
|
||||
{
|
||||
root->ascender = face->horizontal.Ascender;
|
||||
root->descender = face->horizontal.Descender;
|
||||
root->height = root->ascender + root->descender +
|
||||
face->horizontal.Line_Gap;
|
||||
}
|
||||
|
||||
root->max_advance_width = face->horizontal.advance_Width_Max;
|
||||
|
||||
root->max_advance_height = face->vertical_info
|
||||
? face->vertical.advance_Height_Max
|
||||
: root->height;
|
||||
|
||||
root->underline_position = face->postscript.underlinePosition;
|
||||
root->underline_thickness = face->postscript.underlineThickness;
|
||||
|
||||
/* root->max_points -- already set up */
|
||||
/* root->max_contours -- already set up */
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#undef LOAD_
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void SFNT_Done_Face( TT_Face face )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
||||
|
||||
|
||||
if ( sfnt )
|
||||
{
|
||||
/* destroy the postscript names table if it is loaded */
|
||||
if ( sfnt->free_psnames )
|
||||
sfnt->free_psnames( face );
|
||||
|
||||
/* destroy the embedded bitmaps table if it is loaded */
|
||||
if ( sfnt->free_sbits )
|
||||
sfnt->free_sbits( face );
|
||||
}
|
||||
|
||||
/* freeing the kerning table */
|
||||
FREE( face->kern_pairs );
|
||||
face->num_kern_pairs = 0;
|
||||
|
||||
/* freeing the collection table */
|
||||
FREE( face->ttc_header.offsets );
|
||||
face->ttc_header.count = 0;
|
||||
|
||||
/* freeing table directory */
|
||||
FREE( face->dir_tables );
|
||||
face->num_tables = 0;
|
||||
|
||||
/* freeing the character mapping tables */
|
||||
if ( sfnt && sfnt->load_charmaps )
|
||||
{
|
||||
FT_UShort n;
|
||||
|
||||
|
||||
for ( n = 0; n < face->num_charmaps; n++ )
|
||||
sfnt->free_charmap( face, &face->charmaps[n].cmap );
|
||||
}
|
||||
|
||||
FREE( face->charmaps );
|
||||
face->num_charmaps = 0;
|
||||
|
||||
FREE( face->root.charmaps );
|
||||
face->root.num_charmaps = 0;
|
||||
face->root.charmap = 0;
|
||||
|
||||
/* freeing the horizontal metrics */
|
||||
FREE( face->horizontal.long_metrics );
|
||||
FREE( face->horizontal.short_metrics );
|
||||
|
||||
/* freeing the vertical ones, if any */
|
||||
if ( face->vertical_info )
|
||||
{
|
||||
FREE( face->vertical.long_metrics );
|
||||
FREE( face->vertical.short_metrics );
|
||||
face->vertical_info = 0;
|
||||
}
|
||||
|
||||
/* freeing the gasp table */
|
||||
FREE( face->gasp.gaspRanges );
|
||||
face->gasp.numRanges = 0;
|
||||
|
||||
/* freeing the name table */
|
||||
sfnt->free_names( face );
|
||||
|
||||
/* freeing the hdmx table */
|
||||
sfnt->free_hdmx( face );
|
||||
|
||||
/* freeing family and style name */
|
||||
FREE( face->root.family_name );
|
||||
FREE( face->root.style_name );
|
||||
|
||||
/* freeing sbit size table */
|
||||
face->root.num_fixed_sizes = 0;
|
||||
if ( face->root.available_sizes )
|
||||
FREE( face->root.available_sizes );
|
||||
|
||||
face->sfnt = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,57 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* sfobjs.h */
|
||||
/* */
|
||||
/* SFNT object management (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 SFOBJS_H
|
||||
#define SFOBJS_H
|
||||
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error SFNT_Init_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error SFNT_Load_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF
|
||||
void SFNT_Done_Face( TT_Face face );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* SFDRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,37 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* smooth.c */
|
||||
/* */
|
||||
/* FreeType anti-aliasing rasterer module 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 "ftgrays.c"
|
||||
#include "ftsmooth.c"
|
||||
|
||||
#else
|
||||
|
||||
#include <smooth/ftgrays.c>
|
||||
#include <smooth/ftsmooth.c>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,293 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1afm.c */
|
||||
/* */
|
||||
/* AFM support for Type 1 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 "t1afm.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1afm.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/t1types.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_t1afm
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void T1_Done_AFM( FT_Memory memory,
|
||||
T1_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 )
|
||||
{
|
||||
T1_Kern_Pair* pair1 = (T1_Kern_Pair*)a;
|
||||
T1_Kern_Pair* pair2 = (T1_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 T1_Read_AFM( FT_Face t1_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;
|
||||
T1_Kern_Pair* pair;
|
||||
T1_Font* type1 = &((T1_Face)t1_face)->type1;
|
||||
T1_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 occurences 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, T1_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 ( T1_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 T1_Get_Kerning( T1_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
T1_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 */
|
||||
@@ -1,70 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1afm.h */
|
||||
/* */
|
||||
/* AFM support for Type 1 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 T1AFM_H
|
||||
#define T1AFM_H
|
||||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct T1_Kern_Pair_
|
||||
{
|
||||
FT_UInt glyph1;
|
||||
FT_UInt glyph2;
|
||||
FT_Vector kerning;
|
||||
|
||||
} T1_Kern_Pair;
|
||||
|
||||
|
||||
typedef struct T1_AFM_
|
||||
{
|
||||
FT_Int num_pairs;
|
||||
T1_Kern_Pair* kern_pairs;
|
||||
|
||||
} T1_AFM;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Read_AFM( FT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_AFM( FT_Memory memory,
|
||||
T1_AFM* afm );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Get_Kerning( T1_AFM* afm,
|
||||
FT_UInt glyph1,
|
||||
FT_UInt glyph2,
|
||||
FT_Vector* kerning );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T1AFM_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,381 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1driver.c */
|
||||
/* */
|
||||
/* Type 1 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 "t1driver.h"
|
||||
#include "t1gload.h"
|
||||
#include "t1afm.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1driver.h>
|
||||
#include <type1/t1gload.h>
|
||||
#include <type1/t1afm.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_t1driver
|
||||
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_NO_AFM
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <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( T1_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
T1_AFM* afm;
|
||||
|
||||
|
||||
kerning->x = 0;
|
||||
kerning->y = 0;
|
||||
|
||||
afm = (T1_AFM*)face->afm_data;
|
||||
if ( afm )
|
||||
T1_Get_Kerning( afm, left_glyph, right_glyph, kerning );
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
#endif /* T1_CONFIG_OPTION_NO_AFM */
|
||||
|
||||
|
||||
static
|
||||
FT_Error get_t1_glyph_name( T1_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_Pointer buffer,
|
||||
FT_UInt buffer_max )
|
||||
{
|
||||
FT_String* gname;
|
||||
|
||||
|
||||
gname = face->type1.glyph_names[glyph_index];
|
||||
|
||||
if ( buffer_max > 0 )
|
||||
{
|
||||
FT_UInt len = strlen( gname );
|
||||
|
||||
|
||||
if ( len >= buffer_max )
|
||||
len = buffer_max - 1;
|
||||
|
||||
MEM_Copy( buffer, gname, len );
|
||||
((FT_Byte*)buffer)[len] = 0;
|
||||
}
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Module_Interface T1_Get_Interface( FT_Module module,
|
||||
const char* interface )
|
||||
{
|
||||
FT_UNUSED( module );
|
||||
|
||||
if ( strcmp( interface, "glyph_name" ) == 0 )
|
||||
return (FT_Module_Interface)get_t1_glyph_name;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Set_Char_Sizes */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A driver method used to reset a size's character sizes (horizontal */
|
||||
/* and vertical) expressed in fractional points. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* char_width :: The character width expressed in 26.6 */
|
||||
/* fractional points. */
|
||||
/* */
|
||||
/* char_height :: The character height expressed in 26.6 */
|
||||
/* fractional points. */
|
||||
/* */
|
||||
/* horz_resolution :: The horizontal resolution of the output device. */
|
||||
/* */
|
||||
/* vert_resolution :: The vertical resolution of the output device. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Set_Char_Sizes( T1_Size size,
|
||||
FT_F26Dot6 char_width,
|
||||
FT_F26Dot6 char_height,
|
||||
FT_UInt horz_resolution,
|
||||
FT_UInt vert_resolution )
|
||||
{
|
||||
FT_UNUSED( char_width );
|
||||
FT_UNUSED( char_height );
|
||||
FT_UNUSED( horz_resolution );
|
||||
FT_UNUSED( vert_resolution );
|
||||
|
||||
size->valid = FALSE;
|
||||
|
||||
return T1_Reset_Size( size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Set_Pixel_Sizes */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A driver method used to reset a size's character sizes (horizontal */
|
||||
/* and vertical) expressed in integer pixels. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* pixel_width :: The character width expressed in integer pixels. */
|
||||
/* */
|
||||
/* pixel_height :: The character height expressed in integer pixels. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Set_Pixel_Sizes( T1_Size size,
|
||||
FT_Int pixel_width,
|
||||
FT_Int pixel_height )
|
||||
{
|
||||
FT_UNUSED( pixel_width );
|
||||
FT_UNUSED( pixel_height );
|
||||
|
||||
size->valid = FALSE;
|
||||
|
||||
return T1_Reset_Size( size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <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 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 t1_driver_class =
|
||||
{
|
||||
{
|
||||
ft_module_font_driver | ft_module_driver_scalable,
|
||||
sizeof( FT_DriverRec ),
|
||||
|
||||
"type1", /* driver name */
|
||||
0x10000L, /* driver version 1.0 */
|
||||
0x20000L, /* driver requires FreeType 2.0 or above */
|
||||
|
||||
0, /* module specific interface */
|
||||
|
||||
(FT_Module_Constructor)0,
|
||||
(FT_Module_Destructor) 0,
|
||||
(FT_Module_Requester) T1_Get_Interface
|
||||
},
|
||||
|
||||
sizeof( T1_FaceRec ),
|
||||
sizeof( T1_SizeRec ),
|
||||
sizeof( T1_GlyphSlotRec ),
|
||||
|
||||
(FTDriver_initFace) T1_Init_Face,
|
||||
(FTDriver_doneFace) T1_Done_Face,
|
||||
(FTDriver_initSize) T1_Init_Size,
|
||||
(FTDriver_doneSize) T1_Done_Size,
|
||||
(FTDriver_initGlyphSlot)T1_Init_GlyphSlot,
|
||||
(FTDriver_doneGlyphSlot)T1_Done_GlyphSlot,
|
||||
|
||||
(FTDriver_setCharSizes) Set_Char_Sizes,
|
||||
(FTDriver_setPixelSizes)Set_Pixel_Sizes,
|
||||
(FTDriver_loadGlyph) T1_Load_Glyph,
|
||||
(FTDriver_getCharIndex) Get_Char_Index,
|
||||
|
||||
#ifdef T1_CONFIG_OPTION_NO_AFM
|
||||
(FTDriver_getKerning) 0,
|
||||
(FTDriver_attachFile) 0,
|
||||
#else
|
||||
(FTDriver_getKerning) Get_Kerning,
|
||||
(FTDriver_attachFile) T1_Read_AFM,
|
||||
#endif
|
||||
(FTDriver_getAdvances) 0
|
||||
};
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
|
||||
|
||||
EXPORT_FUNC( const FT_Driver_Class* ) getDriverClass( void )
|
||||
{
|
||||
return &t1_driver_class;
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,30 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1driver.h */
|
||||
/* */
|
||||
/* High-level Type 1 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 T1DRIVER_H
|
||||
#define T1DRIVER_H
|
||||
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
|
||||
FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class;
|
||||
|
||||
|
||||
#endif /* T1DRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,326 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1gload.h */
|
||||
/* */
|
||||
/* Type 1 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 T1GLOAD_H
|
||||
#define T1GLOAD_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t1objs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1objs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct T1_Builder_ T1_Builder;
|
||||
|
||||
typedef FT_Error (*T1_Builder_EndChar)( T1_Builder* loader );
|
||||
|
||||
typedef FT_Error (*T1_Builder_Sbw)( T1_Builder* loader,
|
||||
FT_Pos sbx,
|
||||
FT_Pos sby,
|
||||
FT_Pos wx,
|
||||
FT_Pos wy );
|
||||
|
||||
typedef FT_Error (*T1_Builder_ClosePath)( T1_Builder* loader );
|
||||
|
||||
typedef FT_Error (*T1_Builder_RLineTo)( T1_Builder* loader,
|
||||
FT_Pos dx,
|
||||
FT_Pos dy );
|
||||
|
||||
typedef FT_Error (*T1_Builder_RMoveTo)( T1_Builder* loader,
|
||||
FT_Pos dx,
|
||||
FT_Pos dy );
|
||||
|
||||
typedef FT_Error (*T1_Builder_RCurveTo)( T1_Builder* loader,
|
||||
FT_Pos dx1,
|
||||
FT_Pos dy1,
|
||||
FT_Pos dx2,
|
||||
FT_Pos dy2,
|
||||
FT_Pos dx3,
|
||||
FT_Pos dy3 );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> */
|
||||
/* T1_Builder_Funcs */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to store the address of various functions used by a */
|
||||
/* glyph builder to implement the outline's `path construction'. */
|
||||
/* */
|
||||
typedef struct T1_Builder_Funcs_
|
||||
{
|
||||
T1_Builder_EndChar end_char;
|
||||
T1_Builder_Sbw set_bearing_point;
|
||||
T1_Builder_ClosePath close_path;
|
||||
T1_Builder_RLineTo rline_to;
|
||||
T1_Builder_RMoveTo rmove_to;
|
||||
T1_Builder_RCurveTo rcurve_to;
|
||||
|
||||
} T1_Builder_Funcs;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> */
|
||||
/* T1_Builder */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used during glyph loading to store its outline. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* memory :: The current memory object. */
|
||||
/* */
|
||||
/* face :: The current face object. */
|
||||
/* */
|
||||
/* size :: The current size object. */
|
||||
/* */
|
||||
/* glyph :: The current glyph slot. */
|
||||
/* */
|
||||
/* loader :: The current glyph loader. */
|
||||
/* */
|
||||
/* current :: The current glyph outline. */
|
||||
/* */
|
||||
/* base :: The base glyph 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 (for composite glyphs). */
|
||||
/* */
|
||||
/* pos_y :: The vertical translation (for composite glyphs). */
|
||||
/* */
|
||||
/* left_bearing :: The left side bearing point. */
|
||||
/* */
|
||||
/* advance :: The horizontal advance vector. */
|
||||
/* */
|
||||
/* no_recurse :: */
|
||||
/* */
|
||||
/* bbox :: The glyph's bounding box. */
|
||||
/* */
|
||||
/* path_begun :: A flag which indicates that a new path has begun. */
|
||||
/* */
|
||||
/* load_points :: A flag which indicates, if not set, that no points */
|
||||
/* are loaded. */
|
||||
/* */
|
||||
/* pass :: The pass number for multi-pass hinters. */
|
||||
/* */
|
||||
/* hint_point :: The index of the next point to hint. */
|
||||
/* */
|
||||
/* funcs :: A table of builder functions used to perform the */
|
||||
/* outline's path construction. */
|
||||
/* */
|
||||
struct T1_Builder_
|
||||
{
|
||||
FT_Memory memory;
|
||||
T1_Face face;
|
||||
T1_Size size;
|
||||
T1_GlyphSlot glyph;
|
||||
FT_GlyphLoader* loader;
|
||||
|
||||
FT_Outline* current; /* the current glyph outline */
|
||||
FT_Outline* base; /* the composite glyph outline */
|
||||
|
||||
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_Bool no_recurse;
|
||||
|
||||
FT_BBox bbox; /* bounding box */
|
||||
FT_Bool path_begun;
|
||||
FT_Bool load_points;
|
||||
|
||||
FT_Int pass;
|
||||
FT_Int hint_point;
|
||||
|
||||
/* path construction function interface */
|
||||
T1_Builder_Funcs funcs;
|
||||
};
|
||||
|
||||
|
||||
typedef FT_Error (*T1_Hinter_ChangeHints)( T1_Builder* builder );
|
||||
|
||||
typedef FT_Error (*T1_Hinter_DotSection)( T1_Builder* builder );
|
||||
|
||||
typedef FT_Error (*T1_Hinter_Stem)( T1_Builder* builder,
|
||||
FT_Pos pos,
|
||||
FT_Pos width,
|
||||
FT_Bool vertical );
|
||||
|
||||
typedef FT_Error (*T1_Hinter_Stem3)( T1_Builder* builder,
|
||||
FT_Pos pos0,
|
||||
FT_Pos width0,
|
||||
FT_Pos pos1,
|
||||
FT_Pos width1,
|
||||
FT_Pos pos2,
|
||||
FT_Pos width2,
|
||||
FT_Bool vertical );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Structure> */
|
||||
/* T1_Hinter_Funcs */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to store the address of various functions used by a */
|
||||
/* Type 1 hinter to perform outline hinting. */
|
||||
/* */
|
||||
typedef struct T1_Hinter_Func_
|
||||
{
|
||||
T1_Hinter_ChangeHints change_hints;
|
||||
T1_Hinter_DotSection dot_section;
|
||||
T1_Hinter_Stem stem;
|
||||
T1_Hinter_Stem3 stem3;
|
||||
|
||||
} T1_Hinter_Funcs;
|
||||
|
||||
|
||||
typedef enum T1_Operator_
|
||||
{
|
||||
op_none = 0,
|
||||
op_endchar,
|
||||
op_hsbw,
|
||||
op_seac,
|
||||
op_sbw,
|
||||
op_closepath,
|
||||
op_hlineto,
|
||||
op_hmoveto,
|
||||
op_hvcurveto,
|
||||
op_rlineto,
|
||||
op_rmoveto,
|
||||
op_rrcurveto,
|
||||
op_vhcurveto,
|
||||
op_vlineto,
|
||||
op_vmoveto,
|
||||
op_dotsection,
|
||||
op_hstem,
|
||||
op_hstem3,
|
||||
op_vstem,
|
||||
op_vstem3,
|
||||
op_div,
|
||||
op_callothersubr,
|
||||
op_callsubr,
|
||||
op_pop,
|
||||
op_return,
|
||||
op_setcurrentpoint,
|
||||
|
||||
op_max /* never remove this one */
|
||||
|
||||
} T1_Operator;
|
||||
|
||||
|
||||
/* execution context charstring zone */
|
||||
typedef struct T1_Decoder_Zone_
|
||||
{
|
||||
FT_Byte* base;
|
||||
FT_Byte* limit;
|
||||
FT_Byte* cursor;
|
||||
|
||||
} T1_Decoder_Zone;
|
||||
|
||||
|
||||
typedef struct T1_Decoder_
|
||||
{
|
||||
T1_Builder builder;
|
||||
T1_Hinter_Funcs hinter;
|
||||
|
||||
FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
|
||||
FT_Int* top;
|
||||
|
||||
T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
|
||||
T1_Decoder_Zone* zone;
|
||||
|
||||
FT_Int flex_state;
|
||||
FT_Int num_flex_vectors;
|
||||
FT_Vector flex_vectors[7];
|
||||
|
||||
} T1_Decoder;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Init_Builder( T1_Builder* builder,
|
||||
T1_Face face,
|
||||
T1_Size size,
|
||||
T1_GlyphSlot glyph,
|
||||
const T1_Builder_Funcs* funcs );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_Builder( T1_Builder* builder );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Init_Decoder( T1_Decoder* decoder,
|
||||
const T1_Hinter_Funcs* funcs );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Compute_Max_Advance( T1_Face face,
|
||||
FT_Int* max_advance );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
|
||||
FT_Byte* charstring_base,
|
||||
FT_Int charstring_len,
|
||||
FT_Int num_subrs,
|
||||
FT_Byte** subrs_base,
|
||||
FT_Int* subrs_len );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Add_Points( T1_Builder* builder,
|
||||
FT_Int num_points );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Add_Contours( T1_Builder* builder,
|
||||
FT_Int num_contours );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Load_Glyph( T1_GlyphSlot glyph,
|
||||
T1_Size size,
|
||||
FT_Int glyph_index,
|
||||
FT_Int load_flags );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T1GLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,273 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1hinter.h */
|
||||
/* */
|
||||
/* Type 1 hinter (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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T1HINTER_H
|
||||
#define T1HINTER_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t1objs.h"
|
||||
#include "t1gload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1objs.h>
|
||||
#include <type1/t1gload.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Snap_Zone */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A `snap zone' is used to model either a blue zone or a stem width */
|
||||
/* at a given character size. It is made of a minimum and maximum */
|
||||
/* edge, defined in 26.6 pixels, as well as an `original' and */
|
||||
/* `scaled' position. */
|
||||
/* */
|
||||
/* The position corresponds to the stem width (for stem snap zones) */
|
||||
/* or to the blue position (for blue zones). */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* orus :: The original position in font units. */
|
||||
/* */
|
||||
/* pix :: The current position in sub-pixel units. */
|
||||
/* */
|
||||
/* min :: The minimum boundary in sub-pixel units. */
|
||||
/* */
|
||||
/* max :: The maximum boundary in sub-pixel units. */
|
||||
/* */
|
||||
typedef struct T1_Snap_Zone_
|
||||
{
|
||||
FT_Pos orus;
|
||||
FT_Pos pix;
|
||||
FT_Pos min;
|
||||
FT_Pos max;
|
||||
|
||||
} T1_Snap_Zone;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Edge */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very simple structure used to model a stem edge. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* orus :: The original edge position in font units. */
|
||||
/* */
|
||||
/* pix :: The scaled edge position in sub-pixel units. */
|
||||
/* */
|
||||
typedef struct T1_Edge_
|
||||
{
|
||||
FT_Pos orus;
|
||||
FT_Pos pix;
|
||||
|
||||
} T1_Edge;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Stem_Hint */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to model a stem hint. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* min_edge :: The hint's minimum edge. */
|
||||
/* */
|
||||
/* max_edge :: The hint's maximum edge. */
|
||||
/* */
|
||||
/* hint_flags :: Some flags describing the stem properties. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The min and max edges of a ghost stem have the same position, even */
|
||||
/* if they are coded in a weird way in the charstrings. */
|
||||
/* */
|
||||
typedef struct T1_Stem_Hint_
|
||||
{
|
||||
T1_Edge min_edge;
|
||||
T1_Edge max_edge;
|
||||
FT_Int hint_flags;
|
||||
|
||||
} T1_Stem_Hint;
|
||||
|
||||
|
||||
#define T1_HINT_FLAG_ACTIVE 1 /* indicates an active stem */
|
||||
#define T1_HINT_FLAG_MIN_BORDER 2 /* unused for now */
|
||||
#define T1_HINT_FLAG_MAX_BORDER 4 /* unused for now */
|
||||
|
||||
/* hinter's configuration constants */
|
||||
#define T1_HINTER_MAX_BLUES 24 /* maximum number of blue zones */
|
||||
#define T1_HINTER_MAX_SNAPS 16 /* maximum number of stem snap zones */
|
||||
#define T1_HINTER_MAX_EDGES 64 /* maximum number of stem hints */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Size_Hints */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model the hinting information related to a size */
|
||||
/* object. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* supress_overshoots :: A boolean flag to tell whether overshoot */
|
||||
/* supression should occur. */
|
||||
/* */
|
||||
/* num_blue_zones :: The total number of blue zones (top+bottom). */
|
||||
/* */
|
||||
/* num_bottom_zones :: The number of bottom zones. */
|
||||
/* */
|
||||
/* blue_zones :: The blue zones table. Bottom zones are */
|
||||
/* stored first in the table, followed by all */
|
||||
/* top zones. */
|
||||
/* */
|
||||
/* num_snap_widths :: The number of horizontal stem snap zones. */
|
||||
/* */
|
||||
/* snap_widths :: An array of horizontal stem snap zones. */
|
||||
/* */
|
||||
/* num_snap_heights :: The number of vertical stem snap zones. */
|
||||
/* */
|
||||
/* snap_heights :: An array of vertical stem snap zones. */
|
||||
/* */
|
||||
struct T1_Size_Hints_
|
||||
{
|
||||
FT_Bool supress_overshoots;
|
||||
|
||||
FT_Int num_blue_zones;
|
||||
FT_Int num_bottom_zones;
|
||||
T1_Snap_Zone blue_zones[T1_HINTER_MAX_BLUES];
|
||||
|
||||
FT_Int num_snap_widths;
|
||||
T1_Snap_Zone snap_widths[T1_HINTER_MAX_SNAPS];
|
||||
|
||||
FT_Int num_snap_heights;
|
||||
T1_Snap_Zone snap_heights[T1_HINTER_MAX_SNAPS];
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Stem_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to model a set of stem hints in a single */
|
||||
/* direction during the loading of a given glyph outline. Not all */
|
||||
/* stem hints are active at a time. Moreover, stems must be sorted */
|
||||
/* regularly. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_stems :: The total number of stems in the table. */
|
||||
/* */
|
||||
/* num_active :: The number of active stems in the table. */
|
||||
/* */
|
||||
/* stems :: A table of all stems. */
|
||||
/* */
|
||||
/* sort :: A table of indices into the stems table, used to */
|
||||
/* keep a sorted list of the active stems. */
|
||||
/* */
|
||||
typedef struct T1_Stem_Table_
|
||||
{
|
||||
FT_Int num_stems;
|
||||
FT_Int num_active;
|
||||
|
||||
T1_Stem_Hint stems[T1_HINTER_MAX_EDGES];
|
||||
FT_Int sort [T1_HINTER_MAX_EDGES];
|
||||
|
||||
} T1_Stem_Table;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Glyph_Hints */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model the stem hints of a given glyph outline */
|
||||
/* during glyph loading. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* hori_stems :: The horizontal stem hints table. */
|
||||
/* vert_stems :: The vertical stem hints table. */
|
||||
/* */
|
||||
struct T1_Glyph_Hints_
|
||||
{
|
||||
T1_Stem_Table hori_stems;
|
||||
T1_Stem_Table vert_stems;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Data> */
|
||||
/* t1_hinter_funcs */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A table containing the address of various functions used during */
|
||||
/* the loading of an hinted scaled outline. */
|
||||
/* */
|
||||
extern const T1_Hinter_Funcs t1_hinter_funcs;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_New_Size_Hinter( T1_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_Size_Hinter( T1_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Reset_Size_Hinter( T1_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_New_Glyph_Hinter( T1_GlyphSlot glyph );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_Glyph_Hinter( T1_GlyphSlot glyph );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Hint_Points( T1_Builder* builder );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Hint_Stems( T1_Builder* builder );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* T1HINTER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,57 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1load.h */
|
||||
/* */
|
||||
/* Type 1 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 T1LOAD_H
|
||||
#define T1LOAD_H
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t1parse.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1parse.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LOCAL_DEF
|
||||
void Init_T1_Parser( T1_Parser* parser,
|
||||
T1_Face face,
|
||||
T1_Tokenizer tokenizer );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Parse_T1_FontProgram( T1_Parser* parser );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* T1LOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,544 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1objs.c */
|
||||
/* */
|
||||
/* Type 1 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 "t1gload.h"
|
||||
#include "t1load.h"
|
||||
#include "t1afm.h"
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
#include "t1hinter.h"
|
||||
#endif
|
||||
|
||||
#else /* FT_FLAT_COMPILE */
|
||||
|
||||
#include <type1/t1gload.h>
|
||||
#include <type1/t1load.h>
|
||||
#include <type1/t1afm.h>
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
#include <type1/t1hinter.h>
|
||||
#endif
|
||||
|
||||
#endif /* FT_FLAT_COMPILE */
|
||||
|
||||
|
||||
#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_t1objs
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* SIZE FUNCTIONS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Done_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The Type 1 size object destructor. Used to discard a given size */
|
||||
/* object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void T1_Done_Size( T1_Size size )
|
||||
{
|
||||
if ( size )
|
||||
{
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
T1_Done_Size_Hinter( size );
|
||||
#endif
|
||||
|
||||
size->valid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Init_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The size object initializer. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeTrue error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Init_Size( T1_Size size )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
size->valid = 0;
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
error = T1_New_Size_Hinter( size );
|
||||
|
||||
return error;
|
||||
#else
|
||||
|
||||
FT_UNUSED( error );
|
||||
|
||||
return T1_Err_Ok;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Reset_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Resets an instance to a new pointsize/transform. This function is */
|
||||
/* in charge of resetting the blue zones,a s well as the stem snap */
|
||||
/* tables for a given size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* size :: The target size object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T1_Reset_Size( T1_Size size )
|
||||
{
|
||||
/* recompute ascender, descender, etc. */
|
||||
T1_Face face = (T1_Face)size->root.face;
|
||||
FT_Size_Metrics* metrics = &size->root.metrics;
|
||||
|
||||
|
||||
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
/* Compute root ascender, descender, test height, and max_advance */
|
||||
metrics->ascender = ( FT_MulFix( face->root.ascender,
|
||||
metrics->y_scale ) + 32 ) & -64;
|
||||
metrics->descender = ( FT_MulFix( face->root.descender,
|
||||
metrics->y_scale ) + 32 ) & -64;
|
||||
metrics->height = ( FT_MulFix( face->root.height,
|
||||
metrics->y_scale ) + 32 ) & -64;
|
||||
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
|
||||
metrics->x_scale ) + 32 ) & -64;
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
return T1_Reset_Size_Hinter( size );
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FACE FUNCTIONS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Done_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The face object destructor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A typeless pointer to the face object to destroy. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void T1_Done_Face( T1_Face face )
|
||||
{
|
||||
FT_Memory memory;
|
||||
T1_Font* type1 = &face->type1;
|
||||
|
||||
|
||||
if ( face )
|
||||
{
|
||||
memory = face->root.memory;
|
||||
|
||||
/* release font info strings */
|
||||
{
|
||||
T1_FontInfo* info = &type1->font_info;
|
||||
|
||||
|
||||
FREE( info->version );
|
||||
FREE( info->notice );
|
||||
FREE( info->full_name );
|
||||
FREE( info->family_name );
|
||||
FREE( info->weight );
|
||||
}
|
||||
|
||||
/* release top dictionary */
|
||||
FREE( type1->charstrings_len );
|
||||
FREE( type1->charstrings );
|
||||
FREE( type1->glyph_names );
|
||||
|
||||
FREE( type1->subrs );
|
||||
FREE( type1->subrs_len );
|
||||
|
||||
FREE( type1->subrs_block );
|
||||
FREE( type1->charstrings_block );
|
||||
FREE( type1->glyph_names_block );
|
||||
|
||||
FREE( type1->encoding.char_index );
|
||||
FREE( type1->font_name );
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_NO_AFM
|
||||
/* release afm data if present */
|
||||
if ( face->afm_data )
|
||||
T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
|
||||
#endif
|
||||
|
||||
/* release unicode map, if any */
|
||||
FREE( face->unicode_map.maps );
|
||||
face->unicode_map.num_maps = 0;
|
||||
|
||||
face->root.family_name = 0;
|
||||
face->root.style_name = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Init_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The face object constructor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* stream :: input stream where to load font data. */
|
||||
/* */
|
||||
/* 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 face record to build. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T1_Init_Face( FT_Stream stream,
|
||||
T1_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
T1_Tokenizer tokenizer;
|
||||
FT_Error error;
|
||||
PSNames_Interface* psnames;
|
||||
|
||||
FT_UNUSED( num_params );
|
||||
FT_UNUSED( params );
|
||||
FT_UNUSED( face_index );
|
||||
FT_UNUSED( face );
|
||||
|
||||
|
||||
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 */
|
||||
error = New_Tokenizer( stream, &tokenizer );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
/* if we just wanted to check the format, leave successfully now */
|
||||
if ( face_index < 0 )
|
||||
goto Leave;
|
||||
|
||||
/* check the face index */
|
||||
if ( face_index != 0 )
|
||||
{
|
||||
FT_ERROR(( "T1_Init_Face: invalid face index\n" ));
|
||||
error = T1_Err_Invalid_Argument;
|
||||
goto Leave;
|
||||
}
|
||||
|
||||
/* Now, load the font program into the face object */
|
||||
{
|
||||
T1_Parser parser;
|
||||
|
||||
|
||||
Init_T1_Parser( &parser, face, tokenizer );
|
||||
error = Parse_T1_FontProgram( &parser );
|
||||
if ( error )
|
||||
goto Leave;
|
||||
|
||||
/* Init the face object fields */
|
||||
/* Now set up root face fields */
|
||||
{
|
||||
FT_Face root = (FT_Face)&face->root;
|
||||
T1_Font* type1 = &face->type1;
|
||||
|
||||
|
||||
root->num_glyphs = type1->num_glyphs;
|
||||
root->num_charmaps = 1;
|
||||
|
||||
root->face_index = face_index;
|
||||
root->face_flags = FT_FACE_FLAG_SCALABLE;
|
||||
|
||||
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
|
||||
|
||||
root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
|
||||
|
||||
if ( type1->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 = type1->font_info.family_name;
|
||||
if ( root->family_name )
|
||||
{
|
||||
char* full = type1->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 (type1->font_name)
|
||||
{
|
||||
root->family_name = type1->font_name;
|
||||
root->style_name = "Regular";
|
||||
}
|
||||
}
|
||||
|
||||
/* no embedded bitmap support */
|
||||
root->num_fixed_sizes = 0;
|
||||
root->available_sizes = 0;
|
||||
|
||||
root->bbox = type1->font_bbox;
|
||||
root->units_per_EM = 1000;
|
||||
root->ascender = (FT_Short)type1->font_bbox.yMax;
|
||||
root->descender = -(FT_Short)type1->font_bbox.yMin;
|
||||
root->height = ( ( root->ascender + root->descender) * 12 )
|
||||
/ 10;
|
||||
|
||||
/* now compute the maximum advance width */
|
||||
|
||||
root->max_advance_width = type1->private_dict.standard_width[0];
|
||||
|
||||
/* compute max advance width for proportional fonts */
|
||||
if ( !type1->font_info.is_fixed_pitch )
|
||||
{
|
||||
FT_Int max_advance;
|
||||
|
||||
|
||||
error = T1_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;
|
||||
|
||||
root->underline_position = type1->font_info.underline_position;
|
||||
root->underline_thickness = type1->font_info.underline_thickness;
|
||||
|
||||
root->max_points = 0;
|
||||
root->max_contours = 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];
|
||||
}
|
||||
|
||||
Leave:
|
||||
Done_Tokenizer( tokenizer );
|
||||
|
||||
Fail:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Done_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The glyph slot object destructor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph :: The glyph slot handle to destroy. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void T1_Done_GlyphSlot( T1_GlyphSlot glyph )
|
||||
{
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
|
||||
T1_Done_Glyph_Hinter( glyph );
|
||||
|
||||
#else
|
||||
|
||||
FT_UNUSED( glyph );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Init_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The glyph slot object constructor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph :: The glyph slot handle to initialize. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot glyph )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
|
||||
error = T1_New_Glyph_Hinter( glyph );
|
||||
|
||||
#else
|
||||
|
||||
FT_UNUSED( glyph );
|
||||
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,172 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1objs.h */
|
||||
/* */
|
||||
/* Type 1 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 T1OBJS_H
|
||||
#define T1OBJS_H
|
||||
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/internal/t1types.h>
|
||||
|
||||
#include <freetype/internal/t1errors.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* The following structures must be defined by the hinter */
|
||||
typedef struct T1_Size_Hints_ T1_Size_Hints;
|
||||
typedef struct T1_Glyph_Hints_ T1_Glyph_Hints;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T1_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 driver object. */
|
||||
/* */
|
||||
typedef struct T1_DriverRec_* T1_Driver;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T1_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 size object. */
|
||||
/* */
|
||||
typedef struct T1_SizeRec_* T1_Size;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T1_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a Type 1 glyph slot object. */
|
||||
/* */
|
||||
typedef struct T1_GlyphSlotRec_* T1_GlyphSlot;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T1_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 T1_CharMapRec_* T1_CharMap;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* HERE BEGINS THE TYPE1 SPECIFIC STUFF */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T1_SizeRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Type 1 size record. */
|
||||
/* */
|
||||
typedef struct T1_SizeRec_
|
||||
{
|
||||
FT_SizeRec root;
|
||||
FT_Bool valid;
|
||||
T1_Size_Hints* hints; /* defined in the hinter. This allows */
|
||||
/* us to experiment with different */
|
||||
/* hinting schemes without having to */
|
||||
/* change `t1objs' each time. */
|
||||
} T1_SizeRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T1_GlyphSlotRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Type 1 glyph slot record. */
|
||||
/* */
|
||||
typedef struct T1_GlyphSlotRec_
|
||||
{
|
||||
FT_GlyphSlotRec root;
|
||||
|
||||
FT_Bool hint;
|
||||
FT_Bool scaled;
|
||||
|
||||
FT_Int max_points;
|
||||
FT_Int max_contours;
|
||||
|
||||
FT_Fixed x_scale;
|
||||
FT_Fixed y_scale;
|
||||
|
||||
T1_Glyph_Hints* hints; /* defined in the hinter */
|
||||
|
||||
} T1_GlyphSlotRec;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Init_Face( FT_Stream stream,
|
||||
T1_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_Face( T1_Face face );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Init_Size( T1_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_Size( T1_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Reset_Size( T1_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot slot );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_GlyphSlot( T1_GlyphSlot slot );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* T1OBJS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,761 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1parse.c */
|
||||
/* */
|
||||
/* Type 1 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/t1types.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t1parse.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1parse.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h> /* for sscanf() */
|
||||
#include <string.h> /* for strncpy() */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_New_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a T1_Table structure. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* table :: The address of the target table. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* count :: The table size (i.e. maximum number of elements). */
|
||||
/* memory :: The memory object to use for all subsequent */
|
||||
/* reallocations. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T1_New_Table( T1_Table* table,
|
||||
FT_Int count,
|
||||
FT_Memory memory )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
table->memory = memory;
|
||||
|
||||
if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) )
|
||||
return error;
|
||||
|
||||
if ( ALLOC_ARRAY( table->lengths, count, FT_Byte* ) )
|
||||
{
|
||||
FREE( table->elements );
|
||||
return error;
|
||||
}
|
||||
|
||||
table->max_elems = count;
|
||||
table->num_elems = 0;
|
||||
|
||||
table->block = 0;
|
||||
table->capacity = 0;
|
||||
table->cursor = 0;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error reallocate_t1_table( T1_Table* table,
|
||||
FT_Int new_size )
|
||||
{
|
||||
FT_Memory memory = table->memory;
|
||||
FT_Byte* old_base = table->block;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
/* reallocate the base block */
|
||||
if ( REALLOC( table->block, table->capacity, new_size ) )
|
||||
return error;
|
||||
table->capacity = new_size;
|
||||
|
||||
/* shift all offsets if necessary */
|
||||
if ( old_base )
|
||||
{
|
||||
FT_Long delta = table->block - old_base;
|
||||
FT_Byte** offset = table->elements;
|
||||
FT_Byte** limit = offset + table->max_elems;
|
||||
|
||||
|
||||
if ( delta )
|
||||
for ( ; offset < limit; offset ++ )
|
||||
if (offset[0])
|
||||
offset[0] += delta;
|
||||
}
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Add_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Adds an object to a T1_Table, possibly growing its memory block. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* table :: The target table. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* index :: The index of the object in the table. */
|
||||
/* */
|
||||
/* object :: The address of the object to copy in memory. */
|
||||
/* */
|
||||
/* length :: The length in bytes of the source object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. An error is returned if a */
|
||||
/* reallocation failed. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error T1_Add_Table( T1_Table* table,
|
||||
FT_Int index,
|
||||
void* object,
|
||||
FT_Int length )
|
||||
{
|
||||
if ( index < 0 || index > table->max_elems )
|
||||
{
|
||||
FT_ERROR(( "T1_Add_Table: invalid index\n" ));
|
||||
return T1_Err_Syntax_Error;
|
||||
}
|
||||
|
||||
/* grow the base block if needed */
|
||||
if ( table->cursor + length > table->capacity )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Int new_size = table->capacity;
|
||||
|
||||
|
||||
while ( new_size < table->cursor + length )
|
||||
new_size += 1024;
|
||||
|
||||
error = reallocate_t1_table( table, new_size );
|
||||
if ( error )
|
||||
return error;
|
||||
}
|
||||
|
||||
/* add the object to the base block and adjust offset */
|
||||
table->elements[index] = table->block + table->cursor;
|
||||
table->lengths [index] = length;
|
||||
MEM_Copy( table->block + table->cursor, object, length );
|
||||
|
||||
table->cursor += length;
|
||||
|
||||
return T1_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* T1_Done_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalize a T1_Table (reallocate it to its current cursor). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* table :: The target table. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does NOT release the heap's memory block. It is up */
|
||||
/* to the caller to clean it, or reference it in its own structures. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void T1_Done_Table( T1_Table* table )
|
||||
{
|
||||
FT_Memory memory = table->memory;
|
||||
FT_Error error;
|
||||
FT_Byte* old_base;
|
||||
|
||||
|
||||
/* should never fail, as rec.cursor <= rec.size */
|
||||
old_base = table->block;
|
||||
if ( !old_base )
|
||||
return;
|
||||
|
||||
(void)REALLOC( table->block, table->capacity, table->cursor );
|
||||
table->capacity = table->cursor;
|
||||
|
||||
if ( old_base != table->block )
|
||||
{
|
||||
FT_Long delta = table->block - old_base;
|
||||
FT_Byte** element = table->elements;
|
||||
FT_Byte** limit = element + table->max_elems;
|
||||
|
||||
|
||||
for ( ; element < limit; element++ )
|
||||
if ( element[0] )
|
||||
element[0] += delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_String* CopyString( T1_Parser* parser )
|
||||
{
|
||||
FT_String* string = NULL;
|
||||
T1_Token* token = parser->args++;
|
||||
FT_Memory memory = parser->tokenizer->memory;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( token->kind == tok_string )
|
||||
{
|
||||
FT_Int len = token->len - 2;
|
||||
|
||||
|
||||
if ( ALLOC( string, len + 1 ) )
|
||||
{
|
||||
parser->error = error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
MEM_Copy( string, parser->tokenizer->base + token->start + 1, len );
|
||||
string[len] = '\0';
|
||||
|
||||
parser->error = T1_Err_Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
FT_ERROR(( "T1_CopyString: syntax error, string token expected!\n" ));
|
||||
parser->error = T1_Err_Syntax_Error;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_int( FT_Byte* base,
|
||||
FT_Byte* limit,
|
||||
FT_Long* result )
|
||||
{
|
||||
FT_Bool sign = 0;
|
||||
FT_Long sum = 0;
|
||||
|
||||
|
||||
if ( base >= limit )
|
||||
goto Fail;
|
||||
|
||||
/* check sign */
|
||||
if ( *base == '+' )
|
||||
base++;
|
||||
|
||||
else if ( *base == '-' )
|
||||
{
|
||||
sign++;
|
||||
base++;
|
||||
}
|
||||
|
||||
/* parse digits */
|
||||
if ( base >= limit )
|
||||
goto Fail;
|
||||
|
||||
do
|
||||
{
|
||||
sum = ( 10 * sum + ( *base++ - '0' ) );
|
||||
|
||||
} while ( base < limit );
|
||||
|
||||
if ( sign )
|
||||
sum = -sum;
|
||||
|
||||
*result = sum;
|
||||
return T1_Err_Ok;
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "parse_int: integer expected\n" ));
|
||||
*result = 0;
|
||||
return T1_Err_Syntax_Error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_float( FT_Byte* base,
|
||||
FT_Byte* limit,
|
||||
FT_Long scale,
|
||||
FT_Long* result )
|
||||
{
|
||||
#if 1
|
||||
|
||||
/* XXX: We are simply much too lazy to code this function */
|
||||
/* properly for now. We will do that when the rest of */
|
||||
/* the driver works properly. */
|
||||
char temp[32];
|
||||
int len = limit - base;
|
||||
double value;
|
||||
|
||||
|
||||
if ( len > 31 )
|
||||
goto Fail;
|
||||
|
||||
strncpy( temp, (char*)base, len );
|
||||
temp[len] = '\0';
|
||||
if ( sscanf( temp, "%lf", &value ) != 1 )
|
||||
goto Fail;
|
||||
|
||||
*result = (FT_Long)( scale * value );
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
||||
FT_Byte* cur;
|
||||
FT_Bool sign = 0; /* sign */
|
||||
FT_Long number_int = 0; /* integer part */
|
||||
FT_Long number_frac = 0; /* fractional part */
|
||||
FT_Long exponent = 0; /* exponent value */
|
||||
FT_Int num_frac = 0; /* number of fractional digits */
|
||||
|
||||
|
||||
/* check sign */
|
||||
if ( *base == '+' )
|
||||
base++;
|
||||
|
||||
else if ( *base == '-' )
|
||||
{
|
||||
sign++;
|
||||
base++;
|
||||
}
|
||||
|
||||
/* find integer part */
|
||||
cur = base;
|
||||
while ( cur < limit )
|
||||
{
|
||||
FT_Byte c = *cur;
|
||||
|
||||
|
||||
if ( c == '.' || c == 'e' || c == 'E' )
|
||||
break;
|
||||
|
||||
cur++;
|
||||
}
|
||||
|
||||
if ( cur > base )
|
||||
{
|
||||
error = parse_integer( base, cur, &number_int );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
/* read fractional part, if any */
|
||||
if ( *cur == '.' )
|
||||
{
|
||||
cur++;
|
||||
base = cur;
|
||||
while ( cur < limit )
|
||||
{
|
||||
FT_Byte c = *cur;
|
||||
|
||||
|
||||
if ( c == 'e' || c == 'E' )
|
||||
break;
|
||||
cur++;
|
||||
}
|
||||
|
||||
num_frac = cur - base;
|
||||
|
||||
if ( cur > base )
|
||||
{
|
||||
error = parse_integer( base, cur, &number_frac );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
base = cur;
|
||||
}
|
||||
}
|
||||
|
||||
/* read exponent, if any */
|
||||
if ( *cur == 'e' || *cur == 'E' )
|
||||
{
|
||||
cur++;
|
||||
base = cur;
|
||||
error = parse_integer( base, limit, &exponent );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
/* now check that exponent is within `correct bounds' */
|
||||
/* i.e. between -6 and 6 */
|
||||
if ( exponent < -6 || exponent > 6 )
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
/* now adjust integer value and exponent for fractional part */
|
||||
while ( num_frac > 0 )
|
||||
{
|
||||
number_int *= 10;
|
||||
exponent--;
|
||||
num_frac--;
|
||||
}
|
||||
|
||||
number_int += num_frac;
|
||||
|
||||
/* skip point if any, read fractional part */
|
||||
if ( cur + 1 < limit )
|
||||
{
|
||||
if (*cur..
|
||||
}
|
||||
|
||||
/* now compute scaled float value */
|
||||
/* XXX: incomplete! */
|
||||
|
||||
#endif /* 1 */
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "parse_float: syntax error!\n" ));
|
||||
return T1_Err_Syntax_Error;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
FT_Error parse_integer( FT_Byte* base,
|
||||
FT_Byte* limit,
|
||||
FT_Long* result )
|
||||
{
|
||||
FT_Byte* cur;
|
||||
|
||||
|
||||
/* the lexical analyser accepts floats as well as integers */
|
||||
/* now; check that we really have an int in this token */
|
||||
cur = base;
|
||||
while ( cur < limit )
|
||||
{
|
||||
FT_Byte c = *cur++;
|
||||
|
||||
|
||||
if ( c == '.' || c == 'e' || c == 'E' )
|
||||
goto Float_Number;
|
||||
}
|
||||
|
||||
/* now read the number's value */
|
||||
return parse_int( base, limit, result );
|
||||
|
||||
Float_Number:
|
||||
/* we really have a float there; simply call parse_float in this */
|
||||
/* case with a scale of `10' to perform round */
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = parse_float( base, limit, 10, result );
|
||||
if ( !error )
|
||||
{
|
||||
if ( *result >= 0 )
|
||||
*result = ( *result + 5 ) / 10; /* round value */
|
||||
else
|
||||
*result = -( ( 5 - *result ) / 10 );
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Long CopyInteger( T1_Parser* parser )
|
||||
{
|
||||
FT_Long sum = 0;
|
||||
T1_Token* token = parser->args++;
|
||||
|
||||
|
||||
if ( token->kind == tok_number )
|
||||
{
|
||||
FT_Byte* base = parser->tokenizer->base + token->start;
|
||||
FT_Byte* limit = base + token->len;
|
||||
|
||||
|
||||
/* now read the number's value */
|
||||
parser->error = parse_integer( base, limit, &sum );
|
||||
return sum;
|
||||
}
|
||||
|
||||
FT_ERROR(( "CopyInteger: number expected\n" ));
|
||||
parser->args--;
|
||||
parser->error = T1_Err_Syntax_Error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Bool CopyBoolean( T1_Parser* parser )
|
||||
{
|
||||
FT_Error error = T1_Err_Ok;
|
||||
FT_Bool result = 0;
|
||||
T1_Token* token = parser->args++;
|
||||
|
||||
|
||||
if ( token->kind == tok_keyword )
|
||||
{
|
||||
if ( token->kind2 == key_false )
|
||||
result = 0;
|
||||
|
||||
else if ( token->kind2 == key_true )
|
||||
result = !0;
|
||||
|
||||
else
|
||||
goto Fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
Fail:
|
||||
FT_ERROR(( "CopyBoolean:" ));
|
||||
FT_ERROR(( " syntax error; `false' or `true' expected\n" ));
|
||||
error = T1_Err_Syntax_Error;
|
||||
}
|
||||
parser->error = error;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
FT_Long CopyFloat( T1_Parser* parser,
|
||||
FT_Int scale )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Long sum = 0;
|
||||
T1_Token* token = parser->args++;
|
||||
|
||||
|
||||
if ( token->kind == tok_number )
|
||||
{
|
||||
FT_Byte* base = parser->tokenizer->base + token->start;
|
||||
FT_Byte* limit = base + token->len;
|
||||
|
||||
|
||||
error = parser->error = parse_float( base, limit, scale, &sum );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "CopyFloat: syntax error!\n" ));
|
||||
parser->error = T1_Err_Syntax_Error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void CopyBBox( T1_Parser* parser,
|
||||
FT_BBox* bbox )
|
||||
{
|
||||
T1_Token* token = parser->args++;
|
||||
FT_Int n;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( token->kind == tok_program ||
|
||||
token->kind == tok_array )
|
||||
{
|
||||
/* get rid of `['/`]', or `{'/`}' */
|
||||
FT_Byte* base = parser->tokenizer->base + token->start + 1;
|
||||
FT_Byte* limit = base + token->len - 2;
|
||||
FT_Byte* cur;
|
||||
FT_Byte* start;
|
||||
|
||||
|
||||
/* read each parameter independently */
|
||||
cur = base;
|
||||
for ( n = 0; n < 4; n++ )
|
||||
{
|
||||
FT_Long* result;
|
||||
|
||||
|
||||
/* skip whitespace */
|
||||
while ( cur < limit && *cur == ' ' )
|
||||
cur++;
|
||||
|
||||
/* skip numbers */
|
||||
start = cur;
|
||||
while ( cur < limit && *cur != ' ' )
|
||||
cur++;
|
||||
|
||||
/* compute result address */
|
||||
switch ( n )
|
||||
{
|
||||
case 0:
|
||||
result = &bbox->xMin;
|
||||
break;
|
||||
case 1:
|
||||
result = &bbox->yMin;
|
||||
break;
|
||||
case 2:
|
||||
result = &bbox->xMax;
|
||||
break;
|
||||
default:
|
||||
result = &bbox->yMax;
|
||||
}
|
||||
|
||||
error = parse_integer( start, cur, result );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
}
|
||||
parser->error = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "CopyBBox: syntax error!\n" ));
|
||||
parser->error = T1_Err_Syntax_Error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void CopyMatrix( T1_Parser* parser,
|
||||
FT_Matrix* matrix )
|
||||
{
|
||||
T1_Token* token = parser->args++;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( token->kind == tok_array )
|
||||
{
|
||||
/* get rid of `[' and `]' */
|
||||
FT_Byte* base = parser->tokenizer->base + token->start + 1;
|
||||
FT_Byte* limit = base + token->len - 2;
|
||||
FT_Byte* cur;
|
||||
FT_Byte* start;
|
||||
FT_Int n;
|
||||
|
||||
|
||||
/* read each parameter independently */
|
||||
cur = base;
|
||||
for ( n = 0; n < 4; n++ )
|
||||
{
|
||||
FT_Long* result;
|
||||
|
||||
|
||||
/* skip whitespace */
|
||||
while ( cur < limit && *cur == ' ' )
|
||||
cur++;
|
||||
|
||||
/* skip numbers */
|
||||
start = cur;
|
||||
while ( cur < limit && *cur != ' ')
|
||||
cur++;
|
||||
|
||||
/* compute result address */
|
||||
switch ( n )
|
||||
{
|
||||
case 0:
|
||||
result = &matrix->xx;
|
||||
break;
|
||||
case 1:
|
||||
result = &matrix->yx;
|
||||
break;
|
||||
case 2:
|
||||
result = &matrix->xy;
|
||||
break;
|
||||
default:
|
||||
result = &matrix->yy;
|
||||
}
|
||||
|
||||
error = parse_float( start, cur, 65536000L, result );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
}
|
||||
parser->error = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "CopyMatrix: syntax error!\n" ));
|
||||
parser->error = T1_Err_Syntax_Error;
|
||||
}
|
||||
|
||||
|
||||
LOCAL_FUNC
|
||||
void CopyArray( T1_Parser* parser,
|
||||
FT_Byte* num_elements,
|
||||
FT_Short* elements,
|
||||
FT_Int max_elements )
|
||||
{
|
||||
T1_Token* token = parser->args++;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( token->kind == tok_array ||
|
||||
token->kind == tok_program ) /* in the case of MinFeature */
|
||||
{
|
||||
/* get rid of `['/`]', or `{'/`}' */
|
||||
FT_Byte* base = parser->tokenizer->base + token->start + 1;
|
||||
FT_Byte* limit = base + token->len - 2;
|
||||
FT_Byte* cur;
|
||||
FT_Byte* start;
|
||||
FT_Int n;
|
||||
|
||||
|
||||
/* read each parameter independently */
|
||||
cur = base;
|
||||
for ( n = 0; n < max_elements; n++ )
|
||||
{
|
||||
FT_Long result;
|
||||
|
||||
|
||||
/* test end of string */
|
||||
if ( cur >= limit )
|
||||
break;
|
||||
|
||||
/* skip whitespace */
|
||||
while ( cur < limit && *cur == ' ' )
|
||||
cur++;
|
||||
|
||||
/* end of list? */
|
||||
if ( cur >= limit )
|
||||
break;
|
||||
|
||||
/* skip numbers */
|
||||
start = cur;
|
||||
while ( cur < limit && *cur != ' ' )
|
||||
cur++;
|
||||
|
||||
error = parse_integer( start, cur, &result );
|
||||
if ( error )
|
||||
goto Fail;
|
||||
|
||||
*elements++ = (FT_Short)result;
|
||||
}
|
||||
|
||||
if ( num_elements )
|
||||
*num_elements = (FT_Byte)n;
|
||||
|
||||
parser->error = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Fail:
|
||||
FT_ERROR(( "CopyArray: syntax error!\n" ));
|
||||
parser->error = T1_Err_Syntax_Error;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,261 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1parse.h */
|
||||
/* */
|
||||
/* Type 1 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The Type1 parser component is in charge of simply parsing the font */
|
||||
/* input stream and convert simple tokens and elements into integers, */
|
||||
/* floats, matrices, strings, etc. */
|
||||
/* */
|
||||
/* It is used by the Type1 loader. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef T1PARSE_H
|
||||
#define T1PARSE_H
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t1tokens.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1tokens.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* T1_DictState */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration used to describe the Type 1 parser's state, i.e. */
|
||||
/* which dictionary (or array) it is scanning and processing at the */
|
||||
/* current moment. */
|
||||
/* */
|
||||
typedef enum T1_DictState_
|
||||
{
|
||||
dict_none = 0,
|
||||
dict_font, /* parsing the font dictionary */
|
||||
dict_fontinfo, /* parsing the font info dictionary */
|
||||
dict_none2, /* beginning to parse the encrypted section */
|
||||
dict_private, /* parsing the private dictionary */
|
||||
dict_encoding, /* parsing the encoding array */
|
||||
dict_subrs, /* parsing the subrs array */
|
||||
dict_othersubrs, /* parsing the othersubrs array (?) */
|
||||
dict_charstrings, /* parsing the charstrings dictionary */
|
||||
dict_unknown_array, /* parsing/ignoring an unknown array */
|
||||
dict_unknown_dict, /* parsing/ignoring an unknown dictionary */
|
||||
|
||||
dict_max /* do not remove from list */
|
||||
|
||||
} T1_DictState;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A T1_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 */
|
||||
/* reallocation. */
|
||||
/* */
|
||||
/* cursor :: The current top of the grow heap within its block. */
|
||||
/* */
|
||||
/* capacity :: The current size of the heap block. Increments by */
|
||||
/* 1kByte chunks. */
|
||||
/* */
|
||||
/* max_elems :: The maximum number of elements in table. */
|
||||
/* */
|
||||
/* num_elems :: The current number of elements in table. */
|
||||
/* */
|
||||
/* elements :: A table of element addresses within the block. */
|
||||
/* */
|
||||
/* lengths :: A table of element sizes within the block. */
|
||||
/* */
|
||||
/* memory :: The object used for memory operations */
|
||||
/* (alloc/realloc). */
|
||||
/* */
|
||||
typedef struct T1_Table_
|
||||
{
|
||||
FT_Byte* block; /* current memory block */
|
||||
FT_Int cursor; /* current cursor in memory block */
|
||||
FT_Int capacity; /* current size of memory block */
|
||||
|
||||
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;
|
||||
|
||||
} T1_Table;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Parser */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A Type 1 parser. This object is in charge of parsing Type 1 ASCII */
|
||||
/* streams and builds dictionaries for a T1_Face object. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* error :: The current error code. 0 means success. */
|
||||
/* */
|
||||
/* face :: The target T1_Face object being built. */
|
||||
/* */
|
||||
/* tokenizer :: The tokenizer (lexical analyser) used for */
|
||||
/* processing the input stream. */
|
||||
/* */
|
||||
/* dump_tokens :: XXX */
|
||||
/* */
|
||||
/* stack :: The current token stack. Note that we don't */
|
||||
/* use intermediate Postscript objects here! */
|
||||
/* */
|
||||
/* top :: The current top of token stack. */
|
||||
/* */
|
||||
/* limit :: The current upper bound of the token stack. */
|
||||
/* Used for overflow checks. */
|
||||
/* */
|
||||
/* args :: The arguments of a given operator. Used and */
|
||||
/* increased by the various CopyXXX() functions. */
|
||||
/* */
|
||||
/* state_index :: The index of the top of the dictionary state */
|
||||
/* stack. */
|
||||
/* */
|
||||
/* state_stack :: The dictionary states stack. */
|
||||
/* */
|
||||
/* table :: A T1_Table object used to record various kinds */
|
||||
/* of dictionaries or arrays (like `/Encoding', */
|
||||
/* `/Subrs', `/CharStrings'). */
|
||||
/* */
|
||||
/* cur_name :: XXX */
|
||||
/* */
|
||||
/* encoding_type :: XXX */
|
||||
/* */
|
||||
/* encoding_names :: XXX */
|
||||
/* */
|
||||
/* encoding_lengths :: XXX */
|
||||
/* */
|
||||
/* encoding_offsets :: XXX */
|
||||
/* */
|
||||
/* subrs :: XXX */
|
||||
/* */
|
||||
/* charstrings :: XXX */
|
||||
/* */
|
||||
typedef struct T1_Parser_
|
||||
{
|
||||
FT_Error error;
|
||||
T1_Face face;
|
||||
|
||||
T1_Tokenizer tokenizer;
|
||||
FT_Bool dump_tokens;
|
||||
|
||||
T1_Token stack[T1_MAX_STACK_DEPTH];
|
||||
T1_Token* top;
|
||||
T1_Token* limit;
|
||||
T1_Token* args;
|
||||
|
||||
FT_Int state_index;
|
||||
T1_DictState state_stack[T1_MAX_DICT_DEPTH];
|
||||
|
||||
T1_Table table;
|
||||
|
||||
FT_Int cur_name;
|
||||
|
||||
T1_EncodingType encoding_type;
|
||||
FT_Byte* encoding_names;
|
||||
FT_Int* encoding_lengths;
|
||||
FT_Byte** encoding_offsets;
|
||||
|
||||
FT_Byte* subrs;
|
||||
FT_Byte* charstrings;
|
||||
|
||||
} T1_Parser;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_New_Table( T1_Table* table,
|
||||
FT_Int count,
|
||||
FT_Memory memory );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error T1_Add_Table( T1_Table* table,
|
||||
FT_Int index,
|
||||
void* object,
|
||||
FT_Int length );
|
||||
|
||||
LOCAL_DEF
|
||||
void T1_Done_Table( T1_Table* table );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_String* CopyString( T1_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long CopyInteger( T1_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Bool CopyBoolean( T1_Parser* parser );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Long CopyFloat( T1_Parser* parser,
|
||||
FT_Int scale );
|
||||
|
||||
LOCAL_DEF
|
||||
void CopyBBox( T1_Parser* parser,
|
||||
FT_BBox* bbox );
|
||||
|
||||
LOCAL_DEF
|
||||
void CopyMatrix( T1_Parser* parser,
|
||||
FT_Matrix* matrix );
|
||||
|
||||
LOCAL_DEF
|
||||
void CopyArray( T1_Parser* parser,
|
||||
FT_Byte* num_elements,
|
||||
FT_Short* elements,
|
||||
FT_Int max_elements );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* T1PARSE_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,258 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1tokens.h */
|
||||
/* */
|
||||
/* Type 1 tokenizer (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 T1TOKENS_H
|
||||
#define T1TOKENS_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "t1objs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <type1/t1objs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* enum value of first keyword */
|
||||
#define key_first_ 100
|
||||
|
||||
/* enum value of first immediate name */
|
||||
#define imm_first_ 200
|
||||
|
||||
|
||||
typedef enum T1_TokenType_
|
||||
{
|
||||
tok_error = 0,
|
||||
|
||||
tok_eof, /* end of file */
|
||||
|
||||
/* simple token types */
|
||||
|
||||
tok_keyword, /* keyword */
|
||||
tok_number, /* number (integer or real) */
|
||||
tok_string, /* postscript string */
|
||||
tok_program, /* postscript program */
|
||||
tok_immediate, /* any immediate name */
|
||||
tok_array, /* matrix, array, etc.. */
|
||||
tok_hexarray, /* array of hexadecimal nibbles */
|
||||
tok_any, /* anything else */
|
||||
|
||||
/* Postscript keywords -- placed in lexicographical order */
|
||||
|
||||
key_RD_alternate = key_first_, /* `-|' = alternate form of RD */
|
||||
key_ExpertEncoding,
|
||||
key_ND,
|
||||
key_NP,
|
||||
key_RD,
|
||||
key_StandardEncoding,
|
||||
key_array,
|
||||
key_begin,
|
||||
key_closefile,
|
||||
key_currentdict,
|
||||
key_currentfile,
|
||||
key_def,
|
||||
key_dict,
|
||||
key_dup,
|
||||
key_eexec,
|
||||
key_end,
|
||||
key_execonly,
|
||||
key_false,
|
||||
key_for,
|
||||
key_index,
|
||||
key_noaccess,
|
||||
key_put,
|
||||
key_readonly,
|
||||
key_true,
|
||||
key_userdict,
|
||||
key_NP_alternate, /* `|' = alternate form of NP */
|
||||
key_ND_alternate, /* `|-' = alternate form of ND */
|
||||
|
||||
key_max, /* always keep this value there */
|
||||
|
||||
/* Postscript immediate names -- other names will be ignored, except */
|
||||
/* in charstrings */
|
||||
|
||||
imm_RD_alternate = imm_first_, /* `-|' = alternate form of RD */
|
||||
imm_notdef, /* `/.notdef' immediate */
|
||||
imm_BlendAxisTypes,
|
||||
imm_BlueFuzz,
|
||||
imm_BlueScale,
|
||||
imm_BlueShift,
|
||||
imm_BlueValues,
|
||||
imm_CharStrings,
|
||||
imm_Encoding,
|
||||
imm_FamilyBlues,
|
||||
imm_FamilyName,
|
||||
imm_FamilyOtherBlues,
|
||||
imm_FID,
|
||||
imm_FontBBox,
|
||||
imm_FontID,
|
||||
imm_FontInfo,
|
||||
imm_FontMatrix,
|
||||
imm_FontName,
|
||||
imm_FontType,
|
||||
imm_ForceBold,
|
||||
imm_FullName,
|
||||
imm_ItalicAngle,
|
||||
imm_LanguageGroup,
|
||||
imm_Metrics,
|
||||
imm_MinFeature,
|
||||
imm_ND,
|
||||
imm_NP,
|
||||
imm_Notice,
|
||||
imm_OtherBlues,
|
||||
imm_OtherSubrs,
|
||||
imm_PaintType,
|
||||
imm_Private,
|
||||
imm_RD,
|
||||
imm_RndStemUp,
|
||||
imm_StdHW,
|
||||
imm_StdVW,
|
||||
imm_StemSnapH,
|
||||
imm_StemSnapV,
|
||||
imm_StrokeWidth,
|
||||
imm_Subrs,
|
||||
imm_UnderlinePosition,
|
||||
imm_UnderlineThickness,
|
||||
imm_UniqueID,
|
||||
imm_Weight,
|
||||
|
||||
imm_isFixedPitch,
|
||||
imm_lenIV,
|
||||
imm_password,
|
||||
imm_version,
|
||||
|
||||
imm_NP_alternate, /* `|' = alternate form of NP */
|
||||
imm_ND_alternate, /* `|-' = alternate form of ND */
|
||||
|
||||
imm_max /* always keep this value here */
|
||||
|
||||
} T1_TokenType;
|
||||
|
||||
|
||||
/* these arrays are visible for debugging purposes */
|
||||
extern const char* t1_keywords[];
|
||||
extern const char* t1_immediates[];
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Token */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe a token in the current input stream. */
|
||||
/* Note that the Type1 driver doesn't try to interpret tokens until */
|
||||
/* it really needs to. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* kind :: The token type. Describes the token to the loader. */
|
||||
/* */
|
||||
/* kind2 :: Detailed token type. */
|
||||
/* */
|
||||
/* start :: The index of the first character of token in the input */
|
||||
/* stream. */
|
||||
/* */
|
||||
/* len :: The length of the token in characters. */
|
||||
/* */
|
||||
typedef struct T1_Token_
|
||||
{
|
||||
T1_TokenType kind; /* simple type */
|
||||
T1_TokenType kind2; /* detailed type */
|
||||
FT_Int start; /* index of first token character */
|
||||
FT_Int len; /* length of token in chars */
|
||||
|
||||
} T1_Token;
|
||||
|
||||
|
||||
typedef struct T1_TokenParser_
|
||||
{
|
||||
FT_Memory memory;
|
||||
FT_Stream stream;
|
||||
|
||||
FT_Bool in_pfb; /* true if PFB file, PFA otherwise */
|
||||
FT_Bool in_private; /* true if in private dictionary */
|
||||
|
||||
FT_Byte* base; /* base address of current read buffer */
|
||||
FT_Long cursor; /* current position in read buffer */
|
||||
FT_Long limit; /* limit of current read buffer */
|
||||
FT_Long max; /* maximum size of read buffer */
|
||||
|
||||
FT_Error error; /* last error */
|
||||
T1_Token token; /* last token read */
|
||||
|
||||
} T1_TokenParser;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* T1_Tokenizer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an object used to extract tokens from the input. The */
|
||||
/* object is able to perform PFA/PFB recognition, eexec decryption of */
|
||||
/* the private dictionary, as well as eexec decryption of the */
|
||||
/* charstrings. */
|
||||
/* */
|
||||
typedef T1_TokenParser* T1_Tokenizer;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error New_Tokenizer( FT_Stream stream,
|
||||
T1_Tokenizer* tokenizer );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Done_Tokenizer( T1_Tokenizer tokenizer );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Open_PrivateDict( T1_Tokenizer tokenizer );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error Read_Token( T1_Tokenizer tokenizer );
|
||||
|
||||
|
||||
#if 0
|
||||
LOCAL_DEF
|
||||
FT_Error Read_CharStrings( T1_Tokenizer tokenizer,
|
||||
FT_Int num_chars,
|
||||
FT_Byte* buffer );
|
||||
#endif /* 0 */
|
||||
|
||||
LOCAL_DEF
|
||||
void t1_decrypt( FT_Byte* buffer,
|
||||
FT_Int length,
|
||||
FT_UShort seed );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* T1TOKENS_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,377 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,30 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,213 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,757 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,69 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,600 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,148 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,641 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,70 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,96 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* 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 */
|
||||
@@ -1,49 +0,0 @@
|
||||
#define FT_FLAT_COMPILE
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* truetype.c */
|
||||
/* */
|
||||
/* FreeType TrueType 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 "ttdriver.c" /* driver interface */
|
||||
#include "ttpload.c" /* tables loader */
|
||||
#include "ttgload.c" /* glyph loader */
|
||||
#include "ttobjs.c" /* object manager */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
#include "ttinterp.c" /* bytecode interpreter */
|
||||
#endif
|
||||
|
||||
#else /* FT_FLAT_COMPILE */
|
||||
|
||||
#include <truetype/ttdriver.c> /* driver interface */
|
||||
#include <truetype/ttpload.c> /* tables loader */
|
||||
#include <truetype/ttgload.c> /* glyph loader */
|
||||
#include <truetype/ttobjs.c> /* object manager */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
#include <truetype/ttinterp.c> /* bytecode interpreter */
|
||||
#endif
|
||||
|
||||
#endif /* FT_FLAT_COMPILE */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,550 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttcmap.c */
|
||||
/* */
|
||||
/* TrueType character mapping table (cmap) 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/internal/ftdebug.h>
|
||||
#include <freetype/internal/tterrors.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ttload.h"
|
||||
#include "ttcmap.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <sfnt/ttload.h>
|
||||
#include <sfnt/ttcmap.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_ttcmap
|
||||
|
||||
|
||||
static FT_UInt code_to_index0( TT_CMapTable* charmap,
|
||||
FT_ULong char_code );
|
||||
static FT_UInt code_to_index2( TT_CMapTable* charmap,
|
||||
FT_ULong char_code );
|
||||
static FT_UInt code_to_index4( TT_CMapTable* charmap,
|
||||
FT_ULong char_code );
|
||||
static FT_UInt code_to_index6( TT_CMapTable* charmap,
|
||||
FT_ULong char_code );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_CharMap_Load */
|
||||
/* */
|
||||
/* <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> */
|
||||
/* table :: 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. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error TT_CharMap_Load( TT_Face face,
|
||||
TT_CMapTable* cmap,
|
||||
FT_Stream stream )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Memory memory;
|
||||
FT_UShort num_SH, num_Seg, i;
|
||||
|
||||
FT_UShort u, l;
|
||||
|
||||
TT_CMap0* cmap0;
|
||||
TT_CMap2* cmap2;
|
||||
TT_CMap4* cmap4;
|
||||
TT_CMap6* cmap6;
|
||||
|
||||
TT_CMap2SubHeader* cmap2sub;
|
||||
TT_CMap4Segment* segments;
|
||||
|
||||
|
||||
if ( cmap->loaded )
|
||||
return TT_Err_Ok;
|
||||
|
||||
memory = stream->memory;
|
||||
|
||||
if ( FILE_Seek( cmap->offset ) )
|
||||
return error;
|
||||
|
||||
switch ( cmap->format )
|
||||
{
|
||||
case 0:
|
||||
cmap0 = &cmap->c.cmap0;
|
||||
|
||||
if ( ALLOC( cmap0->glyphIdArray, 256L ) ||
|
||||
FILE_Read( cmap0->glyphIdArray, 256L ) )
|
||||
goto Fail;
|
||||
|
||||
cmap->get_index = code_to_index0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
num_SH = 0;
|
||||
cmap2 = &cmap->c.cmap2;
|
||||
|
||||
/* allocate subheader keys */
|
||||
|
||||
if ( ALLOC_ARRAY( cmap2->subHeaderKeys, 256, FT_UShort ) ||
|
||||
ACCESS_Frame( 512L ) )
|
||||
goto Fail;
|
||||
|
||||
for ( i = 0; i < 256; i++ )
|
||||
{
|
||||
u = GET_UShort() / 8;
|
||||
cmap2->subHeaderKeys[i] = u;
|
||||
|
||||
if ( num_SH < u )
|
||||
num_SH = u;
|
||||
}
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
/* load subheaders */
|
||||
|
||||
cmap2->numGlyphId = l =
|
||||
( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2;
|
||||
|
||||
if ( ALLOC_ARRAY( cmap2->subHeaders,
|
||||
num_SH + 1,
|
||||
TT_CMap2SubHeader ) ||
|
||||
ACCESS_Frame( ( num_SH + 1 ) * 8L ) )
|
||||
goto Fail;
|
||||
|
||||
cmap2sub = cmap2->subHeaders;
|
||||
|
||||
for ( i = 0; i <= num_SH; i++ )
|
||||
{
|
||||
cmap2sub->firstCode = GET_UShort();
|
||||
cmap2sub->entryCount = GET_UShort();
|
||||
cmap2sub->idDelta = GET_Short();
|
||||
/* we apply the location offset immediately */
|
||||
cmap2sub->idRangeOffset = GET_UShort() - ( num_SH - i ) * 8 - 2;
|
||||
|
||||
cmap2sub++;
|
||||
}
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
/* load glyph IDs */
|
||||
|
||||
if ( ALLOC_ARRAY( cmap2->glyphIdArray, l, FT_UShort ) ||
|
||||
ACCESS_Frame( l * 2L ) )
|
||||
goto Fail;
|
||||
|
||||
for ( i = 0; i < l; i++ )
|
||||
cmap2->glyphIdArray[i] = GET_UShort();
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
cmap->get_index = code_to_index2;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
cmap4 = &cmap->c.cmap4;
|
||||
|
||||
/* load header */
|
||||
|
||||
if ( ACCESS_Frame( 8L ) )
|
||||
goto Fail;
|
||||
|
||||
cmap4->segCountX2 = GET_UShort();
|
||||
cmap4->searchRange = GET_UShort();
|
||||
cmap4->entrySelector = GET_UShort();
|
||||
cmap4->rangeShift = GET_UShort();
|
||||
|
||||
num_Seg = cmap4->segCountX2 / 2;
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
/* load segments */
|
||||
|
||||
if ( ALLOC_ARRAY( cmap4->segments,
|
||||
num_Seg,
|
||||
TT_CMap4Segment ) ||
|
||||
ACCESS_Frame( ( num_Seg * 4 + 1 ) * 2L ) )
|
||||
goto Fail;
|
||||
|
||||
segments = cmap4->segments;
|
||||
|
||||
for ( i = 0; i < num_Seg; i++ )
|
||||
segments[i].endCount = GET_UShort();
|
||||
|
||||
(void)GET_UShort();
|
||||
|
||||
for ( i = 0; i < num_Seg; i++ )
|
||||
segments[i].startCount = GET_UShort();
|
||||
|
||||
for ( i = 0; i < num_Seg; i++ )
|
||||
segments[i].idDelta = GET_Short();
|
||||
|
||||
for ( i = 0; i < num_Seg; i++ )
|
||||
segments[i].idRangeOffset = GET_UShort();
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
cmap4->numGlyphId = l =
|
||||
( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xFFFF ) / 2;
|
||||
|
||||
/* load IDs */
|
||||
|
||||
if ( ALLOC_ARRAY( cmap4->glyphIdArray, l, FT_UShort ) ||
|
||||
ACCESS_Frame( l * 2L ) )
|
||||
goto Fail;
|
||||
|
||||
for ( i = 0; i < l; i++ )
|
||||
cmap4->glyphIdArray[i] = GET_UShort();
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
cmap->get_index = code_to_index4;
|
||||
|
||||
cmap4->last_segment = cmap4->segments;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
cmap6 = &cmap->c.cmap6;
|
||||
|
||||
if ( ACCESS_Frame( 4L ) )
|
||||
goto Fail;
|
||||
|
||||
cmap6->firstCode = GET_UShort();
|
||||
cmap6->entryCount = GET_UShort();
|
||||
|
||||
FORGET_Frame();
|
||||
|
||||
l = cmap6->entryCount;
|
||||
|
||||
if ( ALLOC_ARRAY( cmap6->glyphIdArray,
|
||||
cmap6->entryCount,
|
||||
FT_Short ) ||
|
||||
ACCESS_Frame( l * 2L ) )
|
||||
goto Fail;
|
||||
|
||||
for ( i = 0; i < l; i++ )
|
||||
cmap6->glyphIdArray[i] = GET_UShort();
|
||||
|
||||
FORGET_Frame();
|
||||
cmap->get_index = code_to_index6;
|
||||
break;
|
||||
|
||||
default: /* corrupt character mapping table */
|
||||
return TT_Err_Invalid_CharMap_Format;
|
||||
|
||||
}
|
||||
|
||||
return TT_Err_Ok;
|
||||
|
||||
Fail:
|
||||
TT_CharMap_Free( face, cmap );
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_CharMap_Free */
|
||||
/* */
|
||||
/* <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. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error TT_CharMap_Free( TT_Face face,
|
||||
TT_CMapTable* cmap )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
if ( !cmap )
|
||||
return TT_Err_Ok;
|
||||
|
||||
memory = face->root.driver->root.memory;
|
||||
|
||||
switch ( cmap->format )
|
||||
{
|
||||
case 0:
|
||||
FREE( cmap->c.cmap0.glyphIdArray );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
FREE( cmap->c.cmap2.subHeaderKeys );
|
||||
FREE( cmap->c.cmap2.subHeaders );
|
||||
FREE( cmap->c.cmap2.glyphIdArray );
|
||||
break;
|
||||
|
||||
case 4:
|
||||
FREE( cmap->c.cmap4.segments );
|
||||
FREE( cmap->c.cmap4.glyphIdArray );
|
||||
cmap->c.cmap4.segCountX2 = 0;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
FREE( cmap->c.cmap6.glyphIdArray );
|
||||
cmap->c.cmap6.entryCount = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* invalid table format, do nothing */
|
||||
;
|
||||
}
|
||||
|
||||
cmap->loaded = FALSE;
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* code_to_index0 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Converts the character code into a glyph index. Uses format 0. */
|
||||
/* `charCode' must be in the range 0x00-0xFF (otherwise 0 is */
|
||||
/* returned). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charCode :: The wanted character code. */
|
||||
/* cmap0 :: A pointer to a cmap table in format 0. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt code_to_index0( TT_CMapTable* cmap,
|
||||
FT_ULong charCode )
|
||||
{
|
||||
TT_CMap0* cmap0 = &cmap->c.cmap0;
|
||||
|
||||
|
||||
return ( charCode <= 0xFF ? cmap0->glyphIdArray[charCode] : 0 );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* code_to_index2 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Converts the character code into a glyph index. Uses format 2. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charCode :: The wanted character code. */
|
||||
/* cmap2 :: A pointer to a cmap table in format 2. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt code_to_index2( TT_CMapTable* cmap,
|
||||
FT_ULong charCode )
|
||||
{
|
||||
FT_UInt result, index1, offset;
|
||||
FT_UInt char_lo;
|
||||
FT_ULong char_hi;
|
||||
TT_CMap2SubHeader* sh2;
|
||||
TT_CMap2* cmap2;
|
||||
|
||||
|
||||
cmap2 = &cmap->c.cmap2;
|
||||
result = 0;
|
||||
char_lo = (FT_UInt)( charCode & 0xFF );
|
||||
char_hi = charCode >> 8;
|
||||
|
||||
if ( char_hi == 0 )
|
||||
{
|
||||
/* an 8-bit character code -- we use the subHeader 0 in this case */
|
||||
/* to test whether the character code is in the charmap */
|
||||
if ( cmap2->subHeaderKeys[char_lo] == 0 )
|
||||
result = cmap2->glyphIdArray[char_lo];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* a 16-bit character code */
|
||||
index1 = cmap2->subHeaderKeys[char_hi & 0xFF];
|
||||
if ( index1 )
|
||||
{
|
||||
sh2 = cmap2->subHeaders + index1;
|
||||
char_lo -= sh2->firstCode;
|
||||
|
||||
if ( char_lo < sh2->entryCount )
|
||||
{
|
||||
offset = sh2->idRangeOffset / 2 + char_lo;
|
||||
if ( offset < cmap2->numGlyphId )
|
||||
{
|
||||
result = cmap2->glyphIdArray[offset];
|
||||
if ( result )
|
||||
result = ( result + sh2->idDelta ) & 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* code_to_index4 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Converts the character code into a glyph index. Uses format 4. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charCode :: The wanted character code. */
|
||||
/* cmap4 :: A pointer to a cmap table in format 4. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt code_to_index4( TT_CMapTable* cmap,
|
||||
FT_ULong charCode )
|
||||
{
|
||||
FT_UInt result, index1, segCount;
|
||||
TT_CMap4* cmap4;
|
||||
TT_CMap4Segment *seg4, *limit;
|
||||
|
||||
|
||||
cmap4 = &cmap->c.cmap4;
|
||||
result = 0;
|
||||
segCount = cmap4->segCountX2 / 2;
|
||||
seg4 = cmap4->segments;
|
||||
limit = seg4 + segCount;
|
||||
|
||||
/* check against the last segment */
|
||||
seg4 = cmap4->last_segment;
|
||||
|
||||
/* the following is equivalent to performing two tests, as in */
|
||||
/* */
|
||||
/* if ( charCode >= seg4->startCount && charCode <= seg4->endCount ) */
|
||||
/* */
|
||||
/* Yes, that's a bit strange, but it's faster, and the idea behind */
|
||||
/* the cache is to significantly speed up charcode to glyph index */
|
||||
/* conversion. */
|
||||
|
||||
if ( (FT_ULong)(charCode - seg4->startCount) <
|
||||
(FT_ULong)(seg4->endCount - seg4->startCount) )
|
||||
goto Found;
|
||||
|
||||
for ( seg4 = cmap4->segments; seg4 < limit; seg4++ )
|
||||
{
|
||||
/* the ranges are sorted in increasing order. If we are out of */
|
||||
/* the range here, the char code isn't in the charmap, so exit. */
|
||||
|
||||
if ( charCode > seg4->endCount )
|
||||
continue;
|
||||
|
||||
if ( charCode >= seg4->startCount )
|
||||
goto Found;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Found:
|
||||
cmap4->last_segment = seg4;
|
||||
|
||||
/* if the idRangeOffset is 0, we can compute the glyph index */
|
||||
/* directly */
|
||||
|
||||
if ( seg4->idRangeOffset == 0 )
|
||||
result = ( charCode + seg4->idDelta ) & 0xFFFF;
|
||||
else
|
||||
{
|
||||
/* otherwise, we must use the glyphIdArray to do it */
|
||||
index1 = seg4->idRangeOffset / 2
|
||||
+ ( charCode - seg4->startCount )
|
||||
+ ( seg4 - cmap4->segments )
|
||||
- segCount;
|
||||
|
||||
if ( index1 < cmap4->numGlyphId &&
|
||||
cmap4->glyphIdArray[index1] != 0 )
|
||||
result = ( cmap4->glyphIdArray[index1] + seg4->idDelta ) & 0xFFFF;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* code_to_index6 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Converts the character code into a glyph index. Uses format 6. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charCode :: The wanted character code. */
|
||||
/* cmap6 :: A pointer to a cmap table in format 6. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Glyph index into the glyphs array. 0 if the glyph does not exist. */
|
||||
/* */
|
||||
static
|
||||
FT_UInt code_to_index6( TT_CMapTable* cmap,
|
||||
FT_ULong charCode )
|
||||
{
|
||||
TT_CMap6* cmap6;
|
||||
FT_UInt result = 0;
|
||||
|
||||
|
||||
cmap6 = &cmap->c.cmap6;
|
||||
result = 0;
|
||||
charCode -= cmap6->firstCode;
|
||||
|
||||
if ( charCode < cmap6->entryCount )
|
||||
result = cmap6->glyphIdArray[charCode];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,45 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttcmap.h */
|
||||
/* */
|
||||
/* TrueType character mapping table (cmap) support (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 TTCMAP_H
|
||||
#define TTCMAP_H
|
||||
|
||||
#include <freetype/internal/tttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_CharMap_Load( TT_Face face,
|
||||
TT_CMapTable* cmap,
|
||||
FT_Stream input );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_CharMap_Free( TT_Face face,
|
||||
TT_CMapTable* cmap );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TTCMAP_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,511 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttdriver.c */
|
||||
/* */
|
||||
/* TrueType 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/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/ttnameid.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ttdriver.h"
|
||||
#include "ttgload.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <truetype/ttdriver.h>
|
||||
#include <truetype/ttgload.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_ttdriver
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** 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 TT_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 TT_Err_Ok;
|
||||
|
||||
Found:
|
||||
kerning->x = pair->value;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
#undef PAIR_TAG
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** S I Z E S ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Set_Char_Sizes */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A driver method used to reset a size's character sizes (horizontal */
|
||||
/* and vertical) expressed in fractional points. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* char_width :: The character width expressed in 26.6 */
|
||||
/* fractional points. */
|
||||
/* */
|
||||
/* char_height :: The character height expressed in 26.6 */
|
||||
/* fractional points. */
|
||||
/* */
|
||||
/* horz_resolution :: The horizontal resolution of the output device. */
|
||||
/* */
|
||||
/* vert_resolution :: The vertical resolution of the output device. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Set_Char_Sizes( TT_Size size,
|
||||
FT_F26Dot6 char_width,
|
||||
FT_F26Dot6 char_height,
|
||||
FT_UInt horz_resolution,
|
||||
FT_UInt vert_resolution )
|
||||
{
|
||||
FT_Size_Metrics* metrics = &size->root.metrics;
|
||||
TT_Face face = (TT_Face)size->root.face;
|
||||
FT_Long dim_x, dim_y;
|
||||
|
||||
|
||||
/* This bit flag, when set, indicates that the pixel size must be */
|
||||
/* truncated to an integer. Nearly all TrueType fonts have this */
|
||||
/* bit set, as hinting won't work really well otherwise. */
|
||||
/* */
|
||||
/* However, for those rare fonts who do not set it, we override */
|
||||
/* the default computations performed by the base layer. I */
|
||||
/* really don't know whether this is useful, but hey, that's the */
|
||||
/* spec :-) */
|
||||
/* */
|
||||
if ( ( face->header.Flags & 8 ) == 0 )
|
||||
{
|
||||
/* Compute pixel sizes in 26.6 units */
|
||||
dim_x = ( char_width * horz_resolution ) / 72;
|
||||
dim_y = ( char_height * vert_resolution ) / 72;
|
||||
|
||||
metrics->x_scale = FT_DivFix( dim_x, face->root.units_per_EM );
|
||||
metrics->y_scale = FT_DivFix( dim_y, face->root.units_per_EM );
|
||||
|
||||
metrics->x_ppem = (FT_UShort)( dim_x >> 6 );
|
||||
metrics->y_ppem = (FT_UShort)( dim_y >> 6 );
|
||||
}
|
||||
|
||||
size->ttmetrics.valid = FALSE;
|
||||
|
||||
return TT_Reset_Size( size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* Set_Pixel_Sizes */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A driver method used to reset a size's character sizes (horizontal */
|
||||
/* and vertical) expressed in integer pixels. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* pixel_width :: The character width expressed in integer pixels. */
|
||||
/* */
|
||||
/* pixel_height :: The character height expressed in integer pixels. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
static
|
||||
FT_Error Set_Pixel_Sizes( TT_Size size,
|
||||
FT_UInt pixel_width,
|
||||
FT_UInt pixel_height )
|
||||
{
|
||||
FT_UNUSED( pixel_width );
|
||||
FT_UNUSED( pixel_height );
|
||||
|
||||
/* many things have been pre-computed by the base layer */
|
||||
|
||||
size->ttmetrics.valid = FALSE;
|
||||
|
||||
return TT_Reset_Size( size );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <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( TT_GlyphSlot slot,
|
||||
TT_Size size,
|
||||
FT_UShort glyph_index,
|
||||
FT_UInt load_flags )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( !slot )
|
||||
return TT_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->root.face != slot->face )
|
||||
return TT_Err_Invalid_Face_Handle;
|
||||
|
||||
if ( !size->ttmetrics.valid )
|
||||
{
|
||||
if ( FT_SET_ERROR( TT_Reset_Size( size ) ) )
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/* now load the glyph outline if necessary */
|
||||
error = TT_Load_Glyph( size, slot, 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 Get_Char_Index( TT_CharMap charmap,
|
||||
FT_Long charcode )
|
||||
{
|
||||
FT_Error error;
|
||||
TT_Face face;
|
||||
TT_CMapTable* cmap;
|
||||
|
||||
|
||||
cmap = &charmap->cmap;
|
||||
face = (TT_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;
|
||||
}
|
||||
|
||||
if ( cmap->get_index )
|
||||
return cmap->get_index( cmap, charcode );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/**** D R I V E R I N T E R F A C E ****/
|
||||
/**** ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
static
|
||||
FT_Module_Interface tt_get_interface( TT_Driver driver,
|
||||
const char* interface )
|
||||
{
|
||||
FT_Module sfntd = FT_Get_Module( driver->root.root.library,
|
||||
"sfnt" );
|
||||
SFNT_Interface* sfnt;
|
||||
|
||||
|
||||
/* only return the default interface from the SFNT module */
|
||||
if ( sfntd )
|
||||
{
|
||||
sfnt = (SFNT_Interface*)( sfntd->clazz->module_interface );
|
||||
if ( sfnt )
|
||||
return sfnt->get_interface( FT_MODULE( driver ), interface );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* The FT_DriverInterface structure is defined in ftdriver.h. */
|
||||
|
||||
const FT_Driver_Class tt_driver_class =
|
||||
{
|
||||
{
|
||||
ft_module_font_driver |
|
||||
ft_module_driver_scalable |
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
ft_module_driver_has_hinter,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
|
||||
sizeof ( TT_DriverRec ),
|
||||
|
||||
"truetype", /* driver name */
|
||||
0x10000L, /* driver version == 1.0 */
|
||||
0x20000L, /* driver requires FreeType 2.0 or above */
|
||||
|
||||
(void*)0, /* driver specific interface */
|
||||
|
||||
(FT_Module_Constructor)TT_Init_Driver,
|
||||
(FT_Module_Destructor) TT_Done_Driver,
|
||||
(FT_Module_Requester) tt_get_interface,
|
||||
},
|
||||
|
||||
sizeof ( TT_FaceRec ),
|
||||
sizeof ( TT_SizeRec ),
|
||||
sizeof ( FT_GlyphSlotRec ),
|
||||
|
||||
|
||||
(FTDriver_initFace) TT_Init_Face,
|
||||
(FTDriver_doneFace) TT_Done_Face,
|
||||
(FTDriver_initSize) TT_Init_Size,
|
||||
(FTDriver_doneSize) TT_Done_Size,
|
||||
(FTDriver_initGlyphSlot)0,
|
||||
(FTDriver_doneGlyphSlot)0,
|
||||
|
||||
(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) 0,
|
||||
(FTDriver_getAdvances) 0
|
||||
};
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* getDriverInterface */
|
||||
/* */
|
||||
/* <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( const FT_Driver_Class* ) getDriverClass( void )
|
||||
{
|
||||
return &tt_driver_class;
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,31 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttdriver.h */
|
||||
/* */
|
||||
/* High-level TrueType 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 TTDRIVER_H
|
||||
#define TTDRIVER_H
|
||||
|
||||
#include <freetype/internal/ftdriver.h>
|
||||
|
||||
|
||||
FT_EXPORT_VAR( const FT_Driver_Class ) tt_driver_class;
|
||||
|
||||
|
||||
#endif /* TTDRIVER_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,69 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttgload.h */
|
||||
/* */
|
||||
/* TrueType 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 TTGLOAD_H
|
||||
#define TTGLOAD_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ttobjs.h"
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
#include "ttinterp.h"
|
||||
#endif
|
||||
|
||||
#else /* FT_FLAT_COMPILE */
|
||||
|
||||
#include <truetype/ttobjs.h>
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
#include <truetype/ttinterp.h>
|
||||
#endif
|
||||
|
||||
#endif /* FT_FLAT_COMPILE */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void TT_Get_Metrics( TT_HoriHeader* header,
|
||||
FT_UInt index,
|
||||
FT_Short* bearing,
|
||||
FT_UShort* advance );
|
||||
|
||||
LOCAL_DEF
|
||||
void TT_Init_Glyph_Loading( TT_Face face );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Glyph( TT_Size size,
|
||||
TT_GlyphSlot glyph,
|
||||
FT_UShort glyph_index,
|
||||
FT_UInt load_flags );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TTGLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,278 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttinterp.h */
|
||||
/* */
|
||||
/* TrueType bytecode interpreter (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 TTINTERP_H
|
||||
#define TTINTERP_H
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ttobjs.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <truetype/ttobjs.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef TT_CONFIG_OPTION_STATIC_INTEPRETER /* indirect implementation */
|
||||
|
||||
#define EXEC_OP_ TT_ExecContext exc,
|
||||
#define EXEC_OP TT_ExecContext exc
|
||||
#define EXEC_ARG_ exc,
|
||||
#define EXEC_ARG exc
|
||||
|
||||
#else /* static implementation */
|
||||
|
||||
#define EXEC_OP_ /* void */
|
||||
#define EXEC_OP /* void */
|
||||
#define EXEC_ARG_ /* void */
|
||||
#define EXEC_ARG /* void */
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Rounding mode constants. */
|
||||
/* */
|
||||
#define TT_Round_Off 5
|
||||
#define TT_Round_To_Half_Grid 0
|
||||
#define TT_Round_To_Grid 1
|
||||
#define TT_Round_To_Double_Grid 2
|
||||
#define TT_Round_Up_To_Grid 4
|
||||
#define TT_Round_Down_To_Grid 3
|
||||
#define TT_Round_Super 6
|
||||
#define TT_Round_Super_45 7
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Function types used by the interpreter, depending on various modes */
|
||||
/* (e.g. the rounding mode, whether to render a vertical or horizontal */
|
||||
/* line etc). */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* Rounding function */
|
||||
typedef FT_F26Dot6 (*TT_Round_Func)( EXEC_OP_ FT_F26Dot6 distance,
|
||||
FT_F26Dot6 compensation );
|
||||
|
||||
/* Point displacement along the freedom vector routine */
|
||||
typedef void (*TT_Move_Func)( EXEC_OP_ TT_GlyphZone* zone,
|
||||
FT_UInt point,
|
||||
FT_F26Dot6 distance );
|
||||
|
||||
/* Distance projection along one of the projection vectors */
|
||||
typedef FT_F26Dot6 (*TT_Project_Func)( EXEC_OP_ FT_Vector* v1,
|
||||
FT_Vector* v2 );
|
||||
|
||||
/* reading a cvt value. Take care of non-square pixels if necessary */
|
||||
typedef FT_F26Dot6 (*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong index );
|
||||
|
||||
/* setting or moving a cvt value. Take care of non-square pixels */
|
||||
/* if necessary */
|
||||
typedef void (*TT_Set_CVT_Func)( EXEC_OP_ FT_ULong index,
|
||||
FT_F26Dot6 value );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This structure defines a call record, used to manage function calls. */
|
||||
/* */
|
||||
typedef struct TT_CallRec_
|
||||
{
|
||||
FT_Int Caller_Range;
|
||||
FT_Long Caller_IP;
|
||||
FT_Long Cur_Count;
|
||||
FT_Long Cur_Restart;
|
||||
|
||||
} TT_CallRec, *TT_CallStack;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The main structure for the interpreter which collects all necessary */
|
||||
/* variables and states. */
|
||||
/* */
|
||||
typedef struct TT_ExecContextRec_
|
||||
{
|
||||
TT_Face face;
|
||||
TT_Size size;
|
||||
FT_Memory memory;
|
||||
|
||||
/* instructions state */
|
||||
|
||||
FT_Error error; /* last execution error */
|
||||
|
||||
FT_Long top; /* top of exec. stack */
|
||||
|
||||
FT_UInt stackSize; /* size of exec. stack */
|
||||
FT_Long* stack; /* current exec. stack */
|
||||
|
||||
FT_Long args;
|
||||
FT_UInt new_top; /* new top after exec. */
|
||||
|
||||
TT_GlyphZone zp0, /* zone records */
|
||||
zp1,
|
||||
zp2,
|
||||
pts,
|
||||
twilight;
|
||||
|
||||
FT_Size_Metrics metrics;
|
||||
TT_Size_Metrics tt_metrics; /* size metrics */
|
||||
|
||||
TT_GraphicsState GS; /* current graphics state */
|
||||
|
||||
FT_Int curRange; /* current code range number */
|
||||
FT_Byte* code; /* current code range */
|
||||
FT_Long IP; /* current instruction pointer */
|
||||
FT_Long codeSize; /* size of current range */
|
||||
|
||||
FT_Byte opcode; /* current opcode */
|
||||
FT_Int length; /* length of current opcode */
|
||||
|
||||
FT_Bool step_ins; /* true if the interpreter must */
|
||||
/* increment IP after ins. exec */
|
||||
FT_Long cvtSize;
|
||||
FT_Long* cvt;
|
||||
|
||||
FT_UInt glyphSize; /* glyph instructions buffer size */
|
||||
FT_Byte* glyphIns; /* glyph instructions buffer */
|
||||
|
||||
FT_UInt numFDefs; /* number of function defs */
|
||||
FT_UInt maxFDefs; /* maximum number of function defs */
|
||||
TT_DefArray FDefs; /* table of FDefs entries */
|
||||
|
||||
FT_UInt numIDefs; /* number of instruction defs */
|
||||
FT_UInt maxIDefs; /* maximum number of ins defs */
|
||||
TT_DefArray IDefs; /* table of IDefs entries */
|
||||
|
||||
FT_UInt maxFunc; /* maximum function index */
|
||||
FT_UInt maxIns; /* maximum instruction index */
|
||||
|
||||
FT_Int callTop, /* top of call stack during execution */
|
||||
callSize; /* size of call stack */
|
||||
TT_CallStack callStack; /* call stack */
|
||||
|
||||
FT_UShort maxPoints; /* capacity of this context's `pts' */
|
||||
FT_Short maxContours; /* record, expressed in points and */
|
||||
/* contours. */
|
||||
|
||||
TT_CodeRangeTable codeRangeTable; /* table of valid code ranges */
|
||||
/* useful for the debugger */
|
||||
|
||||
FT_UShort storeSize; /* size of current storage */
|
||||
FT_Long* storage; /* storage area */
|
||||
|
||||
FT_F26Dot6 period; /* values used for the */
|
||||
FT_F26Dot6 phase; /* `SuperRounding' */
|
||||
FT_F26Dot6 threshold;
|
||||
|
||||
#if 0
|
||||
/* this seems to be unused */
|
||||
FT_Int cur_ppem; /* ppem along the current proj vector */
|
||||
#endif
|
||||
|
||||
FT_Bool instruction_trap; /* If `True', the interpreter will */
|
||||
/* exit after each instruction */
|
||||
|
||||
TT_GraphicsState default_GS; /* graphics state resulting from */
|
||||
/* the prep program */
|
||||
FT_Bool is_composite; /* true if the glyph is composite */
|
||||
FT_Bool pedantic_hinting; /* true for pedantic interpretation */
|
||||
|
||||
/* latest interpreter additions */
|
||||
|
||||
FT_Long F_dot_P; /* dot product of freedom and projection */
|
||||
/* vectors */
|
||||
TT_Round_Func func_round; /* current rounding function */
|
||||
|
||||
TT_Project_Func func_project, /* current projection function */
|
||||
func_dualproj, /* current dual proj. function */
|
||||
func_freeProj; /* current freedom proj. func */
|
||||
|
||||
TT_Move_Func func_move; /* current point move function */
|
||||
|
||||
TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
|
||||
TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
|
||||
TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
|
||||
|
||||
FT_ULong loadSize;
|
||||
TT_SubGlyph_Stack loadStack; /* loading subglyph stack */
|
||||
|
||||
} TT_ExecContextRec;
|
||||
|
||||
|
||||
extern const TT_GraphicsState tt_default_graphics_state;
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Goto_CodeRange( TT_ExecContext exec,
|
||||
FT_Int range,
|
||||
FT_Long IP );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Set_CodeRange( TT_ExecContext exec,
|
||||
FT_Int range,
|
||||
void* base,
|
||||
FT_Long length );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Clear_CodeRange( TT_ExecContext exec,
|
||||
FT_Int range );
|
||||
|
||||
FT_EXPORT_DEF( TT_ExecContext ) TT_New_Context( TT_Face face );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Done_Context( TT_ExecContext exec );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Destroy_Context( TT_ExecContext exec,
|
||||
FT_Memory memory );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Context( TT_ExecContext exec,
|
||||
TT_Face face,
|
||||
TT_Size size );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Save_Context( TT_ExecContext exec,
|
||||
TT_Size ins );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Run_Context( TT_ExecContext exec,
|
||||
FT_Bool debug );
|
||||
|
||||
FT_EXPORT_DEF( FT_Error ) TT_RunIns( TT_ExecContext exec );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TTINTERP_H */
|
||||
|
||||
|
||||
/* END */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,132 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttload.h */
|
||||
/* */
|
||||
/* Load the basic TrueType tables, i.e., tables that can be either in */
|
||||
/* TTF or OTF 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 TTLOAD_H
|
||||
#define TTLOAD_H
|
||||
|
||||
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/tttypes.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
TT_Table* TT_LookUp_Table( TT_Face face,
|
||||
FT_ULong tag );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Goto_Table( TT_Face face,
|
||||
FT_ULong tag,
|
||||
FT_Stream stream,
|
||||
FT_ULong* length );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_SFNT_Header( TT_Face face,
|
||||
FT_Stream stream,
|
||||
FT_Long face_index,
|
||||
SFNT_Header* sfnt );
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Directory( TT_Face face,
|
||||
FT_Stream stream,
|
||||
SFNT_Header* sfnt );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Any( TT_Face face,
|
||||
FT_ULong tag,
|
||||
FT_Long offset,
|
||||
FT_Byte* buffer,
|
||||
FT_ULong* length );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Header( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Metrics_Header( TT_Face face,
|
||||
FT_Stream stream,
|
||||
FT_Bool vertical );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_CMap( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_MaxProfile( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Names( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_OS2( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_PostScript( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Hdmx( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_PCLT( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
LOCAL_DEF
|
||||
void TT_Free_Names( TT_Face face );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
void TT_Free_Hdmx ( TT_Face face );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Kern( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Load_Gasp( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* TTLOAD_H */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -1,734 +0,0 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttobjs.c */
|
||||
/* */
|
||||
/* 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/ttnameid.h>
|
||||
#include <freetype/tttags.h>
|
||||
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/internal/psnames.h>
|
||||
|
||||
|
||||
#ifdef FT_FLAT_COMPILE
|
||||
|
||||
#include "ttgload.h"
|
||||
#include "ttpload.h"
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
#include "ttinterp.h"
|
||||
#endif
|
||||
|
||||
#else /* FT_FLAT_COMPILE */
|
||||
|
||||
#include <truetype/ttgload.h>
|
||||
#include <truetype/ttpload.h>
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
#include <truetype/ttinterp.h>
|
||||
#endif
|
||||
|
||||
#endif /* FT_FLAT_COMPILE */
|
||||
|
||||
|
||||
#include <freetype/internal/tterrors.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_ttobjs
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* GLYPH ZONE FUNCTIONS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Done_GlyphZone */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Deallocates a glyph zone. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* zone :: A pointer to the target glyph zone. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void TT_Done_GlyphZone( TT_GlyphZone* zone )
|
||||
{
|
||||
FT_Memory memory = zone->memory;
|
||||
|
||||
|
||||
FREE( zone->contours );
|
||||
FREE( zone->tags );
|
||||
FREE( zone->cur );
|
||||
FREE( zone->org );
|
||||
|
||||
zone->max_points = zone->n_points = 0;
|
||||
zone->max_contours = zone->n_contours = 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_New_GlyphZone */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Allocates a new glyph zone. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A handle to the current memory object. */
|
||||
/* */
|
||||
/* maxPoints :: The capacity of glyph zone in points. */
|
||||
/* */
|
||||
/* maxContours :: The capacity of glyph zone in contours. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* zone :: A pointer to the target glyph zone record. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error TT_New_GlyphZone( FT_Memory memory,
|
||||
FT_UShort maxPoints,
|
||||
FT_Short maxContours,
|
||||
TT_GlyphZone* zone )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( maxPoints > 0 )
|
||||
maxPoints += 2;
|
||||
|
||||
MEM_Set( zone, 0, sizeof ( *zone ) );
|
||||
zone->memory = memory;
|
||||
|
||||
if ( ALLOC_ARRAY( zone->org, maxPoints * 2, FT_F26Dot6 ) ||
|
||||
ALLOC_ARRAY( zone->cur, maxPoints * 2, FT_F26Dot6 ) ||
|
||||
ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) ||
|
||||
ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) )
|
||||
{
|
||||
TT_Done_GlyphZone( zone );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Init_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given TrueType 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 TT_Init_Face( FT_Stream stream,
|
||||
TT_Face face,
|
||||
FT_Int face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Library library;
|
||||
SFNT_Interface* sfnt;
|
||||
|
||||
|
||||
library = face->root.driver->root.library;
|
||||
sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
|
||||
if ( !sfnt )
|
||||
goto Bad_Format;
|
||||
|
||||
/* create input stream from resource */
|
||||
if ( FILE_Seek( 0 ) )
|
||||
goto Exit;
|
||||
|
||||
/* check that we have a valid TrueType file */
|
||||
error = sfnt->init_face( stream, face, face_index, num_params, params );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
/* We must also be able to accept Mac/GX fonts, as well as OT ones */
|
||||
if ( face->format_tag != 0x00010000L && /* MS fonts */
|
||||
face->format_tag != TTAG_true ) /* Mac fonts */
|
||||
{
|
||||
FT_TRACE2(( "[not a valid TTF font]\n" ));
|
||||
goto Bad_Format;
|
||||
}
|
||||
|
||||
/* If we are performing a simple font format check, exit immediately */
|
||||
if ( face_index < 0 )
|
||||
return TT_Err_Ok;
|
||||
|
||||
/* Load font directory */
|
||||
error = sfnt->load_face( stream, face, face_index, num_params, params );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
error = TT_Load_Locations( face, stream ) ||
|
||||
TT_Load_CVT ( face, stream ) ||
|
||||
TT_Load_Programs ( face, stream );
|
||||
|
||||
/* initialize standard glyph loading routines */
|
||||
TT_Init_Glyph_Loading( face );
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
|
||||
Bad_Format:
|
||||
error = FT_Err_Unknown_File_Format;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Done_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A pointer to the face object to destroy. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
void TT_Done_Face( TT_Face face )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Stream stream = face->root.stream;
|
||||
|
||||
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
|
||||
|
||||
|
||||
/* for `extended TrueType formats' (i.e. compressed versions) */
|
||||
if ( face->extra.finalizer )
|
||||
face->extra.finalizer( face->extra.data );
|
||||
|
||||
if ( sfnt )
|
||||
sfnt->done_face( face );
|
||||
|
||||
/* freeing the locations table */
|
||||
FREE( face->glyph_locations );
|
||||
face->num_locations = 0;
|
||||
|
||||
/* freeing the CVT */
|
||||
FREE( face->cvt );
|
||||
face->cvt_size = 0;
|
||||
|
||||
/* freeing the programs */
|
||||
RELEASE_Frame( face->font_program );
|
||||
RELEASE_Frame( face->cvt_program );
|
||||
face->font_program_size = 0;
|
||||
face->cvt_program_size = 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* SIZE FUNCTIONS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Init_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a new TrueType size object. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* size :: A handle to the size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Init_Size( TT_Size size )
|
||||
{
|
||||
FT_Error error = TT_Err_Ok;
|
||||
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
|
||||
TT_Face face = (TT_Face)size->root.face;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Int i;
|
||||
|
||||
TT_ExecContext exec;
|
||||
FT_UShort n_twilight;
|
||||
TT_MaxProfile* maxp = &face->max_profile;
|
||||
|
||||
|
||||
size->ttmetrics.valid = FALSE;
|
||||
|
||||
size->max_function_defs = maxp->maxFunctionDefs;
|
||||
size->max_instruction_defs = maxp->maxInstructionDefs;
|
||||
|
||||
size->num_function_defs = 0;
|
||||
size->num_instruction_defs = 0;
|
||||
|
||||
size->max_func = 0;
|
||||
size->max_ins = 0;
|
||||
|
||||
size->cvt_size = face->cvt_size;
|
||||
size->storage_size = maxp->maxStorage;
|
||||
|
||||
/* Set default metrics */
|
||||
{
|
||||
FT_Size_Metrics* metrics = &size->root.metrics;
|
||||
TT_Size_Metrics* metrics2 = &size->ttmetrics;
|
||||
|
||||
|
||||
metrics->x_ppem = 0;
|
||||
metrics->y_ppem = 0;
|
||||
|
||||
metrics2->rotated = FALSE;
|
||||
metrics2->stretched = FALSE;
|
||||
|
||||
/* set default compensation (all 0) */
|
||||
for ( i = 0; i < 4; i++ )
|
||||
metrics2->compensations[i] = 0;
|
||||
}
|
||||
|
||||
/* allocate function defs, instruction defs, cvt, and storage area */
|
||||
if ( ALLOC_ARRAY( size->function_defs,
|
||||
size->max_function_defs,
|
||||
TT_DefRecord ) ||
|
||||
|
||||
ALLOC_ARRAY( size->instruction_defs,
|
||||
size->max_instruction_defs,
|
||||
TT_DefRecord ) ||
|
||||
|
||||
ALLOC_ARRAY( size->cvt,
|
||||
size->cvt_size, FT_Long ) ||
|
||||
|
||||
ALLOC_ARRAY( size->storage,
|
||||
size->storage_size, FT_Long ) )
|
||||
|
||||
goto Fail_Memory;
|
||||
|
||||
/* reserve twilight zone */
|
||||
n_twilight = maxp->maxTwilightPoints;
|
||||
error = TT_New_GlyphZone( memory, n_twilight, 0, &size->twilight );
|
||||
if ( error )
|
||||
goto Fail_Memory;
|
||||
|
||||
size->twilight.n_points = n_twilight;
|
||||
|
||||
/* set `face->interpreter' according to the debug hook present */
|
||||
{
|
||||
FT_Library library = face->root.driver->root.library;
|
||||
|
||||
|
||||
face->interpreter = (TT_Interpreter)
|
||||
library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
|
||||
if ( !face->interpreter )
|
||||
face->interpreter = (TT_Interpreter)TT_RunIns;
|
||||
}
|
||||
|
||||
/* Fine, now execute the font program! */
|
||||
exec = size->context;
|
||||
/* size objects used during debugging have their own context */
|
||||
if ( !size->debug )
|
||||
exec = TT_New_Context( face );
|
||||
|
||||
if ( !exec )
|
||||
{
|
||||
error = TT_Err_Could_Not_Find_Context;
|
||||
goto Fail_Memory;
|
||||
}
|
||||
|
||||
size->GS = tt_default_graphics_state;
|
||||
TT_Load_Context( exec, face, size );
|
||||
|
||||
exec->callTop = 0;
|
||||
exec->top = 0;
|
||||
|
||||
exec->period = 64;
|
||||
exec->phase = 0;
|
||||
exec->threshold = 0;
|
||||
|
||||
{
|
||||
FT_Size_Metrics* metrics = &exec->metrics;
|
||||
TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
|
||||
|
||||
|
||||
metrics->x_ppem = 0;
|
||||
metrics->y_ppem = 0;
|
||||
metrics->x_scale = 0;
|
||||
metrics->y_scale = 0;
|
||||
|
||||
tt_metrics->ppem = 0;
|
||||
tt_metrics->scale = 0;
|
||||
tt_metrics->ratio = 0x10000L;
|
||||
}
|
||||
|
||||
exec->instruction_trap = FALSE;
|
||||
|
||||
exec->cvtSize = size->cvt_size;
|
||||
exec->cvt = size->cvt;
|
||||
|
||||
exec->F_dot_P = 0x10000L;
|
||||
|
||||
/* allow font program execution */
|
||||
TT_Set_CodeRange( exec,
|
||||
tt_coderange_font,
|
||||
face->font_program,
|
||||
face->font_program_size );
|
||||
|
||||
/* disable CVT and glyph programs coderange */
|
||||
TT_Clear_CodeRange( exec, tt_coderange_cvt );
|
||||
TT_Clear_CodeRange( exec, tt_coderange_glyph );
|
||||
|
||||
if ( face->font_program_size > 0 )
|
||||
{
|
||||
error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
|
||||
if ( !error )
|
||||
error = face->interpreter( exec );
|
||||
|
||||
if ( error )
|
||||
goto Fail_Exec;
|
||||
}
|
||||
else
|
||||
error = TT_Err_Ok;
|
||||
|
||||
TT_Save_Context( exec, size );
|
||||
|
||||
if ( !size->debug )
|
||||
TT_Done_Context( exec );
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
|
||||
|
||||
size->ttmetrics.valid = FALSE;
|
||||
return error;
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
|
||||
Fail_Exec:
|
||||
if ( !size->debug )
|
||||
TT_Done_Context( exec );
|
||||
|
||||
Fail_Memory:
|
||||
|
||||
#endif
|
||||
|
||||
TT_Done_Size( size );
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Done_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The TrueType size object finalizer. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void TT_Done_Size( TT_Size size )
|
||||
{
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
|
||||
FT_Memory memory = size->root.face->memory;
|
||||
|
||||
|
||||
if ( size->debug )
|
||||
{
|
||||
/* the debug context must be deleted by the debugger itself */
|
||||
size->context = NULL;
|
||||
size->debug = FALSE;
|
||||
}
|
||||
|
||||
FREE( size->cvt );
|
||||
size->cvt_size = 0;
|
||||
|
||||
/* free storage area */
|
||||
FREE( size->storage );
|
||||
size->storage_size = 0;
|
||||
|
||||
/* twilight zone */
|
||||
TT_Done_GlyphZone( &size->twilight );
|
||||
|
||||
FREE( size->function_defs );
|
||||
FREE( size->instruction_defs );
|
||||
|
||||
size->num_function_defs = 0;
|
||||
size->max_function_defs = 0;
|
||||
size->num_instruction_defs = 0;
|
||||
size->max_instruction_defs = 0;
|
||||
|
||||
size->max_func = 0;
|
||||
size->max_ins = 0;
|
||||
|
||||
#endif
|
||||
|
||||
size->ttmetrics.valid = FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Reset_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Resets a TrueType size when resolutions and character dimensions */
|
||||
/* have been changed. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* size :: A handle to the target size object. */
|
||||
/* */
|
||||
LOCAL_DEF
|
||||
FT_Error TT_Reset_Size( TT_Size size )
|
||||
{
|
||||
TT_Face face;
|
||||
FT_Error error = TT_Err_Ok;
|
||||
|
||||
FT_Size_Metrics* metrics;
|
||||
|
||||
|
||||
if ( size->ttmetrics.valid )
|
||||
return TT_Err_Ok;
|
||||
|
||||
face = (TT_Face)size->root.face;
|
||||
|
||||
metrics = &size->root.metrics;
|
||||
|
||||
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
|
||||
return TT_Err_Invalid_PPem;
|
||||
|
||||
/* compute new transformation */
|
||||
if ( metrics->x_ppem >= metrics->y_ppem )
|
||||
{
|
||||
size->ttmetrics.scale = metrics->x_scale;
|
||||
size->ttmetrics.ppem = metrics->x_ppem;
|
||||
size->ttmetrics.x_ratio = 0x10000L;
|
||||
size->ttmetrics.y_ratio = FT_MulDiv( metrics->y_ppem,
|
||||
0x10000L,
|
||||
metrics->x_ppem );
|
||||
}
|
||||
else
|
||||
{
|
||||
size->ttmetrics.scale = metrics->y_scale;
|
||||
size->ttmetrics.ppem = metrics->y_ppem;
|
||||
size->ttmetrics.x_ratio = FT_MulDiv( metrics->x_ppem,
|
||||
0x10000L,
|
||||
metrics->y_ppem );
|
||||
size->ttmetrics.y_ratio = 0x10000L;
|
||||
}
|
||||
|
||||
/* Compute root ascender, descender, test height, and max_advance */
|
||||
metrics->ascender = ( FT_MulFix( face->root.ascender,
|
||||
metrics->y_scale ) + 32 ) & -64;
|
||||
metrics->descender = ( FT_MulFix( face->root.descender,
|
||||
metrics->y_scale ) + 32 ) & -64;
|
||||
metrics->height = ( FT_MulFix( face->root.height,
|
||||
metrics->y_scale ) + 32 ) & -64;
|
||||
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
|
||||
metrics->x_scale ) + 32 ) & -64;
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
|
||||
{
|
||||
TT_ExecContext exec;
|
||||
FT_UInt i, j;
|
||||
|
||||
|
||||
/* Scale the cvt values to the new ppem. */
|
||||
/* We use by default the y ppem to scale the CVT. */
|
||||
for ( i = 0; i < size->cvt_size; i++ )
|
||||
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
|
||||
|
||||
/* All twilight points are originally zero */
|
||||
for ( j = 0; j < size->twilight.n_points; j++ )
|
||||
{
|
||||
size->twilight.org[j].x = 0;
|
||||
size->twilight.org[j].y = 0;
|
||||
size->twilight.cur[j].x = 0;
|
||||
size->twilight.cur[j].y = 0;
|
||||
}
|
||||
|
||||
/* clear storage area */
|
||||
for ( i = 0; i < size->storage_size; i++ )
|
||||
size->storage[i] = 0;
|
||||
|
||||
size->GS = tt_default_graphics_state;
|
||||
|
||||
/* get execution context and run prep program */
|
||||
if ( size->debug )
|
||||
exec = size->context;
|
||||
else
|
||||
exec = TT_New_Context( face );
|
||||
/* debugging instances have their own context */
|
||||
|
||||
if ( !exec )
|
||||
return TT_Err_Could_Not_Find_Context;
|
||||
|
||||
TT_Load_Context( exec, face, size );
|
||||
|
||||
TT_Set_CodeRange( exec,
|
||||
tt_coderange_cvt,
|
||||
face->cvt_program,
|
||||
face->cvt_program_size );
|
||||
|
||||
TT_Clear_CodeRange( exec, tt_coderange_glyph );
|
||||
|
||||
exec->instruction_trap = FALSE;
|
||||
|
||||
exec->top = 0;
|
||||
exec->callTop = 0;
|
||||
|
||||
if ( face->cvt_program_size > 0 )
|
||||
{
|
||||
error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
|
||||
if ( error )
|
||||
goto End;
|
||||
|
||||
if ( !size->debug )
|
||||
error = face->interpreter( exec );
|
||||
}
|
||||
else
|
||||
error = TT_Err_Ok;
|
||||
|
||||
size->GS = exec->GS;
|
||||
/* save default graphics state */
|
||||
|
||||
End:
|
||||
TT_Save_Context( exec, size );
|
||||
|
||||
if ( !size->debug )
|
||||
TT_Done_Context( exec );
|
||||
/* debugging instances keep their context */
|
||||
}
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
|
||||
|
||||
if ( !error )
|
||||
size->ttmetrics.valid = TRUE;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Init_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initializes a given TrueType driver object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target driver object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
FT_Error TT_Init_Driver( TT_Driver driver )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
/* set `extra' in glyph loader */
|
||||
error = FT_GlyphLoader_Create_Extra( FT_DRIVER( driver )->glyph_loader );
|
||||
|
||||
/* init extension registry if needed */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
if ( !error )
|
||||
return TT_Init_Extensions( driver );
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* TT_Done_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Finalizes a given TrueType driver. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* driver :: A handle to the target TrueType driver. */
|
||||
/* */
|
||||
LOCAL_FUNC
|
||||
void TT_Done_Driver( TT_Driver driver )
|
||||
{
|
||||
/* destroy extensions registry if needed */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
|
||||
|
||||
TT_Done_Extensions( driver );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
|
||||
/* destroy the execution context */
|
||||
if ( driver->context )
|
||||
{
|
||||
TT_Destroy_Context( driver->context, driver->root.root.memory );
|
||||
driver->context = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user