From: Robert Roebling Date: Sun, 13 Jan 2002 14:48:49 +0000 (+0000) Subject: Remove more FreeType. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6cfacd2b8a47c604056674a968dc71eed9ba7f05?ds=inline Remove more FreeType. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13539 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/freetype/autohint/CatharonLicense.txt b/src/freetype/autohint/CatharonLicense.txt deleted file mode 100644 index e68bc23050..0000000000 --- a/src/freetype/autohint/CatharonLicense.txt +++ /dev/null @@ -1,123 +0,0 @@ - The Catharon Open Source LICENSE - ---------------------------- - - 2000-Jul-04 - - Copyright (C) 2000 by Catharon Productions, Inc. - - - -Introduction -============ - - This license applies to source files distributed by Catharon - Productions, Inc. in several archive packages. This license - applies to all files found in such packages which do not fall - under their own explicit license. - - This license was inspired by the BSD, Artistic, and IJG - (Independent JPEG Group) licenses, which all encourage inclusion - and use of free software in commercial and freeware products - alike. As a consequence, its main points are that: - - o We don't promise that this software works. However, we are - interested in any kind of bug reports. (`as is' distribution) - - o You can use this software for whatever you want, in parts or - full form, without having to pay us. (`royalty-free' usage) - - o You may not pretend that you wrote this software. If you use - it, or only parts of it, in a program, you must acknowledge - somewhere in your documentation that you have used the - Catharon Code. (`credits') - - We specifically permit and encourage the inclusion of this - software, with or without modifications, in commercial products. - We disclaim all warranties covering the packages distributed by - Catharon Productions, Inc. and assume no liability related to - their use. - - -Legal Terms -=========== - -0. Definitions --------------- - - Throughout this license, the terms `Catharon Package', `package', - and `Catharon Code' refer to the set of files originally - distributed by Catharon Productions, Inc. - - `You' refers to the licensee, or person using the project, where - `using' is a generic term including compiling the project's source - code as well as linking it to form a `program' or `executable'. - This program is referred to as `a program using one of the - Catharon Packages'. - - This license applies to all files distributed in the original - Catharon Package(s), including all source code, binaries and - documentation, unless otherwise stated in the file in its - original, unmodified form as distributed in the original archive. - If you are unsure whether or not a particular file is covered by - this license, you must contact us to verify this. - - The Catharon Packages are copyright (C) 2000 by Catharon - Productions, Inc. All rights reserved except as specified below. - -1. No Warranty --------------- - - THE CATHARON PACKAGES ARE PROVIDED `AS IS' WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OF OR THE INABILITY TO - USE THE CATHARON PACKAGE. - -2. Redistribution ------------------ - - This license grants a worldwide, royalty-free, perpetual and - irrevocable right and license to use, execute, perform, compile, - display, copy, create derivative works of, distribute and - sublicense the Catharon Packages (in both source and object code - forms) and derivative works thereof for any purpose; and to - authorize others to exercise some or all of the rights granted - herein, subject to the following conditions: - - o Redistribution of source code must retain this license file - (`license.txt') unaltered; any additions, deletions or changes - to the original files must be clearly indicated in - accompanying documentation. The copyright notices of the - unaltered, original files must be preserved in all copies of - source files. - - o Redistribution in binary form must provide a disclaimer that - states that the software is based in part on the work of - Catharon Productions, Inc. in the distribution documentation. - - These conditions apply to any software derived from or based on - the Catharon Packages, not just the unmodified files. If you use - our work, you must acknowledge us. However, no fee need be paid - to us. - -3. Advertising --------------- - - Neither Catharon Productions, Inc. and contributors nor you shall - use the name of the other for commercial, advertising, or - promotional purposes without specific prior written permission. - - We suggest, but do not require, that you use the following phrase - to refer to this software in your documentation: 'this software is - based in part on the Catharon Typography Project'. - - As you have not signed this license, you are not required to - accept it. However, as the Catharon Packages are copyrighted - material, only this license, or another one contracted with the - authors, grants you the right to use, distribute, and modify it. - Therefore, by using, distributing, or modifying the Catharon - Packages, you indicate that you understand and accept all the - terms of this license. - ---- end of license.txt --- diff --git a/src/freetype/autohint/ahangles.c b/src/freetype/autohint/ahangles.c deleted file mode 100644 index 2f759edd5c..0000000000 --- a/src/freetype/autohint/ahangles.c +++ /dev/null @@ -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 - -#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 */ diff --git a/src/freetype/autohint/ahangles.h b/src/freetype/autohint/ahangles.h deleted file mode 100644 index 4eb36bf4d2..0000000000 --- a/src/freetype/autohint/ahangles.h +++ /dev/null @@ -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 - -#endif - - -#include - - - /* 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 */ diff --git a/src/freetype/autohint/ahglobal.c b/src/freetype/autohint/ahglobal.c deleted file mode 100644 index 892ca86174..0000000000 --- a/src/freetype/autohint/ahglobal.c +++ /dev/null @@ -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 -#include - -#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 */ diff --git a/src/freetype/autohint/ahglobal.h b/src/freetype/autohint/ahglobal.h deleted file mode 100644 index 79e73586f9..0000000000 --- a/src/freetype/autohint/ahglobal.h +++ /dev/null @@ -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 - -#endif - - -#include /* 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 */ diff --git a/src/freetype/autohint/ahglyph.c b/src/freetype/autohint/ahglyph.c deleted file mode 100644 index 348ee8e32d..0000000000 --- a/src/freetype/autohint/ahglyph.c +++ /dev/null @@ -1,1299 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahglyph.c */ -/* */ -/* Routines used to load and analyze a given glyph before hinting */ -/* (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 "ahglyph.h" -#include "ahangles.h" -#include "ahglobal.h" - -#else - -#include -#include -#include - -#endif - - -#include - - -#define xxxAH_DEBUG_GLYPH - - - /* compute the direction value of a given vector.. */ - static - AH_Direction ah_compute_direction( FT_Pos dx, - FT_Pos dy ) - { - AH_Direction dir; - FT_Pos ax = ABS( dx ); - FT_Pos ay = ABS( dy ); - - - dir = ah_dir_none; - - /* test for vertical direction */ - if ( ax * 12 < ay ) - { - dir = dy > 0 ? ah_dir_up : ah_dir_down; - } - /* test for horizontal direction */ - else if ( ay * 12 < ax ) - { - dir = dx > 0 ? ah_dir_right : ah_dir_left; - } - - return dir; - } - - - /*************************************************************************/ - /* */ - /* */ - /* ah_outline_new */ - /* */ - /* */ - /* Creates a new and empty AH_Outline object. */ - /* */ - LOCAL_FUNC - FT_Error ah_outline_new( FT_Memory memory, - AH_Outline** aoutline ) - { - FT_Error error; - AH_Outline* outline; - - - if ( !ALLOC( outline, sizeof ( *outline ) ) ) - { - outline->memory = memory; - *aoutline = outline; - } - - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* ah_outline_done */ - /* */ - /* */ - /* Destroys a given AH_Outline object. */ - /* */ - LOCAL_FUNC - void ah_outline_done( AH_Outline* outline ) - { - FT_Memory memory = outline->memory; - - - FREE( outline->horz_edges ); - FREE( outline->horz_segments ); - FREE( outline->contours ); - FREE( outline->points ); - - FREE( outline ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* ah_outline_save */ - /* */ - /* */ - /* Saves the content of a given AH_Outline object into a face's glyph */ - /* slot. */ - /* */ - LOCAL_FUNC - void ah_outline_save( AH_Outline* outline, - AH_Loader* gloader ) - { - AH_Point* point = outline->points; - AH_Point* limit = point + outline->num_points; - FT_Vector* vec = gloader->current.outline.points; - char* tag = gloader->current.outline.tags; - - - /* we assume that the glyph loader has already been checked for storage */ - for ( ; point < limit; point++, vec++, tag++ ) - { - vec->x = point->x; - vec->y = point->y; - - if ( point->flags & ah_flah_conic ) - tag[0] = FT_Curve_Tag_Conic; - else if ( point->flags & ah_flah_cubic ) - tag[0] = FT_Curve_Tag_Cubic; - else - tag[0] = FT_Curve_Tag_On; - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* ah_outline_load */ - /* */ - /* */ - /* Loads an unscaled outline from a glyph slot into an AH_Outline */ - /* object. */ - /* */ - LOCAL_FUNC - FT_Error ah_outline_load( AH_Outline* outline, - FT_Face face ) - { - FT_Memory memory = outline->memory; - FT_Error error = FT_Err_Ok; - FT_Outline* source = &face->glyph->outline; - FT_Int num_points = source->n_points; - FT_Int num_contours = source->n_contours; - AH_Point* points; - - - /* check arguments */ - if ( !face || - !face->size || - face->glyph->format != ft_glyph_format_outline ) - return FT_Err_Invalid_Argument; - - /* first of all, reallocate the contours array if necessary */ - if ( num_contours > outline->max_contours ) - { - FT_Int new_contours = ( num_contours + 3 ) & -4; - - - if ( REALLOC_ARRAY( outline->contours, outline->max_contours, - new_contours, AH_Point* ) ) - goto Exit; - - outline->max_contours = new_contours; - } - - /* then, realloc the points, segments & edges arrays if needed */ - if ( num_points > outline->max_points ) - { - FT_Int news = ( num_points + 7 ) & -8; - FT_Int max = outline->max_points; - - - if ( REALLOC_ARRAY( outline->points, max, news, AH_Point ) || - REALLOC_ARRAY( outline->horz_edges, max, news, AH_Edge ) || - REALLOC_ARRAY( outline->horz_segments, max, news, AH_Segment ) ) - goto Exit; - - /* readjust some pointers */ - outline->vert_edges = outline->horz_edges + ( news >> 1 ); - outline->vert_segments = outline->horz_segments + ( news >> 1 ); - outline->max_points = news; - } - - outline->num_points = num_points; - outline->num_contours = num_contours; - - outline->num_hedges = 0; - outline->num_vedges = 0; - outline->num_hsegments = 0; - outline->num_vsegments = 0; - - /* Compute the vertical and horizontal major directions; this is */ - /* currently done by inspecting the `ft_outline_reverse_fill' flag. */ - /* However, some fonts have improper glyphs, and it'd be a good idea */ - /* to be able to re-compute these values on the fly. */ - outline->vert_major_dir = ah_dir_up; - outline->horz_major_dir = ah_dir_left; - - if ( source->flags & ft_outline_reverse_fill ) - { - outline->vert_major_dir = ah_dir_down; - outline->horz_major_dir = ah_dir_right; - } - - outline->x_scale = face->size->metrics.x_scale; - outline->y_scale = face->size->metrics.y_scale; - - points = outline->points; - - { - /* do one thing at a time -- it is easier to understand, and */ - /* the code is clearer */ - AH_Point* point = points; - AH_Point* limit = point + outline->num_points; - - - /* compute coordinates */ - { - FT_Vector* vec = source->points; - FT_Fixed x_scale = outline->x_scale; - FT_Fixed y_scale = outline->y_scale; - - - for (; point < limit; vec++, point++ ) - { - point->fx = vec->x; - point->fy = vec->y; - point->ox = point->x = FT_MulFix( vec->x, x_scale ); - point->oy = point->y = FT_MulFix( vec->y, y_scale ); - - point->flags = 0; - } - } - - /* compute Bezier flags */ - { - char* tag = source->tags; - - - for ( point = points; point < limit; point++, tag++ ) - { - switch ( FT_CURVE_TAG( *tag ) ) - { - case FT_Curve_Tag_Conic: - point->flags = ah_flah_conic; break; - case FT_Curve_Tag_Cubic: - point->flags = ah_flah_cubic; break; - default: - ; - } - } - } - - /* compute `next' and `prev' */ - { - FT_Int contour_index; - AH_Point* prev; - AH_Point* first; - AH_Point* end; - - - contour_index = 0; - - first = points; - end = points + source->contours[0]; - prev = end; - - for ( point = points; point < limit; point++ ) - { - point->prev = prev; - if ( point < end ) - { - point->next = point + 1; - prev = point; - } - else - { - point->next = first; - contour_index++; - if ( point + 1 < limit ) - { - end = points + source->contours[contour_index]; - first = point + 1; - prev = end; - } - } - } - } - - /* set-up the contours array */ - { - AH_Point** contour = outline->contours; - AH_Point** limit = contour + outline->num_contours; - short* end = source->contours; - short index = 0; - - - for ( ; contour < limit; contour++, end++ ) - { - contour[0] = points + index; - index = end[0] + 1; - } - } - - /* compute directions of in & out vectors */ - { - for ( point = points; point < limit; point++ ) - { - AH_Point* prev; - AH_Point* next; - FT_Vector vec; - - - prev = point->prev; - vec.x = point->fx - prev->fx; - vec.y = point->fy - prev->fy; - - point->in_dir = ah_compute_direction( vec.x, vec.y ); - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - point->in_angle = ah_angle( &vec ); -#endif - - next = point->next; - vec.x = next->fx - point->fx; - vec.y = next->fy - point->fy; - - point->out_dir = ah_compute_direction( vec.x, vec.y ); - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - point->out_angle = ah_angle( &vec ); - - { - AH_Angle delta = point->in_angle - point->out_angle; - - - if ( delta < 0 ) - delta = -delta; - if ( delta < 2 ) - point->flags |= ah_flah_weak_interpolation; - } - -#if 0 - if ( point->flags & ( ah_flah_conic | ah_flah_cubic ) ) - point->flags |= ah_flah_weak_interpolation; -#endif - -#endif /* !AH_OPTION_NO_WEAK_INTERPOLATION */ - -#ifdef AH_OPTION_NO_STRONG_INTERPOLATION - point->flags |= ah_flah_weak_interpolation; -#endif - } - } - } - - Exit: - return error; - } - - - LOCAL_FUNC - void ah_setup_uv( AH_Outline* outline, - AH_UV source ) - { - AH_Point* point = outline->points; - AH_Point* limit = point + outline->num_points; - - - for ( ; point < limit; point++ ) - { - FT_Pos u, v; - - - switch ( source ) - { - case ah_uv_fxy: - u = point->fx; - v = point->fy; - break; - case ah_uv_fyx: - u = point->fy; - v = point->fx; - break; - case ah_uv_oxy: - u = point->ox; - v = point->oy; - break; - case ah_uv_oyx: - u = point->oy; - v = point->ox; - break; - case ah_uv_yx: - u = point->y; - v = point->x; - break; - case ah_uv_ox: - u = point->x; - v = point->ox; - break; - case ah_uv_oy: - u = point->y; - v = point->oy; - break; - default: - u = point->x; - v = point->y; - break; - } - point->u = u; - point->v = v; - } - } - - - LOCAL_FUNC - void ah_outline_compute_segments( AH_Outline* outline ) - { - int dimension; - AH_Segment* segments; - FT_Int* p_num_segments; - AH_Direction segment_dir; - AH_Direction major_dir; - - - segments = outline->horz_segments; - p_num_segments = &outline->num_hsegments; - major_dir = ah_dir_right; /* This value must be positive! */ - segment_dir = major_dir; - - /* set up (u,v) in each point */ - ah_setup_uv( outline, ah_uv_fyx ); - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Point** contour = outline->contours; - AH_Point** contour_limit = contour + outline->num_contours; - AH_Segment* segment = segments; - FT_Int num_segments = 0; - -#ifdef AH_HINT_METRICS - AH_Point* min_point = 0; - AH_Point* max_point = 0; - FT_Pos min_coord = 32000; - FT_Pos max_coord = -32000; -#endif - - - /* do each contour separately */ - for ( ; contour < contour_limit; contour++ ) - { - AH_Point* point = contour[0]; - AH_Point* last = point->prev; - int on_edge = 0; - FT_Pos min_pos = +32000; /* minimum segment pos != min_coord */ - FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */ - FT_Bool passed; - - -#ifdef AH_HINT_METRICS - if ( point->u < min_coord ) - { - min_coord = point->u; - min_point = point; - } - if ( point->u > max_coord ) - { - max_coord = point->u; - max_point = point; - } -#endif - - if ( point == last ) /* skip singletons -- just in case? */ - continue; - - if ( ABS( last->out_dir ) == major_dir && - ABS( point->out_dir ) == major_dir ) - { - /* we are already on an edge, try to locate its start */ - last = point; - - for (;;) - { - point = point->prev; - if ( ABS( point->out_dir ) != major_dir ) - { - point = point->next; - break; - } - if ( point == last ) - break; - } - - } - - last = point; - passed = 0; - - for (;;) - { - FT_Pos u, v; - - - if ( on_edge ) - { - u = point->u; - if ( u < min_pos ) - min_pos = u; - if ( u > max_pos ) - max_pos = u; - - if ( point->out_dir != segment_dir || point == last ) - { - /* we are just leaving an edge; record a new segment! */ - segment->last = point; - segment->pos = ( min_pos + max_pos ) >> 1; - - /* a segment is round if either its first or last point */ - /* is a control point */ - if ( ( segment->first->flags | point->flags ) & - ah_flah_control ) - segment->flags |= ah_edge_round; - - /* compute segment size */ - min_pos = max_pos = point->v; - - v = segment->first->v; - if ( v < min_pos ) - min_pos = v; - if ( v > max_pos ) - max_pos = v; - - segment->min_coord = min_pos; - segment->max_coord = max_pos; - - on_edge = 0; - num_segments++; - segment++; - /* fallthrough */ - } - } - - /* now exit if we are at the start/end point */ - if ( point == last ) - { - if ( passed ) - break; - passed = 1; - } - - if ( !on_edge && ABS( point->out_dir ) == major_dir ) - { - /* this is the start of a new segment! */ - segment_dir = point->out_dir; - - /* clear all segment fields */ - memset( segment, 0, sizeof ( *segment ) ); - - segment->dir = segment_dir; - segment->flags = ah_edge_normal; - min_pos = max_pos = point->u; - segment->first = point; - segment->last = point; - segment->contour = contour; - on_edge = 1; - - if ( point == max_point ) - max_point = 0; - - if ( point == min_point ) - min_point = 0; - } - - point = point->next; - } - - } /* contours */ - -#ifdef AH_HINT_METRICS - /* we need to ensure that there are edges on the left-most and */ - /* right-most points of the glyph in order to hint the metrics; */ - /* we do this by inserting fake segments when needed */ - if ( dimension == 0 ) - { - AH_Point* point = outline->points; - AH_Point* limit = point + outline->num_points; - - AH_Point* min_point = 0; - AH_Point* max_point = 0; - FT_Pos min_pos = 32000; - FT_Pos max_pos = -32000; - - - /* compute minimum and maximum points */ - for ( ; point < limit; point++ ) - { - FT_Pos x = point->fx; - - - if ( x < min_pos ) - { - min_pos = x; - min_point = point; - } - if ( x > max_pos ) - { - max_pos = x; - max_point = point; - } - } - - /* insert minimum segment */ - if ( min_point ) - { - /* clear all segment fields */ - memset( segment, 0, sizeof ( *segment ) ); - - segment->dir = segment_dir; - segment->flags = ah_edge_normal; - segment->first = min_point; - segment->last = min_point; - segment->pos = min_pos; - - num_segments++; - segment++; - } - - /* insert maximum segment */ - if ( max_point ) - { - /* clear all segment fields */ - memset( segment, 0, sizeof ( *segment ) ); - - segment->dir = segment_dir; - segment->flags = ah_edge_normal; - segment->first = max_point; - segment->last = max_point; - segment->pos = max_pos; - - num_segments++; - segment++; - } - } -#endif /* AH_HINT_METRICS */ - - *p_num_segments = num_segments; - - segments = outline->vert_segments; - major_dir = ah_dir_up; - p_num_segments = &outline->num_vsegments; - ah_setup_uv( outline, ah_uv_fxy ); - } - } - - - LOCAL_FUNC - void ah_outline_link_segments( AH_Outline* outline ) - { - AH_Segment* segments; - AH_Segment* limit; - int dimension; - - - ah_setup_uv( outline, ah_uv_fyx ); - - segments = outline->horz_segments; - limit = segments + outline->num_hsegments; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Segment* seg1; - AH_Segment* seg2; - - - /* now compare each segment to the others */ - for ( seg1 = segments; seg1 < limit; seg1++ ) - { - FT_Pos best_score = 32000; - AH_Segment* best_segment = 0; - - - /* the fake segments are introduced to hint the metrics -- */ - /* we must never link them to anything */ - if ( seg1->first == seg1->last ) - continue; - - for ( seg2 = segments; seg2 < limit; seg2++ ) - if ( seg1 != seg2 && seg1->dir + seg2->dir == 0 ) - { - FT_Pos pos1 = seg1->pos; - FT_Pos pos2 = seg2->pos; - FT_Bool is_dir; - FT_Bool is_pos; - - - /* check that the segments are correctly oriented and */ - /* positioned to form a black distance */ - - is_dir = ( seg1->dir == outline->horz_major_dir || - seg1->dir == outline->vert_major_dir ); - is_pos = pos1 > pos2; - - if ( pos1 == pos2 || !(is_dir ^ is_pos) ) - continue; - - /* Check the two segments. We now have a better algorithm */ - /* that doesn't rely on the segment points themselves but */ - /* on their relative position. This gets rids of many */ - /* unpleasant artefacts and incorrect stem/serifs */ - /* computations. */ - - /* first of all, compute the size of the `common' height */ - { - FT_Pos min = seg1->min_coord; - FT_Pos max = seg1->max_coord; - FT_Pos len, score; - FT_Pos size1, size2; - - - size1 = max - min; - size2 = seg2->max_coord - seg2->min_coord; - - if ( min < seg2->min_coord ) - min = seg2->min_coord; - - if ( max < seg2->max_coord ) - max = seg2->max_coord; - - len = max - min; - score = seg2->pos - seg1->pos; - if ( score < 0 ) - score = -score; - - /* before comparing the scores, take care that the segments */ - /* are really facing each other (often not for italics..) */ - if ( 4 * len >= size1 && 4 * len >= size2 ) - if ( score < best_score ) - { - best_score = score; - best_segment = seg2; - } - } - } - - if ( best_segment ) - { - seg1->link = best_segment; - seg1->score = best_score; - - best_segment->num_linked++; - } - - - } /* edges 1 */ - - /* now, compute the `serif' segments */ - for ( seg1 = segments; seg1 < limit; seg1++ ) - { - seg2 = seg1->link; - - if ( seg2 && seg2->link != seg1 ) - { - seg1->link = 0; - seg1->serif = seg2->link; - } - } - - ah_setup_uv( outline, ah_uv_fxy ); - - segments = outline->vert_segments; - limit = segments + outline->num_vsegments; - } - } - - -#ifdef AH_DEBUG_GLYPH - - /* A function used to dump the array of linked segments */ - void ah_dump_segments( AH_Outline* outline ) - { - AH_Segment* segments; - AH_Segment* limit; - AH_Point* points; - FT_Int dimension; - - - points = outline->points; - segments = outline->horz_segments; - limit = segments + outline->num_hsegments; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Segment* seg; - - - printf ( "Table of %s segments:\n", - !dimension ? "vertical" : "horizontal" ); - printf ( " [ index | pos | dir | link | serif |" - " numl | first | start ]\n" ); - - for ( seg = segments; seg < limit; seg++ ) - { - printf ( " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n", - seg - segments, - (int)seg->pos, - seg->dir == ah_dir_up - ? "up" - : ( seg->dir == ah_dir_down - ? "down" - : ( seg->dir == ah_dir_left - ? "left" - : ( seg->dir == ah_dir_right - ? "right" - : "none" ) ) ), - seg->link ? (seg->link-segments) : -1, - seg->serif ? (seg->serif-segments) : -1, - (int)seg->num_linked, - seg->first - points, - seg->last - points ); - } - - segments = outline->vert_segments; - limit = segments + outline->num_vsegments; - } - } - -#endif /* AH_DEBUG_GLYPH */ - - - static - void ah_outline_compute_edges( AH_Outline* outline ) - { - AH_Edge* edges; - AH_Segment* segments; - AH_Segment* segment_limit; - AH_Direction up_dir; - FT_Int* p_num_edges; - FT_Int dimension; - FT_Fixed scale; - FT_Pos edge_distance_threshold; - - - edges = outline->horz_edges; - segments = outline->horz_segments; - segment_limit = segments + outline->num_hsegments; - p_num_edges = &outline->num_hedges; - up_dir = ah_dir_right; - scale = outline->y_scale; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge* edge; - AH_Edge* edge_limit; /* really == edge + num_edges */ - AH_Segment* seg; - - - /*********************************************************************/ - /* */ - /* We will begin by generating a sorted table of edges for the */ - /* current direction. To do so, we simply scan each segment and try */ - /* to find an edge in our table that corresponds to its position. */ - /* */ - /* If no edge is found, we create and insert a new edge in the */ - /* sorted table. Otherwise, we simply add the segment to the edge's */ - /* list which will be processed in the second step to compute the */ - /* edge's properties. */ - /* */ - /* Note that the edges table is sorted along the segment/edge */ - /* position. */ - /* */ - /*********************************************************************/ - - edge_distance_threshold = FT_MulFix( outline->edge_distance_threshold, - scale ); - if ( edge_distance_threshold > 64 / 4 ) - edge_distance_threshold = 64 / 4; - - edge_limit = edges; - for ( seg = segments; seg < segment_limit; seg++ ) - { - AH_Edge* found = 0; - - - /* look for an edge corresponding to the segment */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - FT_Pos dist; - - - dist = seg->pos - edge->fpos; - if ( dist < 0 ) - dist = -dist; - - dist = FT_MulFix( dist, scale ); - if ( dist < edge_distance_threshold ) - { - found = edge; - break; - } - } - - if ( !found ) - { - /* insert a new edge in the list and */ - /* sort according to the position */ - while ( edge > edges && edge[-1].fpos > seg->pos ) - { - edge[0] = edge[-1]; - edge--; - } - edge_limit++; - - /* clear all edge fields */ - memset( edge, 0, sizeof ( *edge ) ); - - /* add the segment to the new edge's list */ - edge->first = seg; - edge->last = seg; - edge->fpos = seg->pos; - edge->opos = edge->pos = FT_MulFix( seg->pos, scale ); - seg->edge_next = seg; - } - else - { - /* if an edge was found, simply add the segment to the edge's */ - /* list */ - seg->edge_next = edge->first; - edge->last->edge_next = seg; - edge->last = seg; - } - } - - *p_num_edges = edge_limit - edges; - - - /*********************************************************************/ - /* */ - /* Good, we will now compute each edge's properties according to */ - /* segments found on its position. Basically, these are: */ - /* */ - /* - edge's main direction */ - /* - stem edge, serif edge or both (which defaults to stem then) */ - /* - rounded edge, straigth or both (which defaults to straight) */ - /* - link for edge */ - /* */ - /*********************************************************************/ - - /* first of all, set the `edge' field in each segment -- this is */ - /* required in order to compute edge links */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - seg = edge->first; - if ( seg ) - do - { - seg->edge = edge; - seg = seg->edge_next; - } - while ( seg != edge->first ); - } - - /* now, compute each edge properties */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - int is_round = 0; /* does it contain round segments? */ - int is_straight = 0; /* does it contain straight segments? */ - int ups = 0; /* number of upwards segments */ - int downs = 0; /* number of downwards segments */ - - - seg = edge->first; - - do - { - FT_Bool is_serif; - - - /* check for roundness of segment */ - if ( seg->flags & ah_edge_round ) - is_round++; - else - is_straight++; - - /* check for segment direction */ - if ( seg->dir == up_dir ) - ups += seg->max_coord-seg->min_coord; - else - downs += seg->max_coord-seg->min_coord; - - /* check for links -- if seg->serif is set, then seg->link must */ - /* be ignored */ - is_serif = seg->serif && seg->serif->edge != edge; - - if ( seg->link || is_serif ) - { - AH_Edge* edge2; - AH_Segment* seg2; - - - edge2 = edge->link; - seg2 = seg->link; - - if ( is_serif ) - { - seg2 = seg->serif; - edge2 = edge->serif; - } - - if ( edge2 ) - { - FT_Pos edge_delta; - FT_Pos seg_delta; - - - edge_delta = edge->fpos - edge2->fpos; - if ( edge_delta < 0 ) - edge_delta = -edge_delta; - - seg_delta = seg->pos - seg2->pos; - if ( seg_delta < 0 ) - seg_delta = -seg_delta; - - if ( seg_delta < edge_delta ) - edge2 = seg2->edge; - } - else - edge2 = seg2->edge; - - if ( is_serif ) - edge->serif = edge2; - else - edge->link = edge2; - } - - seg = seg->edge_next; - - } while ( seg != edge->first ); - - /* set the round/straight flags */ - edge->flags = ah_edge_normal; - - if ( is_straight == 0 && is_round ) - edge->flags |= ah_edge_round; - - /* set the edge's main direction */ - edge->dir = ah_dir_none; - - if ( ups > downs ) - edge->dir = up_dir; - - else if ( ups < downs ) - edge->dir = - up_dir; - - else if ( ups == downs ) - edge->dir = 0; /* both up and down !! */ - - /* gets rid of serifs if link is set */ - /* XXX: This gets rid of many unpleasant artefacts! */ - /* Example: the `c' in cour.pfa at size 13 */ - - if ( edge->serif && edge->link ) - edge->serif = 0; - } - - edges = outline->vert_edges; - segments = outline->vert_segments; - segment_limit = segments + outline->num_vsegments; - p_num_edges = &outline->num_vedges; - up_dir = ah_dir_up; - scale = outline->x_scale; - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* ah_outline_detect_features */ - /* */ - /* */ - /* Performs feature detection on a given AH_Outline object. */ - /* */ - LOCAL_FUNC - void ah_outline_detect_features( AH_Outline* outline ) - { - ah_outline_compute_segments( outline ); - ah_outline_link_segments ( outline ); - ah_outline_compute_edges ( outline ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* ah_outline_compute_blue_edges */ - /* */ - /* */ - /* Computes the `blue edges' in a given outline (i.e. those that must */ - /* be snapped to a blue zone edge (top or bottom). */ - /* */ - LOCAL_FUNC - void ah_outline_compute_blue_edges( AH_Outline* outline, - AH_Face_Globals* face_globals ) - { - AH_Edge* edge = outline->horz_edges; - AH_Edge* limit = edge + outline->num_hedges; - AH_Globals* globals = &face_globals->design; - FT_Fixed y_scale = outline->y_scale; - - - /* compute for each horizontal edge, which blue zone is closer */ - for ( ; edge < limit; edge++ ) - { - AH_Blue blue; - FT_Pos* best_blue = 0; - FT_Pos best_dist; /* initial threshold */ - - - /* compute the initial threshold as a fraction of the EM size */ - best_dist = FT_MulFix( face_globals->face->units_per_EM / 40, y_scale ); - if ( best_dist > 64 / 4 ) - best_dist = 64 / 4; - - for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ ) - { - /* if it is a top zone, check for right edges -- if it is a bottom */ - /* zone, check for left edges */ - /* */ - /* of course, that's for TrueType XXX */ - FT_Bool is_top_blue = AH_IS_TOP_BLUE( blue ); - FT_Bool is_major_dir = edge->dir == outline->horz_major_dir; - - - /* if it is a top zone, the edge must be against the major */ - /* direction; if it is a bottom zone, it must be in the major */ - /* direction */ - if ( is_top_blue ^ is_major_dir ) - { - FT_Pos dist; - FT_Pos* blue_pos = globals->blue_refs + blue; - - - /* first of all, compare it to the reference position */ - dist = edge->fpos - *blue_pos; - if ( dist < 0 ) - dist = -dist; - - dist = FT_MulFix( dist, y_scale ); - if ( dist < best_dist ) - { - best_dist = dist; - best_blue = blue_pos; - } - - /* now, compare it to the overshoot position if the edge is */ - /* rounded, and if the edge is over the reference position of a */ - /* top zone, or under the reference position of a bottom zone */ - if ( edge->flags & ah_edge_round && dist != 0 ) - { - FT_Bool is_under_ref = edge->fpos < *blue_pos; - - - if ( is_top_blue ^ is_under_ref ) - { - blue_pos = globals->blue_shoots + blue; - dist = edge->fpos - *blue_pos; - if ( dist < 0 ) - dist = -dist; - - dist = FT_MulFix( dist, y_scale ); - if ( dist < best_dist ) - { - best_dist = dist; - best_blue = blue_pos; - } - } - } - } - } - - if ( best_blue ) - edge->blue_edge = best_blue; - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* ah_outline_scale_blue_edges */ - /* */ - /* */ - /* This functions must be called before hinting in order to re-adjust */ - /* the contents of the detected edges (basically change the `blue */ - /* edge' pointer from `design units' to `scaled ones'). */ - /* */ - LOCAL_FUNC - void ah_outline_scale_blue_edges( AH_Outline* outline, - AH_Face_Globals* globals ) - { - AH_Edge* edge = outline->horz_edges; - AH_Edge* limit = edge + outline->num_hedges; - FT_Int delta; - - - delta = globals->scaled.blue_refs - globals->design.blue_refs; - - for ( ; edge < limit; edge++ ) - { - if ( edge->blue_edge ) - edge->blue_edge += delta; - } - } - - -#ifdef AH_DEBUG_GLYPH - - void ah_dump_edges( AH_Outline* outline ) - { - AH_Edge* edges; - AH_Edge* limit; - AH_Segment* segments; - FT_Int dimension; - - - edges = outline->horz_edges; - limit = edges + outline->num_hedges; - segments = outline->horz_segments; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge* edge; - - - printf ( "Table of %s edges:\n", - !dimension ? "vertical" : "horizontal" ); - printf ( " [ index | pos | dir | link |" - " serif | blue | opos | pos ]\n" ); - - for ( edge = edges; edge < limit; edge++ ) - { - printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n", - edge - edges, - (int)edge->fpos, - edge->dir == ah_dir_up - ? "up" - : ( edge->dir == ah_dir_down - ? "down" - : ( edge->dir == ah_dir_left - ? "left" - : ( edge->dir == ah_dir_right - ? "right" - : "none" ) ) ), - edge->link ? ( edge->link - edges ) : -1, - edge->serif ? ( edge->serif - edges ) : -1, - edge->blue_edge ? 'y' : 'n', - edge->opos / 64.0, - edge->pos / 64.0 ); - } - - edges = outline->vert_edges; - limit = edges + outline->num_vedges; - segments = outline->vert_segments; - } - } - -#endif /* AH_DEBUG_GLYPH */ - - -/* END */ diff --git a/src/freetype/autohint/ahglyph.h b/src/freetype/autohint/ahglyph.h deleted file mode 100644 index 66fd5e3155..0000000000 --- a/src/freetype/autohint/ahglyph.h +++ /dev/null @@ -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 - -#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 */ diff --git a/src/freetype/autohint/ahhint.c b/src/freetype/autohint/ahhint.c deleted file mode 100644 index f50f8839de..0000000000 --- a/src/freetype/autohint/ahhint.c +++ /dev/null @@ -1,1398 +0,0 @@ -/***************************************************************************/ -/* */ -/* ahhint.c */ -/* */ -/* Glyph hinter (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 "ahhint.h" -#include "ahglyph.h" -#include "ahangles.h" - -#else - -#include -#include -#include - -#endif - -#include - - -#define FACE_GLOBALS( face ) ((AH_Face_Globals*)(face)->autohint.data) - -#define AH_USE_IUP - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** Hinting routines ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - static int disable_horz_edges = 0; - static int disable_vert_edges = 0; - - - /* snap a given width in scaled coordinates to one of the */ - /* current standard widths */ - static - FT_Pos ah_snap_width( FT_Pos* widths, - FT_Int count, - FT_Pos width ) - { - int n; - FT_Pos best = 64 + 32 + 2; - FT_Pos reference = width; - - - for ( n = 0; n < count; n++ ) - { - FT_Pos w; - FT_Pos dist; - - - w = widths[n]; - dist = width - w; - if ( dist < 0 ) - dist = -dist; - if ( dist < best ) - { - best = dist; - reference = w; - } - } - - if ( width >= reference ) - { - width -= 0x21; - if ( width < reference ) - width = reference; - } - else - { - width += 0x21; - if ( width > reference ) - width = reference; - } - - return width; - } - - - /* align one stem edge relative to the previous stem edge */ - static - void ah_align_linked_edge( AH_Hinter* hinter, - AH_Edge* base_edge, - AH_Edge* stem_edge, - int vertical ) - { - FT_Pos dist = stem_edge->opos - base_edge->opos; - AH_Globals* globals = &hinter->globals->scaled; - FT_Pos sign = 1; - - - if ( dist < 0 ) - { - dist = -dist; - sign = -1; - } - - if ( vertical ) - { - dist = ah_snap_width( globals->heights, globals->num_heights, dist ); - - /* in the case of vertical hinting, always round */ - /* the stem heights to integer pixels */ - if ( dist >= 64 ) - dist = ( dist + 16 ) & -64; - else - dist = 64; - } - else - { - dist = ah_snap_width( globals->widths, globals->num_widths, dist ); - - if ( hinter->flags & ah_hinter_monochrome ) - { - /* monochrome horizontal hinting: snap widths to integer pixels */ - /* with a different threshold */ - if ( dist < 64 ) - dist = 64; - else - dist = ( dist + 32 ) & -64; - } - else - { - /* for horizontal anti-aliased hinting, we adopt a more subtle */ - /* approach: we strengthen small stems, round stems whose size */ - /* is between 1 and 2 pixels to an integer, otherwise nothing */ - if ( dist < 48 ) - dist = ( dist + 64 ) >> 1; - - else if ( dist < 128 ) - dist = ( dist + 42 ) & -64; - } - } - - stem_edge->pos = base_edge->pos + sign * dist; - } - - - static - void ah_align_serif_edge( AH_Hinter* hinter, - AH_Edge* base, - AH_Edge* serif ) - { - FT_Pos dist; - FT_Pos sign = 1; - - UNUSED( hinter ); - - - dist = serif->opos - base->opos; - if ( dist < 0 ) - { - dist = -dist; - sign = -1; - } - - /* do not strengthen serifs */ - if ( base->flags & ah_edge_done ) - { - if ( dist > 64 ) - dist = ( dist + 16 ) & -64; - - else if ( dist <= 32 ) - dist = ( dist + 33 ) >> 1; - } - - serif->pos = base->pos + sign * dist; - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** E D G E H I N T I N G ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* Another alternative edge hinting algorithm */ - static - void ah_hint_edges_3( AH_Hinter* hinter ) - { - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Outline* outline = hinter->glyph; - FT_Int dimension; - - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge* edge; - AH_Edge* before = 0; - AH_Edge* after = 0; - AH_Edge* anchor = 0; - int has_serifs = 0; - - - if ( disable_vert_edges && !dimension ) - goto Next_Dimension; - - if ( disable_horz_edges && dimension ) - goto Next_Dimension; - - /* we begin by aligning all stems relative to the blue zone */ - /* if needed -- that's only for horizontal edges */ - if ( dimension ) - { - for ( edge = edges; edge < edge_limit; edge++ ) - { - FT_Pos* blue; - AH_Edge *edge1, *edge2; - - - if ( edge->flags & ah_edge_done ) - continue; - - blue = edge->blue_edge; - edge1 = 0; - edge2 = edge->link; - - if ( blue ) - { - edge1 = edge; - } - else if (edge2 && edge2->blue_edge) - { - blue = edge2->blue_edge; - edge1 = edge2; - edge2 = edge; - } - - if ( !edge1 ) - continue; - - edge1->pos = blue[0]; - edge1->flags |= ah_edge_done; - - if ( edge2 && !edge2->blue_edge ) - { - ah_align_linked_edge( hinter, edge1, edge2, dimension ); - edge2->flags |= ah_edge_done; - } - - if ( !anchor ) - anchor = edge; - } - } - - /* now, we will align all stem edges, trying to maintain the */ - /* relative order of stems in the glyph.. */ - before = 0; - after = 0; - for ( edge = edges; edge < edge_limit; edge++ ) - { - AH_Edge *edge2; - - - if ( edge->flags & ah_edge_done ) - continue; - - /* skip all non-stem edges */ - edge2 = edge->link; - if ( !edge2 ) - { - has_serifs++; - continue; - } - - /* now, align the stem */ - - /* this should not happen, but it's better to be safe.. */ - if ( edge2->blue_edge || edge2 < edge ) - { - -#if 0 - printf( "strange blue alignement, edge %d to %d\n", - edge - edges, edge2 - edges ); -#endif - - ah_align_linked_edge( hinter, edge2, edge, dimension ); - edge->flags |= ah_edge_done; - continue; - } - - { - FT_Bool min = 0; - FT_Pos delta; - - if ( !anchor ) - { - edge->pos = ( edge->opos + 32 ) & -64; - anchor = edge; - } - else - edge->pos = anchor->pos + - ( ( edge->opos - anchor->opos + 32 ) & -64 ); - - edge->flags |= ah_edge_done; - - if ( edge > edges && edge->pos < edge[-1].pos ) - { - edge->pos = edge[-1].pos; - min = 1; - } - - ah_align_linked_edge( hinter, edge, edge2, dimension ); - delta = 0; - if ( edge2 + 1 < edge_limit && - edge2[1].flags & ah_edge_done ) - delta = edge2[1].pos - edge2->pos; - - if ( delta < 0 ) - { - edge2->pos += delta; - if ( !min ) - edge->pos += delta; - } - edge2->flags |= ah_edge_done; - } - } - - if ( !has_serifs ) - goto Next_Dimension; - - /* now, hint the remaining edges (serifs and single) in order */ - /* to complete our processing */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - if ( edge->flags & ah_edge_done ) - continue; - - if ( edge->serif ) - { - ah_align_serif_edge( hinter, edge->serif, edge ); - } - else if ( !anchor ) - { - edge->pos = ( edge->opos + 32 ) & -64; - anchor = edge; - } - else - edge->pos = anchor->pos + - ( ( edge->opos-anchor->opos + 32 ) & -64 ); - - edge->flags |= ah_edge_done; - - if ( edge > edges && edge->pos < edge[-1].pos ) - edge->pos = edge[-1].pos; - - if ( edge + 1 < edge_limit && - edge[1].flags & ah_edge_done && - edge->pos > edge[1].pos ) - edge->pos = edge[1].pos; - } - - Next_Dimension: - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - } - } - - - LOCAL_FUNC - void ah_hinter_hint_edges( AH_Hinter* hinter, - int no_horz_edges, - int no_vert_edges ) - { - disable_horz_edges = no_horz_edges; - disable_vert_edges = no_vert_edges; - - /* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */ - /* reduce the problem of the disappearing eye in the `e' of Times... */ - /* also, creates some artifacts near the blue zones? */ - { - ah_hint_edges_3( hinter ); - -#if 0 - /* outline optimizer removed temporarily */ - if ( hinter->flags & ah_hinter_optimize ) - { - AH_Optimizer opt; - - - if ( !AH_Optimizer_Init( &opt, hinter->glyph, hinter->memory ) ) - { - AH_Optimizer_Compute( &opt ); - AH_Optimizer_Done( &opt ); - } - } -#endif - - } - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** P O I N T H I N T I N G ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - static - void ah_hinter_align_edge_points( AH_Hinter* hinter ) - { - AH_Outline* outline = hinter->glyph; - AH_Edge* edges; - AH_Edge* edge_limit; - FT_Int dimension; - - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Edge* edge; - AH_Edge* before; - AH_Edge* after; - - - before = 0; - after = 0; - - edge = edges; - for ( ; edge < edge_limit; edge++ ) - { - /* move the points of each segment */ - /* in each edge to the edge's position */ - AH_Segment* seg = edge->first; - - - do - { - AH_Point* point = seg->first; - - - for (;;) - { - if ( dimension ) - { - point->y = edge->pos; - point->flags |= ah_flah_touch_y; - } - else - { - point->x = edge->pos; - point->flags |= ah_flah_touch_x; - } - - if ( point == seg->last ) - break; - - point = point->next; - } - - seg = seg->edge_next; - - } while ( seg != edge->first ); - } - - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - } - } - - - /* hint the strong points -- this is equivalent to the TrueType `IP' */ - static - void ah_hinter_align_strong_points( AH_Hinter* hinter ) - { - AH_Outline* outline = hinter->glyph; - FT_Int dimension; - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Point* points; - AH_Point* point_limit; - AH_Flags touch_flag; - - - points = outline->points; - point_limit = points + outline->num_points; - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - touch_flag = ah_flah_touch_y; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Point* point; - AH_Edge* edge; - AH_Edge* before; - AH_Edge* after; - - - before = 0; - after = 0; - - if ( edges < edge_limit ) - for ( point = points; point < point_limit; point++ ) - { - FT_Pos u, ou, fu; /* point position */ - FT_Pos delta; - - - if ( point->flags & touch_flag ) - continue; - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - /* if this point is candidate to weak interpolation, we will */ - /* interpolate it after all strong points have been processed */ - if ( point->flags & ah_flah_weak_interpolation ) - continue; -#endif - - if ( dimension ) - { - u = point->fy; - ou = point->oy; - } - else - { - u = point->fx; - ou = point->ox; - } - - fu = u; - - /* is the point before the first edge? */ - edge = edges; - delta = edge->fpos - u; - if ( delta >= 0 ) - { - u = edge->pos - ( edge->opos - ou ); - goto Store_Point; - } - - /* is the point after the last edge ? */ - edge = edge_limit - 1; - delta = u - edge->fpos; - if ( delta >= 0 ) - { - u = edge->pos + ( ou - edge->opos ); - goto Store_Point; - } - - /* otherwise, interpolate the point in between */ - { - AH_Edge* before = 0; - AH_Edge* after = 0; - - - for ( edge = edges; edge < edge_limit; edge++ ) - { - if ( u == edge->fpos ) - { - u = edge->pos; - goto Store_Point; - } - if ( u < edge->fpos ) - break; - before = edge; - } - - for ( edge = edge_limit - 1; edge >= edges; edge-- ) - { - if ( u == edge->fpos ) - { - u = edge->pos; - goto Store_Point; - } - if ( u > edge->fpos ) - break; - after = edge; - } - - /* assert( before && after && before != after ) */ - u = before->pos + FT_MulDiv( fu - before->fpos, - after->pos - before->pos, - after->fpos - before->fpos ); - } - - Store_Point: - - /* save the point position */ - if ( dimension ) - point->y = u; - else - point->x = u; - - point->flags |= touch_flag; - } - - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - touch_flag = ah_flah_touch_x; - } - } - - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - - static - void ah_iup_shift( AH_Point* p1, - AH_Point* p2, - AH_Point* ref ) - { - AH_Point* p; - FT_Pos delta = ref->u - ref->v; - - - for ( p = p1; p < ref; p++ ) - p->u = p->v + delta; - - for ( p = ref + 1; p <= p2; p++ ) - p->u = p->v + delta; - } - - - static - void ah_iup_interp( AH_Point* p1, - AH_Point* p2, - AH_Point* ref1, - AH_Point* ref2 ) - { - AH_Point* p; - FT_Pos u; - FT_Pos v1 = ref1->v; - FT_Pos v2 = ref2->v; - FT_Pos d1 = ref1->u - v1; - FT_Pos d2 = ref2->u - v2; - - - if ( p1 > p2 ) - return; - - if ( v1 == v2 ) - { - for ( p = p1; p <= p2; p++ ) - { - FT_Pos u = p->v; - - - if ( u <= v1 ) - u += d1; - else - u += d2; - - p->u = u; - } - return; - } - - if ( v1 < v2 ) - { - for ( p = p1; p <= p2; p++ ) - { - u = p->v; - - if ( u <= v1 ) - u += d1; - else if ( u >= v2 ) - u += d2; - else - u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 ); - - p->u = u; - } - } - else - { - for ( p = p1; p <= p2; p++ ) - { - u = p->v; - - if ( u <= v2 ) - u += d2; - else if ( u >= v1 ) - u += d1; - else - u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 ); - - p->u = u; - } - } - } - - - /* interpolate weak points -- this is equivalent to the TrueType `IUP' */ - static - void ah_hinter_align_weak_points( AH_Hinter* hinter ) - { - AH_Outline* outline = hinter->glyph; - FT_Int dimension; - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Point* points; - AH_Point* point_limit; - AH_Point** contour_limit; - AH_Flags touch_flag; - - - points = outline->points; - point_limit = points + outline->num_points; - - /* PASS 1: Move segment points to edge positions */ - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - touch_flag = ah_flah_touch_y; - - contour_limit = outline->contours + outline->num_contours; - - ah_setup_uv( outline, ah_uv_oy ); - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Point* point; - AH_Point* end_point; - AH_Point* first_point; - AH_Point** contour; - - - point = points; - contour = outline->contours; - - for ( ; contour < contour_limit; contour++ ) - { - point = *contour; - end_point = point->prev; - first_point = point; - - while ( point <= end_point && !( point->flags & touch_flag ) ) - point++; - - if ( point <= end_point ) - { - AH_Point* first_touched = point; - AH_Point* cur_touched = point; - - - point++; - while ( point <= end_point ) - { - if ( point->flags & touch_flag ) - { - /* we found two successive touched points; we interpolate */ - /* all contour points between them */ - ah_iup_interp( cur_touched + 1, point - 1, - cur_touched, point ); - cur_touched = point; - } - point++; - } - - if ( cur_touched == first_touched ) - { - /* this is a special case: only one point was touched in the */ - /* contour; we thus simply shift the whole contour */ - ah_iup_shift( first_point, end_point, cur_touched ); - } - else - { - /* now interpolate after the last touched point to the end */ - /* of the contour */ - ah_iup_interp( cur_touched + 1, end_point, - cur_touched, first_touched ); - - /* if the first contour point isn't touched, interpolate */ - /* from the contour start to the first touched point */ - if ( first_touched > points ) - ah_iup_interp( first_point, first_touched - 1, - cur_touched, first_touched ); - } - } - } - - /* now save the interpolated values back to x/y */ - if ( dimension ) - { - for ( point = points; point < point_limit; point++ ) - point->y = point->u; - - touch_flag = ah_flah_touch_x; - ah_setup_uv( outline, ah_uv_ox ); - } - else - { - for ( point = points; point < point_limit; point++ ) - point->x = point->u; - - break; /* exit loop */ - } - } - } - -#endif /* !AH_OPTION_NO_WEAK_INTERPOLATION */ - - - LOCAL_FUNC - void ah_hinter_align_points( AH_Hinter* hinter ) - { - ah_hinter_align_edge_points( hinter ); - -#ifndef AH_OPTION_NO_STRONG_INTERPOLATION - ah_hinter_align_strong_points( hinter ); -#endif - -#ifndef AH_OPTION_NO_WEAK_INTERPOLATION - ah_hinter_align_weak_points( hinter ); -#endif - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** H I N T E R O B J E C T M E T H O D S ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* scale and fit the global metrics */ - static - void ah_hinter_scale_globals( AH_Hinter* hinter, - FT_Fixed x_scale, - FT_Fixed y_scale ) - { - FT_Int n; - AH_Face_Globals* globals = hinter->globals; - AH_Globals* design = &globals->design; - AH_Globals* scaled = &globals->scaled; - - - /* copy content */ - *scaled = *design; - - /* scale the standard widths & heights */ - for ( n = 0; n < design->num_widths; n++ ) - scaled->widths[n] = FT_MulFix( design->widths[n], x_scale ); - - for ( n = 0; n < design->num_heights; n++ ) - scaled->heights[n] = FT_MulFix( design->heights[n], y_scale ); - - /* scale the blue zones */ - for ( n = 0; n < ah_blue_max; n++ ) - { - FT_Pos delta, delta2; - - - delta = design->blue_shoots[n] - design->blue_refs[n]; - delta2 = delta; - if ( delta < 0 ) - delta2 = -delta2; - delta2 = FT_MulFix( delta2, y_scale ); - - if ( delta2 < 32 ) - delta2 = 0; - else if ( delta2 < 64 ) - delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & -32 ); - else - delta2 = ( delta2 + 32 ) & -64; - - if ( delta < 0 ) - delta2 = -delta2; - - scaled->blue_refs[n] = - ( FT_MulFix( design->blue_refs[n], y_scale ) + 32 ) & -64; - scaled->blue_shoots[n] = scaled->blue_refs[n] + delta2; - } - - globals->x_scale = x_scale; - globals->y_scale = y_scale; - } - - - static - void ah_hinter_align( AH_Hinter* hinter ) - { - ah_hinter_align_edge_points( hinter ); - ah_hinter_align_points( hinter ); - } - - - /* finalize a hinter object */ - void ah_hinter_done( AH_Hinter* hinter ) - { - if ( hinter ) - { - FT_Memory memory = hinter->memory; - - - ah_loader_done( hinter->loader ); - ah_outline_done( hinter->glyph ); - - /* note: the `globals' pointer is _not_ owned by the hinter */ - /* but by the current face object, we don't need to */ - /* release it */ - hinter->globals = 0; - hinter->face = 0; - - FREE( hinter ); - } - } - - - /* create a new empty hinter object */ - FT_Error ah_hinter_new( FT_Library library, - AH_Hinter** ahinter ) - { - AH_Hinter* hinter = 0; - FT_Memory memory = library->memory; - FT_Error error; - - - *ahinter = 0; - - /* allocate object */ - if ( ALLOC( hinter, sizeof ( *hinter ) ) ) - goto Exit; - - hinter->memory = memory; - hinter->flags = 0; - - /* allocate outline and loader */ - error = ah_outline_new( memory, &hinter->glyph ) || - ah_loader_new ( memory, &hinter->loader ) || - ah_loader_create_extra( hinter->loader ); - if ( error ) - goto Exit; - - *ahinter = hinter; - - Exit: - if ( error ) - ah_hinter_done( hinter ); - - return error; - } - - - /* create a face's autohint globals */ - FT_Error ah_hinter_new_face_globals( AH_Hinter* hinter, - FT_Face face, - AH_Globals* globals ) - { - FT_Error error; - FT_Memory memory = hinter->memory; - AH_Face_Globals* face_globals; - - - if ( ALLOC( face_globals, sizeof ( *face_globals ) ) ) - goto Exit; - - hinter->face = face; - hinter->globals = face_globals; - - if ( globals ) - face_globals->design = *globals; - else - ah_hinter_compute_globals( hinter ); - - face->autohint.data = face_globals; - face->autohint.finalizer = (FT_Generic_Finalizer) - ah_hinter_done_face_globals; - face_globals->face = face; - - Exit: - return error; - } - - - /* discard a face's autohint globals */ - void ah_hinter_done_face_globals( AH_Face_Globals* globals ) - { - FT_Face face = globals->face; - FT_Memory memory = face->memory; - - - FREE( globals ); - } - - - static - FT_Error ah_hinter_load( AH_Hinter* hinter, - FT_UInt glyph_index, - FT_UInt load_flags, - FT_UInt depth ) - { - FT_Face face = hinter->face; - FT_GlyphSlot slot = face->glyph; - FT_Fixed x_scale = face->size->metrics.x_scale; - FT_Fixed y_scale = face->size->metrics.y_scale; - FT_Glyph_Metrics metrics; /* temporary metrics */ - FT_Error error; - AH_Outline* outline = hinter->glyph; - AH_Loader* gloader = hinter->loader; - FT_Bool no_horz_hints = - ( load_flags & AH_HINT_NO_HORZ_EDGES ) != 0; - FT_Bool no_vert_hints = - ( load_flags & AH_HINT_NO_VERT_EDGES ) != 0; - - - /* load the glyph */ - error = FT_Load_Glyph( face, glyph_index, load_flags ); - if ( error ) - goto Exit; - - /* save current glyph metrics */ - metrics = slot->metrics; - - switch ( slot->format ) - { - case ft_glyph_format_outline: - /* first of all, copy the outline points in the loader's current */ - /* extra points, which is used to keep original glyph coordinates */ - error = ah_loader_check_points( gloader, slot->outline.n_points + 2, - slot->outline.n_contours ); - if ( error ) - goto Exit; - - MEM_Copy( gloader->current.extra_points, slot->outline.points, - slot->outline.n_points * sizeof ( FT_Vector ) ); - - MEM_Copy( gloader->current.outline.contours, slot->outline.contours, - slot->outline.n_contours * sizeof ( short ) ); - - MEM_Copy( gloader->current.outline.tags, slot->outline.tags, - slot->outline.n_points * sizeof ( char ) ); - - gloader->current.outline.n_points = slot->outline.n_points; - gloader->current.outline.n_contours = slot->outline.n_contours; - - /* compute original phantom points */ - hinter->pp1.x = 0; - hinter->pp1.y = 0; - hinter->pp2.x = FT_MulFix( slot->metrics.horiAdvance, x_scale ); - hinter->pp2.y = 0; - - /* be sure to check for spacing glyphs */ - if ( slot->outline.n_points == 0 ) - goto Hint_Metrics; - - /* now, load the slot image into the auto-outline, and run the */ - /* automatic hinting process */ - error = ah_outline_load( outline, face ); /* XXX: change to slot */ - if ( error ) - goto Exit; - - /* perform feature detection */ - ah_outline_detect_features( outline ); - - if ( !no_horz_hints ) - { - ah_outline_compute_blue_edges( outline, hinter->globals ); - ah_outline_scale_blue_edges( outline, hinter->globals ); - } - - /* perform alignment control */ - ah_hinter_hint_edges( hinter, no_horz_hints, no_vert_hints ); - ah_hinter_align( hinter ); - - /* now save the current outline into the loader's current table */ - ah_outline_save( outline, gloader ); - - /* we now need to hint the metrics according to the change in */ - /* width/positioning that occured during the hinting process */ - { - FT_Pos old_width, new_width; - FT_Pos old_advance, new_advance; - FT_Pos old_lsb, new_lsb; - AH_Edge* edge1 = outline->vert_edges; /* leftmost edge */ - AH_Edge* edge2 = edge1 + - outline->num_vedges - 1; /* rightmost edge */ - - - old_width = edge2->opos - edge1->opos; - new_width = edge2->pos - edge1->pos; - - old_advance = hinter->pp2.x; - old_lsb = edge1->opos; - new_lsb = edge1->pos; - - new_advance = old_advance + - ( new_width + new_lsb - old_width - old_lsb ); - - hinter->pp1.x = ( ( new_lsb - old_lsb ) + 32 ) & -64; - hinter->pp2.x = ( ( edge2->pos + - ( old_advance - edge2->opos ) ) + 32 ) & -64; - } - - /* good, we simply add the glyph to our loader's base */ - ah_loader_add( gloader ); - break; - - case ft_glyph_format_composite: - { - FT_UInt nn, num_subglyphs = slot->num_subglyphs; - FT_UInt num_base_subgs, start_point, start_contour; - FT_SubGlyph* subglyph; - - - start_point = gloader->base.outline.n_points; - start_contour = gloader->base.outline.n_contours; - - /* first of all, copy the subglyph descriptors in the glyph loader */ - error = ah_loader_check_subglyphs( gloader, num_subglyphs ); - if ( error ) - goto Exit; - - MEM_Copy( gloader->current.subglyphs, slot->subglyphs, - num_subglyphs * sizeof ( FT_SubGlyph ) ); - - gloader->current.num_subglyphs = num_subglyphs; - num_base_subgs = gloader->base.num_subglyphs; - - /* now, read each subglyph independently */ - for ( nn = 0; nn < num_subglyphs; nn++ ) - { - FT_Vector pp1, pp2; - FT_Pos x, y; - FT_UInt num_points, num_new_points, num_base_points; - - - /* gloader.current.subglyphs can change during glyph loading due */ - /* to re-allocation -- we must recompute the current subglyph on */ - /* each iteration */ - subglyph = gloader->base.subglyphs + num_base_subgs + nn; - - pp1 = hinter->pp1; - pp2 = hinter->pp2; - - num_base_points = gloader->base.outline.n_points; - - error = ah_hinter_load( hinter, subglyph->index, - load_flags, depth + 1 ); - if ( error ) - goto Exit; - - /* recompute subglyph pointer */ - subglyph = gloader->base.subglyphs + num_base_subgs + nn; - - if ( subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS ) - { - pp1 = hinter->pp1; - pp2 = hinter->pp2; - } - else - { - hinter->pp1 = pp1; - hinter->pp2 = pp2; - } - - num_points = gloader->base.outline.n_points; - num_new_points = num_points - num_base_points; - - /* now perform the transform required for this subglyph */ - - if ( subglyph->flags & ( FT_SUBGLYPH_FLAG_SCALE | - FT_SUBGLYPH_FLAG_XY_SCALE | - FT_SUBGLYPH_FLAG_2X2 ) ) - { - FT_Vector* cur = gloader->base.outline.points + - num_base_points; - FT_Vector* org = gloader->base.extra_points + - num_base_points; - FT_Vector* limit = cur + num_new_points; - - - for ( ; cur < limit; cur++, org++ ) - { - FT_Vector_Transform( cur, &subglyph->transform ); - FT_Vector_Transform( org, &subglyph->transform ); - } - } - - /* apply offset */ - - if ( !( subglyph->flags & FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ) ) - { - FT_Int k = subglyph->arg1; - FT_UInt l = subglyph->arg2; - FT_Vector* p1; - FT_Vector* p2; - - - if ( start_point + k >= num_base_points || - l >= (FT_UInt)num_new_points ) - { - error = FT_Err_Invalid_Composite; - goto Exit; - } - - l += num_base_points; - - /* for now, only use the current point coordinates */ - /* we may consider another approach in the near future */ - p1 = gloader->base.outline.points + start_point + k; - p2 = gloader->base.outline.points + start_point + l; - - x = p1->x - p2->x; - y = p1->y - p2->y; - } - else - { - x = FT_MulFix( subglyph->arg1, x_scale ); - y = FT_MulFix( subglyph->arg2, y_scale ); - - x = ( x + 32 ) & -64; - y = ( y + 32 ) & -64; - } - - { - FT_Outline dummy = gloader->base.outline; - - - dummy.points += num_base_points; - dummy.n_points = num_new_points; - - FT_Outline_Translate( &dummy, x, y ); - } - } - } - break; - - default: - /* we don't support other formats (yet?) */ - error = FT_Err_Unimplemented_Feature; - } - - Hint_Metrics: - if ( depth == 0 ) - { - FT_BBox bbox; - - - /* we must translate our final outline by -pp1.x, and compute */ - /* the new metrics */ - if ( hinter->pp1.x ) - FT_Outline_Translate( &gloader->base.outline, -hinter->pp1.x, 0 ); - - FT_Outline_Get_CBox( &gloader->base.outline, &bbox ); - bbox.xMin &= -64; - bbox.yMin &= -64; - bbox.xMax = ( bbox.xMax + 63 ) & -64; - bbox.yMax = ( bbox.yMax + 63 ) & -64; - - slot->metrics.width = bbox.xMax - bbox.xMin; - slot->metrics.height = bbox.yMax - bbox.yMin; - slot->metrics.horiBearingX = bbox.xMin; - slot->metrics.horiBearingY = bbox.yMax; - slot->metrics.horiAdvance = hinter->pp2.x - hinter->pp1.x; - /* XXX: TO DO - slot->linearHoriAdvance */ - - /* now copy outline into glyph slot */ - ah_loader_rewind( slot->loader ); - error = ah_loader_copy_points( slot->loader, gloader ); - if ( error ) - goto Exit; - - slot->outline = slot->loader->base.outline; - slot->format = ft_glyph_format_outline; - } - - Exit: - return error; - } - - - /* load and hint a given glyph */ - FT_Error ah_hinter_load_glyph( AH_Hinter* hinter, - FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_Int load_flags ) - { - FT_Face face = slot->face; - FT_Error error; - FT_Fixed x_scale = size->metrics.x_scale; - FT_Fixed y_scale = size->metrics.y_scale; - AH_Face_Globals* face_globals = FACE_GLOBALS( face ); - - - /* first of all, we need to check that we're using the correct face and */ - /* global hints to load the glyph */ - if ( hinter->face != face || hinter->globals != face_globals ) - { - hinter->face = face; - if ( !face_globals ) - { - error = ah_hinter_new_face_globals( hinter, face, 0 ); - if ( error ) - goto Exit; - } - hinter->globals = FACE_GLOBALS( face ); - face_globals = FACE_GLOBALS( face ); - } - - /* now, we must check the current character pixel size to see if we */ - /* need to rescale the global metrics */ - if ( face_globals->x_scale != x_scale || - face_globals->y_scale != y_scale ) - ah_hinter_scale_globals( hinter, x_scale, y_scale ); - - load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_RECURSE; - - ah_loader_rewind( hinter->loader ); - - error = ah_hinter_load( hinter, glyph_index, load_flags, 0 ); - - Exit: - return error; - } - - - /* retrieve a face's autohint globals for client applications */ - void ah_hinter_get_global_hints( AH_Hinter* hinter, - FT_Face face, - void** global_hints, - long* global_len ) - { - AH_Globals* globals = 0; - FT_Memory memory = hinter->memory; - FT_Error error; - - - /* allocate new master globals */ - if ( ALLOC( globals, sizeof ( *globals ) ) ) - goto Fail; - - /* compute face globals if needed */ - if ( !FACE_GLOBALS( face ) ) - { - error = ah_hinter_new_face_globals( hinter, face, 0 ); - if ( error ) - goto Fail; - } - - *globals = FACE_GLOBALS( face )->design; - *global_hints = globals; - *global_len = sizeof( *globals ); - - return; - - Fail: - FREE( globals ); - - *global_hints = 0; - *global_len = 0; - } - - - void ah_hinter_done_global_hints( AH_Hinter* hinter, - void* global_hints ) - { - FT_Memory memory = hinter->memory; - - - FREE( global_hints ); - } - - -/* END */ diff --git a/src/freetype/autohint/ahhint.h b/src/freetype/autohint/ahhint.h deleted file mode 100644 index bb297fb80f..0000000000 --- a/src/freetype/autohint/ahhint.h +++ /dev/null @@ -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 - -#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 */ diff --git a/src/freetype/autohint/ahloader.h b/src/freetype/autohint/ahloader.h deleted file mode 100644 index 4a8563c0aa..0000000000 --- a/src/freetype/autohint/ahloader.h +++ /dev/null @@ -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 - - #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 */ diff --git a/src/freetype/autohint/ahmodule.c b/src/freetype/autohint/ahmodule.c deleted file mode 100644 index 85755681ee..0000000000 --- a/src/freetype/autohint/ahmodule.c +++ /dev/null @@ -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 - - -#ifdef FT_FLAT_COMPILE - -#include "ahhint.h" - -#else - -#include - -#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 */ diff --git a/src/freetype/autohint/ahmodule.h b/src/freetype/autohint/ahmodule.h deleted file mode 100644 index 28b07538bc..0000000000 --- a/src/freetype/autohint/ahmodule.h +++ /dev/null @@ -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 - - FT_EXPORT_VAR( const FT_Module_Class ) autohint_module_class; - -#endif /* AHMODULE_H */ - - -/* END */ diff --git a/src/freetype/autohint/ahoptim.c b/src/freetype/autohint/ahoptim.c deleted file mode 100644 index d301dd7eee..0000000000 --- a/src/freetype/autohint/ahoptim.c +++ /dev/null @@ -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 /* for ALLOC_ARRAY() and FREE() */ - - -#ifdef FT_FLAT_COMPILE - -#include "ahoptim.h" - -#else - -#include - -#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 -#include -#include - -#define FLOAT( x ) ( (float)( (x) / 64.0 ) ) - - static - void optim_log( const char* fmt, ... ) - { - va_list ap; - - - va_start( ap, fmt ); - vprintf( fmt, ap ); - va_end( ap ); - } - - - static - void AH_Dump_Stems( AH_Optimizer* optimizer ) - { - int n; - AH_Stem* stem; - - - stem = optimizer->stems; - for ( n = 0; n < optimizer->num_stems; n++, stem++ ) - { - LOG(( " %c%2d [%.1f:%.1f]={%.1f:%.1f}=" - "<%1.f..%1.f> force=%.1f speed=%.1f\n", - optimizer->vertical ? 'V' : 'H', n, - FLOAT( stem->edge1->opos ), FLOAT( stem->edge2->opos ), - FLOAT( stem->edge1->pos ), FLOAT( stem->edge2->pos ), - FLOAT( stem->min_pos ), FLOAT( stem->max_pos ), - FLOAT( stem->force ), FLOAT( stem->velocity ) )); - } - } - - - static - void AH_Dump_Stems2( AH_Optimizer* optimizer ) - { - int n; - AH_Stem* stem; - - - stem = optimizer->stems; - for ( n = 0; n < optimizer->num_stems; n++, stem++ ) - { - LOG(( " %c%2d [%.1f]=<%1.f..%1.f> force=%.1f speed=%.1f\n", - optimizer->vertical ? 'V' : 'H', n, - FLOAT( stem->pos ), - FLOAT( stem->min_pos ), FLOAT( stem->max_pos ), - FLOAT( stem->force ), FLOAT( stem->velocity ) )); - } - } - - - static - void AH_Dump_Springs( AH_Optimizer* optimizer ) - { - int n; - AH_Spring* spring; - AH_Stem* stems; - - - spring = optimizer->springs; - stems = optimizer->stems; - LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' )); - - for ( n = 0; n < optimizer->num_springs; n++, spring++ ) - { - LOG(( " [%d-%d:%.1f:%1.f:%.1f]", - spring->stem1 - stems, spring->stem2 - stems, - FLOAT( spring->owidth ), - FLOAT( spring->stem2->pos - - ( spring->stem1->pos + spring->stem1->width ) ), - FLOAT( spring->tension ) )); - } - - LOG(( "\n" )); - } - -#endif /* AH_DEBUG_OPTIM */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** COMPUTE STEMS AND SPRINGS IN AN OUTLINE ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - static - int valid_stem_segments( AH_Segment* seg1, - AH_Segment* seg2 ) - { - return seg1->serif == 0 && - seg2 && - seg2->link == seg1 && - seg1->pos < seg2->pos && - seg1->min_coord <= seg2->max_coord && - seg2->min_coord <= seg1->max_coord; - } - - - /* compute all stems in an outline */ - static - int optim_compute_stems( AH_Optimizer* optimizer ) - { - AH_Outline* outline = optimizer->outline; - FT_Fixed scale; - FT_Memory memory = optimizer->memory; - FT_Error error = 0; - FT_Int dimension; - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Stem** p_stems; - FT_Int* p_num_stems; - - - edges = outline->horz_edges; - edge_limit = edges + outline->num_hedges; - scale = outline->y_scale; - - p_stems = &optimizer->horz_stems; - p_num_stems = &optimizer->num_hstems; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - AH_Stem* stems = 0; - FT_Int num_stems = 0; - AH_Edge* edge; - - - /* first of all, count the number of stems in this direction */ - for ( edge = edges; edge < edge_limit; edge++ ) - { - AH_Segment* seg = edge->first; - - - do - { - if (valid_stem_segments( seg, seg->link ) ) - num_stems++; - - seg = seg->edge_next; - - } while ( seg != edge->first ); - } - - /* now allocate the stems and build their table */ - if ( num_stems > 0 ) - { - AH_Stem* stem; - - - if ( ALLOC_ARRAY( stems, num_stems, AH_Stem ) ) - goto Exit; - - stem = stems; - for ( edge = edges; edge < edge_limit; edge++ ) - { - AH_Segment* seg = edge->first; - AH_Segment* seg2; - - - do - { - seg2 = seg->link; - if ( valid_stem_segments( seg, seg2 ) ) - { - AH_Edge* edge1 = seg->edge; - AH_Edge* edge2 = seg2->edge; - - - stem->edge1 = edge1; - stem->edge2 = edge2; - stem->opos = edge1->opos; - stem->pos = edge1->pos; - stem->owidth = edge2->opos - edge1->opos; - stem->width = edge2->pos - edge1->pos; - - /* compute min_coord and max_coord */ - { - FT_Pos min_coord = seg->min_coord; - FT_Pos max_coord = seg->max_coord; - - - if ( seg2->min_coord > min_coord ) - min_coord = seg2->min_coord; - - if ( seg2->max_coord < max_coord ) - max_coord = seg2->max_coord; - - stem->min_coord = min_coord; - stem->max_coord = max_coord; - } - - /* compute minimum and maximum positions for stem -- */ - /* note that the left-most/bottom-most stem has always */ - /* a fixed position */ - if ( stem == stems || edge1->blue_edge || edge2->blue_edge ) - { - /* this stem cannot move; it is snapped to a blue edge */ - stem->min_pos = stem->pos; - stem->max_pos = stem->pos; - } - else - { - /* this edge can move; compute its min and max positions */ - FT_Pos pos1 = stem->opos; - FT_Pos pos2 = pos1 + stem->owidth - stem->width; - FT_Pos min1 = pos1 & -64; - FT_Pos min2 = pos2 & -64; - - - stem->min_pos = min1; - stem->max_pos = min1 + 64; - if ( min2 < min1 ) - stem->min_pos = min2; - else - stem->max_pos = min2 + 64; - - /* XXX: just to see what it does */ - stem->max_pos += 64; - - /* just for the case where direct hinting did some */ - /* incredible things (e.g. blue edge shifts) */ - if ( stem->min_pos > stem->pos ) - stem->min_pos = stem->pos; - - if ( stem->max_pos < stem->pos ) - stem->max_pos = stem->pos; - } - - stem->velocity = 0; - stem->force = 0; - - stem++; - } - seg = seg->edge_next; - - } while ( seg != edge->first ); - } - } - - *p_stems = stems; - *p_num_stems = num_stems; - - edges = outline->vert_edges; - edge_limit = edges + outline->num_vedges; - scale = outline->x_scale; - - p_stems = &optimizer->vert_stems; - p_num_stems = &optimizer->num_vstems; - } - - Exit: - -#ifdef AH_DEBUG_OPTIM - AH_Dump_Stems( optimizer ); -#endif - - return error; - } - - - /* returns the spring area between two stems, 0 if none */ - static - FT_Pos stem_spring_area( AH_Stem* stem1, - AH_Stem* stem2 ) - { - FT_Pos area1 = stem1->max_coord - stem1->min_coord; - FT_Pos area2 = stem2->max_coord - stem2->min_coord; - FT_Pos min = stem1->min_coord; - FT_Pos max = stem1->max_coord; - FT_Pos area; - - - /* order stems */ - if ( stem2->opos <= stem1->opos + stem1->owidth ) - return 0; - - if ( min < stem2->min_coord ) - min = stem2->min_coord; - - if ( max < stem2->max_coord ) - max = stem2->max_coord; - - area = ( max-min ); - if ( 2 * area < area1 && 2 * area < area2 ) - area = 0; - - return area; - } - - - /* compute all springs in an outline */ - static - int optim_compute_springs( AH_Optimizer* optimizer ) - { - /* basically, a spring exists between two stems if most of their */ - /* surface is aligned */ - FT_Memory memory = optimizer->memory; - - AH_Stem* stems; - AH_Stem* stem_limit; - AH_Stem* stem; - int dimension; - int error = 0; - - FT_Int* p_num_springs; - AH_Spring** p_springs; - - - stems = optimizer->horz_stems; - stem_limit = stems + optimizer->num_hstems; - - p_springs = &optimizer->horz_springs; - p_num_springs = &optimizer->num_hsprings; - - for ( dimension = 1; dimension >= 0; dimension-- ) - { - FT_Int num_springs = 0; - AH_Spring* springs = 0; - - - /* first of all, count stem springs */ - for ( stem = stems; stem + 1 < stem_limit; stem++ ) - { - AH_Stem* stem2; - - - for ( stem2 = stem+1; stem2 < stem_limit; stem2++ ) - if ( stem_spring_area( stem, stem2 ) ) - num_springs++; - } - - /* then allocate and build the springs table */ - if ( num_springs > 0 ) - { - AH_Spring* spring; - - - /* allocate table of springs */ - if ( ALLOC_ARRAY( springs, num_springs, AH_Spring ) ) - goto Exit; - - /* fill the springs table */ - spring = springs; - for ( stem = stems; stem+1 < stem_limit; stem++ ) - { - AH_Stem* stem2; - FT_Pos area; - - - for ( stem2 = stem + 1; stem2 < stem_limit; stem2++ ) - { - area = stem_spring_area( stem, stem2 ); - if ( area ) - { - /* add a new spring here */ - spring->stem1 = stem; - spring->stem2 = stem2; - spring->owidth = stem2->opos - ( stem->opos + stem->owidth ); - spring->tension = 0; - - spring++; - } - } - } - } - *p_num_springs = num_springs; - *p_springs = springs; - - stems = optimizer->vert_stems; - stem_limit = stems + optimizer->num_vstems; - - p_springs = &optimizer->vert_springs; - p_num_springs = &optimizer->num_vsprings; - } - - Exit: - -#ifdef AH_DEBUG_OPTIM - AH_Dump_Springs( optimizer ); -#endif - - return error; - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** OPTIMIZE THROUGH MY STRANGE SIMULATED ANNEALING ALGO ;-) ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - -#ifndef AH_BRUTE_FORCE - - /* compute all spring tensions */ - static - void optim_compute_tensions( AH_Optimizer* optimizer ) - { - AH_Spring* spring = optimizer->springs; - AH_Spring* limit = spring + optimizer->num_springs; - - - for ( ; spring < limit; spring++ ) - { - AH_Stem* stem1 = spring->stem1; - AH_Stem* stem2 = spring->stem2; - FT_Int status; - - FT_Pos width; - FT_Pos tension; - FT_Pos sign; - - - /* compute the tension; it simply is -K*(new_width-old_width) */ - width = stem2->pos - ( stem1->pos + stem1->width ); - tension = width - spring->owidth; - - sign = 1; - if ( tension < 0 ) - { - sign = -1; - tension = -tension; - } - - if ( width <= 0 ) - tension = 32000; - else - tension = ( tension << 10 ) / width; - - tension = -sign * FT_MulFix( tension, optimizer->tension_scale ); - spring->tension = tension; - - /* now, distribute tension among the englobing stems, if they */ - /* are able to move */ - status = 0; - if ( stem1->pos <= stem1->min_pos ) - status |= 1; - if ( stem2->pos >= stem2->max_pos ) - status |= 2; - - if ( !status ) - tension /= 2; - - if ( ( status & 1 ) == 0 ) - stem1->force -= tension; - - if ( ( status & 2 ) == 0 ) - stem2->force += tension; - } - } - - - /* compute all stem movements -- returns 0 if nothing moved */ - static - int optim_compute_stem_movements( AH_Optimizer* optimizer ) - { - AH_Stem* stems = optimizer->stems; - AH_Stem* limit = stems + optimizer->num_stems; - AH_Stem* stem = stems; - int moved = 0; - - - /* set initial forces to velocity */ - for ( stem = stems; stem < limit; stem++ ) - { - stem->force = stem->velocity; - stem->velocity /= 2; /* XXX: Heuristics */ - } - - /* compute the sum of forces applied on each stem */ - optim_compute_tensions( optimizer ); - -#ifdef AH_DEBUG_OPTIM - AH_Dump_Springs( optimizer ); - AH_Dump_Stems2( optimizer ); -#endif - - /* now, see whether something can move */ - for ( stem = stems; stem < limit; stem++ ) - { - if ( stem->force > optimizer->tension_threshold ) - { - /* there is enough tension to move the stem to the right */ - if ( stem->pos < stem->max_pos ) - { - stem->pos += 64; - stem->velocity = stem->force / 2; - moved = 1; - } - else - stem->velocity = 0; - } - else if ( stem->force < optimizer->tension_threshold ) - { - /* there is enough tension to move the stem to the left */ - if ( stem->pos > stem->min_pos ) - { - stem->pos -= 64; - stem->velocity = stem->force / 2; - moved = 1; - } - else - stem->velocity = 0; - } - } - - /* return 0 if nothing moved */ - return moved; - } - -#endif /* AH_BRUTE_FORCE */ - - - /* compute current global distortion from springs */ - static - FT_Pos optim_compute_distortion( AH_Optimizer* optimizer ) - { - AH_Spring* spring = optimizer->springs; - AH_Spring* limit = spring + optimizer->num_springs; - FT_Pos distortion = 0; - - - for ( ; spring < limit; spring++ ) - { - AH_Stem* stem1 = spring->stem1; - AH_Stem* stem2 = spring->stem2; - FT_Pos width; - - width = stem2->pos - ( stem1->pos + stem1->width ); - width -= spring->owidth; - if ( width < 0 ) - width = -width; - - distortion += width; - } - - return distortion; - } - - - /* record stems configuration in `best of' history */ - static - void optim_record_configuration( AH_Optimizer* optimizer ) - { - FT_Pos distortion; - AH_Configuration* configs = optimizer->configs; - AH_Configuration* limit = configs + optimizer->num_configs; - AH_Configuration* config; - - - distortion = optim_compute_distortion( optimizer ); - LOG(( "config distortion = %.1f ", FLOAT( distortion * 64 ) )); - - /* check that we really need to add this configuration to our */ - /* sorted history */ - if ( limit > configs && limit[-1].distortion < distortion ) - { - LOG(( "ejected\n" )); - return; - } - - /* add new configuration at the end of the table */ - { - int n; - - - config = limit; - if ( optimizer->num_configs < AH_MAX_CONFIGS ) - optimizer->num_configs++; - else - config--; - - config->distortion = distortion; - - for ( n = 0; n < optimizer->num_stems; n++ ) - config->positions[n] = optimizer->stems[n].pos; - } - - /* move the current configuration towards the front of the list */ - /* when necessary -- yes this is slow bubble sort ;-) */ - while ( config > configs && config[0].distortion < config[-1].distortion ) - { - AH_Configuration temp; - - - config--; - temp = config[0]; - config[0] = config[1]; - config[1] = temp; - } - LOG(( "recorded!\n" )); - } - - -#ifdef AH_BRUTE_FORCE - - /* optimize outline in a single direction */ - static - void optim_compute( AH_Optimizer* optimizer ) - { - int n; - FT_Bool moved; - - AH_Stem* stem = optimizer->stems; - AH_Stem* limit = stem + optimizer->num_stems; - - - /* empty, exit */ - if ( stem >= limit ) - return; - - optimizer->num_configs = 0; - - stem = optimizer->stems; - for ( ; stem < limit; stem++ ) - stem->pos = stem->min_pos; - - do - { - /* record current configuration */ - optim_record_configuration( optimizer ); - - /* now change configuration */ - moved = 0; - for ( stem = optimizer->stems; stem < limit; stem++ ) - { - if ( stem->pos < stem->max_pos ) - { - stem->pos += 64; - moved = 1; - break; - } - - stem->pos = stem->min_pos; - } - } while ( moved ); - - /* now, set the best stem positions */ - for ( n = 0; n < optimizer->num_stems; n++ ) - { - AH_Stem* stem = optimizer->stems + n; - FT_Pos pos = optimizer->configs[0].positions[n]; - - - stem->edge1->pos = pos; - stem->edge2->pos = pos + stem->width; - - stem->edge1->flags |= ah_edge_done; - stem->edge2->flags |= ah_edge_done; - } - } - -#else /* AH_BRUTE_FORCE */ - - /* optimize outline in a single direction */ - static - void optim_compute( AH_Optimizer* optimizer ) - { - int n, counter, counter2; - - - optimizer->num_configs = 0; - optimizer->tension_scale = 0x80000L; - optimizer->tension_threshold = 64; - - /* record initial configuration threshold */ - optim_record_configuration( optimizer ); - - counter = 0; - for ( counter2 = optimizer->num_stems*8; counter2 >= 0; counter2-- ) - { - if ( counter == 0 ) - counter = 2 * optimizer->num_stems; - - if ( !optim_compute_stem_movements( optimizer ) ) - break; - - optim_record_configuration( optimizer ); - - counter--; - if ( counter == 0 ) - optimizer->tension_scale /= 2; - } - - /* now, set the best stem positions */ - for ( n = 0; n < optimizer->num_stems; n++ ) - { - AH_Stem* stem = optimizer->stems + n; - FT_Pos pos = optimizer->configs[0].positions[n]; - - - stem->edge1->pos = pos; - stem->edge2->pos = pos + stem->width; - - stem->edge1->flags |= ah_edge_done; - stem->edge2->flags |= ah_edge_done; - } - } - -#endif /* AH_BRUTE_FORCE */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** HIGH-LEVEL OPTIMIZER API ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* releases the optimization data */ - void AH_Optimizer_Done( AH_Optimizer* optimizer ) - { - if ( optimizer ) - { - FT_Memory memory = optimizer->memory; - - - FREE( optimizer->horz_stems ); - FREE( optimizer->vert_stems ); - FREE( optimizer->horz_springs ); - FREE( optimizer->vert_springs ); - FREE( optimizer->positions ); - } - } - - - /* loads the outline into the optimizer */ - int AH_Optimizer_Init( AH_Optimizer* optimizer, - AH_Outline* outline, - FT_Memory memory ) - { - FT_Error error; - - - MEM_Set( optimizer, 0, sizeof ( *optimizer ) ); - optimizer->outline = outline; - optimizer->memory = memory; - - LOG(( "initializing new optimizer\n" )); - /* compute stems and springs */ - error = optim_compute_stems ( optimizer ) || - optim_compute_springs( optimizer ); - if ( error ) - goto Fail; - - /* allocate stem positions history and configurations */ - { - int n, max_stems; - - - max_stems = optimizer->num_hstems; - if ( max_stems < optimizer->num_vstems ) - max_stems = optimizer->num_vstems; - - if ( ALLOC_ARRAY( optimizer->positions, - max_stems * AH_MAX_CONFIGS, FT_Pos ) ) - goto Fail; - - optimizer->num_configs = 0; - for ( n = 0; n < AH_MAX_CONFIGS; n++ ) - optimizer->configs[n].positions = optimizer->positions + - n * max_stems; - } - - return error; - - Fail: - AH_Optimizer_Done( optimizer ); - return error; - } - - - /* compute optimal outline */ - void AH_Optimizer_Compute( AH_Optimizer* optimizer ) - { - optimizer->num_stems = optimizer->num_hstems; - optimizer->stems = optimizer->horz_stems; - optimizer->num_springs = optimizer->num_hsprings; - optimizer->springs = optimizer->horz_springs; - - if ( optimizer->num_springs > 0 ) - { - LOG(( "horizontal optimization ------------------------\n" )); - optim_compute( optimizer ); - } - - optimizer->num_stems = optimizer->num_vstems; - optimizer->stems = optimizer->vert_stems; - optimizer->num_springs = optimizer->num_vsprings; - optimizer->springs = optimizer->vert_springs; - - if ( optimizer->num_springs ) - { - LOG(( "vertical optimization --------------------------\n" )); - optim_compute( optimizer ); - } - } - - -/* END */ diff --git a/src/freetype/autohint/ahoptim.h b/src/freetype/autohint/ahoptim.h deleted file mode 100644 index a1f52bf68f..0000000000 --- a/src/freetype/autohint/ahoptim.h +++ /dev/null @@ -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 - -#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 */ diff --git a/src/freetype/autohint/ahtypes.h b/src/freetype/autohint/ahtypes.h deleted file mode 100644 index 3372ea9af6..0000000000 --- a/src/freetype/autohint/ahtypes.h +++ /dev/null @@ -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 /* for freetype.h + LOCAL_DEF etc. */ - - -#ifdef FT_FLAT_COMPILE - -#include "ahloader.h" - -#else - -#include - -#endif - - -#define xxAH_DEBUG - - -#ifdef AH_DEBUG - -#include - -#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; - - - /*************************************************************************/ - /* */ - /* */ - /* AH_Point */ - /* */ - /* */ - /* A structure used to model an outline point to the AH_Outline type. */ - /* */ - /* */ - /* 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 */ - }; - - - /*************************************************************************/ - /* */ - /* */ - /* AH_Segment */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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; - }; - - - /*************************************************************************/ - /* */ - /* */ - /* AH_Edge */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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; - - - /*************************************************************************/ - /* */ - /* */ - /* AH_Globals */ - /* */ - /* */ - /* Holds the global metrics for a given font face (be it in design */ - /* units or scaled pixel values). */ - /* */ - /* */ - /* 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; - - - /*************************************************************************/ - /* */ - /* */ - /* AH_Face_Globals */ - /* */ - /* */ - /* Holds the complete global metrics for a given font face (i.e., the */ - /* design units version + a scaled version + the current scales */ - /* used). */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/autohint/autohint.c b/src/freetype/autohint/autohint.c deleted file mode 100644 index 5916b63302..0000000000 --- a/src/freetype/autohint/autohint.c +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************/ -/* */ -/* 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 -#include -#include -#include -#include - -#endif - - -/* END */ diff --git a/src/freetype/autohint/mather.py b/src/freetype/autohint/mather.py deleted file mode 100644 index b416fdfcb6..0000000000 --- a/src/freetype/autohint/mather.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -# - -# -# autohint math table builder -# - - -# Copyright 1996-2000 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -import math - -ag_pi = 256 - -def print_arctan( atan_bits ): - atan_base = 1 << atan_bits - - print " static AH_Angle ag_arctan[1L << AG_ATAN_BITS] =" - print " {" - - count = 0 - line = " " - - for n in range( atan_base ): - comma = "," - if ( n == atan_base - 1 ): - comma = "" - - angle = math.atan( n * 1.0 / atan_base ) / math.pi * ag_pi - line = line + " " + repr( int( angle + 0.5 ) ) + comma - count = count + 1; - if ( count == 8 ): - count = 0 - print line - line = " " - - if ( count > 0 ): - print line - print " };" - - -# This routine is not used currently. -# -def print_sines(): - print " static FT_Fixed ah_sines[AG_HALF_PI + 1] =" - print " {" - - count = 0 - line = " " - - for n in range( ag_pi / 2 ): - sinus = math.sin( n * math.pi / ag_pi ) - line = line + " " + repr( int( 65536.0 * sinus ) ) + "," - count = count + 1 - if ( count == 8 ): - count = 0 - print line - line = " " - - if ( count > 0 ): - print line - print " 65536" - print " };" - - -print_arctan( 8 ) -print - - -# END diff --git a/src/freetype/autohint/module.mk b/src/freetype/autohint/module.mk deleted file mode 100644 index 71e5ee3524..0000000000 --- a/src/freetype/autohint/module.mk +++ /dev/null @@ -1,7 +0,0 @@ -make_module_list: add_autohint_module - -add_autohint_module: - $(OPEN_DRIVER)autohint_module_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)autohint $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE) - -# EOF diff --git a/src/freetype/autohint/rules.mk b/src/freetype/autohint/rules.mk deleted file mode 100644 index 87f7849adc..0000000000 --- a/src/freetype/autohint/rules.mk +++ /dev/null @@ -1,77 +0,0 @@ -# -# FreeType 2 auto-hinter module configuration rules -# - - -# Copyright 2000 Catharon Productions Inc. -# Author: David Turner -# -# This file is part of the Catharon Typography Project and shall only -# be used, modified, and distributed under the terms of the Catharon -# Open Source License that should come with this file under the name -# `CatharonLicense.txt'. By continuing to use, modify, or distribute -# this file you indicate that you have read the license and -# understand and accept it fully. -# -# Note that this license is compatible with the FreeType license. - - -# AUTO driver directory -# -AUTO_DIR := $(SRC_)autohint -AUTO_DIR_ := $(AUTO_DIR)$(SEP) - - -# compilation flags for the driver -# -AUTO_COMPILE := $(FT_COMPILE) - - -# AUTO driver sources (i.e., C files) -# -AUTO_DRV_SRC := $(AUTO_DIR_)ahangles.c \ - $(AUTO_DIR_)ahglobal.c \ - $(AUTO_DIR_)ahglyph.c \ - $(AUTO_DIR_)ahhint.c \ - $(AUTO_DIR_)ahmodule.c - -# AUTO driver headers -# -AUTO_DRV_H := $(AUTO_DRV_SRC:%c=%h) \ - $(AUTO_DIR_)ahloader.h \ - $(AUTO_DIR_)ahtypes.h - - -# AUTO driver object(s) -# -# AUTO_DRV_OBJ_M is used during `multi' builds. -# AUTO_DRV_OBJ_S is used during `single' builds. -# -AUTO_DRV_OBJ_M := $(AUTO_DRV_SRC:$(AUTO_DIR_)%.c=$(OBJ_)%.$O) -AUTO_DRV_OBJ_S := $(OBJ_)autohint.$O - -# AUTO driver source file for single build -# -AUTO_DRV_SRC_S := $(AUTO_DIR_)autohint.c - - -# AUTO driver - single object -# -$(AUTO_DRV_OBJ_S): $(AUTO_DRV_SRC_S) $(AUTO_DRV_SRC) \ - $(FREETYPE_H) $(AUTO_DRV_H) - $(AUTO_COMPILE) $T$@ $(AUTO_DRV_SRC_S) - - -# AUTO driver - multiple objects -# -$(OBJ_)%.$O: $(AUTO_DIR_)%.c $(FREETYPE_H) $(AUTO_DRV_H) - $(AUTO_COMPILE) $T$@ $< - - -# update main driver object lists -# -DRV_OBJS_S += $(AUTO_DRV_OBJ_S) -DRV_OBJS_M += $(AUTO_DRV_OBJ_M) - - -# EOF diff --git a/src/freetype/base/ftbase.c b/src/freetype/base/ftbase.c deleted file mode 100644 index a110af42b4..0000000000 --- a/src/freetype/base/ftbase.c +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************/ -/* */ -/* 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 -#include -#include -#include -#include -#include -#include - -#endif /* FT_FLAT_COMPILE */ - - -/* END */ diff --git a/src/freetype/base/ftcalc.c b/src/freetype/base/ftcalc.c deleted file mode 100644 index d27de26524..0000000000 --- a/src/freetype/base/ftcalc.c +++ /dev/null @@ -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 -#include -#include /* 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 - - /*************************************************************************/ - /* */ - /* */ - /* FT_Sqrt32 */ - /* */ - /* */ - /* Computes the square root of an Int32 integer (which will be */ - /* handled as an unsigned long value). */ - /* */ - /* */ - /* x :: The value to compute the root for. */ - /* */ - /* */ - /* 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 - - /*************************************************************************/ - /* */ - /* */ - /* FT_MulDiv */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MulFix */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* */ - /* The result of `(a*b)/0x10000'. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_DivFix */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* */ - /* The result of `(a*0x10000)/b'. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Sqrt64 */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* l :: A 64-bit integer. */ - /* */ - /* */ - /* 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 */ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MulDiv */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* */ - /* 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'. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MulFix */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* */ - /* The result of `(a*b)/0x10000'. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_DivFix */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* */ - /* The result of `(a*0x10000)/b'. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Add64 */ - /* */ - /* */ - /* Add two Int64 values. */ - /* */ - /* */ - /* x :: A pointer to the first value to be added. */ - /* y :: A pointer to the second value to be added. */ - /* */ - /* */ - /* z :: A pointer to the result of `x + y'. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MulTo64 */ - /* */ - /* */ - /* Multiplies two Int32 integers. Returns an Int64 integer. */ - /* */ - /* */ - /* x :: The first multiplier. */ - /* y :: The second multiplier. */ - /* */ - /* */ - /* z :: A pointer to the result of `x * y'. */ - /* */ - /* */ - /* 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 ); - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Div64by32 */ - /* */ - /* */ - /* Divides an Int64 value by an Int32 value. Returns an Int32 */ - /* integer. */ - /* */ - /* */ - /* x :: A pointer to the dividend. */ - /* y :: The divisor. */ - /* */ - /* */ - /* The result of `x / y'. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Sqrt64 */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* z :: A pointer to a 64-bit integer. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftdebug.c b/src/freetype/base/ftdebug.c deleted file mode 100644 index 32da7897ef..0000000000 --- a/src/freetype/base/ftdebug.c +++ /dev/null @@ -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 - -#ifdef FT_DEBUG_LEVEL_TRACE - char ft_trace_levels[trace_max]; -#endif - - -#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE ) - - -#include -#include -#include - - - FT_EXPORT_FUNC( void ) FT_Message( const char* fmt, ... ) - { - va_list ap; - - - va_start( ap, fmt ); - vprintf( fmt, ap ); - va_end( ap ); - } - - - FT_EXPORT_FUNC( void ) FT_Panic( const char* fmt, ... ) - { - va_list ap; - - - va_start( ap, fmt ); - vprintf( fmt, ap ); - va_end( ap ); - - exit( EXIT_FAILURE ); - } - - -#ifdef FT_DEBUG_LEVEL_TRACE - - - /*************************************************************************/ - /* */ - /* */ - /* FT_SetTraceLevel */ - /* */ - /* */ - /* Sets the trace level for debugging. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftextend.c b/src/freetype/base/ftextend.c deleted file mode 100644 index f298b19a8a..0000000000 --- a/src/freetype/base/ftextend.c +++ /dev/null @@ -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 -#include - - - /*************************************************************************/ - /* */ - /* 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; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Init_Extensions */ - /* */ - /* */ - /* Initializes the extension component. */ - /* */ - /* */ - /* driver :: A handle to the driver object. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Extensions */ - /* */ - /* */ - /* Finalizes the extension component. */ - /* */ - /* */ - /* driver :: A handle to the driver object. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Register_Extension */ - /* */ - /* */ - /* Registers a new extension. */ - /* */ - /* */ - /* driver :: A handle to the driver object. */ - /* class :: A pointer to a class describing the extension. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Extension */ - /* */ - /* */ - /* Queries an extension block by an extension ID string. */ - /* */ - /* */ - /* face :: A handle to the face object. */ - /* extension_id :: An ID string identifying the extension. */ - /* */ - /* */ - /* extension_interface :: A generic pointer, usually pointing to a */ - /* table of functions implementing the */ - /* extension interface. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Destroy_Extensions */ - /* */ - /* */ - /* Destroys all extensions within a face object. */ - /* */ - /* */ - /* face :: A handle to the face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Create_Extensions */ - /* */ - /* */ - /* Creates an extension object within a face object for all */ - /* registered extensions. */ - /* */ - /* */ - /* face :: A handle to the face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftglyph.c b/src/freetype/base/ftglyph.c deleted file mode 100644 index 4052e6e4f8..0000000000 --- a/src/freetype/base/ftglyph.c +++ /dev/null @@ -1,1184 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftglyph.c */ -/* */ -/* FreeType convenience functions to handle glyphs (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 definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ - - -#include -#include -#include - - - /*************************************************************************/ - /* */ - /* 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_glyph - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** Convenience functions ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Matrix_Multiply */ - /* */ - /* */ - /* Performs the matrix operation `b = a*b'. */ - /* */ - /* */ - /* a :: A pointer to matrix `a'. */ - /* */ - /* */ - /* b :: A pointer to matrix `b'. */ - /* */ - /* */ - /* Yes. */ - /* */ - /* */ - /* The result is undefined if either `a' or `b' is zero. */ - /* */ - FT_EXPORT_FUNC( void ) FT_Matrix_Multiply( FT_Matrix* a, - FT_Matrix* b ) - { - FT_Fixed xx, xy, yx, yy; - - - if ( !a || !b ) - return; - - xx = FT_MulFix( a->xx, b->xx ) + FT_MulFix( a->xy, b->yx ); - xy = FT_MulFix( a->xx, b->xy ) + FT_MulFix( a->xy, b->yy ); - yx = FT_MulFix( a->yx, b->xx ) + FT_MulFix( a->yy, b->yx ); - yy = FT_MulFix( a->yx, b->xy ) + FT_MulFix( a->yy, b->yy ); - - b->xx = xx; b->xy = xy; - b->yx = yx; b->yy = yy; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Matrix_Invert */ - /* */ - /* */ - /* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */ - /* */ - /* */ - /* matrix :: A pointer to the target matrix. Remains untouched in */ - /* case of error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Yes. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix ) - { - FT_Pos delta, xx, yy; - - - if ( !matrix ) - return FT_Err_Invalid_Argument; - - /* compute discriminant */ - delta = FT_MulFix( matrix->xx, matrix->yy ) - - FT_MulFix( matrix->xy, matrix->yx ); - - if ( !delta ) - return FT_Err_Invalid_Argument; /* matrix can't be inverted */ - - matrix->xy = - FT_DivFix( matrix->xy, delta ); - matrix->yx = - FT_DivFix( matrix->yx, delta ); - - xx = matrix->xx; - yy = matrix->yy; - - matrix->xx = FT_DivFix( yy, delta ); - matrix->yy = FT_DivFix( xx, delta ); - - return FT_Err_Ok; - } - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** FT_BitmapGlyph support ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - static - FT_Error ft_bitmap_copy( FT_Memory memory, - FT_Bitmap* source, - FT_Bitmap* target ) - { - FT_Error error; - FT_Int pitch = source->pitch; - FT_ULong size; - - - *target = *source; - - if ( pitch < 0 ) - pitch = -pitch; - - size = (FT_ULong)( pitch * source->rows ); - - if ( !ALLOC( target->buffer, size ) ) - MEM_Copy( source->buffer, target->buffer, size ); - - return error; - } - - - static - FT_Error ft_bitmap_glyph_init( FT_BitmapGlyph glyph, - FT_GlyphSlot slot ) - { - FT_Error error = FT_Err_Ok; - FT_Library library = FT_GLYPH(glyph)->library; - FT_Memory memory = library->memory; - - - if ( slot->format != ft_glyph_format_bitmap ) - { - error = FT_Err_Invalid_Glyph_Format; - goto Exit; - } - - /* grab the bitmap in the slot - do lazy copying whenever possible */ - glyph->bitmap = slot->bitmap; - glyph->left = slot->bitmap_left; - glyph->top = slot->bitmap_top; - - if ( slot->flags & ft_glyph_own_bitmap ) - slot->flags &= ~ft_glyph_own_bitmap; - else - { - /* copy the bitmap into a new buffer */ - error = ft_bitmap_copy( memory, &slot->bitmap, &glyph->bitmap ); - } - - Exit: - return error; - } - - - static - FT_Error ft_bitmap_glyph_copy( FT_BitmapGlyph source, - FT_BitmapGlyph target ) - { - FT_Memory memory = source->root.library->memory; - - - target->left = source->left; - target->top = source->top; - - return ft_bitmap_copy( memory, &source->bitmap, &target->bitmap ); - } - - - static - void ft_bitmap_glyph_done( FT_BitmapGlyph glyph ) - { - FT_Memory memory = FT_GLYPH(glyph)->library->memory; - - - FREE( glyph->bitmap.buffer ); - } - - - static - void ft_bitmap_glyph_bbox( FT_BitmapGlyph glyph, - FT_BBox* cbox ) - { - cbox->xMin = glyph->left << 6; - cbox->xMax = cbox->xMin + ( glyph->bitmap.width << 6 ); - cbox->yMax = glyph->top << 6; - cbox->yMin = cbox->xMax - ( glyph->bitmap.rows << 6 ); - } - - - const FT_Glyph_Class ft_bitmap_glyph_class = - { - sizeof( FT_BitmapGlyphRec ), - ft_glyph_format_bitmap, - - (FT_Glyph_Init_Func) ft_bitmap_glyph_init, - (FT_Glyph_Done_Func) ft_bitmap_glyph_done, - (FT_Glyph_Copy_Func) ft_bitmap_glyph_copy, - (FT_Glyph_Transform_Func)0, - (FT_Glyph_BBox_Func) ft_bitmap_glyph_bbox, - (FT_Glyph_Prepare_Func) 0 - }; - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** FT_OutlineGlyph support ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - static - FT_Error ft_outline_glyph_init( FT_OutlineGlyph glyph, - FT_GlyphSlot slot ) - { - FT_Error error = FT_Err_Ok; - FT_Library library = FT_GLYPH(glyph)->library; - FT_Outline* source = &slot->outline; - FT_Outline* target = &glyph->outline; - - - /* check format in glyph slot */ - if ( slot->format != ft_glyph_format_outline ) - { - error = FT_Err_Invalid_Glyph_Format; - goto Exit; - } - - /* allocate new outline */ - error = FT_Outline_New( library, source->n_points, source->n_contours, - &glyph->outline ); - if ( error ) - goto Exit; - - /* copy it */ - 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 */ - target->flags = source->flags | ft_outline_owner; - - Exit: - return error; - } - - - static - void ft_outline_glyph_done( FT_OutlineGlyph glyph ) - { - FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline ); - } - - - static - FT_Error ft_outline_glyph_copy( FT_OutlineGlyph source, - FT_OutlineGlyph target ) - { - FT_Error error; - FT_Library library = FT_GLYPH( source )->library; - - - error = FT_Outline_New( library, source->outline.n_points, - source->outline.n_contours, &target->outline ); - if ( !error ) - FT_Outline_Copy( &source->outline, &target->outline ); - - return error; - } - - - static - void ft_outline_glyph_transform( FT_OutlineGlyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ) - { - if ( matrix ) - FT_Outline_Transform( &glyph->outline, matrix ); - - if ( delta ) - FT_Outline_Translate( &glyph->outline, delta->x, delta->y ); - } - - - static - void ft_outline_glyph_bbox( FT_OutlineGlyph glyph, - FT_BBox* bbox ) - { - FT_Outline_Get_CBox( &glyph->outline, bbox ); - } - - - static - FT_Error ft_outline_glyph_prepare( FT_OutlineGlyph glyph, - FT_GlyphSlot slot ) - { - slot->format = ft_glyph_format_outline; - slot->outline = glyph->outline; - slot->outline.flags &= ~ft_outline_owner; - - return FT_Err_Ok; - } - - - const FT_Glyph_Class ft_outline_glyph_class = - { - sizeof( FT_OutlineGlyphRec ), - ft_glyph_format_outline, - - (FT_Glyph_Init_Func) ft_outline_glyph_init, - (FT_Glyph_Done_Func) ft_outline_glyph_done, - (FT_Glyph_Copy_Func) ft_outline_glyph_copy, - (FT_Glyph_Transform_Func)ft_outline_glyph_transform, - (FT_Glyph_BBox_Func) ft_outline_glyph_bbox, - (FT_Glyph_Prepare_Func) ft_outline_glyph_prepare - }; - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** FT_Glyph class and API ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - static - FT_Error ft_new_glyph( FT_Library library, - const FT_Glyph_Class* clazz, - FT_Glyph* aglyph ) - { - FT_Memory memory = library->memory; - FT_Error error; - FT_Glyph glyph; - - - *aglyph = 0; - - if ( !ALLOC( glyph, clazz->glyph_size ) ) - { - glyph->library = library; - glyph->clazz = clazz; - glyph->format = clazz->glyph_format; - - *aglyph = glyph; - } - - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Copy */ - /* */ - /* */ - /* A function used to copy a glyph image. */ - /* */ - /* */ - /* source :: A handle to the source glyph object. */ - /* */ - /* */ - /* target :: A handle to the target glyph object. 0 in case of */ - /* error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Glyph_Copy( FT_Glyph source, - FT_Glyph* target ) - { - FT_Glyph copy; - FT_Error error; - const FT_Glyph_Class* clazz; - - - /* check arguments */ - if ( !target || !source || !source->clazz ) - { - error = FT_Err_Invalid_Argument; - goto Exit; - } - - *target = 0; - - clazz = source->clazz; - error = ft_new_glyph( source->library, clazz, © ); - if ( error ) - goto Exit; - - if ( clazz->glyph_copy ) - error = clazz->glyph_copy( source, copy ); - - if ( error ) - FT_Done_Glyph( copy ); - else - *target = copy; - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Glyph */ - /* */ - /* */ - /* A function used to extract a glyph image from a slot. */ - /* */ - /* */ - /* slot :: A handle to the source glyph slot. */ - /* */ - /* */ - /* aglyph :: A handle to the glyph object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot, - FT_Glyph* aglyph ) - { - FT_Library library = slot->library; - FT_Error error; - FT_Glyph glyph; - - const FT_Glyph_Class* clazz = 0; - - - if ( !slot ) - return FT_Err_Invalid_Slot_Handle; - - if ( !aglyph ) - return FT_Err_Invalid_Argument; - - /* if it is a bitmap, that's easy :-) */ - if ( slot->format == ft_glyph_format_bitmap ) - clazz = &ft_bitmap_glyph_class; - - /* it it is an outline too */ - else if ( slot->format == ft_glyph_format_outline ) - clazz = &ft_outline_glyph_class; - - else - { - /* try to find a renderer that supports the glyph image format */ - FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 ); - - - if ( render ) - clazz = &render->glyph_class; - } - - if ( !clazz ) - { - error = FT_Err_Invalid_Glyph_Format; - goto Exit; - } - - /* create FT_Glyph object */ - error = ft_new_glyph( library, clazz, &glyph ); - if ( error ) - goto Exit; - - /* copy advance while converting it to 16.16 format */ - glyph->advance.x = slot->advance.x << 10; - glyph->advance.y = slot->advance.y << 10; - - /* now import the image from the glyph slot */ - error = clazz->glyph_init( glyph, slot ); - - /* if an error occurred, destroy the glyph */ - if ( error ) - FT_Done_Glyph( glyph ); - else - *aglyph = glyph; - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Transform */ - /* */ - /* */ - /* Transforms a glyph image if its format is scalable. */ - /* */ - /* */ - /* glyph :: A handle to the target glyph object. */ - /* */ - /* matrix :: A pointer to a 2x2 matrix to apply. */ - /* */ - /* delta :: A pointer to a 2d vector to apply. Coordinates are */ - /* expressed in 1/64th of a pixel. */ - /* */ - /* */ - /* FreeType error code (the glyph format is not scalable if it is */ - /* not zero). */ - /* */ - /* */ - /* The 2x2 transformation matrix is also applied to the glyph's */ - /* advance vector. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Glyph_Transform( FT_Glyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ) - { - const FT_Glyph_Class* clazz; - FT_Error error = FT_Err_Ok; - - - if ( !glyph || !glyph->clazz ) - error = FT_Err_Invalid_Argument; - else - { - clazz = glyph->clazz; - if ( clazz->glyph_transform ) - { - /* transform glyph image */ - clazz->glyph_transform( glyph, matrix, delta ); - - /* transform advance vector */ - if ( matrix ) - FT_Vector_Transform( &glyph->advance, matrix ); - } - else - error = FT_Err_Invalid_Glyph_Format; - } - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Get_CBox */ - /* */ - /* */ - /* Returns the glyph image's bounding box. */ - /* */ - /* */ - /* glyph :: A handle to the source glyph object. */ - /* */ - /* mode :: A set of bit flags that indicate how to interpret the */ - /* returned bounding box values. */ - /* */ - /* */ - /* box :: The glyph bounding box. Coordinates are expressed in */ - /* 1/64th of pixels if it is grid-fitted. */ - /* */ - /* */ - /* Coordinates are relative to the glyph origin, using the Y-upwards */ - /* convention. */ - /* */ - /* If `ft_glyph_bbox_subpixels' is set in `mode', the bbox */ - /* coordinates are returned in 26.6 pixels (i.e. 1/64th of pixels). */ - /* Otherwise, coordinates are expressed in integer pixels. */ - /* */ - /* Note that the maximum coordinates are exclusive, which means that */ - /* one can compute the width and height of the glyph image (be it in */ - /* integer or 26.6 pixels) as: */ - /* */ - /* width = bbox.xMax - bbox.xMin; */ - /* height = bbox.yMax - bbox.yMin; */ - /* */ - /* Note also that for 26.6 coordinates, if the */ - /* `ft_glyph_bbox_gridfit' flag is set in `mode;, the coordinates */ - /* will also be grid-fitted, which corresponds to: */ - /* */ - /* bbox.xMin = FLOOR(bbox.xMin); */ - /* bbox.yMin = FLOOR(bbox.yMin); */ - /* bbox.xMax = CEILING(bbox.xMax); */ - /* bbox.yMax = CEILING(bbox.yMax); */ - /* */ - /* The default value (0) for `bbox_mode' is `ft_glyph_bbox_pixels'. */ - /* */ - FT_EXPORT_FUNC( void ) FT_Glyph_Get_CBox( FT_Glyph glyph, - FT_UInt bbox_mode, - FT_BBox* cbox ) - { - const FT_Glyph_Class* clazz; - FT_Error error = FT_Err_Ok; - - - if ( !cbox || !glyph || !glyph->clazz ) - error = FT_Err_Invalid_Argument; - else - { - clazz = glyph->clazz; - if ( !clazz->glyph_bbox ) - error = FT_Err_Invalid_Glyph_Format; - else - { - /* retrieve bbox in 26.6 coordinates */ - clazz->glyph_bbox( glyph, cbox ); - - /* perform grid fitting if needed */ - if ( bbox_mode & ft_glyph_bbox_gridfit ) - { - cbox->xMin &= -64; - cbox->yMin &= -64; - cbox->xMax = ( cbox->xMax + 63 ) & -64; - cbox->yMax = ( cbox->yMax + 63 ) & -64; - } - - /* convert to integer pixels if needed */ - if ( !( bbox_mode & ft_glyph_bbox_subpixels ) ) - { - cbox->xMin >>= 6; - cbox->yMin >>= 6; - cbox->xMax >>= 6; - cbox->yMax >>= 6; - } - } - } - return; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_To_Bitmap */ - /* */ - /* */ - /* Converts a given glyph object to a bitmap glyph object. */ - /* */ - /* */ - /* glyph :: A pointer to a handle to the target glyph. */ - /* */ - /* */ - /* render_mode :: A set of bit flags that describe how the data is */ - /* */ - /* */ - /* origin :: A pointer to a vector used to translate the glyph */ - /* image before rendering. Can be 0 (if no */ - /* translation). The origin is expressed in */ - /* 26.6 pixels. */ - /* */ - /* destroy :: A boolean that indicates that the original glyph */ - /* image should be destroyed by this function. It is */ - /* never destroyed in case of error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The glyph image is translated with the `origin' vector before */ - /* rendering. In case of error, it it translated back to its */ - /* original position and the glyph is left untouched. */ - /* */ - /* The first parameter is a pointer to a FT_Glyph handle, that will */ - /* be replaced by this function. Typically, you would use (omitting */ - /* error handling): */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyph; */ - /* FT_BitmapGlyph glyph_bitmap; */ - /* */ - /* */ - /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ - /* */ - /* // extract glyph image */ - /* error = FT_Get_Glyph( face->glyph, &glyph ); */ - /* */ - /* // convert to a bitmap (default render mode + destroy old) */ - /* if ( glyph->format != ft_glyph_format_bitmap ) */ - /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, */ - /* 0, 1 ); */ - /* if ( error ) // glyph unchanged */ - /* ... */ - /* } */ - /* */ - /* // access bitmap content by typecasting */ - /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ - /* */ - /* // do funny stuff with it, like blitting/drawing */ - /* ... */ - /* */ - /* // discard glyph image (bitmap or not) */ - /* FT_Done_Glyph( glyph ); */ - /* } */ - /* */ - /* */ - /* This function will always fail if the glyph's format isn't */ - /* scalable. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, - FT_ULong render_mode, - FT_Vector* origin, - FT_Bool destroy ) - { - FT_GlyphSlotRec dummy; - FT_Error error; - FT_Glyph glyph; - FT_BitmapGlyph bitmap; - - const FT_Glyph_Class* clazz; - - - /* check argument */ - if ( !the_glyph ) - goto Bad; - - /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */ - /* then calling FT_Render_Glyph_Internal() */ - - glyph = *the_glyph; - if ( !glyph ) - goto Bad; - - clazz = glyph->clazz; - if ( !clazz || !clazz->glyph_prepare ) - goto Bad; - - MEM_Set( &dummy, 0, sizeof ( dummy ) ); - dummy.library = glyph->library; - dummy.format = clazz->glyph_format; - - /* if `origin' is set, translate the glyph image */ - if ( origin ) - FT_Glyph_Transform( glyph, 0, origin ); - - /* create result bitmap glyph */ - error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class, - (FT_Glyph*)&bitmap ); - if ( error ) - goto Exit; - - /* prepare dummy slot for rendering */ - error = clazz->glyph_prepare( glyph, &dummy ) || - FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode ); - - if ( !destroy && origin ) - { - FT_Vector v; - - - v.x = -origin->x; - v.y = -origin->y; - FT_Glyph_Transform( glyph, 0, &v ); - } - - /* in case of succes, copy the bitmap to the glyph bitmap */ - if ( !error ) - { - error = ft_bitmap_glyph_init( bitmap, &dummy ); - if ( error ) - { - /* this should never happen, but let's be safe */ - FT_Done_Glyph( FT_GLYPH( bitmap ) ); - goto Exit; - } - - if ( destroy ) - FT_Done_Glyph( glyph ); - - *the_glyph = FT_GLYPH( bitmap ); - } - - Exit: - return error; - - Bad: - error = FT_Err_Invalid_Argument; - goto Exit; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Glyph */ - /* */ - /* */ - /* Destroys a given glyph. */ - /* */ - /* */ - /* glyph :: A handle to the target glyph object. */ - /* */ - FT_EXPORT_FUNC( void ) FT_Done_Glyph( FT_Glyph glyph ) - { - if ( glyph ) - { - FT_Memory memory = glyph->library->memory; - const FT_Glyph_Class* clazz = glyph->clazz; - - - if ( clazz->glyph_done ) - clazz->glyph_done( glyph ); - - FREE( glyph ); - } - } - - -#if 0 - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - /* Compute the norm of a vector */ - -#ifdef FT_CONFIG_OPTION_OLD_CALCS - - static - FT_Pos ft_norm( FT_Vector* vec ) - { - FT_Int64 t1, t2; - - - MUL_64( vec->x, vec->x, t1 ); - MUL_64( vec->y, vec->y, t2 ); - ADD_64( t1, t2, t1 ); - - return (FT_Pos)SQRT_64( t1 ); - } - -#else /* FT_CONFIG_OPTION_OLD_CALCS */ - - static - FT_Pos ft_norm( FT_Vector* vec ) - { - FT_F26Dot6 u, v, d; - FT_Int shift; - FT_ULong H, L, L2, hi, lo, med; - - - u = vec->x; if ( u < 0 ) u = -u; - v = vec->y; if ( v < 0 ) v = -v; - - if ( u < v ) - { - d = u; - u = v; - v = d; - } - - /* check that we are not trying to normalize zero! */ - if ( u == 0 ) - return 0; - - /* compute (u*u + v*v) on 64 bits with two 32-bit registers [H:L] */ - hi = (FT_ULong)u >> 16; - lo = (FT_ULong)u & 0xFFFF; - med = hi * lo; - - H = hi * hi + ( med >> 15 ); - med <<= 17; - L = lo * lo + med; - if ( L < med ) - H++; - - hi = (FT_ULong)v >> 16; - lo = (FT_ULong)v & 0xFFFF; - med = hi * lo; - - H += hi * hi + ( med >> 15 ); - med <<= 17; - L2 = lo * lo + med; - if ( L2 < med ) - H++; - - L += L2; - if ( L < L2 ) - H++; - - /* if the value is smaller than 32 bits */ - shift = 0; - if ( H == 0 ) - { - while ( ( L & 0xC0000000UL ) == 0 ) - { - L <<= 2; - shift++; - } - return ( FT_Sqrt32( L ) >> shift ); - } - else - { - while ( H ) - { - L = ( L >> 2 ) | ( H << 30 ); - H >>= 2; - shift++; - } - return ( FT_Sqrt32( L ) << shift ); - } - } - -#endif /* FT_CONFIG_OPTION_OLD_CALCS */ - - - static - int ft_test_extrema( FT_Outline* outline, - int n ) - { - FT_Vector *prev, *cur, *next; - FT_Pos product; - FT_Int first, last; - - - /* we need to compute the `previous' and `next' point */ - /* for these extrema. */ - cur = outline->points + n; - prev = cur - 1; - next = cur + 1; - - first = 0; - for ( c = 0; c < outline->n_contours; c++ ) - { - last = outline->contours[c]; - - if ( n == first ) - prev = outline->points + last; - - if ( n == last ) - next = outline->points + first; - - first = last + 1; - } - - product = FT_MulDiv( cur->x - prev->x, /* in.x */ - next->y - cur->y, /* out.y */ - 0x40 ) - - - FT_MulDiv( cur->y - prev->y, /* in.y */ - next->x - cur->x, /* out.x */ - 0x40 ); - - if ( product ) - product = product > 0 ? 1 : -1; - - return product; - } - - - /* Compute the orientation of path filling. It differs between TrueType */ - /* and Type1 formats. We could use the `ft_outline_reverse_fill' flag, */ - /* but it is better to re-compute it directly (it seems that this flag */ - /* isn't correctly set for some weird composite glyphs currently). */ - /* */ - /* We do this by computing bounding box points, and computing their */ - /* curvature. */ - /* */ - /* The function returns either 1 or -1. */ - /* */ - static - int ft_get_orientation( FT_Outline* outline ) - { - FT_BBox box; - FT_BBox indices; - int n, last; - - - indices.xMin = -1; - indices.yMin = -1; - indices.xMax = -1; - indices.yMax = -1; - - box.xMin = box.yMin = 32767; - box.xMax = box.yMax = -32768; - - /* is it empty ? */ - if ( outline->n_contours < 1 ) - return 1; - - last = outline->contours[outline->n_contours - 1]; - - for ( n = 0; n <= last; n++ ) - { - FT_Pos x, y; - - - x = outline->points[n].x; - if ( x < box.xMin ) - { - box.xMin = x; - indices.xMin = n; - } - if ( x > box.xMax ) - { - box.xMax = x; - indices.xMax = n; - } - - y = outline->points[n].y; - if ( y < box.yMin ) - { - box.yMin = y; - indices.yMin = n; - } - if ( y > box.yMax ) - { - box.yMax = y; - indices.yMax = n; - } - } - - /* test orientation of the xmin */ - return ft_test_extrema( outline, indices.xMin ) || - ft_test_extrema( outline, indices.yMin ) || - ft_test_extrema( outline, indices.xMax ) || - ft_test_extrema( outline, indices.yMax ) || - 1; /* this is an empty glyph? */ - } - - - static - FT_Error ft_embolden( FT_Face original, - FT_Outline* outline, - FT_Pos* advance ) - { - FT_Vector u, v; - FT_Vector* points; - FT_Vector cur, prev, next; - FT_Pos distance; - int c, n, first, orientation; - - FT_UNUSED( advance ); - - - /* compute control distance */ - distance = FT_MulFix( original->em_size / 60, - original->size->metrics.y_scale ); - - orientation = ft_get_orientation( &original->glyph->outline ); - - points = original->glyph->outline.points; - - first = 0; - for ( c = 0; c < outline->n_contours; c++ ) - { - int last = outline->contours[c]; - - - prev = points[last]; - - for ( n = first; n <= last; n++ ) - { - FT_Pos norm, delta, d; - FT_Vector in, out; - - - cur = points[n]; - if ( n < last ) next = points[n + 1]; - else next = points[first]; - - /* compute the in and out vectors */ - in.x = cur.x - prev.x; - in.y = cur.y - prev.y; - - out.x = next.x - cur.x; - out.y = next.y - cur.y; - - /* compute U and V */ - norm = ft_norm( &in ); - u.x = orientation * FT_DivFix( in.y, norm ); - u.y = orientation * -FT_DivFix( in.x, norm ); - - norm = ft_norm( &out ); - v.x = orientation * FT_DivFix( out.y, norm ); - v.y = orientation * -FT_DivFix( out.x, norm ); - - d = distance; - - if ( ( outline->flags[n] & FT_Curve_Tag_On ) == 0 ) - d *= 2; - - /* Check discriminant for parallel vectors */ - delta = FT_MulFix( u.x, v.y ) - FT_MulFix( u.y, v.x ); - if ( delta > FT_BOLD_THRESHOLD || delta < -FT_BOLD_THRESHOLD ) - { - /* Move point -- compute A and B */ - FT_Pos x, y, A, B; - - - A = d + FT_MulFix( cur.x, u.x ) + FT_MulFix( cur.y, u.y ); - B = d + FT_MulFix( cur.x, v.x ) + FT_MulFix( cur.y, v.y ); - - x = FT_MulFix( A, v.y ) - FT_MulFix( B, u.y ); - y = FT_MulFix( B, u.x ) - FT_MulFix( A, v.x ); - - outline->points[n].x = distance + FT_DivFix( x, delta ); - outline->points[n].y = distance + FT_DivFix( y, delta ); - } - else - { - /* Vectors are nearly parallel */ - FT_Pos x, y; - - - x = distance + cur.x + FT_MulFix( d, u.x + v.x ) / 2; - y = distance + cur.y + FT_MulFix( d, u.y + v.y ) / 2; - - outline->points[n].x = x; - outline->points[n].y = y; - } - - prev = cur; - } - - first = last + 1; - } - - if ( advance ) - *advance = ( *advance + distance * 4 ) & -64; - - return 0; - } - -#endif /* 0 -- EXPERIMENTAL STUFF! */ - - -/* END */ diff --git a/src/freetype/base/ftinit.c b/src/freetype/base/ftinit.c deleted file mode 100644 index cc754eb856..0000000000 --- a/src/freetype/base/ftinit.c +++ /dev/null @@ -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 -#include -#include -#include - - - /*************************************************************************/ - /* */ - /* 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 - -#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 - 0 - }; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Add_Default_Modules */ - /* */ - /* */ - /* 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). */ - /* */ - /* */ - /* 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++; - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Init_FreeType */ - /* */ - /* */ - /* Initializes a new FreeType library object. The set of drivers */ - /* that are registered by this function is determined at build time. */ - /* */ - /* */ - /* library :: A handle to a new library object. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftlist.c b/src/freetype/base/ftlist.c deleted file mode 100644 index 0158ba4434..0000000000 --- a/src/freetype/base/ftlist.c +++ /dev/null @@ -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 -#include -#include - - - /*************************************************************************/ - /* */ - /* 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 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Find */ - /* */ - /* */ - /* Finds the list node for a given listed object. */ - /* */ - /* */ - /* list :: A pointer to the parent list. */ - /* data :: The address of the listed object. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Add */ - /* */ - /* */ - /* Appends an element to the end of a list. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Insert */ - /* */ - /* */ - /* Inserts an element at the head of a list. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Remove */ - /* */ - /* */ - /* Removes a node from a list. This function doesn't check whether */ - /* the node is in the list! */ - /* */ - /* */ - /* node :: The node to remove. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Up */ - /* */ - /* */ - /* Moves a node to the head/top of a list. Used to maintain LRU */ - /* lists. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Iterate */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Finalize */ - /* */ - /* */ - /* Destroys all elements in the list as well as the list itself. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftmm.c b/src/freetype/base/ftmm.c deleted file mode 100644 index 0f6fddea28..0000000000 --- a/src/freetype/base/ftmm.c +++ /dev/null @@ -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 -#include - - - /*************************************************************************/ - /* */ - /* 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 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Multi_Master */ - /* */ - /* */ - /* Retrieves the Multiple Master descriptor of a given font. */ - /* */ - /* */ - /* face :: A handle to the source face. */ - /* */ - /* */ - /* master :: The Multiple Masters descriptor. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_MM_Design_Coordinates */ - /* */ - /* */ - /* For Multiple Masters fonts, choose an interpolated font design */ - /* through design coordinates. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_MM_Blend_Coordinates */ - /* */ - /* */ - /* For Multiple Masters fonts, choose an interpolated font design */ - /* through normalized blend coordinates. */ - /* */ - /* */ - /* 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). */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftnames.c b/src/freetype/base/ftnames.c deleted file mode 100644 index 43a0d12d07..0000000000 --- a/src/freetype/base/ftnames.c +++ /dev/null @@ -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 -#include - - -#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 */ diff --git a/src/freetype/base/ftobjs.c b/src/freetype/base/ftobjs.c deleted file mode 100644 index de74882554..0000000000 --- a/src/freetype/base/ftobjs.c +++ /dev/null @@ -1,3246 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftobjs.c */ -/* */ -/* The FreeType private base classes (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 -#include -#include -#include - -#include - -#include /* for strcmp() */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** M E M O R Y ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* 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_memory - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Alloc */ - /* */ - /* */ - /* Allocates a new block of memory. The returned area is always */ - /* zero-filled; this is a strong convention in many FreeType parts. */ - /* */ - /* */ - /* memory :: A handle to a given `memory object' which handles */ - /* allocation. */ - /* */ - /* size :: The size in bytes of the block to allocate. */ - /* */ - /* */ - /* P :: A pointer to the fresh new block. It should be set to */ - /* NULL if `size' is 0, or in case of error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - BASE_FUNC( FT_Error ) FT_Alloc( FT_Memory memory, - FT_Long size, - void** P ) - { - FT_Assert( P != 0 ); - - if ( size > 0 ) - { - *P = memory->alloc( memory, size ); - if ( !*P ) - { - FT_ERROR(( "FT_Alloc:" )); - FT_ERROR(( " Out of memory? (%ld requested)\n", - size )); - - return FT_Err_Out_Of_Memory; - } - MEM_Set( *P, 0, size ); - } - else - *P = NULL; - - FT_TRACE7(( "FT_Alloc:" )); - FT_TRACE7(( " size = %ld, block = 0x%08p, ref = 0x%08p\n", - size, *P, P )); - - return FT_Err_Ok; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Realloc */ - /* */ - /* */ - /* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ - /* from the heap, possibly changing `*P'. */ - /* */ - /* */ - /* memory :: A handle to a given `memory object' which handles */ - /* reallocation. */ - /* */ - /* current :: The current block size in bytes. */ - /* */ - /* size :: The new block size in bytes. */ - /* */ - /* */ - /* P :: A pointer to the fresh new block. It should be set to */ - /* NULL if `size' is 0, or in case of error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* All callers of FT_Realloc() _must_ provide the current block size */ - /* as well as the new one. */ - /* */ - BASE_FUNC( FT_Error ) FT_Realloc( FT_Memory memory, - FT_Long current, - FT_Long size, - void** P ) - { - void* Q; - - - FT_Assert( P != 0 ); - - /* if the original pointer is NULL, call FT_Alloc() */ - if ( !*P ) - return FT_Alloc( memory, size, P ); - - /* if the new block if zero-sized, clear the current one */ - if ( size <= 0 ) - { - FT_Free( memory, P ); - return FT_Err_Ok; - } - - Q = memory->realloc( memory, current, size, *P ); - if ( !Q ) - goto Fail; - - *P = Q; - return FT_Err_Ok; - - Fail: - FT_ERROR(( "FT_Realloc:" )); - FT_ERROR(( " Failed (current %ld, requested %ld)\n", - current, size )); - return FT_Err_Out_Of_Memory; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Free */ - /* */ - /* */ - /* Releases a given block of memory allocated through FT_Alloc(). */ - /* */ - /* */ - /* memory :: A handle to a given `memory object' which handles */ - /* memory deallocation */ - /* */ - /* P :: This is the _address_ of a _pointer_ which points to the */ - /* allocated block. It is always set to NULL on exit. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* If P or *P are NULL, this function should return successfully. */ - /* This is a strong convention within all of FreeType and its */ - /* drivers. */ - /* */ - BASE_FUNC( void ) FT_Free( FT_Memory memory, - void** P ) - { - FT_TRACE7(( "FT_Free:" )); - FT_TRACE7(( " Freeing block 0x%08p, ref 0x%08p\n", - P, P ? *P : (void*)0 )); - - if ( P && *P ) - { - memory->free( memory, *P ); - *P = 0; - } - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** S T R E A M ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* ft_new_input_stream */ - /* */ - /* */ - /* Creates a new input stream object from an FT_Open_Args structure. */ - /* */ - /* */ - /* The function expects a valid `astream' parameter. */ - /* */ - static - FT_Error ft_new_input_stream( FT_Library library, - FT_Open_Args* args, - FT_Stream* astream ) - { - FT_Error error; - FT_Memory memory; - FT_Stream stream; - - - if ( !library ) - return FT_Err_Invalid_Library_Handle; - - if ( !args ) - return FT_Err_Invalid_Argument; - - *astream = 0; - memory = library->memory; - if ( ALLOC( stream, sizeof ( *stream ) ) ) - goto Exit; - - stream->memory = memory; - - /* now, look at the stream flags */ - if ( args->flags & ft_open_memory ) - { - error = 0; - FT_New_Memory_Stream( library, - args->memory_base, - args->memory_size, - stream ); - } - else if ( args->flags & ft_open_pathname ) - { - error = FT_New_Stream( args->pathname, stream ); - stream->pathname.pointer = args->pathname; - } - else if ( args->flags & ft_open_stream && args->stream ) - { - *stream = *(args->stream); - stream->memory = memory; - } - else - error = FT_Err_Invalid_Argument; - - if ( error ) - FREE( stream ); - - *astream = stream; - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Stream */ - /* */ - /* */ - /* Closes and destroys a stream object. */ - /* */ - /* */ - /* stream :: The stream to be closed and destroyed. */ - /* */ - FT_EXPORT_FUNC( void ) FT_Done_Stream( FT_Stream stream ) - { - if ( stream && stream->close ) - stream->close( stream ); - } - - - static - void ft_done_stream( FT_Stream* astream ) - { - FT_Stream stream = *astream; - FT_Memory memory = stream->memory; - - - if ( stream->close ) - stream->close( stream ); - - FREE( stream ); - *astream = 0; - } - - -#undef FT_COMPONENT -#define FT_COMPONENT trace_objs - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** G L Y P H L O A D E R ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The glyph loader is a simple object which is used to load a set of */ - /* glyphs easily. It is critical for the correct loading of composites. */ - /* */ - /* Ideally, one can see it as a stack of abstract `glyph' objects. */ - /* */ - /* loader.base Is really the bottom of the stack. It describes a */ - /* single glyph image made of the juxtaposition of */ - /* several glyphs (those `in the stack'). */ - /* */ - /* loader.current Describes the top of the stack, on which a new */ - /* glyph can be loaded. */ - /* */ - /* Rewind Clears the stack. */ - /* Prepare Set up `loader.current' for addition of a new glyph */ - /* image. */ - /* Add Add the `current' glyph image to the `base' one, */ - /* and prepare for another one. */ - /* */ - /* The glyph loader is now a base object. Each driver used to */ - /* re-implement it in one way or the other, which wasted code and */ - /* energy. */ - /* */ - /*************************************************************************/ - - - /* create a new glyph loader */ - BASE_FUNC( FT_Error ) FT_GlyphLoader_New( FT_Memory memory, - FT_GlyphLoader** aloader ) - { - FT_GlyphLoader* loader; - FT_Error error; - - - if ( !ALLOC( loader, sizeof ( *loader ) ) ) - { - loader->memory = memory; - *aloader = loader; - } - return error; - } - - - /* rewind the glyph loader - reset counters to 0 */ - BASE_FUNC( void ) FT_GlyphLoader_Rewind( FT_GlyphLoader* loader ) - { - FT_GlyphLoad* base = &loader->base; - FT_GlyphLoad* current = &loader->current; - - - base->outline.n_points = 0; - base->outline.n_contours = 0; - base->num_subglyphs = 0; - - *current = *base; - } - - - /* reset the glyph loader, frees all allocated tables */ - /* and starts from zero */ - BASE_FUNC( void ) FT_GlyphLoader_Reset( FT_GlyphLoader* loader ) - { - FT_Memory memory = loader->memory; - - - FREE( loader->base.outline.points ); - FREE( loader->base.outline.tags ); - FREE( loader->base.outline.contours ); - FREE( loader->base.extra_points ); - FREE( loader->base.subglyphs ); - - loader->max_points = 0; - loader->max_contours = 0; - loader->max_subglyphs = 0; - - FT_GlyphLoader_Rewind( loader ); - } - - - /* delete a glyph loader */ - BASE_FUNC( void ) FT_GlyphLoader_Done( FT_GlyphLoader* loader ) - { - if ( loader ) - { - FT_Memory memory = loader->memory; - - - FT_GlyphLoader_Reset( loader ); - FREE( loader ); - } - } - - - /* re-adjust the `current' outline fields */ - static - void FT_GlyphLoader_Adjust_Points( FT_GlyphLoader* loader ) - { - FT_Outline* base = &loader->base.outline; - FT_Outline* current = &loader->current.outline; - - - current->points = base->points + base->n_points; - current->tags = base->tags + base->n_points; - current->contours = base->contours + base->n_contours; - - /* handle extra points table - if any */ - if ( loader->use_extra ) - loader->current.extra_points = - loader->base.extra_points + base->n_points; - } - - - BASE_FUNC( FT_Error ) FT_GlyphLoader_Create_Extra( - FT_GlyphLoader* loader ) - { - FT_Error error; - FT_Memory memory = loader->memory; - - - if ( !ALLOC_ARRAY( loader->base.extra_points, - loader->max_points, FT_Vector ) ) - { - loader->use_extra = 1; - FT_GlyphLoader_Adjust_Points( loader ); - } - return error; - } - - - /* re-adjust the `current' subglyphs field */ - static - void FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader* loader ) - { - FT_GlyphLoad* base = &loader->base; - FT_GlyphLoad* current = &loader->current; - - - current->subglyphs = base->subglyphs + base->num_subglyphs; - } - - - /* Ensure that we can add `n_points' and `n_contours' to our glyph. this */ - /* function reallocates its outline tables if necessary. Note that it */ - /* DOESN'T change the number of points within the loader! */ - /* */ - BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Points( - FT_GlyphLoader* loader, - FT_UInt n_points, - FT_UInt n_contours ) - { - FT_Memory memory = loader->memory; - FT_Error error = FT_Err_Ok; - FT_Outline* base = &loader->base.outline; - FT_Outline* current = &loader->current.outline; - FT_Bool adjust = 1; - - FT_UInt new_max; - - - /* check points & tags */ - new_max = base->n_points + current->n_points + n_points; - if ( new_max > loader->max_points ) - { - new_max = ( new_max + 7 ) & -8; - if ( REALLOC_ARRAY( base->points, base->n_points, - new_max, FT_Vector ) || - REALLOC_ARRAY( base->tags, base->n_points, - new_max, FT_Byte ) ) - goto Exit; - - if ( loader->use_extra && - REALLOC_ARRAY( loader->base.extra_points, base->n_points, - new_max, FT_Vector ) ) - goto Exit; - - adjust = 1; - loader->max_points = new_max; - } - - /* check contours */ - new_max = base->n_contours + current->n_contours + - n_contours; - if ( new_max > loader->max_contours ) - { - new_max = ( new_max + 3 ) & -4; - if ( REALLOC_ARRAY( base->contours, base->n_contours, - new_max, FT_Short ) ) - goto Exit; - - adjust = 1; - loader->max_contours = new_max; - } - - if ( adjust ) - FT_GlyphLoader_Adjust_Points( loader ); - - Exit: - return error; - } - - - /* Ensure that we can add `n_subglyphs' to our glyph. this function */ - /* reallocates its subglyphs table if necessary. Note that it DOES */ - /* NOT change the number of subglyphs within the loader! */ - /* */ - BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Subglyphs( - FT_GlyphLoader* loader, - FT_UInt n_subs ) - { - FT_Memory memory = loader->memory; - FT_Error error = FT_Err_Ok; - FT_UInt new_max; - - FT_GlyphLoad* base = &loader->base; - FT_GlyphLoad* current = &loader->current; - - - new_max = base->num_subglyphs + current->num_subglyphs + n_subs; - if ( new_max > loader->max_subglyphs ) - { - new_max = ( new_max + 1 ) & -2; - if ( REALLOC_ARRAY( base->subglyphs, base->num_subglyphs, - new_max, FT_SubGlyph ) ) - goto Exit; - - loader->max_subglyphs = new_max; - - FT_GlyphLoader_Adjust_Subglyphs( loader ); - } - - Exit: - return error; - } - - - /* prepare loader for the addition of a new glyph on top of the base one */ - BASE_FUNC( void ) FT_GlyphLoader_Prepare( FT_GlyphLoader* loader ) - { - FT_GlyphLoad* current = &loader->current; - - - current->outline.n_points = 0; - current->outline.n_contours = 0; - current->num_subglyphs = 0; - - FT_GlyphLoader_Adjust_Points ( loader ); - FT_GlyphLoader_Adjust_Subglyphs( loader ); - } - - - /* add current glyph to the base image - and prepare for another */ - BASE_FUNC( void ) FT_GlyphLoader_Add( FT_GlyphLoader* loader ) - { - FT_GlyphLoad* base = &loader->base; - FT_GlyphLoad* current = &loader->current; - - FT_UInt n_curr_contours = current->outline.n_contours; - FT_UInt n_base_points = base->outline.n_points; - FT_UInt n; - - - base->outline.n_points += current->outline.n_points; - base->outline.n_contours += current->outline.n_contours; - base->num_subglyphs += current->num_subglyphs; - - /* adjust contours count in newest outline */ - for ( n = 0; n < n_curr_contours; n++ ) - current->outline.contours[n] += n_base_points; - - /* prepare for another new glyph image */ - FT_GlyphLoader_Prepare( loader ); - } - - - BASE_FUNC( FT_Error ) FT_GlyphLoader_Copy_Points( FT_GlyphLoader* target, - FT_GlyphLoader* source ) - { - FT_Error error; - FT_UInt num_points = source->base.outline.n_points; - FT_UInt num_contours = source->base.outline.n_contours; - - - error = FT_GlyphLoader_Check_Points( target, num_points, num_contours ); - if ( !error ) - { - FT_Outline* out = &target->base.outline; - FT_Outline* in = &source->base.outline; - - - MEM_Copy( out->points, in->points, - num_points * sizeof ( FT_Vector ) ); - MEM_Copy( out->tags, in->tags, - num_points * sizeof ( char ) ); - MEM_Copy( out->contours, in->contours, - num_contours * sizeof ( short ) ); - - /* do we need to copy the extra points? */ - if ( target->use_extra && source->use_extra ) - MEM_Copy( target->base.extra_points, source->base.extra_points, - num_points * sizeof ( FT_Vector ) ); - - out->n_points = num_points; - out->n_contours = num_contours; - - FT_GlyphLoader_Adjust_Points( target ); - } - - return error; - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** FACE, SIZE & GLYPH SLOT OBJECTS ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - static - FT_Error ft_glyphslot_init( FT_GlyphSlot slot ) - { - FT_Driver driver = slot->face->driver; - FT_Driver_Class* clazz = driver->clazz; - FT_Memory memory = driver->root.memory; - FT_Error error = FT_Err_Ok; - - - slot->library = driver->root.library; - - if ( FT_DRIVER_USES_OUTLINES( driver ) ) - error = FT_GlyphLoader_New( memory, &slot->loader ); - - if ( !error && clazz->init_slot ) - error = clazz->init_slot( slot ); - - return error; - } - - - static - void ft_glyphslot_clear( FT_GlyphSlot slot ) - { - /* free bitmap if needed */ - if ( slot->flags & ft_glyph_own_bitmap ) - { - FT_Memory memory = FT_FACE_MEMORY( slot->face ); - - - FREE( slot->bitmap.buffer ); - slot->flags &= ~ft_glyph_own_bitmap; - } - - /* clear all public fields in the glyph slot */ - MEM_Set( &slot->metrics, 0, sizeof ( slot->metrics ) ); - MEM_Set( &slot->outline, 0, sizeof ( slot->outline ) ); - MEM_Set( &slot->bitmap, 0, sizeof ( slot->bitmap ) ); - - slot->bitmap_left = 0; - slot->bitmap_top = 0; - slot->num_subglyphs = 0; - slot->subglyphs = 0; - slot->control_data = 0; - slot->control_len = 0; - slot->other = 0; - slot->format = ft_glyph_format_none; - - slot->linearHoriAdvance = 0; - slot->linearVertAdvance = 0; - } - - - static - void ft_glyphslot_done( FT_GlyphSlot slot ) - { - FT_Driver driver = slot->face->driver; - FT_Driver_Class* clazz = driver->clazz; - FT_Memory memory = driver->root.memory; - - - /* free bitmap buffer if needed */ - if ( slot->flags & ft_glyph_own_bitmap ) - FREE( slot->bitmap.buffer ); - - /* free glyph loader */ - if ( FT_DRIVER_USES_OUTLINES( driver ) ) - { - FT_GlyphLoader_Done( slot->loader ); - slot->loader = 0; - } - - if ( clazz->done_slot ) - clazz->done_slot( slot ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_GlyphSlot */ - /* */ - /* */ - /* It is sometimes useful to have more than one glyph slot for a */ - /* given face object. This function is used to create additional */ - /* slots. All of them are automatically discarded when the face is */ - /* destroyed. */ - /* */ - /* */ - /* face :: A handle to a parent face object. */ - /* */ - /* */ - /* aslot :: A handle to a new glyph slot object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_New_GlyphSlot( FT_Face face, - FT_GlyphSlot* aslot ) - { - FT_Error error; - FT_Driver driver; - FT_Driver_Class* clazz; - FT_Memory memory; - FT_GlyphSlot slot; - - - if ( !face || !aslot || !face->driver ) - return FT_Err_Invalid_Argument; - - *aslot = 0; - - driver = face->driver; - clazz = driver->clazz; - memory = driver->root.memory; - - FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); - if ( !ALLOC( slot, clazz->slot_object_size ) ) - { - slot->face = face; - - error = ft_glyphslot_init( slot ); - if ( error ) - { - ft_glyphslot_done( slot ); - FREE( slot ); - goto Exit; - } - - *aslot = slot; - } - - Exit: - FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error )); - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_GlyphSlot */ - /* */ - /* */ - /* Destroys a given glyph slot. Remember however that all slots are */ - /* automatically destroyed with its parent. Using this function is */ - /* not always mandatory. */ - /* */ - /* */ - /* slot :: A handle to a target glyph slot. */ - /* */ - FT_EXPORT_FUNC( void ) FT_Done_GlyphSlot( FT_GlyphSlot slot ) - { - if ( slot ) - { - FT_Driver driver = slot->face->driver; - FT_Memory memory = driver->root.memory; - FT_GlyphSlot* parent; - FT_GlyphSlot cur; - - - /* Remove slot from its parent face's list */ - parent = &slot->face->glyph; - cur = *parent; - - while ( cur ) - { - if ( cur == slot ) - { - *parent = cur->next; - ft_glyphslot_done( slot ); - FREE( slot ); - break; - } - cur = cur->next; - } - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Transform */ - /* */ - /* */ - /* A function used to set the transformation that is applied to glyph */ - /* images just before they are converted to bitmaps in a glyph slot */ - /* when FT_Render_Glyph() is called. */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* */ - /* matrix :: A pointer to the transformation's 2x2 matrix. Use 0 for */ - /* the identity matrix. */ - /* delta :: A pointer to the translation vector. Use 0 for the null */ - /* vector. */ - /* */ - /* */ - /* The transformation is only applied to scalable image formats after */ - /* the glyph has been loaded. It means that hinting is unaltered by */ - /* the transformation and is performed on the character size given in */ - /* the last call to FT_Set_Char_Sizes() or FT_Set_Pixel_Sizes(). */ - /* */ - FT_EXPORT_FUNC( void ) FT_Set_Transform( FT_Face face, - FT_Matrix* matrix, - FT_Vector* delta ) - { - if ( !face ) - return; - - face->transform_flags = 0; - - if ( !matrix ) - { - face->transform_matrix.xx = 0x10000L; - face->transform_matrix.xy = 0; - face->transform_matrix.yx = 0; - face->transform_matrix.yy = 0x10000L; - matrix = &face->transform_matrix; - } - else - face->transform_matrix = *matrix; - - /* set transform_flags bit flag 0 if `matrix' isn't the identity */ - if ( ( matrix->xy | matrix->yx ) || - matrix->xx != 0x10000L || - matrix->yy != 0x10000L ) - face->transform_flags |= 1; - - if ( !delta ) - { - face->transform_delta.x = 0; - face->transform_delta.y = 0; - delta = &face->transform_delta; - } - else - face->transform_delta = *delta; - - /* set transform_flags bit flag 1 if `delta' isn't the null vector */ - if ( delta->x | delta->y ) - face->transform_flags |= 2; - } - - - static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Load_Glyph */ - /* */ - /* */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size. */ - /* */ - /* */ - /* face :: A handle to the target face object where the glyph */ - /* will be loaded. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX 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). */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* If the glyph image is not a bitmap, and if the bit flag */ - /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ - /* transformed with the information passed to a previous call to */ - /* FT_Set_Transform. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Load_Glyph( FT_Face face, - FT_UInt glyph_index, - FT_Int load_flags ) - { - FT_Error error; - FT_Driver driver; - FT_GlyphSlot slot; - FT_Library library; - FT_Bool autohint; - FT_Module hinter; - - - if ( !face || !face->size || !face->glyph ) - return FT_Err_Invalid_Face_Handle; - - if ( glyph_index >= (FT_UInt)face->num_glyphs ) - return FT_Err_Invalid_Argument; - - slot = face->glyph; - ft_glyphslot_clear( slot ); - - driver = face->driver; - - /* when the flag NO_RECURSE is set, we disable hinting and scaling */ - if ( load_flags & FT_LOAD_NO_RECURSE ) - load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; - - /* do we need to load the glyph through the auto-hinter? */ - library = driver->root.library; - hinter = library->auto_hinter; - autohint = hinter && - !( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ); - if ( autohint ) - { - if ( FT_DRIVER_HAS_HINTER( driver ) && - !( load_flags & FT_LOAD_FORCE_AUTOHINT ) ) - autohint = 0; - } - - if ( autohint ) - { - FT_AutoHinter_Interface* hinting; - - - hinting = (FT_AutoHinter_Interface*)hinter->clazz->module_interface; - error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size, - glyph_index, load_flags ); - } - else - error = driver->clazz->load_glyph( slot, - face->size, - glyph_index, - load_flags ); - if ( error ) - goto Exit; - - /* compute the advance */ - if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) - { - slot->advance.x = 0; - slot->advance.y = slot->metrics.vertAdvance; - } - else - { - slot->advance.x = slot->metrics.horiAdvance; - slot->advance.y = 0; - } - - /* now, transform the glyph image when needed */ - if ( face->transform_flags ) - { - /* get renderer */ - FT_Renderer renderer = ft_lookup_glyph_renderer( slot ); - - - if ( renderer ) - error = renderer->clazz->transform_glyph( renderer, slot, - &face->transform_matrix, - &face->transform_delta ); - /* transform advance */ - FT_Vector_Transform( &slot->advance, &face->transform_matrix ); - } - - /* do we need to render the image now? */ - if ( !error && - slot->format != ft_glyph_format_bitmap && - slot->format != ft_glyph_format_composite && - load_flags & FT_LOAD_RENDER ) - { - error = FT_Render_Glyph( slot, - ( load_flags & FT_LOAD_MONOCHROME ) - ? ft_render_mode_mono - : ft_render_mode_normal ); - } - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Load_Char */ - /* */ - /* */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size, according to its character code. */ - /* */ - /* */ - /* face :: A handle to a target face object where the glyph */ - /* will be loaded. */ - /* */ - /* char_code :: The glyph's character code, according to the */ - /* current charmap used in the face. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX 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). */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* If the face has no current charmap, or if the character code */ - /* is not defined in the charmap, this function will return an */ - /* error. */ - /* */ - /* If the glyph image is not a bitmap, and if the bit flag */ - /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ - /* transformed with the information passed to a previous call to */ - /* FT_Set_Transform(). */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Load_Char( FT_Face face, - FT_ULong char_code, - FT_Int load_flags ) - { - FT_UInt glyph_index; - - - if ( !face ) - return FT_Err_Invalid_Face_Handle; - - glyph_index = (FT_UInt)char_code; - if ( face->charmap ) - glyph_index = FT_Get_Char_Index( face, char_code ); - - return FT_Load_Glyph( face, glyph_index, load_flags ); - } - - - /* destructor for sizes list */ - static - void destroy_size( FT_Memory memory, - FT_Size size, - FT_Driver driver ) - { - /* finalize client-specific data */ - if ( size->generic.finalizer ) - size->generic.finalizer( size ); - - /* finalize format-specific stuff */ - if ( driver->clazz->done_size ) - driver->clazz->done_size( size ); - - FREE( size ); - } - - - /* destructor for faces list */ - static - void destroy_face( FT_Memory memory, - FT_Face face, - FT_Driver driver ) - { - FT_Driver_Class* clazz = driver->clazz; - - - /* discard auto-hinting data */ - if ( face->autohint.finalizer ) - face->autohint.finalizer( face->autohint.data ); - - /* Discard glyph slots for this face */ - /* Beware! FT_Done_GlyphSlot() changes the field `face->slot' */ - while ( face->glyph ) - FT_Done_GlyphSlot( face->glyph ); - - /* Discard all sizes for this face */ - FT_List_Finalize( &face->sizes_list, - (FT_List_Destructor)destroy_size, - memory, - driver ); - face->size = 0; - - /* Now discard client data */ - if ( face->generic.finalizer ) - face->generic.finalizer( face ); - - /* finalize format-specific stuff */ - if ( clazz->done_face ) - clazz->done_face( face ); - - /* close the stream for this face if needed */ - if ( ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) == 0 ) - ft_done_stream( &face->stream ); - - /* get rid of it */ - FREE( face ); - } - - - static - void Destroy_Driver( FT_Driver driver ) - { - FT_List_Finalize( &driver->faces_list, - (FT_List_Destructor)destroy_face, - driver->root.memory, - driver ); - - /* check whether we need to drop the driver's glyph loader */ - if ( FT_DRIVER_USES_OUTLINES( driver ) ) - FT_GlyphLoader_Done( driver->glyph_loader ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* open_face */ - /* */ - /* */ - /* This function does some work for FT_Open_Face(). */ - /* */ - static - FT_Error open_face( FT_Driver driver, - FT_Stream stream, - FT_Long face_index, - FT_Int num_params, - FT_Parameter* params, - FT_Face* aface ) - { - FT_Memory memory; - FT_Driver_Class* clazz; - FT_Face face = 0; - FT_Error error; - - - clazz = driver->clazz; - memory = driver->root.memory; - - /* allocate the face object and perform basic initialization */ - if ( ALLOC( face, clazz->face_object_size ) ) - goto Fail; - - face->driver = driver; - face->memory = memory; - face->stream = stream; - - error = clazz->init_face( stream, - face, - face_index, - num_params, - params ); - if ( error ) - goto Fail; - - *aface = face; - - Fail: - if ( error ) - { - clazz->done_face( face ); - FREE( face ); - *aface = 0; - } - - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Face */ - /* */ - /* */ - /* Creates a new face object from a given resource and typeface index */ - /* using a pathname to the font file. */ - /* */ - /* */ - /* library :: A handle to the library resource. */ - /* */ - /* */ - /* pathname :: A path to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ - /* */ - /* aface :: A handle to a new face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Note that additional slots can be added to each face with the */ - /* FT_New_GlyphSlot() API function. Slots are linked in a single */ - /* list through their `next' field. */ - /* */ - /* FT_New_Face() can be used to determine and/or check the font */ - /* format of a given font resource. If the `face_index' field is */ - /* negative, the function will _not_ return any face handle in */ - /* `*face'. Its return value should be 0 if the resource is */ - /* recognized, or non-zero if not. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_New_Face( FT_Library library, - const char* pathname, - FT_Long face_index, - FT_Face* aface ) - { - FT_Open_Args args; - - - /* test for valid `library' and `aface' delayed to FT_Open_Face() */ - if ( !pathname ) - return FT_Err_Invalid_Argument; - - args.flags = ft_open_pathname; - args.pathname = (char*)pathname; - - return FT_Open_Face( library, &args, face_index, aface ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Memory_Face */ - /* */ - /* */ - /* Creates a new face object from a given resource and typeface index */ - /* using a font file already loaded into memory. */ - /* */ - /* */ - /* library :: A handle to the library resource. */ - /* */ - /* */ - /* file_base :: A pointer to the beginning of the font data. */ - /* */ - /* file_size :: The size of the memory chunk used by the font data. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ - /* */ - /* face :: A handle to a new face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Note that additional slots can be added to each face with the */ - /* FT_New_GlyphSlot() API function. Slots are linked in a single */ - /* list through their `next' field. */ - /* */ - /* FT_New_Memory_Face() can be used to determine and/or check the */ - /* font format of a given font resource. If the `face_index' field */ - /* is negative, the function will _not_ return any face handle in */ - /* `*face'. Its return value should be 0 if the resource is */ - /* recognized, or non-zero if not. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_New_Memory_Face( FT_Library library, - FT_Byte* file_base, - FT_Long file_size, - FT_Long face_index, - FT_Face* face ) - { - FT_Open_Args args; - - - /* test for valid `library' and `face' delayed to FT_Open_Face() */ - if ( !file_base ) - return FT_Err_Invalid_Argument; - - args.flags = ft_open_memory; - args.memory_base = file_base; - args.memory_size = file_size; - - return FT_Open_Face( library, &args, face_index, face ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Open_Face */ - /* */ - /* */ - /* Opens a face object from a given resource and typeface index using */ - /* an `FT_Open_Args' structure. If the face object doesn't exist, it */ - /* will be created. */ - /* */ - /* */ - /* library :: A handle to the library resource. */ - /* */ - /* */ - /* args :: A pointer to an `FT_Open_Args' structure which must */ - /* be filled by the caller. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ - /* */ - /* aface :: A handle to a new face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Note that additional slots can be added to each face with the */ - /* FT_New_GlyphSlot() API function. Slots are linked in a single */ - /* list through their `next' field. */ - /* */ - /* FT_Open_Face() can be used to determine and/or check the font */ - /* format of a given font resource. If the `face_index' field is */ - /* negative, the function will _not_ return any face handle in */ - /* `*face'. Its return value should be 0 if the resource is */ - /* recognized, or non-zero if not. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Open_Face( FT_Library library, - FT_Open_Args* args, - FT_Long face_index, - FT_Face* aface ) - { - FT_Error error; - FT_Driver driver; - FT_Memory memory; - FT_Stream stream; - FT_Face face = 0; - FT_ListNode node = 0; - - - /* test for valid `library' and `args' delayed to */ - /* ft_new_input_stream() */ - - if ( !aface ) - return FT_Err_Invalid_Argument; - - *aface = 0; - - /* create input stream */ - error = ft_new_input_stream( library, args, &stream ); - if ( error ) - goto Exit; - - memory = library->memory; - - /* If the font driver is specified in the `args' structure, use */ - /* it. Otherwise, we scan the list of registered drivers. */ - if ( args->flags & ft_open_driver && args->driver ) - { - driver = FT_DRIVER( args->driver ); - - /* not all modules are drivers, so check... */ - if ( FT_MODULE_IS_DRIVER( driver ) ) - { - FT_Int num_params = 0; - FT_Parameter* params = 0; - - - if ( args->flags & ft_open_params ) - { - num_params = args->num_params; - params = args->params; - } - - error = open_face( driver, stream, face_index, - num_params, params, &face ); - if ( !error ) - goto Success; - } - else - error = FT_Err_Invalid_Handle; - - ft_done_stream( &stream ); - goto Fail; - } - else - { - /* check each font driver for an appropriate format */ - FT_Module* cur = library->modules; - FT_Module* limit = cur + library->num_modules; - - - for ( ; cur < limit; cur++ ) - { - /* not all modules are font drivers, so check... */ - if ( FT_MODULE_IS_DRIVER( cur[0] ) ) - { - FT_Int num_params = 0; - FT_Parameter* params = 0; - - - driver = FT_DRIVER( cur[0] ); - - if ( args->flags & ft_open_params ) - { - num_params = args->num_params; - params = args->params; - } - - error = open_face( driver, stream, face_index, - num_params, params, &face ); - if ( !error ) - goto Success; - - if ( error != FT_Err_Unknown_File_Format ) - goto Fail; - } - } - - ft_done_stream( &stream ); - - /* no driver is able to handle this format */ - error = FT_Err_Unknown_File_Format; - goto Fail; - } - - Success: - FT_TRACE4(( "FT_New_Face: New face object, adding to list\n" )); - - /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ - if ( args->flags & ft_open_stream && args->stream ) - face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; - - /* add the face object to its driver's list */ - if ( ALLOC( node, sizeof ( *node ) ) ) - goto Fail; - - node->data = face; - /* don't assume driver is the same as face->driver, so use */ - /* face->driver instead. */ - FT_List_Add( &face->driver->faces_list, node ); - - /* now allocate a glyph slot object for the face */ - { - FT_GlyphSlot slot; - - - FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" )); - - error = FT_New_GlyphSlot( face, &slot ); - if ( error ) - goto Fail; - - face->glyph = slot; - } - - /* finally, allocate a size object for the face */ - { - FT_Size size; - - - FT_TRACE4(( "FT_Open_Face: Creating size object\n" )); - - error = FT_New_Size( face, &size ); - if ( error ) - goto Fail; - - face->size = size; - } - - /* initialize transformation for convenience functions */ - face->transform_matrix.xx = 0x10000L; - face->transform_matrix.xy = 0; - face->transform_matrix.yx = 0; - face->transform_matrix.yy = 0x10000L; - - face->transform_delta.x = 0; - face->transform_delta.y = 0; - - *aface = face; - goto Exit; - - Fail: - FT_Done_Face( face ); - - Exit: - FT_TRACE4(( "FT_Open_Face: Return %d\n", error )); - - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Attach_File */ - /* */ - /* */ - /* `Attaches' a given font file to an existing face. This is usually */ - /* to read additional information for a single face object. For */ - /* example, it is used to read the AFM files that come with Type 1 */ - /* fonts in order to add kerning data and other metrics. */ - /* */ - /* */ - /* face :: The target face object. */ - /* */ - /* */ - /* filepathname :: An 8-bit pathname naming the `metrics' file. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* If your font file is in memory, or if you want to provide your */ - /* own input stream object, use FT_Attach_Stream(). */ - /* */ - /* The meaning of the `attach' action (i.e., what really happens when */ - /* the new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Attach_File( FT_Face face, - const char* filepathname ) - { - FT_Open_Args open; - - - /* test for valid `face' delayed to FT_Attach_Stream() */ - - if ( !filepathname ) - return FT_Err_Invalid_Argument; - - open.flags = ft_open_pathname; - open.pathname = (char*)filepathname; - - return FT_Attach_Stream( face, &open ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Attach_Stream */ - /* */ - /* */ - /* This function is similar to FT_Attach_File() with the exception */ - /* that it reads the attachment from an arbitrary stream. */ - /* */ - /* */ - /* face :: The target face object. */ - /* */ - /* parameters :: A pointer to an FT_Open_Args structure used to */ - /* describe the input stream to FreeType. */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The meaning of the `attach' (i.e. what really happens when the */ - /* new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Attach_Stream( FT_Face face, - FT_Open_Args* parameters ) - { - FT_Stream stream; - FT_Error error; - FT_Driver driver; - - FT_Driver_Class* clazz; - - - /* test for valid `parameters' delayed to ft_new_input_stream() */ - - if ( !face ) - return FT_Err_Invalid_Face_Handle; - - driver = face->driver; - if ( !driver ) - return FT_Err_Invalid_Driver_Handle; - - error = ft_new_input_stream( driver->root.library, parameters, &stream ); - if ( error ) - goto Exit; - - /* we implement FT_Attach_Stream in each driver through the */ - /* `attach_file' interface */ - - error = FT_Err_Unimplemented_Feature; - clazz = driver->clazz; - if ( clazz->attach_file ) - error = clazz->attach_file( face, stream ); - - /* close the attached stream */ - if ( !parameters->stream || ( parameters->flags & ft_open_stream ) ) - ft_done_stream( &stream ); - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Face */ - /* */ - /* */ - /* Discards a given face object, as well as all of its child slots */ - /* and sizes. */ - /* */ - /* */ - /* face :: A handle to a target face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Done_Face( FT_Face face ) - { - FT_Error error; - FT_Driver driver; - FT_Memory memory; - FT_ListNode node; - - - error = FT_Err_Invalid_Face_Handle; - if ( face && face->driver ) - { - driver = face->driver; - memory = driver->root.memory; - - /* find face in driver's list */ - node = FT_List_Find( &driver->faces_list, face ); - if ( node ) - { - /* remove face object from the driver's list */ - FT_List_Remove( &driver->faces_list, node ); - FREE( node ); - - /* now destroy the object proper */ - destroy_face( memory, face, driver ); - error = FT_Err_Ok; - } - } - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Size */ - /* */ - /* */ - /* Creates a new size object from a given face object. */ - /* */ - /* */ - /* face :: A handle to a parent face object. */ - /* */ - /* */ - /* asize :: A handle to a new size object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_New_Size( FT_Face face, - FT_Size* asize ) - { - FT_Error error; - FT_Memory memory; - FT_Driver driver; - FT_Driver_Class* clazz; - - FT_Size size = 0; - FT_ListNode node = 0; - - - if ( !face ) - return FT_Err_Invalid_Face_Handle; - - if ( !asize ) - return FT_Err_Invalid_Size_Handle; - - if ( !face->driver ) - return FT_Err_Invalid_Driver_Handle; - - *asize = 0; - - driver = face->driver; - clazz = driver->clazz; - memory = face->memory; - - /* Allocate new size object and perform basic initialisation */ - if ( ALLOC( size, clazz->size_object_size ) || - ALLOC( node, sizeof ( FT_ListNodeRec ) ) ) - goto Exit; - - size->face = face; - - if ( clazz->init_size ) - error = clazz->init_size( size ); - - /* in case of success, add to the face's list */ - if ( !error ) - { - *asize = size; - node->data = size; - FT_List_Add( &face->sizes_list, node ); - } - - Exit: - if ( error ) - { - FREE( node ); - FREE( size ); - } - - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Size */ - /* */ - /* */ - /* Discards a given size object. */ - /* */ - /* */ - /* size :: A handle to a target size object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Done_Size( FT_Size size ) - { - FT_Error error; - FT_Driver driver; - FT_Memory memory; - FT_Face face; - FT_ListNode node; - - - if ( !size ) - return FT_Err_Invalid_Size_Handle; - - face = size->face; - if ( !face ) - return FT_Err_Invalid_Face_Handle; - - driver = face->driver; - if ( !driver ) - return FT_Err_Invalid_Driver_Handle; - - memory = driver->root.memory; - - error = FT_Err_Ok; - node = FT_List_Find( &face->sizes_list, size ); - if ( node ) - { - FT_List_Remove( &face->sizes_list, node ); - FREE( node ); - - if ( face->size == size ) - { - face->size = 0; - if ( face->sizes_list.head ) - face->size = (FT_Size)(face->sizes_list.head->data); - } - - destroy_size( memory, size, driver ); - } - else - error = FT_Err_Invalid_Size_Handle; - - return FT_Err_Ok; - } - - - static - void ft_recompute_scaled_metrics( FT_Face face, - FT_Size_Metrics* metrics ) - { - /* Compute root ascender, descender, test height, and max_advance */ - - metrics->ascender = ( FT_MulFix( face->ascender, - metrics->y_scale ) + 32 ) & -64; - - metrics->descender = ( FT_MulFix( face->descender, - metrics->y_scale ) + 32 ) & -64; - - metrics->height = ( FT_MulFix( face->height, - metrics->y_scale ) + 32 ) & -64; - - metrics->max_advance = ( FT_MulFix( face->max_advance_width, - metrics->x_scale ) + 32 ) & -64; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Char_Size */ - /* */ - /* */ - /* Sets the character dimensions of a given face object. The */ - /* `char_width' and `char_height' values are used for the width and */ - /* height, respectively, expressed in 26.6 fractional points. */ - /* */ - /* If the horizontal or vertical resolution values are zero, a */ - /* default value of 72dpi is used. Similarly, if one of the */ - /* character dimensions is zero, its value is set equal to the other. */ - /* */ - /* */ - /* size :: A handle to a target size object. */ - /* */ - /* */ - /* char_width :: The character width, in 26.6 fractional points. */ - /* */ - /* char_height :: The character height, in 26.6 fractional */ - /* points. */ - /* */ - /* horz_resolution :: The horizontal resolution. */ - /* */ - /* vert_resolution :: The vertical resolution. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* When dealing with fixed-size faces (i.e., non-scalable formats), */ - /* use the function FT_Set_Pixel_Sizes(). */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Set_Char_Size( FT_Face face, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) - { - FT_Error error = FT_Err_Ok; - FT_Driver driver; - FT_Memory memory; - FT_Driver_Class* clazz; - FT_Size_Metrics* metrics; - FT_Long dim_x, dim_y; - - - if ( !face || !face->size || !face->driver ) - return FT_Err_Invalid_Face_Handle; - - driver = face->driver; - metrics = &face->size->metrics; - - if ( !char_width ) - char_width = char_height; - - else if ( !char_height ) - char_height = char_width; - - if ( !horz_resolution ) - horz_resolution = 72; - - if ( !vert_resolution ) - vert_resolution = 72; - - driver = face->driver; - clazz = driver->clazz; - memory = driver->root.memory; - - /* default processing -- this can be overridden by the driver */ - if ( char_width < 1 * 64 ) - char_width = 1 * 64; - if ( char_height < 1 * 64 ) - char_height = 1 * 64; - - /* Compute pixel sizes in 26.6 units */ - dim_x = ( ( ( char_width * horz_resolution ) / 72 ) + 32 ) & -64; - dim_y = ( ( ( char_height * vert_resolution ) / 72 ) + 32 ) & -64; - - metrics->x_ppem = (FT_UShort)( dim_x >> 6 ); - metrics->y_ppem = (FT_UShort)( dim_y >> 6 ); - - metrics->x_scale = 0x10000L; - metrics->y_scale = 0x10000L; - - if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - { - metrics->x_scale = FT_DivFix( dim_x, face->units_per_EM ); - metrics->y_scale = FT_DivFix( dim_y, face->units_per_EM ); - - ft_recompute_scaled_metrics( face, metrics ); - } - - if ( clazz->set_char_sizes ) - error = clazz->set_char_sizes( face->size, - char_width, - char_height, - horz_resolution, - vert_resolution ); - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Pixel_Sizes */ - /* */ - /* */ - /* Sets the character dimensions of a given face object. The width */ - /* and height are expressed in integer pixels. */ - /* */ - /* If one of the character dimensions is zero, its value is set equal */ - /* to the other. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* */ - /* pixel_width :: The character width, in integer pixels. */ - /* */ - /* pixel_height :: The character height, in integer pixels. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face, - FT_UInt pixel_width, - FT_UInt pixel_height ) - { - FT_Error error = FT_Err_Ok; - FT_Driver driver; - FT_Memory memory; - FT_Driver_Class* clazz; - FT_Size_Metrics* metrics = &face->size->metrics; - - - if ( !face || !face->size || !face->driver ) - return FT_Err_Invalid_Face_Handle; - - driver = face->driver; - clazz = driver->clazz; - memory = driver->root.memory; - - /* default processing -- this can be overridden by the driver */ - if ( pixel_width == 0 ) - pixel_width = pixel_height; - - else if ( pixel_height == 0 ) - pixel_height = pixel_width; - - if ( pixel_width < 1 ) - pixel_width = 1; - if ( pixel_height < 1 ) - pixel_height = 1; - - metrics->x_ppem = pixel_width; - metrics->y_ppem = pixel_height; - - if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - { - metrics->x_scale = FT_DivFix( metrics->x_ppem << 6, - face->units_per_EM ); - - metrics->y_scale = FT_DivFix( metrics->y_ppem << 6, - face->units_per_EM ); - - ft_recompute_scaled_metrics( face, metrics ); - } - - if ( clazz->set_pixel_sizes ) - error = clazz->set_pixel_sizes( face->size, - pixel_width, - pixel_height ); - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Kerning */ - /* */ - /* */ - /* Returns the kerning vector between two glyphs of a same face. */ - /* */ - /* */ - /* face :: A handle to a 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. */ - /* */ - /* kern_mode :: See FT_Kerning_Mode() for more information. */ - /* Determines the scale/dimension of the returned */ - /* kerning vector. */ - /* */ - /* */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this method. Other layouts, or more sophisticated */ - /* kernings, are out of the scope of this API function -- they can be */ - /* implemented through format-specific interfaces. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Get_Kerning( FT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_UInt kern_mode, - FT_Vector* kerning ) - { - FT_Error error = FT_Err_Ok; - FT_Driver driver; - FT_Memory memory; - - - if ( !face ) - return FT_Err_Invalid_Face_Handle; - - if ( !kerning ) - return FT_Err_Invalid_Argument; - - driver = face->driver; - memory = driver->root.memory; - - kerning->x = 0; - kerning->y = 0; - - if ( driver->clazz->get_kerning ) - { - error = driver->clazz->get_kerning( face, - left_glyph, - right_glyph, - kerning ); - if ( !error ) - { - if ( kern_mode != ft_kerning_unscaled ) - { - kerning->x = FT_MulFix( kerning->x, face->size->metrics.x_scale ); - kerning->y = FT_MulFix( kerning->y, face->size->metrics.y_scale ); - - if ( kern_mode != ft_kerning_unfitted ) - { - kerning->x = ( kerning->x + 32 ) & -64; - kerning->y = ( kerning->y + 32 ) & -64; - } - } - } - } - - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Select_Charmap */ - /* */ - /* */ - /* Selects a given charmap by its encoding tag (as listed in */ - /* `freetype.h'). */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* encoding :: A handle to the selected charmap. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* This function will return an error if no charmap in the face */ - /* corresponds to the encoding queried here. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Select_Charmap( FT_Face face, - FT_Encoding encoding ) - { - FT_CharMap* cur; - FT_CharMap* limit; - - - if ( !face ) - return FT_Err_Invalid_Face_Handle; - - cur = face->charmaps; - if ( !cur ) - return FT_Err_Invalid_CharMap_Handle; - - limit = cur + face->num_charmaps; - - for ( ; cur < limit; cur++ ) - { - if ( cur[0]->encoding == encoding ) - { - face->charmap = cur[0]; - return 0; - } - } - - return FT_Err_Invalid_Argument; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Charmap */ - /* */ - /* */ - /* Selects a given charmap for character code to glyph index */ - /* decoding. */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* charmap :: A handle to the selected charmap. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* This function will return an error if the charmap is not part of */ - /* the face (i.e., if it is not listed in the face->charmaps[] */ - /* table). */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Set_Charmap( FT_Face face, - FT_CharMap charmap ) - { - FT_CharMap* cur; - FT_CharMap* limit; - - - if ( !face ) - return FT_Err_Invalid_Face_Handle; - - cur = face->charmaps; - if ( !cur ) - return FT_Err_Invalid_CharMap_Handle; - - limit = cur + face->num_charmaps; - - for ( ; cur < limit; cur++ ) - { - if ( cur[0] == charmap ) - { - face->charmap = cur[0]; - return 0; - } - } - return FT_Err_Invalid_Argument; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Char_Index */ - /* */ - /* */ - /* Returns the glyph index of a given character code. This function */ - /* uses a charmap object to do the translation. */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* */ - /* The glyph index. 0 means `undefined character code'. */ - /* */ - FT_EXPORT_FUNC( FT_UInt ) FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ) - { - FT_UInt result; - FT_Driver driver; - - - result = 0; - if ( face && face->charmap ) - { - driver = face->driver; - result = driver->clazz->get_char_index( face->charmap, charcode ); - } - return result; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Glyph_Name */ - /* */ - /* */ - /* Retrieves the ASCII name of a given glyph in a face. This only */ - /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */ - /* */ - /* */ - /* face :: A handle to a source face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* buffer :: A pointer to a target buffer where the name will be */ - /* copied to. */ - /* */ - /* buffer_max :: The maximal number of bytes available in the */ - /* buffer. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* An error is returned if the face doesn't provide glyph names or if */ - /* the glyph index is invalid. In all cases of failure, the first */ - /* byte of `buffer' will be set to 0 to indicate an empty name. */ - /* */ - /* The glyph name is truncated to fit within the buffer if it is too */ - /* long. The returned string is always zero-terminated. */ - /* */ - /* This function is not compiled within the library if the config */ - /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */ - /* `include/freetype/config/ftoptions.h' */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Get_Glyph_Name( FT_Face face, - FT_UInt glyph_index, - FT_Pointer buffer, - FT_UInt buffer_max ) - { - FT_Error error = FT_Err_Invalid_Argument; - - - /* clean up buffer */ - if ( buffer && buffer_max > 0 ) - ((FT_Byte*)buffer)[0] = 0; - - if ( face && - glyph_index < (FT_UInt)face->num_glyphs && - FT_HAS_GLYPH_NAMES( face ) ) - { - /* now, lookup for glyph name */ - FT_Driver driver = face->driver; - FT_Module_Class* clazz = FT_MODULE_CLASS( driver ); - - - if ( clazz->get_interface ) - { - FT_Glyph_Name_Requester requester; - - - requester = (FT_Glyph_Name_Requester)clazz->get_interface( - FT_MODULE( driver ), "glyph_name" ); - if ( requester ) - error = requester( face, glyph_index, buffer, buffer_max ); - } - } - - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Sfnt_Table */ - /* */ - /* */ - /* Returns a pointer to a given SFNT table within a face. */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* tag :: An index of an SFNT table. */ - /* */ - /* */ - /* A type-less pointer to the table. This will be 0 in case of */ - /* error, or if the corresponding table was not found *OR* loaded */ - /* from the file. */ - /* */ - /* */ - /* The table is owned by the face object, and disappears with it. */ - /* */ - /* This function is only useful to access SFNT tables that are loaded */ - /* by the sfnt/truetype/opentype drivers. See the FT_Sfnt_Tag */ - /* enumeration in `tttables.h' for a list. */ - /* */ - /* You can load any table with a different function.. XXX */ - /* */ - FT_EXPORT_FUNC( void* ) FT_Get_Sfnt_Table( FT_Face face, - FT_Sfnt_Tag tag ) - { - void* table = 0; - FT_Get_Sfnt_Table_Func func; - FT_Driver driver; - - - if ( !face || !FT_IS_SFNT( face ) ) - goto Exit; - - driver = face->driver; - func = (FT_Get_Sfnt_Table_Func)driver->root.clazz->get_interface( - FT_MODULE( driver ), "get_sfnt" ); - if ( func ) - table = func( face, tag ); - - Exit: - return table; - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** R E N D E R E R S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /* lookup a renderer by glyph format in the library's list */ - BASE_FUNC( FT_Renderer ) FT_Lookup_Renderer( FT_Library library, - FT_Glyph_Format format, - FT_ListNode* node ) - { - FT_ListNode cur; - FT_Renderer result = 0; - - - if ( !library ) - goto Exit; - - cur = library->renderers.head; - - if ( node ) - { - if ( *node ) - cur = (*node)->next; - *node = 0; - } - - while ( cur ) - { - FT_Renderer renderer = FT_RENDERER( cur->data ); - - - if ( renderer->glyph_format == format ) - { - if ( node ) - *node = cur; - - result = renderer; - break; - } - cur = cur->next; - } - - Exit: - return result; - } - - - static - FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ) - { - FT_Face face = slot->face; - FT_Library library = FT_FACE_LIBRARY( face ); - FT_Renderer result = library->cur_renderer; - - - if ( !result || result->glyph_format != slot->format ) - result = FT_Lookup_Renderer( library, slot->format, 0 ); - - return result; - } - - - static - void ft_set_current_renderer( FT_Library library ) - { - FT_Renderer renderer; - - - renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 ); - library->cur_renderer = renderer; - } - - - static - FT_Error ft_add_renderer( FT_Module module ) - { - FT_Library library = module->library; - FT_Memory memory = library->memory; - FT_Error error; - FT_ListNode node; - - - if ( ALLOC( node, sizeof ( *node ) ) ) - goto Exit; - - { - FT_Renderer render = FT_RENDERER( module ); - FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz; - - - render->clazz = clazz; - render->glyph_format = clazz->glyph_format; - - /* allocate raster object if needed */ - if ( clazz->glyph_format == ft_glyph_format_outline && - clazz->raster_class->raster_new ) - { - error = clazz->raster_class->raster_new( memory, &render->raster ); - if ( error ) - goto Fail; - - render->raster_render = clazz->raster_class->raster_render; - render->render = clazz->render_glyph; - } - - /* add to list */ - node->data = module; - FT_List_Add( &library->renderers, node ); - - ft_set_current_renderer( library ); - } - - Fail: - if ( error ) - FREE( node ); - - Exit: - return error; - } - - - static - void ft_remove_renderer( FT_Module module ) - { - FT_Library library = module->library; - FT_Memory memory = library->memory; - FT_ListNode node; - - - node = FT_List_Find( &library->renderers, module ); - if ( node ) - { - FT_Renderer render = FT_RENDERER( module ); - - - /* release raster object, if any */ - if ( render->raster ) - render->clazz->raster_class->raster_done( render->raster ); - - /* remove from list */ - FT_List_Remove( &library->renderers, node ); - FREE( node ); - - ft_set_current_renderer( library ); - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Renderer */ - /* */ - /* */ - /* Retrieves the current renderer for a given glyph format. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* format :: The glyph format. */ - /* */ - /* */ - /* A renderer handle. 0 if none found. */ - /* */ - /* */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - /* To add a new renderer, simply use FT_Add_Module(). To retrieve a */ - /* renderer by its name, use FT_Get_Module(). */ - /* */ - FT_EXPORT_FUNC( FT_Renderer ) FT_Get_Renderer( FT_Library library, - FT_Glyph_Format format ) - { - /* test for valid `library' delayed to FT_Lookup_Renderer() */ - - return FT_Lookup_Renderer( library, format, 0 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Renderer */ - /* */ - /* */ - /* Sets the current renderer to use, and set additional mode. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* renderer :: A handle to the renderer object. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* parameters :: Additional parameters. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* In case of success, the renderer will be used to convert glyph */ - /* images in the renderer's known format into bitmaps. */ - /* */ - /* This doesn't change the current renderer for other formats. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Set_Renderer( FT_Library library, - FT_Renderer renderer, - FT_UInt num_params, - FT_Parameter* parameters ) - { - FT_ListNode node; - FT_Error error = FT_Err_Ok; - - - if ( !library ) - return FT_Err_Invalid_Library_Handle; - - if ( !renderer ) - return FT_Err_Invalid_Argument; - - node = FT_List_Find( &library->renderers, renderer ); - if ( !node ) - { - error = FT_Err_Invalid_Argument; - goto Exit; - } - - FT_List_Up( &library->renderers, node ); - - if ( renderer->glyph_format == ft_glyph_format_outline ) - library->cur_renderer = renderer; - - if ( num_params > 0 ) - { - FTRenderer_setMode set_mode = renderer->clazz->set_mode; - - - for ( ; num_params > 0; num_params-- ) - { - error = set_mode( renderer, parameters->tag, parameters->data ); - if ( error ) - break; - } - } - - Exit: - return error; - } - - - LOCAL_FUNC - FT_Error FT_Render_Glyph_Internal( FT_Library library, - FT_GlyphSlot slot, - FT_UInt render_mode ) - { - FT_Error error = FT_Err_Ok; - FT_Renderer renderer; - - - /* if it is already a bitmap, no need to do anything */ - switch ( slot->format ) - { - case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */ - break; - - default: - { - FT_ListNode node = 0; - FT_Bool update = 0; - - - /* small shortcut for the very common case */ - if ( slot->format == ft_glyph_format_outline ) - { - renderer = library->cur_renderer; - node = library->renderers.head; - } - else - renderer = FT_Lookup_Renderer( library, slot->format, &node ); - - error = FT_Err_Unimplemented_Feature; - while ( renderer ) - { - error = renderer->render( renderer, slot, render_mode, 0 ); - 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, slot->format, &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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Render_Glyph */ - /* */ - /* */ - /* Converts a given glyph image to a bitmap. It does so by */ - /* inspecting the glyph image format, find the relevant renderer, and */ - /* invoke it. */ - /* */ - /* */ - /* slot :: A handle to the glyph slot containing the image to */ - /* convert. */ - /* */ - /* render_mode :: This is the render mode used to render the glyph */ - /* image into a bitmap. See FT_Render_Mode for a list */ - /* of possible values. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot, - FT_UInt render_mode ) - { - FT_Library library; - - - if ( !slot ) - return FT_Err_Invalid_Argument; - - library = FT_FACE_LIBRARY( slot->face ); - - return FT_Render_Glyph_Internal( library, slot, render_mode ); - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** M O D U L E S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* Destroy_Module */ - /* */ - /* */ - /* Destroys a given module object. For drivers, this also destroys */ - /* all child faces. */ - /* */ - /* */ - /* module :: A handle to the target driver object. */ - /* */ - /* */ - /* The driver _must_ be LOCKED! */ - /* */ - static - void Destroy_Module( FT_Module module ) - { - FT_Memory memory = module->memory; - FT_Module_Class* clazz = module->clazz; - FT_Library library = module->library; - - - /* finalize client-data - before anything else */ - if ( module->generic.finalizer ) - module->generic.finalizer( module ); - - if ( library && library->auto_hinter == module ) - library->auto_hinter = 0; - - /* if the module is a renderer */ - if ( FT_MODULE_IS_RENDERER( module ) ) - ft_remove_renderer( module ); - - /* if the module is a font driver, add some steps */ - if ( FT_MODULE_IS_DRIVER( module ) ) - Destroy_Driver( FT_DRIVER( module ) ); - - /* finalize the module object */ - if ( clazz->module_done ) - clazz->module_done( module ); - - /* discard it */ - FREE( module ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Add_Module */ - /* */ - /* */ - /* Adds a new module to a given library instance. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* clazz :: A pointer to class descriptor for the module. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Add_Module( FT_Library library, - const FT_Module_Class* clazz ) - { - FT_Error error; - FT_Memory memory; - FT_Module module; - FT_UInt nn; - - -#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \ - FREETYPE_MINOR ) - - if ( !library ) - return FT_Err_Invalid_Library_Handle; - - if ( !clazz ) - return FT_Err_Invalid_Argument; - - /* check freetype version */ - if ( clazz->module_requires > FREETYPE_VER_FIXED ) - return FT_Err_Invalid_Version; - - /* look for a module with the same name in the library's table */ - for ( nn = 0; nn < library->num_modules; nn++ ) - { - module = library->modules[nn]; - if ( strcmp( module->clazz->module_name, clazz->module_name ) == 0 ) - { - /* this installed module has the same name, compare their versions */ - if ( clazz->module_version <= module->clazz->module_version ) - return FT_Err_Lower_Module_Version; - - /* remove the module from our list, then exit the loop to replace */ - /* it by our new version.. */ - FT_Remove_Module( library, module ); - break; - } - } - - memory = library->memory; - error = FT_Err_Ok; - - if ( library->num_modules >= FT_MAX_MODULES ) - { - error = FT_Err_Too_Many_Drivers; - goto Exit; - } - - /* allocate module object */ - if ( ALLOC( module,clazz->module_size ) ) - goto Exit; - - /* base initialization */ - module->library = library; - module->memory = memory; - module->clazz = (FT_Module_Class*)clazz; - - /* check whether the module is a renderer - this must be performed */ - /* before the normal module initialization */ - if ( FT_MODULE_IS_RENDERER( module ) ) - { - /* add to the renderers list */ - error = ft_add_renderer( module ); - if ( error ) - goto Fail; - } - - /* is the module a auto-hinter? */ - if ( FT_MODULE_IS_HINTER( module ) ) - library->auto_hinter = module; - - /* if the module is a font driver */ - if ( FT_MODULE_IS_DRIVER( module ) ) - { - /* allocate glyph loader if needed */ - FT_Driver driver = FT_DRIVER( module ); - - - driver->clazz = (FT_Driver_Class*)module->clazz; - if ( FT_DRIVER_USES_OUTLINES( driver ) ) - { - error = FT_GlyphLoader_New( memory, &driver->glyph_loader ); - if ( error ) - goto Fail; - } - } - - if ( clazz->module_init ) - { - error = clazz->module_init( module ); - if ( error ) - goto Fail; - } - - /* add module to the library's table */ - library->modules[library->num_modules++] = module; - - Exit: - return error; - - Fail: - if ( FT_MODULE_IS_DRIVER( module ) ) - { - FT_Driver driver = FT_DRIVER( module ); - - - if ( FT_DRIVER_USES_OUTLINES( driver ) ) - FT_GlyphLoader_Done( driver->glyph_loader ); - } - - if ( FT_MODULE_IS_RENDERER( module ) ) - { - FT_Renderer renderer = FT_RENDERER( module ); - - - if ( renderer->raster ) - renderer->clazz->raster_class->raster_done( renderer->raster ); - } - - FREE( module ); - goto Exit; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Module */ - /* */ - /* */ - /* Finds a module by its name. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* */ - /* A module handle. 0 if none was found. */ - /* */ - /* */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for :-) */ - /* */ - FT_EXPORT_FUNC( FT_Module ) FT_Get_Module( FT_Library library, - const char* module_name ) - { - FT_Module result = 0; - FT_Module* cur; - FT_Module* limit; - - - if ( !library || !module_name ) - return result; - - cur = library->modules; - limit = cur + library->num_modules; - - for ( ; cur < limit; cur++ ) - if ( strcmp( cur[0]->clazz->module_name, module_name ) == 0 ) - { - result = cur[0]; - break; - } - - return result; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Module_Interface */ - /* */ - /* */ - /* Finds a module and returns its specific interface as a typeless */ - /* pointer. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* */ - /* A module-specific interface if available, 0 otherwise. */ - /* */ - /* */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for, and what its interface is :-) */ - /* */ - BASE_FUNC( const void* ) FT_Get_Module_Interface( FT_Library library, - const char* mod_name ) - { - FT_Module module; - - - /* test for valid `library' delayed to FT_Get_Module() */ - - module = FT_Get_Module( library, mod_name ); - - return module ? module->clazz->module_interface : 0; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Remove_Module */ - /* */ - /* */ - /* Removes a given module from a library instance. */ - /* */ - /* */ - /* library :: A handle to a library object. */ - /* */ - /* module :: A handle to a module object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The module object is destroyed by the function in case of success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Remove_Module( FT_Library library, - FT_Module module ) - { - /* try to find the module from the table, then remove it from there */ - - if ( !library ) - return FT_Err_Invalid_Library_Handle; - - if ( module ) - { - FT_Module* cur = library->modules; - FT_Module* limit = cur + library->num_modules; - - - for ( ; cur < limit; cur++ ) - { - if ( cur[0] == module ) - { - /* remove it from the table */ - library->num_modules--; - limit--; - while ( cur < limit ) - { - cur[0] = cur[1]; - cur++; - } - limit[0] = 0; - - /* destroy the module */ - Destroy_Module( module ); - - return FT_Err_Ok; - } - } - } - return FT_Err_Invalid_Driver_Handle; - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** L I B R A R Y ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Library */ - /* */ - /* */ - /* This function is used to create a new FreeType library instance */ - /* from a given memory object. It is thus possible to use libraries */ - /* with distinct memory allocators within the same program. */ - /* */ - /* */ - /* memory :: A handle to the original memory object. */ - /* */ - /* */ - /* alibrary :: A pointer to handle of a new library object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_New_Library( FT_Memory memory, - FT_Library* alibrary ) - { - FT_Library library = 0; - FT_Error error; - - - if ( !memory ) - return FT_Err_Invalid_Argument; - - /* first of all, allocate the library object */ - if ( ALLOC( library, sizeof ( *library ) ) ) - return error; - - library->memory = memory; - - /* allocate the render pool */ - library->raster_pool_size = FT_RENDER_POOL_SIZE; - if ( ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) ) - goto Fail; - - /* That's ok now */ - *alibrary = library; - - return FT_Err_Ok; - - Fail: - FREE( library ); - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Library */ - /* */ - /* */ - /* Discards a given library object. This closes all drivers and */ - /* discards all resource objects. */ - /* */ - /* */ - /* library :: A handle to the target library. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Done_Library( FT_Library library ) - { - FT_Memory memory; - FT_UInt n; - - - if ( !library ) - return FT_Err_Invalid_Library_Handle; - - memory = library->memory; - - /* Discard client-data */ - if ( library->generic.finalizer ) - library->generic.finalizer( library ); - - /* Close all modules in the library */ - for ( n = 0; n < library->num_modules; n++ ) - { - FT_Module module = library->modules[n]; - - - if ( module ) - { - Destroy_Module( module ); - library->modules[n] = 0; - } - } - - /* Destroy raster objects */ - FREE( library->raster_pool ); - library->raster_pool_size = 0; - - FREE( library ); - return FT_Err_Ok; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Debug_Hook */ - /* */ - /* */ - /* Sets a debug hook function for debugging the interpreter of a font */ - /* format. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* hook_index :: The index of the debug hook. You should use the */ - /* values defined in ftobjs.h, e.g. */ - /* FT_DEBUG_HOOK_TRUETYPE */ - /* */ - /* debug_hook :: The function used to debug the interpreter. */ - /* */ - /* */ - /* Currently, four debug hook slots are available, but only two (for */ - /* the TrueType and the Type 1 interpreter) are defined. */ - /* */ - FT_EXPORT_FUNC( void ) FT_Set_Debug_Hook( FT_Library library, - FT_UInt hook_index, - FT_DebugHook_Func debug_hook ) - { - if ( library && debug_hook && - hook_index < - ( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) ) - library->debug_hooks[hook_index] = debug_hook; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_FreeType */ - /* */ - /* */ - /* Destroys a given FreeType library object and all of its childs, */ - /* including resources, drivers, faces, sizes, etc. */ - /* */ - /* */ - /* library :: A handle to the target library object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_Done_FreeType( FT_Library library ) - { - /* test for valid `library' delayed to FT_Done_Library() */ - - /* Discard the library object */ - FT_Done_Library( library ); - - return FT_Err_Ok; - } - - -/* END */ diff --git a/src/freetype/base/ftoutln.c b/src/freetype/base/ftoutln.c deleted file mode 100644 index 20292d0c3a..0000000000 --- a/src/freetype/base/ftoutln.c +++ /dev/null @@ -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 -#include - - - /*************************************************************************/ - /* */ - /* 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 }; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Decompose */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_New */ - /* */ - /* */ - /* Creates a new outline of a given size. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* outline :: A handle to the new outline. NULL in case of */ - /* error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* No. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Copy */ - /* */ - /* */ - /* Copies an outline into another one. Both objects must have the */ - /* same sizes (number of points & number of contours) when this */ - /* function is called. */ - /* */ - /* */ - /* source :: A handle to the source outline. */ - /* */ - /* */ - /* target :: A handle to the target outline. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Done */ - /* */ - /* */ - /* Destroys an outline created with FT_Outline_New(). */ - /* */ - /* */ - /* library :: A handle of the library object used to allocate the */ - /* outline. */ - /* */ - /* outline :: A pointer to the outline object to be discarded. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* No. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Get_CBox */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* */ - /* cbox :: The outline's control box. */ - /* */ - /* */ - /* 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; - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Translate */ - /* */ - /* */ - /* Applies a simple translation to the points of an outline. */ - /* */ - /* */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* xOffset :: The horizontal offset. */ - /* */ - /* yOffset :: The vertical offset. */ - /* */ - /* */ - /* 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++; - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Reverse */ - /* */ - /* */ - /* Reverses the drawing direction of an outline. This is used to */ - /* ensure consistent fill conventions for mirrored glyphs. */ - /* */ - /* */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Render */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* YES. Rendering is synchronized, so that concurrent calls to the */ - /* scan-line converter will be serialized. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Get_Bitmap */ - /* */ - /* */ - /* Renders an outline within a bitmap. The outline's image is simply */ - /* OR-ed to the target bitmap. */ - /* */ - /* */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* map :: A pointer to the target bitmap descriptor. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* YES. Rendering is synchronized, so that concurrent calls to the */ - /* scan-line converter will be serialized. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Vector_Transform */ - /* */ - /* */ - /* Transforms a single vector through a 2x2 matrix. */ - /* */ - /* */ - /* vector :: The target vector to transform. */ - /* */ - /* */ - /* matrix :: A pointer to the source 2x2 matrix. */ - /* */ - /* */ - /* Yes. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Transform */ - /* */ - /* */ - /* Applies a simple 2x2 matrix to all of an outline's points. Useful */ - /* for applying rotations, slanting, flipping, etc. */ - /* */ - /* */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* matrix :: A pointer to the transformation matrix. */ - /* */ - /* */ - /* Yes. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftstream.c b/src/freetype/base/ftstream.c deleted file mode 100644 index 768586ebbf..0000000000 --- a/src/freetype/base/ftstream.c +++ /dev/null @@ -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 -#include - - - /*************************************************************************/ - /* */ - /* 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 */ diff --git a/src/freetype/base/ftsystem.c b/src/freetype/base/ftsystem.c deleted file mode 100644 index b99b0eaae4..0000000000 --- a/src/freetype/base/ftsystem.c +++ /dev/null @@ -1,299 +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 -#include -#include -#include -#include - -#include -#include -#include - - - /*************************************************************************/ - /* */ - /* 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(). */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* ft_alloc */ - /* */ - /* */ - /* The memory allocation function. */ - /* */ - /* */ - /* memory :: A pointer to the memory object. */ - /* */ - /* size :: The requested size in bytes. */ - /* */ - /* */ - /* block :: The address of newly allocated block. */ - /* */ - static - void* ft_alloc( FT_Memory memory, - long size ) - { - FT_UNUSED( memory ); - - return malloc( size ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* ft_realloc */ - /* */ - /* */ - /* The memory reallocation function. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* ft_free */ - /* */ - /* */ - /* The memory release function. */ - /* */ - /* */ - /* memory :: A pointer to the memory object. */ - /* */ - /* block :: The address of block in memory to be freed. */ - /* */ - static - void ft_free( FT_Memory memory, - void* block ) - { - FT_UNUSED( memory ); - - free( block ); - } - - - /*************************************************************************/ - /* */ - /* RESOURCE MANAGEMENT INTERFACE */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ -#undef FT_COMPONENT -#define FT_COMPONENT trace_io - - /* We use the macro STREAM_FILE for convenience to extract the */ - /* system-specific stream handle from a given FreeType stream object */ -#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer ) - - - /*************************************************************************/ - /* */ - /* */ - /* ft_close_stream */ - /* */ - /* */ - /* The function to close a stream. */ - /* */ - /* */ - /* stream :: A pointer to the stream object. */ - /* */ - static - void ft_close_stream( FT_Stream stream ) - { - fclose( STREAM_FILE( stream ) ); - - stream->descriptor.pointer = NULL; - stream->size = 0; - stream->base = 0; - } - - - /*************************************************************************/ - /* */ - /* */ - /* ft_io_stream */ - /* */ - /* */ - /* The function to open a stream. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* The number of bytes actually read. */ - /* */ - static - unsigned long ft_io_stream( FT_Stream stream, - unsigned long offset, - unsigned char* buffer, - unsigned long count ) - { - FILE* file; - - - file = STREAM_FILE( stream ); - - fseek( file, offset, SEEK_SET ); - - return (unsigned long)fread( buffer, 1, count, file ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Stream */ - /* */ - /* */ - /* Creates a new stream object. */ - /* */ - /* */ - /* filepathname :: The name of the stream (usually a file) to be */ - /* opened. */ - /* */ - /* stream :: A pointer to the stream object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_FUNC( FT_Error ) FT_New_Stream( const char* filepathname, - FT_Stream stream ) - { - FILE* file; - - - if ( !stream ) - return FT_Err_Invalid_Stream_Handle; - - file = fopen( filepathname, "rb" ); - if ( !file ) - { - FT_ERROR(( "FT_New_Stream:" )); - FT_ERROR(( " could not open `%s'\n", filepathname )); - - return FT_Err_Cannot_Open_Resource; - } - - fseek( file, 0, SEEK_END ); - stream->size = ftell( file ); - fseek( file, 0, SEEK_SET ); - - stream->descriptor.pointer = file; - stream->pathname.pointer = (char*)filepathname; - stream->pos = 0; - - stream->read = ft_io_stream; - stream->close = ft_close_stream; - - FT_TRACE1(( "FT_New_Stream:" )); - FT_TRACE1(( " opened `%s' (%d bytes) successfully\n", - filepathname, stream->size )); - - return FT_Err_Ok; - } - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Memory */ - /* */ - /* */ - /* Creates a new memory object. */ - /* */ - /* */ - /* A pointer to the new memory object. 0 in case of error. */ - /* */ - FT_EXPORT_FUNC( FT_Memory ) FT_New_Memory( void ) - { - FT_Memory memory; - - - memory = (FT_Memory)malloc( sizeof ( *memory ) ); - if ( memory ) - { - memory->user = 0; - memory->alloc = ft_alloc; - memory->realloc = ft_realloc; - memory->free = ft_free; - } - - return memory; - } - - -/* END */ diff --git a/src/freetype/base/rules.mk b/src/freetype/base/rules.mk deleted file mode 100644 index 1763a09817..0000000000 --- a/src/freetype/base/rules.mk +++ /dev/null @@ -1,83 +0,0 @@ -# -# FreeType 2 base layer configuration rules -# - - -# Copyright 1996-2000 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -# It sets the following variables which are used by the master Makefile -# after the call: -# -# BASE_OBJ_S: The single-object base layer. -# BASE_OBJ_M: A list of all objects for a multiple-objects build. -# BASE_EXT_OBJ: A list of base layer extensions, i.e., components found -# in `freetype/src/base' which are not compiled within the -# base layer proper. -# -# BASE_H is defined in freetype.mk to simplify the dependency rules. - - -BASE_COMPILE := $(FT_COMPILE) $I$(SRC_)base - - -# Base layer sources -# -# ftsystem, ftinit, and ftdebug are handled by freetype.mk -# -BASE_SRC := $(BASE_)ftcalc.c \ - $(BASE_)ftextend.c \ - $(BASE_)ftlist.c \ - $(BASE_)ftobjs.c \ - $(BASE_)ftstream.c \ - $(BASE_)ftoutln.c - -# Base layer `extensions' sources -# -# An extension is added to the library file (.a or .lib) as a separate -# object. It will then be linked to the final executable only if one of its -# symbols is used by the application. -# -BASE_EXT_SRC := $(BASE_)ftglyph.c \ - $(BASE_)ftmm.c - -# Default extensions objects -# -BASE_EXT_OBJ := $(BASE_EXT_SRC:$(BASE_)%.c=$(OBJ_)%.$O) - - -# Base layer object(s) -# -# BASE_OBJ_M is used during `multi' builds (each base source file compiles -# to a single object file). -# -# BASE_OBJ_S is used during `single' builds (the whole base layer is -# compiled as a single object file using ftbase.c). -# -BASE_OBJ_M := $(BASE_SRC:$(BASE_)%.c=$(OBJ_)%.$O) -BASE_OBJ_S := $(OBJ_)ftbase.$O - -# Base layer root source file for single build -# -BASE_SRC_S := $(BASE_)ftbase.c - - -# Base layer - single object build -# -$(BASE_OBJ_S): $(BASE_SRC_S) $(BASE_SRC) $(FREETYPE_H) - $(BASE_COMPILE) $T$@ $(BASE_SRC_S) - - -# Multiple objects build + extensions -# -$(OBJ_)%.$O: $(BASE_)%.c $(FREETYPE_H) - $(BASE_COMPILE) $T$@ $< - -# EOF diff --git a/src/freetype/cff/cff.c b/src/freetype/cff/cff.c deleted file mode 100644 index 5a987f1cdf..0000000000 --- a/src/freetype/cff/cff.c +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************/ -/* */ -/* 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 /* driver interface */ -#include /* token parser */ -#include /* tables loader */ -#include /* object management */ -#include /* glyph loader */ - -#endif - - -/* END */ diff --git a/src/freetype/cff/module.mk b/src/freetype/cff/module.mk deleted file mode 100644 index 9bc5c8f722..0000000000 --- a/src/freetype/cff/module.mk +++ /dev/null @@ -1,7 +0,0 @@ -make_module_list: add_cff_driver - -add_cff_driver: - $(OPEN_DRIVER)cff_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)cff $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE) - -# EOF diff --git a/src/freetype/cff/rules.mk b/src/freetype/cff/rules.mk deleted file mode 100644 index ba87af5f18..0000000000 --- a/src/freetype/cff/rules.mk +++ /dev/null @@ -1,69 +0,0 @@ -# -# FreeType 2 OpenType/CFF driver configuration rules -# - - -# Copyright 1996-2000 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -# OpenType driver directory -# -T2_DIR := $(SRC_)cff -T2_DIR_ := $(T2_DIR)$(SEP) - - -T2_COMPILE := $(FT_COMPILE) - - -# T2 driver sources (i.e., C files) -# -T2_DRV_SRC := $(T2_DIR_)t2objs.c \ - $(T2_DIR_)t2load.c \ - $(T2_DIR_)t2gload.c \ - $(T2_DIR_)t2parse.c \ - $(T2_DIR_)t2driver.c - -# T2 driver headers -# -T2_DRV_H := $(T2_DRV_SRC:%.c=%.h) \ - $(T2_DIR_)t2tokens.h - - -# T2 driver object(s) -# -# T2_DRV_OBJ_M is used during `multi' builds -# T2_DRV_OBJ_S is used during `single' builds -# -T2_DRV_OBJ_M := $(T2_DRV_SRC:$(T2_DIR_)%.c=$(OBJ_)%.$O) -T2_DRV_OBJ_S := $(OBJ_)cff.$O - -# T2 driver source file for single build -# -T2_DRV_SRC_S := $(T2_DIR_)cff.c - - -# T2 driver - single object -# -$(T2_DRV_OBJ_S): $(T2_DRV_SRC_S) $(T2_DRV_SRC) $(FREETYPE_H) $(T2_DRV_H) - $(T2_COMPILE) $T$@ $(T2_DRV_SRC_S) - - -# T2 driver - multiple objects -# -$(OBJ_)%.$O: $(T2_DIR_)%.c $(FREETYPE_H) $(T2_DRV_H) - $(T2_COMPILE) $T$@ $< - - -# update main driver object lists -# -DRV_OBJS_S += $(T2_DRV_OBJ_S) -DRV_OBJS_M += $(T2_DRV_OBJ_M) - -# EOF diff --git a/src/freetype/cff/t2driver.c b/src/freetype/cff/t2driver.c deleted file mode 100644 index d1e1b188d2..0000000000 --- a/src/freetype/cff/t2driver.c +++ /dev/null @@ -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 -#include -#include -#include -#include - -#include - - -#ifdef FT_FLAT_COMPILE - -#include "t2driver.h" -#include "t2gload.h" - -#else - -#include -#include - -#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 ) - - - /*************************************************************************/ - /* */ - /* */ - /* Get_Kerning */ - /* */ - /* */ - /* A driver method used to return the kerning vector between two */ - /* glyphs of the same face. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* 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 - - - /*************************************************************************/ - /* */ - /* */ - /* Load_Glyph */ - /* */ - /* */ - /* A driver method used to load a glyph within a given glyph slot. */ - /* */ - /* */ - /* 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). */ - /* */ - /* */ - /* 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 ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* */ - /* Get_Char_Index */ - /* */ - /* */ - /* Uses a charmap to return a given character code's glyph index. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* charcode :: The character code. */ - /* */ - /* */ - /* 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 - - - /*************************************************************************/ - /* */ - /* */ - /* getDriverClass */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cff/t2driver.h b/src/freetype/cff/t2driver.h deleted file mode 100644 index e0b0afd3ac..0000000000 --- a/src/freetype/cff/t2driver.h +++ /dev/null @@ -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 - - FT_EXPORT_VAR( const FT_Driver_Class ) cff_driver_class; - - -#endif /* T2DRIVER_H */ - - -/* END */ diff --git a/src/freetype/cff/t2gload.c b/src/freetype/cff/t2gload.c deleted file mode 100644 index 1023e3cf48..0000000000 --- a/src/freetype/cff/t2gload.c +++ /dev/null @@ -1,2045 +0,0 @@ -/***************************************************************************/ -/* */ -/* t2gload.c */ -/* */ -/* OpenType Glyph 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 -#include -#include -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "t2load.h" -#include "t2gload.h" - -#else - -#include -#include - -#endif - - -#include - - - /*************************************************************************/ - /* */ - /* 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_t2gload - - - typedef enum T2_Operator_ - { - t2_op_unknown = 0, - - t2_op_rmoveto, - t2_op_hmoveto, - t2_op_vmoveto, - - t2_op_rlineto, - t2_op_hlineto, - t2_op_vlineto, - - t2_op_rrcurveto, - t2_op_hhcurveto, - t2_op_hvcurveto, - t2_op_rcurveline, - t2_op_rlinecurve, - t2_op_vhcurveto, - t2_op_vvcurveto, - - t2_op_flex, - t2_op_hflex, - t2_op_hflex1, - t2_op_flex1, - - t2_op_endchar, - - t2_op_hstem, - t2_op_vstem, - t2_op_hstemhm, - t2_op_vstemhm, - - t2_op_hintmask, - t2_op_cntrmask, - - t2_op_abs, - t2_op_add, - t2_op_sub, - t2_op_div, - t2_op_neg, - t2_op_random, - t2_op_mul, - t2_op_sqrt, - - t2_op_blend, - - t2_op_drop, - t2_op_exch, - t2_op_index, - t2_op_roll, - t2_op_dup, - - t2_op_put, - t2_op_get, - t2_op_store, - t2_op_load, - - t2_op_and, - t2_op_or, - t2_op_not, - t2_op_eq, - t2_op_ifelse, - - t2_op_callsubr, - t2_op_callgsubr, - t2_op_return, - - /* do not remove */ - t2_op_max - - } T2_Operator; - - -#define T2_COUNT_CHECK_WIDTH 0x80 -#define T2_COUNT_EXACT 0x40 -#define T2_COUNT_CLEAR_STACK 0x20 - - - static const FT_Byte t2_argument_counts[] = - { - 0, /* unknown */ - - 2 | T2_COUNT_CHECK_WIDTH | T2_COUNT_EXACT, /* rmoveto */ - 1 | T2_COUNT_CHECK_WIDTH | T2_COUNT_EXACT, - 1 | T2_COUNT_CHECK_WIDTH | T2_COUNT_EXACT, - - 0 | T2_COUNT_CLEAR_STACK, /* rlineto */ - 0 | T2_COUNT_CLEAR_STACK, - 0 | T2_COUNT_CLEAR_STACK, - - 0 | T2_COUNT_CLEAR_STACK, /* rrcurveto */ - 0 | T2_COUNT_CLEAR_STACK, - 0 | T2_COUNT_CLEAR_STACK, - 0 | T2_COUNT_CLEAR_STACK, - 0 | T2_COUNT_CLEAR_STACK, - 0 | T2_COUNT_CLEAR_STACK, - 0 | T2_COUNT_CLEAR_STACK, - - 13, /* flex */ - 7, - 9, - 11, - - 0, /* endchar */ - - 2 | T2_COUNT_CHECK_WIDTH, /* hstem */ - 2 | T2_COUNT_CHECK_WIDTH, - 2 | T2_COUNT_CHECK_WIDTH, - 2 | T2_COUNT_CHECK_WIDTH, - - 0, /* hintmask */ - 0, /* cntrmask */ - - 1, /* abs */ - 2, - 2, - 2, - 1, - 0, - 2, - 1, - - 1, /* blend */ - - 1, /* drop */ - 2, - 1, - 2, - 1, - - 2, /* put */ - 1, - 4, - 3, - - 2, /* and */ - 2, - 1, - 2, - 4, - - 1, /* callsubr */ - 1, - 0 - }; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** GENERIC CHARSTRING PARSING *********/ - /********** *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Init_Builder */ - /* */ - /* */ - /* Initializes a given glyph builder. */ - /* */ - /* */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - static - void T2_Init_Builder( T2_Builder* builder, - TT_Face face, - T2_Size size, - T2_GlyphSlot glyph ) - { - builder->path_begun = 0; - builder->load_points = 1; - - builder->face = face; - builder->glyph = glyph; - builder->memory = face->root.memory; - - if ( glyph ) - { - FT_GlyphLoader* loader = glyph->root.loader; - - - builder->loader = loader; - builder->base = &loader->base.outline; - builder->current = &loader->current.outline; - FT_GlyphLoader_Rewind( loader ); - } - - if ( size ) - { - builder->scale_x = size->metrics.x_scale; - builder->scale_y = size->metrics.y_scale; - } - - builder->pos_x = 0; - builder->pos_y = 0; - - builder->left_bearing.x = 0; - builder->left_bearing.y = 0; - builder->advance.x = 0; - builder->advance.y = 0; - } - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Done_Builder */ - /* */ - /* */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ - static - void T2_Done_Builder( T2_Builder* builder ) - { - T2_GlyphSlot glyph = builder->glyph; - - - if ( glyph ) - glyph->root.outline = *builder->base; - } - - - /*************************************************************************/ - /* */ - /* */ - /* t2_compute_bias */ - /* */ - /* */ - /* Computes the bias value in dependence of the number of glyph */ - /* subroutines. */ - /* */ - /* */ - /* num_subrs :: The number of glyph subroutines. */ - /* */ - /* */ - /* The bias value. */ - static - FT_Int t2_compute_bias( FT_UInt num_subrs ) - { - FT_Int result; - - - if ( num_subrs < 1240 ) - result = 107; - else if ( num_subrs < 33900 ) - result = 1131; - else - result = 32768; - - return result; - } - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Init_Decoder */ - /* */ - /* */ - /* Initializes a given glyph decoder. */ - /* */ - /* */ - /* decoder :: A pointer to the glyph builder to initialize. */ - /* */ - /* */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* slot :: The current glyph object. */ - /* */ - LOCAL_FUNC - void T2_Init_Decoder( T2_Decoder* decoder, - TT_Face face, - T2_Size size, - T2_GlyphSlot slot ) - { - CFF_Font* cff = (CFF_Font*)face->extra.data; - - - /* clear everything */ - MEM_Set( decoder, 0, sizeof ( *decoder ) ); - - /* initialize builder */ - T2_Init_Builder( &decoder->builder, face, size, slot ); - - /* initialize Type2 decoder */ - decoder->num_globals = cff->num_global_subrs; - decoder->globals = cff->global_subrs; - decoder->globals_bias = t2_compute_bias( decoder->num_globals ); - } - - - /* this function is used to select the locals subrs array */ - LOCAL_DEF - void T2_Prepare_Decoder( T2_Decoder* decoder, - FT_UInt glyph_index ) - { - CFF_Font* cff = (CFF_Font*)decoder->builder.face->extra.data; - CFF_SubFont* sub = &cff->top_font; - - - /* manage CID fonts */ - if ( cff->num_subfonts >= 1 ) - { - FT_Byte fd_index = CFF_Get_FD( &cff->fd_select, glyph_index ); - - - sub = cff->subfonts[fd_index]; - } - - decoder->num_locals = sub->num_local_subrs; - decoder->locals = sub->local_subrs; - decoder->locals_bias = t2_compute_bias( decoder->num_locals ); - - decoder->glyph_width = sub->private_dict.default_width; - decoder->nominal_width = sub->private_dict.nominal_width; - } - - - /* check that there is enough room for `count' more points */ - static - FT_Error check_points( T2_Builder* builder, - FT_Int count ) - { - return FT_GlyphLoader_Check_Points( builder->loader, count, 0 ); - } - - - /* add a new point, do not check space */ - static - void add_point( T2_Builder* builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ) - { - FT_Outline* outline = builder->current; - - - if ( builder->load_points ) - { - FT_Vector* point = outline->points + outline->n_points; - FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; - - - point->x = x >> 16; - point->y = y >> 16; - *control = flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic; - - builder->last = *point; - } - outline->n_points++; - } - - - /* check space for a new on-curve point, then add it */ - static - FT_Error add_point1( T2_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - FT_Error error; - - - error = check_points( builder, 1 ); - if ( !error ) - add_point( builder, x, y, 1 ); - - return error; - } - - - /* check room for a new contour, then add it */ - static - FT_Error add_contour( T2_Builder* builder ) - { - FT_Outline* outline = builder->current; - FT_Error error; - - - if ( !builder->load_points ) - { - outline->n_contours++; - return T2_Err_Ok; - } - - error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 ); - if ( !error ) - { - if ( outline->n_contours > 0 ) - outline->contours[outline->n_contours - 1] = outline->n_points - 1; - - outline->n_contours++; - } - - return error; - } - - - /* if a path was begun, add its first on-curve point */ - static - FT_Error start_point( T2_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - FT_Error error = 0; - - - /* test whether we are building a new contour */ - if ( !builder->path_begun ) - { - builder->path_begun = 1; - error = add_contour( builder ); - if ( !error ) - error = add_point1( builder, x, y ); - } - return error; - } - - - /* close the current contour */ - static - void close_contour( T2_Builder* builder ) - { - FT_Outline* outline = builder->current; - - /* XXXX: We must not include the last point in the path if it */ - /* is located on the first point. */ - if ( outline->n_points > 1 ) - { - FT_Int first = 0; - FT_Vector* p1 = outline->points + first; - FT_Vector* p2 = outline->points + outline->n_points - 1; - - if ( outline->n_contours > 1 ) - { - first = outline->contours[outline->n_contours - 2] + 1; - p1 = outline->points + first; - } - - if ( p1->x == p2->x && p1->y == p2->y ) - outline->n_points--; - } - - if ( outline->n_contours > 0 ) - outline->contours[outline->n_contours - 1] = outline->n_points - 1; - } - - -#define USE_ARGS( n ) do \ - { \ - top -= n; \ - if ( top < decoder->stack ) \ - goto Stack_Underflow; \ - } while ( 0 ) - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Parse_CharStrings */ - /* */ - /* */ - /* Parses a given Type 2 charstrings program. */ - /* */ - /* */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* */ - /* charstring_base :: The base of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - LOCAL_FUNC - FT_Error T2_Parse_CharStrings( T2_Decoder* decoder, - FT_Byte* charstring_base, - FT_Int charstring_len ) - { - FT_Error error; - T2_Decoder_Zone* zone; - FT_Byte* ip; - FT_Byte* limit; - T2_Builder* builder = &decoder->builder; - FT_Outline* outline; - FT_Pos x, y; - FT_Fixed seed; - FT_Fixed* stack; - - - /* set default width */ - decoder->num_hints = 0; - decoder->read_width = 1; - - /* compute random seed from stack address of parameter */ - seed = (FT_Fixed)(char*)&seed ^ - (FT_Fixed)(char*)&decoder ^ - (FT_Fixed)(char*)&charstring_base; - seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFF; - if ( seed == 0 ) - seed = 0x7384; - - /* initialize the decoder */ - decoder->top = decoder->stack; - decoder->zone = decoder->zones; - zone = decoder->zones; - stack = decoder->top; - - builder->path_begun = 0; - - zone->base = charstring_base; - limit = zone->limit = charstring_base + charstring_len; - ip = zone->cursor = zone->base; - - error = T2_Err_Ok; - outline = builder->current; - - x = builder->pos_x; - y = builder->pos_y; - - /* now, execute loop */ - while ( ip < limit ) - { - T2_Operator op; - FT_Byte v; - FT_Byte count; - - - /********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - v = *ip++; - if ( v >= 32 || v == 28 ) - { - FT_Int shift = 16; - FT_Int32 val; - - - /* this is an operand, push it on the stack */ - if ( v == 28 ) - { - if ( ip + 1 >= limit ) - goto Syntax_Error; - val = (FT_Short)( ( (FT_Short)ip[0] << 8 ) | ip[1] ); - ip += 2; - } - else if ( v < 247 ) - val = (FT_Long)v - 139; - else if ( v < 251 ) - { - if ( ip >= limit ) - goto Syntax_Error; - val = ( (FT_Long)v - 247 ) * 256 + *ip++ + 108; - } - else if ( v < 255 ) - { - if ( ip >= limit ) - goto Syntax_Error; - val = -( (FT_Long)v - 251 ) * 256 - *ip++ - 108; - } - else - { - if ( ip + 3 >= limit ) - goto Syntax_Error; - val = ( (FT_Int32)ip[0] << 24 ) | - ( (FT_Int32)ip[1] << 16 ) | - ( (FT_Int32)ip[2] << 8 ) | - ip[3]; - ip += 4; - shift = 0; - } - if ( decoder->top - stack >= T2_MAX_OPERANDS ) - goto Stack_Overflow; - - val <<= shift; - *decoder->top++ = val; - -#ifdef FT_DEBUG_LEVEL_TRACE - if ( !( val & 0xFFFF ) ) - FT_TRACE4(( " %d", (FT_Int32)( val >> 16 ) )); - else - FT_TRACE4(( " %.2f", val/65536.0 )); -#endif - - } - else - { - FT_Fixed* args = decoder->top; - FT_Int num_args = args - decoder->stack; - FT_Int req_args; - - - /* find operator */ - op = t2_op_unknown; - - switch ( v ) - { - case 1: - op = t2_op_hstem; - break; - case 3: - op = t2_op_vstem; - break; - case 4: - op = t2_op_vmoveto; - break; - case 5: - op = t2_op_rlineto; - break; - case 6: - op = t2_op_hlineto; - break; - case 7: - op = t2_op_vlineto; - break; - case 8: - op = t2_op_rrcurveto; - break; - case 10: - op = t2_op_callsubr; - break; - case 11: - op = t2_op_return; - break; - case 12: - { - if ( ip >= limit ) - goto Syntax_Error; - v = *ip++; - - switch ( v ) - { - case 3: - op = t2_op_and; - break; - case 4: - op = t2_op_or; - break; - case 5: - op = t2_op_not; - break; - case 8: - op = t2_op_store; - break; - case 9: - op = t2_op_abs; - break; - case 10: - op = t2_op_add; - break; - case 11: - op = t2_op_sub; - break; - case 12: - op = t2_op_div; - break; - case 13: - op = t2_op_load; - break; - case 14: - op = t2_op_neg; - break; - case 15: - op = t2_op_eq; - break; - case 18: - op = t2_op_drop; - break; - case 20: - op = t2_op_put; - break; - case 21: - op = t2_op_get; - break; - case 22: - op = t2_op_ifelse; - break; - case 23: - op = t2_op_random; - break; - case 24: - op = t2_op_mul; - break; - case 26: - op = t2_op_sqrt; - break; - case 27: - op = t2_op_dup; - break; - case 28: - op = t2_op_exch; - break; - case 29: - op = t2_op_index; - break; - case 30: - op = t2_op_roll; - break; - case 34: - op = t2_op_hflex; - break; - case 35: - op = t2_op_flex; - break; - case 36: - op = t2_op_hflex1; - break; - case 37: - op = t2_op_flex1; - break; - default: - /* decrement ip for syntax error message */ - ip--; - } - } - break; - case 14: - op = t2_op_endchar; - break; - case 16: - op = t2_op_blend; - break; - case 18: - op = t2_op_hstemhm; - break; - case 19: - op = t2_op_hintmask; - break; - case 20: - op = t2_op_cntrmask; - break; - case 21: - op = t2_op_rmoveto; - break; - case 22: - op = t2_op_hmoveto; - break; - case 23: - op = t2_op_vstemhm; - break; - case 24: - op = t2_op_rcurveline; - break; - case 25: - op = t2_op_rlinecurve; - break; - case 26: - op = t2_op_vvcurveto; - break; - case 27: - op = t2_op_hhcurveto; - break; - case 29: - op = t2_op_callgsubr; - break; - case 30: - op = t2_op_vhcurveto; - break; - case 31: - op = t2_op_hvcurveto; - break; - default: - ; - } - if ( op == t2_op_unknown ) - goto Syntax_Error; - - /* check arguments */ - req_args = count = t2_argument_counts[op]; - if ( req_args & T2_COUNT_CHECK_WIDTH ) - { - args = stack; - if ( num_args & 1 && decoder->read_width ) - { - decoder->glyph_width = decoder->nominal_width + - ( stack[0] >> 16 ); - num_args--; - args++; - } - decoder->read_width = 0; - req_args = 0; - } - - req_args &= 15; - if ( num_args < req_args ) - goto Stack_Underflow; - args -= req_args; - num_args -= req_args; - - switch ( op ) - { - case t2_op_hstem: - case t2_op_vstem: - case t2_op_hstemhm: - case t2_op_vstemhm: - /* if the number of arguments is not even, the first one */ - /* is simply the glyph width, encoded as the difference */ - /* to nominalWidthX */ - FT_TRACE4(( op == t2_op_hstem ? " hstem" : - op == t2_op_vstem ? " vstem" : - op == t2_op_hstemhm ? " hstemhm" : - " vstemhm" )); - decoder->num_hints += num_args / 2; - args = stack; - break; - - case t2_op_hintmask: - case t2_op_cntrmask: - FT_TRACE4(( op == t2_op_hintmask ? " hintmask" - : " cntrmask" )); - - decoder->num_hints += num_args / 2; - ip += ( decoder->num_hints + 7 ) >> 3; - if ( ip >= limit ) - goto Syntax_Error; - args = stack; - break; - - case t2_op_rmoveto: - FT_TRACE4(( " rmoveto" )); - - close_contour( builder ); - builder->path_begun = 0; - x += args[0]; - y += args[1]; - args = stack; - break; - - case t2_op_vmoveto: - FT_TRACE4(( " vmoveto" )); - - close_contour( builder ); - builder->path_begun = 0; - y += args[0]; - args = stack; - break; - - case t2_op_hmoveto: - FT_TRACE4(( " hmoveto" )); - - close_contour( builder ); - builder->path_begun = 0; - x += args[0]; - args = stack; - break; - - case t2_op_rlineto: - FT_TRACE4(( " rlineto" )); - - if ( start_point ( builder, x, y ) || - check_points( builder, num_args / 2 ) ) - goto Memory_Error; - - if ( num_args < 2 || num_args & 1 ) - goto Stack_Underflow; - - args = stack; - while ( args < decoder->top ) - { - x += args[0]; - y += args[1]; - add_point( builder, x, y, 1 ); - args += 2; - } - args = stack; - break; - - case t2_op_hlineto: - case t2_op_vlineto: - { - FT_Int phase = ( op == t2_op_hlineto ); - - - FT_TRACE4(( op == t2_op_hlineto ? " hlineto" - : " vlineto" )); - - if ( start_point ( builder, x, y ) || - check_points( builder, num_args ) ) - goto Memory_Error; - - args = stack; - while (args < decoder->top ) - { - if ( phase ) - x += args[0]; - else - y += args[0]; - - if ( add_point1( builder, x, y ) ) - goto Memory_Error; - - args++; - phase ^= 1; - } - args = stack; - } - break; - - case t2_op_rrcurveto: - FT_TRACE4(( " rrcurveto" )); - - /* check number of arguments; must be a multiple of 6 */ - if ( num_args % 6 != 0 ) - goto Stack_Underflow; - - if ( start_point ( builder, x, y ) || - check_points( builder, num_args / 2 ) ) - goto Memory_Error; - - args = stack; - while ( args < decoder->top ) - { - x += args[0]; - y += args[1]; - add_point( builder, x, y, 0 ); - x += args[2]; - y += args[3]; - add_point( builder, x, y, 0 ); - x += args[4]; - y += args[5]; - add_point( builder, x, y, 1 ); - args += 6; - } - args = stack; - break; - - case t2_op_vvcurveto: - FT_TRACE4(( " vvcurveto" )); - - if ( start_point ( builder, x, y ) ) - goto Memory_Error; - - args = stack; - if ( num_args & 1 ) - { - x += args[0]; - args++; - num_args--; - } - - if ( num_args % 4 != 0 ) - goto Stack_Underflow; - - if ( check_points( builder, 3 * ( num_args / 4 ) ) ) - goto Memory_Error; - - while ( args < decoder->top ) - { - y += args[0]; - add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; - add_point( builder, x, y, 0 ); - y += args[3]; - add_point( builder, x, y, 1 ); - args += 4; - } - args = stack; - break; - - case t2_op_hhcurveto: - FT_TRACE4(( " hhcurveto" )); - - if ( start_point ( builder, x, y ) ) - goto Memory_Error; - - args = stack; - if ( num_args & 1 ) - { - y += args[0]; - args++; - num_args--; - } - - if ( num_args % 4 != 0 ) - goto Stack_Underflow; - - if ( check_points( builder, 3 * ( num_args / 4 ) ) ) - goto Memory_Error; - - while ( args < decoder->top ) - { - x += args[0]; - add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; - add_point( builder, x, y, 0 ); - x += args[3]; - add_point( builder, x, y, 1 ); - args += 4; - } - args = stack; - break; - - case t2_op_vhcurveto: - case t2_op_hvcurveto: - { - FT_Int phase; - - - FT_TRACE4(( op == t2_op_vhcurveto ? " vhcurveto" - : " hvcurveto" )); - - if ( start_point ( builder, x, y ) ) - goto Memory_Error; - - args = stack; - if (num_args < 4 || ( num_args % 4 ) > 1 ) - goto Stack_Underflow; - - if ( check_points( builder, ( num_args / 4 ) * 3 ) ) - goto Stack_Underflow; - - phase = ( op == t2_op_hvcurveto ); - - while ( num_args >= 4 ) - { - num_args -= 4; - if ( phase ) - { - x += args[0]; - add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; - add_point( builder, x, y, 0 ); - y += args[3]; - if ( num_args == 1 ) - x += args[4]; - add_point( builder, x, y, 1 ); - } - else - { - y += args[0]; - add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; - add_point( builder, x, y, 0 ); - x += args[3]; - if ( num_args == 1 ) - y += args[4]; - add_point( builder, x, y, 1 ); - } - args += 4; - phase ^= 1; - } - args = stack; - } - break; - - case t2_op_rlinecurve: - { - FT_Int num_lines = ( num_args - 6 ) / 2; - - - FT_TRACE4(( " rlinecurve" )); - - if ( num_args < 8 || ( num_args - 6 ) & 1 ) - goto Stack_Underflow; - - if ( start_point( builder, x, y ) || - check_points( builder, num_lines + 3 ) ) - goto Memory_Error; - - args = stack; - - /* first, add the line segments */ - while ( num_lines > 0 ) - { - x += args[0]; - y += args[1]; - add_point( builder, x, y, 1 ); - args += 2; - num_lines--; - } - - /* then the curve */ - x += args[0]; - y += args[1]; - add_point( builder, x, y, 0 ); - x += args[2]; - y += args[3]; - add_point( builder, x, y, 0 ); - x += args[4]; - y += args[5]; - add_point( builder, x, y, 1 ); - args = stack; - } - break; - - case t2_op_rcurveline: - { - FT_Int num_curves = ( num_args - 2 ) / 6; - - - FT_TRACE4(( " rcurveline" )); - - if ( num_args < 8 || ( num_args - 2 ) % 6 ) - goto Stack_Underflow; - - if ( start_point ( builder, x, y ) || - check_points( builder, num_curves*3 + 2 ) ) - goto Memory_Error; - - args = stack; - - /* first, add the curves */ - while ( num_curves > 0 ) - { - x += args[0]; - y += args[1]; - add_point( builder, x, y, 0 ); - x += args[2]; - y += args[3]; - add_point( builder, x, y, 0 ); - x += args[4]; - y += args[5]; - add_point( builder, x, y, 1 ); - args += 6; - num_curves--; - } - - /* then the final line */ - x += args[0]; - y += args[1]; - add_point( builder, x, y, 1 ); - args = stack; - } - break; - - case t2_op_hflex1: - { - FT_Pos start_y; - - - FT_TRACE4(( " hflex1" )); - - args = stack; - - /* adding five more points; 4 control points, 1 on-curve point */ - /* make sure we have enough space for the start point if it */ - /* needs to be added.. */ - if ( start_point( builder, x, y ) || - check_points( builder, 6 ) ) - goto Memory_Error; - - /* Record the starting point's y postion for later use */ - start_y = y; - - /* first control point */ - x += args[0]; - y += args[1]; - add_point( builder, x, y, 0 ); - - /* second control point */ - x += args[2]; - y += args[3]; - add_point( builder, x, y, 0 ); - - /* join point; on curve, with y-value the same as the last */ - /* control point's y-value */ - x += args[4]; - add_point( builder, x, y, 1 ); - - /* third control point, with y-value the same as the join */ - /* point's y-value */ - x += args[5]; - add_point( builder, x, y, 0 ); - - /* fourth control point */ - x += args[6]; - y += args[7]; - add_point( builder, x, y, 0 ); - - /* ending point, with y-value the same as the start */ - x += args[8]; - y = start_y; - add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case t2_op_hflex: - { - FT_Pos start_y; - - - FT_TRACE4(( " hflex" )); - - args = stack; - - /* adding six more points; 4 control points, 2 on-curve points */ - if ( start_point( builder, x, y ) || - check_points ( builder, 6 ) ) - goto Memory_Error; - - /* record the starting point's y-position for later use */ - start_y = y; - - /* first control point */ - x += args[0]; - add_point( builder, x, y, 0 ); - - /* second control point */ - x += args[1]; - y += args[2]; - add_point( builder, x, y, 0 ); - - /* join point; on curve, with y-value the same as the last */ - /* control point's y-value */ - x += args[3]; - add_point( builder, x, y, 1 ); - - /* third control point, with y-value the same as the join */ - /* point's y-value */ - x += args[4]; - add_point( builder, x, y, 0 ); - - /* fourth control point */ - x += args[5]; - y = start_y; - add_point( builder, x, y, 0 ); - - /* ending point, with y-value the same as the start point's */ - /* y-value -- we don't add this point, though */ - x += args[6]; - add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case t2_op_flex1: - { - FT_Pos start_x, start_y; /* record start x, y values for alter */ - /* use */ - FT_Int dx = 0, dy = 0; /* used in horizontal/vertical */ - /* algorithm below */ - FT_Int horizontal, count; - - - FT_TRACE4(( " flex1" )); - - /* adding six more points; 4 control points, 2 on-curve points */ - if ( start_point( builder, x, y ) || - check_points( builder, 6 ) ) - goto Memory_Error; - - /* record the starting point's x, y postion for later use */ - start_x = x; - start_y = y; - - /* XXX: figure out whether this is supposed to be a horizontal */ - /* or vertical flex; the Type 2 specification is vague... */ - - args = stack; - - /* grab up to the last argument */ - for ( count = 5; count > 0; count-- ) - { - dx += args[0]; - dy += args[1]; - args += 2; - } - - /* rewind */ - args = stack; - - if ( dx < 0 ) dx = -dx; - if ( dy < 0 ) dy = -dy; - - /* strange test, but here it is... */ - horizontal = ( dx > dy ); - - for ( count = 5; count > 0; count-- ) - { - x += args[0]; - y += args[1]; - add_point( builder, x, y, (FT_Bool)( count == 3 ) ); - args += 2; - } - - /* is last operand an x- or y-delta? */ - if ( horizontal ) - { - x += args[0]; - y = start_y; - } - else - { - x = start_x; - y += args[0]; - } - - add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case t2_op_flex: - { - FT_UInt count; - - - FT_TRACE4(( " flex" )); - - if ( start_point( builder, x, y ) || - check_points( builder, 6 ) ) - goto Memory_Error; - - args = stack; - for ( count = 6; count > 0; count-- ) - { - x += args[0]; - y += args[1]; - add_point( builder, x, y, - (FT_Bool)( count == 3 || count == 0 ) ); - args += 2; - } - - args = stack; - } - break; - - case t2_op_endchar: - FT_TRACE4(( " endchar" )); - - close_contour( builder ); - - /* add current outline to the glyph slot */ - FT_GlyphLoader_Add( builder->loader ); - - /* return now! */ - FT_TRACE4(( "\n\n" )); - return T2_Err_Ok; - - case t2_op_abs: - FT_TRACE4(( " abs" )); - - if ( args[0] < 0 ) - args[0] = -args[0]; - args++; - break; - - case t2_op_add: - FT_TRACE4(( " add" )); - - args[0] += args[1]; - args++; - break; - - case t2_op_sub: - FT_TRACE4(( " sub" )); - - args[0] -= args[1]; - args++; - break; - - case t2_op_div: - FT_TRACE4(( " div" )); - - args[0] = FT_DivFix( args[0], args[1] ); - args++; - break; - - case t2_op_neg: - FT_TRACE4(( " neg" )); - - args[0] = -args[0]; - args++; - break; - - case t2_op_random: - { - FT_Fixed rand; - - - FT_TRACE4(( " rand" )); - - rand = seed; - if ( rand >= 0x8000 ) - rand++; - - args[0] = rand; - seed = FT_MulFix( seed, 0x10000L - seed ); - if ( seed == 0 ) - seed += 0x2873; - args++; - } - break; - - case t2_op_mul: - FT_TRACE4(( " mul" )); - - args[0] = FT_MulFix( args[0], args[1] ); - args++; - break; - - case t2_op_sqrt: - FT_TRACE4(( " sqrt" )); - - if ( args[0] > 0 ) - { - FT_Int count = 9; - FT_Fixed root = args[0]; - FT_Fixed new_root; - - - for (;;) - { - new_root = ( root + FT_DivFix(args[0],root) + 1 ) >> 1; - if ( new_root == root || count <= 0 ) - break; - root = new_root; - } - args[0] = new_root; - } - else - args[0] = 0; - args++; - break; - - case t2_op_drop: - /* nothing */ - FT_TRACE4(( " drop" )); - - break; - - case t2_op_exch: - { - FT_Fixed tmp; - - - FT_TRACE4(( " exch" )); - - tmp = args[0]; - args[0] = args[1]; - args[1] = tmp; - args += 2; - } - break; - - case t2_op_index: - { - FT_Int index = args[0] >> 16; - - - FT_TRACE4(( " index" )); - - if ( index < 0 ) - index = 0; - else if ( index > num_args - 2 ) - index = num_args - 2; - args[0] = args[-( index + 1 )]; - args++; - } - break; - - case t2_op_roll: - { - FT_Int count = (FT_Int)( args[0] >> 16 ); - FT_Int index = (FT_Int)( args[1] >> 16 ); - - - FT_TRACE4(( " roll" )); - - if ( count <= 0 ) - count = 1; - - args -= count; - if ( args < stack ) - goto Stack_Underflow; - - if ( index >= 0 ) - { - while ( index > 0 ) - { - FT_Fixed tmp = args[count - 1]; - FT_Int i; - - - for ( i = count - 2; i >= 0; i-- ) - args[i + 1] = args[i]; - args[0] = tmp; - index--; - } - } - else - { - while ( index < 0 ) - { - FT_Fixed tmp = args[0]; - FT_Int i; - - - for ( i = 0; i < count - 1; i++ ) - args[i] = args[i + 1]; - args[count - 1] = tmp; - index++; - } - } - args += count; - } - break; - - case t2_op_dup: - FT_TRACE4(( " dup" )); - - args[1] = args[0]; - args++; - break; - - case t2_op_put: - { - FT_Fixed val = args[0]; - FT_Int index = (FT_Int)( args[1] >> 16 ); - - - FT_TRACE4(( " put" )); - - if ( index >= 0 && index < decoder->len_buildchar ) - decoder->buildchar[index] = val; - } - break; - - case t2_op_get: - { - FT_Int index = (FT_Int)( args[0] >> 16 ); - FT_Fixed val = 0; - - - FT_TRACE4(( " get" )); - - if ( index >= 0 && index < decoder->len_buildchar ) - val = decoder->buildchar[index]; - - args[0] = val; - args++; - } - break; - - case t2_op_store: - FT_TRACE4(( " store ")); - - goto Unimplemented; - - case t2_op_load: - FT_TRACE4(( " load" )); - - goto Unimplemented; - - case t2_op_and: - { - FT_Fixed cond = args[0] && args[1]; - - - FT_TRACE4(( " and" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case t2_op_or: - { - FT_Fixed cond = args[0] || args[1]; - - - FT_TRACE4(( " or" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case t2_op_eq: - { - FT_Fixed cond = !args[0]; - - - FT_TRACE4(( " eq" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case t2_op_ifelse: - { - FT_Fixed cond = (args[2] <= args[3]); - - - FT_TRACE4(( " ifelse" )); - - if ( !cond ) - args[0] = args[1]; - args++; - } - break; - - case t2_op_callsubr: - { - FT_UInt index = (FT_UInt)( ( args[0] >> 16 ) + - decoder->locals_bias ); - - - FT_TRACE4(( " callsubr(%d)", index )); - - if ( index >= decoder->num_locals ) - { - FT_ERROR(( "T2_Parse_CharStrings:" )); - FT_ERROR(( " invalid local subr index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= T2_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "T2_Parse_CharStrings: too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = decoder->locals[index]; - zone->limit = decoder->locals[index+1]; - zone->cursor = zone->base; - - if ( !zone->base ) - { - FT_ERROR(( "T2_Parse_CharStrings: invoking empty subrs!\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case t2_op_callgsubr: - { - FT_UInt index = (FT_UInt)( ( args[0] >> 16 ) + - decoder->globals_bias ); - - - FT_TRACE4(( " callgsubr(%d)", index )); - - if ( index >= decoder->num_globals ) - { - FT_ERROR(( "T2_Parse_CharStrings:" )); - FT_ERROR(( " invalid global subr index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= T2_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "T2_Parse_CharStrings: too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = decoder->globals[index]; - zone->limit = decoder->globals[index+1]; - zone->cursor = zone->base; - - if ( !zone->base ) - { - FT_ERROR(( "T2_Parse_CharStrings: invoking empty subrs!\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case t2_op_return: - FT_TRACE4(( " return" )); - - if ( decoder->zone <= decoder->zones ) - { - FT_ERROR(( "T2_Parse_CharStrings: unexpected return\n" )); - goto Syntax_Error; - } - - decoder->zone--; - zone = decoder->zone; - ip = zone->cursor; - limit = zone->limit; - break; - - default: - Unimplemented: - FT_ERROR(( "Unimplemented opcode: %d", ip[-1] )); - - if ( ip[-1] == 12 ) - FT_ERROR(( " %d", ip[0] )); - FT_ERROR(( "\n" )); - - return T2_Err_Unimplemented_Feature; - } - - decoder->top = args; - - } /* general operator processing */ - - } /* while ip < limit */ - - FT_TRACE4(( "..end..\n\n" )); - - return error; - - Syntax_Error: - FT_TRACE4(( "T2_Parse_CharStrings: syntax error!" )); - return T2_Err_Invalid_File_Format; - - Stack_Underflow: - FT_TRACE4(( "T2_Parse_CharStrings: stack underflow!" )); - return T2_Err_Too_Few_Arguments; - - Stack_Overflow: - FT_TRACE4(( "T2_Parse_CharStrings: stack overflow!" )); - return T2_Err_Stack_Overflow; - - Memory_Error: - return builder->error; - } - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ - /********** *********/ - /********** The following code is in charge of computing *********/ - /********** the maximum advance width of the font. It *********/ - /********** quickly processes each glyph charstring to *********/ - /********** extract the value from either a `sbw' or `seac' *********/ - /********** operator. *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#if 0 /* unused until we support pure CFF fonts */ - - - LOCAL_FUNC - FT_Error T2_Compute_Max_Advance( TT_Face face, - FT_Int* max_advance ) - { - FT_Error error = 0; - T2_Decoder decoder; - FT_Int glyph_index; - CFF_Font* cff = (CFF_Font*)face->other; - - - *max_advance = 0; - - /* Initialize load decoder */ - T2_Init_Decoder( &decoder, face, 0, 0 ); - - decoder.builder.metrics_only = 1; - decoder.builder.load_points = 0; - - /* For each glyph, parse the glyph charstring and extract */ - /* the advance width. */ - for ( glyph_index = 0; glyph_index < face->root.num_glyphs; - glyph_index++ ) - { - FT_Byte* charstring; - FT_ULong charstring_len; - - - /* now get load the unscaled outline */ - error = T2_Access_Element( &cff->charstrings_index, glyph_index, - &charstring, &charstring_len ); - if ( !error ) - { - T2_Prepare_Decoder( &decoder, glyph_index ); - error = T2_Parse_CharStrings( &decoder, charstring, charstring_len ); - - T2_Forget_Element( &cff->charstrings_index, &charstring ); - } - - /* ignore the error if one has occurred -- skip to next glyph */ - error = 0; - } - - *max_advance = decoder.builder.advance.x; - - return T2_Err_Ok; - } - - -#endif /* 0 */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** UNHINTED GLYPH LOADER *********/ - /********** *********/ - /********** The following code is in charge of loading a *********/ - /********** single outline. It completely ignores hinting *********/ - /********** and is used when FT_LOAD_NO_HINTING is set. *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - LOCAL_FUNC - FT_Error T2_Load_Glyph( T2_GlyphSlot glyph, - T2_Size size, - FT_Int glyph_index, - FT_Int load_flags ) - { - FT_Error error; - T2_Decoder decoder; - TT_Face face = (TT_Face)glyph->root.face; - FT_Bool hinting; - CFF_Font* cff = (CFF_Font*)face->extra.data; - - - if ( load_flags & FT_LOAD_NO_RECURSE ) - load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; - - glyph->x_scale = 0x10000L; - glyph->y_scale = 0x10000L; - if ( size ) - { - glyph->x_scale = size->metrics.x_scale; - glyph->y_scale = size->metrics.y_scale; - } - - glyph->root.outline.n_points = 0; - glyph->root.outline.n_contours = 0; - - hinting = ( load_flags & FT_LOAD_NO_SCALE ) == 0 && - ( load_flags & FT_LOAD_NO_HINTING ) == 0; - - glyph->root.format = ft_glyph_format_outline; /* by default */ - - { - FT_Byte* charstring; - FT_ULong charstring_len; - - - T2_Init_Decoder( &decoder, face, size, glyph ); - - decoder.builder.no_recurse = - (FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ); - - /* now load the unscaled outline */ - error = T2_Access_Element( &cff->charstrings_index, glyph_index, - &charstring, &charstring_len ); - if ( !error ) - { - T2_Prepare_Decoder( &decoder, glyph_index ); - error = T2_Parse_CharStrings( &decoder, charstring, charstring_len ); - - T2_Forget_Element( &cff->charstrings_index, &charstring ); - } - - /* save new glyph tables */ - T2_Done_Builder( &decoder.builder ); - } - - /* Now, set the metrics -- this is rather simple, as */ - /* the left side bearing is the xMin, and the top side */ - /* bearing the yMax. */ - if ( !error ) - { - /* for composite glyphs, return only left side bearing and */ - /* advance width */ - if ( glyph->root.format == ft_glyph_format_composite ) - { - glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; - glyph->root.metrics.horiAdvance = decoder.glyph_width; - } - else - { - FT_BBox cbox; - FT_Glyph_Metrics* metrics = &glyph->root.metrics; - - - /* copy the _unscaled_ advance width */ - metrics->horiAdvance = decoder.glyph_width; - - /* make up vertical metrics */ - metrics->vertBearingX = 0; - metrics->vertBearingY = 0; - metrics->vertAdvance = 0; - - glyph->root.format = ft_glyph_format_outline; - - glyph->root.outline.flags = 0; - if ( size && size->metrics.y_ppem < 24 ) - glyph->root.outline.flags |= ft_outline_high_precision; - - glyph->root.outline.flags |= ft_outline_reverse_fill; - - if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) - { - /* scale the outline and the metrics */ - FT_Int n; - FT_Outline* cur = &glyph->root.outline; - FT_Vector* vec = cur->points; - FT_Fixed x_scale = glyph->x_scale; - FT_Fixed y_scale = glyph->y_scale; - - - /* First of all, scale the points */ - for ( n = cur->n_points; n > 0; n--, vec++ ) - { - vec->x = FT_MulFix( vec->x, x_scale ); - vec->y = FT_MulFix( vec->y, y_scale ); - } - - FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - - /* Then scale the metrics */ - metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); - metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); - - metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); - metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - } - -#if 0 - /* apply the font matrix */ - FT_Outline_Transform( &glyph->root.outline, cff->font_matrix ); -#endif - - /* compute the other metrics */ - FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - - /* grid fit the bounding box if necessary */ - if ( hinting ) - { - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax + 63 ) & -64; - cbox.yMax = ( cbox.yMax + 63 ) & -64; - } - - metrics->width = cbox.xMax - cbox.xMin; - metrics->height = cbox.yMax - cbox.yMin; - - metrics->horiBearingX = cbox.xMin; - metrics->horiBearingY = cbox.yMax; - } - } - - return error; - } - - -/* END */ diff --git a/src/freetype/cff/t2gload.h b/src/freetype/cff/t2gload.h deleted file mode 100644 index 2654d4b563..0000000000 --- a/src/freetype/cff/t2gload.h +++ /dev/null @@ -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 - - -#ifdef FT_FLAT_COMPILE - -#include "t2objs.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - - -#define T2_MAX_OPERANDS 48 -#define T2_MAX_SUBRS_CALLS 32 - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Builder */ - /* */ - /* */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cff/t2load.c b/src/freetype/cff/t2load.c deleted file mode 100644 index 4a77693318..0000000000 --- a/src/freetype/cff/t2load.c +++ /dev/null @@ -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 -#include -#include -#include - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "t2load.h" -#include "t2parse.h" - -#else - -#include -#include - -#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 */ diff --git a/src/freetype/cff/t2load.h b/src/freetype/cff/t2load.h deleted file mode 100644 index 7ebc76d27d..0000000000 --- a/src/freetype/cff/t2load.h +++ /dev/null @@ -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 -#include - -#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 */ diff --git a/src/freetype/cff/t2objs.c b/src/freetype/cff/t2objs.c deleted file mode 100644 index 1d59a585f7..0000000000 --- a/src/freetype/cff/t2objs.c +++ /dev/null @@ -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 -#include -#include -#include -#include -#include - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "t2objs.h" -#include "t2load.h" - -#else - -#include -#include - -#endif - - -#include - -#include /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Init_Face */ - /* */ - /* */ - /* Initializes a given OpenType face object. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* face :: The newly built face object. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Done_Face */ - /* */ - /* */ - /* Finalizes a given face object. */ - /* */ - /* */ - /* 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 ); - } - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Init_Driver */ - /* */ - /* */ - /* Initializes a given OpenType driver object. */ - /* */ - /* */ - /* driver :: A handle to the target driver object. */ - /* */ - /* */ - /* 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 - } - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Done_Driver */ - /* */ - /* */ - /* Finalizes a given OpenType driver. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cff/t2objs.h b/src/freetype/cff/t2objs.h deleted file mode 100644 index 2602862751..0000000000 --- a/src/freetype/cff/t2objs.h +++ /dev/null @@ -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 -#include -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Driver */ - /* */ - /* */ - /* A handle to an OpenType driver object. */ - /* */ - typedef struct T2_DriverRec_* T2_Driver; - - typedef TT_Face T2_Face; - - - /*************************************************************************/ - /* */ - /* */ - /* T2_Size */ - /* */ - /* */ - /* A handle to an OpenType size object. */ - /* */ - typedef FT_Size T2_Size; - - - /*************************************************************************/ - /* */ - /* */ - /* T2_GlyphSlot */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cff/t2parse.c b/src/freetype/cff/t2parse.c deleted file mode 100644 index 7d62fef5b6..0000000000 --- a/src/freetype/cff/t2parse.c +++ /dev/null @@ -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 - -#endif - - -#include - - - /*************************************************************************/ - /* */ - /* 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 - -#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 */ diff --git a/src/freetype/cff/t2parse.h b/src/freetype/cff/t2parse.h deleted file mode 100644 index 2238444b7a..0000000000 --- a/src/freetype/cff/t2parse.h +++ /dev/null @@ -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 -#include - -#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 */ diff --git a/src/freetype/cff/t2tokens.h b/src/freetype/cff/t2tokens.h deleted file mode 100644 index 13a15e43df..0000000000 --- a/src/freetype/cff/t2tokens.h +++ /dev/null @@ -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 */ diff --git a/src/freetype/cid/cidafm.c b/src/freetype/cid/cidafm.c deleted file mode 100644 index b5638836ea..0000000000 --- a/src/freetype/cid/cidafm.c +++ /dev/null @@ -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 - -#endif - - -#include -#include -#include - -#include /* for qsort() */ -#include /* for strcmp() */ -#include /* 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 */ diff --git a/src/freetype/cid/cidafm.h b/src/freetype/cid/cidafm.h deleted file mode 100644 index 542604e0dd..0000000000 --- a/src/freetype/cid/cidafm.h +++ /dev/null @@ -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 - -#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 */ diff --git a/src/freetype/cid/cidgload.c b/src/freetype/cid/cidgload.c deleted file mode 100644 index 97c9252be2..0000000000 --- a/src/freetype/cid/cidgload.c +++ /dev/null @@ -1,1558 +0,0 @@ -/***************************************************************************/ -/* */ -/* cidgload.c */ -/* */ -/* CID-keyed Type1 Glyph 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. */ -/* */ -/***************************************************************************/ - - -#ifdef FT_FLAT_COMPILE - -#include "cidload.h" -#include "cidgload.h" - -#else - -#include -#include - -#endif - - -#include -#include -#include - - - /*************************************************************************/ - /* */ - /* 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_cidgload - - - /* forward */ - static - FT_Error cid_load_glyph( CID_Decoder* decoder, - FT_UInt glyph_index ); - - - typedef enum CID_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 */ - - } CID_Operator; - - static - const FT_Int t1_args_count[op_max] = - { - 0, /* none */ - 0, /* endchar */ - 2, /* hsbw */ - 5, /* seac */ - 4, /* sbw */ - 0, /* closepath */ - - 1, /* hlineto */ - 1, /* hmoveto */ - 4, /* hvcurveto */ - 2, /* rlineto */ - 2, /* rmoveto */ - 6, /* rrcurveto */ - 4, /* vhcurveto */ - 1, /* vlineto */ - 1, /* vmoveto */ - - 0, /* dotsection */ - - 2, /* hstem */ - 6, /* hstem3 */ - 2, /* vstem */ - 6, /* vstem3 */ - - 2, /* div */ - -1, /* callothersubr */ - 1, /* callsubr */ - 0, /* pop */ - 0, /* return */ - 2 /* setcurrentpoint */ - }; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** GENERIC CHARSTRING PARSING *********/ - /********** *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Init_Builder */ - /* */ - /* */ - /* Initializes a given glyph builder. */ - /* */ - /* */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - LOCAL_FUNC - void CID_Init_Builder( CID_Builder* builder, - CID_Face face, - CID_Size size, - CID_GlyphSlot glyph ) - { - builder->path_begun = 0; - builder->load_points = 1; - - builder->face = face; - builder->glyph = glyph; - builder->memory = face->root.memory; - - if ( glyph ) - { - FT_GlyphLoader* loader = glyph->root.loader; - - - builder->loader = loader; - builder->base = &loader->base.outline; - builder->current = &loader->current.outline; - - FT_GlyphLoader_Rewind( loader ); - } - - if ( size ) - { - builder->scale_x = size->root.metrics.x_scale; - builder->scale_y = size->root.metrics.y_scale; - } - - builder->pos_x = 0; - builder->pos_y = 0; - - builder->left_bearing.x = 0; - builder->left_bearing.y = 0; - builder->advance.x = 0; - builder->advance.y = 0; - - } - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Done_Builder */ - /* */ - /* */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ - LOCAL_FUNC - void CID_Done_Builder( CID_Builder* builder ) - { - CID_GlyphSlot glyph = builder->glyph; - - - if ( glyph ) - glyph->root.outline = *builder->base; - } - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Init_Decoder */ - /* */ - /* */ - /* Initializes a given glyph decoder. */ - /* */ - /* */ - /* decoder :: A pointer to the glyph builder to initialize. */ - /* */ - LOCAL_FUNC - void CID_Init_Decoder( CID_Decoder* decoder ) - { - MEM_Set( decoder, 0, sizeof ( *decoder ) ); - - decoder->font_matrix.xx = 0x10000L; - decoder->font_matrix.yy = 0x10000L; - } - - - /* check that there is enough space for `count' more points */ - static - FT_Error check_points( CID_Builder* builder, - FT_Int count ) - { - return FT_GlyphLoader_Check_Points( builder->loader, count, 0 ); - } - - - /* add a new point, but do not check space */ - static - void add_point( CID_Builder* builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ) - { - FT_Outline* outline = builder->current; - - - if ( builder->load_points ) - { - FT_Vector* point = outline->points + outline->n_points; - FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; - - - point->x = x; - point->y = y; - *control = flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic; - - builder->last = *point; - } - - outline->n_points++; - } - - - /* check space for a new on-curve point, then add it */ - static - FT_Error add_point1( CID_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - FT_Error error; - - - error = check_points( builder, 1 ); - if ( !error ) - add_point( builder, x, y, 1 ); - - return error; - } - - - /* check room for a new contour, then add it */ - static - FT_Error add_contour( CID_Builder* builder ) - { - FT_Outline* outline = builder->current; - FT_Error error; - - - if ( !builder->load_points ) - { - outline->n_contours++; - return T1_Err_Ok; - } - - error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 ); - if ( !error ) - { - if ( outline->n_contours > 0 ) - outline->contours[outline->n_contours - 1] = outline->n_points - 1; - - outline->n_contours++; - } - return error; - } - - - /* if a path has been started, add its first on-curve point */ - static - FT_Error start_point( CID_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - /* test whether we are building a new contour */ - if ( !builder->path_begun ) - { - FT_Error error; - - - builder->path_begun = 1; - error = add_contour( builder ); - if ( error ) - return error; - } - - return add_point1( builder, x, y ); - } - - - /* close the current contour */ - static - void close_contour( CID_Builder* builder ) - { - FT_Outline* outline = builder->current; - - - /* XXX: We must not include the last point in the path if it */ - /* is located on the first point. */ - if ( outline->n_points > 1 ) - { - FT_Int first = 0; - FT_Vector* p1 = outline->points + first; - FT_Vector* p2 = outline->points + outline->n_points - 1; - - - if ( outline->n_contours > 1 ) - { - first = outline->contours[outline->n_contours - 2] + 1; - p1 = outline->points + first; - } - - if ( p1->x == p2->x && p1->y == p2->y ) - outline->n_points--; - } - - if ( outline->n_contours > 0 ) - outline->contours[outline->n_contours - 1] = outline->n_points - 1; - } - - -#if 0 - - - /*************************************************************************/ - /* */ - /* */ - /* lookup_glyph_by_stdcharcode */ - /* */ - /* */ - /* Looks up a given glyph by its StandardEncoding charcode. Used */ - /* to implement the SEAC Type 1 operator. */ - /* */ - /* */ - /* face :: The current face object. */ - /* */ - /* charcode :: The character code to look for. */ - /* */ - /* */ - /* A glyph index in the font face. Returns -1 if the corresponding */ - /* glyph wasn't found. */ - /* */ - static - FT_Int lookup_glyph_by_stdcharcode( CID_Face face, - FT_Int charcode ) - { - FT_Int n; - const FT_String* glyph_name; - PSNames_Interface* psnames = (PSNames_Interface*)face->psnames; - - - /* check range of standard char code */ - if ( charcode < 0 || charcode > 255 ) - return -1; - - glyph_name = psnames->adobe_std_strings( - psnames->adobe_std_encoding[charcode]); - - for ( n = 0; n < face->cid.cid_count; n++ ) - { - FT_String* name = (FT_String*)face->type1.glyph_names[n]; - - - if ( name && strcmp( name, glyph_name ) == 0 ) - return n; - } - - return -1; - } - - -#endif /* 0 */ - - - /*************************************************************************/ - /* */ - /* */ - /* t1operator_seac */ - /* */ - /* */ - /* Implements the `seac' Type 1 operator for a Type 1 decoder. */ - /* */ - /* */ - /* decoder :: The current CID decoder. */ - /* */ - /* asb :: The accent's side bearing. */ - /* */ - /* adx :: The horizontal offset of the accent. */ - /* */ - /* ady :: The vertical offset of the accent. */ - /* */ - /* bchar :: The base character's StandardEncoding charcode. */ - /* */ - /* achar :: The accent character's StandardEncoding charcode. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - static - FT_Error t1operator_seac( CID_Decoder* decoder, - FT_Pos asb, - FT_Pos adx, - FT_Pos ady, - FT_Int bchar, - FT_Int achar ) - { - FT_Error error; - FT_Int bchar_index, achar_index, n_base_points; - FT_Outline* base = decoder->builder.base; - FT_Vector left_bearing, advance; - - - bchar_index = bchar; - achar_index = achar; - - if ( bchar_index < 0 || achar_index < 0 ) - { - FT_ERROR(( "t1operator_seac:" )); - FT_ERROR(( " invalid seac character code arguments\n" )); - return T1_Err_Syntax_Error; - } - - /* if we are trying to load a composite glyph, do not load the */ - /* accent character and return the array of subglyphs. */ - if ( decoder->builder.no_recurse ) - { - FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph; - FT_GlyphLoader* loader = glyph->loader; - FT_SubGlyph* subg; - - - /* reallocate subglyph array if necessary */ - error = FT_GlyphLoader_Check_Subglyphs( loader, 2 ); - if ( error ) - goto Exit; - - subg = loader->current.subglyphs; - - /* subglyph 0 = base character */ - subg->index = bchar_index; - subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | - FT_SUBGLYPH_FLAG_USE_MY_METRICS; - subg->arg1 = 0; - subg->arg2 = 0; - subg++; - - /* subglyph 1 = accent character */ - subg->index = achar_index; - subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; - subg->arg1 = adx - asb; - subg->arg2 = ady; - - /* set up remaining glyph fields */ - glyph->num_subglyphs = 2; - glyph->subglyphs = loader->current.subglyphs; - glyph->format = ft_glyph_format_composite; - - loader->current.num_subglyphs = 2; - } - - /* First load `bchar' in builder */ - /* now load the unscaled outline */ - if ( decoder->builder.loader ) - FT_GlyphLoader_Prepare( decoder->builder.loader ); - - error = cid_load_glyph( decoder, bchar_index ); /* load one glyph */ - if ( error ) - goto Exit; - - n_base_points = base->n_points; - - { - /* save the left bearing and width of the base character */ - /* as they will be erased by the next load. */ - - left_bearing = decoder->builder.left_bearing; - advance = decoder->builder.advance; - - decoder->builder.left_bearing.x = 0; - decoder->builder.left_bearing.y = 0; - - /* Now load `achar' on top of */ - /* the base outline */ - error = cid_load_glyph( decoder, achar_index ); - if ( error ) - return error; - - /* restore the left side bearing and */ - /* advance width of the base character */ - - decoder->builder.left_bearing = left_bearing; - decoder->builder.advance = advance; - - /* Finally, move the accent */ - if ( decoder->builder.load_points ) - { - FT_Outline dummy; - - - dummy.n_points = base->n_points - n_base_points; - dummy.points = base->points + n_base_points; - FT_Outline_Translate( &dummy, adx - asb, ady ); - } - } - - Exit: - return error; - } - - -#define USE_ARGS( n ) do \ - { \ - top -= n; \ - if ( top < decoder->stack ) \ - goto Stack_Underflow; \ - } while ( 0 ) - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Parse_CharStrings */ - /* */ - /* */ - /* Parses a given CID charstrings program. */ - /* */ - /* */ - /* decoder :: The current CID decoder. */ - /* */ - /* */ - /* charstring_base :: The base of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - LOCAL_FUNC - FT_Error CID_Parse_CharStrings( CID_Decoder* decoder, - FT_Byte* charstring_base, - FT_Int charstring_len ) - { - FT_Error error; - CID_Decoder_Zone* zone; - FT_Byte* ip; - FT_Byte* limit; - CID_Builder* builder = &decoder->builder; - FT_Outline* outline; - FT_Pos x, y; - - - /* First of all, initialize the decoder */ - decoder->top = decoder->stack; - decoder->zone = decoder->zones; - zone = decoder->zones; - - builder->path_begun = 0; - - zone->base = charstring_base; - limit = zone->limit = charstring_base + charstring_len; - ip = zone->cursor = zone->base; - - error = T1_Err_Ok; - outline = builder->current; - - x = builder->pos_x; - y = builder->pos_y; - - /* now, execute loop */ - while ( ip < limit ) - { - FT_Int* top = decoder->top; - CID_Operator op = op_none; - FT_Long value = 0; - - - /********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - - /* First of all, decompress operator or value */ - switch ( *ip++ ) - { - case 1: - op = op_hstem; - break; - - case 3: - op = op_vstem; - break; - case 4: - op = op_vmoveto; - break; - case 5: - op = op_rlineto; - break; - case 6: - op = op_hlineto; - break; - case 7: - op = op_vlineto; - break; - case 8: - op = op_rrcurveto; - break; - case 9: - op = op_closepath; - break; - case 10: - op = op_callsubr; - break; - case 11: - op = op_return; - break; - - case 13: - op = op_hsbw; - break; - case 14: - op = op_endchar; - break; - - case 21: - op = op_rmoveto; - break; - case 22: - op = op_hmoveto; - break; - - case 30: - op = op_vhcurveto; - break; - case 31: - op = op_hvcurveto; - break; - - case 12: - if ( ip > limit ) - { - FT_ERROR(( "CID_Parse_CharStrings: invalid escape (12+EOF)\n" )); - goto Syntax_Error; - } - - switch ( *ip++ ) - { - case 0: - op = op_dotsection; - break; - case 1: - op = op_vstem3; - break; - case 2: - op = op_hstem3; - break; - case 6: - op = op_seac; - break; - case 7: - op = op_sbw; - break; - case 12: - op = op_div; - break; - case 16: - op = op_callothersubr; - break; - case 17: - op = op_pop; - break; - case 33: - op = op_setcurrentpoint; - break; - - default: - FT_ERROR(( "CID_Parse_CharStrings: invalid escape (12+%d)\n", - ip[-1] )); - goto Syntax_Error; - } - break; - - case 255: /* four bytes integer */ - if ( ip + 4 > limit ) - { - FT_ERROR(( "CID_Parse_CharStrings: unexpected EOF in integer\n" )); - goto Syntax_Error; - } - - value = ( (long)ip[0] << 24 ) | - ( (long)ip[1] << 16 ) | - ( (long)ip[2] << 8 ) | - ip[3]; - ip += 4; - break; - - default: - if ( ip[-1] >= 32 ) - { - if ( ip[-1] < 247 ) - value = (long)ip[-1] - 139; - else - { - if ( ++ip > limit ) - { - FT_ERROR(( "CID_Parse_CharStrings:" )); - FT_ERROR(( " unexpected EOF in integer\n" )); - goto Syntax_Error; - } - - if ( ip[-2] < 251 ) - value = ( (long)( ip[-2] - 247 ) << 8 ) + ip[-1] + 108; - else - value = -( ( ( (long)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 ); - } - } - else - { - FT_ERROR(( "CID_Parse_CharStrings: invalid byte (%d)\n", - ip[-1] )); - goto Syntax_Error; - } - } - - /********************************************************************/ - /* */ - /* Push value on stack, or process operator */ - /* */ - if ( op == op_none ) - { - if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) - { - FT_ERROR(( "CID_Parse_CharStrings: Stack overflow!\n" )); - goto Syntax_Error; - } - - FT_TRACE4(( " %ld", value )); - *top++ = value; - decoder->top = top; - } - else if ( op == op_callothersubr ) /* callothersubr */ - { - FT_TRACE4(( " callothersubr" )); - - if ( top - decoder->stack < 2 ) - goto Stack_Underflow; - - top -= 2; - switch ( top[1] ) - { - case 1: /* start flex feature ---------------------- */ - if ( top[0] != 0 ) - goto Unexpected_OtherSubr; - - decoder->flex_state = 1; - decoder->num_flex_vectors = 0; - if ( start_point( builder, x, y ) || - check_points( builder, 6 ) ) - goto Memory_Error; - break; - - case 2: /* add flex vectors ------------------------ */ - { - FT_Int index; - - - if ( top[0] != 0 ) - goto Unexpected_OtherSubr; - - /* note that we should not add a point for index 0. */ - /* this will move our current position to the flex */ - /* point without adding any point to the outline */ - index = decoder->num_flex_vectors++; - if ( index > 0 && index < 7 ) - add_point( builder, - x, - y, - (FT_Byte)( index==3 || index==6 ) ); - } - break; - - case 0: /* end flex feature ------------------------- */ - if ( top[0] != 3 ) - goto Unexpected_OtherSubr; - - if ( decoder->flex_state == 0 || - decoder->num_flex_vectors != 7 ) - { - FT_ERROR(( "CID_Parse_CharStrings: unexpected flex end\n" )); - goto Syntax_Error; - } - - /* now consume the remaining `pop pop setcurpoint' */ - if ( ip + 6 > limit || - ip[0] != 12 || ip[1] != 17 || /* pop */ - ip[2] != 12 || ip[3] != 17 || /* pop */ - ip[4] != 12 || ip[5] != 33 ) /* setcurpoint */ - { - FT_ERROR(( "CID_Parse_CharStrings: invalid flex charstring\n" )); - goto Syntax_Error; - } - - ip += 6; - decoder->flex_state = 0; - break; - - case 3: /* change hints ---------------------------- */ - if ( top[0] != 1 ) - goto Unexpected_OtherSubr; - - /* eat the following `pop' */ - if ( ip + 2 > limit ) - { - FT_ERROR(( "CID_Parse_CharStrings: invalid escape (12+%d)\n", - ip[-1] )); - goto Syntax_Error; - } - - if ( ip[0] != 12 || ip[1] != 17 ) - { - FT_ERROR(( "CID_Parse_CharStrings:" )); - FT_ERROR(( " `pop' expected, found (%d %d)\n", - ip[0], ip[1] )); - goto Syntax_Error; - } - ip += 2; - break; - - case 12: - case 13: - /* counter control hints, clear stack */ - top = decoder->stack; - break; - -#if 0 - - case 14: - case 15: - case 16: - case 17: - case 18: /* multiple masters */ - { - T1_Blend* blend = decoder->blend; - FT_UInt num_points, nn, mm; - FT_Int* delta; - FT_Int* values; - - - if ( !blend ) - { - FT_ERROR(( "CID_Parse_CharStrings:" )); - FT_ERROR(( " unexpected multiple masters operator!\n" )); - goto Syntax_Error; - } - - num_points = top[1] - 13 + ( top[1] == 18 ); - if ( top[0] != num_points * blend->num_designs ) - { - FT_ERROR(( "CID_Parse_CharStrings:" )); - FT_ERROR(( " incorrect number of mm arguments\n" )); - goto Syntax_Error; - } - - top -= blend->num_designs * num_points; - if ( top < decoder->stack ) - goto Stack_Underflow; - - /* We want to compute: */ - /* */ - /* a0*w0 + a1*w1 + ... + ak*wk */ - /* */ - /* but we only have the a0, a1-a0, a2-a0, .. ak-a0. */ - /* However, given that w0 + w1 + ... + wk == 1, we can */ - /* rewrite it easily as: */ - /* */ - /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk */ - /* */ - /* where k == num_designs-1 */ - /* */ - /* I guess that's why it's written in this `compact' */ - /* form... */ - /* */ - delta = top + num_points; - values = top; - for ( nn = 0; nn < num_points; nn++ ) - { - FT_Int x = values[0]; - - - for ( mm = 1; mm < blend->num_designs; mm++ ) - x += FT_MulFix( *delta++, blend->weight_vector[mm] ); - - *values++ = x; - } - /* note that `top' will be incremented later by calls to `pop' */ - } - break; - -#endif - - default: - Unexpected_OtherSubr: - FT_ERROR(( "CID_Parse_CharStrings: invalid othersubr [%d %d]!\n", - top[0], top[1] )); - goto Syntax_Error; - } - decoder->top = top; - } - else /* general operator */ - { - FT_Int num_args = t1_args_count[op]; - - - if ( top - decoder->stack < num_args ) - goto Stack_Underflow; - - top -= num_args; - - switch ( op ) - { - case op_endchar: - FT_TRACE4(( " endchar" )); - - close_contour( builder ); - - /* add current outline to the glyph slot */ - FT_GlyphLoader_Add( builder->loader ); - - /* return now! */ - FT_TRACE4(( "\n\n" )); - return T1_Err_Ok; - - case op_hsbw: - FT_TRACE4(( " hsbw" )); - - builder->left_bearing.x += top[0]; - builder->advance.x = top[1]; - builder->advance.y = 0; - - builder->last.x = x = top[0]; - builder->last.y = y = 0; - - /* The `metrics_only' indicates that we only want to compute */ - /* the glyph's metrics (lsb + advance width), not load the */ - /* rest of it. So exit immediately. */ - if ( builder->metrics_only ) - return T1_Err_Ok; - - break; - - case op_seac: - /* return immediately after processing */ - return t1operator_seac( decoder, top[0], top[1], - top[2], top[3], top[4] ); - - case op_sbw: - FT_TRACE4(( " sbw" )); - - builder->left_bearing.x += top[0]; - builder->left_bearing.y += top[1]; - builder->advance.x = top[2]; - builder->advance.y = top[3]; - - builder->last.x = x = top[0]; - builder->last.y = y = top[1]; - - /* The `metrics_only' indicates that we only want to compute */ - /* the glyph's metrics (lsb + advance width), not load the */ - /* rest of it. So exit immediately. */ - if ( builder->metrics_only ) - return T1_Err_Ok; - - break; - - case op_closepath: - FT_TRACE4(( " closepath" )); - - close_contour( builder ); - builder->path_begun = 0; - break; - - case op_hlineto: - FT_TRACE4(( " hlineto" )); - - if ( start_point( builder, x, y ) ) - goto Memory_Error; - - x += top[0]; - goto Add_Line; - - case op_hmoveto: - FT_TRACE4(( " hmoveto" )); - - x += top[0]; - break; - - case op_hvcurveto: - FT_TRACE4(( " hvcurveto" )); - - if ( start_point( builder, x, y ) || - check_points( builder, 3 ) ) - goto Memory_Error; - - x += top[0]; - add_point( builder, x, y, 0 ); - - x += top[1]; - y += top[2]; - add_point( builder, x, y, 0 ); - - y += top[3]; - add_point( builder, x, y, 1 ); - - break; - - case op_rlineto: - FT_TRACE4(( " rlineto" )); - - if ( start_point( builder, x, y ) ) - goto Memory_Error; - - x += top[0]; - y += top[1]; - - Add_Line: - if ( add_point1( builder, x, y ) ) - goto Memory_Error; - break; - - case op_rmoveto: - FT_TRACE4(( " rmoveto" )); - - x += top[0]; - y += top[1]; - break; - - case op_rrcurveto: - FT_TRACE4(( " rcurveto" )); - - if ( start_point( builder, x, y ) || - check_points( builder, 3 ) ) - goto Memory_Error; - - x += top[0]; - y += top[1]; - add_point( builder, x, y, 0 ); - - x += top[2]; - y += top[3]; - add_point( builder, x, y, 0 ); - - x += top[4]; - y += top[5]; - add_point( builder, x, y, 1 ); - - break; - - case op_vhcurveto: - FT_TRACE4(( " vhcurveto" )); - - if ( start_point( builder, x, y ) || - check_points( builder, 3 ) ) - goto Memory_Error; - - y += top[0]; - add_point( builder, x, y, 0 ); - - x += top[1]; - y += top[2]; - add_point( builder, x, y, 0 ); - - x += top[3]; - add_point( builder, x, y, 1 ); - - break; - - case op_vlineto: - FT_TRACE4(( " vlineto" )); - - if ( start_point( builder, x, y ) ) - goto Memory_Error; - - y += top[0]; - goto Add_Line; - - case op_vmoveto: - FT_TRACE4(( " vmoveto" )); - - y += top[0]; - break; - - case op_div: - FT_TRACE4(( " div" )); - - if ( top[1] ) - { - *top = top[0] / top[1]; - top++; - } - else - { - FT_ERROR(( "CID_Parse_CharStrings: division by 0\n" )); - goto Syntax_Error; - } - break; - - case op_callsubr: - { - FT_Int index; - - - FT_TRACE4(( " callsubr" )); - - index = top[0]; - if ( index < 0 || index >= (FT_Int)decoder->subrs->num_subrs ) - { - FT_ERROR(( "CID_Parse_CharStrings: invalid subrs index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "CID_Parse_CharStrings: too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = decoder->subrs->code[index] + decoder->lenIV; - zone->limit = decoder->subrs->code[index + 1]; - zone->cursor = zone->base; - - if ( !zone->base ) - { - FT_ERROR(( "CID_Parse_CharStrings: invoking empty subrs!\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case op_pop: - FT_TRACE4(( " pop" )); - - /* theoretically, the arguments are already on the stack */ - top++; - break; - - case op_return: - FT_TRACE4(( " return" )); - - if ( zone <= decoder->zones ) - { - FT_ERROR(( "CID_Parse_CharStrings: unexpected return\n" )); - goto Syntax_Error; - } - - zone--; - ip = zone->cursor; - limit = zone->limit; - decoder->zone = zone; - - break; - - case op_dotsection: - FT_TRACE4(( " dotsection" )); - - break; - - case op_hstem: - FT_TRACE4(( " hstem" )); - - break; - - case op_hstem3: - FT_TRACE4(( " hstem3" )); - - break; - - case op_vstem: - FT_TRACE4(( " vstem" )); - - break; - - case op_vstem3: - FT_TRACE4(( " vstem3" )); - - break; - - case op_setcurrentpoint: - FT_TRACE4(( " setcurrentpoint" )); - - FT_ERROR(( "CID_Parse_CharStrings:" )); - FT_ERROR(( " unexpected `setcurrentpoint'\n" )); - goto Syntax_Error; - - default: - FT_ERROR(( "CID_Parse_CharStrings: unhandled opcode %d\n", op )); - goto Syntax_Error; - } - - decoder->top = top; - - } /* general operator processing */ - - } /* while ip < limit */ - - FT_TRACE4(( "..end..\n\n" )); - - return error; - - Syntax_Error: - return T1_Err_Syntax_Error; - - Stack_Underflow: - return T1_Err_Stack_Underflow; - - Memory_Error: - return builder->error; - } - - -#if 0 - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ - /********** *********/ - /********** The following code is in charge of computing *********/ - /********** the maximum advance width of the font. It *********/ - /********** quickly processes each glyph charstring to *********/ - /********** extract the value from either a `sbw' or `seac' *********/ - /********** operator. *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - LOCAL_FUNC - FT_Error CID_Compute_Max_Advance( CID_Face face, - FT_Int* max_advance ) - { - FT_Error error; - CID_Decoder decoder; - FT_Int glyph_index; - - - *max_advance = 0; - - /* Initialize load decoder */ - CID_Init_Decoder( &decoder ); - CID_Init_Builder( &decoder.builder, face, 0, 0 ); - - decoder.builder.metrics_only = 1; - decoder.builder.load_points = 0; - - /* for each glyph, parse the glyph charstring and extract */ - /* the advance width */ - for ( glyph_index = 0; glyph_index < face->root.num_glyphs; - glyph_index++ ) - { - /* now get load the unscaled outline */ - error = cid_load_glyph( &decoder, glyph_index ); - /* ignore the error if one occurred - skip to next glyph */ - } - - *max_advance = decoder.builder.advance.x; - - return T1_Err_Ok; - } - - -#endif /* 0 */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** UNHINTED GLYPH LOADER *********/ - /********** *********/ - /********** The following code is in charge of loading a *********/ - /********** single outline. It completely ignores hinting *********/ - /********** and is used when FT_LOAD_NO_HINTING is set. *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - static - FT_Error cid_load_glyph( CID_Decoder* decoder, - FT_UInt glyph_index ) - { - CID_Face face = decoder->builder.face; - CID_Info* cid = &face->cid; - FT_Byte* p; - FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes; - FT_UInt fd_select; - FT_ULong off1, glyph_len; - FT_Stream stream = face->root.stream; - FT_Error error = 0; - - - /* read the CID font dict index and charstring offset from the CIDMap */ - if ( FILE_Seek( cid->data_offset + cid->cidmap_offset + - glyph_index * entry_len) || - ACCESS_Frame( 2 * entry_len ) ) - goto Exit; - - p = (FT_Byte*)stream->cursor; - fd_select = (FT_UInt) cid_get_offset( &p, (FT_Byte)cid->fd_bytes ); - off1 = (FT_ULong)cid_get_offset( &p, (FT_Byte)cid->gd_bytes ); - p += cid->fd_bytes; - glyph_len = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ) - off1; - - FORGET_Frame(); - - /* now, if the glyph is not empty, set up the subrs array, and parse */ - /* the charstrings */ - if ( glyph_len > 0 ) - { - CID_FontDict* dict; - FT_Byte* charstring; - FT_UInt lenIV; - FT_Memory memory = face->root.memory; - - - /* setup subrs */ - decoder->subrs = face->subrs + fd_select; - - /* setup font matrix */ - dict = cid->font_dicts + fd_select; - decoder->font_matrix = dict->font_matrix; - lenIV = dict->private_dict.lenIV; - decoder->lenIV = lenIV; - - /* the charstrings are encoded (stupid!) */ - /* load the charstrings, then execute it */ - - if ( ALLOC( charstring, glyph_len ) ) - goto Exit; - - if ( !FILE_Read_At( cid->data_offset + off1, charstring, glyph_len ) ) - { - cid_decrypt( charstring, glyph_len, 4330 ); - error = CID_Parse_CharStrings( decoder, - charstring + lenIV, - glyph_len - lenIV ); - } - - FREE( charstring ); - } - - Exit: - return error; - } - - - LOCAL_FUNC - FT_Error CID_Load_Glyph( CID_GlyphSlot glyph, - CID_Size size, - FT_Int glyph_index, - FT_Int load_flags ) - { - FT_Error error; - CID_Decoder decoder; - CID_Face face = (CID_Face)glyph->root.face; - FT_Bool hinting; - - - if ( load_flags & FT_LOAD_NO_RECURSE ) - load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; - - glyph->x_scale = size->root.metrics.x_scale; - glyph->y_scale = size->root.metrics.y_scale; - - glyph->root.outline.n_points = 0; - glyph->root.outline.n_contours = 0; - - hinting = ( load_flags & FT_LOAD_NO_SCALE ) == 0 && - ( load_flags & FT_LOAD_NO_HINTING ) == 0; - - glyph->root.format = ft_glyph_format_outline; - - { - CID_Init_Decoder( &decoder ); - CID_Init_Builder( &decoder.builder, face, size, glyph ); - - /* set up the decoder */ - decoder.builder.no_recurse = - (FT_Bool)( load_flags & FT_LOAD_NO_RECURSE ); - - error = cid_load_glyph( &decoder, glyph_index ); - - /* save new glyph tables */ - CID_Done_Builder( &decoder.builder ); - } - - /* Now, set the metrics - this is rather simple, as */ - /* the left side bearing is the xMin, and the top side */ - /* bearing the yMax. */ - if ( !error ) - { - /* for composite glyphs, return only the left side bearing and the */ - /* advance width */ - if ( load_flags & FT_LOAD_NO_RECURSE ) - { - glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; - glyph->root.metrics.horiAdvance = decoder.builder.advance.x; - } - else - { - FT_BBox cbox; - FT_Glyph_Metrics* metrics = &glyph->root.metrics; - - - /* copy the _unscaled_ advance width */ - metrics->horiAdvance = decoder.builder.advance.x; - - /* make up vertical metrics */ - metrics->vertBearingX = 0; - metrics->vertBearingY = 0; - metrics->vertAdvance = 0; - - glyph->root.format = ft_glyph_format_outline; - - glyph->root.outline.flags &= ft_outline_owner; - if ( size && size->root.metrics.y_ppem < 24 ) - glyph->root.outline.flags |= ft_outline_high_precision; - - glyph->root.outline.flags |= ft_outline_reverse_fill; - -#if 0 - glyph->root.outline.second_pass = TRUE; - glyph->root.outline.high_precision = size->root.metrics.y_ppem < 24; - glyph->root.outline.dropout_mode = 2; -#endif - - if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) - { - /* scale the outline and the metrics */ - FT_Int n; - FT_Outline* cur = &glyph->root.outline; - FT_Vector* vec = cur->points; - FT_Fixed x_scale = glyph->x_scale; - FT_Fixed y_scale = glyph->y_scale; - - - /* First of all, scale the points */ - for ( n = cur->n_points; n > 0; n--, vec++ ) - { - vec->x = FT_MulFix( vec->x, x_scale ); - vec->y = FT_MulFix( vec->y, y_scale ); - } - - FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - - /* Then scale the metrics */ - metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); - metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); - - metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); - metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); - } - - /* apply the font matrix */ - FT_Outline_Transform( &glyph->root.outline, &decoder.font_matrix ); - - /* compute the other metrics */ - FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); - - /* grid fit the bounding box if necessary */ - if ( hinting ) - { - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax + 63 ) & -64; - cbox.yMax = ( cbox.yMax + 63 ) & -64; - } - - metrics->width = cbox.xMax - cbox.xMin; - metrics->height = cbox.yMax - cbox.yMin; - - metrics->horiBearingX = cbox.xMin; - metrics->horiBearingY = cbox.yMax; - } - } - - return error; - } - - -/* END */ diff --git a/src/freetype/cid/cidgload.h b/src/freetype/cid/cidgload.h deleted file mode 100644 index 5f3913d527..0000000000 --- a/src/freetype/cid/cidgload.h +++ /dev/null @@ -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 - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Builder */ - /* */ - /* */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cid/cidload.c b/src/freetype/cid/cidload.c deleted file mode 100644 index 1f7c7aea01..0000000000 --- a/src/freetype/cid/cidload.c +++ /dev/null @@ -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 -#include -#include - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "cidload.h" - -#else - -#include - -#endif - - -#include -#include /* 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 - -#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 */ diff --git a/src/freetype/cid/cidload.h b/src/freetype/cid/cidload.h deleted file mode 100644 index 7495da0dc1..0000000000 --- a/src/freetype/cid/cidload.h +++ /dev/null @@ -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 - - -#ifdef FT_FLAT_COMPILE - -#include "cidparse.h" - -#else - -#include - -#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 */ diff --git a/src/freetype/cid/cidobjs.c b/src/freetype/cid/cidobjs.c deleted file mode 100644 index a75567b6bf..0000000000 --- a/src/freetype/cid/cidobjs.c +++ /dev/null @@ -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 -#include - - -#ifdef FT_FLAT_COMPILE - -#include "cidgload.h" -#include "cidload.h" - -#else - -#include -#include - -#endif - - -#include - - - /*************************************************************************/ - /* */ - /* 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 */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Done_Face */ - /* */ - /* */ - /* Finalizes a given face object. */ - /* */ - /* */ - /* 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; - } - } - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Init_Face */ - /* */ - /* */ - /* Initializes a given CID face object. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* face :: The newly built face object. */ - /* */ - /* */ - /* 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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Init_Driver */ - /* */ - /* */ - /* Initializes a given CID driver object. */ - /* */ - /* */ - /* driver :: A handle to the target driver object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - LOCAL_FUNC - FT_Error CID_Init_Driver( CID_Driver driver ) - { - FT_UNUSED( driver ); - - return T1_Err_Ok; - } - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Done_Driver */ - /* */ - /* */ - /* Finalizes a given CID driver. */ - /* */ - /* */ - /* driver :: A handle to the target CID driver. */ - /* */ - LOCAL_DEF - void CID_Done_Driver( CID_Driver driver ) - { - FT_UNUSED( driver ); - } - - -/* END */ diff --git a/src/freetype/cid/cidobjs.h b/src/freetype/cid/cidobjs.h deleted file mode 100644 index c28c59be25..0000000000 --- a/src/freetype/cid/cidobjs.h +++ /dev/null @@ -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 -#include -#include -#include - - -#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; - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Driver */ - /* */ - /* */ - /* A handle to a Type 1 driver object. */ - /* */ - typedef struct CID_DriverRec_* CID_Driver; - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Size */ - /* */ - /* */ - /* A handle to a Type 1 size object. */ - /* */ - typedef struct CID_SizeRec_* CID_Size; - - - /*************************************************************************/ - /* */ - /* */ - /* CID_GlyphSlot */ - /* */ - /* */ - /* A handle to a Type 1 glyph slot object. */ - /* */ - typedef struct CID_GlyphSlotRec_* CID_GlyphSlot; - - - /*************************************************************************/ - /* */ - /* */ - /* CID_CharMap */ - /* */ - /* */ - /* A handle to a Type 1 character mapping object. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cid/cidparse.c b/src/freetype/cid/cidparse.c deleted file mode 100644 index 33d3d8af3c..0000000000 --- a/src/freetype/cid/cidparse.c +++ /dev/null @@ -1,1024 +0,0 @@ -/***************************************************************************/ -/* */ -/* cidparse.c */ -/* */ -/* CID-keyed Type1 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 -#include -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "cidparse.h" - -#else - -#include - -#endif - - -#include /* for strncmp() */ - - - /*************************************************************************/ - /* */ - /* 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_cidparse - - -#if 0 - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** IMPLEMENTATION OF CID_TABLE OBJECT *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* CID_New_Table */ - /* */ - /* */ - /* Initializes a CID_Table. */ - /* */ - /* */ - /* table :: The address of the target table. */ - /* */ - /* */ - /* count :: The table size, i.e., the maximal number of elements. */ - /* */ - /* memory :: The memory object to be used for all subsequent */ - /* reallocations. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - LOCAL_FUNC - FT_Error CID_New_Table( CID_Table* table, - FT_Int count, - FT_Memory memory ) - { - FT_Error error; - - - table->memory = memory; - if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) || - ALLOC_ARRAY( table->lengths, count, FT_Byte* ) ) - goto Exit; - - table->max_elems = count; - table->init = 0xDEADBEEFL; - table->num_elems = 0; - table->block = 0; - table->capacity = 0; - table->cursor = 0; - - Exit: - if ( error ) - FREE( table->elements ); - - return error; - } - - - static - void shift_elements( CID_Table* table, - FT_Byte* 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; - } - } - - - static - FT_Error reallocate_t1_table( CID_Table* table, - FT_Int new_size ) - { - FT_Memory memory = table->memory; - FT_Byte* old_base = table->block; - FT_Error error; - - - /* realloc the base block */ - if ( REALLOC( table->block, table->capacity, new_size ) ) - return error; - - table->capacity = new_size; - - /* shift all offsets when needed */ - if ( old_base ) - shift_elements( table, old_base ); - - return T1_Err_Ok; - } - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Add_Table */ - /* */ - /* */ - /* Adds an object to a CID_Table, possibly growing its memory block. */ - /* */ - /* */ - /* table :: The target table. */ - /* */ - /* */ - /* index :: The index of the object in the table. */ - /* */ - /* object :: The address of the object to copy in the memory. */ - /* */ - /* length :: The length in bytes of the source object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. An error is returned if */ - /* reallocation fails. */ - /* */ - LOCAL_FUNC - FT_Error CID_Add_Table( CID_Table* table, - FT_Int index, - void* object, - FT_Int length ) - { - if ( index < 0 || index > table->max_elems ) - { - FT_ERROR(( "CID_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; - } - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Done_Table */ - /* */ - /* */ - /* Finalizes a CID_Table (reallocate it to its current cursor). */ - /* */ - /* */ - /* table :: The target table. */ - /* */ - /* */ - /* 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 CID_Done_Table( CID_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 ) - shift_elements( table, old_base ); - } - - - LOCAL_FUNC - void CID_Release_Table( CID_Table* table ) - { - FT_Memory memory = table->memory; - - - if ( table->init == 0xDEADBEEFL ) - { - FREE( table->block ); - FREE( table->elements ); - FREE( table->lengths ); - table->init = 0; - } - } - -#endif /* 0 */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** INPUT STREAM PARSER *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#define IS_CID_WHITESPACE( c ) ( (c) == ' ' || (c) == '\t' ) -#define IS_CID_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' ) - -#define IS_CID_SPACE( c ) ( IS_CID_WHITESPACE( c ) || IS_CID_LINESPACE( c ) ) - - - LOCAL_FUNC - void CID_Skip_Spaces( CID_Parser* parser ) - { - FT_Byte* cur = parser->cursor; - FT_Byte* limit = parser->limit; - - - while ( cur < limit ) - { - FT_Byte c = *cur; - - - if ( !IS_CID_SPACE( c ) ) - break; - cur++; - } - - parser->cursor = cur; - } - - - LOCAL_FUNC - void CID_ToToken( CID_Parser* parser, - CID_Token_Rec* token ) - { - FT_Byte* cur; - FT_Byte* limit; - FT_Byte starter, ender; - FT_Int embed; - - - token->type = t1_token_none; - token->start = 0; - token->limit = 0; - - /* first of all, skip space */ - CID_Skip_Spaces( parser ); - - cur = parser->cursor; - limit = parser->limit; - - if ( cur < limit ) - { - switch ( *cur ) - { - /************* check for strings ***********************/ - case '(': - token->type = t1_token_string; - ender = ')'; - goto Lookup_Ender; - - /************* check for programs/array ****************/ - case '{': - token->type = t1_token_array; - ender = '}'; - goto Lookup_Ender; - - /************* check for table/array ******************/ - case '[': - token->type = t1_token_array; - ender = ']'; - - Lookup_Ender: - embed = 1; - starter = *cur++; - token->start = cur; - - while ( cur < limit ) - { - if ( *cur == starter ) - embed++; - else if ( *cur == ender ) - { - embed--; - if ( embed <= 0 ) - { - token->limit = cur++; - break; - } - } - cur++; - } - break; - - /* **************** otherwise, it is any token **********/ - default: - token->start = cur++; - token->type = t1_token_any; - while ( cur < limit && !IS_CID_SPACE( *cur ) ) - cur++; - - token->limit = cur; - } - - if ( !token->limit ) - { - token->start = 0; - token->type = t1_token_none; - } - - parser->cursor = cur; - } - } - - - LOCAL_FUNC - void CID_ToTokenArray( CID_Parser* parser, - CID_Token_Rec* tokens, - FT_UInt max_tokens, - FT_Int* pnum_tokens ) - { - CID_Token_Rec master; - - - *pnum_tokens = -1; - - CID_ToToken( parser, &master ); - - if ( master.type == t1_token_array ) - { - FT_Byte* old_cursor = parser->cursor; - FT_Byte* old_limit = parser->limit; - CID_Token_Rec* cur = tokens; - CID_Token_Rec* limit = cur + max_tokens; - - - parser->cursor = master.start; - parser->limit = master.limit; - - while ( parser->cursor < parser->limit ) - { - CID_Token_Rec token; - - - CID_ToToken( parser, &token ); - if ( !token.type ) - break; - - if ( cur < limit ) - *cur = token; - - cur++; - } - - *pnum_tokens = cur - tokens; - - parser->cursor = old_cursor; - parser->limit = old_limit; - } - } - - - static - FT_Long t1_toint( FT_Byte** cursor, - FT_Byte* limit ) - { - FT_Long result = 0; - FT_Byte* cur = *cursor; - FT_Byte c, d; - - - for ( ; cur < limit; cur++ ) - { - c = *cur; - d = (FT_Byte)( c - '0' ); - if ( d < 10 ) - break; - - if ( c == '-' ) - { - cur++; - break; - } - } - - if ( cur < limit ) - { - do - { - d = (FT_Byte)( cur[0] - '0' ); - if ( d >= 10 ) - break; - - result = result * 10 + d; - cur++; - - } while ( cur < limit ); - - if ( c == '-' ) - result = -result; - } - - *cursor = cur; - - return result; - } - - - static - FT_Long t1_tofixed( FT_Byte** cursor, - FT_Byte* limit, - FT_Long power_ten ) - { - FT_Byte* cur = *cursor; - FT_Long num, divider, result; - FT_Int sign = 0; - FT_Byte d; - - - if ( cur >= limit ) - return 0; - - /* first of all, read the integer part */ - result = t1_toint( &cur, limit ) << 16; - num = 0; - divider = 1; - - if ( result < 0 ) - { - sign = 1; - result = -result; - } - - if ( cur >= limit ) - goto Exit; - - /* read decimal part, if any */ - if ( *cur == '.' && cur + 1 < limit ) - { - cur++; - - for (;;) - { - d = (FT_Byte)( *cur - '0' ); - if ( d >= 10 ) - break; - - if ( divider < 10000000L ) - { - num = num * 10 + d; - divider *= 10; - } - - cur++; - if ( cur >= limit ) - break; - } - } - - /* read exponent, if any */ - if ( cur + 1 < limit && ( *cur == 'e' || *cur == 'E' ) ) - { - cur++; - power_ten += t1_toint( &cur, limit ); - } - - Exit: - /* 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; - - *cursor = cur; - - return result; - } - - - static - int t1_tobool( FT_Byte** cursor, - FT_Byte* limit ) - { - FT_Byte* cur = *cursor; - FT_Bool result = 0; - - - /* return 1 if we find a "true", 0 otherwise */ - if ( cur + 3 < limit && - cur[0] == 't' && - cur[1] == 'r' && - cur[2] == 'u' && - cur[3] == 'e' ) - { - result = 1; - cur += 5; - } - else if ( cur + 4 < limit && - cur[0] == 'f' && - cur[1] == 'a' && - cur[2] == 'l' && - cur[3] == 's' && - cur[4] == 'e' ) - { - result = 0; - cur += 6; - } - *cursor = cur; - return result; - } - - - static - FT_Int t1_tocoordarray( FT_Byte** cursor, - FT_Byte* limit, - FT_Int max_coords, - FT_Short* coords ) - { - FT_Byte* cur = *cursor; - FT_Int count = 0; - FT_Byte c, ender; - - - if ( cur >= limit ) - goto Exit; - - /* check for the beginning of an array. */ - /* If not, only one number will be read */ - c = *cur; - ender = 0; - - if ( c == '[' ) - ender = ']'; - - if ( c == '{' ) - ender = '}'; - - if ( ender ) - cur++; - - /* now, read the coordinates */ - for ( ; cur < limit; ) - { - /* skip whitespace in front of data */ - for (;;) - { - c = *cur; - if ( c != ' ' && c != '\t' ) - break; - - cur++; - if ( cur >= limit ) - goto Exit; - } - - if ( count >= max_coords || c == ender ) - break; - - coords[count] = (FT_Short)( t1_tofixed( &cur, limit, 0 ) >> 16 ); - count++; - - if ( !ender ) - break; - } - - Exit: - *cursor = cur; - return count; - } - - - static - FT_Int t1_tofixedarray( FT_Byte** cursor, - FT_Byte* limit, - FT_Int max_values, - FT_Fixed* values, - FT_Int power_ten ) - { - FT_Byte* cur = *cursor; - FT_Int count = 0; - FT_Byte c, ender; - - - if ( cur >= limit ) - goto Exit; - - /* check for the beginning of an array. */ - /* If not, only one number will be read */ - c = *cur; - ender = 0; - - if ( c == '[' ) - ender = ']'; - - if ( c == '{' ) - ender = '}'; - - if ( ender ) - cur++; - - /* now, read the values */ - for ( ; cur < limit; ) - { - /* skip whitespace in front of data */ - for (;;) - { - c = *cur; - if ( c != ' ' && c != '\t' ) - break; - - cur++; - if ( cur >= limit ) - goto Exit; - } - - if ( count >= max_values || c == ender ) - break; - - values[count] = t1_tofixed( &cur, limit, power_ten ); - count++; - - if ( !ender ) - break; - } - - Exit: - *cursor = cur; - - return count; - } - - - /* Loads a simple field (i.e. non-table) into the current */ - /* list of objects */ - LOCAL_FUNC - FT_Error CID_Load_Field( CID_Parser* parser, - const CID_Field_Rec* field, - void* object ) - { - CID_Token_Rec token; - FT_Byte* cur; - FT_Byte* limit; - FT_UInt count; - FT_UInt index; - FT_Error error; - - - CID_ToToken( parser, &token ); - if ( !token.type ) - goto Fail; - - count = 1; - index = 0; - cur = token.start; - limit = token.limit; - - { - FT_Byte* q = (FT_Byte*)object + field->offset; - FT_Long val; - FT_String* string; - - - switch ( field->type ) - { - case t1_field_bool: - val = t1_tobool( &cur, limit ); - goto Store_Integer; - - case t1_field_fixed: - val = t1_tofixed( &cur, limit, 0 ); - goto Store_Integer; - - case t1_field_integer: - val = t1_toint( &cur, limit ); - - Store_Integer: - switch ( field->size ) - { - case 1: - *(FT_Byte*)q = (FT_Byte)val; - break; - - case 2: - *(FT_UShort*)q = (FT_UShort)val; - break; - - case 4: - *(FT_Int32*)q = (FT_Int)val; - break; - - default: /* for 64-bit systems */ - *(FT_Long*)q = val; - } - break; - - case t1_field_string: - { - FT_Memory memory = parser->memory; - FT_UInt len = limit-cur; - - - if ( ALLOC( string, len + 1 ) ) - goto Exit; - - MEM_Copy( string, cur, len ); - string[len] = 0; - - *(FT_String**)q = string; - } - break; - - default: - /* an error occurred */ - goto Fail; - } - } - - error = 0; - - Exit: - return error; - - Fail: - error = T1_Err_Invalid_File_Format; - goto Exit; - } - - -#define T1_MAX_TABLE_ELEMENTS 32 - - - LOCAL_FUNC - FT_Error CID_Load_Field_Table( CID_Parser* parser, - const CID_Field_Rec* field, - void* object ) - { - CID_Token_Rec elements[T1_MAX_TABLE_ELEMENTS]; - CID_Token_Rec* token; - FT_Int num_elements; - FT_Error error = 0; - FT_Byte* old_cursor; - FT_Byte* old_limit; - CID_Field_Rec fieldrec = *(CID_Field_Rec*)field; - - - fieldrec.type = t1_field_integer; - if ( field->type == t1_field_fixed_array ) - fieldrec.type = t1_field_fixed; - - CID_ToTokenArray( parser, elements, 32, &num_elements ); - if ( num_elements < 0 ) - goto Fail; - - if ( num_elements > T1_MAX_TABLE_ELEMENTS ) - num_elements = T1_MAX_TABLE_ELEMENTS; - - old_cursor = parser->cursor; - old_limit = parser->limit; - - /* we store the elements count */ - if ( field->count_offset ) - *(FT_Byte*)( (FT_Byte*)object + field->count_offset ) = num_elements; - - /* we now load each element, adjusting the field.offset on each one */ - token = elements; - for ( ; num_elements > 0; num_elements--, token++ ) - { - parser->cursor = token->start; - parser->limit = token->limit; - CID_Load_Field( parser, &fieldrec, object ); - fieldrec.offset += fieldrec.size; - } - - parser->cursor = old_cursor; - parser->limit = old_limit; - - Exit: - return error; - - Fail: - error = T1_Err_Invalid_File_Format; - goto Exit; - } - - - LOCAL_FUNC - FT_Long CID_ToInt( CID_Parser* parser ) - { - return t1_toint( &parser->cursor, parser->limit ); - } - - - LOCAL_FUNC - FT_Int CID_ToCoordArray( CID_Parser* parser, - FT_Int max_coords, - FT_Short* coords ) - { - return t1_tocoordarray( &parser->cursor, parser->limit, - max_coords, coords ); - } - - - LOCAL_FUNC - FT_Int CID_ToFixedArray( CID_Parser* parser, - FT_Int max_values, - FT_Fixed* values, - FT_Int power_ten ) - { - return t1_tofixedarray( &parser->cursor, parser->limit, - max_values, values, power_ten ); - } - - -#if 0 - - /* return the value of an hexadecimal digit */ - static - int hexa_value( char c ) - { - unsigned int d; - - - d = (unsigned int)( c - '0' ); - if ( d <= 9 ) - return (int)d; - - d = (unsigned int)( c - 'a' ); - if ( d <= 5 ) - return (int)( d + 10 ); - - d = (unsigned int)( c - 'A' ); - if ( d <= 5 ) - return (int)( d + 10 ); - - return -1; - } - -#endif /* 0 */ - - - LOCAL_FUNC - FT_Error CID_New_Parser( CID_Parser* parser, - FT_Stream stream, - FT_Memory memory ) - { - FT_Error error; - FT_ULong base_offset, offset, ps_len; - FT_Byte buffer[256 + 10]; - FT_Int buff_len; - - - MEM_Set( parser, 0, sizeof ( *parser ) ); - parser->stream = stream; - parser->memory = memory; - - base_offset = FILE_Pos(); - - /* first of all, check the font format in the header */ - if ( ACCESS_Frame( 31 ) ) - goto Exit; - - if ( strncmp( (char *)stream->cursor, - "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) ) - { - FT_TRACE2(( "[not a valid CID-keyed font]\n" )); - error = FT_Err_Unknown_File_Format; - } - - FORGET_Frame(); - if ( error ) - goto Exit; - - /* now, read the rest of the file, until we find a `StartData' */ - buff_len = 256; - for (;;) - { - FT_Byte *p, *limit = buffer + 256; - - /* fill input buffer */ - buff_len -= 256; - if ( buff_len > 0 ) - MEM_Move( buffer, limit, buff_len ); - - if ( FILE_Read( buffer, 256 + 10 - buff_len ) ) - goto Exit; - - buff_len = 256 + 10; - - /* look for `StartData' */ - for ( p = buffer; p < limit; p++ ) - { - if ( p[0] == 'S' && strncmp( (char*)p, "StartData", 9 ) == 0 ) - { - /* save offset of binary data after `StartData' */ - offset = FILE_Pos() - ( limit - p ) + 10; - goto Found; - } - } - } - - Found: - /* we have found the start of the binary data. We will now */ - /* rewind and extract the frame of corresponding to the Postscript */ - /* section */ - - ps_len = offset - base_offset; - if ( FILE_Seek( base_offset ) || - EXTRACT_Frame( ps_len, parser->postscript ) ) - goto Exit; - - parser->data_offset = offset; - parser->postscript_len = ps_len; - parser->cursor = parser->postscript; - parser->limit = parser->cursor + ps_len; - parser->num_dict = -1; - - Exit: - return error; - } - - - LOCAL_FUNC - void CID_Done_Parser( CID_Parser* parser ) - { - /* always free the private dictionary */ - if ( parser->postscript ) - { - FT_Stream stream = parser->stream; - - - RELEASE_Frame( parser->postscript ); - } - } - - -/* END */ diff --git a/src/freetype/cid/cidparse.h b/src/freetype/cid/cidparse.h deleted file mode 100644 index 7a8211ad30..0000000000 --- a/src/freetype/cid/cidparse.h +++ /dev/null @@ -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 - - -#ifdef __cplusplus - extern "C" { -#endif - - -#if 0 - - /*************************************************************************/ - /* */ - /* */ - /* CID_Table */ - /* */ - /* */ - /* A CID_Table is a simple object used to store an array of objects */ - /* in a single memory block. */ - /* */ - /* */ - /* 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 */ - - - /*************************************************************************/ - /* */ - /* */ - /* CID_Parser */ - /* */ - /* */ - /* A CID_Parser is an object used to parse a Type 1 fonts very */ - /* quickly. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cid/cidriver.c b/src/freetype/cid/cidriver.c deleted file mode 100644 index f1c6b6a012..0000000000 --- a/src/freetype/cid/cidriver.c +++ /dev/null @@ -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 -#include - -#endif - - -#include -#include -#include - -#include /* 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 */ - - - /*************************************************************************/ - /* */ - /* */ - /* Cid_Get_Char_Index */ - /* */ - /* */ - /* Uses a charmap to return a given character code's glyph index. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* */ - /* 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 - - - /*************************************************************************/ - /* */ - /* */ - /* getDriverClass */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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 */ diff --git a/src/freetype/cid/cidriver.h b/src/freetype/cid/cidriver.h deleted file mode 100644 index a9674eed44..0000000000 --- a/src/freetype/cid/cidriver.h +++ /dev/null @@ -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 - - FT_EXPORT_VAR( const FT_Driver_Class ) t1cid_driver_class; - -#endif /* CIDRIVER_H */ - - -/* END */ diff --git a/src/freetype/cid/cidtokens.h b/src/freetype/cid/cidtokens.h deleted file mode 100644 index a916cea322..0000000000 --- a/src/freetype/cid/cidtokens.h +++ /dev/null @@ -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 */ diff --git a/src/freetype/cid/module.mk b/src/freetype/cid/module.mk deleted file mode 100644 index 3d13c9ca1d..0000000000 --- a/src/freetype/cid/module.mk +++ /dev/null @@ -1,6 +0,0 @@ -make_module_list: add_type1cid_driver - -add_type1cid_driver: - $(OPEN_DRIVER)t1cid_driver_class$(CLOSE_DRIVER) - $(ECHO_DRIVER)cid $(ECHO_DRIVER_DESC)Postscript CID-keyed fonts, no known extension$(ECHO_DRIVER_DONE) -# EOF diff --git a/src/freetype/cid/rules.mk b/src/freetype/cid/rules.mk deleted file mode 100644 index cbaaec7685..0000000000 --- a/src/freetype/cid/rules.mk +++ /dev/null @@ -1,69 +0,0 @@ -# -# FreeType 2 CID driver configuration rules -# - - -# Copyright 1996-2000 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - - -# CID driver directory -# -CID_DIR := $(SRC_)cid -CID_DIR_ := $(CID_DIR)$(SEP) - - -CID_COMPILE := $(FT_COMPILE) - - -# CID driver sources (i.e., C files) -# -CID_DRV_SRC := $(CID_DIR_)cidparse.c \ - $(CID_DIR_)cidload.c \ - $(CID_DIR_)cidriver.c \ - $(CID_DIR_)cidgload.c \ - $(CID_DIR_)cidobjs.c - -# CID driver headers -# -CID_DRV_H := $(CID_DRV_SRC:%.c=%.h) \ - $(CID_DIR_)cidtokens.h - - -# CID driver object(s) -# -# CID_DRV_OBJ_M is used during `multi' builds -# CID_DRV_OBJ_S is used during `single' builds -# -CID_DRV_OBJ_M := $(CID_DRV_SRC:$(CID_DIR_)%.c=$(OBJ_)%.$O) -CID_DRV_OBJ_S := $(OBJ_)type1cid.$O - -# CID driver source file for single build -# -CID_DRV_SRC_S := $(CID_DIR_)type1cid.c - - -# CID driver - single object -# -$(CID_DRV_OBJ_S): $(CID_DRV_SRC_S) $(CID_DRV_SRC) $(FREETYPE_H) $(CID_DRV_H) - $(CID_COMPILE) $T$@ $(CID_DRV_SRC_S) - - -# CID driver - multiple objects -# -$(OBJ_)%.$O: $(CID_DIR_)%.c $(FREETYPE_H) $(CID_DRV_H) - $(CID_COMPILE) $T$@ $< - - -# update main driver object lists -# -DRV_OBJS_S += $(CID_DRV_OBJ_S) -DRV_OBJS_M += $(CID_DRV_OBJ_M) - -# EOF diff --git a/src/freetype/cid/type1cid.c b/src/freetype/cid/type1cid.c deleted file mode 100644 index d26aee26f4..0000000000 --- a/src/freetype/cid/type1cid.c +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************/ -/* */ -/* cff.c */ -/* */ -/* FreeType OpenType driver component (body only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#define FT_MAKE_OPTION_SINGLE_OBJECT - -#ifdef FT_FLAT_COMPILE - -#include "cidparse.c" -#include "cidload.c" -#include "cidobjs.c" -#include "cidriver.c" -#include "cidgload.c" - -#else - -#include -#include -#include -#include -#include - -#endif - - -/* END */ diff --git a/src/freetype/freetype/config/ftconfig.h b/src/freetype/freetype/config/ftconfig.h deleted file mode 100644 index 338e22cb2a..0000000000 --- a/src/freetype/freetype/config/ftconfig.h +++ /dev/null @@ -1,187 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftconfig.h */ -/* */ -/* ANSI-specific configuration file (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This header file contains a number of macro definitions that are used */ - /* by the rest of the engine. Most of the macros here are automatically */ - /* determined at compile time, and you should not need to change it to */ - /* port FreeType, except to compile the library with a non-ANSI */ - /* compiler. */ - /* */ - /* Note however that if some specific modifications are needed, we */ - /* advise you to place a modified copy in your build directory. */ - /* */ - /* The build directory is usually `freetype/builds/', and */ - /* contains system-specific files that are always included first when */ - /* building the library. */ - /* */ - /* This ANSI version should stay in `include/freetype/config'. */ - /* */ - /*************************************************************************/ - - -#ifndef FTCONFIG_H -#define FTCONFIG_H - - - /* Include the header file containing all developer build options */ -#include - - - /*************************************************************************/ - /* */ - /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ - /* */ - /* These macros can be toggled to suit a specific system. The current */ - /* ones are defaults used to compile FreeType in an ANSI C environment */ - /* (16bit compilers are also supported). Copy this file to your own */ - /* `freetype/builds/' directory, and edit it to port the engine. */ - /* */ - /*************************************************************************/ - - - /* We use values to know the sizes of the types. */ -#include - - /* The number of bytes in an `int' type. */ -#if UINT_MAX == 0xFFFFFFFF -#define FT_SIZEOF_INT 4 -#elif UINT_MAX == 0xFFFF -#define FT_SIZEOF_INT 2 -#elif UINT_MAX > 0xFFFFFFFF && UINT_MAX == 0xFFFFFFFFFFFFFFFF -#define FT_SIZEOF_INT 8 -#else -#error "Unsupported number of bytes in `int' type!" -#endif - - /* The number of bytes in a `long' type. */ -#if ULONG_MAX == 0xFFFFFFFF -#define FT_SIZEOF_LONG 4 -#elif ULONG_MAX > 0xFFFFFFFF && ULONG_MAX == 0xFFFFFFFFFFFFFFFF -#define FT_SIZEOF_LONG 8 -#else -#error "Unsupported number of bytes in `long' type!" -#endif - - - /* Preferred alignment of data */ -#define FT_ALIGNMENT 8 - - - /* UNUSED is a macro used to indicate that a given parameter is not used */ - /* -- this is only used to get rid of unpleasant compiler warnings */ -#ifndef FT_UNUSED -#define FT_UNUSED( arg ) ( (arg) = (arg) ) -#endif - - - /*************************************************************************/ - /* */ - /* AUTOMATIC CONFIGURATION MACROS */ - /* */ - /* These macros are computed from the ones defined above. Don't touch */ - /* their definition, unless you know precisely what you are doing. No */ - /* porter should need to mess with them. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* IntN types */ - /* */ - /* Used to guarantee the size of some specific integers. */ - /* */ - typedef signed short FT_Int16; - typedef unsigned short FT_UInt16; - -#if FT_SIZEOF_INT == 4 - - typedef signed int FT_Int32; - typedef unsigned int FT_UInt32; - -#elif FT_SIZEOF_LONG == 4 - - typedef signed long FT_Int32; - typedef unsigned long FT_UInt32; - -#else -#error "no 32bit type found -- please check your configuration files" -#endif - -#if FT_SIZEOF_LONG == 8 - - /* FT_LONG64 must be defined if a 64-bit type is available */ -#define FT_LONG64 -#define FT_INT64 long - -#else - - - /*************************************************************************/ - /* */ - /* Many compilers provide the non-ANSI `long long' 64-bit type. You can */ - /* activate it by defining the FTCALC_USE_LONG_LONG macro in */ - /* `ftoption.h'. */ - /* */ - /* Note that this will produce many -ansi warnings during library */ - /* compilation, and that in many cases, the generated code will be */ - /* neither smaller nor faster! */ - /* */ -#ifdef FTCALC_USE_LONG_LONG - -#define FT_LONG64 -#define FT_INT64 long long - -#endif /* FTCALC_USE_LONG_LONG */ -#endif /* FT_SIZEOF_LONG == 8 */ - - -#ifdef FT_MAKE_OPTION_SINGLE_OBJECT -#define LOCAL_DEF static -#define LOCAL_FUNC static -#else -#define LOCAL_DEF extern -#define LOCAL_FUNC /* nothing */ -#endif - -#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT -#define BASE_DEF( x ) static x -#define BASE_FUNC( x ) static x -#else -#define BASE_DEF( x ) extern x -#define BASE_FUNC( x ) extern x -#endif - -#ifndef FT_EXPORT_DEF -#define FT_EXPORT_DEF( x ) extern x -#endif - -#ifndef FT_EXPORT_FUNC -#define FT_EXPORT_FUNC( x ) extern x -#endif - -#ifndef FT_EXPORT_VAR -#define FT_EXPORT_VAR( x ) extern x -#endif - -#endif /* FTCONFIG_H */ - - -/* END */ diff --git a/src/freetype/freetype/config/ftmodule.h b/src/freetype/freetype/config/ftmodule.h deleted file mode 100644 index 50cc46b5c6..0000000000 --- a/src/freetype/freetype/config/ftmodule.h +++ /dev/null @@ -1,10 +0,0 @@ -FT_USE_MODULE(autohint_module_class) -FT_USE_MODULE(cff_driver_class) -FT_USE_MODULE(t1cid_driver_class) -FT_USE_MODULE(psnames_module_class) -FT_USE_MODULE(ft_raster1_renderer_class) -FT_USE_MODULE(sfnt_module_class) -FT_USE_MODULE(ft_smooth_renderer_class) -FT_USE_MODULE(tt_driver_class) -FT_USE_MODULE(t1_driver_class) -FT_USE_MODULE(winfnt_driver_class) diff --git a/src/freetype/freetype/config/ftoption.h b/src/freetype/freetype/config/ftoption.h deleted file mode 100644 index a7e1f406a2..0000000000 --- a/src/freetype/freetype/config/ftoption.h +++ /dev/null @@ -1,395 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftoption.h */ -/* */ -/* User-selectable configuration macros (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTOPTION_H -#define FTOPTION_H - - - /*************************************************************************/ - /* */ - /* USER-SELECTABLE CONFIGURATION MACROS */ - /* */ - /* These macros can be toggled by developers to enable or disable */ - /* certain aspects of FreeType. This is a default file, where all major */ - /* options are enabled. */ - /* */ - /* Note that if some modifications are required for your build, we */ - /* advise you to put a modified copy of this file in your build */ - /* directory, rather than modifying it in-place. */ - /* */ - /* The build directory is normally `freetype/builds/' and */ - /* contains build or system-specific files that are included in */ - /* priority when building the library. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Convenience functions support */ - /* */ - /* Some functions of the FreeType 2 API are provided as a convenience */ - /* for client applications and developers. However, they are not */ - /* required to build and run the library itself. */ - /* */ - /* By defining this configuration macro, you'll disable the */ - /* compilation of these functions at build time. This can be useful */ - /* to reduce the library's code size when you don't need any of */ - /* these functions. */ - /* */ - /* All convenience functions are declared as such in their */ - /* documentation. */ - /* */ -#undef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS - - - /*************************************************************************/ - /* */ - /* Alternate Glyph Image Format support */ - /* */ - /* By default, the glyph images returned by the FreeType glyph loader */ - /* can either be a pixmap or a vectorial outline defined through */ - /* Bezier control points. When defining the following configuration */ - /* macro, some font drivers will be able to register alternate */ - /* glyph image formats. */ - /* */ - /* Unset this macro if you are sure that you will never use a font */ - /* driver with an alternate glyph format; this will reduce the size of */ - /* the base layer code. */ - /* */ - /* Note that a few Type 1 fonts, as well as Windows `vector' fonts */ - /* use a vector `plotter' format that isn't supported when this */ - /* macro is undefined. */ - /* */ -#define FT_CONFIG_OPTION_ALTERNATE_GLYPH_FORMATS - - - /*************************************************************************/ - /* */ - /* Glyph Postscript Names handling */ - /* */ - /* By default, FreeType 2 is compiled with the `PSNames' module. This */ - /* This module is in charge of converting a glyph name string into a */ - /* Unicode value, or return a Macintosh standard glyph name for the */ - /* use with the TrueType `post' table. */ - /* */ - /* Undefine this macro if you do not want `PSNames' compiled in your */ - /* build of FreeType. This has the following effects: */ - /* */ - /* - The TrueType driver will provide its own set of glyph names, */ - /* if you build it to support postscript names in the TrueType */ - /* `post' table. */ - /* */ - /* - The Type 1 driver will not be able to synthetize a Unicode */ - /* charmap out of the glyphs found in the fonts. */ - /* */ - /* You would normally undefine this configuration macro when building */ - /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ - /* */ -#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES - - - /*************************************************************************/ - /* */ - /* Postscript Names to Unicode Values support */ - /* */ - /* By default, FreeType 2 is built with the `PSNames' module compiled */ - /* in. Among other things, the module is used to convert a glyph name */ - /* into a Unicode value. This is especially useful in order to */ - /* synthetize on the fly a Unicode charmap from the CFF/Type 1 driver */ - /* through a big table named the `Adobe Glyph List' (AGL). */ - /* */ - /* Undefine this macro if you do not want the Adobe Glyph List */ - /* compiled in your `PSNames' module. The Type 1 driver will not be */ - /* able to synthetize a Unicode charmap out of the glyphs found in the */ - /* fonts. */ - /* */ -#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - - - /*************************************************************************/ - /* */ - /* Many compilers provide the non-ANSI `long long' 64-bit type. You can */ - /* activate it by defining the FTCALC_USE_LONG_LONG macro. Note that */ - /* this will produce many -ansi warnings during library compilation, and */ - /* that in many cases the generated code will not be smaller or faster! */ - /* */ -#undef FTCALC_USE_LONG_LONG - - - /*************************************************************************/ - /* */ - /* DLL export compilation */ - /* */ - /* When compiling FreeType as a DLL, some systems/compilers need a */ - /* special keyword in front OR after the return type of function */ - /* declarations. */ - /* */ - /* Two macros are used within the FreeType source code to define */ - /* exported library functions: FT_EXPORT_DEF and FT_EXPORT_FUNC. */ - /* */ - /* FT_EXPORT_DEF( return_type ) */ - /* */ - /* is used in a function declaration, as in */ - /* */ - /* FT_EXPORT_DEF( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ); */ - /* */ - /* */ - /* FT_EXPORT_FUNC( return_type ) */ - /* */ - /* is used in a function definition, as in */ - /* */ - /* FT_EXPORT_FUNC( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ) */ - /* { */ - /* ... some code ... */ - /* return FT_Err_Ok; */ - /* } */ - /* */ - /* You can provide your own implementation of FT_EXPORT_DEF and */ - /* FT_EXPORT_FUNC here if you want. If you leave them undefined, they */ - /* will be later automatically defined as `extern return_type' to */ - /* allow normal compilation. */ - /* */ -#undef FT_EXPORT_DEF -#undef FT_EXPORT_FUNC - - - /*************************************************************************/ - /* */ - /* Debug level */ - /* */ - /* FreeType can be compiled in debug or trace mode. In debug mode, */ - /* errors are reported through the `ftdebug' component. In trace */ - /* mode, additional messages are sent to the standard output during */ - /* execution. */ - /* */ - /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ - /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ - /* */ - /* Don't define any of these macros to compile in `release' mode! */ - /* */ -#define FT_DEBUG_LEVEL_ERROR -#define FT_DEBUG_LEVEL_TRACE - - - /*************************************************************************/ - /* */ - /* Computation Algorithms */ - /* */ - /* Used for debugging, this configuration macro should disappear */ - /* soon. */ - /* */ -#define FT_CONFIG_OPTION_OLD_CALCS - - - /*************************************************************************/ - /* */ - /* The size in bytes of the render pool used by the scan-line converter */ - /* to do all of its work. */ - /* */ - /* This must be greater than 4kByte. */ - /* */ -#define FT_RENDER_POOL_SIZE 16384 - - - /*************************************************************************/ - /* */ - /* FT_MAX_MODULES */ - /* */ - /* The maximum number of modules that can be registered in a single */ - /* FreeType library object. 16 is the default. */ - /* */ -#define FT_MAX_MODULES 16 - - - /*************************************************************************/ - /* */ - /* FT_MAX_EXTENSIONS */ - /* */ - /* The maximum number of extensions that can be registered in a single */ - /* font driver. 8 is the default. */ - /* */ - /* If you don't know what this means, you certainly do not need to */ - /* change this value. */ - /* */ -#define FT_MAX_EXTENSIONS 8 - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** S F N T D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ - /* embedded bitmaps in all formats using the SFNT module (namely */ - /* TrueType & OpenType). */ - /* */ -#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ - /* load and enumerate the glyph Postscript names in a TrueType or */ - /* OpenType file. */ - /* */ - /* Note that when you do not compile the `PSNames' module by undefining */ - /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ - /* contain additional code used to read the PS Names table from a font. */ - /* */ - /* (By default, the module uses `PSNames' to extract glyph names.) */ - /* */ -#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ - /* access the internal name table in a SFNT-based format like TrueType */ - /* or OpenType. The name table contains various strings used to */ - /* describe the font, like family name, copyright, version, etc. It */ - /* does not contain any glyph name though. */ - /* */ - /* Accessing SFNT names is done through the functions declared in */ - /* `freetype/ftnames.h'. */ - /* */ -#define TT_CONFIG_OPTION_SFNT_NAMES - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ - /* a bytecode interpreter in the TrueType driver. Note that there are */ - /* important patent issues related to the use of the interpreter. */ - /* */ - /* By undefining this, you will only compile the code necessary to load */ - /* TrueType glyphs without hinting. */ - /* */ -#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_INTERPRETER_SWITCH to compile the TrueType */ - /* bytecode interpreter with a huge switch statement, rather than a call */ - /* table. This results in smaller and faster code for a number of */ - /* architectures. */ - /* */ - /* Note however that on some compiler/processor combinations, undefining */ - /* this macro will generate faster, though larger, code. */ - /* */ -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* T1_MAX_STACK_DEPTH is the maximal depth of the token stack used by */ - /* the Type 1 parser (see t1load.c). A minimum of 16 is required. */ - /* */ -#define T1_MAX_STACK_DEPTH 16 - - - /*************************************************************************/ - /* */ - /* T1_MAX_DICT_DEPTH is the maximal depth of nest dictionaries and */ - /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ - /* required. */ - /* */ -#define T1_MAX_DICT_DEPTH 5 - - - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ -#define T1_MAX_SUBRS_CALLS 8 - - - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. */ - /* */ -#define T1_MAX_CHARSTRINGS_OPERANDS 32 - - - /*************************************************************************/ - /* */ - /* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */ - /* driver with no hinter. This can be useful to debug the parser. */ - /* */ -#undef T1_CONFIG_OPTION_DISABLE_HINTER - - - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ - /* files into an existing face. Note that if set, the T1 driver will be */ - /* unable to produce kerning distances. */ - /* */ -#undef T1_CONFIG_OPTION_NO_AFM - - - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of the Multiple Masters font support in the Type 1 */ - /* driver. */ - /* */ -#undef T1_CONFIG_OPTION_NO_MM_SUPPORT - - -#endif /* FTOPTION_H */ - - -/* END */ diff --git a/src/freetype/freetype/freetype.h b/src/freetype/freetype/freetype.h deleted file mode 100644 index 29316c67ba..0000000000 --- a/src/freetype/freetype/freetype.h +++ /dev/null @@ -1,2286 +0,0 @@ -/***************************************************************************/ -/* */ -/* freetype.h */ -/* */ -/* FreeType high-level API and common types (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FREETYPE_H -#define FREETYPE_H - - - /*************************************************************************/ - /* */ - /* The `raster' component duplicates some of the declarations in */ - /* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */ - /* */ -#define _FREETYPE_ - - - /*************************************************************************/ - /* */ - /* The FREETYPE_MAJOR and FREETYPE_MINOR macros are used to version the */ - /* new FreeType design, which is able to host several kinds of font */ - /* drivers. It starts at 2.0. */ - /* */ -#define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 0 - - -#include /* read configuration information */ -#include -#include - - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* B A S I C T Y P E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Metrics */ - /* */ - /* */ - /* A structure used to model the metrics of a single glyph. Note */ - /* that values are expressed in 26.6 fractional pixel format or in */ - /* font units, depending on context. */ - /* */ - /* */ - /* width :: The glyph's width. */ - /* */ - /* height :: The glyph's height. */ - /* */ - /* horiBearingX :: Horizontal left side bearing. */ - /* */ - /* horiBearingY :: Horizontal top side bearing. */ - /* */ - /* horiAdvance :: Horizontal advance width. */ - /* */ - /* vertBearingX :: Vertical left side bearing. */ - /* */ - /* vertBearingY :: Vertical top side bearing. */ - /* */ - /* vertAdvance :: Vertical advance height. */ - /* */ - typedef struct FT_Glyph_Metrics_ - { - FT_Pos width; /* glyph width */ - FT_Pos height; /* glyph height */ - - FT_Pos horiBearingX; /* left side bearing in horizontal layouts */ - FT_Pos horiBearingY; /* top side bearing in horizontal layouts */ - FT_Pos horiAdvance; /* advance width for horizontal layout */ - - FT_Pos vertBearingX; /* left side bearing in vertical layouts */ - FT_Pos vertBearingY; /* top side bearing in vertical layouts */ - FT_Pos vertAdvance; /* advance height for vertical layout */ - - } FT_Glyph_Metrics; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Generic_Finalizer */ - /* */ - /* */ - /* Describes a function used to destroy the `client' data of any */ - /* FreeType object. See the description of the FT_Generic type for */ - /* details of usage. */ - /* */ - /* */ - /* The address of the FreeType object which is under finalization. */ - /* Its client data is accessed through its `generic' field. */ - /* */ - typedef void (*FT_Generic_Finalizer)(void* object); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Generic */ - /* */ - /* */ - /* Client applications often need to associate their own data to a */ - /* variety of FreeType core objects. For example, a text layout API */ - /* might want to associate a glyph cache to a given size object. */ - /* */ - /* Most FreeType object contains a `generic' field, of type */ - /* FT_Generic, which usage is left to client applications and font */ - /* servers. */ - /* */ - /* It can be used to store a pointer to client-specific data, as well */ - /* as the address of a `finalizer' function, which will be called by */ - /* FreeType when the object is destroyed (for example, the previous */ - /* client example would put the address of the glyph cache destructor */ - /* in the `finalizer' field). */ - /* */ - /* */ - /* data :: A typeless pointer to any client-specified data. This */ - /* field is completely ignored by the FreeType library. */ - /* */ - /* finalizer :: A pointer to a `generic finalizer' function, which */ - /* will be called when the object is destroyed. If this */ - /* field is set to NULL, no code will be called. */ - /* */ - typedef struct FT_Generic_ - { - void* data; - FT_Generic_Finalizer finalizer; - - } FT_Generic; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Bitmap_Size */ - /* */ - /* */ - /* An extremely simple structure used to model the size of a bitmap */ - /* strike (i.e., a bitmap instance of the font for a given */ - /* resolution) in a fixed-size font face. This is used for the */ - /* `available_sizes' field of the FT_Face_Properties structure. */ - /* */ - /* */ - /* height :: The character height in pixels. */ - /* */ - /* width :: The character width in pixels. */ - /* */ - typedef struct FT_Bitmap_Size_ - { - FT_Short height; - FT_Short width; - - } FT_Bitmap_Size; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* O B J E C T C L A S S E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* */ - /* FT_Library */ - /* */ - /* */ - /* A handle to a FreeType library instance. Each `library' is */ - /* completely independent from the others; it is the `root' of a set */ - /* of objects like fonts, faces, sizes, etc. */ - /* */ - /* It also embeds a system object (see FT_System), as well as a */ - /* scan-line converter object (see FT_Raster). */ - /* */ - /* */ - /* Library objects are created through FT_Init_FreeType(). */ - /* */ - typedef struct FT_LibraryRec_ *FT_Library; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Module */ - /* */ - /* */ - /* A handle to a given FreeType module object. Each module can be a */ - /* font driver, a renderer, or anything else that provides services */ - /* to the formers. */ - /* */ - typedef struct FT_ModuleRec_* FT_Module; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Driver */ - /* */ - /* */ - /* A handle to a given FreeType font driver object. Each font driver */ - /* is able to create faces, sizes, glyph slots, and charmaps from the */ - /* resources whose format it supports. */ - /* */ - /* A driver can support either bitmap, graymap, or scalable font */ - /* formats. */ - /* */ - typedef struct FT_DriverRec_* FT_Driver; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Renderer */ - /* */ - /* */ - /* A handle to a given FreeType renderer. A renderer is in charge of */ - /* converting a glyph image to a bitmap, when necessary. Each */ - /* supports a given glyph image format, and one or more target */ - /* surface depths. */ - /* */ - typedef struct FT_RendererRec_* FT_Renderer; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Face */ - /* */ - /* */ - /* A handle to a given driver face object. A face object contains */ - /* all the instance and glyph independent data of a font file */ - /* typeface. */ - /* */ - /* A face object is created from a resource object through the */ - /* new_face() method of a given driver. */ - /* */ - typedef struct FT_FaceRec_* FT_Face; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Size */ - /* */ - /* */ - /* A handle to a given driver size object. Such an object models the */ - /* _resolution_ AND _size_ dependent state of a given driver face */ - /* size. */ - /* */ - /* A size object is always created from a given face object. It is */ - /* discarded automatically by its parent face. */ - /* */ - typedef struct FT_SizeRec_* FT_Size; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_GlyphSlot */ - /* */ - /* */ - /* A handle to a given `glyph slot'. A slot is a container where it */ - /* is possible to load any of the glyphs contained within its parent */ - /* face. */ - /* */ - /* A glyph slot is created from a given face object. It is discarded */ - /* automatically by its parent face. */ - /* */ - typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_CharMap */ - /* */ - /* */ - /* A handle to a given character map. A charmap is used to translate */ - /* character codes in a given encoding into glyph indexes for its */ - /* parent's face. Some font formats may provide several charmaps per */ - /* font. */ - /* */ - /* A charmap is created from a given face object. It is discarded */ - /* automatically by its parent face. */ - /* */ - typedef struct FT_CharMapRec_* FT_CharMap; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Encoding */ - /* */ - /* */ - /* An enumeration used to specify encodings supported by charmaps. */ - /* Used in the FT_Select_CharMap() API function. */ - /* */ - /* */ - /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */ - /* all character codes must be expressed as FT_Longs. */ - /* */ - typedef enum FT_Encoding_ - { - ft_encoding_none = 0, - ft_encoding_symbol = FT_MAKE_TAG( 's', 'y', 'm', 'b' ), - ft_encoding_unicode = FT_MAKE_TAG( 'u', 'n', 'i', 'c' ), - ft_encoding_latin_2 = FT_MAKE_TAG( 'l', 'a', 't', '2' ), - ft_encoding_sjis = FT_MAKE_TAG( 's', 'j', 'i', 's' ), - ft_encoding_gb2312 = FT_MAKE_TAG( 'g', 'b', ' ', ' ' ), - ft_encoding_big5 = FT_MAKE_TAG( 'b', 'i', 'g', '5' ), - ft_encoding_wansung = FT_MAKE_TAG( 'w', 'a', 'n', 's' ), - ft_encoding_johab = FT_MAKE_TAG( 'j', 'o', 'h', 'a' ), - - ft_encoding_adobe_standard = FT_MAKE_TAG( 'A', 'D', 'O', 'B' ), - ft_encoding_adobe_expert = FT_MAKE_TAG( 'A', 'D', 'B', 'E' ), - ft_encoding_adobe_custom = FT_MAKE_TAG( 'A', 'D', 'B', 'C' ), - - ft_encoding_apple_roman = FT_MAKE_TAG( 'a', 'r', 'm', 'n' ) - - /* other encodings might be defined in the future */ - - } FT_Encoding; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_CharMapRec */ - /* */ - /* */ - /* The base charmap class. */ - /* */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* flags :: A set of bit flags used to describe the charmap. */ - /* Each bit indicates that a given encoding is */ - /* supported. */ - /* */ - /* platform_id :: An ID number describing the platform for the */ - /* following encoding ID. This comes directly from */ - /* the TrueType specification and should be emulated */ - /* for other formats. */ - /* */ - /* encoding_id :: A platform specific encoding number. This also */ - /* comes from the TrueType specification and should be */ - /* emulated similarly. */ - /* */ - /* */ - /* We STRONGLY recommmend emulating a Unicode charmap for drivers */ - /* that do not support TrueType or OpenType. */ - /* */ - typedef struct FT_CharMapRec_ - { - FT_Face face; - FT_Encoding encoding; - FT_UShort platform_id; - FT_UShort encoding_id; - - } FT_CharMapRec; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* B A S E O B J E C T C L A S S E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* FreeType base face class */ - /* */ - /* */ - /* FT_FaceRec */ - /* */ - /* */ - /* FreeType root face class structure. A face object models the */ - /* resolution and point-size independent data found in a font file. */ - /* */ - /* */ - /* num_faces :: In the case where the face is located in a */ - /* collection (i.e., a resource which embeds */ - /* several faces), this is the total number of */ - /* faces found in the resource. 1 by default. */ - /* */ - /* face_index :: The index of the face in its resource. */ - /* Usually, this is 0 for all normal font */ - /* formats. It can be more in the case of */ - /* collections (which embed several fonts in a */ - /* single resource/file). */ - /* */ - /* face_flags :: A set of bit flags that give important */ - /* information about the face; see the */ - /* FT_FACE_FLAG_XXX macros for details. */ - /* */ - /* style_flags :: A set of bit flags indicating the style of */ - /* the face (i.e., italic, bold, underline, */ - /* etc). */ - /* */ - /* num_glyphs :: The total number of glyphs in the face. */ - /* */ - /* family_name :: The face's family name. This is an ASCII */ - /* string, usually in English, which describes */ - /* the typeface's family (like `Times New */ - /* Roman', `Bodoni', `Garamond', etc). This */ - /* is a least common denominator used to list */ - /* fonts. Some formats (TrueType & OpenType) */ - /* provide localized and Unicode versions of */ - /* this string. Applications should use the */ - /* format specific interface to access them. */ - /* */ - /* style_name :: The face's style name. This is an ASCII */ - /* string, usually in English, which describes */ - /* the typeface's style (like `Italic', */ - /* `Bold', `Condensed', etc). Not all font */ - /* formats provide a style name, so this field */ - /* is optional, and can be set to NULL. As */ - /* for `family_name', some formats provide */ - /* localized/Unicode versions of this string. */ - /* Applications should use the format specific */ - /* interface to access them. */ - /* */ - /* num_fixed_sizes :: The number of fixed sizes available in this */ - /* face. This should be set to 0 for scalable */ - /* fonts, unless its resource includes a */ - /* complete set of glyphs (called a `strike') */ - /* for the specified size. */ - /* */ - /* available_sizes :: An array of sizes specifying the available */ - /* bitmap/graymap sizes that are contained in */ - /* in the font resource. Should be set to */ - /* NULL if the field `num_fixed_sizes' is set */ - /* to 0. */ - /* */ - /* num_charmaps :: The total number of character maps in the */ - /* face. */ - /* */ - /* charmaps :: A table of pointers to the face's charmaps */ - /* Used to scan the list of available charmaps */ - /* this table might change after a call to */ - /* FT_Attach_File/Stream (e.g. when it used */ - /* to hook and additional encoding/CMap to */ - /* the face object). */ - /* */ - /* generic :: A field reserved for client uses. See the */ - /* FT_Generic type description. */ - /* */ - /* bbox :: The font bounding box. Coordinates are */ - /* expressed in font units (see units_per_EM). */ - /* The box is large enough to contain any */ - /* glyph from the font. Thus, bbox.yMax can */ - /* be seen as the `maximal ascender', */ - /* bbox.yMin as the `minimal descender', and */ - /* the maximal glyph width is given by */ - /* `bbox.xMax-bbox.xMin' (not to be confused */ - /* with the maximal _advance_width_). Only */ - /* relevant for scalable formats. */ - /* */ - /* units_per_EM :: The number of font units per EM square for */ - /* this face. This is typically 2048 for */ - /* TrueType fonts, 1000 for Type1 fonts, and */ - /* should be set to the (unrealistic) value 1 */ - /* for fixed-sizes fonts. Only relevant for */ - /* scalable formats. */ - /* */ - /* ascender :: The face's ascender is the vertical */ - /* distance from the baseline to the topmost */ - /* point of any glyph in the face. This */ - /* field's value is positive, expressed in */ - /* font units. Some font designs use a value */ - /* different from `bbox.yMax'. Only relevant */ - /* for scalable formats. */ - /* */ - /* descender :: The face's descender is the vertical */ - /* distance from the baseline to the */ - /* bottommost point of any glyph in the face. */ - /* This field's value is positive, expressed */ - /* in font units. Some font designs use a */ - /* value different from `-bbox.yMin'. Only */ - /* relevant for scalable formats. */ - /* */ - /* height :: The face's height is the vertical distance */ - /* from one baseline to the next when writing */ - /* several lines of text. Its value is always */ - /* positive, expressed in font units. The */ - /* value can be computed as */ - /* `ascender+descender+line_gap' where the */ - /* value of `line_gap' is also called */ - /* `external leading'. Only relevant for */ - /* scalable formats. */ - /* */ - /* max_advance_width :: The maximal advance width, in font units, */ - /* for all glyphs in this face. This can be */ - /* used to make word wrapping computations */ - /* faster. Only relevant for scalable */ - /* formats. */ - /* */ - /* max_advance_height :: The maximal advance height, in font units, */ - /* for all glyphs in this face. This is only */ - /* relevant for vertical layouts, and should */ - /* be set to the `height' for fonts that do */ - /* not provide vertical metrics. Only */ - /* relevant for scalable formats. */ - /* */ - /* underline_position :: The position, in font units, of the */ - /* underline line for this face. It's the */ - /* center of the underlining stem. Only */ - /* relevant for scalable formats. */ - /* */ - /* underline_thickness :: The thickness, in font units, of the */ - /* underline for this face. Only relevant for */ - /* scalable formats. */ - /* */ - /* driver :: A handle to the face's parent driver */ - /* object. */ - /* */ - /* memory :: A handle to the face's parent memory */ - /* object. Used for the allocation of */ - /* subsequent objects. */ - /* */ - /* stream :: A handle to the face's stream. */ - /* */ - /* glyph :: The face's associated glyph slot(s). This */ - /* object is created automatically with a new */ - /* face object. However, certain kinds of */ - /* applications (mainly tools like converters) */ - /* can need more than one slot to ease their */ - /* task. */ - /* */ - /* sizes_list :: The list of child sizes for this face. */ - /* */ - /* max_points :: The maximal number of points used to store */ - /* the vectorial outline of any glyph in this */ - /* face. If this value cannot be known in */ - /* advance, or if the face isn't scalable, */ - /* this should be set to 0. Only relevant for */ - /* scalable formats. */ - /* */ - /* max_contours :: The maximal number of contours used to */ - /* store the vectorial outline of any glyph in */ - /* this face. If this value cannot be known */ - /* in advance, or if the face isn't scalable, */ - /* this should be set to 0. Only relevant for */ - /* scalable formats. */ - /* */ - /* transform_matrix :: A 2x2 matrix of 16.16 coefficients used */ - /* to transform glyph outlines after they are */ - /* loaded from the font. Only used by the */ - /* convenience functions. */ - /* */ - /* transform_delta :: A translation vector used to transform */ - /* glyph outlines after they are loaded from */ - /* the font. Only used by the convenience */ - /* functions. */ - /* */ - /* transform_flags :: Some flags used to classify the transform. */ - /* Only used by the convenience functions. */ - /* */ - typedef struct FT_FaceRec_ - { - FT_Long num_faces; - FT_Long face_index; - - FT_Long face_flags; - FT_Long style_flags; - - FT_Long num_glyphs; - - FT_String* family_name; - FT_String* style_name; - - FT_Int num_fixed_sizes; - FT_Bitmap_Size* available_sizes; - - /* the face's table of available charmaps */ - FT_Int num_charmaps; - FT_CharMap* charmaps; - - FT_Generic generic; - - /* the following are only relevant for scalable outlines */ - FT_BBox bbox; - - FT_UShort units_per_EM; - FT_Short ascender; - FT_Short descender; - FT_Short height; - - FT_Short max_advance_width; - FT_Short max_advance_height; - - FT_Short underline_position; - FT_Short underline_thickness; - - FT_GlyphSlot glyph; - FT_Size size; - - /************************************************************/ - /* The following fields should be considered private and */ - /* rarely, if ever, used directly by client applications. */ - - FT_Driver driver; - FT_Memory memory; - FT_Stream stream; - - FT_CharMap charmap; - FT_ListRec sizes_list; - - FT_Generic autohint; - void* extensions; - - FT_UShort max_points; - FT_Short max_contours; - - FT_Matrix transform_matrix; - FT_Vector transform_delta; - FT_Int transform_flags; - - } FT_FaceRec; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_SCALABLE */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face provides */ - /* vectorial outlines (i.e., TrueType or Type1). This doesn't */ - /* prevent embedding of bitmap strikes though, i.e., a given face can */ - /* have both this bit set, and a `num_fixed_sizes' property > 0. */ - /* */ -#define FT_FACE_FLAG_SCALABLE 1 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_FIXED_SIZES */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* `fixed sizes', i.e., bitmap strikes for some given pixel sizes. */ - /* See the `num_fixed_sizes' and `available_sizes' face properties */ - /* for more information. */ - /* */ -#define FT_FACE_FLAG_FIXED_SIZES 2 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_FIXED_WIDTH */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* fixed-width characters (like Courier, Lucida, MonoType, etc.). */ - /* */ -#define FT_FACE_FLAG_FIXED_WIDTH 4 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_SFNT */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face uses the */ - /* `sfnt' storage fomat. For now, this means TrueType or OpenType. */ - /* */ -#define FT_FACE_FLAG_SFNT 8 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_HORIZONTAL */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* horizontal glyph metrics. This should be set for all common */ - /* formats, but who knows. */ - /* */ -#define FT_FACE_FLAG_HORIZONTAL 0x10 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_VERTICAL */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* vertical glyph metrics. If not set, the glyph loader will */ - /* synthetize vertical metrics itself to help display vertical text */ - /* correctly. */ - /* */ -#define FT_FACE_FLAG_VERTICAL 0x20 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_KERNING */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* kerning information. When set, this information can be retrieved */ - /* through the function FT_Get_Kerning(). Note that when unset, this */ - /* function will always return the kerning vector (0,0). */ - /* */ -#define FT_FACE_FLAG_KERNING 0x40 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_FAST_GLYPHS */ - /* */ - /* */ - /* A bit-field constant, used to indicate that the glyphs in a given */ - /* font can be retrieved very quickly, and that a glyph cache is thus */ - /* not necessary for any of its child size objects. */ - /* */ - /* This flag should really be set for fixed-size formats like FNT, */ - /* where each glyph bitmap is available directly in binary form */ - /* without any kind of compression. */ - /* */ -#define FT_FACE_FLAG_FAST_GLYPHS 0x80 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS */ - /* */ - /* */ - /* A bit-field constant, used to indicate that the font contains */ - /* multiple masters and is capable of interpolating between them. */ - /* */ -#define FT_FACE_FLAG_MULTIPLE_MASTERS 0x100 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_GLYPH_NAMES */ - /* */ - /* */ - /* A bit-field constant, used to indicate that the font contains */ - /* glyph names that can be retrieved through FT_Get_Glyph_Name(). */ - /* */ -#define FT_FACE_FLAG_GLYPH_NAMES 0x200 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_EXTERNAL_STREAM */ - /* */ - /* */ - /* This bit field is used internally by FreeType to indicate that */ - /* a face's stream was provided by the client application and should */ - /* not be destroyed by FT_Done_Face(). */ - /* */ -#define FT_FACE_FLAG_EXTERNAL_STREAM 0x4000 - - -#define FT_HAS_HORIZONTAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_HORIZONTAL ) -#define FT_HAS_VERTICAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_VERTICAL ) -#define FT_HAS_KERNING( face ) \ - ( face->face_flags & FT_FACE_FLAG_KERNING ) -#define FT_IS_SCALABLE( face ) \ - ( face->face_flags & FT_FACE_FLAG_SCALABLE ) -#define FT_IS_SFNT( face ) \ - ( face->face_flags & FT_FACE_FLAG_SFNT ) -#define FT_IS_FIXED_WIDTH( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) -#define FT_HAS_FIXED_SIZES( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) -#define FT_HAS_FAST_GLYPHS( face ) \ - ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS ) -#define FT_HAS_GLYPH_NAMES( face ) \ - ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) - -#define FT_HAS_MULTIPLE_MASTERS( face ) \ - ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) - - - /*************************************************************************/ - /* */ - /* */ - /* FT_STYLE_FLAG_ITALIC */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face is */ - /* italicized. */ - /* */ -#define FT_STYLE_FLAG_ITALIC 1 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_STYLE_FLAG_BOLD */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face is */ - /* emboldened. */ - /* */ -#define FT_STYLE_FLAG_BOLD 2 - - - /*************************************************************************/ - /* */ - /* FreeType base size metrics */ - /* */ - /* */ - /* FT_Size_Metrics */ - /* */ - /* */ - /* The size metrics structure returned scaled important distances for */ - /* a given size object. */ - /* */ - /* */ - /* x_ppem :: The character width, expressed in integer pixels. */ - /* This is the width of the EM square expressed in */ - /* pixels, hence the term `ppem' (pixels per EM). */ - /* */ - /* y_ppem :: The character height, expressed in integer pixels. */ - /* This is the height of the EM square expressed in */ - /* pixels, hence the term `ppem' (pixels per EM). */ - /* */ - /* x_scale :: A simple 16.16 fixed point format coefficient used */ - /* to scale horizontal distances expressed in font */ - /* units to fractional (26.6) pixel coordinates. */ - /* */ - /* y_scale :: A simple 16.16 fixed point format coefficient used */ - /* to scale vertical distances expressed in font */ - /* units to fractional (26.6) pixel coordinates. */ - /* */ - /* x_resolution :: The horizontal device resolution for this size */ - /* object, expressed in integer dots per inches */ - /* (dpi). As a convention, fixed font formats set */ - /* this value to 72. */ - /* */ - /* y_resolution :: The vertical device resolution for this size */ - /* object, expressed in integer dots per inches */ - /* (dpi). As a convention, fixed font formats set */ - /* this value to 72. */ - /* */ - /* ascender :: The ascender, expressed in 26.6 fixed point */ - /* pixels. Always positive. */ - /* */ - /* descender :: The descender, expressed in 26.6 fixed point */ - /* pixels. Always positive. */ - /* */ - /* height :: The text height, expressed in 26.6 fixed point */ - /* pixels. Always positive. */ - /* */ - /* max_advance :: Maximum horizontal advance, expressed in 26.6 */ - /* fixed point pixels. Always positive. */ - /* */ - /* */ - /* The values of `ascender', `descender', and `height' are only the */ - /* scaled versions of `face->ascender', `face->descender', and */ - /* `face->height'. */ - /* */ - /* Unfortunately, due to glyph hinting, these values might not be */ - /* exact for certain fonts, they thus must be treated as unreliable */ - /* with an error margin of at least one pixel! */ - /* */ - /* Indeed, the only way to get the exact pixel ascender and descender */ - /* is to render _all_ glyphs. As this would be a definite */ - /* performance hit, it is up to client applications to perform such */ - /* computations. */ - /* */ - typedef struct FT_Size_Metrics_ - { - FT_UShort x_ppem; /* horizontal pixels per EM */ - FT_UShort y_ppem; /* vertical pixels per EM */ - - FT_Fixed x_scale; /* two scales used to convert font units */ - FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */ - - FT_Pos ascender; /* ascender in 26.6 frac. pixels */ - FT_Pos descender; /* descender in 26.6 frac. pixels */ - FT_Pos height; /* text height in 26.6 frac. pixels */ - FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */ - - } FT_Size_Metrics; - - - /*************************************************************************/ - /* */ - /* FreeType base size class */ - /* */ - /* */ - /* FT_SizeRec */ - /* */ - /* */ - /* FreeType root size class structure. A size object models the */ - /* resolution and pointsize dependent data of a given face. */ - /* */ - /* */ - /* face :: Handle to the parent face object. */ - /* */ - /* generic :: A typeless pointer, which is unused by the FreeType */ - /* library or any of its drivers. It can be used by */ - /* client applications to link their own data to each size */ - /* object. */ - /* */ - /* metrics :: Metrics for this size object. This field is read-only. */ - /* */ - typedef struct FT_SizeRec_ - { - FT_Face face; /* parent face object */ - FT_Generic generic; /* generic pointer for client uses */ - FT_Size_Metrics metrics; /* size metrics */ - - } FT_SizeRec; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_SubGlyph */ - /* */ - /* */ - /* The subglyph structure is an internal object used to describe */ - /* subglyphs (for example, in the case of composites). */ - /* */ - /* */ - /* The subglyph implementation is not part of the high-level API, */ - /* hence the forward structure declaration. */ - /* */ - typedef struct FT_SubGlyph_ FT_SubGlyph; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_GlyphLoader */ - /* */ - /* */ - /* The glyph loader is an internal object used to load several glyphs */ - /* together (for example, in the case of composites). */ - /* */ - /* */ - /* The glyph loader implementation is not part of the high-level API, */ - /* hence the forward structure declaration. */ - /* */ - typedef struct FT_GlyphLoader_ FT_GlyphLoader; - - - /*************************************************************************/ - /* */ - /* FreeType Glyph Slot base class */ - /* */ - /* */ - /* FT_GlyphSlotRec */ - /* */ - /* */ - /* FreeType root glyph slot class structure. A glyph slot is a */ - /* container where individual glyphs can be loaded, be they */ - /* vectorial or bitmap/graymaps. */ - /* */ - /* */ - /* library :: A handle to the FreeType library instance */ - /* this slot belongs to. */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* next :: In some cases (like some font tools), several */ - /* glyph slots per face object can be a good */ - /* thing. As this is rare, the glyph slots are */ - /* listed through a direct, single-linked list */ - /* using its `next' field. */ - /* */ - /* generic :: A typeless pointer which is unused by the */ - /* FreeType library or any of its drivers. It */ - /* can be used by client applications to link */ - /* their own data to each size object. */ - /* */ - /* metrics :: The metrics of the last loaded glyph in the */ - /* slot. The returned values depend on the last */ - /* load flags (see the FT_Load_Glyph() API */ - /* function) and can be expressed either in 26.6 */ - /* fractional pixels or font units. */ - /* */ - /* Note that even when the glyph image is */ - /* transformed, the metrics are not. */ - /* */ - /* linearHoriAdvance :: For scalable formats only, this field holds */ - /* the linearly scaled horizontal advance width */ - /* for the glyph (i.e. the scaled and unhinted */ - /* value of the hori advance). This can be */ - /* important to perform correct WYSIWYG layout */ - /* */ - /* Note that this value is expressed by default */ - /* in 16.16 pixels. However, when the glyph is */ - /* loaded with the FT_LOAD_UNSCALED_LINEAR flag, */ - /* this field contains simply the value of the */ - /* advance in original font units. */ - /* */ - /* linearVertAdvance :: For scalable formats only, this field holds */ - /* the linearly scaled vertical advance height */ - /* for the glyph. See linearHoriAdvance for */ - /* comments. */ - /* */ - /* advance :: This is the transformed advance width for the */ - /* glyph. */ - /* */ - /* format :: This field indicates the format of the image */ - /* contained in the glyph slot. Typically */ - /* ft_glyph_format_bitmap, */ - /* ft_glyph_format_outline, and */ - /* ft_glyph_format_composite, but others are */ - /* possible. */ - /* */ - /* bitmap :: This field is used as a bitmap descriptor */ - /* when the slot format is */ - /* ft_glyph_format_bitmap. Note that the */ - /* address and content of the bitmap buffer can */ - /* change between calls of FT_Load_Glyph() and a */ - /* few other functions. */ - /* */ - /* bitmap_left :: This is the bitmap's left bearing expressed */ - /* in integer pixels. Of course, this is only */ - /* valid if the format is */ - /* ft_glyph_format_bitmap. */ - /* */ - /* bitmap_top :: This is the bitmap's top bearing expressed in */ - /* integer pixels. Remember that this is the */ - /* distance from the baseline to the top-most */ - /* glyph scanline, upwards y-coordinates being */ - /* *positive*. */ - /* */ - /* outline :: The outline descriptor for the current glyph */ - /* image if its format is */ - /* ft_glyph_bitmap_outline. */ - /* */ - /* num_subglyphs :: The number of subglyphs in a composite glyph. */ - /* This format is only valid for the composite */ - /* glyph format, that should normally only be */ - /* loaded with the FT_LOAD_NO_RECURSE flag. */ - /* */ - /* subglyphs :: An array of subglyph descriptors for */ - /* composite glyphs. There are `num_subglyphs' */ - /* elements in there. */ - /* */ - /* control_data :: Certain font drivers can also return the */ - /* control data for a given glyph image (e.g. */ - /* TrueType bytecode, Type 1 charstrings, etc.). */ - /* This field is a pointer to such data. */ - /* */ - /* control_len :: This is the length in bytes of the control */ - /* data. */ - /* */ - /* other :: Really wicked formats can use this pointer to */ - /* present their own glyph image to client apps. */ - /* Note that the app will need to know about the */ - /* image format. */ - /* */ - /* loader :: This is a private object for the glyph slot. */ - /* Do not touch this. */ - /* */ - /* */ - /* If FT_Load_Glyph() is called with default flags (FT_LOAD_DEFAULT), */ - /* the glyph image is loaded in the glyph slot in its native format */ - /* (e.g. a vectorial outline for TrueType and Type 1 formats). */ - /* */ - /* This image can later be converted into a bitmap by calling */ - /* FT_Render_Glyph(). This function finds the current renderer for */ - /* the native image's format then invokes it. */ - /* */ - /* The renderer is in charge of transforming the native image through */ - /* the slot's face transformation fields, then convert it into a */ - /* bitmap that is returned in `slot->bitmap'. */ - /* */ - /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ - /* to specify the position of the bitmap relative to the current pen */ - /* position (e.g. coordinates [0,0] on the baseline). Of course, */ - /* `slot->format' is also changed to `ft_glyph_format_bitmap' . */ - /* */ - typedef struct FT_GlyphSlotRec_ - { - FT_Library library; - FT_Face face; - FT_GlyphSlot next; - FT_UInt flags; - FT_Generic generic; - - FT_Glyph_Metrics metrics; - FT_Fixed linearHoriAdvance; - FT_Fixed linearVertAdvance; - FT_Vector advance; - - FT_Glyph_Format format; - - FT_Bitmap bitmap; - FT_Int bitmap_left; - FT_Int bitmap_top; - - FT_Outline outline; - - FT_UInt num_subglyphs; - FT_SubGlyph* subglyphs; - - void* control_data; - long control_len; - - void* other; - - /* private fields */ - FT_GlyphLoader* loader; - - } FT_GlyphSlotRec; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* F U N C T I O N S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Init_FreeType */ - /* */ - /* */ - /* Initializes a new FreeType library object. The set of drivers */ - /* that are registered by this function is determined at build time. */ - /* */ - /* */ - /* library :: A handle to a new library object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Init_FreeType( FT_Library* library ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_FreeType */ - /* */ - /* */ - /* Destroys a given FreeType library object and all of its childs, */ - /* including resources, drivers, faces, sizes, etc. */ - /* */ - /* */ - /* library :: A handle to the target library object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Done_FreeType( FT_Library library ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Open_Flags */ - /* */ - /* */ - /* An enumeration used to list the bit flags used within */ - /* FT_Open_Args(). */ - /* */ - /* */ - /* ft_open_memory :: This is a memory-based stream. */ - /* */ - /* ft_open_stream :: Copy the stream from the `stream' field. */ - /* */ - /* ft_open_pathname :: Create a new input stream from a C pathname. */ - /* */ - /* ft_open_driver :: Use the `driver' field. */ - /* */ - /* ft_open_params :: Use the `num_params' & `params' field. */ - /* */ - typedef enum - { - ft_open_memory = 1, - ft_open_stream = 2, - ft_open_pathname = 4, - ft_open_driver = 8, - ft_open_params = 16 - - } FT_Open_Flags; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Parameter */ - /* */ - /* */ - /* A simple structure used to pass more or less generic parameters */ - /* to FT_Open_Face(). */ - /* */ - /* */ - /* tag :: A 4-byte identification tag. */ - /* */ - /* data :: A pointer to the parameter data. */ - /* */ - /* */ - /* The id and function of parameters are driver-specific. */ - /* */ - typedef struct FT_Parameter_ - { - FT_ULong tag; - FT_Pointer data; - - } FT_Parameter; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Open_Args */ - /* */ - /* */ - /* A structure used to indicate how to open a new font file/stream. */ - /* A pointer to such a structure can be used as a parameter for the */ - /* functions FT_Open_Face() & FT_Attach_Stream(). */ - /* */ - /* */ - /* flags :: A set of bit flags indicating how to use the */ - /* structure. */ - /* */ - /* memory_base :: The first byte of the file in memory. */ - /* */ - /* memory_size :: The size in bytes of the file in memory. */ - /* */ - /* pathname :: A pointer to an 8-bit file pathname. */ - /* */ - /* stream :: A handle to a source stream object. */ - /* */ - /* driver :: This field is exclusively used by FT_Open_Face(); */ - /* it simply specifies the font driver to use to open */ - /* the face. If set to 0, FreeType will try to load */ - /* the face with each one of the drivers in its list. */ - /* */ - /* num_params :: The number of extra parameters. */ - /* */ - /* params :: Extra parameters passed to the font driver when */ - /* opening a new face. */ - /* */ - /* */ - /* `stream_type' determines which fields are used to create a new */ - /* input stream. */ - /* */ - /* If it is `ft_stream_memory', a new memory-based stream will be */ - /* created using the memory block specified by `memory_base' and */ - /* `memory_size'. */ - /* */ - /* If it is `ft_stream_pathname', a new stream will be created with */ - /* the `pathname' field, calling the system-specific FT_New_Stream() */ - /* function. */ - /* */ - /* If is is `ft_stream_copy', then the content of `stream' will be */ - /* copied to a new input stream object. The object will be closed */ - /* and destroyed when the face is destroyed itself. Note that this */ - /* means that you should not close the stream before the library */ - /* does! */ - /* */ - typedef struct FT_Open_Args_ - { - FT_Open_Flags flags; - FT_Byte* memory_base; - FT_Long memory_size; - FT_String* pathname; - FT_Stream stream; - FT_Module driver; - FT_Int num_params; - FT_Parameter* params; - - } FT_Open_Args; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Face */ - /* */ - /* */ - /* Creates a new face object from a given resource and typeface index */ - /* using a pathname to the font file. */ - /* */ - /* */ - /* library :: A handle to the library resource. */ - /* */ - /* */ - /* pathname :: A path to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ - /* */ - /* aface :: A handle to a new face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Note that additional slots can be added to each face with the */ - /* FT_New_GlyphSlot() API function. Slots are linked in a single */ - /* list through their `next' field. */ - /* */ - /* FT_New_Face() can be used to determine and/or check the font */ - /* format of a given font resource. If the `face_index' field is */ - /* negative, the function will _not_ return any face handle in */ - /* `*face'. Its return value should be 0 if the resource is */ - /* recognized, or non-zero if not. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_New_Face( FT_Library library, - const char* filepathname, - FT_Long face_index, - FT_Face* face ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Memory_Face */ - /* */ - /* */ - /* Creates a new face object from a given resource and typeface index */ - /* using a font file already loaded into memory. */ - /* */ - /* */ - /* library :: A handle to the library resource. */ - /* */ - /* */ - /* file_base :: A pointer to the beginning of the font data. */ - /* */ - /* file_size :: The size of the memory chunk used by the font data. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ - /* */ - /* face :: A handle to a new face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Note that additional slots can be added to each face with the */ - /* FT_New_GlyphSlot() API function. Slots are linked in a single */ - /* list through their `next' field. */ - /* */ - /* FT_New_Memory_Face() can be used to determine and/or check the */ - /* font format of a given font resource. If the `face_index' field */ - /* is negative, the function will _not_ return any face handle in */ - /* `*face'. Its return value should be 0 if the resource is */ - /* recognized, or non-zero if not. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_New_Memory_Face( FT_Library library, - FT_Byte* file_base, - FT_Long file_size, - FT_Long face_index, - FT_Face* face ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Open_Face */ - /* */ - /* */ - /* Opens a face object from a given resource and typeface index using */ - /* an `FT_Open_Args' structure. If the face object doesn't exist, it */ - /* will be created. */ - /* */ - /* */ - /* library :: A handle to the library resource. */ - /* */ - /* */ - /* args :: A pointer to an `FT_Open_Args' structure which must */ - /* be filled by the caller. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index 0. */ - /* */ - /* aface :: A handle to a new face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object which can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Note that additional slots can be added to each face with the */ - /* FT_New_GlyphSlot() API function. Slots are linked in a single */ - /* list through their `next' field. */ - /* */ - /* FT_Open_Face() can be used to determine and/or check the font */ - /* format of a given font resource. If the `face_index' field is */ - /* negative, the function will _not_ return any face handle in */ - /* `*face'. Its return value should be 0 if the resource is */ - /* recognized, or non-zero if not. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Open_Face( FT_Library library, - FT_Open_Args* args, - FT_Long face_index, - FT_Face* face ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Attach_File */ - /* */ - /* */ - /* `Attaches' a given font file to an existing face. This is usually */ - /* to read additional information for a single face object. For */ - /* example, it is used to read the AFM files that come with Type 1 */ - /* fonts in order to add kerning data and other metrics. */ - /* */ - /* */ - /* face :: The target face object. */ - /* */ - /* */ - /* filepathname :: An 8-bit pathname naming the `metrics' file. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* If your font file is in memory, or if you want to provide your */ - /* own input stream object, use FT_Attach_Stream(). */ - /* */ - /* The meaning of the `attach' action (i.e., what really happens when */ - /* the new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Attach_File( FT_Face face, - const char* filepathname ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Attach_Stream */ - /* */ - /* */ - /* This function is similar to FT_Attach_File() with the exception */ - /* that it reads the attachment from an arbitrary stream. */ - /* */ - /* */ - /* face :: The target face object. */ - /* */ - /* parameters :: A pointer to an FT_Open_Args structure used to */ - /* describe the input stream to FreeType. */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The meaning of the `attach' (i.e. what really happens when the */ - /* new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Attach_Stream( FT_Face face, - FT_Open_Args* parameters ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Face */ - /* */ - /* */ - /* Discards a given face object, as well as all of its child slots */ - /* and sizes. */ - /* */ - /* */ - /* face :: A handle to a target face object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Done_Face( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Char_Size */ - /* */ - /* */ - /* Sets the character dimensions of a given face object. The */ - /* `char_width' and `char_height' values are used for the width and */ - /* height, respectively, expressed in 26.6 fractional points. */ - /* */ - /* If the horizontal or vertical resolution values are zero, a */ - /* default value of 72dpi is used. Similarly, if one of the */ - /* character dimensions is zero, its value is set equal to the other. */ - /* */ - /* */ - /* size :: A handle to a target size object. */ - /* */ - /* */ - /* char_width :: The character width, in 26.6 fractional points. */ - /* */ - /* char_height :: The character height, in 26.6 fractional */ - /* points. */ - /* */ - /* horz_resolution :: The horizontal resolution. */ - /* */ - /* vert_resolution :: The vertical resolution. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* When dealing with fixed-size faces (i.e., non-scalable formats), */ - /* use the function FT_Set_Pixel_Sizes(). */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Set_Char_Size( FT_Face face, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Pixel_Sizes */ - /* */ - /* */ - /* Sets the character dimensions of a given face object. The width */ - /* and height are expressed in integer pixels. */ - /* */ - /* If one of the character dimensions is zero, its value is set equal */ - /* to the other. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* */ - /* pixel_width :: The character width, in integer pixels. */ - /* */ - /* pixel_height :: The character height, in integer pixels. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face, - FT_UInt pixel_width, - FT_UInt pixel_height ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Load_Glyph */ - /* */ - /* */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size. */ - /* */ - /* */ - /* face :: A handle to the target face object where the glyph */ - /* will be loaded. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX 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). */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* If the glyph image is not a bitmap, and if the bit flag */ - /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ - /* transformed with the information passed to a previous call to */ - /* FT_Set_Transform. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Load_Glyph( FT_Face face, - FT_UInt glyph_index, - FT_Int load_flags ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Load_Char */ - /* */ - /* */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size, according to its character code. */ - /* */ - /* */ - /* face :: A handle to a target face object where the glyph */ - /* will be loaded. */ - /* */ - /* char_code :: The glyph's character code, according to the */ - /* current charmap used in the face. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX 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). */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* If the face has no current charmap, or if the character code */ - /* is not defined in the charmap, this function will return an */ - /* error. */ - /* */ - /* If the glyph image is not a bitmap, and if the bit flag */ - /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ - /* transformed with the information passed to a previous call to */ - /* FT_Set_Transform(). */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Load_Char( FT_Face face, - FT_ULong char_code, - FT_Int load_flags ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_SCALE */ - /* */ - /* */ - /* A bit field constant, used with FT_Load_Glyph() to indicate that */ - /* the vector outline being loaded should not be scaled to 26.6 */ - /* fractional pixels, but kept in notional units. */ - /* */ -#define FT_LOAD_NO_SCALE 1 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_HINTING */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the vector outline being loaded should not be fitted to the pixel */ - /* grid but simply scaled to 26.6 fractional pixels. */ - /* */ - /* This flag is ignored if FT_LOAD_NO_SCALE is set. */ - /* */ -#define FT_LOAD_NO_HINTING 2 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_RENDER */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should load the glyph and immediately convert it into */ - /* a bitmap, if necessary, by calling FT_Render_Glyph(). */ - /* */ - /* Note that by default, FT_Load_Glyph() loads the glyph image in its */ - /* native format. */ - /* */ -#define FT_LOAD_RENDER 4 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_BITMAP */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should not load the bitmap or pixmap of a given */ - /* glyph. This is useful when you do not want to load the embedded */ - /* bitmaps of scalable formats, as the native glyph image will be */ - /* loaded, and can then be rendered through FT_Render_Glyph(). */ - /* */ -#define FT_LOAD_NO_BITMAP 8 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_VERTICAL_LAYOUT */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph image should be prepared for vertical layout. This */ - /* basically means that `face.glyph.advance' will correspond to the */ - /* vertical advance height (instead of the default horizontal */ - /* advance width), and that the glyph image will translated to match */ - /* the vertical bearings positions. */ - /* */ -#define FT_LOAD_VERTICAL_LAYOUT 16 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_FORCE_AUTOHINT */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should try to auto-hint the glyphs, even if a driver */ - /* specific hinter is available. */ - /* */ -#define FT_LOAD_FORCE_AUTOHINT 32 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_CROP_BITMAP */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the font driver should try to crop the bitmap (i.e. remove all */ - /* space around its black bits) when loading it. For now, this */ - /* really only works with embedded bitmaps in TrueType fonts. */ - /* */ -#define FT_LOAD_CROP_BITMAP 64 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_PEDANTIC */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should perform a pedantic bytecode */ - /* interpretation. Many popular fonts come with broken glyph */ - /* programs. When this flag is set, loading them will return an */ - /* error. Otherwise, errors are ignored by the loader, sometimes */ - /* resulting in ugly glyphs. */ - /* */ -#define FT_LOAD_PEDANTIC 128 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should ignore the global advance width defined */ - /* in the font. As far as we know, this is only used by the */ - /* X-TrueType font server, in order to deal correctly with the */ - /* incorrect metrics contained in DynaLab's TrueType CJK fonts. */ - /* */ -#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 512 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_RECURSE */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should not load composite glyph recursively. */ - /* Rather, when a composite glyph is encountered, it should set */ - /* the values of `num_subglyphs' and `subglyphs', as well as set */ - /* `face->glyph.format' to ft_glyph_format_composite. */ - /* */ - /* This is for use by the auto-hinter and possibly other tools. */ - /* For nearly all applications, this flags should be left unset */ - /* when invoking FT_Load_Glyph(). */ - /* */ - /* Note that the flag forces the load of unscaled glyphs. */ - /* */ -#define FT_LOAD_NO_RECURSE 1024 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_IGNORE_TRANSFORM */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should not try to transform the loaded glyph */ - /* image. */ - /* */ -#define FT_LOAD_IGNORE_TRANSFORM 2048 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_MONOCHROME */ - /* */ - /* */ - /* Only used with FT_LOAD_RENDER set, it indicates that the returned */ - /* glyph image should be 1-bit monochrome. This really tells the */ - /* glyph loader to use `ft_render_mode_mono' when calling */ - /* FT_Render_Glyph(). */ - /* */ -#define FT_LOAD_MONOCHROME 4096 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_LINEAR_DESIGN */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should return the linearly scaled metrics expressed */ - /* in original font units, instead of the default 16.16 pixel values. */ - /* */ -#define FT_LOAD_LINEAR_DESIGN 8192 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_DEFAULT */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should try to load the glyph normally, i.e., */ - /* embedded bitmaps are favored over outlines, vectors are always */ - /* scaled and grid-fitted. */ - /* */ -#define FT_LOAD_DEFAULT 0 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Transform */ - /* */ - /* */ - /* A function used to set the transformation that is applied to glyph */ - /* images just before they are converted to bitmaps in a glyph slot */ - /* when FT_Render_Glyph() is called. */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* */ - /* matrix :: A pointer to the transformation's 2x2 matrix. Use 0 for */ - /* the identity matrix. */ - /* delta :: A pointer to the translation vector. Use 0 for the null */ - /* vector. */ - /* */ - /* */ - /* The transformation is only applied to scalable image formats after */ - /* the glyph has been loaded. It means that hinting is unaltered by */ - /* the transformation and is performed on the character size given in */ - /* the last call to FT_Set_Char_Sizes() or FT_Set_Pixel_Sizes(). */ - /* */ - FT_EXPORT_DEF( void ) FT_Set_Transform( FT_Face face, - FT_Matrix* matrix, - FT_Vector* delta ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Render_Mode */ - /* */ - /* */ - /* An enumeration type that lists the render modes supported by the */ - /* FreeType 2 renderer(s). A renderer is in charge of converting a */ - /* glyph image into a bitmap. */ - /* */ - /* */ - /* ft_render_mode_normal :: This is the default render mode; it */ - /* corresponds to 8-bit anti-aliased */ - /* bitmaps, using 256 levels of gray. */ - /* */ - /* ft_render_mode_mono :: This render mode is used to produce 1-bit */ - /* monochrome bitmaps. */ - /* */ - /* */ - /* There is no render mode to produce 8-bit `monochrome' bitmaps -- */ - /* you have to make the conversion yourself if you need such things */ - /* (besides, FreeType is not a graphics library). */ - /* */ - /* More modes might appear later for specific display modes (e.g. TV, */ - /* LCDs, etc.). They will be supported through the simple addition */ - /* of a renderer module, with no changes to the rest of the engine. */ - /* */ - typedef enum FT_Render_Mode_ - { - ft_render_mode_normal = 0, - ft_render_mode_mono = 1 - - } FT_Render_Mode; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Render_Glyph */ - /* */ - /* */ - /* Converts a given glyph image to a bitmap. It does so by */ - /* inspecting the glyph image format, find the relevant renderer, and */ - /* invoke it. */ - /* */ - /* */ - /* slot :: A handle to the glyph slot containing the image to */ - /* convert. */ - /* */ - /* render_mode :: This is the render mode used to render the glyph */ - /* image into a bitmap. See FT_Render_Mode for a list */ - /* of possible values. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot, - FT_UInt render_mode ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Kerning_Mode */ - /* */ - /* */ - /* An enumeration used to specify which kerning values to return in */ - /* FT_Get_Kerning(). */ - /* */ - /* */ - /* ft_kerning_default :: Return scaled and grid-fitted kerning */ - /* distances (value is 0). */ - /* */ - /* ft_kerning_unfitted :: Return scaled but un-grid-fitted kerning */ - /* distances. */ - /* */ - /* ft_kerning_unscaled :: Return the kerning vector in original font */ - /* units. */ - /* */ - typedef enum FT_Kerning_Mode_ - { - ft_kerning_default = 0, - ft_kerning_unfitted, - ft_kerning_unscaled - - } FT_Kerning_Mode; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Kerning */ - /* */ - /* */ - /* Returns the kerning vector between two glyphs of a same face. */ - /* */ - /* */ - /* face :: A handle to a 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. */ - /* */ - /* kern_mode :: See FT_Kerning_Mode() for more information. */ - /* Determines the scale/dimension of the returned */ - /* kerning vector. */ - /* */ - /* */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this method. Other layouts, or more sophisticated */ - /* kernings, are out of the scope of this API function -- they can be */ - /* implemented through format-specific interfaces. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Get_Kerning( FT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_UInt kern_mode, - FT_Vector* kerning ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Glyph_Name */ - /* */ - /* */ - /* Retrieves the ASCII name of a given glyph in a face. This only */ - /* works for those faces where FT_HAS_GLYPH_NAME(face) returns true. */ - /* */ - /* */ - /* face :: A handle to a source face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* buffer :: A pointer to a target buffer where the name will be */ - /* copied to. */ - /* */ - /* buffer_max :: The maximal number of bytes available in the */ - /* buffer. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* An error is returned if the face doesn't provide glyph names or if */ - /* the glyph index is invalid. In all cases of failure, the first */ - /* byte of `buffer' will be set to 0 to indicate an empty name. */ - /* */ - /* The glyph name is truncated to fit within the buffer if it is too */ - /* long. The returned string is always zero-terminated. */ - /* */ - /* This function is not compiled within the library if the config */ - /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */ - /* `include/freetype/config/ftoptions.h' */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Get_Glyph_Name( FT_Face face, - FT_UInt glyph_index, - FT_Pointer buffer, - FT_UInt buffer_max ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Select_Charmap */ - /* */ - /* */ - /* Selects a given charmap by its encoding tag (as listed in */ - /* `freetype.h'). */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* encoding :: A handle to the selected charmap. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* This function will return an error if no charmap in the face */ - /* corresponds to the encoding queried here. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Select_Charmap( FT_Face face, - FT_Encoding encoding ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Charmap */ - /* */ - /* */ - /* Selects a given charmap for character code to glyph index */ - /* decoding. */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* charmap :: A handle to the selected charmap. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* This function will return an error if the charmap is not part of */ - /* the face (i.e., if it is not listed in the face->charmaps[] */ - /* table). */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Set_Charmap( FT_Face face, - FT_CharMap charmap ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Char_Index */ - /* */ - /* */ - /* Returns the glyph index of a given character code. This function */ - /* uses a charmap object to do the translation. */ - /* */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* */ - /* The glyph index. 0 means `undefined character code'. */ - /* */ - FT_EXPORT_DEF( FT_UInt ) FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MulDiv */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* */ - /* 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_DEF( FT_Long ) FT_MulDiv( FT_Long a, - FT_Long b, - FT_Long c ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MulFix */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* */ - /* The result of `(a*b)/0x10000'. */ - /* */ - /* */ - /* 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_DEF( FT_Long ) FT_MulFix( FT_Long a, - FT_Long b ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_DivFix */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* */ - /* The result of `(a*0x10000)/b'. */ - /* */ - /* */ - /* 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_DEF( FT_Long ) FT_DivFix( FT_Long a, - FT_Long b ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Vector_Transform */ - /* */ - /* */ - /* Transforms a single vector through a 2x2 matrix. */ - /* */ - /* */ - /* vector :: The target vector to transform. */ - /* */ - /* */ - /* matrix :: A pointer to the source 2x2 matrix. */ - /* */ - /* */ - /* Yes. */ - /* */ - /* */ - /* The result is undefined if either `vector' or `matrix' is invalid. */ - /* */ - FT_EXPORT_DEF( void ) FT_Vector_Transform( FT_Vector* vec, - FT_Matrix* matrix ); - - - -#ifdef __cplusplus - } -#endif - - -#endif /* FREETYPE_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftbbox.h b/src/freetype/freetype/ftbbox.h deleted file mode 100644 index e1446647df..0000000000 --- a/src/freetype/freetype/ftbbox.h +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbbox.h */ -/* */ -/* FreeType bbox computation (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component has a _single_ role: to compute exact outline bounding */ - /* boxes. */ - /* */ - /* It is separated from the rest of the engine for various technical */ - /* reasons. It may well be integrated in `ftoutln' later. */ - /* */ - /*************************************************************************/ - - -#ifndef FTBBOX_H -#define FTBBOX_H - -#include - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_GetBBox */ - /* */ - /* */ - /* Computes the exact bounding box of an outline. This is slower */ - /* than computing the control box. However, it uses an advanced */ - /* algorithm which returns _very_ quickly when the two boxes */ - /* coincide. Otherwise, the outline Bezier arcs are walked over to */ - /* extract their extrema. */ - /* */ - /* */ - /* outline :: A pointer to the source outline. */ - /* */ - /* */ - /* bbox :: The outline's exact bounding box. */ - /* */ - /* */ - /* Error code. 0 means success. */ - /* */ - FT_EXPORT_DEF(FT_Error) FT_Raster_GetBBox( FT_Outline* outline, - FT_BBox* abbox ); - - -#ifdef __cplusplus - } -#endif - -#endif /* FTBBOX_H */ - - -/* END */ diff --git a/src/freetype/freetype/fterrors.h b/src/freetype/freetype/fterrors.h deleted file mode 100644 index 9fb8099b89..0000000000 --- a/src/freetype/freetype/fterrors.h +++ /dev/null @@ -1,166 +0,0 @@ -/***************************************************************************/ -/* */ -/* fterrors.h */ -/* */ -/* FreeType error codes (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the FreeType error enumeration constants */ - /* It can also be used to create an error message table easily with */ - /* something like: */ - /* */ - /* { */ - /* #undef FTERRORS_H */ - /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ - /* #define FT_ERROR_START_LIST { */ - /* #define FT_ERROR_END_LIST { 0, 0 } }; */ - /* */ - /* const struct */ - /* { */ - /* int err_code; */ - /* const char* err_msg */ - /* } ft_errors[] = */ - /* */ - /* #include */ - /* } */ - /* */ - /*************************************************************************/ - - -#ifndef FTERRORS_H -#define FTERRORS_H - - -#ifndef FT_ERRORDEF - -#define FT_ERRORDEF( e, v, s ) e = v, -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST FT_Err_Max }; - -#endif /* !FT_ERRORDEF */ - - -#ifdef FT_ERROR_START_LIST - FT_ERROR_START_LIST -#endif - - FT_ERRORDEF( FT_Err_Ok, 0x0000, \ - "no error" ) - FT_ERRORDEF( FT_Err_Cannot_Open_Resource, 0x0001, \ - "can't open stream" ) - FT_ERRORDEF( FT_Err_Unknown_File_Format, 0x0002, \ - "unknown file format" ) - FT_ERRORDEF( FT_Err_Invalid_File_Format, 0x0003, \ - "broken file" ) - - FT_ERRORDEF( FT_Err_Invalid_Argument, 0x0010, \ - "invalid argument" ) - FT_ERRORDEF( FT_Err_Invalid_Handle, 0x0011, \ - "invalid object handle" ) - FT_ERRORDEF( FT_Err_Invalid_Glyph_Index, 0x0012, \ - "invalid glyph index" ) - FT_ERRORDEF( FT_Err_Invalid_Character_Code, 0x0013, \ - "invalid character code" ) - - FT_ERRORDEF( FT_Err_Unimplemented_Feature, 0x0020, \ - "unimplemented feature" ) - FT_ERRORDEF( FT_Err_Invalid_Glyph_Format, 0x0021, \ - "unsupported glyph image format" ) - FT_ERRORDEF( FT_Err_Cannot_Render_Glyph, 0x0022, \ - "cannot render this glyph format" ) - - FT_ERRORDEF( FT_Err_Invalid_Library_Handle, 0x0030, \ - "invalid library handle" ) - FT_ERRORDEF( FT_Err_Invalid_Driver_Handle, 0x0031, \ - "invalid module handle" ) - FT_ERRORDEF( FT_Err_Invalid_Face_Handle, 0x0032, \ - "invalid face handle" ) - FT_ERRORDEF( FT_Err_Invalid_Size_Handle, 0x0033, \ - "invalid size handle" ) - FT_ERRORDEF( FT_Err_Invalid_Slot_Handle, 0x0034, \ - "invalid glyph slot handle" ) - FT_ERRORDEF( FT_Err_Invalid_CharMap_Handle, 0x0035, \ - "invalid charmap handle" ) - FT_ERRORDEF( FT_Err_Invalid_Outline, 0x0036, \ - "invalid outline" ) - FT_ERRORDEF( FT_Err_Invalid_Version, 0x0037, \ - "invalid FreeType version" ) - FT_ERRORDEF( FT_Err_Lower_Module_Version, 0x0038, \ - "module version is too low" ) - - FT_ERRORDEF( FT_Err_Too_Many_Drivers, 0x0040, \ - "too many modules" ) - FT_ERRORDEF( FT_Err_Too_Many_Extensions, 0x0041, \ - "too many extensions" ) - - FT_ERRORDEF( FT_Err_Out_Of_Memory, 0x0050, \ - "out of memory" ) - FT_ERRORDEF( FT_Err_Unlisted_Object, 0x0051, \ - "unlisted object" ) - - FT_ERRORDEF( FT_Err_Invalid_Stream_Handle, 0x0060, \ - "invalid stream handle" ) - FT_ERRORDEF( FT_Err_Cannot_Open_Stream, 0x0061, \ - "cannot open stream" ) - FT_ERRORDEF( FT_Err_Invalid_Stream_Seek, 0x0062, \ - "invalid stream seek" ) - FT_ERRORDEF( FT_Err_Invalid_Stream_Skip, 0x0063, \ - "invalid stream skip" ) - FT_ERRORDEF( FT_Err_Invalid_Stream_Read, 0x0064, \ - "invalid stream read" ) - FT_ERRORDEF( FT_Err_Invalid_Stream_Operation, 0x0065, \ - "invalid stream operation" ) - FT_ERRORDEF( FT_Err_Invalid_Frame_Operation, 0x0066, \ - "invalid frame operation" ) - FT_ERRORDEF( FT_Err_Nested_Frame_Access, 0x0067, \ - "nested frame access" ) - FT_ERRORDEF( FT_Err_Invalid_Frame_Read, 0x0068, \ - "invalid frame read" ) - - FT_ERRORDEF( FT_Err_Invalid_Composite, 0x0070, \ - "invalid composite glyph" ) - FT_ERRORDEF( FT_Err_Too_Many_Hints, 0x0071, \ - "too many hints" ) - - FT_ERRORDEF( FT_Err_Raster_Uninitialized, 0x0080, \ - "raster uninitialized" ) - FT_ERRORDEF( FT_Err_Raster_Corrupted, 0x0081, \ - "raster corrupted" ) - FT_ERRORDEF( FT_Err_Raster_Overflow, 0x0082, \ - "raster overflow" ) - FT_ERRORDEF( FT_Err_Raster_Negative_Height, 0x0083, \ - "negative height while rastering" ) - - /* range 0x400 - 0x4FF is reserved for TrueType specific stuff */ - - /* range 0x500 - 0x5FF is reserved for CFF specific stuff */ - - /* range 0x600 - 0x6FF is reserved for Type1 specific stuff */ - -#ifdef FT_ERROR_END_LIST - FT_ERROR_END_LIST -#endif - - -#undef FT_ERROR_START_LIST -#undef FT_ERROR_END_LIST -#undef FT_ERRORDEF - - -#endif /* FTERRORS_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftglyph.h b/src/freetype/freetype/ftglyph.h deleted file mode 100644 index 0647c883eb..0000000000 --- a/src/freetype/freetype/ftglyph.h +++ /dev/null @@ -1,422 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftglyph.h */ -/* */ -/* FreeType convenience functions to handle glyphs (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ - - -#ifndef FTGLYPH_H -#define FTGLYPH_H - -#include - -#ifdef __cplusplus - extern "C" { -#endif - - /* forward declaration to a private type */ - typedef struct FT_Glyph_Class_ FT_Glyph_Class; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_GlyphRec */ - /* */ - /* */ - /* The root glyph structure contains a given glyph image plus its */ - /* advance width in 16.16 fixed float format. */ - /* */ - /* */ - /* library :: A handle to the FreeType library object. */ - /* */ - /* clazz :: A pointer to the glyph's class. Private. */ - /* */ - /* format :: The format of the glyph's image. */ - /* */ - /* advance :: A 16.16 vector that gives the glyph's advance width. */ - /* */ - typedef struct FT_GlyphRec_ - { - FT_Library library; - const FT_Glyph_Class* clazz; - FT_Glyph_Format format; - FT_Vector advance; - - } FT_GlyphRec, *FT_Glyph; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_BitmapGlyphRec */ - /* */ - /* */ - /* A structure used for bitmap glyph images. This really is a */ - /* `sub-class' of `FT_GlyphRec'. */ - /* */ - /* */ - /* root :: The root FT_Glyph fields. */ - /* */ - /* left :: The left-side bearing, i.e., the horizontal distance */ - /* from the current pen position to the left border of the */ - /* glyph bitmap. */ - /* */ - /* top :: The top-side bearing, i.e., the vertical distance from */ - /* the current pen position to the top border of the glyph */ - /* bitmap. This distance is positive for upwards-y! */ - /* */ - /* bitmap :: A descriptor for the bitmap. */ - /* */ - /* */ - /* You can typecast FT_Glyph to FT_BitmapGlyph if you have */ - /* glyph->format == ft_glyph_format_bitmap. This lets you access */ - /* the bitmap's contents easily. */ - /* */ - /* The corresponding pixel buffer is always owned by the BitmapGlyph */ - /* and is thus created and destroyed with it. */ - /* */ - typedef struct FT_BitmapGlyphRec_ - { - FT_GlyphRec root; - FT_Int left; - FT_Int top; - FT_Bitmap bitmap; - - } FT_BitmapGlyphRec, *FT_BitmapGlyph; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_OutlineGlyphRec */ - /* */ - /* */ - /* A structure used for outline (vectorial) glyph images. This */ - /* really is a `sub-class' of `FT_GlyphRec'. */ - /* */ - /* */ - /* root :: The root FT_Glyph fields. */ - /* */ - /* outline :: A descriptor for the outline. */ - /* */ - /* */ - /* You can typecast FT_Glyph to FT_OutlineGlyph if you have */ - /* glyph->format == ft_glyph_format_outline. This lets you access */ - /* the outline's content easily. */ - /* */ - /* As the outline is extracted from a glyph slot, its coordinates are */ - /* expressed normally in 26.6 pixels, unless the flag */ - /* FT_LOAD_NO_SCALE was used in FT_Load_Glyph() or FT_Load_Char(). */ - /* */ - /* The outline's tables are always owned by the object and are */ - /* destroyed with it. */ - /* */ - typedef struct FT_OutlineGlyphRec_ - { - FT_GlyphRec root; - FT_Outline outline; - - } FT_OutlineGlyphRec, *FT_OutlineGlyph; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Glyph */ - /* */ - /* */ - /* A function used to extract a glyph image from a slot. */ - /* */ - /* */ - /* slot :: A handle to the source glyph slot. */ - /* */ - /* */ - /* aglyph :: A handle to the glyph object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot, - FT_Glyph* aglyph ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Copy */ - /* */ - /* */ - /* A function used to copy a glyph image. */ - /* */ - /* */ - /* source :: A handle to the source glyph object. */ - /* */ - /* */ - /* target :: A handle to the target glyph object. 0 in case of */ - /* error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Glyph_Copy( FT_Glyph source, - FT_Glyph* target ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Transform */ - /* */ - /* */ - /* Transforms a glyph image if its format is scalable. */ - /* */ - /* */ - /* glyph :: A handle to the target glyph object. */ - /* */ - /* matrix :: A pointer to a 2x2 matrix to apply. */ - /* */ - /* delta :: A pointer to a 2d vector to apply. Coordinates are */ - /* expressed in 1/64th of a pixel. */ - /* */ - /* */ - /* FreeType error code (the glyph format is not scalable if it is */ - /* not zero). */ - /* */ - /* */ - /* The 2x2 transformation matrix is also applied to the glyph's */ - /* advance vector. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Glyph_Transform( FT_Glyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ); - - - enum - { - ft_glyph_bbox_pixels = 0, - ft_glyph_bbox_subpixels = 1, - ft_glyph_bbox_gridfit = 2 - }; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Get_CBox */ - /* */ - /* */ - /* Returns the glyph image's bounding box. */ - /* */ - /* */ - /* glyph :: A handle to the source glyph object. */ - /* */ - /* mode :: A set of bit flags that indicate how to interpret the */ - /* returned bounding box values. */ - /* */ - /* */ - /* box :: The glyph bounding box. Coordinates are expressed in */ - /* 1/64th of pixels if it is grid-fitted. */ - /* */ - /* */ - /* Coordinates are relative to the glyph origin, using the Y-upwards */ - /* convention. */ - /* */ - /* If `ft_glyph_bbox_subpixels' is set in `mode', the bbox */ - /* coordinates are returned in 26.6 pixels (i.e. 1/64th of pixels). */ - /* Otherwise, coordinates are expressed in integer pixels. */ - /* */ - /* Note that the maximum coordinates are exclusive, which means that */ - /* one can compute the width and height of the glyph image (be it in */ - /* integer or 26.6 pixels) as: */ - /* */ - /* width = bbox.xMax - bbox.xMin; */ - /* height = bbox.yMax - bbox.yMin; */ - /* */ - /* Note also that for 26.6 coordinates, if the */ - /* `ft_glyph_bbox_gridfit' flag is set in `mode;, the coordinates */ - /* will also be grid-fitted, which corresponds to: */ - /* */ - /* bbox.xMin = FLOOR(bbox.xMin); */ - /* bbox.yMin = FLOOR(bbox.yMin); */ - /* bbox.xMax = CEILING(bbox.xMax); */ - /* bbox.yMax = CEILING(bbox.yMax); */ - /* */ - /* The default value (0) for `bbox_mode' is `ft_glyph_bbox_pixels'. */ - /* */ - FT_EXPORT_DEF( void ) FT_Glyph_Get_CBox( FT_Glyph glyph, - FT_UInt bbox_mode, - FT_BBox* cbox ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_To_Bitmap */ - /* */ - /* */ - /* Converts a given glyph object to a bitmap glyph object. */ - /* */ - /* */ - /* glyph :: A pointer to a handle to the target glyph. */ - /* */ - /* */ - /* render_mode :: A set of bit flags that describe how the data is */ - /* */ - /* */ - /* origin :: A pointer to a vector used to translate the glyph */ - /* image before rendering. Can be 0 (if no */ - /* translation). The origin is expressed in */ - /* 26.6 pixels. */ - /* */ - /* destroy :: A boolean that indicates that the original glyph */ - /* image should be destroyed by this function. It is */ - /* never destroyed in case of error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The glyph image is translated with the `origin' vector before */ - /* rendering. In case of error, it it translated back to its */ - /* original position and the glyph is left untouched. */ - /* */ - /* The first parameter is a pointer to a FT_Glyph handle, that will */ - /* be replaced by this function. Typically, you would use (omitting */ - /* error handling): */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyph; */ - /* FT_BitmapGlyph glyph_bitmap; */ - /* */ - /* */ - /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ - /* */ - /* // extract glyph image */ - /* error = FT_Get_Glyph( face->glyph, &glyph ); */ - /* */ - /* // convert to a bitmap (default render mode + destroy old) */ - /* if ( glyph->format != ft_glyph_format_bitmap ) */ - /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, */ - /* 0, 1 ); */ - /* if ( error ) // glyph unchanged */ - /* ... */ - /* } */ - /* */ - /* // access bitmap content by typecasting */ - /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ - /* */ - /* // do funny stuff with it, like blitting/drawing */ - /* ... */ - /* */ - /* // discard glyph image (bitmap or not) */ - /* FT_Done_Glyph( glyph ); */ - /* } */ - /* */ - /* */ - /* This function will always fail if the glyph's format isn't */ - /* scalable. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, - FT_ULong render_mode, - FT_Vector* origin, - FT_Bool destroy ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Glyph */ - /* */ - /* */ - /* Destroys a given glyph. */ - /* */ - /* */ - /* glyph :: A handle to the target glyph object. */ - /* */ - FT_EXPORT_DEF( void ) FT_Done_Glyph( FT_Glyph glyph ); - - - /* other helpful functions */ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Matrix_Multiply */ - /* */ - /* */ - /* Performs the matrix operation `b = a*b'. */ - /* */ - /* */ - /* a :: A pointer to matrix `a'. */ - /* */ - /* */ - /* b :: A pointer to matrix `b'. */ - /* */ - /* */ - /* Yes. */ - /* */ - /* */ - /* The result is undefined if either `a' or `b' is zero. */ - /* */ - FT_EXPORT_DEF( void ) FT_Matrix_Multiply( FT_Matrix* a, - FT_Matrix* b ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Matrix_Invert */ - /* */ - /* */ - /* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */ - /* */ - /* */ - /* matrix :: A pointer to the target matrix. Remains untouched in */ - /* case of error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Yes. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix ); - - -#ifdef __cplusplus - } -#endif - -#endif /* FTGLYPH_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftimage.h b/src/freetype/freetype/ftimage.h deleted file mode 100644 index 4dd1c3d213..0000000000 --- a/src/freetype/freetype/ftimage.h +++ /dev/null @@ -1,1003 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftimage.h */ -/* */ -/* FreeType glyph image formats and default raster 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. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Note: A `raster' is simply a scan-line converter, used to render */ - /* FT_Outlines into FT_Bitmaps. */ - /* */ - /*************************************************************************/ - - -#ifndef FTIMAGE_H -#define FTIMAGE_H - - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Pos */ - /* */ - /* */ - /* The type FT_Pos is a 32-bit integer used to store vectorial */ - /* coordinates. Depending on the context, these can represent */ - /* distances in integer font units, or 26.6 fixed float pixel */ - /* coordinates. */ - /* */ - typedef signed long FT_Pos; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Vector */ - /* */ - /* */ - /* A simple structure used to store a 2D vector; coordinates are of */ - /* the FT_Pos type. */ - /* */ - /* */ - /* x :: The horizontal coordinate. */ - /* y :: The vertical coordinate. */ - /* */ - typedef struct FT_Vector_ - { - FT_Pos x; - FT_Pos y; - - } FT_Vector; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Pixel_Mode */ - /* */ - /* */ - /* An enumeration type used to describe the format of pixels in a */ - /* given bitmap. Note that additional formats may be added in the */ - /* future. */ - /* */ - /* */ - /* ft_pixel_mode_mono :: A monochrome bitmap (1 bit/pixel). */ - /* */ - /* ft_pixel_mode_grays :: An 8-bit gray-levels bitmap. Note that the */ - /* total number of gray levels is given in the */ - /* `num_grays' field of the FT_Bitmap */ - /* structure. */ - /* */ - /* ft_pixel_mode_pal2 :: A 2-bit paletted bitmap. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_pal4 :: A 4-bit paletted bitmap. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_pal8 :: An 8-bit paletted bitmap. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_rgb15 :: A 15-bit RGB bitmap. Uses 5:5:5 encoding. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_rgb16 :: A 16-bit RGB bitmap. Uses 5:6:5 encoding. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_rgb24 :: A 24-bit RGB bitmap. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_rgb32 :: A 32-bit RGB bitmap. */ - /* Currently unused by FreeType. */ - /* */ - /* */ - /* Some anti-aliased bitmaps might be embedded in TrueType fonts */ - /* using formats pal2 or pal4, though no fonts presenting those have */ - /* been found to date. */ - /* */ - typedef enum FT_Pixel_Mode_ - { - ft_pixel_mode_none = 0, - ft_pixel_mode_mono, - ft_pixel_mode_grays, - ft_pixel_mode_pal2, - ft_pixel_mode_pal4, - ft_pixel_mode_pal8, - ft_pixel_mode_rgb15, - ft_pixel_mode_rgb16, - ft_pixel_mode_rgb24, - ft_pixel_mode_rgb32, - - ft_pixel_mode_max /* do not remove */ - - } FT_Pixel_Mode; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Palette_Mode */ - /* */ - /* */ - /* An enumeration type used to describe the format of a bitmap */ - /* palette, used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */ - /* */ - /* */ - /* ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */ - /* records. */ - /* */ - /* ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */ - /* records. */ - /* */ - /* */ - /* As ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */ - /* FreeType, these types are not handled by the library itself. */ - /* */ - typedef enum FT_Palette_Mode_ - { - ft_palette_mode_rgb = 0, - ft_palette_mode_rgba, - - ft_palettte_mode_max /* do not remove */ - - } FT_Palette_Mode; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Bitmap */ - /* */ - /* */ - /* A structure used to describe a bitmap or pixmap to the raster. */ - /* Note that we now manage pixmaps of various depths through the */ - /* `pixel_mode' field. */ - /* */ - /* */ - /* rows :: The number of bitmap rows. */ - /* */ - /* width :: The number of pixels in bitmap row. */ - /* */ - /* pitch :: The pitch's absolute value is the number of bytes */ - /* taken by one bitmap row, including padding. */ - /* However, the pitch is positive when the bitmap has */ - /* a `down' flow, and negative when it has an `up' */ - /* flow. In all cases, the pitch is an offset to add */ - /* to a bitmap pointer in order to go down one row. */ - /* */ - /* buffer :: A typeless pointer to the bitmap buffer. This */ - /* value should be aligned on 32-bit boundaries in */ - /* most cases. */ - /* */ - /* num_grays :: This field is only used with */ - /* `ft_pixel_mode_grays'; it gives the number of gray */ - /* levels used in the bitmap. */ - /* */ - /* pixel_mode :: The pixel_mode, i.e., how pixel bits are stored. */ - /* */ - /* palette_mode :: This field is only used with paletted pixel modes; */ - /* it indicates how the palette is stored. */ - /* */ - /* palette :: A typeless pointer to the bitmap palette; only */ - /* used for paletted pixel modes. */ - /* */ - /* */ - /* For now, the only pixel mode supported by FreeType are mono and */ - /* grays. However, drivers might be added in the future to support */ - /* more `colorful' options. */ - /* */ - /* When using pixel modes pal2, pal4 and pal8 with a void `palette' */ - /* field, a gray pixmap with respectively 4, 16, and 256 levels of */ - /* gray is assumed. This, in order to be compatible with some */ - /* embedded bitmap formats defined in the TrueType specification. */ - /* */ - /* Note that no font was found presenting such embedded bitmaps, so */ - /* this is currently completely unhandled by the library. */ - /* */ - typedef struct FT_Bitmap_ - { - int rows; - int width; - int pitch; - unsigned char* buffer; - short num_grays; - char pixel_mode; - char palette_mode; - void* palette; - - } FT_Bitmap; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline */ - /* */ - /* */ - /* This structure is used to describe an outline to the scan-line */ - /* converter. */ - /* */ - /* */ - /* n_contours :: The number of contours in the outline. */ - /* */ - /* n_points :: The number of points in the outline. */ - /* */ - /* points :: A pointer to an array of `n_points' FT_Vector */ - /* elements, giving the outline's point coordinates. */ - /* */ - /* tags :: A pointer to an array of `n_points' chars, giving */ - /* giving each outline point's type. If bit 0 is */ - /* unset, the point is 'off' the curve, i.e. a Bezier */ - /* control point, while it is `on' when unset. */ - /* */ - /* Bit 1 is meaningful for `off' points only. If set, */ - /* it indicates a third-order Bezier arc control point; */ - /* and a second-order control point if unset. */ - /* */ - /* contours :: An array of `n_contours' shorts, giving the end */ - /* point of each contour within the outline. For */ - /* example, the first contour is defined by the points */ - /* `0' to `contours[0]', the second one is defined by */ - /* the points `contours[0]+1' to `contours[1]', etc. */ - /* */ - /* flags :: A set of bit flags used to characterize the outline */ - /* and give hints to the scan-converter and hinter on */ - /* how to convert/grid-fit it. See FT_Outline_Flags. */ - /* */ - typedef struct FT_Outline_ - { - short n_contours; /* number of contours in glyph */ - short n_points; /* number of points in the glyph */ - - FT_Vector* points; /* the outline's points */ - char* tags; /* the points flags */ - short* contours; /* the contour end points */ - - int flags; /* outline masks */ - - } FT_Outline; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Flags */ - /* */ - /* */ - /* A simple type used to enumerates the flags in an outline's */ - /* `outline_flags' field. */ - /* */ - /* */ - /* ft_outline_owner :: If set, this flag indicates that the */ - /* outline's field arrays (i.e. */ - /* `points', `flags' & `contours') are */ - /* `owned' by the outline object, and */ - /* should thus be freed when it is */ - /* destroyed. */ - /* */ - /* ft_outline_even_odd_fill :: By default, outlines are filled using */ - /* the non-zero winding rule. If set to */ - /* 1, the outline will be filled using */ - /* the even-odd fill rule (only works */ - /* with the smooth raster). */ - /* */ - /* ft_outline_reverse_fill :: By default, outside contours of an */ - /* outline are oriented in clock-wise */ - /* direction, as defined in the TrueType */ - /* specification. This flag is set if */ - /* the outline uses the opposite */ - /* direction (typically for Type 1 */ - /* fonts). This flag is ignored by the */ - /* scan-converter. However, it is very */ - /* important for the auto-hinter. */ - /* */ - /* ft_outline_ignore_dropouts :: By default, the scan converter will */ - /* try to detect drop-outs in an outline */ - /* and correct the glyph bitmap to */ - /* ensure consistent shape continuity. */ - /* If set, this flag hints the scan-line */ - /* converter to ignore such cases. */ - /* */ - /* ft_outline_high_precision :: This flag indicates that the */ - /* scan-line converter should try to */ - /* convert this outline to bitmaps with */ - /* the highest possible quality. It is */ - /* typically set for small character */ - /* sizes. Note that this is only a */ - /* hint, that might be completely */ - /* ignored by a given scan-converter. */ - /* */ - /* ft_outline_single_pass :: This flag is set to force a given */ - /* scan-converter to only use a single */ - /* pass over the outline to render a */ - /* bitmap glyph image. Normally, it is */ - /* set for very large character sizes. */ - /* It is only a hint, that might be */ - /* completely ignored by a given */ - /* scan-converter. */ - /* */ - typedef enum FT_Outline_Flags_ - { - ft_outline_none = 0, - ft_outline_owner = 1, - ft_outline_even_odd_fill = 2, - ft_outline_reverse_fill = 4, - ft_outline_ignore_dropouts = 8, - ft_outline_high_precision = 256, - ft_outline_single_pass = 512 - - } FT_Outline_Flags; - - -#define FT_CURVE_TAG( flag ) ( flag & 3 ) - -#define FT_Curve_Tag_On 1 -#define FT_Curve_Tag_Conic 0 -#define FT_Curve_Tag_Cubic 2 - -#define FT_Curve_Tag_Touch_X 8 /* reserved for the TrueType hinter */ -#define FT_Curve_Tag_Touch_Y 16 /* reserved for the TrueType hinter */ - -#define FT_Curve_Tag_Touch_Both ( FT_Curve_Tag_Touch_X | \ - FT_Curve_Tag_Touch_Y ) - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_MoveTo_Func */ - /* */ - /* */ - /* A function pointer type used to describe the signature of a `move */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `move to' is emitted to start a new contour in an outline. */ - /* */ - /* */ - /* to :: A pointer to the target point of the `move to'. */ - /* */ - /* user :: A typeless pointer which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* */ - /* Error code. 0 means success. */ - /* */ - typedef int (*FT_Outline_MoveTo_Func)( FT_Vector* to, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_LineTo_Func */ - /* */ - /* */ - /* A function pointer type used to describe the signature of a `line */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `line to' is emitted to indicate a segment in the outline. */ - /* */ - /* */ - /* to :: A pointer to the target point of the `line to'. */ - /* */ - /* user :: A typeless pointer which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* */ - /* Error code. 0 means success. */ - /* */ - typedef int (*FT_Outline_LineTo_Func)( FT_Vector* to, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_ConicTo_Func */ - /* */ - /* */ - /* A function pointer type use to describe the signature of a `conic */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `conic to' is emitted to indicate a second-order Bezier arc in */ - /* the outline. */ - /* */ - /* */ - /* control :: An intermediate control point between the last position */ - /* and the new target in `to'. */ - /* */ - /* to :: A pointer to the target end point of the conic arc. */ - /* */ - /* user :: A typeless pointer which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* */ - /* Error code. 0 means success. */ - /* */ - typedef int (*FT_Outline_ConicTo_Func)( FT_Vector* control, - FT_Vector* to, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_CubicTo_Func */ - /* */ - /* */ - /* A function pointer type used to describe the signature of a `cubic */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `cubic to' is emitted to indicate a third-order Bezier arc. */ - /* */ - /* */ - /* control1 :: A pointer to the first Bezier control point. */ - /* */ - /* control2 :: A pointer to the second Bezier control point. */ - /* */ - /* to :: A pointer to the target end point. */ - /* */ - /* user :: A typeless pointer which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* */ - /* Error code. 0 means success. */ - /* */ - typedef int (*FT_Outline_CubicTo_Func)( FT_Vector* control1, - FT_Vector* control2, - FT_Vector* to, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Funcs */ - /* */ - /* */ - /* A structure to hold various function pointers used during outline */ - /* decomposition in order to emit segments, conic, and cubic Beziers, */ - /* as well as `move to' and `close to' operations. */ - /* */ - /* */ - /* move_to :: The `move to' emitter. */ - /* */ - /* line_to :: The segment emitter. */ - /* */ - /* conic_to :: The second-order Bezier arc emitter. */ - /* */ - /* cubic_to :: The third-order Bezier arc emitter. */ - /* */ - /* shift :: The shift that is applied to coordinates before they */ - /* are sent to the emitter. */ - /* */ - /* delta :: The delta that is applied to coordinates before they */ - /* are sent to the emitter, but after the shift. */ - /* */ - /* */ - /* The point coordinates sent to the emitters are the transformed */ - /* version of the original coordinates (this is important for high */ - /* accuracy during scan-conversion). The transformation is simple: */ - /* */ - /* x' = (x << shift) - delta */ - /* y' = (x << shift) - delta */ - /* */ - /* Set the value of `shift' and `delta' to 0 to get the original */ - /* point coordinates. */ - /* */ - typedef struct FT_Outline_Funcs_ - { - FT_Outline_MoveTo_Func move_to; - FT_Outline_LineTo_Func line_to; - FT_Outline_ConicTo_Func conic_to; - FT_Outline_CubicTo_Func cubic_to; - - int shift; - FT_Pos delta; - - } FT_Outline_Funcs; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_IMAGE_TAG */ - /* */ - /* */ - /* This macro converts four letter tags into an unsigned long. */ - /* */ -#define FT_IMAGE_TAG( _x1, _x2, _x3, _x4 ) \ - ( ( (unsigned long)_x1 << 24 ) | \ - ( (unsigned long)_x2 << 16 ) | \ - ( (unsigned long)_x3 << 8 ) | \ - (unsigned long)_x4 ) - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Glyph_Format */ - /* */ - /* */ - /* An enumeration type used to describe the format of a given glyph */ - /* image. Note that this version of FreeType only supports two image */ - /* formats, even though future font drivers will be able to register */ - /* their own format. */ - /* */ - /* */ - /* ft_glyph_format_composite :: The glyph image is a composite of */ - /* several other images. This glyph */ - /* format is _only_ used with the */ - /* FT_LOAD_FLAG_NO_RECURSE flag (XXX: */ - /* Which is currently unimplemented). */ - /* */ - /* ft_glyph_format_bitmap :: The glyph image is a bitmap, and can */ - /* be described as a FT_Bitmap. */ - /* */ - /* ft_glyph_format_outline :: The glyph image is a vectorial image */ - /* made of bezier control points, and */ - /* can be described as a FT_Outline. */ - /* */ - /* ft_glyph_format_plotter :: The glyph image is a vectorial image */ - /* made of plotter lines (some T1 fonts */ - /* like Hershey contain glyph in this */ - /* format). */ - /* */ - typedef enum FT_Glyph_Format_ - { - ft_glyph_format_none = 0, - ft_glyph_format_composite = FT_IMAGE_TAG( 'c', 'o', 'm', 'p' ), - ft_glyph_format_bitmap = FT_IMAGE_TAG( 'b', 'i', 't', 's' ), - ft_glyph_format_outline = FT_IMAGE_TAG( 'o', 'u', 't', 'l' ), - ft_glyph_format_plotter = FT_IMAGE_TAG( 'p', 'l', 'o', 't' ) - - } FT_Glyph_Format; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** R A S T E R D E F I N I T I O N S *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* A raster is a scan converter, in charge of rendering an outline into */ - /* a a bitmap. This section contains the public API for rasters. */ - /* */ - /* Note that in FreeType 2, all rasters are now encapsulated within */ - /* specific modules called `renderers'. See `freetype/ftrender.h' for */ - /* more details on renderers. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster */ - /* */ - /* */ - /* A handle (pointer) to a raster object. Each object can be used */ - /* independently to convert an outline into a bitmap or pixmap. */ - /* */ - typedef struct FT_RasterRec_* FT_Raster; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Span */ - /* */ - /* */ - /* A structure used to model a single span of gray (or black) pixels */ - /* when rendering a monochrome or anti-aliased bitmap. */ - /* */ - /* */ - /* x :: The span's horizontal start position. */ - /* */ - /* len :: The span's length in pixels. */ - /* */ - /* coverage :: The span color/coverage, ranging from 0 (background) */ - /* to 255 (foreground). Only used for anti-aliased */ - /* rendering. */ - /* */ - /* */ - /* This structure is used by the span drawing callback type named */ - /* FT_Raster_Span_Func(), which takes the y-coordinate of the span as */ - /* a parameter. */ - /* */ - /* The coverage value is always between 0 and 255, even if the number */ - /* of gray levels have been set through FT_Set_Gray_Levels(). */ - /* */ - typedef struct FT_Span_ - { - short x; - unsigned short len; - unsigned char coverage; - - } FT_Span; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Span_Func */ - /* */ - /* */ - /* A function used as a call-back by the anti-aliased renderer in */ - /* order to let client applications draw themselves the gray pixel */ - /* spans on each scan line. */ - /* */ - /* */ - /* y :: The scanline's y-coordinate. */ - /* */ - /* count :: The number of spans to draw on this scanline. */ - /* */ - /* spans :: A table of `count' spans to draw on the scanline. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* */ - /* This callback allows client applications to directly render the */ - /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ - /* */ - /* This can be used to write anti-aliased outlines directly to a */ - /* given background bitmap, and even perform translucency. */ - /* */ - /* Note that the `count' field cannot be greater than a fixed value */ - /* defined by the FT_MAX_GRAY_SPANS configuration macro in */ - /* ftoption.h. By default, this value is set to 32, which means that */ - /* if there are more than 32 spans on a given scanline, the callback */ - /* will be called several times with the same `y' parameter in order */ - /* to draw all callbacks. */ - /* */ - /* Otherwise, the callback is only called once per scan-line, and */ - /* only for those scanlines that do have `gray' pixels on them. */ - /* */ - typedef void (*FT_Raster_Span_Func)( int y, - int count, - FT_Span* spans, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_BitTest_Func */ - /* */ - /* */ - /* A function used as a call-back by the monochrome scan-converter */ - /* to test whether a given target pixel is already set to the drawing */ - /* `color'. These tests are crucial to implement drop-out control */ - /* per-se the TrueType spec. */ - /* */ - /* */ - /* y :: The pixel's y-coordinate. */ - /* */ - /* x :: The pixel's x-coordinate. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* */ - /* 1 if the pixel is `set', 0 otherwise. */ - /* */ - typedef int (*FT_Raster_BitTest_Func)( int y, - int x, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_BitSet_Func */ - /* */ - /* */ - /* A function used as a call-back by the monochrome scan-converter */ - /* to set an individual target pixel. This is crucial to implement */ - /* drop-out control according to the TrueType specification. */ - /* */ - /* */ - /* y :: The pixel's y-coordinate. */ - /* */ - /* x :: The pixel's x-coordinate. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* */ - /* 1 if the pixel is `set', 0 otherwise. */ - /* */ - typedef void (*FT_Raster_BitSet_Func)( int y, - int x, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Flag */ - /* */ - /* */ - /* An enumeration to list the bit flags as used in the `flags' field */ - /* of a FT_Raster_Params structure. */ - /* */ - /* */ - /* ft_raster_flag_default :: This value is 0. */ - /* */ - /* ft_raster_flag_aa :: Requests the rendering of an */ - /* anti-aliased glyph bitmap. If unset, a */ - /* monchrome bitmap will be rendered. */ - /* */ - /* ft_raster_flag_direct :: Requests direct rendering over the */ - /* target bitmap. Direct rendering uses */ - /* user-provided callbacks in order to */ - /* perform direct drawing or composition */ - /* over an existing bitmap. If this bit is */ - /* unset, the content of the target bitmap */ - /* *must be zeroed*! */ - /* */ - typedef enum - { - ft_raster_flag_default = 0, - ft_raster_flag_aa = 1, - ft_raster_flag_direct = 2 - - } FT_Raster_Flag; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Params */ - /* */ - /* */ - /* A structure to hold the arguments used by a raster's render */ - /* function. */ - /* */ - /* */ - /* target :: The target bitmap. */ - /* */ - /* source :: A pointer to the source glyph image (e.g. an */ - /* FT_Outline). */ - /* */ - /* flags :: The rendering flags. */ - /* */ - /* gray_spans :: The gray span drawing callback. */ - /* */ - /* black_spans :: The black span drawing callback. */ - /* */ - /* bit_test :: The bit test callback. */ - /* */ - /* bit_set :: The bit set callback. */ - /* */ - /* user :: User-supplied data that is passed to each drawing */ - /* callback. */ - /* */ - /* */ - /* An anti-aliased glyph bitmap is drawn if the ft_raster_flag_aa bit */ - /* flag is set in the `flags' field, otherwise a monochrome bitmap */ - /* will be generated. */ - /* */ - /* If the ft_raster_flag_direct bit flag is set in `flags', the */ - /* raster will call the `gray_spans' callback to draw gray pixel */ - /* spans, in the case of an aa glyph bitmap, it will call */ - /* `black_spans', and `bit_test' and `bit_set' in the case of a */ - /* monochrome bitmap. This allows direct composition over a */ - /* pre-existing bitmap through user-provided callbacks to perform the */ - /* span drawing/composition. */ - /* */ - /* Note that the `bit_test' and `bit_set' callbacks are required when */ - /* rendering a monochrome bitmap, as they are crucial to implement */ - /* correct drop-out control as defined in the TrueType specification. */ - /* */ - typedef struct FT_Raster_Params_ - { - FT_Bitmap* target; - void* source; - int flags; - FT_Raster_Span_Func gray_spans; - FT_Raster_Span_Func black_spans; - FT_Raster_BitTest_Func bit_test; - FT_Raster_BitSet_Func bit_set; - void* user; - - } FT_Raster_Params; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_New_Func */ - /* */ - /* */ - /* A function used to create a new raster object. */ - /* */ - /* */ - /* memory :: A handle to the memory allocator. */ - /* */ - /* */ - /* raster :: A handle to the new raster object. */ - /* */ - /* */ - /* Error code. 0 means success. */ - /* */ - /* */ - /* The `memory' parameter is a typeless pointer in order to avoid */ - /* un-wanted dependencies on the rest of the FreeType code. In */ - /* practice, it is a FT_Memory, i.e., a handle to the standard */ - /* FreeType memory allocator. However, this field can be completely */ - /* ignored by a given raster implementation. */ - /* */ - typedef int (*FT_Raster_New_Func)( void* memory, - FT_Raster* raster ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Done_Func */ - /* */ - /* */ - /* A function used to destroy a given raster object. */ - /* */ - /* */ - /* raster :: A handle to the raster object. */ - /* */ - typedef void (*FT_Raster_Done_Func)( FT_Raster raster ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Reset_Func */ - /* */ - /* */ - /* FreeType provides an area of memory called the `render pool', */ - /* available to all registered rasters. This pool can be freely used */ - /* during a given scan-conversion but is shared by all rasters. Its */ - /* content is thus transient. */ - /* */ - /* This function is called each time the render pool changes, or just */ - /* after a new raster object is created. */ - /* */ - /* */ - /* raster :: A handle to the new raster object. */ - /* */ - /* pool_base :: The address in memory of the render pool. */ - /* */ - /* pool_size :: The size in bytes of the render pool. */ - /* */ - /* */ - /* Rasters can ignore the render pool and rely on dynamic memory */ - /* allocation if they want to (a handle to the memory allocator is */ - /* passed to the raster constructor). However, this is not */ - /* recommended for efficiency purposes. */ - /* */ - typedef void (*FT_Raster_Reset_Func)( FT_Raster raster, - unsigned char* pool_base, - unsigned long pool_size ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Set_Mode_Func */ - /* */ - /* */ - /* This function is a generic facility to change modes or attributes */ - /* in a given raster. This can be used for debugging purposes, or */ - /* simply to allow implementation-specific `features' in a given */ - /* raster module. */ - /* */ - /* */ - /* raster :: A handle to the new raster object. */ - /* */ - /* mode :: A 4-byte tag used to name the mode or property. */ - /* */ - /* args :: A pointer to the new mode/property to use. */ - /* */ - typedef int (*FT_Raster_Set_Mode_Func)( FT_Raster raster, - unsigned long mode, - void* args ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Render_Func */ - /* */ - /* */ - /* Invokes a given raster to scan-convert a given glyph image into a */ - /* target bitmap. */ - /* */ - /* */ - /* raster :: A handle to the raster object. */ - /* */ - /* params :: A pointer to a FT_Raster_Params structure used to store */ - /* the rendering parameters. */ - /* */ - /* */ - /* Error code. 0 means success. */ - /* */ - /* */ - /* The exact format of the source image depends on the raster's glyph */ - /* format defined in its FT_Raster_Funcs structure. It can be an */ - /* FT_Outline or anything else in order to support a large array of */ - /* glyph formats. */ - /* */ - /* Note also that the render function can fail and return a */ - /* FT_Err_Unimplemented_Feature error code if the raster used does */ - /* not support direct composition. */ - /* */ - /* XXX: For now, the standard raster doesn't support direct */ - /* composition but this should change for the final release (see */ - /* the files demos/src/ftgrays.c and demos/src/ftgrays2.c for */ - /* examples of distinct implementations which support direct */ - /* composition). */ - /* */ - typedef int (*FT_Raster_Render_Func)( FT_Raster raster, - FT_Raster_Params* params ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Raster_Funcs */ - /* */ - /* */ - /* A structure used to describe a given raster class to the library. */ - /* */ - /* */ - /* glyph_format :: The supported glyph format for this raster. */ - /* */ - /* raster_new :: The raster constructor. */ - /* */ - /* raster_reset :: Used to reset the render pool within the raster. */ - /* */ - /* raster_render :: A function to render a glyph into a given bitmap. */ - /* */ - /* raster_done :: The raster destructor. */ - /* */ - typedef struct FT_Raster_Funcs_ - { - FT_Glyph_Format glyph_format; - FT_Raster_New_Func raster_new; - FT_Raster_Reset_Func raster_reset; - FT_Raster_Set_Mode_Func raster_set_mode; - FT_Raster_Render_Func raster_render; - FT_Raster_Done_Func raster_done; - - } FT_Raster_Funcs; - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTIMAGE_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftmm.h b/src/freetype/freetype/ftmm.h deleted file mode 100644 index db5db0464c..0000000000 --- a/src/freetype/freetype/ftmm.h +++ /dev/null @@ -1,175 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmm.h */ -/* */ -/* FreeType Multiple Master font interface (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTMM_H -#define FTMM_H - -#include - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MM_Axis */ - /* */ - /* */ - /* A simple structure used to model a given axis in design space for */ - /* Multiple Masters fonts. */ - /* */ - /* */ - /* name :: The axis's name. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ - typedef struct FT_MM_Axis_ - { - FT_String* name; - FT_Long minimum; - FT_Long maximum; - - } FT_MM_Axis; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Multi_Master */ - /* */ - /* */ - /* A structure used to model the axes and space of a Multiple Masters */ - /* font. */ - /* */ - /* */ - /* num_axis :: Number of axes. Cannot exceed 4. */ - /* */ - /* num_designs :: Number of designs; should ne normally 2^num_axis */ - /* even though the Type 1 specification strangely */ - /* allows for intermediate designs to be present. This */ - /* number cannot exceed 16. */ - /* */ - /* axis :: A table of axis descriptors. */ - /* */ - typedef struct FT_Multi_Master_ - { - FT_UInt num_axis; - FT_UInt num_designs; - FT_MM_Axis axis[T1_MAX_MM_AXIS]; - - } FT_Multi_Master; - - - typedef FT_Error (*FT_Get_MM_Func)( FT_Face face, - FT_Multi_Master* master ); - - typedef FT_Error (*FT_Set_MM_Design_Func)( FT_Face face, - FT_UInt num_coords, - FT_Long* coords ); - - typedef FT_Error (*FT_Set_MM_Blend_Func)( FT_Face face, - FT_UInt num_coords, - FT_Long* coords ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Multi_Master */ - /* */ - /* */ - /* Retrieves the Multiple Master descriptor of a given font. */ - /* */ - /* */ - /* face :: A handle to the source face. */ - /* */ - /* */ - /* master :: The Multiple Masters descriptor. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Get_Multi_Master( FT_Face face, - FT_Multi_Master* master ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_MM_Design_Coordinates */ - /* */ - /* */ - /* For Multiple Masters fonts, choose an interpolated font design */ - /* through design coordinates. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Set_MM_Design_Coordinates( - FT_Face face, - FT_UInt num_coords, - FT_Long* coords ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_MM_Blend_Coordinates */ - /* */ - /* */ - /* For Multiple Masters fonts, choose an interpolated font design */ - /* through normalized blend coordinates. */ - /* */ - /* */ - /* 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). */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Set_MM_Blend_Coordinates( - FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - -#ifdef __cplusplus - } -#endif - -#endif /* FTMM_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftmodule.h b/src/freetype/freetype/ftmodule.h deleted file mode 100644 index 3c09aa2afd..0000000000 --- a/src/freetype/freetype/ftmodule.h +++ /dev/null @@ -1,274 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmodule.h */ -/* */ -/* FreeType modules public interface (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTMODULE_H -#define FTMODULE_H - -#include - - -#ifdef __cplusplus - extern "C" { -#endif - - - /* module bit flags */ - typedef enum FT_Module_Flags_ - { - ft_module_font_driver = 1, /* this module is a font driver */ - ft_module_renderer = 2, /* this module is a renderer */ - ft_module_hinter = 4, /* this module is a glyph hinter */ - ft_module_styler = 8, /* this module is a styler */ - - ft_module_driver_scalable = 0x100, /* the driver supports scalable */ - /* fonts */ - ft_module_driver_no_outlines = 0x200, /* the driver does not support */ - /* vector outlines */ - ft_module_driver_has_hinter = 0x400 /* the driver provides its own */ - /* hinter */ - - } FT_Module_Flags; - - - typedef void (*FT_Module_Interface)( void ); - - typedef FT_Error (*FT_Module_Constructor)( FT_Module module ); - - typedef void (*FT_Module_Destructor)( FT_Module module ); - - typedef FT_Module_Interface (*FT_Module_Requester)( FT_Module module, - const char* name ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Module_Class */ - /* */ - /* */ - /* The module class descriptor. */ - /* */ - /* */ - /* module_flags :: Bit flags describing the module. */ - /* */ - /* module_size :: The size of one module object/instance in */ - /* bytes. */ - /* */ - /* module_name :: The name of the module. */ - /* */ - /* module_version :: The version, as a 16.16 fixed number */ - /* (major.minor). */ - /* */ - /* module_requires :: The version of FreeType this module requires */ - /* (starts at version 2.0, i.e 0x20000) */ - /* */ - /* module_init :: A function used to initialize (not create) a */ - /* new module object. */ - /* */ - /* module_done :: A function used to finalize (not destroy) a */ - /* given module object */ - /* */ - /* get_interface :: Queries a given module for a specific */ - /* interface by name. */ - /* */ - typedef struct FT_Module_Class_ - { - FT_ULong module_flags; - FT_Int module_size; - const FT_String* module_name; - FT_Fixed module_version; - FT_Fixed module_requires; - - const void* module_interface; - - FT_Module_Constructor module_init; - FT_Module_Destructor module_done; - FT_Module_Requester get_interface; - - } FT_Module_Class; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Add_Module */ - /* */ - /* */ - /* Adds a new module to a given library instance. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* clazz :: A pointer to class descriptor for the module. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Add_Module( FT_Library library, - const FT_Module_Class* clazz ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Module */ - /* */ - /* */ - /* Finds a module by its name. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* */ - /* A module handle. 0 if none was found. */ - /* */ - /* */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for :-) */ - /* */ - FT_EXPORT_DEF( FT_Module ) FT_Get_Module( FT_Library library, - const char* module_name ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Remove_Module */ - /* */ - /* */ - /* Removes a given module from a library instance. */ - /* */ - /* */ - /* library :: A handle to a library object. */ - /* */ - /* module :: A handle to a module object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The module object is destroyed by the function in case of success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Remove_Module( FT_Library library, - FT_Module module ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_New_Library */ - /* */ - /* */ - /* This function is used to create a new FreeType library instance */ - /* from a given memory object. It is thus possible to use libraries */ - /* with distinct memory allocators within the same program. */ - /* */ - /* */ - /* memory :: A handle to the original memory object. */ - /* */ - /* */ - /* alibrary :: A pointer to handle of a new library object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_New_Library( FT_Memory memory, - FT_Library* library ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Done_Library */ - /* */ - /* */ - /* Discards a given library object. This closes all drivers and */ - /* discards all resource objects. */ - /* */ - /* */ - /* library :: A handle to the target library. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Done_Library( FT_Library library ); - - - - typedef void (*FT_DebugHook_Func)( void* arg ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Debug_Hook */ - /* */ - /* */ - /* Sets a debug hook function for debugging the interpreter of a font */ - /* format. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* hook_index :: The index of the debug hook. You should use the */ - /* values defined in ftobjs.h, e.g. */ - /* FT_DEBUG_HOOK_TRUETYPE */ - /* */ - /* debug_hook :: The function used to debug the interpreter. */ - /* */ - /* */ - /* Currently, four debug hook slots are available, but only two (for */ - /* the TrueType and the Type 1 interpreter) are defined. */ - /* */ - FT_EXPORT_DEF( void ) FT_Set_Debug_Hook( FT_Library library, - FT_UInt hook_index, - FT_DebugHook_Func debug_hook ); - - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Add_Default_Modules */ - /* */ - /* */ - /* 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). */ - /* */ - /* */ - /* library :: A handle to a new library object. */ - /* */ - FT_EXPORT_DEF( void ) FT_Add_Default_Modules( FT_Library library ); - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTMODULE_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftnames.h b/src/freetype/freetype/ftnames.h deleted file mode 100644 index 2969214b9b..0000000000 --- a/src/freetype/freetype/ftnames.h +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftnames.h */ -/* */ -/* Simple interface to access SFNT name tables (which are used */ -/* to hold font names, copyright info, notices, etc.). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTNAMES_H -#define FTNAMES_H - - -#include - - - typedef struct FT_SfntName_ - { - FT_UShort platform_id; - FT_UShort encoding_id; - FT_UShort language_id; - FT_UShort name_id; - - FT_Byte* string; - FT_UInt string_len; /* in bytes */ - - } FT_SfntName; - - - FT_EXPORT_DEF( FT_UInt ) FT_Get_Sfnt_Name_Count( FT_Face face ); - - FT_EXPORT_DEF( FT_Error ) FT_Get_Sfnt_Name( FT_Face face, - FT_UInt index, - FT_SfntName* aname ); - - -#endif /* FTNAMES_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftoutln.h b/src/freetype/freetype/ftoutln.h deleted file mode 100644 index 1e448bd0ec..0000000000 --- a/src/freetype/freetype/ftoutln.h +++ /dev/null @@ -1,344 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftoutln.h */ -/* */ -/* Support for the FT_Outline type used to store glyph shapes of */ -/* most scalable font formats (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTOUTLN_H -#define FTOUTLN_H - - -#include - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Decompose */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* FreeType error code. 0 means sucess. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Outline_Decompose( - FT_Outline* outline, - FT_Outline_Funcs* interface, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_New */ - /* */ - /* */ - /* Creates a new outline of a given size. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* outline :: A handle to the new outline. NULL in case of */ - /* error. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* No. */ - /* */ - /* */ - /* The reason why this function takes a `library' parameter is simply */ - /* to use the library's memory allocator. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Outline_New( FT_Library library, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline* outline ); - - - FT_EXPORT_DEF( FT_Error ) FT_Outline_New_Internal( - FT_Memory memory, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Done */ - /* */ - /* */ - /* Destroys an outline created with FT_Outline_New(). */ - /* */ - /* */ - /* library :: A handle of the library object used to allocate the */ - /* outline. */ - /* */ - /* outline :: A pointer to the outline object to be discarded. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* No. */ - /* */ - /* */ - /* If the outline's `owner' field is not set, only the outline */ - /* descriptor will be released. */ - /* */ - /* The reason why this function takes an `outline' parameter is */ - /* simply to use FT_Free(). */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Outline_Done( FT_Library library, - FT_Outline* outline ); - - - FT_EXPORT_DEF( FT_Error ) FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Get_CBox */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* */ - /* cbox :: The outline's control box. */ - /* */ - /* */ - /* Yes. */ - /* */ - FT_EXPORT_DEF( void ) FT_Outline_Get_CBox( FT_Outline* outline, - FT_BBox* cbox ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Translate */ - /* */ - /* */ - /* Applies a simple translation to the points of an outline. */ - /* */ - /* */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* xOffset :: The horizontal offset. */ - /* */ - /* yOffset :: The vertical offset. */ - /* */ - /* */ - /* Yes. */ - /* */ - FT_EXPORT_DEF( void ) FT_Outline_Translate( FT_Outline* outline, - FT_Pos xOffset, - FT_Pos yOffset ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Copy */ - /* */ - /* */ - /* Copies an outline into another one. Both objects must have the */ - /* same sizes (number of points & number of contours) when this */ - /* function is called. */ - /* */ - /* */ - /* source :: A handle to the source outline. */ - /* */ - /* */ - /* target :: A handle to the target outline. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Outline_Copy( FT_Outline* source, - FT_Outline* target ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Vector_Transform */ - /* */ - /* */ - /* Transforms a single vector through a 2x2 matrix. */ - /* */ - /* */ - /* vector :: The target vector to transform. */ - /* */ - /* */ - /* matrix :: A pointer to the source 2x2 matrix. */ - /* */ - /* */ - /* Yes. */ - /* */ - /* */ - /* The result is undefined if either `vector' or `matrix' is invalid. */ - /* */ - FT_EXPORT_DEF( void ) FT_Outline_Transform( FT_Outline* outline, - FT_Matrix* matrix ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Reverse */ - /* */ - /* */ - /* Reverses the drawing direction of an outline. This is used to */ - /* ensure consistent fill conventions for mirrored glyphs. */ - /* */ - /* */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* */ - /* This functions toggles the bit flag `ft_outline_reverse_fill' in */ - /* the outline's `flags' field. */ - /* */ - /* It shouldn't be used by a normal client application, unless it */ - /* knows what it is doing. */ - /* */ - FT_EXPORT_DEF( void ) FT_Outline_Reverse( FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Get_Bitmap */ - /* */ - /* */ - /* Renders an outline within a bitmap. The outline's image is simply */ - /* OR-ed to the target bitmap. */ - /* */ - /* */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* map :: A pointer to the target bitmap descriptor. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* YES. Rendering is synchronized, so that concurrent calls to the */ - /* scan-line converter will be serialized. */ - /* */ - /* */ - /* This function does NOT CREATE the bitmap, it only renders an */ - /* outline image within the one you pass to it! */ - /* */ - /* It will use the raster correponding to the default glyph format. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Outline_Get_Bitmap( FT_Library library, - FT_Outline* outline, - FT_Bitmap* bitmap ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Outline_Render */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* YES. Rendering is synchronized, so that concurrent calls to the */ - /* scan-line converter will be serialized. */ - /* */ - /* */ - /* You should know what you are doing and how FT_Raster_Params works */ - /* to use this function. */ - /* */ - /* The field `params.source' will be set to `outline' before the scan */ - /* converter is called, which means that the value you give to it is */ - /* actually ignored. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FT_Outline_Render( FT_Library library, - FT_Outline* outline, - FT_Raster_Params* params ); - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTOUTLN_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftrender.h b/src/freetype/freetype/ftrender.h deleted file mode 100644 index fe5acd2ce6..0000000000 --- a/src/freetype/freetype/ftrender.h +++ /dev/null @@ -1,191 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftrender.h */ -/* */ -/* FreeType renderer modules public interface (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTRENDER_H -#define FTRENDER_H - -#include -#include - - -#ifdef __cplusplus - extern "C" { -#endif - - - /* create a new glyph object */ - typedef FT_Error (*FT_Glyph_Init_Func)( FT_Glyph glyph, - FT_GlyphSlot slot ); - - /* destroys a given glyph object */ - typedef void (*FT_Glyph_Done_Func)( FT_Glyph glyph ); - - typedef void (*FT_Glyph_Transform_Func)( FT_Glyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ); - - typedef void (*FT_Glyph_BBox_Func)( FT_Glyph glyph, - FT_BBox* abbox ); - - typedef FT_Error (*FT_Glyph_Copy_Func)( FT_Glyph source, - FT_Glyph target ); - - typedef FT_Error (*FT_Glyph_Prepare_Func)( FT_Glyph glyph, - FT_GlyphSlot slot ); - - struct FT_Glyph_Class_ - { - FT_UInt glyph_size; - FT_Glyph_Format glyph_format; - FT_Glyph_Init_Func glyph_init; - FT_Glyph_Done_Func glyph_done; - FT_Glyph_Copy_Func glyph_copy; - FT_Glyph_Transform_Func glyph_transform; - FT_Glyph_BBox_Func glyph_bbox; - FT_Glyph_Prepare_Func glyph_prepare; - }; - - - typedef FT_Error (*FTRenderer_render)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_UInt mode, - FT_Vector* origin ); - - typedef FT_Error (*FTRenderer_transform)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_Matrix* matrix, - FT_Vector* delta ); - - typedef void (*FTRenderer_getCBox)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_BBox* cbox ); - - typedef FT_Error (*FTRenderer_setMode)( FT_Renderer renderer, - FT_ULong mode_tag, - FT_Pointer mode_ptr ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Renderer_Class */ - /* */ - /* */ - /* The renderer module class descriptor. */ - /* */ - /* */ - /* root :: The root FT_Module_Class fields. */ - /* */ - /* glyph_format :: The glyph image format this renderer handles. */ - /* */ - /* render_glyph :: A method used to render the image that is in a */ - /* given glyph slot into a bitmap. */ - /* */ - /* set_mode :: A method used to pass additional parameters. */ - /* */ - /* raster_class :: For `ft_glyph_format_outline' renderers only, this */ - /* is a pointer to its raster's class. */ - /* */ - /* raster :: For `ft_glyph_format_outline' renderers only. this */ - /* is a pointer to the corresponding raster object, */ - /* if any. */ - /* */ - typedef struct FT_Renderer_Class_ - { - FT_Module_Class root; - - FT_Glyph_Format glyph_format; - - FTRenderer_render render_glyph; - FTRenderer_transform transform_glyph; - FTRenderer_getCBox get_glyph_cbox; - FTRenderer_setMode set_mode; - - FT_Raster_Funcs* raster_class; - - } FT_Renderer_Class; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Renderer */ - /* */ - /* */ - /* Retrieves the current renderer for a given glyph format. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* format :: The glyph format. */ - /* */ - /* */ - /* A renderer handle. 0 if none found. */ - /* */ - /* */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - /* To add a new renderer, simply use FT_Add_Module(). To retrieve a */ - /* renderer by its name, use FT_Get_Module(). */ - /* */ - FT_EXPORT_DEF( FT_Renderer ) FT_Get_Renderer( FT_Library library, - FT_Glyph_Format format ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Set_Renderer */ - /* */ - /* */ - /* Sets the current renderer to use, and set additional mode. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* renderer :: A handle to the renderer object. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* parameters :: Additional parameters. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* In case of success, the renderer will be used to convert glyph */ - /* images in the renderer's known format into bitmaps. */ - /* */ - /* This doesn't change the current renderer for other formats. */ - /* */ - FT_EXPORT_DEF(FT_Error) FT_Set_Renderer( FT_Library library, - FT_Renderer renderer, - FT_UInt num_params, - FT_Parameter* parameters ); - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTRENDER_H */ - - -/* END */ diff --git a/src/freetype/freetype/ftsystem.h b/src/freetype/freetype/ftsystem.h deleted file mode 100644 index bc74bced22..0000000000 --- a/src/freetype/freetype/ftsystem.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsystem.h */ -/* */ -/* FreeType low-level system interface definition (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTSYSTEM_H -#define FTSYSTEM_H - - - /*************************************************************************/ - /* */ - /* M E M O R Y M A N A G E M E N T */ - /* */ - /*************************************************************************/ - - - typedef struct FT_MemoryRec_* FT_Memory; - - - typedef void* (*FT_Alloc_Func)( FT_Memory memory, - long size ); - - typedef void (*FT_Free_Func)( FT_Memory memory, - void* block ); - - typedef void* (*FT_Realloc_Func)( FT_Memory memory, - long cur_size, - long new_size, - void* block ); - - - struct FT_MemoryRec_ - { - void* user; - FT_Alloc_Func alloc; - FT_Free_Func free; - FT_Realloc_Func realloc; - }; - - - /*************************************************************************/ - /* */ - /* I / O M A N A G E M E N T */ - /* */ - /*************************************************************************/ - - - typedef union FT_StreamDesc_ - { - long value; - void* pointer; - - } FT_StreamDesc; - - - typedef struct FT_StreamRec_* FT_Stream; - - - typedef unsigned long (*FT_Stream_IO)( FT_Stream stream, - unsigned long offset, - unsigned char* buffer, - unsigned long count ); - - typedef void (*FT_Stream_Close)( FT_Stream stream ); - - - struct FT_StreamRec_ - { - unsigned char* base; - unsigned long size; - unsigned long pos; - - FT_StreamDesc descriptor; - FT_StreamDesc pathname; /* ignored by FreeType -- */ - /* useful for debugging */ - FT_Stream_IO read; - FT_Stream_Close close; - - FT_Memory memory; - unsigned char* cursor; - unsigned char* limit; - }; - - -#endif /* FTSYSTEM_H */ - - -/* END */ diff --git a/src/freetype/freetype/fttypes.h b/src/freetype/freetype/fttypes.h deleted file mode 100644 index ec909061de..0000000000 --- a/src/freetype/freetype/fttypes.h +++ /dev/null @@ -1,400 +0,0 @@ -/***************************************************************************/ -/* */ -/* fttypes.h */ -/* */ -/* FreeType simple types definitions (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTTYPES_H -#define FTTYPES_H - - -#include -#include - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Bool */ - /* */ - /* */ - /* A typedef of unsigned char, used for simple booleans. */ - /* */ - typedef unsigned char FT_Bool; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FWord */ - /* */ - /* */ - /* A signed 16-bit integer used to store a distance in original font */ - /* units. */ - /* */ - typedef signed short FT_FWord; /* distance in FUnits */ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UFWord */ - /* */ - /* */ - /* An unsigned 16-bit integer used to store a distance in original */ - /* font units. */ - /* */ - typedef unsigned short FT_UFWord; /* unsigned distance */ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Char */ - /* */ - /* */ - /* A simple typedef for the _signed_ char type. */ - /* */ - typedef signed char FT_Char; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Byte */ - /* */ - /* */ - /* A simple typedef for the _unsigned_ char type. */ - /* */ - typedef unsigned char FT_Byte; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_String */ - /* */ - /* */ - /* A simple typedef for the char type, usually used for strings. */ - /* */ - typedef char FT_String; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Short */ - /* */ - /* */ - /* A typedef for signed short. */ - /* */ - typedef signed short FT_Short; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UShort */ - /* */ - /* */ - /* A typedef for unsigned short. */ - /* */ - typedef unsigned short FT_UShort; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Int */ - /* */ - /* */ - /* A typedef for the int type. */ - /* */ - typedef int FT_Int; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt */ - /* */ - /* */ - /* A typedef for the unsigned int type. */ - /* */ - typedef unsigned int FT_UInt; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Long */ - /* */ - /* */ - /* A typedef for signed long. */ - /* */ - typedef signed long FT_Long; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_ULong */ - /* */ - /* */ - /* A typedef for unsigned long. */ - /* */ - typedef unsigned long FT_ULong; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_F2Dot14 */ - /* */ - /* */ - /* A signed 2.14 fixed float type used for unit vectors. */ - /* */ - typedef signed short FT_F2Dot14; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_F26Dot6 */ - /* */ - /* */ - /* A signed 26.6 fixed float type used for vectorial pixel */ - /* coordinates. */ - /* */ - typedef signed long FT_F26Dot6; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Fixed */ - /* */ - /* */ - /* This type is used to store 16.16 fixed float values, like scales */ - /* or matrix coefficients. */ - /* */ - typedef signed long FT_Fixed; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Error */ - /* */ - /* */ - /* The FreeType error code type. A value of 0 is always interpreted */ - /* as a successful operation. */ - /* */ - typedef int FT_Error; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Pointer */ - /* */ - /* */ - /* A simple typedef for a typeless pointer. */ - /* */ - typedef void* FT_Pointer; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UnitVector */ - /* */ - /* */ - /* A simple structure used to store a 2D vector unit vector. Uses */ - /* FT_F2Dot14 types. */ - /* */ - /* */ - /* x :: Horizontal coordinate. */ - /* */ - /* y :: Vertical coordinate. */ - /* */ - typedef struct FT_UnitVector_ - { - FT_F2Dot14 x; - FT_F2Dot14 y; - - } FT_UnitVector; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Matrix */ - /* */ - /* */ - /* A simple structure used to store a 2x2 matrix. Coefficients are */ - /* in 16.16 fixed float format. The computation performed is: */ - /* */ - /* { */ - /* x' = x*xx + y*xy */ - /* y' = x*yx + y*yy */ - /* } */ - /* */ - /* */ - /* xx :: Matrix coefficient. */ - /* */ - /* xy :: Matrix coefficient. */ - /* */ - /* yx :: Matrix coefficient. */ - /* */ - /* yy :: Matrix coefficient. */ - /* */ - typedef struct FT_Matrix_ - { - FT_Fixed xx, xy; - FT_Fixed yx, yy; - - } FT_Matrix; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_BBox */ - /* */ - /* */ - /* A structure used to hold an outline's bounding box, i.e., the */ - /* coordinates of its extrema in the horizontal and vertical */ - /* directions. */ - /* */ - /* */ - /* xMin :: The horizontal minimum (left-most). */ - /* */ - /* yMin :: The vertical minimum (bottom-most). */ - /* */ - /* xMax :: The horizontal maximum (right-most). */ - /* */ - /* yMax :: The vertical maximum (top-most). */ - /* */ - typedef struct FT_BBox_ - { - FT_Pos xMin, yMin; - FT_Pos xMax, yMax; - - } FT_BBox; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_MAKE_TAG */ - /* */ - /* */ - /* This macro converts four letter tags which are used to label */ - /* TrueType tables into an unsigned long to be used within FreeType. */ - /* */ -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ - ( ( (FT_ULong)_x1 << 24 ) | \ - ( (FT_ULong)_x2 << 16 ) | \ - ( (FT_ULong)_x3 << 8 ) | \ - (FT_ULong)_x4 ) - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* L I S T M A N A G E M E N T */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_ListNode */ - /* */ - /* */ - /* Many elements and objects in FreeType are listed through a */ - /* FT_List record (see FT_ListRec). As its name suggests, a */ - /* FT_ListNode is a handle to a single list element. */ - /* */ - typedef struct FT_ListNodeRec_* FT_ListNode; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List */ - /* */ - /* */ - /* A handle to a list record (see FT_ListRec). */ - /* */ - typedef struct FT_ListRec_* FT_List; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_ListNodeRec */ - /* */ - /* */ - /* A structure used to hold a single list element. */ - /* */ - /* */ - /* prev :: The previous element in the list. NULL if first. */ - /* */ - /* next :: The next element in the list. NULL if last. */ - /* */ - /* data :: A typeless pointer to the listed object. */ - /* */ - typedef struct FT_ListNodeRec_ - { - FT_ListNode prev; - FT_ListNode next; - void* data; - - } FT_ListNodeRec; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_ListRec */ - /* */ - /* */ - /* A structure used to hold a simple doubly-linked list. These are */ - /* used in many parts of FreeType. */ - /* */ - /* */ - /* head :: The head (first element) of doubly-linked list. */ - /* */ - /* tail :: The tail (last element) of doubly-linked list. */ - /* */ - typedef struct FT_ListRec_ - { - FT_ListNode head; - FT_ListNode tail; - - } FT_ListRec; - - -#define FT_IS_EMPTY( list ) ( (list).head == 0 ) - - -#endif /* FTTYPES_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/autohint.h b/src/freetype/freetype/internal/autohint.h deleted file mode 100644 index 5d35a5dcd4..0000000000 --- a/src/freetype/freetype/internal/autohint.h +++ /dev/null @@ -1,195 +0,0 @@ -/***************************************************************************/ -/* */ -/* autohint.h */ -/* */ -/* High-level `autohint' module-specific interface (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The auto-hinter is used to load and automatically hint glyphs if a */ - /* format-specific hinter isn't available. */ - /* */ - /*************************************************************************/ - - -#ifndef AUTOHINT_H -#define AUTOHINT_H - - - /*************************************************************************/ - /* */ - /* A small technical note regarding automatic hinting in order to */ - /* clarify this module interface. */ - /* */ - /* An automatic hinter might compute two kinds of data for a given face: */ - /* */ - /* - global hints: Usually some metrics that describe global properties */ - /* of the face. It is computed by scanning more or less */ - /* agressively the glyphs in the face, and thus can be */ - /* very slow to compute (even if the size of global */ - /* hints is really small). */ - /* */ - /* - glyph hints: These describe some important features of the glyph */ - /* outline, as well as how to align them. They are */ - /* generally much faster to compute than global hints. */ - /* */ - /* The current FreeType auto-hinter does a pretty good job while */ - /* performing fast computations for both global and glyph hints. */ - /* However, we might be interested in introducing more complex and */ - /* powerful algorithms in the future, like the one described in the John */ - /* D. Hobby paper, which unfortunately requires a lot more horsepower. */ - /* */ - /* Because a sufficiently sophisticated font management system would */ - /* typically implement an LRU cache of opened face objects to reduce */ - /* memory usage, it is a good idea to be able to avoid recomputing */ - /* global hints every time the same face is re-opened. */ - /* */ - /* We thus provide the ability to cache global hints outside of the face */ - /* object, in order to speed up font re-opening time. Of course, this */ - /* feature is purely optional, so most client programs won't even notice */ - /* it. */ - /* */ - /* I initially thought that it would be a good idea to cache the glyph */ - /* hints too. However, my general idea now is that if you really need */ - /* to cache these too, you are simply in need of a new font format, */ - /* where all this information could be stored within the font file and */ - /* decoded on the fly. */ - /* */ - /*************************************************************************/ - - -#include - - - typedef struct FT_AutoHinterRec_ *FT_AutoHinter; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_AutoHinter_Get_Global_Func */ - /* */ - /* */ - /* Retrieves the global hints computed for a given face object the */ - /* resulting data is dissociated from the face and will survive a */ - /* call to FT_Done_Face(). It must be discarded through the API */ - /* FT_AutoHinter_Done_Global_Func(). */ - /* */ - /* */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* */ - /* global_hints :: A typeless pointer to the global hints. */ - /* */ - /* global_len :: The size in bytes of the global hints. */ - /* */ - typedef void (*FT_AutoHinter_Get_Global_Func)( - FT_AutoHinter hinter, - FT_Face face, - void** global_hints, - long* global_len ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_AutoHinter_Done_Global_Func */ - /* */ - /* */ - /* Discards the global hints retrieved through */ - /* FT_AutoHinter_Get_Global_Func(). This is the only way these hints */ - /* are freed from memory. */ - /* */ - /* */ - /* hinter :: A handle to the auto-hinter module. */ - /* */ - /* global :: A pointer to retrieved global hints to discard. */ - /* */ - typedef void (*FT_AutoHinter_Done_Global_Func)( FT_AutoHinter hinter, - void* global ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_AutoHinter_Reset_Func */ - /* */ - /* */ - /* This function is used to recompute the global metrics in a given */ - /* font. This is useful when global font data changes (e.g. Multiple */ - /* Masters fonts where blend coordinates change). */ - /* */ - /* */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the face. */ - /* */ - typedef void (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter, - FT_Face face ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_AutoHinter_Load_Func */ - /* */ - /* */ - /* This function is used to load, scale, and automatically hint a */ - /* glyph from a given face. */ - /* */ - /* */ - /* face :: A handle to the face. */ - /* glyph_index :: The glyph index. */ - /* load_flags :: The load flags. */ - /* */ - /* */ - /* This function is capable of loading composite glyphs by hinting */ - /* each sub-glyph independently (which improves quality). */ - /* */ - /* It will call the font driver with FT_Load_Glyph(), with */ - /* FT_LOAD_NO_SCALE set. */ - /* */ - typedef FT_Error (*FT_AutoHinter_Load_Func)( FT_AutoHinter hinter, - FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_ULong load_flags ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_AutoHinter_Interface */ - /* */ - /* */ - /* The auto-hinter module's interface. */ - /* */ - typedef struct FT_AutoHinter_Interface - { - FT_AutoHinter_Reset_Func reset_face; - FT_AutoHinter_Load_Func load_glyph; - - FT_AutoHinter_Get_Global_Func get_global_hints; - FT_AutoHinter_Done_Global_Func done_global_hints; - - } FT_AutoHinter_Interface; - - -#endif /* AUTOHINT_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftcalc.h b/src/freetype/freetype/internal/ftcalc.h deleted file mode 100644 index 99b6cfaf64..0000000000 --- a/src/freetype/freetype/internal/ftcalc.h +++ /dev/null @@ -1,123 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcalc.h */ -/* */ -/* Arithmetic computations (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTCALC_H -#define FTCALC_H - -#include -#include /* for LONG64 */ - -#ifdef __cplusplus - extern "C" { -#endif - - -#ifdef LONG64 - - - typedef INT64 FT_Int64; - -#define ADD_64( x, y, z ) z = (x) + (y) -#define MUL_64( x, y, z ) z = (FT_Int64)(x) * (y) - -#define DIV_64( x, y ) ( (x) / (y) ) - - -#ifdef FT_CONFIG_OPTION_OLD_CALCS - -#define SQRT_64( z ) FT_Sqrt64( z ) - - FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64 l ); - -#endif /* FT_CONFIG_OPTION_OLD_CALCS */ - - -#else /* LONG64 */ - - - typedef struct FT_Int64_ - { - FT_UInt32 lo; - FT_UInt32 hi; - - } FT_Int64; - - -#define ADD_64( x, y, z ) FT_Add64( &x, &y, &z ) -#define MUL_64( x, y, z ) FT_MulTo64( x, y, &z ) -#define DIV_64( x, y ) FT_Div64by32( &x, y ) - - - FT_EXPORT_DEF( void ) FT_Add64( FT_Int64* x, - FT_Int64* y, - FT_Int64* z ); - - FT_EXPORT_DEF( void ) FT_MulTo64( FT_Int32 x, - FT_Int32 y, - FT_Int64* z ); - - FT_EXPORT_DEF( FT_Int32 ) FT_Div64by32( FT_Int64* x, - FT_Int32 y ); - - -#ifdef FT_CONFIG_OPTION_OLD_CALCS - -#define SQRT_64( z ) FT_Sqrt64( &z ) - - FT_EXPORT_DEF( FT_Int32 ) FT_Sqrt64( FT_Int64* x ); - -#endif /* FT_CONFIG_OPTION_OLD_CALCS */ - - -#endif /* LONG64 */ - - -#ifndef FT_CONFIG_OPTION_OLD_CALCS - -#define SQRT_32( x ) FT_Sqrt32( x ) - - BASE_DEF( FT_Int32 ) FT_Sqrt32( FT_Int32 x ); - -#endif /* !FT_CONFIG_OPTION_OLD_CALCS */ - - - /*************************************************************************/ - /* */ - /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */ - /* */ - /*************************************************************************/ - - -#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 ) -#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 ) -#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 ) -#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 ) -#define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) ) - -#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \ - : ( -( ( 32 - (x) ) & -64 ) ) ) - - -#ifdef __cplusplus - } -#endif - -#endif /* FTCALC_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftdebug.h b/src/freetype/freetype/internal/ftdebug.h deleted file mode 100644 index 8b1e4dd5a5..0000000000 --- a/src/freetype/freetype/internal/ftdebug.h +++ /dev/null @@ -1,225 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftdebug.h */ -/* */ -/* Debugging and logging component (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTDEBUG_H -#define FTDEBUG_H - -#include /* for FT_DEBUG_LEVEL_TRACE, */ - /* FT_DEBUG_LEVEL_ERROR */ - -#ifdef __cplusplus - extern "C" { -#endif - - - /* A very stupid pre-processor trick. See K&R version 2 */ - /* section A12.3 for details... */ - /* */ - /* It is also described in the section `Separate */ - /* Expansion of Macro Arguments' in the info file */ - /* `cpp.info', describing GNU cpp. */ - /* */ -#define FT_CAT( x, y ) x ## y -#define FT_XCAT( x, y ) FT_CAT( x, y ) - - -#ifdef FT_DEBUG_LEVEL_TRACE - - - /* note that not all levels are used currently */ - - typedef enum FT_Trace_ - { - /* the first level must always be `trace_any' */ - trace_any = 0, - - /* base components */ - trace_aaraster, /* anti-aliasing raster (ftgrays.c) */ - trace_calc, /* calculations (ftcalc.c) */ - trace_extend, /* extension manager (ftextend.c) */ - trace_glyph, /* glyph manager (ftglyph.c) */ - trace_io, /* i/o monitoring (ftsystem.c) */ - trace_init, /* initialization (ftinit.c) */ - trace_list, /* list manager (ftlist.c) */ - trace_memory, /* memory manager (ftobjs.c) */ - trace_mm, /* MM interface (ftmm.c) */ - trace_objs, /* base objects (ftobjs.c) */ - trace_outline, /* outline management (ftoutln.c) */ - trace_raster, /* rasterizer (ftraster.c) */ - trace_stream, /* stream manager (ftstream.c) */ - - /* SFNT driver components */ - trace_sfobjs, /* SFNT object handler (sfobjs.c) */ - trace_ttcmap, /* charmap handler (ttcmap.c) */ - trace_ttload, /* basic TrueType tables (ttload.c) */ - trace_ttpost, /* PS table processing (ttpost.c) */ - trace_ttsbit, /* TrueType sbit handling (ttsbit.c) */ - - /* TrueType driver components */ - trace_ttdriver, /* TT font driver (ttdriver.c) */ - trace_ttgload, /* TT glyph loader (ttgload.c) */ - trace_ttinterp, /* bytecode interpreter (ttinterp.c) */ - trace_ttobjs, /* TT objects manager (ttobjs.c) */ - trace_ttpload, /* TT data/program loader (ttpload.c) */ - - /* Type 1 driver components */ - trace_t1driver, - trace_t1gload, - trace_t1hint, - trace_t1load, - trace_t1objs, - - /* experimental Type 1 driver components */ - trace_z1driver, - trace_z1gload, - trace_z1hint, - trace_z1load, - trace_z1objs, - trace_z1parse, - - /* Type 2 driver components */ - trace_t2driver, - trace_t2gload, - trace_t2load, - trace_t2objs, - trace_t2parse, - - /* CID driver components */ - trace_cidafm, - trace_ciddriver, - trace_cidgload, - trace_cidload, - trace_cidobjs, - trace_cidparse, - - /* Windows fonts component */ - trace_winfnt, - - /* the last level must always be `trace_max' */ - trace_max - - } FT_Trace; - - - /* declared in ftdebug.c */ - extern char ft_trace_levels[trace_max]; - - - /*************************************************************************/ - /* */ - /* IMPORTANT! */ - /* */ - /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */ - /* value before using any TRACE macro. */ - /* */ - /*************************************************************************/ - - -#define FT_TRACE( level, varformat ) \ - do \ - { \ - if ( ft_trace_levels[FT_COMPONENT] >= level ) \ - FT_XCAT( FT_Message, varformat ); \ - } while ( 0 ) - - - FT_EXPORT_DEF( void ) FT_SetTraceLevel( FT_Trace component, - char level ); - - -#elif defined( FT_DEBUG_LEVEL_ERROR ) - - -#define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */ - - -#else /* release mode */ - - -#define FT_Assert( condition ) do ; while ( 0 ) /* nothing */ - -#define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */ -#define FT_ERROR( varformat ) do ; while ( 0 ) /* nothing */ - - -#endif /* FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */ - - - /*************************************************************************/ - /* */ - /* Define macros and functions that are common to the debug and trace */ - /* modes. */ - /* */ - /* You need vprintf() to be able to compile ftdebug.c. */ - /* */ - /*************************************************************************/ - - -#if defined( FT_DEBUG_LEVEL_TRACE ) || defined( FT_DEBUG_LEVEL_ERROR ) - - -#include "stdio.h" /* for vprintf() */ - - -#define FT_Assert( condition ) \ - do \ - { \ - if ( !( condition ) ) \ - FT_Panic( "assertion failed on line %d of file %s\n", \ - __LINE__, __FILE__ ); \ - } while ( 0 ) - - /* print a message */ - FT_EXPORT_DEF( void ) FT_Message( const char* fmt, ... ); - - /* print a message and exit */ - FT_EXPORT_DEF( void ) FT_Panic( const char* fmt, ... ); - -#define FT_ERROR( varformat ) FT_XCAT( FT_Message, varformat ) - - -#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */ - - - /*************************************************************************/ - /* */ - /* You need two opening resp. closing parentheses! */ - /* */ - /* Example: FT_TRACE0(( "Value is %i", foo )) */ - /* */ - /*************************************************************************/ - -#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat ) -#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat ) -#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat ) -#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat ) -#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat ) -#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat ) -#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat ) -#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat ) - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTDEBUG_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftdriver.h b/src/freetype/freetype/internal/ftdriver.h deleted file mode 100644 index 592de498c1..0000000000 --- a/src/freetype/freetype/internal/ftdriver.h +++ /dev/null @@ -1,182 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftdriver.h */ -/* */ -/* FreeType font driver interface (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTDRIVER_H -#define FTDRIVER_H - - -#include -#include - - - typedef FT_Error (*FTDriver_initFace)( FT_Stream stream, - FT_Face face, - FT_Int typeface_index, - FT_Int num_params, - FT_Parameter* parameters ); - - typedef void (*FTDriver_doneFace)( FT_Face face ); - - - typedef FT_Error (*FTDriver_initSize)( FT_Size size ); - - typedef void (*FTDriver_doneSize)( FT_Size size ); - - - typedef FT_Error (*FTDriver_initGlyphSlot)( FT_GlyphSlot slot ); - - typedef void (*FTDriver_doneGlyphSlot)( FT_GlyphSlot slot ); - - - typedef FT_Error (*FTDriver_setCharSizes)( FT_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ); - - typedef FT_Error (*FTDriver_setPixelSizes)( FT_Size size, - FT_UInt pixel_width, - FT_UInt pixel_height ); - - typedef FT_Error (*FTDriver_loadGlyph)( FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_Int load_flags ); - - - typedef FT_UInt (*FTDriver_getCharIndex)( FT_CharMap charmap, - FT_Long charcode ); - - typedef FT_Error (*FTDriver_getKerning)( FT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_Vector* kerning ); - - - typedef FT_Error (*FTDriver_attachFile)( FT_Face face, - FT_Stream stream ); - - - typedef FT_Error (*FTDriver_getAdvances)( FT_Face face, - FT_UInt first, - FT_UInt count, - FT_Bool vertical, - FT_UShort* advances ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Driver_Class */ - /* */ - /* */ - /* The font driver class. This structure mostly contains pointers to */ - /* driver methods. */ - /* */ - /* */ - /* root :: The parent module. */ - /* */ - /* face_object_size :: The size of a face object in bytes. */ - /* */ - /* size_object_size :: The size of a size object in bytes. */ - /* */ - /* slot_object_size :: The size of a glyph object in bytes. */ - /* */ - /* init_face :: The format-specific face constructor. */ - /* */ - /* done_face :: The format-specific face destructor. */ - /* */ - /* init_size :: The format-specific size constructor. */ - /* */ - /* done_size :: The format-specific size destructor. */ - /* */ - /* init_slot :: The format-specific slot constructor. */ - /* */ - /* done_slot :: The format-specific slot destructor. */ - /* */ - /* set_char_sizes :: A handle to a function used to set the new */ - /* character size in points + resolution. Can be */ - /* set to 0 to indicate default behaviour. */ - /* */ - /* set_pixel_sizes :: A handle to a function used to set the new */ - /* character size in pixels. Can be set to 0 to */ - /* indicate default behaviour. */ - /* */ - /* load_glyph :: A function handle to load a given glyph image */ - /* in a slot. This field is mandatory! */ - /* */ - /* get_char_index :: A function handle to return the glyph index of */ - /* a given character for a given charmap. This */ - /* field is mandatory! */ - /* */ - /* get_kerning :: A function handle to return the unscaled */ - /* kerning for a given pair of glyphs. Can be */ - /* set to 0 if the format doesn't support */ - /* kerning. */ - /* */ - /* attach_file :: This function handle is used to read */ - /* additional data for a face from another */ - /* file/stream. For example, this can be used to */ - /* add data from AFM or PFM files on a Type 1 */ - /* face, or a CIDMap on a CID-keyed face. */ - /* */ - /* get_advances :: A function handle used to return the advances */ - /* of 'count' glyphs, starting at `index'. the */ - /* `vertical' flags must be set when vertical */ - /* advances are queried. The advances buffer is */ - /* caller-allocated. */ - /* */ - /* */ - /* Most function pointers, with the exception of `load_glyph' and */ - /* `get_char_index' can be set to 0 to indicate a default behaviour. */ - /* */ - typedef struct FT_Driver_Class_ - { - FT_Module_Class root; - - FT_Int face_object_size; - FT_Int size_object_size; - FT_Int slot_object_size; - - FTDriver_initFace init_face; - FTDriver_doneFace done_face; - - FTDriver_initSize init_size; - FTDriver_doneSize done_size; - - FTDriver_initGlyphSlot init_slot; - FTDriver_doneGlyphSlot done_slot; - - FTDriver_setCharSizes set_char_sizes; - FTDriver_setPixelSizes set_pixel_sizes; - - FTDriver_loadGlyph load_glyph; - FTDriver_getCharIndex get_char_index; - - FTDriver_getKerning get_kerning; - FTDriver_attachFile attach_file; - - FTDriver_getAdvances get_advances; - - } FT_Driver_Class; - - -#endif /* FTDRIVER_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftextend.h b/src/freetype/freetype/internal/ftextend.h deleted file mode 100644 index fdd2c6ef24..0000000000 --- a/src/freetype/freetype/internal/ftextend.h +++ /dev/null @@ -1,178 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftextend.h */ -/* */ -/* FreeType extensions implementation (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTEXTEND_H -#define FTEXTEND_H - - -#include - - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* The extensions don't need to be integrated at compile time into the */ - /* engine, only at link time. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Extension_Initializer */ - /* */ - /* */ - /* Each new face object can have several extensions associated with */ - /* it at creation time. This function is used to initialize given */ - /* extension data for a given face. */ - /* */ - /* */ - /* ext :: A typeless pointer to the extension data. */ - /* */ - /* face :: A handle to the source face object the extension is */ - /* associated with. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* In case of error, the initializer should not destroy the extension */ - /* data, as the finalizer will get called later by the function's */ - /* caller. */ - /* */ - typedef FT_Error (*FT_Extension_Initializer)( void* ext, - FT_Face face ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Extension_Finalizer */ - /* */ - /* */ - /* Each new face object can have several extensions associated with */ - /* it at creation time. This function is used to finalize given */ - /* extension data for a given face; it occurs before the face object */ - /* itself is finalized. */ - /* */ - /* */ - /* ext :: A typeless pointer to the extension data. */ - /* */ - /* face :: A handle to the source face object the extension is */ - /* associated with. */ - /* */ - typedef void (*FT_Extension_Finalizer)( void* ext, - FT_Face face ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Extension_Class */ - /* */ - /* */ - /* A simple structure used to describe a given extension to the */ - /* FreeType base layer. An FT_Extension_Class is used as a parameter */ - /* for FT_Register_Extension(). */ - /* */ - /* */ - /* id :: The extension's ID. This is a normal C string that */ - /* is used to uniquely reference the extension's */ - /* interface. */ - /* */ - /* size :: The size in bytes of the extension data that must be */ - /* associated with each face object. */ - /* */ - /* init :: A pointer to the extension data's initializer. */ - /* */ - /* finalize :: A pointer to the extension data's finalizer. */ - /* */ - /* interface :: This pointer can be anything, but should usually */ - /* point to a table of function pointers which implement */ - /* the extension's interface. */ - /* */ - /* offset :: This field is set and used within the base layer and */ - /* should be set to 0 when registering an extension */ - /* through FT_Register_Extension(). It contains an */ - /* offset within the face's extension block for the */ - /* current extension's data. */ - /* */ - typedef struct FT_Extension_Class_ - { - const char* id; - FT_ULong size; - FT_Extension_Initializer init; - FT_Extension_Finalizer finalize; - void* interface; - - FT_ULong offset; - - } FT_Extension_Class; - - - FT_EXPORT_DEF( FT_Error ) FT_Register_Extension( - FT_Driver driver, - FT_Extension_Class* clazz ); - - -#ifdef FT_CONFIG_OPTION_EXTEND_ENGINE - - - /* Initialize the extension component */ - LOCAL_DEF - FT_Error FT_Init_Extensions( FT_Library library ); - - /* Finalize the extension component */ - LOCAL_DEF - FT_Error FT_Done_Extensions( FT_Library library ); - - /* Create an extension within a face object. Called by the */ - /* face object constructor. */ - LOCAL_DEF - FT_Error FT_Create_Extensions( FT_Face face ); - - /* Destroy all extensions within a face object. Called by the */ - /* face object destructor. */ - LOCAL_DEF - FT_Error FT_Destroy_Extensions( FT_Face face ); - - -#endif - - - /* return an extension's data & interface according to its ID */ - FT_EXPORT_DEF( void* ) FT_Get_Extension( - FT_Face face, - const char* extension_id, - void** extension_interface ); - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTEXTEND_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftlist.h b/src/freetype/freetype/internal/ftlist.h deleted file mode 100644 index 7c6d8ed3b3..0000000000 --- a/src/freetype/freetype/internal/ftlist.h +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlist.c */ -/* */ -/* Generic list support for FreeType (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file implements functions relative to list processing. Its */ - /* data structures are defined in `freetype.h'. */ - /* */ - /*************************************************************************/ - - -#ifndef FTLIST_H -#define FTLIST_H - -#include - -#ifdef __cplusplus - extern "C" { -#endif - - - FT_EXPORT_DEF( FT_ListNode ) FT_List_Find( FT_List list, - void* data ); - - FT_EXPORT_DEF( void ) FT_List_Add( FT_List list, - FT_ListNode node ); - - FT_EXPORT_DEF( void ) FT_List_Insert( FT_List list, - FT_ListNode node ); - - FT_EXPORT_DEF( void ) FT_List_Remove( FT_List list, - FT_ListNode node ); - - FT_EXPORT_DEF( void ) FT_List_Up( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Iterator */ - /* */ - /* */ - /* An FT_List iterator function which is called during a list parse */ - /* by FT_List_Iterate(). */ - /* */ - /* */ - /* node :: The current iteration list node. */ - /* */ - /* user :: A typeless pointer passed to FT_List_Iterate(). */ - /* Can be used to point to the iteration's state. */ - /* */ - typedef FT_Error (*FT_List_Iterator)( FT_ListNode node, - void* user ); - - - FT_EXPORT_DEF( FT_Error ) FT_List_Iterate( FT_List list, - FT_List_Iterator iterator, - void* user ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_List_Destructor */ - /* */ - /* */ - /* An FT_List iterator function which is called during a list */ - /* finalization by FT_List_Finalize() to destroy all elements in a */ - /* given list. */ - /* */ - /* */ - /* system :: The current system object. */ - /* */ - /* data :: The current object to destroy. */ - /* */ - /* user :: A typeless pointer passed to FT_List_Iterate(). It can */ - /* be used to point to the iteration's state. */ - /* */ - typedef void (*FT_List_Destructor)( FT_Memory memory, - void* data, - void* user ); - - - FT_EXPORT_DEF( void ) FT_List_Finalize( FT_List list, - FT_List_Destructor destroy, - FT_Memory memory, - void* user ); - - -#ifdef __cplusplus - } -#endif - -#endif /* FTLIST_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftmemory.h b/src/freetype/freetype/internal/ftmemory.h deleted file mode 100644 index da8d3a4126..0000000000 --- a/src/freetype/freetype/internal/ftmemory.h +++ /dev/null @@ -1,127 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmemory.h */ -/* */ -/* The FreeType memory management macros (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTMEMORY_H -#define FTMEMORY_H - - -#include -#include - - - /*************************************************************************/ - /* */ - /* */ - /* FT_SET_ERROR */ - /* */ - /* */ - /* This macro is used to set an implicit `error' variable to a given */ - /* expression's value (usually a function call), and convert it to a */ - /* boolean which is set whenever the value is != 0. */ - /* */ -#undef FT_SET_ERROR -#define FT_SET_ERROR( expression ) \ - ( ( error = (expression) ) != 0 ) - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** M E M O R Y ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - BASE_DEF( FT_Error ) FT_Alloc( FT_Memory memory, - FT_Long size, - void** P ); - - BASE_DEF( FT_Error ) FT_Realloc( FT_Memory memory, - FT_Long current, - FT_Long size, - void** P ); - - BASE_DEF( void ) FT_Free( FT_Memory memory, - void** P ); - - - - /* This `#include' is needed by the MEM_xxx() macros; it should be */ - /* available on all platforms we know of. */ -#include - -#define MEM_Set( dest, byte, count ) memset( dest, byte, count ) - -#define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) - -#define MEM_Move( dest, source, count ) memmove( dest, source, count ) - - - /*************************************************************************/ - /* */ - /* We now support closures to produce completely reentrant code. This */ - /* means the allocation functions now takes an additional argument */ - /* (`memory'). It is a handle to a given memory object, responsible for */ - /* all low-level operations, including memory management and */ - /* synchronisation. */ - /* */ - /* In order to keep our code readable and use the same macros in the */ - /* font drivers and the rest of the library, MEM_Alloc(), ALLOC(), and */ - /* ALLOC_ARRAY() now use an implicit variable, `memory'. It must be */ - /* defined at all locations where a memory operation is queried. */ - /* */ -#define MEM_Alloc( _pointer_, _size_ ) \ - FT_Alloc( memory, _size_, (void**)&(_pointer_) ) - -#define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \ - FT_Alloc( memory, (_count_)*sizeof ( _type_ ), \ - (void**)&(_pointer_) ) - -#define MEM_Realloc( _pointer_, _current_, _size_ ) \ - FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) ) - -#define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \ - FT_Realloc( memory, (_current_)*sizeof ( _type_ ), \ - (_new_)*sizeof ( _type_ ), (void**)&(_pointer_) ) - -#define ALLOC( _pointer_, _size_ ) \ - FT_SET_ERROR( MEM_Alloc( _pointer_, _size_ ) ) - -#define REALLOC( _pointer_, _current_, _size_ ) \ - FT_SET_ERROR( MEM_Realloc( _pointer_, _current_, _size_ ) ) - -#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ - FT_SET_ERROR( MEM_Alloc( _pointer_, \ - (_count_)*sizeof ( _type_ ) ) ) - -#define REALLOC_ARRAY( _pointer_, _current_, _count_, _type_ ) \ - FT_SET_ERROR( MEM_Realloc( _pointer_, \ - (_current_)*sizeof ( _type_ ), \ - (_count_)*sizeof ( _type_ ) ) ) - -#define FREE( _pointer_ ) FT_Free( memory, (void**)&(_pointer_) ) - - -#endif /* FTMEMORY_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftobjs.h b/src/freetype/freetype/internal/ftobjs.h deleted file mode 100644 index 0d0f5d80ac..0000000000 --- a/src/freetype/freetype/internal/ftobjs.h +++ /dev/null @@ -1,532 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftobjs.h */ -/* */ -/* The FreeType private base classes (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of all internal FreeType classes. */ - /* */ - /*************************************************************************/ - - -#ifndef FTOBJS_H -#define FTOBJS_H - -#include -#include -#include -#include - - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* Some generic definitions. */ - /* */ -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef NULL -#define NULL (void*)0 -#endif - -#ifndef UNUSED -#define UNUSED( arg ) ( (arg)=(arg) ) -#endif - - - /*************************************************************************/ - /* */ - /* The min and max functions missing in C. As usual, be careful not to */ - /* write things like MIN( a++, b++ ) to avoid side effects. */ - /* */ -#ifndef MIN -#define MIN( a, b ) ( (a) < (b) ? (a) : (b) ) -#endif - -#ifndef MAX -#define MAX( a, b ) ( (a) > (b) ? (a) : (b) ) -#endif - -#ifndef ABS -#define ABS( a ) ( (a) < 0 ? -(a) : (a) ) -#endif - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** M O D U L E S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_ModuleRec */ - /* */ - /* */ - /* A module object instance. */ - /* */ - /* */ - /* clazz :: A pointer to the module's class. */ - /* */ - /* library :: A handle to the parent library object. */ - /* */ - /* memory :: A handle to the memory manager. */ - /* */ - /* generic :: A generic structure for user-level extensibility (?). */ - /* */ - typedef struct FT_ModuleRec_ - { - FT_Module_Class* clazz; - FT_Library library; - FT_Memory memory; - FT_Generic generic; - - } FT_ModuleRec; - - - /* typecast an object to a FT_Module */ -#define FT_MODULE( x ) ((FT_Module)(x)) -#define FT_MODULE_CLASS( x ) FT_MODULE(x)->clazz -#define FT_MODULE_LIBRARY( x ) FT_MODULE(x)->library -#define FT_MODULE_MEMORY( x ) FT_MODULE(x)->memory - -#define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - ft_module_font_driver ) - -#define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - ft_module_renderer ) - -#define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - ft_module_hinter ) - -#define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - ft_module_styler ) - -#define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS(x)->module_flags & \ - ft_module_driver_scalable ) - -#define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS(x)->module_flags & \ - ft_module_driver_no_outlines ) - -#define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS(x)->module_flags & \ - ft_module_driver_has_hinter ) - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Module_Interface */ - /* */ - /* */ - /* Finds a module and returns its specific interface as a typeless */ - /* pointer. */ - /* */ - /* */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* */ - /* A module-specific interface if available, 0 otherwise. */ - /* */ - /* */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for, and what its interface is :-) */ - /* */ - BASE_DEF( const void* ) FT_Get_Module_Interface( FT_Library library, - const char* mod_name ); - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** FACE, SIZE & GLYPH SLOT OBJECTS ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /* a few macros used to perform easy typecasts with minimal brain damage */ - -#define FT_FACE( x ) ((FT_Face)(x)) -#define FT_SIZE( x ) ((FT_Size)(x)) -#define FT_SLOT( x ) ((FT_GlyphSlot)(x)) - -#define FT_FACE_DRIVER( x ) FT_FACE( x )->driver -#define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library -#define FT_FACE_MEMORY( x ) FT_FACE( x )->memory - -#define FT_SIZE_FACE( x ) FT_SIZE( x )->face -#define FT_SLOT_FACE( x ) FT_SLOT( x )->face - -#define FT_FACE_SLOT( x ) FT_FACE( x )->glyph -#define FT_FACE_SIZE( x ) FT_FACE( x )->size - - - /* this must be kept exported -- tt will be used later in our own */ - /* high-level caching font manager called SemTex (way after the */ - /* 2.0 release though */ - FT_EXPORT_DEF( FT_Error ) FT_New_Size( FT_Face face, - FT_Size* size ); - - FT_EXPORT_DEF( FT_Error ) FT_Done_Size( FT_Size size ); - - - FT_EXPORT_DEF( FT_Error ) FT_New_GlyphSlot( FT_Face face, - FT_GlyphSlot* aslot ); - - FT_EXPORT_DEF( void ) FT_Done_GlyphSlot( FT_GlyphSlot slot ); - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** G L Y P H L O A D E R ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 -#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 -#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 -#define FT_SUBGLYPH_FLAG_SCALE 8 -#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 -#define FT_SUBGLYPH_FLAG_2X2 0x80 -#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 - - - enum - { - ft_glyph_own_bitmap = 1 - }; - - - struct FT_SubGlyph_ - { - FT_Int index; - FT_UShort flags; - FT_Int arg1; - FT_Int arg2; - FT_Matrix transform; - }; - - - typedef struct FT_GlyphLoad_ - { - FT_Outline outline; /* outline */ - FT_UInt num_subglyphs; /* number of subglyphs */ - FT_SubGlyph* subglyphs; /* subglyphs */ - FT_Vector* extra_points; /* extra points table */ - - } FT_GlyphLoad; - - - struct FT_GlyphLoader_ - { - FT_Memory memory; - FT_UInt max_points; - FT_UInt max_contours; - FT_UInt max_subglyphs; - FT_Bool use_extra; - - FT_GlyphLoad base; - FT_GlyphLoad current; - - void* other; /* for possible future extension? */ - - }; - - - BASE_DEF( FT_Error ) FT_GlyphLoader_New( FT_Memory memory, - FT_GlyphLoader** aloader ); - - BASE_DEF( FT_Error ) FT_GlyphLoader_Create_Extra( - FT_GlyphLoader* loader ); - - BASE_DEF( void ) FT_GlyphLoader_Done( FT_GlyphLoader* loader ); - - BASE_DEF( void ) FT_GlyphLoader_Reset( FT_GlyphLoader* loader ); - - BASE_DEF( void ) FT_GlyphLoader_Rewind( FT_GlyphLoader* loader ); - - BASE_DEF( FT_Error ) FT_GlyphLoader_Check_Points( - FT_GlyphLoader* loader, - FT_UInt n_points, - FT_UInt n_contours ); - - BASE_DEF( FT_Error ) FT_GlyphLoader_Check_Subglyphs( - FT_GlyphLoader* loader, - FT_UInt n_subs ); - - BASE_DEF( void ) FT_GlyphLoader_Prepare( FT_GlyphLoader* loader ); - - BASE_DEF( void ) FT_GlyphLoader_Add( FT_GlyphLoader* loader ); - - BASE_DEF( FT_Error ) FT_GlyphLoader_Copy_Points( FT_GlyphLoader* target, - FT_GlyphLoader* source ); - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** R E N D E R E R S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#define FT_RENDERER( x ) ((FT_Renderer)( x )) -#define FT_GLYPH( x ) ((FT_Glyph)( x )) -#define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x )) -#define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x )) - - - typedef struct FT_RendererRec_ - { - FT_ModuleRec root; - FT_Renderer_Class* clazz; - FT_Glyph_Format glyph_format; - const FT_Glyph_Class glyph_class; - - FT_Raster raster; - FT_Raster_Render_Func raster_render; - FTRenderer_render render; - - } FT_RendererRec; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** F O N T D R I V E R S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* typecast a module into a driver easily */ -#define FT_DRIVER( x ) ((FT_Driver)(x)) - - /* typecast a module as a driver, and get its driver class */ -#define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz - - - /*************************************************************************/ - /* */ - /* */ - /* FT_DriverRec */ - /* */ - /* */ - /* The root font driver class. A font driver is responsible for */ - /* managing and loading font files of a given format. */ - /* */ - /* */ - /* root :: Contains the fields of the root module class. */ - /* */ - /* clazz :: A pointer to the font driver's class. Note that */ - /* this is NOT root.clazz. `class' wasn't used */ - /* as it is a reserved word in C++. */ - /* */ - /* faces_list :: The list of faces currently opened by this */ - /* driver. */ - /* */ - /* extensions :: A typeless pointer to the driver's extensions */ - /* registry, if they are supported through the */ - /* configuration macro FT_CONFIG_OPTION_EXTENSIONS. */ - /* */ - /* glyph_loader :: The glyph loader for all faces managed by this */ - /* driver. This object isn't defined for unscalable */ - /* formats. */ - /* */ - typedef struct FT_DriverRec_ - { - FT_ModuleRec root; - FT_Driver_Class* clazz; - - FT_ListRec faces_list; - void* extensions; - - FT_GlyphLoader* glyph_loader; - - } FT_DriverRec; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** L I B R A R I E S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#define FT_DEBUG_HOOK_TRUETYPE 0 -#define FT_DEBUG_HOOK_TYPE1 1 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LibraryRec */ - /* */ - /* */ - /* The FreeType library class. This is the root of all FreeType */ - /* data. Use FT_New_Library() to create a library object, and */ - /* FT_Done_Library() to discard it and all child objects. */ - /* */ - /* */ - /* memory :: The library's memory object. Manages memory */ - /* allocation. */ - /* */ - /* generic :: Client data variable. Used to extend the */ - /* Library class by higher levels and clients. */ - /* */ - /* num_modules :: The number of modules currently registered */ - /* within this library. This is set to 0 for new */ - /* libraries. New modules are added through the */ - /* FT_Add_Module() API function. */ - /* */ - /* modules :: A table used to store handles to the currently */ - /* registered modules. Note that each font driver */ - /* contains a list of its opened faces. */ - /* */ - /* renderers :: The list of renderers currently registered */ - /* within the library. */ - /* */ - /* cur_renderer :: The current outline renderer. This is a */ - /* shortcut used to avoid parsing the list on */ - /* each call to FT_Outline_Render(). It is a */ - /* handle to the current renderer for the */ - /* ft_glyph_format_outline format. */ - /* */ - /* auto_hinter :: XXX */ - /* */ - /* raster_pool :: The raster object's render pool. This can */ - /* ideally be changed dynamically at run-time. */ - /* */ - /* raster_pool_size :: The size of the render pool in bytes. */ - /* */ - /* debug_hooks :: XXX */ - /* */ - typedef struct FT_LibraryRec_ - { - FT_Memory memory; /* library's memory manager */ - - FT_Generic generic; - - FT_UInt num_modules; - FT_Module modules[FT_MAX_MODULES]; /* module objects */ - - FT_ListRec renderers; /* list of renderers */ - FT_Renderer cur_renderer; /* current outline renderer */ - FT_Module auto_hinter; - - FT_Byte* raster_pool; /* scan-line conversion */ - /* render pool */ - FT_ULong raster_pool_size; /* size of render pool in bytes */ - - FT_DebugHook_Func debug_hooks[4]; - - } FT_LibraryRec; - - - BASE_DEF( FT_Renderer ) FT_Lookup_Renderer( FT_Library library, - FT_Glyph_Format format, - FT_ListNode* node ); - - BASE_DEF( FT_Error ) FT_Render_Glyph_Internal( FT_Library library, - FT_GlyphSlot slot, - FT_UInt render_mode ); - - typedef FT_Error (*FT_Glyph_Name_Requester)( FT_Face face, - FT_UInt glyph_index, - FT_Pointer buffer, - FT_UInt buffer_max ); - - -#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM - - - FT_EXPORT_DEF( FT_Error ) FT_New_Stream( const char* filepathname, - FT_Stream astream ); - - FT_EXPORT_DEF( void ) FT_Done_Stream( FT_Stream stream ); - - FT_EXPORT_DEF( FT_Memory ) FT_New_Memory( void ); - - -#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ - - - /* Define default raster's interface. The default raster is located in */ - /* `src/base/ftraster.c' */ - /* */ - /* Client applications can register new rasters through the */ - /* FT_Set_Raster() API. */ - -#ifndef FT_NO_DEFAULT_RASTER - FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster; -#endif - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTOBJS_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/ftstream.h b/src/freetype/freetype/internal/ftstream.h deleted file mode 100644 index 365f479a8a..0000000000 --- a/src/freetype/freetype/internal/ftstream.h +++ /dev/null @@ -1,361 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftstream.h */ -/* */ -/* Stream handling(specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTSTREAM_H -#define FTSTREAM_H - -#include - - -#ifdef __cplusplus - extern "C" { -#endif - - - /* format of an 8-bit frame_op value = [ xxxxx | e | s ] */ - /* s is set to 1 if the value is signed, */ - /* e is set to 1 if the value is little-endian */ - /* xxxxx is a command */ - -#define FT_FRAME_OP_SHIFT 2 -#define FT_FRAME_OP_SIGNED 1 -#define FT_FRAME_OP_LITTLE 2 -#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT ) - -#define FT_MAKE_FRAME_OP( command, little, sign ) \ - ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign ) - -#define FT_FRAME_OP_END 0 -#define FT_FRAME_OP_START 1 /* start a new frame */ -#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */ -#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */ -#define FT_FRAME_OP_LONG 4 /* read 4-byte value */ -#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */ -#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */ - - - typedef enum FT_Frame_Op_ - { - ft_frame_end = 0, - ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ), - - ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ), - ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ), - - ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ), - ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ), - ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ), - ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ), - - ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ), - ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ), - ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ), - ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ), - - ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ), - ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ), - ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ), - ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ), - - ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ), - ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 ) - - } FT_Frame_Op; - - - typedef struct FT_Frame_Field_ - { - FT_Frame_Op value; - char size; - FT_UShort offset; - - } FT_Frame_Field; - - - /* make-up a FT_Frame_Field out of a structure type and a field name */ -#define FT_FIELD_REF( s, f ) (((s*)0)->f) - -#define FT_FRAME_FIELD( frame_op, struct_type, field ) \ - { \ - frame_op, \ - sizeof ( FT_FIELD_REF( struct_type,field ) ), \ - (FT_UShort)(char*)&FT_FIELD_REF( struct_type, field ) \ - } - -#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 } - -#define FT_FRAME_START( s ) { ft_frame_start, 0, s } -#define FT_FRAME_END { ft_frame_end, 0, 0 } - -#define FT_FRAME_LONG( s, f ) FT_FRAME_FIELD( ft_frame_long_be, s, f ) -#define FT_FRAME_ULONG( s, f ) FT_FRAME_FIELD( ft_frame_ulong_be, s, f ) -#define FT_FRAME_SHORT( s, f ) FT_FRAME_FIELD( ft_frame_short_be, s, f ) -#define FT_FRAME_USHORT( s, f ) FT_FRAME_FIELD( ft_frame_ushort_be, s, f ) -#define FT_FRAME_BYTE( s, f ) FT_FRAME_FIELD( ft_frame_byte, s, f ) -#define FT_FRAME_CHAR( s, f ) FT_FRAME_FIELD( ft_frame_schar, s, f ) - -#define FT_FRAME_LONG_LE( s, f ) FT_FRAME_FIELD( ft_frame_long_le, s, f ) -#define FT_FRAME_ULONG_LE( s, f ) FT_FRAME_FIELD( ft_frame_ulong_le, s, f ) -#define FT_FRAME_SHORT_LE( s, f ) FT_FRAME_FIELD( ft_frame_short_le, s, f ) -#define FT_FRAME_USHORT_LE( s, f ) FT_FRAME_FIELD( ft_frame_ushort_le, s, f ) - -#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 } -#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 } -#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 } - -#define FT_FRAME_BYTES( struct_type, field, count ) \ - { \ - ft_frame_bytes, \ - count, \ - (FT_UShort)(char*)&FT_FIELD_REF( struct_type, field ) \ - } -#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } - - - - /*************************************************************************/ - /* */ - /* integer extraction macros -- the `buffer' parameter must ALWAYS be of */ - /* type `char*' or equivalent (1-byte elements). */ - /* */ -#define NEXT_Char( buffer ) \ - ( (signed char)*buffer++ ) -#define NEXT_Byte( buffer ) \ - ( (unsigned char)*buffer++ ) - -#define NEXT_Short( buffer ) \ - ( buffer += 2, \ - ( (short)( (signed char)buffer[-2] << 8 ) | \ - (unsigned char)buffer[-1] ) ) - -#define NEXT_UShort( buffer ) \ - ( (unsigned short)NEXT_Short( buffer ) ) - -#define NEXT_Offset( buffer ) \ - ( buffer += 3, \ - ( ( (long)(signed char)buffer[-3] << 16 ) | \ - ( (long)(unsigned char)buffer[-2] << 8 ) | \ - (long)(unsigned char)buffer[-1] ) ) - -#define NEXT_UOffset( buffer ) \ - ( (unsigned long)NEXT_Offset( buffer ) ) - -#define NEXT_Long( buffer ) \ - ( buffer += 4, \ - ( ( (long)(signed char)buffer[-4] << 24 ) | \ - ( (long)(unsigned char)buffer[-3] << 16 ) | \ - ( (long)(unsigned char)buffer[-2] << 8 ) | \ - (long)(unsigned char)buffer[-1] ) ) - -#define NEXT_ULong( buffer ) \ - ( (unsigned long)NEXT_Long( buffer ) ) - - -#define NEXT_ShortLE( buffer ) \ - ( buffer += 2, \ - ( (short)( (signed char)buffer[-1] << 8 ) | \ - (unsigned char)buffer[-2] ) ) - -#define NEXT_UShortLE( buffer ) \ - ( (unsigned short)NEXT_ShortLE( buffer ) ) - -#define NEXT_OffsetLE( buffer ) \ - ( buffer += 3, \ - ( ( (long)(signed char)buffer[-1] << 16 ) | \ - ( (long)(unsigned char)buffer[-2] << 8 ) | \ - (long)(unsigned char)buffer[-3] ) ) - -#define NEXT_UOffsetLE( buffer ) \ - ( (unsigned long)NEXT_OffsetLE( buffer ) ) - - -#define NEXT_LongLE( buffer ) \ - ( buffer += 4, \ - ( ( (long)(signed char)buffer[-1] << 24 ) | \ - ( (long)(unsigned char)buffer[-2] << 16 ) | \ - ( (long)(unsigned char)buffer[-3] << 8 ) | \ - (long)(unsigned char)buffer[-4] ) ) - -#define NEXT_ULongLE( buffer ) \ - ( (unsigned long)NEXT_LongLE( buffer ) ) - - - /*************************************************************************/ - /* */ - /* Each GET_xxxx() macro uses an implicit `stream' variable. */ - /* */ -#define FT_GET_MACRO( func, type ) ( (type)func( stream ) ) - -#define GET_Char() FT_GET_MACRO( FT_Get_Char, FT_Char ) -#define GET_Byte() FT_GET_MACRO( FT_Get_Char, FT_Byte ) -#define GET_Short() FT_GET_MACRO( FT_Get_Short, FT_Short ) -#define GET_UShort() FT_GET_MACRO( FT_Get_Short, FT_UShort ) -#define GET_Offset() FT_GET_MACRO( FT_Get_Offset, FT_Long ) -#define GET_UOffset() FT_GET_MACRO( FT_Get_Offset, FT_ULong ) -#define GET_Long() FT_GET_MACRO( FT_Get_Long, FT_Long ) -#define GET_ULong() FT_GET_MACRO( FT_Get_Long, FT_ULong ) -#define GET_Tag4() FT_GET_MACRO( FT_Get_Long, FT_ULong ) - -#define GET_ShortLE() FT_GET_MACRO( FT_Get_ShortLE, FT_Short ) -#define GET_UShortLE() FT_GET_MACRO( FT_Get_ShortLE, FT_UShort ) -#define GET_LongLE() FT_GET_MACRO( FT_Get_LongLE, FT_Short ) -#define GET_ULongLE() FT_GET_MACRO( FT_Get_LongLE, FT_Short ) - -#define FT_READ_MACRO( func, type, var ) \ - ( var = (type)func( stream, &error ), \ - error != FT_Err_Ok ) - -#define READ_Byte( var ) FT_READ_MACRO( FT_Read_Char, FT_Byte, var ) -#define READ_Char( var ) FT_READ_MACRO( FT_Read_Char, FT_Char, var ) -#define READ_Short( var ) FT_READ_MACRO( FT_Read_Short, FT_Short, var ) -#define READ_UShort( var ) FT_READ_MACRO( FT_Read_Short, FT_UShort, var ) -#define READ_Offset( var ) FT_READ_MACRO( FT_Read_Offset, FT_Long, var ) -#define READ_UOffset( var ) FT_READ_MACRO( FT_Read_Offset, FT_ULong, var ) -#define READ_Long( var ) FT_READ_MACRO( FT_Read_Long, FT_Long, var ) -#define READ_ULong( var ) FT_READ_MACRO( FT_Read_Long, FT_ULong, var ) - -#define READ_ShortLE( var ) FT_READ_MACRO( FT_Read_ShortLE, FT_Short, var ) -#define READ_UShortLE( var ) FT_READ_MACRO( FT_Read_ShortLE, FT_UShort, var ) -#define READ_LongLE( var ) FT_READ_MACRO( FT_Read_LongLE, FT_Long, var ) -#define READ_ULongLE( var ) FT_READ_MACRO( FT_Read_LongLE, FT_ULong, var ) - - - BASE_DEF( void ) FT_New_Memory_Stream( FT_Library library, - FT_Byte* base, - FT_ULong size, - FT_Stream stream ); - - BASE_DEF( FT_Error ) FT_Seek_Stream( FT_Stream stream, - FT_ULong pos ); - - BASE_DEF( FT_Error ) FT_Skip_Stream( FT_Stream stream, - FT_Long distance ); - - BASE_DEF( FT_Long ) FT_Stream_Pos( FT_Stream stream ); - - - BASE_DEF( FT_Error ) FT_Read_Stream( FT_Stream stream, - FT_Byte* buffer, - FT_ULong count ); - - BASE_DEF( FT_Error ) FT_Read_Stream_At( FT_Stream stream, - FT_ULong pos, - FT_Byte* buffer, - FT_ULong count ); - - BASE_DEF( FT_Error ) FT_Access_Frame( FT_Stream stream, - FT_ULong count ); - - BASE_DEF( void ) FT_Forget_Frame( FT_Stream stream ); - - BASE_DEF( FT_Error ) FT_Extract_Frame( FT_Stream stream, - FT_ULong count, - FT_Byte** pbytes ); - - BASE_DEF( void ) FT_Release_Frame( FT_Stream stream, - FT_Byte** pbytes ); - - BASE_DEF( FT_Char ) FT_Get_Char( FT_Stream stream ); - - BASE_DEF( FT_Short ) FT_Get_Short( FT_Stream stream ); - - BASE_DEF( FT_Long ) FT_Get_Offset( FT_Stream stream ); - - BASE_DEF( FT_Long ) FT_Get_Long( FT_Stream stream ); - - BASE_DEF( FT_Short ) FT_Get_ShortLE( FT_Stream stream ); - - BASE_DEF( FT_Long ) FT_Get_LongLE( FT_Stream stream ); - - - BASE_DEF( FT_Char ) FT_Read_Char( FT_Stream stream, - FT_Error* error ); - - BASE_DEF( FT_Short ) FT_Read_Short( FT_Stream stream, - FT_Error* error ); - - BASE_DEF( FT_Long ) FT_Read_Offset( FT_Stream stream, - FT_Error* error ); - - BASE_DEF( FT_Long ) FT_Read_Long( FT_Stream stream, - FT_Error* error ); - - BASE_DEF( FT_Short ) FT_Read_ShortLE( FT_Stream stream, - FT_Error* error ); - - BASE_DEF( FT_Long ) FT_Read_LongLE( FT_Stream stream, - FT_Error* error ); - - BASE_DEF( FT_Error ) FT_Read_Fields( FT_Stream stream, - const FT_Frame_Field* fields, - void* structure ); - - -#define USE_Stream( resource, stream ) \ - FT_SET_ERROR( FT_Open_Stream( resource, stream ) ) - -#define DONE_Stream( stream ) \ - FT_Done_Stream( stream ) - - -#define ACCESS_Frame( size ) \ - FT_SET_ERROR( FT_Access_Frame( stream, size ) ) - -#define FORGET_Frame() \ - FT_Forget_Frame( stream ) - -#define EXTRACT_Frame( size, bytes ) \ - FT_SET_ERROR( FT_Extract_Frame( stream, size, \ - (FT_Byte**)&(bytes) ) ) - -#define RELEASE_Frame( bytes ) \ - FT_Release_Frame( stream, (FT_Byte**)&(bytes) ) - -#define FILE_Seek( position ) \ - FT_SET_ERROR( FT_Seek_Stream( stream, position ) ) - -#define FILE_Skip( distance ) \ - FT_SET_ERROR( FT_Skip_Stream( stream, distance ) ) - -#define FILE_Pos() \ - FT_Stream_Pos( stream ) - -#define FILE_Read( buffer, count ) \ - FT_SET_ERROR( FT_Read_Stream( stream, \ - (FT_Byte*)buffer, \ - count ) ) - -#define FILE_Read_At( position, buffer, count ) \ - FT_SET_ERROR( FT_Read_Stream_At( stream, \ - position, \ - (FT_Byte*)buffer, \ - count ) ) - -#define READ_Fields( fields, object ) \ - ( ( error = FT_Read_Fields( stream, fields, object ) ) != FT_Err_Ok ) - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTSTREAM_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/psnames.h b/src/freetype/freetype/internal/psnames.h deleted file mode 100644 index ed862359e2..0000000000 --- a/src/freetype/freetype/internal/psnames.h +++ /dev/null @@ -1,220 +0,0 @@ -/***************************************************************************/ -/* */ -/* psnames.h */ -/* */ -/* High-level interface for the `PSNames' module (in charge of */ -/* various functions related to Postscript glyph names conversion). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef PSNAMES_H -#define PSNAMES_H - - -#include - - - /*************************************************************************/ - /* */ - /* */ - /* PS_Unicode_Value_Func */ - /* */ - /* */ - /* A function used to return the Unicode index corresponding to a */ - /* given glyph name. */ - /* */ - /* */ - /* glyph_name :: The glyph name. */ - /* */ - /* */ - /* The Unicode character index resp. the non-Unicode value 0xFFFF if */ - /* the glyph name has no known Unicode meaning. */ - /* */ - /* */ - /* This function is able to map several different glyph names to the */ - /* same Unicode value, according to the rules defined in the Adobe */ - /* Glyph List table. */ - /* */ - /* This function will not be compiled if the configuration macro */ - /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */ - /* */ - typedef FT_ULong (*PS_Unicode_Value_Func)( const char* glyph_name ); - - - /*************************************************************************/ - /* */ - /* */ - /* PS_Unicode_Index_Func */ - /* */ - /* */ - /* A function used to return the glyph index corresponding to a given */ - /* Unicode value. */ - /* */ - /* */ - /* num_glyphs :: The number of glyphs in the face. */ - /* */ - /* glyph_names :: An array of glyph name pointers. */ - /* */ - /* unicode :: The Unicode value. */ - /* */ - /* */ - /* The glyph index resp. 0xFFFF if no glyph corresponds to this */ - /* Unicode value. */ - /* */ - /* */ - /* This function is able to recognize several glyph names per Unicode */ - /* value, according to the Adobe Glyph List. */ - /* */ - /* This function will not be compiled if the configuration macro */ - /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */ - /* */ - typedef FT_UInt (*PS_Unicode_Index_Func)( FT_UInt num_glyphs, - const char** glyph_names, - FT_ULong unicode ); - - - /*************************************************************************/ - /* */ - /* */ - /* PS_Macintosh_Name_Func */ - /* */ - /* */ - /* A function used to return the glyph name corresponding to an Apple */ - /* glyph name index. */ - /* */ - /* */ - /* name_index :: The index of the Mac name. */ - /* */ - /* */ - /* The glyph name, or 0 if the index is invalid. */ - /* */ - /* */ - /* This function will not be compiled if the configuration macro */ - /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES is undefined. */ - /* */ - typedef const char* (*PS_Macintosh_Name_Func)( FT_UInt name_index ); - - - typedef const char* (*PS_Adobe_Std_Strings_Func)( FT_UInt string_index ); - - - typedef struct PS_UniMap_ - { - FT_UInt unicode; - FT_UInt glyph_index; - - } PS_UniMap; - - - /*************************************************************************/ - /* */ - /* */ - /* PS_Unicodes */ - /* */ - /* */ - /* A simple table used to map Unicode values to glyph indices. It is */ - /* built by the PS_Build_Unicodes table according to the glyphs */ - /* present in a font file. */ - /* */ - /* */ - /* num_codes :: The number of glyphs in the font that match a given */ - /* Unicode value. */ - /* */ - /* unicodes :: An array of unicode values, sorted in increasing */ - /* order. */ - /* */ - /* gindex :: An array of glyph indices, corresponding to each */ - /* Unicode value. */ - /* */ - /* */ - /* Use the function PS_Lookup_Unicode() to retrieve the glyph index */ - /* corresponding to a given Unicode character code. */ - /* */ - typedef struct PS_Unicodes_ - { - FT_UInt num_maps; - PS_UniMap* maps; - - } PS_Unicodes; - - - typedef FT_Error (*PS_Build_Unicodes_Func)( FT_Memory memory, - FT_UInt num_glyphs, - const char** glyph_names, - PS_Unicodes* unicodes ); - - typedef FT_UInt (*PS_Lookup_Unicode_Func)( PS_Unicodes* unicodes, - FT_UInt unicode ); - - - /*************************************************************************/ - /* */ - /* */ - /* PSNames_Interface */ - /* */ - /* */ - /* This structure defines the PSNames interface. */ - /* */ - /* */ - /* unicode_value :: A function used to convert a glyph name */ - /* into a Unicode character code. */ - /* */ - /* build_unicodes :: A function which builds up the Unicode */ - /* mapping table. */ - /* */ - /* lookup_unicode :: A function used to return the glyph index */ - /* corresponding to a given Unicode */ - /* character. */ - /* */ - /* macintosh_name :: A function used to return the standard */ - /* Apple glyph Postscript name corresponding */ - /* to a given string index (used by the */ - /* TrueType `post' table). */ - /* */ - /* adobe_std_strings :: A function that returns a pointer to a */ - /* Adobe Standard String for a given SID. */ - /* */ - /* adobe_std_encoding :: A table of 256 unsigned shorts that maps */ - /* character codes in the Adobe Standard */ - /* Encoding to SIDs. */ - /* */ - /* adobe_expert_encoding :: A table of 256 unsigned shorts that maps */ - /* character codes in the Adobe Expert */ - /* Encoding to SIDs. */ - /* */ - /* */ - /* `unicode_value' and `unicode_index' will be set to 0 if the */ - /* configuration macro FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is */ - /* undefined. */ - /* */ - /* `macintosh_name' will be set to 0 if the configuration macro */ - /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES is undefined. */ - /* */ - typedef struct PSNames_Interface_ - { - PS_Unicode_Value_Func unicode_value; - PS_Build_Unicodes_Func build_unicodes; - PS_Lookup_Unicode_Func lookup_unicode; - PS_Macintosh_Name_Func macintosh_name; - - PS_Adobe_Std_Strings_Func adobe_std_strings; - const unsigned short* adobe_std_encoding; - const unsigned short* adobe_expert_encoding; - - } PSNames_Interface; - - -#endif /* PSNAMES_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/sfnt.h b/src/freetype/freetype/internal/sfnt.h deleted file mode 100644 index 380ee93dec..0000000000 --- a/src/freetype/freetype/internal/sfnt.h +++ /dev/null @@ -1,492 +0,0 @@ -/***************************************************************************/ -/* */ -/* sfnt.h */ -/* */ -/* High-level `sfnt' driver interface (specification). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef SFNT_H -#define SFNT_H - - -#include -#include -#include - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Init_Face_Func */ - /* */ - /* */ - /* First part of the SFNT face object initialization. This will find */ - /* the face in a SFNT file or collection, and load its format tag in */ - /* face->format_tag. */ - /* */ - /* */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The stream cursor must be at the font file's origin. */ - /* */ - /* This function recognizes fonts embedded in a `TrueType */ - /* collection'. */ - /* */ - /* Once the format tag has been validated by the font driver, it */ - /* should then call the TT_Load_Face_Func() callback to read the rest */ - /* of the SFNT tables in the object. */ - /* */ - typedef - FT_Error (*TT_Init_Face_Func)( FT_Stream stream, - TT_Face face, - FT_Int face_index, - FT_Int num_params, - FT_Parameter* params ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_Face_Func */ - /* */ - /* */ - /* Second part of the SFNT face object initialization. This will */ - /* load the common SFNT tables (head, OS/2, maxp, metrics, etc.) in */ - /* the face object. */ - /* */ - /* */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* This function must be called after TT_Init_Face_Func(). */ - /* */ - typedef - FT_Error (*TT_Load_Face_Func)( FT_Stream stream, - TT_Face face, - FT_Int face_index, - FT_Int num_params, - FT_Parameter* params ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Done_Face_Func */ - /* */ - /* */ - /* A callback used to delete the common SFNT data from a face. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* */ - /* This function does NOT destroy the face object. */ - /* */ - typedef - void (*TT_Done_Face_Func)( TT_Face face ); - - - typedef - FT_Module_Interface (*SFNT_Get_Interface_Func)( FT_Module module, - const char* interface ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_SFNT_Header_Func */ - /* */ - /* */ - /* Loads the header of a SFNT font file. Supports collections. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection. */ - /* */ - /* */ - /* sfnt :: The SFNT header. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The stream cursor must be at the font file's origin. */ - /* */ - /* This function recognizes fonts embedded in a `TrueType */ - /* collection'. */ - /* */ - /* This function checks that the header is valid by looking at the */ - /* values of `search_range', `entry_selector', and `range_shift'. */ - /* */ - typedef - FT_Error (*TT_Load_SFNT_Header_Func)( TT_Face face, - FT_Stream stream, - FT_Long face_index, - SFNT_Header* sfnt ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_Directory_Func */ - /* */ - /* */ - /* Loads the table directory into a face object. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* sfnt :: The SFNT header. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The stream cursor must be on the first byte after the 4-byte font */ - /* format tag. This is the case just after a call to */ - /* TT_Load_Format_Tag(). */ - /* */ - typedef - FT_Error (*TT_Load_Directory_Func)( TT_Face face, - FT_Stream stream, - SFNT_Header* sfnt ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_Any_Func */ - /* */ - /* */ - /* Loads any font table into client memory. */ - /* */ - /* */ - /* face :: The face object to look for. */ - /* */ - /* tag :: The tag of table to load. Use the value 0 if you want */ - /* to access the whole font file, else set this parameter */ - /* to a valid TrueType table tag that you can forge with */ - /* the MAKE_TT_TAG macro. */ - /* */ - /* offset :: The starting offset in the table (or the file if */ - /* tag == 0). */ - /* */ - /* length :: The address of the decision variable: */ - /* */ - /* If length == NULL: */ - /* Loads the whole table. Returns an error if */ - /* `offset' == 0! */ - /* */ - /* If *length == 0: */ - /* Exits immediately; returning the length of the given */ - /* table or of the font file, depending on the value of */ - /* `tag'. */ - /* */ - /* If *length != 0: */ - /* Loads the next `length' bytes of table or font, */ - /* starting at offset `offset' (in table or font too). */ - /* */ - /* */ - /* buffer :: The address of target buffer. */ - /* */ - /* */ - /* TrueType error code. 0 means success. */ - /* */ - typedef - FT_Error (*TT_Load_Any_Func)( TT_Face face, - FT_ULong tag, - FT_Long offset, - FT_Byte* buffer, - FT_ULong* length ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_SBit_Image_Func */ - /* */ - /* */ - /* Loads a given glyph sbit image from the font resource. This also */ - /* returns its metrics. */ - /* */ - /* */ - /* face :: The target face object. */ - /* */ - /* x_ppem :: The horizontal resolution in points per EM. */ - /* */ - /* y_ppem :: The vertical resolution in points per EM. */ - /* */ - /* glyph_index :: The current glyph index. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* */ - /* map :: The target pixmap. */ - /* */ - /* metrics :: A big sbit metrics structure for the glyph image. */ - /* */ - /* */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* glyph sbit exists for the index. */ - /* */ - /* */ - /* The `map.buffer' field is always freed before the glyph is loaded. */ - /* */ - typedef - FT_Error (*TT_Load_SBit_Image_Func)( TT_Face face, - FT_Int x_ppem, - FT_Int y_ppem, - FT_UInt glyph_index, - FT_UInt load_flags, - FT_Stream stream, - FT_Bitmap* map, - TT_SBit_Metrics* metrics ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Get_PS_Name_Func */ - /* */ - /* */ - /* Gets the PostScript glyph name of a glyph. */ - /* */ - /* */ - /* index :: The glyph index. */ - /* */ - /* PSname :: The address of a string pointer. Will be NULL in case */ - /* of error, otherwise it is a pointer to the glyph name. */ - /* */ - /* You must not modify the returned string! */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - typedef - FT_Error (*TT_Get_PS_Name_Func)( TT_Face face, - FT_UInt index, - FT_String** PSname ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_Metrics_Func */ - /* */ - /* */ - /* Loads the horizontal or vertical header in a face object. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load vertical metrics. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - typedef - FT_Error (*TT_Load_Metrics_Func)( TT_Face face, - FT_Stream stream, - FT_Bool vertical ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_CharMap_Load_Func */ - /* */ - /* */ - /* Loads a given TrueType character map into memory. */ - /* */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* stream :: A handle to the current stream object. */ - /* */ - /* */ - /* cmap :: A pointer to a cmap object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The function assumes that the stream is already in use (i.e., */ - /* opened). In case of error, all partially allocated tables are */ - /* released. */ - /* */ - typedef - FT_Error (*TT_CharMap_Load_Func)( TT_Face face, - TT_CMapTable* cmap, - FT_Stream input ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_CharMap_Free_Func */ - /* */ - /* */ - /* Destroys a character mapping table. */ - /* */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* cmap :: A handle to a cmap object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - typedef - FT_Error (*TT_CharMap_Free_Func)( TT_Face face, - TT_CMapTable* cmap ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_Table_Func */ - /* */ - /* */ - /* Loads a given TrueType table. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The function will use `face->goto_table' to seek the stream to */ - /* the start of the table. */ - /* */ - typedef - FT_Error (*TT_Load_Table_Func)( TT_Face face, - FT_Stream stream ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Free_Table_Func */ - /* */ - /* */ - /* Frees a given TrueType table. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - typedef - void (*TT_Free_Table_Func)( TT_Face face ); - - - /*************************************************************************/ - /* */ - /* */ - /* SFNT_Interface */ - /* */ - /* */ - /* This structure holds pointers to the functions used to load and */ - /* free the basic tables that are required in a `sfnt' font file. */ - /* */ - /* */ - /* Check the various xxx_Func() descriptions for details. */ - /* */ - typedef struct SFNT_Interface_ - { - TT_Goto_Table_Func goto_table; - - TT_Init_Face_Func init_face; - TT_Load_Face_Func load_face; - TT_Done_Face_Func done_face; - SFNT_Get_Interface_Func get_interface; - - TT_Load_Any_Func load_any; - TT_Load_SFNT_Header_Func load_sfnt_header; - TT_Load_Directory_Func load_directory; - - /* these functions are called by `load_face' but they can also */ - /* be called from external modules, if there is a need to do so */ - TT_Load_Table_Func load_header; - TT_Load_Metrics_Func load_metrics; - TT_Load_Table_Func load_charmaps; - TT_Load_Table_Func load_max_profile; - TT_Load_Table_Func load_os2; - TT_Load_Table_Func load_psnames; - - TT_Load_Table_Func load_names; - TT_Free_Table_Func free_names; - - /* optional tables */ - TT_Load_Table_Func load_hdmx; - TT_Free_Table_Func free_hdmx; - - TT_Load_Table_Func load_kerning; - TT_Load_Table_Func load_gasp; - TT_Load_Table_Func load_pclt; - - /* see `ttsbit.h' */ - TT_Load_Table_Func load_sbits; - TT_Load_SBit_Image_Func load_sbit_image; - TT_Free_Table_Func free_sbits; - - /* see `ttpost.h' */ - TT_Get_PS_Name_Func get_psname; - TT_Free_Table_Func free_psnames; - - /* see `ttcmap.h' */ - TT_CharMap_Load_Func load_charmap; - TT_CharMap_Free_Func free_charmap; - - } SFNT_Interface; - - -#endif /* SFNT_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/t1errors.h b/src/freetype/freetype/internal/t1errors.h deleted file mode 100644 index 58566d8ee5..0000000000 --- a/src/freetype/freetype/internal/t1errors.h +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************/ -/* */ -/* t1errors.h */ -/* */ -/* Type 1 error ID definitions (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef T1ERRORS_H -#define T1ERRORS_H - - - /************************ error codes declaration **************/ - - /* The error codes are grouped into `classes' used to indicate the */ - /* `level' at which the error happened. */ - /* */ - /* The class is given by an error code's high byte. */ - - - /* ------------- Success is always 0 -------- */ - -#define T1_Err_Ok FT_Err_Ok - - /* ----------- high level API errors -------- */ - -#define T1_Err_Invalid_File_Format FT_Err_Invalid_File_Format -#define T1_Err_Invalid_Argument FT_Err_Invalid_Argument -#define T1_Err_Invalid_Driver_Handle FT_Err_Invalid_Driver_Handle -#define T1_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle -#define T1_Err_Invalid_Size_Handle FT_Err_Invalid_Size_Handle -#define T1_Err_Invalid_Glyph_Handle FT_Err_Invalid_Slot_Handle -#define T1_Err_Invalid_CharMap_Handle FT_Err_Invalid_CharMap_Handle -#define T1_Err_Invalid_Glyph_Index FT_Err_Invalid_Glyph_Index - -#define T1_Err_Unimplemented_Feature FT_Err_Unimplemented_Feature - -#define T1_Err_Invalid_Engine FT_Err_Invalid_Driver_Handle - - /* ------------- internal errors ------------ */ - -#define T1_Err_Out_Of_Memory FT_Err_Out_Of_Memory -#define T1_Err_Unlisted_Object FT_Err_Unlisted_Object - - /* ------------ general glyph outline errors ------ */ - -#define T1_Err_Invalid_Composite FT_Err_Invalid_Composite - -#define T1_Err_Syntax_Error FT_Err_Invalid_File_Format -#define T1_Err_Stack_Underflow FT_Err_Invalid_File_Format -#define T1_Err_Stack_Overflow FT_Err_Invalid_File_Format - - -#endif /* T1ERRORS_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/t1types.h b/src/freetype/freetype/internal/t1types.h deleted file mode 100644 index 4d41a6b591..0000000000 --- a/src/freetype/freetype/internal/t1types.h +++ /dev/null @@ -1,188 +0,0 @@ -/***************************************************************************/ -/* */ -/* t1types.h */ -/* */ -/* Basic Type1/Type2 type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef T1TYPES_H -#define T1TYPES_H - - -#include -#include - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** REQUIRED TYPE1/TYPE2 TABLES DEFINITIONS ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* T1_Encoding */ - /* */ - /* */ - /* A structure modeling a custom encoding */ - /* */ - /* */ - /* num_chars :: The number of character codes in the encoding. */ - /* Usually 256. */ - /* */ - /* code_first :: The lowest valid character code in the encoding. */ - /* */ - /* code_last :: The highest valid character code in the encoding. */ - /* */ - /* char_index :: An array of corresponding glyph indices. */ - /* */ - /* char_name :: An array of corresponding glyph names. */ - /* */ - typedef struct T1_Encoding_ - { - FT_Int num_chars; - FT_Int code_first; - FT_Int code_last; - - FT_UShort* char_index; - FT_String** char_name; - - } T1_Encoding; - - - typedef enum T1_EncodingType_ - { - t1_encoding_none = 0, - t1_encoding_array, - t1_encoding_standard, - t1_encoding_expert - - } T1_EncodingType; - - - typedef struct T1_Font_ - { - - /* font info dictionary */ - T1_FontInfo font_info; - - /* private dictionary */ - T1_Private private_dict; - - /* top-level dictionary */ - FT_String* font_name; - - T1_EncodingType encoding_type; - T1_Encoding encoding; - - FT_Byte* subrs_block; - FT_Byte* charstrings_block; - FT_Byte* glyph_names_block; - - FT_Int num_subrs; - FT_Byte** subrs; - FT_Int* subrs_len; - - FT_Int num_glyphs; - FT_String** glyph_names; /* array of glyph names */ - FT_Byte** charstrings; /* array of glyph charstrings */ - FT_Int* charstrings_len; - - FT_Byte paint_type; - FT_Byte font_type; - FT_Matrix font_matrix; - FT_BBox font_bbox; - FT_Long font_id; - - FT_Int stroke_width; - - } T1_Font; - - - typedef struct CID_Subrs_ - { - FT_UInt num_subrs; - FT_Byte** code; - - } CID_Subrs; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** ORIGINAL T1_FACE CLASS DEFINITION ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This structure/class is defined here because it is common to the */ - /* following formats: TTF, OpenType-TT, and OpenType-CFF. */ - /* */ - /* Note, however, that the classes TT_Size, TT_GlyphSlot, and TT_CharMap */ - /* are not shared between font drivers, and are thus defined normally in */ - /* `ttobjs.h'. */ - /* */ - /*************************************************************************/ - - typedef struct T1_FaceRec_* T1_Face; - typedef struct CID_FaceRec_* CID_Face; - - - typedef struct T1_FaceRec_ - { - FT_FaceRec root; - T1_Font type1; - void* psnames; - void* afm_data; - FT_CharMapRec charmaprecs[2]; - FT_CharMap charmaps[2]; - PS_Unicodes unicode_map; - - /* support for Multiple Masters fonts */ - T1_Blend* blend; - - } T1_FaceRec; - - - typedef struct CID_FaceRec_ - { - FT_FaceRec root; - void* psnames; - CID_Info cid; - void* afm_data; - CID_Subrs* subrs; - - } CID_FaceRec; - - -#endif /* T1TYPES_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/t2errors.h b/src/freetype/freetype/internal/t2errors.h deleted file mode 100644 index d685220013..0000000000 --- a/src/freetype/freetype/internal/t2errors.h +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************/ -/* */ -/* t2errors.h */ -/* */ -/* OpenType error ID definitions (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef T2ERRORS_H -#define T2ERRORS_H - - - /*************************************************************************/ - /* */ - /* Error codes declaration */ - /* */ - /* The error codes are grouped in `classes' used to indicate the `level' */ - /* at which the error happened. The class is given by an error code's */ - /* high byte. */ - /* */ - /*************************************************************************/ - - - /* Success is always 0. */ - -#define T2_Err_Ok FT_Err_Ok - - /* High level API errors. */ - -#define T2_Err_Invalid_File_Format FT_Err_Invalid_File_Format -#define T2_Err_Invalid_Argument FT_Err_Invalid_Argument -#define T2_Err_Invalid_Driver_Handle FT_Err_Invalid_Driver_Handle -#define T2_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle -#define T2_Err_Invalid_Instance_Handle FT_Err_Invalid_Size_Handle -#define T2_Err_Invalid_Glyph_Handle FT_Err_Invalid_Slot_Handle -#define T2_Err_Invalid_CharMap_Handle FT_Err_Invalid_CharMap_Handle -#define T2_Err_Invalid_Glyph_Index FT_Err_Invalid_Glyph_Index - -#define T2_Err_Unimplemented_Feature FT_Err_Unimplemented_Feature - -#define T2_Err_Invalid_Engine FT_Err_Invalid_Driver_Handle - - /* Internal errors. */ - -#define T2_Err_Out_Of_Memory FT_Err_Out_Of_Memory -#define T2_Err_Unlisted_Object FT_Err_Unlisted_Object - - /* General glyph outline errors. */ - -#define T2_Err_Invalid_Composite FT_Err_Invalid_Composite - - /* Bytecode interpreter error codes. */ - - /* These error codes are produced by the TrueType */ - /* bytecode interpreter. They usually indicate a */ - /* broken font file, a broken glyph within a font */ - /* file, or a bug in the interpreter! */ - -#define T2_Err_Invalid_Opcode 0x500 -#define T2_Err_Too_Few_Arguments 0x501 -#define T2_Err_Stack_Overflow 0x502 -#define T2_Err_Code_Overflow 0x503 -#define T2_Err_Bad_Argument 0x504 -#define T2_Err_Divide_By_Zero 0x505 -#define T2_Err_Storage_Overflow 0x506 -#define T2_Err_Cvt_Overflow 0x507 -#define T2_Err_Invalid_Reference 0x508 -#define T2_Err_Invalid_Distance 0x509 -#define T2_Err_Interpolate_Twilight 0x50A -#define T2_Err_Debug_OpCode 0x50B -#define T2_Err_ENDF_In_Exec_Stream 0x50C -#define T2_Err_Out_Of_CodeRanges 0x50D -#define T2_Err_Nested_DEFS 0x50E -#define T2_Err_Invalid_CodeRange 0x50F -#define T2_Err_Invalid_Displacement 0x510 -#define T2_Err_Execution_Too_Long 0x511 - -#define T2_Err_Too_Many_Instruction_Defs 0x512 -#define T2_Err_Too_Many_Function_Defs 0x513 - - /* Other TrueType specific error codes. */ - -#define T2_Err_Table_Missing 0x520 -#define T2_Err_Too_Many_Extensions 0x521 -#define T2_Err_Extensions_Unsupported 0x522 -#define T2_Err_Invalid_Extension_Id 0x523 - -#define T2_Err_No_Vertical_Data 0x524 - -#define T2_Err_Max_Profile_Missing 0x530 -#define T2_Err_Header_Table_Missing 0x531 -#define T2_Err_Horiz_Header_Missing 0x532 -#define T2_Err_Locations_Missing 0x533 -#define T2_Err_Name_Table_Missing 0x534 -#define T2_Err_CMap_Table_Missing 0x535 -#define T2_Err_Hmtx_Table_Missing 0x536 -#define T2_Err_OS2_Table_Missing 0x537 -#define T2_Err_Post_Table_Missing 0x538 - -#define T2_Err_Invalid_Horiz_Metrics 0x540 -#define T2_Err_Invalid_CharMap_Format 0x541 -#define T2_Err_Invalid_PPem 0x542 -#define T2_Err_Invalid_Vert_Metrics 0x543 - -#define T2_Err_Could_Not_Find_Context 0x550 - - -#endif /* T2ERRORS_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/t2types.h b/src/freetype/freetype/internal/t2types.h deleted file mode 100644 index 033f315e95..0000000000 --- a/src/freetype/freetype/internal/t2types.h +++ /dev/null @@ -1,218 +0,0 @@ -/***************************************************************************/ -/* */ -/* t2types.h */ -/* */ -/* Basic OpenType/CFF type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef T2TYPES_H -#define T2TYPES_H - - -#include - - - /*************************************************************************/ - /* */ - /* */ - /* CFF_Index */ - /* */ - /* */ - /* A structure used to model a CFF Index table. */ - /* */ - /* */ - /* stream :: XXX */ - /* */ - /* count :: The number of elements in the index. */ - /* */ - /* off_size :: The size in bytes of object offsets in index. */ - /* */ - /* data_offset :: The position of first data byte in the index's */ - /* bytes. */ - /* */ - /* offsets :: XXX */ - /* */ - /* bytes :: If the index is loaded in memory, its bytes. */ - /* */ - typedef struct CFF_Index_ - { - FT_Stream stream; - FT_UInt count; - FT_Byte off_size; - FT_ULong data_offset; - - FT_ULong* offsets; - FT_Byte* bytes; - - } CFF_Index; - - - typedef struct CFF_Font_Dict_ - { - FT_UInt version; - FT_UInt notice; - FT_UInt copyright; - FT_UInt full_name; - FT_UInt family_name; - FT_UInt weight; - FT_Bool is_fixed_pitch; - FT_Fixed italic_angle; - FT_Pos underline_position; - FT_Pos underline_thickness; - FT_Int paint_type; - FT_Int charstring_type; - FT_Matrix font_matrix; - FT_ULong unique_id; - FT_BBox font_bbox; - FT_Pos stroke_width; - FT_ULong charset_offset; - FT_ULong encoding_offset; - FT_ULong charstrings_offset; - FT_ULong private_offset; - FT_ULong private_size; - FT_Long synthetic_base; - FT_UInt embedded_postscript; - FT_UInt base_font_name; - FT_UInt postscript; - - /* these should only be used for the top-level font dictionary */ - FT_UInt cid_registry; - FT_UInt cid_ordering; - FT_ULong cid_supplement; - - FT_Long cid_font_version; - FT_Long cid_font_revision; - FT_Long cid_font_type; - FT_Long cid_count; - FT_ULong cid_uid_base; - FT_ULong cid_fd_array_offset; - FT_ULong cid_fd_select_offset; - FT_UInt cid_font_name; - - } CFF_Font_Dict; - - - typedef struct CFF_Private_ - { - FT_Byte num_blue_values; - FT_Byte num_other_blues; - FT_Byte num_family_blues; - FT_Byte num_family_other_blues; - - FT_Pos blue_values[14]; - FT_Pos other_blues[10]; - FT_Pos family_blues[14]; - FT_Pos family_other_blues[10]; - - FT_Fixed blue_scale; - FT_Pos blue_shift; - FT_Pos blue_fuzz; - FT_Pos standard_width; - FT_Pos standard_height; - - FT_Byte num_snap_widths; - FT_Byte num_snap_heights; - FT_Pos snap_widths[13]; - FT_Pos snap_heights[13]; - FT_Bool force_bold; - FT_Fixed force_bold_threshold; - FT_Int lenIV; - FT_Int language_group; - FT_Fixed expansion_factor; - FT_Long initial_random_seed; - FT_ULong local_subrs_offset; - FT_Pos default_width; - FT_Pos nominal_width; - - } CFF_Private; - - - typedef struct CFF_FD_Select_ - { - FT_Byte format; - FT_UInt range_count; - - /* that's the table, taken from the file `as is' */ - FT_Byte* data; - FT_UInt data_size; - - /* small cache for format 3 only */ - FT_UInt cache_first; - FT_UInt cache_count; - FT_Byte cache_fd; - - } CFF_FD_Select; - - - /* A SubFont packs a font dict and a private dict together. They are */ - /* needed to support CID-keyed CFF fonts. */ - typedef struct CFF_SubFont_ - { - CFF_Font_Dict font_dict; - CFF_Private private_dict; - - CFF_Index local_subrs_index; - FT_UInt num_local_subrs; - FT_Byte** local_subrs; - - } CFF_SubFont; - - - /* maximum number of sub-fonts in a CID-keyed file */ -#define CFF_MAX_CID_FONTS 16 - - - typedef struct CFF_Font_ - { - FT_Stream stream; - FT_Memory memory; - FT_UInt num_faces; - FT_UInt num_glyphs; - - FT_Byte version_major; - FT_Byte version_minor; - FT_Byte header_size; - FT_Byte absolute_offsize; - - - CFF_Index name_index; - CFF_Index top_dict_index; - CFF_Index string_index; - CFF_Index global_subrs_index; - - /* we don't load the Encoding and CharSet tables */ - - CFF_Index charstrings_index; - CFF_Index font_dict_index; - CFF_Index private_index; - CFF_Index local_subrs_index; - - FT_String* font_name; - FT_UInt num_global_subrs; - FT_Byte** global_subrs; - - CFF_SubFont top_font; - FT_UInt num_subfonts; - CFF_SubFont* subfonts[CFF_MAX_CID_FONTS]; - - CFF_FD_Select fd_select; - - } CFF_Font; - - -#endif /* T2TYPES_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/tterrors.h b/src/freetype/freetype/internal/tterrors.h deleted file mode 100644 index b53e9f3da4..0000000000 --- a/src/freetype/freetype/internal/tterrors.h +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************/ -/* */ -/* tterrors.h */ -/* */ -/* TrueType error ID definitions (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTERRORS_H -#define TTERRORS_H - - - /*************************************************************************/ - /* */ - /* Error codes declaration */ - /* */ - /* The error codes are grouped in `classes' used to indicate the `level' */ - /* at which the error happened. The class is given by an error code's */ - /* high byte. */ - /* */ - /*************************************************************************/ - - - /* Success is always 0. */ - -#define TT_Err_Ok FT_Err_Ok - - /* High level API errors. */ - -#define TT_Err_Invalid_File_Format FT_Err_Invalid_File_Format -#define TT_Err_Invalid_Argument FT_Err_Invalid_Argument -#define TT_Err_Invalid_Driver_Handle FT_Err_Invalid_Driver_Handle -#define TT_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle -#define TT_Err_Invalid_Instance_Handle FT_Err_Invalid_Size_Handle -#define TT_Err_Invalid_Glyph_Handle FT_Err_Invalid_Slot_Handle -#define TT_Err_Invalid_CharMap_Handle FT_Err_Invalid_CharMap_Handle -#define TT_Err_Invalid_Glyph_Index FT_Err_Invalid_Glyph_Index - -#define TT_Err_Unimplemented_Feature FT_Err_Unimplemented_Feature - -#define TT_Err_Invalid_Engine FT_Err_Invalid_Driver_Handle - - /* Internal errors. */ - -#define TT_Err_Out_Of_Memory FT_Err_Out_Of_Memory -#define TT_Err_Unlisted_Object FT_Err_Unlisted_Object - - /* General glyph outline errors. */ - -#define TT_Err_Too_Many_Ins FT_Err_Too_Many_Hints -#define TT_Err_Invalid_Composite FT_Err_Invalid_Composite - - /* Bytecode interpreter error codes. */ - - /* These error codes are produced by the TrueType */ - /* bytecode interpreter. They usually indicate a */ - /* broken font file, a broken glyph within a font */ - /* file, or a bug in the interpreter! */ - -#define TT_Err_Invalid_Opcode 0x400 -#define TT_Err_Too_Few_Arguments 0x401 -#define TT_Err_Stack_Overflow 0x402 -#define TT_Err_Code_Overflow 0x403 -#define TT_Err_Bad_Argument 0x404 -#define TT_Err_Divide_By_Zero 0x405 -#define TT_Err_Storage_Overflow 0x406 -#define TT_Err_Cvt_Overflow 0x407 -#define TT_Err_Invalid_Reference 0x408 -#define TT_Err_Invalid_Distance 0x409 -#define TT_Err_Interpolate_Twilight 0x40A -#define TT_Err_Debug_OpCode 0x40B -#define TT_Err_ENDF_In_Exec_Stream 0x40C -#define TT_Err_Out_Of_CodeRanges 0x40D -#define TT_Err_Nested_DEFS 0x40E -#define TT_Err_Invalid_CodeRange 0x40F -#define TT_Err_Invalid_Displacement 0x410 -#define TT_Err_Execution_Too_Long 0x411 -#define TT_Err_Too_Many_Function_Defs 0x412 -#define TT_Err_Too_Many_Instruction_Defs 0x413 - - /* Other TrueType specific error codes. */ - -#define TT_Err_Table_Missing 0x420 -#define TT_Err_Too_Many_Extensions 0x421 -#define TT_Err_Extensions_Unsupported 0x422 -#define TT_Err_Invalid_Extension_Id 0x423 - -#define TT_Err_No_Vertical_Data 0x424 - -#define TT_Err_Max_Profile_Missing 0x430 -#define TT_Err_Header_Table_Missing 0x431 -#define TT_Err_Horiz_Header_Missing 0x432 -#define TT_Err_Locations_Missing 0x433 -#define TT_Err_Name_Table_Missing 0x434 -#define TT_Err_CMap_Table_Missing 0x435 -#define TT_Err_Hmtx_Table_Missing 0x436 -#define TT_Err_OS2_Table_Missing 0x437 -#define TT_Err_Post_Table_Missing 0x438 - -#define TT_Err_Invalid_Horiz_Metrics 0x440 -#define TT_Err_Invalid_CharMap_Format 0x441 -#define TT_Err_Invalid_PPem 0x442 -#define TT_Err_Invalid_Vert_Metrics 0x443 - -#define TT_Err_Could_Not_Find_Context 0x450 - - -#endif /* TTERRORS_H */ - - -/* END */ diff --git a/src/freetype/freetype/internal/tttypes.h b/src/freetype/freetype/internal/tttypes.h deleted file mode 100644 index 1fd43ceb50..0000000000 --- a/src/freetype/freetype/internal/tttypes.h +++ /dev/null @@ -1,1582 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttypes.h */ -/* */ -/* Basic SFNT/TrueType type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTTYPES_H -#define TTTYPES_H - - -#include - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* TTC_Header */ - /* */ - /* */ - /* TrueType collection header. This table contains the offsets of */ - /* the font headers of each distinct TrueType face in the file. */ - /* */ - /* */ - /* tag :: Must be `ttc ' to indicate a TrueType collection. */ - /* */ - /* version :: The version number. */ - /* */ - /* count :: The number of faces in the collection. The */ - /* specification says this should be an unsigned long, but */ - /* we use a signed long since we need the value -1 for */ - /* specific purposes. */ - /* */ - /* offsets :: The offsets of the font headers, one per face. */ - /* */ - typedef struct TTC_Header_ - { - FT_ULong tag; - FT_Fixed version; - FT_Long count; - FT_ULong* offsets; - - } TTC_Header; - - - /*************************************************************************/ - /* */ - /* */ - /* SFNT_Header */ - /* */ - /* */ - /* SFNT file format header. */ - /* */ - /* */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of tables in file. */ - /* */ - /* search_range :: Must be 16*(max power of 2 <= num_tables). */ - /* */ - /* entry_selector :: Must be log2 of search_range/16. */ - /* */ - /* range_shift :: Must be num_tables*16 - search_range. */ - /* */ - typedef struct SFNT_Header_ - { - FT_ULong format_tag; - FT_UShort num_tables; - FT_UShort search_range; - FT_UShort entry_selector; - FT_UShort range_shift; - - } SFNT_Header; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_TableDir */ - /* */ - /* */ - /* This structure models a TrueType table directory. It is used to */ - /* access the various tables of the font face. */ - /* */ - /* */ - /* version :: The version number; starts with 0x00010000. */ - /* */ - /* numTables :: The number of tables. */ - /* */ - /* searchRange :: Unused. */ - /* */ - /* entrySelector :: Unused. */ - /* */ - /* rangeShift :: Unused. */ - /* */ - /* */ - /* This structure is only used during font opening. */ - /* */ - typedef struct TT_TableDir_ - { - FT_Fixed version; /* should be 0x10000 */ - FT_UShort numTables; /* number of tables */ - - FT_UShort searchRange; /* These parameters are only used */ - FT_UShort entrySelector; /* for a dichotomy search in the */ - FT_UShort rangeShift; /* directory. We ignore them. */ - - } TT_TableDir; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Table */ - /* */ - /* */ - /* This structure describes a given table of a TrueType font. */ - /* */ - /* */ - /* Tag :: A four-bytes tag describing the table. */ - /* */ - /* CheckSum :: The table checksum. This value can be ignored. */ - /* */ - /* Offset :: The offset of the table from the start of the TrueType */ - /* font in its resource. */ - /* */ - /* Length :: The table length (in bytes). */ - /* */ - typedef struct TT_Table_ - { - FT_ULong Tag; /* table type */ - FT_ULong CheckSum; /* table checksum */ - FT_ULong Offset; /* table file offset */ - FT_ULong Length; /* table length */ - - } TT_Table; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_CMapDir */ - /* */ - /* */ - /* This structure describes the directory of the `cmap' table, */ - /* containing the font's character mappings table. */ - /* */ - /* */ - /* tableVersionNumber :: The version number. */ - /* */ - /* numCMaps :: The number of charmaps in the font. */ - /* */ - /* */ - /* This structure is only used during font loading. */ - /* */ - typedef struct TT_CMapDir_ - { - FT_UShort tableVersionNumber; - FT_UShort numCMaps; - - } TT_CMapDir; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_CMapDirEntry */ - /* */ - /* */ - /* This structure describes a charmap in a TrueType font. */ - /* */ - /* */ - /* platformID :: An ID used to specify for which platform this */ - /* charmap is defined (FreeType manages all platforms). */ - /* */ - /* encodingID :: A platform-specific ID used to indicate which source */ - /* encoding is used in this charmap. */ - /* */ - /* offset :: The offset of the charmap relative to the start of */ - /* the `cmap' table. */ - /* */ - /* */ - /* This structure is only used during font loading. */ - /* */ - typedef struct TT_CMapDirEntry_ - { - FT_UShort platformID; - FT_UShort platformEncodingID; - FT_Long offset; - - } TT_CMapDirEntry; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_LongMetrics */ - /* */ - /* */ - /* A structure modeling the long metrics of the `hmtx' and `vmtx' */ - /* TrueType tables. The values are expressed in font units. */ - /* */ - /* */ - /* advance :: The advance width or height for the glyph. */ - /* */ - /* bearing :: The left-side or top-side bearing for the glyph. */ - /* */ - typedef struct TT_LongMetrics_ - { - FT_UShort advance; - FT_Short bearing; - - } TT_LongMetrics; - - - /*************************************************************************/ - /* */ - /* TT_ShortMetrics */ - /* */ - /* */ - /* A simple type to model the short metrics of the `hmtx' and `vmtx' */ - /* tables. */ - /* */ - typedef FT_Short TT_ShortMetrics; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_NameRec */ - /* */ - /* */ - /* A structure modeling TrueType name records. Name records are used */ - /* to store important strings like family name, style name, */ - /* copyright, etc. in _localized_ versions (i.e., language, encoding, */ - /* etc). */ - /* */ - /* */ - /* platformID :: The ID of the name's encoding platform. */ - /* */ - /* encodingID :: The platform-specific ID for the name's encoding. */ - /* */ - /* languageID :: The platform-specific ID for the name's language. */ - /* */ - /* nameID :: The ID specifying what kind of name this is. */ - /* */ - /* stringLength :: The length of the string in bytes. */ - /* */ - /* stringOffset :: The offset to the string in the `name' table. */ - /* */ - /* string :: A pointer to the string's bytes. Note that these */ - /* are usually UTF-16 encoded characters. */ - /* */ - typedef struct TT_NameRec_ - { - FT_UShort platformID; - FT_UShort encodingID; - FT_UShort languageID; - FT_UShort nameID; - FT_UShort stringLength; - FT_UShort stringOffset; - - /* this last field is not defined in the spec */ - /* but used by the FreeType engine */ - - FT_Byte* string; - - } TT_NameRec; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_NameTable */ - /* */ - /* */ - /* A structure modeling the TrueType name table. */ - /* */ - /* */ - /* format :: The format of the name table. */ - /* */ - /* numNameRecords :: The number of names in table. */ - /* */ - /* storageOffset :: The offset of the name table in the `name' */ - /* TrueType table. */ - /* */ - /* names :: An array of name records. */ - /* */ - /* storage :: The names storage area. */ - /* */ - typedef struct TT_NameTable_ - { - FT_UShort format; - FT_UShort numNameRecords; - FT_UShort storageOffset; - TT_NameRec* names; - FT_Byte* storage; - - } TT_NameTable; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* TT_GaspRange */ - /* */ - /* */ - /* A tiny structure used to model a gasp range according to the */ - /* TrueType specification. */ - /* */ - /* */ - /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */ - /* */ - /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */ - /* modes to be used. */ - /* */ - typedef struct TT_GaspRange_ - { - FT_UShort maxPPEM; - FT_UShort gaspFlag; - - } TT_GaspRange; - - -#define TT_GASP_GRIDFIT 0x01 -#define TT_GASP_DOGRAY 0x02 - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Gasp */ - /* */ - /* */ - /* A structure modeling the TrueType `gasp' table used to specify */ - /* grid-fitting and anti-aliasing behaviour. */ - /* */ - /* */ - /* version :: The version number. */ - /* */ - /* numRanges :: The number of gasp ranges in table. */ - /* */ - /* gaspRanges :: An array of gasp ranges. */ - /* */ - typedef struct TT_Gasp_ - { - FT_UShort version; - FT_UShort numRanges; - TT_GaspRange* gaspRanges; - - } TT_Gasp; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_HdmxRec */ - /* */ - /* */ - /* A small structure used to model the pre-computed widths of a given */ - /* size. They are found in the `hdmx' table. */ - /* */ - /* */ - /* ppem :: The pixels per EM value at which these metrics apply. */ - /* */ - /* max_width :: The maximum advance width for this metric. */ - /* */ - /* widths :: An array of widths. Note: These are 8-bit bytes. */ - /* */ - typedef struct TT_HdmxRec_ - { - FT_Byte ppem; - FT_Byte max_width; - FT_Byte* widths; - - } TT_HdmxRec; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Hdmx */ - /* */ - /* */ - /* A structure used to model the `hdmx' table, which contains */ - /* pre-computed widths for a set of given sizes/dimensions. */ - /* */ - /* */ - /* version :: The version number. */ - /* */ - /* num_records :: The number of hdmx records. */ - /* */ - /* records :: An array of hdmx records. */ - /* */ - typedef struct TT_Hdmx_ - { - FT_UShort version; - FT_Short num_records; - TT_HdmxRec* records; - - } TT_Hdmx; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Kern_0_Pair */ - /* */ - /* */ - /* A structure used to model a kerning pair for the kerning table */ - /* format 0. The engine now loads this table if it finds one in the */ - /* font file. */ - /* */ - /* */ - /* left :: The index of the left glyph in pair. */ - /* */ - /* right :: The index of the right glyph in pair. */ - /* */ - /* value :: The kerning distance. A positive value spaces the */ - /* glyphs, a negative one makes them closer. */ - /* */ - typedef struct TT_Kern_0_Pair_ - { - FT_UShort left; /* index of left glyph in pair */ - FT_UShort right; /* index of right glyph in pair */ - FT_FWord value; /* kerning value */ - - } TT_Kern_0_Pair; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** EMBEDDED BITMAPS SUPPORT ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* TT_SBit_Metrics */ - /* */ - /* */ - /* A structure used to hold the big metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or `bdat' (Apple) table. */ - /* */ - /* */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* horiBearingX :: The horizontal left bearing. */ - /* */ - /* horiBearingY :: The horizontal top bearing. */ - /* */ - /* horiAdvance :: The horizontal advance. */ - /* */ - /* vertBearingX :: The vertical left bearing. */ - /* */ - /* vertBearingY :: The vertical top bearing. */ - /* */ - /* vertAdvance :: The vertical advance. */ - /* */ - typedef struct TT_SBit_Metrics_ - { - FT_Byte height; - FT_Byte width; - - FT_Char horiBearingX; - FT_Char horiBearingY; - FT_Byte horiAdvance; - - FT_Char vertBearingX; - FT_Char vertBearingY; - FT_Byte vertAdvance; - - } TT_SBit_Metrics; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_SBit_Small_Metrics */ - /* */ - /* */ - /* A structure used to hold the small metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */ - /* */ - /* */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* bearingX :: The left-side bearing. */ - /* */ - /* bearingY :: The top-side bearing. */ - /* */ - /* advance :: The advance width or height. */ - /* */ - typedef struct TT_SBit_Small_Metrics_ - { - FT_Byte height; - FT_Byte width; - - FT_Char bearingX; - FT_Char bearingY; - FT_Byte advance; - - } TT_SBit_Small_Metrics; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_SBit_Line_Metrics */ - /* */ - /* */ - /* A structure used to describe the text line metrics of a given */ - /* bitmap strike, for either a horizontal or vertical layout. */ - /* */ - /* */ - /* ascender :: The ascender in pixels. */ - /* */ - /* descender :: The descender in pixels. */ - /* */ - /* max_width :: The maximum glyph width in pixels. */ - /* */ - /* caret_slope_enumerator :: Rise of the caret slope, typically set */ - /* to 1 for non-italic fonts. */ - /* */ - /* caret_slope_denominator :: Rise of the caret slope, typically set */ - /* to 0 for non-italic fonts. */ - /* */ - /* caret_offset :: Offset in pixels to move the caret for */ - /* proper positioning. */ - /* */ - /* min_origin_SB :: Minimum of horiBearingX (resp. */ - /* vertBearingY). */ - /* min_advance_SB :: Minimum of */ - /* */ - /* horizontal advance - */ - /* ( horiBearingX + width ) */ - /* */ - /* resp. */ - /* */ - /* vertical advance - */ - /* ( vertBearingY + height ) */ - /* */ - /* max_before_BL :: Maximum of horiBearingY (resp. */ - /* vertBearingY). */ - /* */ - /* min_after_BL :: Minimum of */ - /* */ - /* horiBearingY - height */ - /* */ - /* resp. */ - /* */ - /* vertBearingX - width */ - /* */ - /* pads :: Unused (to make the size of the record */ - /* a multiple of 32 bits. */ - /* */ - typedef struct TT_SBit_Line_Metrics_ - { - FT_Char ascender; - FT_Char descender; - FT_Byte max_width; - FT_Char caret_slope_numerator; - FT_Char caret_slope_denominator; - FT_Char caret_offset; - FT_Char min_origin_SB; - FT_Char min_advance_SB; - FT_Char max_before_BL; - FT_Char min_after_BL; - FT_Char pads[2]; - - } TT_SBit_Line_Metrics; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_SBit_Range */ - /* */ - /* */ - /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* */ - /* first_glyph :: The first glyph index in the range. */ - /* */ - /* last_glyph :: The last glyph index in the range. */ - /* */ - /* index_format :: The format of index table. Valid values are 1 */ - /* to 5. */ - /* */ - /* image_format :: The format of `EBDT' image data. */ - /* */ - /* image_offset :: The offset to image data in `EBDT'. */ - /* */ - /* image_size :: For index formats 2 and 5. This is the size in */ - /* bytes of each glyph bitmap. */ - /* */ - /* big_metrics :: For index formats 2 and 5. This is the big */ - /* metrics for each glyph bitmap. */ - /* */ - /* num_glyphs :: For index formats 4 and 5. This is the number of */ - /* glyphs in the code array. */ - /* */ - /* glyph_offsets :: For index formats 1 and 3. */ - /* */ - /* glyph_codes :: For index formats 4 and 5. */ - /* */ - /* table_offset :: The offset of the index table in the `EBLC' */ - /* table. Only used during strike loading. */ - /* */ - typedef struct TT_SBit_Range - { - FT_UShort first_glyph; - FT_UShort last_glyph; - - FT_UShort index_format; - FT_UShort image_format; - FT_ULong image_offset; - - FT_ULong image_size; - TT_SBit_Metrics metrics; - FT_ULong num_glyphs; - - FT_ULong* glyph_offsets; - FT_UShort* glyph_codes; - - FT_ULong table_offset; - - } TT_SBit_Range; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_SBit_Strike */ - /* */ - /* */ - /* A structure used describe a given bitmap strike in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* */ - /* num_index_ranges :: The number of index ranges. */ - /* */ - /* index_ranges :: An array of glyph index ranges. */ - /* */ - /* color_ref :: Unused. A color reference? */ - /* */ - /* hori :: The line metrics for horizontal layouts. */ - /* */ - /* vert :: The line metrics for vertical layouts. */ - /* */ - /* start_glyph :: The lowest glyph index for this strike. */ - /* */ - /* end_glyph :: The highest glyph index for this strike. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */ - /* and 8. */ - /* */ - /* flags :: Is this a vertical or horizontal strike? */ - /* */ - typedef struct TT_SBit_Strike_ - { - FT_Int num_ranges; - TT_SBit_Range* sbit_ranges; - FT_ULong ranges_offset; - - FT_ULong color_ref; - - TT_SBit_Line_Metrics hori; - TT_SBit_Line_Metrics vert; - - FT_UShort start_glyph; - FT_UShort end_glyph; - - FT_Byte x_ppem; - FT_Byte y_ppem; - - FT_Byte bit_depth; - FT_Char flags; - - } TT_SBit_Strike; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_SBit_Component */ - /* */ - /* */ - /* A simple structure to describe a compound sbit element. */ - /* */ - /* */ - /* glyph_code :: The element's glyph index. */ - /* */ - /* x_offset :: The element's left bearing. */ - /* */ - /* y_offset :: The element's top bearing. */ - /* */ - typedef struct TT_SBit_Component_ - { - FT_UShort glyph_code; - - FT_Char x_offset; - FT_Char y_offset; - - } TT_SBit_Component; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_SBit_Scale */ - /* */ - /* */ - /* A structure used describe a given bitmap scaling table, as defined */ - /* in the `EBSC' table. */ - /* */ - /* */ - /* hori :: The horizontal line metrics. */ - /* */ - /* vert :: The vertical line metrics. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* x_ppem_substitute :: Substitution x_ppem value. */ - /* */ - /* y_ppem_substitute :: Substitution y_ppem value. */ - /* */ - typedef struct TT_SBit_Scale_ - { - TT_SBit_Line_Metrics hori; - TT_SBit_Line_Metrics vert; - - FT_Byte x_ppem; - FT_Byte y_ppem; - - FT_Byte x_ppem_substitute; - FT_Byte y_ppem_substitute; - - } TT_SBit_Scale; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Post_20 */ - /* */ - /* */ - /* Postscript names sub-table, format 2.0. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* */ - /* num_glyphs :: The number of named glyphs in the table. */ - /* */ - /* num_names :: The number of PS names stored in the table. */ - /* */ - /* glyph_indices :: The indices of the glyphs in the names arrays. */ - /* */ - /* glyph_names :: The PS names not in Mac Encoding. */ - /* */ - typedef struct TT_Post_20_ - { - FT_UShort num_glyphs; - FT_UShort num_names; - FT_UShort* glyph_indices; - FT_Char** glyph_names; - - } TT_Post_20; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Post_25 */ - /* */ - /* */ - /* Postscript names sub-table, format 2.5. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* */ - /* num_glyphs :: The number of glyphs in the table. */ - /* */ - /* offsets :: An array of signed offsets in a normal Mac */ - /* Postscript name encoding. */ - /* */ - typedef struct TT_Post_25_ - { - FT_UShort num_glyphs; - FT_Char* offsets; - - } TT_Post_25; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Post_Names */ - /* */ - /* */ - /* Postscript names table, either format 2.0 or 2.5. */ - /* */ - /* */ - /* loaded :: A flag to indicate whether the PS names are loaded. */ - /* */ - /* format_20 :: The sub-table used for format 2.0. */ - /* */ - /* format_25 :: The sub-table used for format 2.5. */ - /* */ - typedef struct TT_Post_Names_ - { - FT_Bool loaded; - - union - { - TT_Post_20 format_20; - TT_Post_25 format_25; - - } names; - - } TT_Post_Names; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** TRUETYPE CHARMAPS SUPPORT ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* format 0 */ - - typedef struct TT_CMap0_ - { - FT_Byte* glyphIdArray; - - } TT_CMap0; - - - /* format 2 */ - - typedef struct TT_CMap2SubHeader_ - { - FT_UShort firstCode; /* first valid low byte */ - FT_UShort entryCount; /* number of valid low bytes */ - FT_Short idDelta; /* delta value to glyphIndex */ - FT_UShort idRangeOffset; /* offset from here to 1st code */ - - } TT_CMap2SubHeader; - - - typedef struct TT_CMap2_ - { - FT_UShort* subHeaderKeys; - /* high byte mapping table */ - /* value = subHeader index * 8 */ - - TT_CMap2SubHeader* subHeaders; - FT_UShort* glyphIdArray; - FT_UShort numGlyphId; /* control value */ - - } TT_CMap2; - - - /* format 4 */ - - typedef struct TT_CMap4Segment_ - { - FT_UShort endCount; - FT_UShort startCount; - FT_Short idDelta; - FT_UShort idRangeOffset; - - } TT_CMap4Segment; - - - typedef struct TT_CMap4_ - { - FT_UShort segCountX2; /* number of segments * 2 */ - FT_UShort searchRange; /* these parameters can be used */ - FT_UShort entrySelector; /* for a binary search */ - FT_UShort rangeShift; - - TT_CMap4Segment* segments; - FT_UShort* glyphIdArray; - FT_UShort numGlyphId; /* control value */ - - TT_CMap4Segment* last_segment; /* last used segment; this is a small */ - /* cache to potentially increase speed */ - } TT_CMap4; - - - /* format 6 */ - - typedef struct TT_CMap6_ - { - FT_UShort firstCode; /* first character code of subrange */ - FT_UShort entryCount; /* number of character codes in subrange */ - - FT_UShort* glyphIdArray; - - } TT_CMap6; - - - typedef struct TT_CMapTable_ TT_CMapTable; - - - typedef - FT_UInt (*TT_CharMap_Func)( TT_CMapTable* charmap, - FT_ULong char_code ); - - - /* charmap table */ - struct TT_CMapTable_ - { - FT_UShort platformID; - FT_UShort platformEncodingID; - FT_UShort format; - FT_UShort length; - FT_UShort version; - - FT_Bool loaded; - FT_ULong offset; - - union - { - TT_CMap0 cmap0; - TT_CMap2 cmap2; - TT_CMap4 cmap4; - TT_CMap6 cmap6; - } c; - - TT_CharMap_Func get_index; - }; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_CharMapRec */ - /* */ - /* */ - /* The TrueType character map object type. */ - /* */ - /* */ - /* root :: The parent character map structure. */ - /* */ - /* cmap :: The used character map. */ - /* */ - typedef struct TT_CharMapRec_ - { - FT_CharMapRec root; - TT_CMapTable cmap; - - } TT_CharMapRec; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** ORIGINAL TT_FACE CLASS DEFINITION ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This structure/class is defined here because it is common to the */ - /* following formats: TTF, OpenType-TT, and OpenType-CFF. */ - /* */ - /* Note, however, that the classes TT_Size, TT_GlyphSlot, and TT_CharMap */ - /* are not shared between font drivers, and are thus defined normally in */ - /* `ttobjs.h'. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Face */ - /* */ - /* */ - /* A handle to a TrueType face/font object. A TT_Face encapsulates */ - /* the resolution and scaling independent parts of a TrueType font */ - /* resource. */ - /* */ - /* */ - /* The TT_Face structure is also used as a `parent class' for the */ - /* OpenType-CFF class (T2_Face). */ - /* */ - typedef struct TT_FaceRec_* TT_Face; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_CharMap */ - /* */ - /* */ - /* A handle to a TrueType character mapping object. */ - /* */ - typedef struct TT_CharMapRec_* TT_CharMap; - - - /* a function type used for the truetype bytecode interpreter hooks */ - typedef FT_Error (*TT_Interpreter)( void* exec_context ); - - /* forward declaration */ - typedef struct TT_Loader_ TT_Loader; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Goto_Table_Func */ - /* */ - /* */ - /* Seeks a stream to the start of a given TrueType table. */ - /* */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* tag :: A 4-byte tag used to name the table. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* */ - /* length :: The length of the table in bytes. Set to 0 if not */ - /* needed. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* The stream cursor must be at the font file's origin. */ - /* */ - typedef - FT_Error (*TT_Goto_Table_Func)( TT_Face face, - FT_ULong tag, - FT_Stream stream, - FT_ULong* length ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Access_Glyph_Frame_Func */ - /* */ - /* */ - /* Seeks a stream to the start of a given glyph element, and opens a */ - /* frame for it. */ - /* */ - /* */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* glyph index :: The index of the glyph to access. */ - /* */ - /* offset :: The offset of the glyph according to the */ - /* `locations' table. */ - /* */ - /* byte_count :: The size of the frame in bytes. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* This function is normally equivalent to FILE_Seek(offset) */ - /* followed by ACCESS_Frame(byte_count) with the loader's stream, but */ - /* alternative formats (e.g. compressed ones) might use something */ - /* different. */ - /* */ - typedef - FT_Error (*TT_Access_Glyph_Frame_Func)( TT_Loader* loader, - FT_UInt glyph_index, - FT_ULong offset, - FT_UInt byte_count ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Load_Glyph_Element_Func */ - /* */ - /* */ - /* Reads one glyph element (its header, a simple glyph, or a */ - /* composite) from the loader's current stream frame. */ - /* */ - /* */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - typedef - FT_Error (*TT_Load_Glyph_Element_Func)( TT_Loader* loader ); - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Forget_Glyph_Frame_Func */ - /* */ - /* */ - /* Closes the current loader stream frame for the glyph. */ - /* */ - /* */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - typedef - void (*TT_Forget_Glyph_Frame_Func)( TT_Loader* loader ); - - - - /*************************************************************************/ - /* */ - /* TrueType Face Type */ - /* */ - /* */ - /* TT_Face */ - /* */ - /* */ - /* The TrueType face class. These objects model the resolution and */ - /* point-size independent data found in a TrueType font file. */ - /* */ - /* */ - /* root :: The base FT_Face structure, managed by the */ - /* base layer. */ - /* */ - /* ttc_header :: The TrueType collection header, used when */ - /* the file is a `ttc' rather than a `ttf'. */ - /* For ordinary font files, the field */ - /* `ttc_header.count' is set to 0. */ - /* */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of TrueType tables in this font */ - /* file. */ - /* */ - /* dir_tables :: The directory of TrueType tables for this */ - /* font file. */ - /* */ - /* header :: The font's font header (`head' table). */ - /* Read on font opening. */ - /* */ - /* horizontal :: The font's horizontal header (`hhea' */ - /* table). This field also contains the */ - /* associated horizontal metrics table */ - /* (`hmtx'). */ - /* */ - /* max_profile :: The font's maximum profile table. Read on */ - /* font opening. Note that some maximum */ - /* values cannot be taken directly from this */ - /* table. We thus define additional fields */ - /* below to hold the computed maxima. */ - /* */ - /* max_components :: The maximum number of glyph components */ - /* required to load any composite glyph from */ - /* this font. Used to size the load stack. */ - /* */ - /* vertical_info :: A boolean which is set when the font file */ - /* contains vertical metrics. If not, the */ - /* value of the `vertical' field is */ - /* undefined. */ - /* */ - /* vertical :: The font's vertical header (`vhea' table). */ - /* This field also contains the associated */ - /* vertical metrics table (`vmtx'), if found. */ - /* IMPORTANT: The contents of this field is */ - /* undefined if the `verticalInfo' field is */ - /* unset. */ - /* */ - /* num_names :: The number of name records within this */ - /* TrueType font. */ - /* */ - /* name_table :: The table of name records (`name'). */ - /* */ - /* os2 :: The font's OS/2 table (`OS/2'). */ - /* */ - /* postscript :: The font's PostScript table (`post' */ - /* table). The PostScript glyph names are */ - /* not loaded by the driver on face opening. */ - /* See the `ttpost' module for more details. */ - /* */ - /* num_charmaps :: The number of character mappings in the */ - /* font. */ - /* */ - /* charmaps :: The array of charmap objects for this font */ - /* file. Note that this field is a typeless */ - /* pointer. The Reason is that the format of */ - /* charmaps varies with the underlying font */ - /* format and cannot be determined here. */ - /* */ - /* goto_table :: A function called by each TrueType table */ - /* loader to position a stream's cursor to */ - /* the start of a given table according to */ - /* its tag. It defaults to TT_Goto_Face but */ - /* can be different for strange formats (e.g. */ - /* Type 42). */ - /* */ - /* access_glyph_frame :: XXX */ - /* */ - /* read_glyph_header :: XXX */ - /* */ - /* read_simple_glyph :: XXX */ - /* */ - /* read_composite_glyph :: XXX */ - /* */ - /* forget_glyph_frame :: XXX */ - /* */ - /* sfnt :: A pointer to the SFNT `driver' interface. */ - /* */ - /* psnames :: A pointer to the `PSNames' module */ - /* interface. */ - /* */ - /* hdmx :: The face's horizontal device metrics */ - /* (`hdmx' table). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* gasp :: The grid-fitting and scaling properties */ - /* table (`gasp'). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* pclt :: XXX */ - /* */ - /* num_sbit_strikes :: The number of sbit strikes, i.e., bitmap */ - /* sizes, embedded in this font. */ - /* */ - /* sbit_strikes :: An array of sbit strikes embedded in this */ - /* font. This table is optional in a */ - /* TrueType/OpenType font. */ - /* */ - /* num_sbit_scales :: The number of sbit scales for this font. */ - /* */ - /* sbit_scales :: Array of sbit scales embedded in this */ - /* font. This table is optional in a */ - /* TrueType/OpenType font. */ - /* */ - /* postscript_names :: A table used to store the Postscript names */ - /* of the glyphs for this font. See the */ - /* file `ttconfig.h' for comments on the */ - /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */ - /* */ - /* num_locations :: The number of glyph locations in this */ - /* TrueType file. This should be */ - /* identical to the number of glyphs. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* glyph_locations :: An array of longs. These are offsets to */ - /* glyph data within the `glyf' table. */ - /* Ignored for Type 2 font faces. */ - /* */ - /* font_program_size :: Size in bytecodes of the face's font */ - /* program. 0 if none defined. Ignored for */ - /* Type 2 fonts. */ - /* */ - /* font_program :: The face's font program (bytecode stream) */ - /* executed at load time, also used during */ - /* glyph rendering. Comes from the `fpgm' */ - /* table. Ignored for Type 2 font fonts. */ - /* */ - /* cvt_program_size :: The size in bytecodes of the face's cvt */ - /* program. Ignored for Type 2 fonts. */ - /* */ - /* cvt_program :: The face's cvt program (bytecode stream) */ - /* executed each time an instance/size is */ - /* changed/reset. Comes from the `prep' */ - /* table. Ignored for Type 2 fonts. */ - /* */ - /* cvt_size :: Size of the control value table (in */ - /* entries). Ignored for Type 2 fonts. */ - /* */ - /* cvt :: The face's original control value table. */ - /* Coordinates are expressed in unscaled font */ - /* units. Comes from the `cvt ' table. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* num_kern_pairs :: The number of kerning pairs present in the */ - /* font file. The engine only loads the */ - /* first horizontal format 0 kern table it */ - /* finds in the font file. You should use */ - /* the `ttxkern' structures if you want to */ - /* access other kerning tables. Ignored */ - /* for Type 2 fonts. */ - /* */ - /* kern_table_index :: The index of the kerning table in the font */ - /* kerning directory. Only used by the */ - /* ttxkern extension to avoid data */ - /* duplication. Ignored for Type 2 fonts. */ - /* */ - /* interpreter :: A pointer to the TrueType bytecode */ - /* interpreters field is also used to hook */ - /* the debugger in `ttdebug'. */ - /* */ - /* extra :: XXX */ - /* */ - typedef struct TT_FaceRec_ - { - FT_FaceRec root; - - TTC_Header ttc_header; - - FT_ULong format_tag; - FT_UShort num_tables; - TT_Table* dir_tables; - - TT_Header header; /* TrueType header table */ - TT_HoriHeader horizontal; /* TrueType horizontal header */ - - TT_MaxProfile max_profile; - FT_ULong max_components; - - FT_Bool vertical_info; - TT_VertHeader vertical; /* TT Vertical header, if present */ - - FT_Int num_names; /* number of name records */ - TT_NameTable name_table; /* name table */ - - TT_OS2 os2; /* TrueType OS/2 table */ - TT_Postscript postscript; /* TrueType Postscript table */ - - FT_Int num_charmaps; - TT_CharMap charmaps; /* array of TT_CharMapRec */ - - TT_Goto_Table_Func goto_table; - - TT_Access_Glyph_Frame_Func access_glyph_frame; - TT_Load_Glyph_Element_Func read_glyph_header; - TT_Load_Glyph_Element_Func read_simple_glyph; - TT_Load_Glyph_Element_Func read_composite_glyph; - TT_Forget_Glyph_Frame_Func forget_glyph_frame; - - /* a typeless pointer to the SFNT_Interface table used to load */ - /* the basic TrueType tables in the face object */ - void* sfnt; - - /* a typeless pointer to the PSNames_Interface table used to */ - /* handle glyph names <-> unicode & Mac values */ - void* psnames; - - /***********************************************************************/ - /* */ - /* Optional TrueType/OpenType tables */ - /* */ - /***********************************************************************/ - - /* horizontal device metrics */ - TT_Hdmx hdmx; - - /* grid-fitting and scaling table */ - TT_Gasp gasp; /* the `gasp' table */ - - /* PCL 5 table */ - TT_PCLT pclt; - - /* embedded bitmaps support */ - FT_Int num_sbit_strikes; - TT_SBit_Strike* sbit_strikes; - - FT_Int num_sbit_scales; - TT_SBit_Scale* sbit_scales; - - /* postscript names table */ - TT_Post_Names postscript_names; - - - /***********************************************************************/ - /* */ - /* TrueType-specific fields (ignored by the OTF-Type2 driver) */ - /* */ - /***********************************************************************/ - - /* the glyph locations */ - FT_UShort num_locations; - FT_Long* glyph_locations; - - /* the font program, if any */ - FT_ULong font_program_size; - FT_Byte* font_program; - - /* the cvt program, if any */ - FT_ULong cvt_program_size; - FT_Byte* cvt_program; - - /* the original, unscaled, control value table */ - FT_ULong cvt_size; - FT_Short* cvt; - - /* the format 0 kerning table, if any */ - FT_Int num_kern_pairs; - FT_Int kern_table_index; - TT_Kern_0_Pair* kern_pairs; - - /* A pointer to the bytecode interpreter to use. This is also */ - /* used to hook the debugger for the `ttdebug' utility. */ - TT_Interpreter interpreter; - - - /***********************************************************************/ - /* */ - /* Other tables or fields. This is used by derivative formats like */ - /* OpenType. */ - /* */ - /***********************************************************************/ - - FT_Generic extra; - - } TT_FaceRec; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_GlyphZone */ - /* */ - /* */ - /* A glyph zone is used to load, scale and hint glyph outline */ - /* coordinates. */ - /* */ - /* */ - /* memory :: A handle to the memory manager. */ - /* */ - /* max_points :: The maximal size in points of the zone. */ - /* */ - /* max_contours :: Max size in links contours of thez one. */ - /* */ - /* n_points :: The current number of points in the zone. */ - /* */ - /* n_contours :: The current number of contours in the zone. */ - /* */ - /* org :: The original glyph coordinates (font */ - /* units/scaled). */ - /* */ - /* cur :: The current glyph coordinates (scaled/hinted). */ - /* */ - /* tags :: The point control tags. */ - /* */ - /* contours :: The contours end points. */ - /* */ - typedef struct TT_GlyphZone_ - { - FT_Memory memory; - FT_UShort max_points; - FT_UShort max_contours; - FT_UShort n_points; /* number of points in zone */ - FT_Short n_contours; /* number of contours */ - - FT_Vector* org; /* original point coordinates */ - FT_Vector* cur; /* current point coordinates */ - - FT_Byte* tags; /* current touch flags */ - FT_UShort* contours; /* contour end points */ - - } TT_GlyphZone; - - - /* handle to execution context */ - typedef struct TT_ExecContextRec_* TT_ExecContext; - - /* glyph loader structure */ - struct TT_Loader_ - { - FT_Face face; - FT_Size size; - FT_GlyphSlot glyph; - FT_GlyphLoader* gloader; - - FT_ULong load_flags; - FT_UInt glyph_index; - - FT_Stream stream; - FT_Int byte_len; - - FT_Short n_contours; - FT_BBox bbox; - FT_Int left_bearing; - FT_Int advance; - FT_Bool preserve_pps; - FT_Vector pp1; - FT_Vector pp2; - - FT_ULong glyf_offset; - - /* the zone where we load our glyphs */ - TT_GlyphZone base; - TT_GlyphZone zone; - - TT_ExecContext exec; - FT_Byte* instructions; - FT_ULong ins_pos; - - /* for possible extensibility in other formats */ - void* other; - - }; - - -#endif /* TTTYPES_H */ - - -/* END */ diff --git a/src/freetype/freetype/t1tables.h b/src/freetype/freetype/t1tables.h deleted file mode 100644 index 323e0130c1..0000000000 --- a/src/freetype/freetype/t1tables.h +++ /dev/null @@ -1,235 +0,0 @@ -/***************************************************************************/ -/* */ -/* t1tables.h */ -/* */ -/* Basic Type 1/Type 2 tables definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef T1TABLES_H -#define T1TABLES_H - - -#include - - - /* Note that we separate font data in T1_FontInfo and T1_Private */ - /* structures in order to support Multiple Master fonts. */ - - - /*************************************************************************/ - /* */ - /* */ - /* T1_FontInfo */ - /* */ - /* */ - /* A structure used to model a Type1/Type2 FontInfo dictionary. Note */ - /* that for Multiple Master fonts, each instance has its own */ - /* FontInfo. */ - /* */ - typedef struct T1_FontInfo - { - FT_String* version; - FT_String* notice; - FT_String* full_name; - FT_String* family_name; - FT_String* weight; - FT_Long italic_angle; - FT_Bool is_fixed_pitch; - FT_Short underline_position; - FT_UShort underline_thickness; - - } T1_FontInfo; - - - /*************************************************************************/ - /* */ - /* */ - /* T1_Private */ - /* */ - /* */ - /* A structure used to model a Type1/Type2 FontInfo dictionary. Note */ - /* that for Multiple Master fonts, each instance has its own Private */ - /* dict. */ - /* */ - typedef struct T1_Private - { - FT_Int unique_id; - FT_Int lenIV; - - FT_Byte num_blue_values; - FT_Byte num_other_blues; - FT_Byte num_family_blues; - FT_Byte num_family_other_blues; - - FT_Short blue_values[14]; - FT_Short other_blues[10]; - - FT_Short family_blues [14]; - FT_Short family_other_blues[10]; - - FT_Fixed blue_scale; - FT_Int blue_shift; - FT_Int blue_fuzz; - - FT_UShort standard_width[1]; - FT_UShort standard_height[1]; - - FT_Byte num_snap_widths; - FT_Byte num_snap_heights; - FT_Bool force_bold; - FT_Bool round_stem_up; - - FT_Short snap_widths [13]; /* reserve one place for the std */ - FT_Short snap_heights[13]; /* reserve one place for the std */ - - FT_Long language_group; - FT_Long password; - - FT_Short min_feature[2]; - - } T1_Private; - - - /*************************************************************************/ - /* */ - /* */ - /* T1_Blend_Flags */ - /* */ - /* */ - /* A set of flags used to indicate which fields are present in a */ - /* given blen dictionary (font info or private). Used to support */ - /* Multiple Masters fonts. */ - /* */ - typedef enum - { - /* required fields in a FontInfo blend dictionary */ - t1_blend_underline_position = 0, - t1_blend_underline_thickness, - t1_blend_italic_angle, - - /* required fields in a Private blend dictionary */ - t1_blend_blue_values, - t1_blend_other_blues, - t1_blend_standard_width, - t1_blend_standard_height, - t1_blend_stem_snap_widths, - t1_blend_stem_snap_heights, - t1_blend_blue_scale, - t1_blend_blue_shift, - t1_blend_family_blues, - t1_blend_family_other_blues, - t1_blend_force_bold, - - /* never remove */ - t1_blend_max - - } T1_Blend_Flags; - - - /* maximum number of Multiple Masters designs, as defined in the spec */ -#define T1_MAX_MM_DESIGNS 16 - - /* maximum number of Multiple Masters axes, as defined in the spec */ -#define T1_MAX_MM_AXIS 4 - - /* maximum number of elements in a design map */ -#define T1_MAX_MM_MAP_POINTS 20 - - - /* this structure is used to store the BlendDesignMap entry for an axis */ - typedef struct T1_DesignMap_ - { - FT_Byte num_points; - FT_Fixed* design_points; - FT_Fixed* blend_points; - - } T1_DesignMap; - - - typedef struct T1_Blend_ - { - FT_UInt num_designs; - FT_UInt num_axis; - - FT_String* axis_names[T1_MAX_MM_AXIS]; - FT_Fixed* design_pos[T1_MAX_MM_DESIGNS]; - T1_DesignMap design_map[T1_MAX_MM_AXIS]; - - FT_Fixed* weight_vector; - FT_Fixed* default_weight_vector; - - T1_FontInfo* font_infos[T1_MAX_MM_DESIGNS + 1]; - T1_Private* privates [T1_MAX_MM_DESIGNS + 1]; - - FT_ULong blend_bitflags; - - } T1_Blend; - - - typedef struct CID_FontDict_ - { - T1_Private private_dict; - - FT_UInt len_buildchar; - FT_Fixed forcebold_threshold; - FT_Pos stroke_width; - FT_Fixed expansion_factor; - - FT_Byte paint_type; - FT_Byte font_type; - FT_Matrix font_matrix; - - FT_UInt num_subrs; - FT_ULong subrmap_offset; - FT_Int sd_bytes; - - } CID_FontDict; - - - typedef struct CID_Info_ - { - FT_String* cid_font_name; - FT_Fixed cid_version; - FT_Int cid_font_type; - - FT_String* registry; - FT_String* ordering; - FT_Int supplement; - - T1_FontInfo font_info; - FT_BBox font_bbox; - FT_ULong uid_base; - - FT_Int num_xuid; - FT_ULong xuid[16]; - - - FT_ULong cidmap_offset; - FT_Int fd_bytes; - FT_Int gd_bytes; - FT_ULong cid_count; - - FT_Int num_dicts; - CID_FontDict* font_dicts; - - FT_ULong data_offset; - - } CID_Info; - - -#endif /* T1TABLES_H */ - - -/* END */ diff --git a/src/freetype/freetype/ttnameid.h b/src/freetype/freetype/ttnameid.h deleted file mode 100644 index 4890242415..0000000000 --- a/src/freetype/freetype/ttnameid.h +++ /dev/null @@ -1,698 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttmakeid.h */ -/* */ -/* TrueType name ID definitions (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTNAMEID_H -#define TTNAMEID_H - - - /*************************************************************************/ - /* */ - /* Possible values for the `platform' identifier code in the name */ - /* records of the TTF `name' table. */ - /* */ -#define TT_PLATFORM_APPLE_UNICODE 0 -#define TT_PLATFORM_MACINTOSH 1 -#define TT_PLATFORM_ISO 2 /* deprecated */ -#define TT_PLATFORM_MICROSOFT 3 - - - /*************************************************************************/ - /* */ - /* Possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_APPLE_UNICODE. */ - /* */ -#define TT_APPLE_ID_DEFAULT 0 -#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ -#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ -#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ - - - /*************************************************************************/ - /* */ - /* Possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_MACINTOSH. */ - /* */ -#define TT_MAC_ID_ROMAN 0 -#define TT_MAC_ID_JAPANESE 1 -#define TT_MAC_ID_TRADITIONAL_CHINESE 2 -#define TT_MAC_ID_KOREAN 3 -#define TT_MAC_ID_ARABIC 4 -#define TT_MAC_ID_HEBREW 5 -#define TT_MAC_ID_GREEK 6 -#define TT_MAC_ID_RUSSIAN 7 -#define TT_MAC_ID_RSYMBOL 8 -#define TT_MAC_ID_DEVANAGARI 9 -#define TT_MAC_ID_GURMUKHI 10 -#define TT_MAC_ID_GUJARATI 11 -#define TT_MAC_ID_ORIYA 12 -#define TT_MAC_ID_BENGALI 13 -#define TT_MAC_ID_TAMIL 14 -#define TT_MAC_ID_TELUGU 15 -#define TT_MAC_ID_KANNADA 16 -#define TT_MAC_ID_MALAYALAM 17 -#define TT_MAC_ID_SINHALESE 18 -#define TT_MAC_ID_BURMESE 19 -#define TT_MAC_ID_KHMER 20 -#define TT_MAC_ID_THAI 21 -#define TT_MAC_ID_LAOTIAN 22 -#define TT_MAC_ID_GEORGIAN 23 -#define TT_MAC_ID_ARMENIAN 24 -#define TT_MAC_ID_MALDIVIAN 25 -#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 -#define TT_MAC_ID_TIBETAN 26 -#define TT_MAC_ID_MONGOLIAN 27 -#define TT_MAC_ID_GEEZ 28 -#define TT_MAC_ID_SLAVIC 29 -#define TT_MAC_ID_VIETNAMESE 30 -#define TT_MAC_ID_SINDHI 31 -#define TT_MAC_ID_UNINTERP 32 - - - /*************************************************************************/ - /* */ - /* Possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_ISO. */ - /* */ - /* This use is now deprecated. */ - /* */ -#define TT_ISO_ID_7BIT_ASCII 0 -#define TT_ISO_ID_10646 1 -#define TT_ISO_ID_8859_1 2 - - - /*************************************************************************/ - /* */ - /* possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_MICROSOFT. */ - /* */ -#define TT_MS_ID_SYMBOL_CS 0 -#define TT_MS_ID_UNICODE_CS 1 -#define TT_MS_ID_SJIS 2 -#define TT_MS_ID_GB2312 3 -#define TT_MS_ID_BIG_5 4 -#define TT_MS_ID_WANSUNG 5 -#define TT_MS_ID_JOHAB 6 - - - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MACINTOSH. */ - /* */ - /* The canonical source for the Apple assigned Language ID's is at */ - /* */ - /* http://fonts.apple.com/TTRefMan/RM06/Chap6name.html */ - /* */ -#define TT_MAC_LANGID_ENGLISH 0 -#define TT_MAC_LANGID_FRENCH 1 -#define TT_MAC_LANGID_GERMAN 2 -#define TT_MAC_LANGID_ITALIAN 3 -#define TT_MAC_LANGID_DUTCH 4 -#define TT_MAC_LANGID_SWEDISH 5 -#define TT_MAC_LANGID_SPANISH 6 -#define TT_MAC_LANGID_DANISH 7 -#define TT_MAC_LANGID_PORTUGUESE 8 -#define TT_MAC_LANGID_NORWEGIAN 9 -#define TT_MAC_LANGID_HEBREW 10 -#define TT_MAC_LANGID_JAPANESE 11 -#define TT_MAC_LANGID_ARABIC 12 -#define TT_MAC_LANGID_FINNISH 13 -#define TT_MAC_LANGID_GREEK 14 -#define TT_MAC_LANGID_ICELANDIC 15 -#define TT_MAC_LANGID_MALTESE 16 -#define TT_MAC_LANGID_TURKISH 17 -#define TT_MAC_LANGID_CROATIAN 18 -#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 -#define TT_MAC_LANGID_URDU 20 -#define TT_MAC_LANGID_HINDI 21 -#define TT_MAC_LANGID_THAI 22 -#define TT_MAC_LANGID_KOREAN 23 -#define TT_MAC_LANGID_LITHUANIAN 24 -#define TT_MAC_LANGID_POLISH 25 -#define TT_MAC_LANGID_HUNGARIAN 26 -#define TT_MAC_LANGID_ESTONIAN 27 -#define TT_MAC_LANGID_LETTISH 28 -#define TT_MAC_LANGID_SAAMISK 29 -#define TT_MAC_LANGID_FAEROESE 30 -#define TT_MAC_LANGID_FARSI 31 -#define TT_MAC_LANGID_RUSSIAN 32 -#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 -#define TT_MAC_LANGID_FLEMISH 34 -#define TT_MAC_LANGID_IRISH 35 -#define TT_MAC_LANGID_ALBANIAN 36 -#define TT_MAC_LANGID_ROMANIAN 37 -#define TT_MAC_LANGID_CZECH 38 -#define TT_MAC_LANGID_SLOVAK 39 -#define TT_MAC_LANGID_SLOVENIAN 40 -#define TT_MAC_LANGID_YIDDISH 41 -#define TT_MAC_LANGID_SERBIAN 42 -#define TT_MAC_LANGID_MACEDONIAN 43 -#define TT_MAC_LANGID_BULGARIAN 44 -#define TT_MAC_LANGID_UKRAINIAN 45 -#define TT_MAC_LANGID_BYELORUSSIAN 46 -#define TT_MAC_LANGID_UZBEK 47 -#define TT_MAC_LANGID_KAZAKH 48 -#define TT_MAC_LANGID_AZERBAIJANI 49 -#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49 -#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 -#define TT_MAC_LANGID_ARMENIAN 51 -#define TT_MAC_LANGID_GEORGIAN 52 -#define TT_MAC_LANGID_MOLDAVIAN 53 -#define TT_MAC_LANGID_KIRGHIZ 54 -#define TT_MAC_LANGID_TAJIKI 55 -#define TT_MAC_LANGID_TURKMEN 56 -#define TT_MAC_LANGID_MONGOLIAN 57 -#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57 -#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 -#define TT_MAC_LANGID_PASHTO 59 -#define TT_MAC_LANGID_KURDISH 60 -#define TT_MAC_LANGID_KASHMIRI 61 -#define TT_MAC_LANGID_SINDHI 62 -#define TT_MAC_LANGID_TIBETAN 63 -#define TT_MAC_LANGID_NEPALI 64 -#define TT_MAC_LANGID_SANSKRIT 65 -#define TT_MAC_LANGID_MARATHI 66 -#define TT_MAC_LANGID_BENGALI 67 -#define TT_MAC_LANGID_ASSAMESE 68 -#define TT_MAC_LANGID_GUJARATI 69 -#define TT_MAC_LANGID_PUNJABI 70 -#define TT_MAC_LANGID_ORIYA 71 -#define TT_MAC_LANGID_MALAYALAM 72 -#define TT_MAC_LANGID_KANNADA 73 -#define TT_MAC_LANGID_TAMIL 74 -#define TT_MAC_LANGID_TELUGU 75 -#define TT_MAC_LANGID_SINHALESE 76 -#define TT_MAC_LANGID_BURMESE 77 -#define TT_MAC_LANGID_KHMER 78 -#define TT_MAC_LANGID_LAO 79 -#define TT_MAC_LANGID_VIETNAMESE 80 -#define TT_MAC_LANGID_INDONESIAN 81 -#define TT_MAC_LANGID_TAGALOG 82 -#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 -#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 -#define TT_MAC_LANGID_AMHARIC 85 -#define TT_MAC_LANGID_TIGRINYA 86 -#define TT_MAC_LANGID_GALLA 87 -#define TT_MAC_LANGID_SOMALI 88 -#define TT_MAC_LANGID_SWAHILI 89 -#define TT_MAC_LANGID_RUANDA 90 -#define TT_MAC_LANGID_RUNDI 91 -#define TT_MAC_LANGID_CHEWA 92 -#define TT_MAC_LANGID_MALAGASY 93 -#define TT_MAC_LANGID_ESPERANTO 94 -#define TT_MAC_LANGID_WELSH 128 -#define TT_MAC_LANGID_BASQUE 129 -#define TT_MAC_LANGID_CATALAN 130 -#define TT_MAC_LANGID_LATIN 131 -#define TT_MAC_LANGID_QUECHUA 132 -#define TT_MAC_LANGID_GUARANI 133 -#define TT_MAC_LANGID_AYMARA 134 -#define TT_MAC_LANGID_TATAR 135 -#define TT_MAC_LANGID_UIGHUR 136 -#define TT_MAC_LANGID_DZONGKHA 137 -#define TT_MAC_LANGID_JAVANESE 138 -#define TT_MAC_LANGID_SUNDANESE 139 - - -#if 0 /* these seem to be errors that have been dropped */ - -#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 -#define TT_MAC_LANGID_IRISH_GAELIC 141 - -#endif - - - /* The following codes are new as of 2000-03-10 */ -#define TT_MAC_LANGID_GALICIAN 140 -#define TT_MAC_LANGID_AFRIKAANS 141 -#define TT_MAC_LANGID_BRETON 142 -#define TT_MAC_LANGID_INUKTITUT 143 -#define TT_MAC_LANGID_SCOTTISH_GAELIC 144 -#define TT_MAC_LANGID_MANX_GAELIC 145 -#define TT_MAC_LANGID_IRISH_GAELIC 146 -#define TT_MAC_LANGID_TONGAN 147 -#define TT_MAC_LANGID_GREEK_POLYTONIC 148 -#define TT_MAC_LANGID_GREELANDIC 149 -#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 - - - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MICROSOFT. */ - /* */ - /* The canonical source for the MS assigned LCID's is at */ - /* */ - /* http://www.microsoft.com/typography/OTSPEC/lcid-cp.txt */ - /* */ -#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 -#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 -#define TT_MS_LANGID_ARABIC_EGYPT 0x0c01 -#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 -#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 -#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 -#define TT_MS_LANGID_ARABIC_TUNISIA 0x1c01 -#define TT_MS_LANGID_ARABIC_OMAN 0x2001 -#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 -#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 -#define TT_MS_LANGID_ARABIC_JORDAN 0x2c01 -#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 -#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 -#define TT_MS_LANGID_ARABIC_UAE 0x3801 -#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3c01 -#define TT_MS_LANGID_ARABIC_QATAR 0x4001 -#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 -#define TT_MS_LANGID_CATALAN_SPAIN 0x0403 -#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 -#define TT_MS_LANGID_CHINESE_PRC 0x0804 -#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0c04 -#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 -#define TT_MS_LANGID_CHINESE_MACAU 0x1404 -#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 -#define TT_MS_LANGID_DANISH_DENMARK 0x0406 -#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 -#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 -#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0c07 -#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 -#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 -#define TT_MS_LANGID_GREEK_GREECE 0x0408 -#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 -#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 -#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0c09 -#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 -#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 -#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 -#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1c09 -#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 -#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 -#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 -#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2c09 -#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 -#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 -#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040a -#define TT_MS_LANGID_SPANISH_MEXICO 0x080a -#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0c0a -#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100a -#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140a -#define TT_MS_LANGID_SPANISH_PANAMA 0x180a -#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1c0a -#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200a -#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240a -#define TT_MS_LANGID_SPANISH_PERU 0x280a -#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2c0a -#define TT_MS_LANGID_SPANISH_ECUADOR 0x300a -#define TT_MS_LANGID_SPANISH_CHILE 0x340a -#define TT_MS_LANGID_SPANISH_URUGUAY 0x380a -#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3c0a -#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400a -#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440a -#define TT_MS_LANGID_SPANISH_HONDURAS 0x480a -#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4c0a -#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500a -#define TT_MS_LANGID_FINNISH_FINLAND 0x040b -#define TT_MS_LANGID_FRENCH_FRANCE 0x040c -#define TT_MS_LANGID_FRENCH_BELGIUM 0x080c -#define TT_MS_LANGID_FRENCH_CANADA 0x0c0c -#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100c -#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140c -#define TT_MS_LANGID_FRENCH_MONACO 0x180c -#define TT_MS_LANGID_HEBREW_ISRAEL 0x040d -#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040e -#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040f -#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 -#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 -#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 -#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 -#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 -#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 -#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 -#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 -#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 -#define TT_MS_LANGID_POLISH_POLAND 0x0415 -#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 -#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 -#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 -#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 -#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 -#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 -#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 -#define TT_MS_LANGID_CROATIAN_CROATIA 0x041a -#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081a -#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0c1a -#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041b -#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041c -#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041d -#define TT_MS_LANGID_SWEDISH_FINLAND 0x081d -#define TT_MS_LANGID_THAI_THAILAND 0x041e -#define TT_MS_LANGID_TURKISH_TURKEY 0x041f -#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 -#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 -#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 -#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 -#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 -#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 -#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 -#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 -#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 -#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0428 -#define TT_MS_LANGID_FARSI_IRAN 0x0429 -#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042a -#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042b -#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042c -#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082c -#define TT_MS_LANGID_BASQUE_SPAIN 0x042d -#define TT_MS_LANGID_SORBIAN_GERMANY 0x042e -#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042f -#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 -#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 -#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432 -#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 -#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 -#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 -#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 -#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 -#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 -#define TT_MS_LANGID_HINDI_INDIA 0x0439 -#define TT_MS_LANGID_MALTESE_MALTA 0x043a -#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b -#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c -#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c -#define TT_MS_LANGID_MALAY_MALAYSIA 0x043e -#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083e -#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043f -#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 -#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 -#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 -#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 -#define TT_MS_LANGID_BENGALI_INDIA 0x0445 -#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 -#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 -#define TT_MS_LANGID_ORIYA_INDIA 0x0448 -#define TT_MS_LANGID_TAMIL_INDIA 0x0449 -#define TT_MS_LANGID_TELUGU_INDIA 0x044a -#define TT_MS_LANGID_KANNADA_INDIA 0x044b -#define TT_MS_LANGID_MALAYALAM_INDIA 0x044c -#define TT_MS_LANGID_ASSAMESE_INDIA 0x044d -#define TT_MS_LANGID_MARATHI_INDIA 0x044e -#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f -#define TT_MS_LANGID_KONKANI_INDIA 0x0457 - - - /*************************************************************************/ - /* */ - /* Possible values of the `name' identifier field in the name records of */ - /* the TTF `name' table. These values are platform independent. */ - /* */ -#define TT_NAME_ID_COPYRIGHT 0 -#define TT_NAME_ID_FONT_FAMILY 1 -#define TT_NAME_ID_FONT_SUBFAMILY 2 -#define TT_NAME_ID_UNIQUE_ID 3 -#define TT_NAME_ID_FULL_NAME 4 -#define TT_NAME_ID_VERSION_STRING 5 -#define TT_NAME_ID_PS_NAME 6 -#define TT_NAME_ID_TRADEMARK 7 - -/* the following values are from the OpenType spec */ -#define TT_NAME_ID_MANUFACTURER 8 -#define TT_NAME_ID_DESIGNER 9 -#define TT_NAME_ID_DESCRIPTION 10 -#define TT_NAME_ID_VENDOR_URL 11 -#define TT_NAME_ID_DESIGNER_URL 12 -#define TT_NAME_ID_LICENSE 13 -#define TT_NAME_ID_LICENSE_URL 14 -/* number 15 is reserved */ -#define TT_NAME_ID_PREFERRED_FAMILY 16 -#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 -#define TT_NAME_ID_MAC_FULL_NAME 18 - -/* The following code is new as of 2000-01-21 */ -#define TT_NAME_ID_SAMPLE_TEXT 19 - - - /*************************************************************************/ - /* */ - /* Bit mask values for the Unicode Ranges from the TTF `OS2 ' table. */ - /* */ - /* Updated 02-Jul-2000. */ - /* */ - - /* General Scripts Area */ - - /* Bit 0 C0 Controls and Basic Latin */ -#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */ - /* Bit 1 C1 Controls and Latin-1 Supplement */ -#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+00A0-U+00FF */ - /* Bit 2 Latin Extended-A */ -#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ - /* Bit 3 Latin Extended-B */ -#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ - /* Bit 4 IPA Extensions */ -#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ - /* Bit 5 Spacing Modifier Letters */ -#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ - /* Bit 6 Combining Diacritical Marks */ -#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ - /* Bit 7 Greek */ -#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ - /* Bit 8 is reserved (was: Greek Symbols and Coptic) */ - /* Bit 9 Cyrillic */ -#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ - /* Bit 10 Armenian */ -#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ - /* Bit 11 Hebrew */ -#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ - /* Bit 12 is reserved (was: Hebrew Extended) */ - /* Bit 13 Arabic */ -#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ - /* Bit 14 is reserved (was: Arabic Extended) */ - /* Bit 15 Devanagari */ -#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ - /* Bit 16 Bengali */ -#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ - /* Bit 17 Gurmukhi */ -#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ - /* Bit 18 Gujarati */ -#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ - /* Bit 19 Oriya */ -#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ - /* Bit 20 Tamil */ -#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ - /* Bit 21 Telugu */ -#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ - /* Bit 22 Kannada */ -#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ - /* Bit 23 Malayalam */ -#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ - /* Bit 24 Thai */ -#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ - /* Bit 25 Lao */ -#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ - /* Bit 26 Georgian */ -#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ - /* Bit 27 is reserved (was Georgian Extended) */ - /* Bit 28 Hangul Jamo */ -#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ - /* Bit 29 Latin Extended Additional */ -#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ - /* Bit 30 Greek Extended */ -#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ - - /* Symbols Area */ - - /* Bit 31 General Punctuation */ -#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ - /* Bit 32 Superscripts And Subscripts */ -#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ - /* Bit 33 Currency Symbols */ -#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ - /* Bit 34 Combining Diacritical Marks For Symbols */ -#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ - /* Bit 35 Letterlike Symbols */ -#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ - /* Bit 36 Number Forms */ -#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ - /* Bit 37 Arrows */ -#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ - /* Bit 38 Mathematical Operators */ -#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ - /* Bit 39 Miscellaneous Technical */ -#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ - /* Bit 40 Control Pictures */ -#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ - /* Bit 41 Optical Character Recognition */ -#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ - /* Bit 42 Enclosed Alphanumerics */ -#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ - /* Bit 43 Box Drawing */ -#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ - /* Bit 44 Block Elements */ -#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ - /* Bit 45 Geometric Shapes */ -#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ - /* Bit 46 Miscellaneous Symbols */ -#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ - /* Bit 47 Dingbats */ -#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ - - /* CJK Phonetics and Symbols Area */ - - /* Bit 48 CJK Symbols And Punctuation */ -#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ - /* Bit 49 Hiragana */ -#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ - /* Bit 50 Katakana */ -#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ - /* Bit 51 Bopomofo + Extended Bopomofo */ -#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ - /* U+31A0-U+31BF */ - /* Bit 52 Hangul Compatibility Jamo */ -#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ - /* Bit 53 CJK Miscellaneous */ -#define TT_UCR_CJK_MISC (1L << 21) /* U+3190-U+319F */ - /* Bit 54 Enclosed CJK Letters And Months */ -#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ - /* Bit 55 CJK Compatibility */ -#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ - - /* Hangul Syllables Area */ - - /* Bit 56 Hangul */ -#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ - - /* Surrogates Area */ - - /* Bit 57 Surrogates */ -#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DFFF */ - /* Bit 58 is reserved for Unicode SubRanges */ - - /* CJK Ideographs Area */ - - /* Bit 59 CJK Unified Ideographs + */ - /* CJK Radical Supplement + */ - /* Kangxi Radicals + */ - /* Ideographic Description + */ - /* CJK Unified Ideographs Extension A */ -#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ - /* U+2E80-U+2EFF */ - /* U+2F00-U+2FDF */ - /* U+2FF0-U+2FFF */ - /* U+34E0-U+4DB5 */ - - /* Private Use Area */ - - /* Bit 60 Private Use */ -#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ - - /* Compatibility Area and Specials */ - - /* Bit 61 CJK Compatibility Ideographs */ -#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+F900-U+FAFF */ - /* Bit 62 Alphabetic Presentation Forms */ -#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ - /* Bit 63 Arabic Presentation Forms-A */ -#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FDFF */ - /* Bit 64 Combining Half Marks */ -#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ - /* Bit 65 CJK Compatibility Forms */ -#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE30-U+FE4F */ - /* Bit 66 Small Form Variants */ -#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ - /* Bit 67 Arabic Presentation Forms-B */ -#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFE */ - /* Bit 68 Halfwidth And Fullwidth Forms */ -#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ - /* Bit 69 Specials */ -#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */ - /* Bit 70 Tibetan */ -#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FCF */ - /* Bit 71 Syriac */ -#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */ - /* Bit 72 Thaana */ -#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */ - /* Bit 73 Sinhala */ -#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */ - /* Bit 74 Myanmar */ -#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */ - /* Bit 75 Ethiopic */ -#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+12BF */ - /* Bit 76 Cherokee */ -#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */ - /* Bit 77 Canadian Aboriginal Syllabics */ -#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+14DF */ - /* Bit 78 Ogham */ -#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */ - /* Bit 79 Runic */ -#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */ - /* Bit 80 Khmer */ -#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */ - /* Bit 81 Mongolian */ -#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */ - /* Bit 82 Braille */ -#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */ - /* Bit 83 Yi + Yi Radicals */ -#define TT_UCR_YI (1L << 19) /* U+A000-U+A48C */ - /* U+A490-U+A4CF */ - - - /*************************************************************************/ - /* */ - /* Some compilers have a very limited length of identifiers. */ - /* */ -#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) -#define HAVE_LIMIT_ON_IDENTS -#endif - - -#ifndef HAVE_LIMIT_ON_IDENTS - - - /*************************************************************************/ - /* */ - /* Here some alias #defines in order to be clearer. */ - /* */ - /* These are not always #defined to stay within the 31 character limit */ - /* which some compilers have. */ - /* */ - /* Credits go to Dave Hoo for pointing out that modern */ - /* Borland compilers (read: from BC++ 3.1 on) can increase this limit. */ - /* If you get a warning with such a compiler, use the -i40 switch. */ - /* */ -#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ - TT_UCR_ARABIC_PRESENTATIONS_A -#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ - TT_UCR_ARABIC_PRESENTATIONS_B - -#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ - TT_UCR_COMBINING_DIACRITICS -#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ - TT_UCR_COMBINING_DIACRITICS_SYMB - - -#endif /* !HAVE_LIMIT_ON_IDENTS */ - - -#endif /* TTNAMEID_H */ - - -/* END */ diff --git a/src/freetype/freetype/tttables.h b/src/freetype/freetype/tttables.h deleted file mode 100644 index 27c46f3c99..0000000000 --- a/src/freetype/freetype/tttables.h +++ /dev/null @@ -1,583 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttables.h */ -/* */ -/* Basic SFNT/TrueType tables definitions and interface */ -/* (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTTABLES_H -#define TTTABLES_H - - -#include - - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Header */ - /* */ - /* */ - /* A structure used to model a TrueType font header table. All */ - /* fields follow the TrueType specification. */ - /* */ - typedef struct TT_Header_ - { - FT_Fixed Table_Version; - FT_Fixed Font_Revision; - - FT_Long CheckSum_Adjust; - FT_Long Magic_Number; - - FT_UShort Flags; - FT_UShort Units_Per_EM; - - FT_Long Created [2]; - FT_Long Modified[2]; - - FT_Short xMin; - FT_Short yMin; - FT_Short xMax; - FT_Short yMax; - - FT_UShort Mac_Style; - FT_UShort Lowest_Rec_PPEM; - - FT_Short Font_Direction; - FT_Short Index_To_Loc_Format; - FT_Short Glyph_Data_Format; - - } TT_Header; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_HoriHeader */ - /* */ - /* */ - /* A structure used to model a TrueType horizontal header, the `hhea' */ - /* table, as well as the corresponding horizontal metrics table, */ - /* i.e., the `hmtx' table. */ - /* */ - /* */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of all */ - /* glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoAscender' field */ - /* of the OS/2 table instead if you want */ - /* the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the distance */ - /* from the baseline to the bottom-most of */ - /* all glyph points found in the font. It */ - /* is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Width_Max :: This field is the maximum of all advance */ - /* widths found in the font. It can be */ - /* used to compute the maximum width of an */ - /* arbitrary string of text. */ - /* */ - /* min_Left_Side_Bearing :: The minimum left side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Right_Side_Bearing :: The minimum right side bearing of all */ - /* glyphs within the font. */ - /* */ - /* xMax_Extent :: The maximum horizontal extent (i.e., the */ - /* `width' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* Reserved :: 10 reserved bytes. */ - /* */ - /* metric_Data_Format :: Always 0. */ - /* */ - /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ - /* table -- this value can be smaller than */ - /* the total number of glyphs in the font. */ - /* */ - /* long_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields which */ - /* are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ - /* */ - typedef struct TT_HoriHeader_ - { - FT_Fixed Version; - FT_Short Ascender; - FT_Short Descender; - FT_Short Line_Gap; - - FT_UShort advance_Width_Max; /* advance width maximum */ - - FT_Short min_Left_Side_Bearing; /* minimum left-sb */ - FT_Short min_Right_Side_Bearing; /* minimum right-sb */ - FT_Short xMax_Extent; /* xmax extents */ - FT_Short caret_Slope_Rise; - FT_Short caret_Slope_Run; - FT_Short caret_Offset; - - FT_Short Reserved[4]; - - FT_Short metric_Data_Format; - FT_UShort number_Of_HMetrics; - - /* The following fields are not defined by the TrueType specification */ - /* but they're used to connect the metrics header to the relevant */ - /* `HMTX' table. */ - - void* long_metrics; - void* short_metrics; - - } TT_HoriHeader; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_VertHeader */ - /* */ - /* */ - /* A structure used to model a TrueType vertical header, the `vhea' */ - /* table, as well as the corresponding vertical metrics table, i.e., */ - /* the `vmtx' table. */ - /* */ - /* */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of */ - /* all glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoAscender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the */ - /* distance from the baseline to the */ - /* bottom-most of all glyph points found */ - /* in the font. It is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Height_Max :: This field is the maximum of all */ - /* advance heights found in the font. It */ - /* can be used to compute the maximum */ - /* height of an arbitrary string of text. */ - /* */ - /* min_Top_Side_Bearing :: The minimum top side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ - /* glyphs within the font. */ - /* */ - /* yMax_Extent :: The maximum vertical extent (i.e., the */ - /* `height' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* Reserved :: 10 reserved bytes. */ - /* */ - /* metric_Data_Format :: Always 0. */ - /* */ - /* number_Of_HMetrics :: Number of VMetrics entries in the */ - /* `vmtx' table -- this value can be */ - /* smaller than the total number of glyphs */ - /* in the font. */ - /* */ - /* long_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields which */ - /* are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ - /* */ - typedef struct TT_VertHeader_ - { - FT_Fixed Version; - FT_Short Ascender; - FT_Short Descender; - FT_Short Line_Gap; - - FT_UShort advance_Height_Max; /* advance height maximum */ - - FT_Short min_Top_Side_Bearing; /* minimum left-sb or top-sb */ - FT_Short min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ - FT_Short yMax_Extent; /* xmax or ymax extents */ - FT_Short caret_Slope_Rise; - FT_Short caret_Slope_Run; - FT_Short caret_Offset; - - FT_Short Reserved[4]; - - FT_Short metric_Data_Format; - FT_UShort number_Of_VMetrics; - - /* The following fields are not defined by the TrueType specification */ - /* but they're used to connect the metrics header to the relevant */ - /* `HMTX' or `VMTX' table. */ - - void* long_metrics; - void* short_metrics; - - } TT_VertHeader; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_OS2 */ - /* */ - /* */ - /* A structure used to model a TrueType OS/2 table. This is the long */ - /* table version. All fields comply to the TrueType specification. */ - /* */ - /* Note that we now support old Mac fonts which do not include an */ - /* OS/2 table. In this case, the `version' field is always set to */ - /* 0xFFFF. */ - /* */ - typedef struct TT_OS2_ - { - FT_UShort version; /* 0x0001 - more or 0xFFFF */ - FT_Short xAvgCharWidth; - FT_UShort usWeightClass; - FT_UShort usWidthClass; - FT_Short fsType; - FT_Short ySubscriptXSize; - FT_Short ySubscriptYSize; - FT_Short ySubscriptXOffset; - FT_Short ySubscriptYOffset; - FT_Short ySuperscriptXSize; - FT_Short ySuperscriptYSize; - FT_Short ySuperscriptXOffset; - FT_Short ySuperscriptYOffset; - FT_Short yStrikeoutSize; - FT_Short yStrikeoutPosition; - FT_Short sFamilyClass; - - FT_Byte panose[10]; - - FT_ULong ulUnicodeRange1; /* Bits 0-31 */ - FT_ULong ulUnicodeRange2; /* Bits 32-63 */ - FT_ULong ulUnicodeRange3; /* Bits 64-95 */ - FT_ULong ulUnicodeRange4; /* Bits 96-127 */ - - FT_Char achVendID[4]; - - FT_UShort fsSelection; - FT_UShort usFirstCharIndex; - FT_UShort usLastCharIndex; - FT_Short sTypoAscender; - FT_Short sTypoDescender; - FT_Short sTypoLineGap; - FT_UShort usWinAscent; - FT_UShort usWinDescent; - - /* only version 1 tables: */ - - FT_ULong ulCodePageRange1; /* Bits 0-31 */ - FT_ULong ulCodePageRange2; /* Bits 32-63 */ - - /* only version 2 tables: */ - - FT_Short sxHeight; - FT_Short sCapHeight; - FT_UShort usDefaultChar; - FT_UShort usBreakChar; - FT_UShort usMaxContext; - - } TT_OS2; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_Postscript */ - /* */ - /* */ - /* A structure used to model a TrueType Postscript table. All fields */ - /* comply to the TrueType table. This structure does not reference */ - /* the Postscript glyph names, which can be nevertheless accessed */ - /* with the `ttpost' module. */ - /* */ - typedef struct TT_Postscript_ - { - FT_Fixed FormatType; - FT_Fixed italicAngle; - FT_Short underlinePosition; - FT_Short underlineThickness; - FT_ULong isFixedPitch; - FT_ULong minMemType42; - FT_ULong maxMemType42; - FT_ULong minMemType1; - FT_ULong maxMemType1; - - /* Glyph names follow in the file, but we don't */ - /* load them by default. See the ttpost.c file. */ - - } TT_Postscript; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_PCLT */ - /* */ - /* */ - /* A structure used to model a TrueType PCLT table. All fields */ - /* comply to the TrueType table. */ - /* */ - typedef struct TT_PCLT_ - { - FT_Fixed Version; - FT_ULong FontNumber; - FT_UShort Pitch; - FT_UShort xHeight; - FT_UShort Style; - FT_UShort TypeFamily; - FT_UShort CapHeight; - FT_UShort SymbolSet; - FT_Char TypeFace[16]; - FT_Char CharacterComplement[8]; - FT_Char FileName[6]; - FT_Char StrokeWeight; - FT_Char WidthType; - FT_Byte SerifStyle; - FT_Byte Reserved; - - } TT_PCLT; - - - /*************************************************************************/ - /* */ - /* */ - /* TT_MaxProfile */ - /* */ - /* */ - /* The maximum profile is a table containing many max values which */ - /* can be used to pre-allocate arrays. This ensures that no memory */ - /* allocation occurs during a glyph load. */ - /* */ - /* */ - /* version :: The version number. */ - /* */ - /* numGlyphs :: The number of glyphs in this TrueType */ - /* font. */ - /* */ - /* maxPoints :: The maximum number of points in a */ - /* non-composite TrueType glyph. See also */ - /* the structure element */ - /* `maxCompositePoints'. */ - /* */ - /* maxContours :: The maximum number of contours in a */ - /* non-composite TrueType glyph. See also */ - /* the structure element */ - /* `maxCompositeContours'. */ - /* */ - /* maxCompositePoints :: The maximum number of points in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxPoints'. */ - /* */ - /* maxCompositeContours :: The maximum number of contours in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxContours'. */ - /* */ - /* maxZones :: The maximum number of zones used for */ - /* glyph hinting. */ - /* */ - /* maxTwilightPoints :: The maximum number of points in the */ - /* twilight zone used for glyph hinting. */ - /* */ - /* maxStorage :: The maximum number of elements in the */ - /* storage area used for glyph hinting. */ - /* */ - /* maxFunctionDefs :: The maximum number of function */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxInstructionDefs :: The maximum number of instruction */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxStackElements :: The maximum number of stack elements used */ - /* during bytecode interpretation. */ - /* */ - /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ - /* used for glyph hinting. */ - /* */ - /* maxComponentElements :: An obscure value related to composite */ - /* glyphs definitions. */ - /* */ - /* maxComponentDepth :: An obscure value related to composite */ - /* glyphs definitions. Probably the maximum */ - /* number of simple glyphs in a composite. */ - /* */ - /* */ - /* This structure is only used during font loading. */ - /* */ - typedef struct TT_MaxProfile_ - { - FT_Fixed version; - FT_UShort numGlyphs; - FT_UShort maxPoints; - FT_UShort maxContours; - FT_UShort maxCompositePoints; - FT_UShort maxCompositeContours; - FT_UShort maxZones; - FT_UShort maxTwilightPoints; - FT_UShort maxStorage; - FT_UShort maxFunctionDefs; - FT_UShort maxInstructionDefs; - FT_UShort maxStackElements; - FT_UShort maxSizeOfInstructions; - FT_UShort maxComponentElements; - FT_UShort maxComponentDepth; - - } TT_MaxProfile; - - - typedef enum - { - ft_sfnt_head = 0, - ft_sfnt_maxp = 1, - ft_sfnt_os2 = 2, - ft_sfnt_hhea = 3, - ft_sfnt_vhea = 4, - ft_sfnt_post = 5, - ft_sfnt_pclt = 6, - - sfnt_max /* don't remove */ - - } FT_Sfnt_Tag; - - - /* internal use only */ - typedef void* (*FT_Get_Sfnt_Table_Func)( FT_Face face, - FT_Sfnt_Tag tag ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Get_Sfnt_Table */ - /* */ - /* */ - /* Returns a pointer to a given SFNT table within a face. */ - /* */ - /* */ - /* face :: A handle to the source. */ - /* */ - /* tag :: The index of the SFNT table. */ - /* */ - /* */ - /* A type-less pointer to the table. This will be 0 in case of */ - /* error, or if the corresponding table was not found *OR* loaded */ - /* from the file. */ - /* */ - /* */ - /* The table is owned by the face object and disappears with it. */ - /* */ - /* This function is only useful to access SFNT tables that are loaded */ - /* by the sfnt/truetype/opentype drivers. See FT_Sfnt_tag for a */ - /* list. */ - /* */ - /* You can load any table using the (internal) SFNT_Interface */ - /* structure -- this is available via FT_Get_Module_Interface(). */ - /* */ - FT_EXPORT_DEF( void* ) FT_Get_Sfnt_Table( FT_Face face, - FT_Sfnt_Tag tag ); - -#ifdef __cplusplus - } -#endif - - -#endif /* TTTABLES_H */ - - -/* END */ diff --git a/src/freetype/freetype/tttags.h b/src/freetype/freetype/tttags.h deleted file mode 100644 index 9de9810e99..0000000000 --- a/src/freetype/freetype/tttags.h +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttags.h */ -/* */ -/* Tags for TrueType tables (specification only). */ -/* */ -/* Copyright 1996-2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTAGS_H -#define TTAGS_H - - -#include /* for MAKE_TT_TAG() */ - - -#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) -#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) -#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) -#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) -#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) -#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) -#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) -#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) -#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) -#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) -#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) -#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) -#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) -#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) -#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) -#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) -#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) -#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) -#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) -#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) -#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) -#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) -#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) -#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) -#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) -#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) -#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) -#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) -#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) -#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) -#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) -#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) -#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) -#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) -#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) -#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) - -#endif /* TTAGS_H */ - - -/* END */