2 Copyright (c) 1998-2002 by Juliusz Chroboczek
3 Copyright (c) 2003 After X-TT Project, All rights reserved.
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 /* Number of buckets in the hashtable holding faces */
25 #define NUMFACEBUCKETS 32
27 /* Glyphs are held in segments of this size */
28 #define FONTSEGMENTSIZE 16
30 /* A structure that holds bitmap order and padding info. */
33 int bit; /* bit order */
34 int byte; /* byte order */
35 int glyph; /* glyph pad size */
36 int scan; /* machine word size */
37 } FontBitmapFormatRec, *FontBitmapFormatPtr;
41 /* At the lowest level, there is face; FTFaces are in one-to-one
42 correspondence with TrueType faces. Multiple instance may share
45 typedef struct _FTFace {
50 struct _FTInstance *instances;
51 struct _FTInstance *active_instance;
52 struct _FTFace *next; /* link to next face in bucket */
53 } FTFaceRec, *FTFacePtr;
55 /* A transformation matrix with resolution information */
56 typedef struct _FTNormalisedTransformation {
58 int nonIdentity; /* if 0, matrix is the identity */
61 } FTNormalisedTransformationRec, *FTNormalisedTransformationPtr;
63 #define FT_PROPORTIONAL 0
64 #define FT_MONOSPACED 1
67 #define FT_AVAILABLE_UNKNOWN 0
68 #define FT_AVAILABLE_NO 1
69 #define FT_AVAILABLE_METRICS 2
70 #define FT_AVAILABLE_RASTERISED 3
72 #define FT_GET_GLYPH_BOTH 0x01
73 #define FT_GET_GLYPH_METRICS_ONLY 0x02
74 #define FT_GET_DUMMY 0x04
75 #define FT_FORCE_CONSTANT_SPACING 0x08
77 #define TTCAP_DOUBLE_STRIKE 0x0001
78 #define TTCAP_DOUBLE_STRIKE_MKBOLD_EDGE_LEFT 0x0002
79 #define TTCAP_DOUBLE_STRIKE_CORRECT_B_BOX_WIDTH 0x0008
80 #define TTCAP_IS_VERY_LAZY 0x0010
81 #define TTCAP_DISABLE_DEFAULT_VERY_LAZY 0x0020
82 #define TTCAP_FORCE_C_LSB_FLAG 0x0100
83 #define TTCAP_FORCE_C_RSB_FLAG 0x0200
84 #define TTCAP_FORCE_C_OUTSIDE 0x0400
85 #define TTCAP_MONO_CENTER 0x0800
92 double scaleBBoxWidth;
93 double scaleBBoxHeight;
94 int doubleStrikeShift;
95 int adjustBBoxWidthByPixel;
96 int adjustLeftSideBearingByPixel;
97 int adjustRightSideBearingByPixel;
99 int forceConstantSpacingBegin;
100 int forceConstantSpacingEnd;
101 /* We don't compare */
102 int force_c_adjust_width_by_pixel;
103 int force_c_adjust_lsb_by_pixel;
104 int force_c_adjust_rsb_by_pixel;
105 int force_c_representative_metrics_char_code;
106 double force_c_scale_b_box_width;
107 double force_c_scale_b_box_height;
108 double force_c_scale_lsb;
109 double force_c_scale_rsb;
111 int lsbShiftOfBitmapAutoItalic;
112 int rsbShiftOfBitmapAutoItalic;
115 /* An instance builds on a face by specifying the transformation
116 matrix. Multiple fonts may share the same instance. */
118 /* This structure caches bitmap data */
119 typedef struct _FTInstance {
120 FTFacePtr face; /* the associated face */
122 FTNormalisedTransformationRec transformation;
124 FT_ULong strike_index;
125 int spacing; /* actual spacing */
126 double pixel_size; /* to calc attributes (actual height) */
127 double pixel_width_unit_x; /* to calc horiz. width (cosine) */
128 double pixel_width_unit_y; /* to calc vert. width (cosine) */
129 xCharInfo *charcellMetrics; /* the header's metrics */
130 int averageWidth; /* the header's metrics */
131 long rawAverageWidth; /* the header's metrics */
132 double advance; /* the header's metrics */
133 xCharInfo *forceConstantMetrics;
134 FontBitmapFormatRec bmfmt;
136 CharInfoPtr *glyphs; /* glyphs and available are used in parallel */
138 struct TTCapInfo ttcap;
140 struct _FTInstance *next; /* link to next instance */
141 } FTInstanceRec, *FTInstancePtr;
143 /* A font is an instance with coding information; fonts are in
144 one-to-one correspondence with X fonts */
145 typedef struct _FTFont{
146 FTInstancePtr instance;
147 FTMappingRec mapping;
151 CharInfoRec dummy_char;
153 } FTFontRec, *FTFontPtr;
155 #ifndef NOT_IN_FTFUNCS
157 /* Prototypes for some local functions */
159 static int FreeTypeOpenFace(FTFacePtr *facep, char *FTFileName, char *realFileName, int faceNumber);
160 static void FreeTypeFreeFace(FTFacePtr face);
162 FreeTypeOpenInstance(FTInstancePtr *instancep, FTFacePtr face,
163 char *FTFileName, FTNormalisedTransformationPtr trans,
164 int spacing, FontBitmapFormatPtr bmfmt,
165 struct TTCapInfo *tmp_ttcap, FT_Int32 load_flags);
166 static void FreeTypeFreeInstance(FTInstancePtr instance);
168 FreeTypeInstanceGetGlyph(unsigned idx, int flags, CharInfoPtr *g, FTInstancePtr instance);
170 FreeTypeInstanceGetGlyphMetrics(unsigned idx, int flags,
171 xCharInfo **metrics, FTInstancePtr instance );
173 FreeTypeRasteriseGlyph(unsigned idx, int flags, CharInfoPtr tgp,
174 FTInstancePtr instance, int hasMetrics );
175 static void FreeTypeFreeFont(FTFontPtr font);
176 static void FreeTypeFreeXFont(FontPtr pFont, int freeProps);
177 static void FreeTypeUnloadXFont(FontPtr pFont);
179 FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
180 char *fontname, int rawAverageWidth, Bool font_properties);
181 static int FreeTypeFontGetGlyph(unsigned code, int flags, CharInfoPtr *g, FTFontPtr font);
183 FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
184 char *FTFileName, FontScalablePtr vals, FontEntryPtr entry,
185 FontBitmapFormatPtr bmfmt, FT_Int32 load_flags,
186 struct TTCapInfo *tmp_ttcap, char *dynStrTTCapCodeRange,
189 #endif /* NOT_IN_FTFUNCS */