1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
/*******************************************************************
*
* Copyright 2007 Trolltech ASA
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_SHAPER_H
#define HARFBUZZ_SHAPER_H
#include <harfbuzz.h>
HB_BEGIN_HEADER
typedef enum {
HB_Script_Common,
HB_Script_Greek,
HB_Script_Cyrillic,
HB_Script_Armenian,
HB_Script_Hebrew,
HB_Script_Arabic,
HB_Script_Syriac,
HB_Script_Thaana,
HB_Script_Devanagari,
HB_Script_Bengali,
HB_Script_Gurmukhi,
HB_Script_Gujarati,
HB_Script_Oriya,
HB_Script_Tamil,
HB_Script_Telugu,
HB_Script_Kannada,
HB_Script_Malayalam,
HB_Script_Sinhala,
HB_Script_Thai,
HB_Script_Lao,
HB_Script_Tibetan,
HB_Script_Myanmar,
HB_Script_Georgian,
HB_Script_Hangul,
HB_Script_Ogham,
HB_Script_Runic,
HB_Script_Khmer,
HB_Script_Inherited,
HB_ScriptCount = HB_Script_Inherited
/*
HB_Script_Latin = Common,
HB_Script_Ethiopic = Common,
HB_Script_Cherokee = Common,
HB_Script_CanadianAboriginal = Common,
HB_Script_Mongolian = Common,
HB_Script_Hiragana = Common,
HB_Script_Katakana = Common,
HB_Script_Bopomofo = Common,
HB_Script_Han = Common,
HB_Script_Yi = Common,
HB_Script_OldItalic = Common,
HB_Script_Gothic = Common,
HB_Script_Deseret = Common,
HB_Script_Tagalog = Common,
HB_Script_Hanunoo = Common,
HB_Script_Buhid = Common,
HB_Script_Tagbanwa = Common,
HB_Script_Limbu = Common,
HB_Script_TaiLe = Common,
HB_Script_LinearB = Common,
HB_Script_Ugaritic = Common,
HB_Script_Shavian = Common,
HB_Script_Osmanya = Common,
HB_Script_Cypriot = Common,
HB_Script_Braille = Common,
HB_Script_Buginese = Common,
HB_Script_Coptic = Common,
HB_Script_NewTaiLue = Common,
HB_Script_Glagolitic = Common,
HB_Script_Tifinagh = Common,
HB_Script_SylotiNagri = Common,
HB_Script_OldPersian = Common,
HB_Script_Kharoshthi = Common,
HB_Script_Balinese = Common,
HB_Script_Cuneiform = Common,
HB_Script_Phoenician = Common,
HB_Script_PhagsPa = Common,
HB_Script_Nko = Common
*/
} HB_Script;
typedef struct
{
hb_uint32 pos;
hb_uint32 length;
HB_Script script;
hb_uint8 bidiLevel;
} HB_ScriptItem;
typedef enum {
HB_NoBreak,
HB_SoftHyphen,
HB_Break,
HB_ForcedBreak
} HB_LineBreakType;
typedef struct {
/*HB_LineBreakType*/ unsigned int lineBreakType :2;
/*HB_Bool*/ unsigned int whiteSpace :1; /* A unicode whitespace character, except NBSP, ZWNBSP */
/*HB_Bool*/ unsigned int charStop :1; /* Valid cursor position (for left/right arrow) */
unsigned int unused :4;
} HB_CharAttributes;
void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
const HB_ScriptItem *items, hb_uint32 numItems,
HB_CharAttributes *attributes);
typedef enum {
HB_LeftToRight = 0,
HB_RightToLeft = 1
} HB_StringToGlyphsFlags;
typedef enum {
HB_ShaperFlag_Default = 0,
HB_ShaperFlag_NoKerning = 1,
HB_ShaperFlag_UseDesignMetrics = 2
} HB_ShaperFlag;
/*
highest value means highest priority for justification. Justification is done by first inserting kashidas
starting with the highest priority positions, then stretching spaces, afterwards extending inter char
spacing, and last spacing between arabic words.
NoJustification is for example set for arabic where no Kashida can be inserted or for diacritics.
*/
typedef enum {
HB_NoJustification= 0, /* Justification can't be applied after this glyph */
HB_Arabic_Space = 1, /* This glyph represents a space inside arabic text */
HB_Character = 2, /* Inter-character justification point follows this glyph */
HB_Space = 4, /* This glyph represents a blank outside an Arabic run */
HB_Arabic_Normal = 7, /* Normal Middle-Of-Word glyph that connects to the right (begin) */
HB_Arabic_Waw = 8, /* Next character is final form of Waw/Ain/Qaf/Fa */
HB_Arabic_BaRa = 9, /* Next two chars are Ba + Ra/Ya/AlefMaksura */
HB_Arabic_Alef = 10, /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
HB_Arabic_HaaDal = 11, /* Next character is final form of Haa/Dal/Taa Marbutah */
HB_Arabic_Seen = 12, /* Initial or Medial form Of Seen/Sad */
HB_Arabic_Kashida = 13 /* Kashida(U+640) in middle of word */
} HB_JustificationClass;
typedef struct {
unsigned int justification :4; /* Justification class */
unsigned int clusterStart :1; /* First glyph of representation of cluster */
unsigned int mark :1; /* needs to be positioned around base char */
unsigned int zeroWidth :1; /* ZWJ, ZWNJ etc, with no width */
unsigned int dontPrint :1;
unsigned int combiningClass :8;
} HB_GlyphAttributes;
typedef struct {
HB_Bool isSymbolFont;
HB_GDEF gdef;
HB_GSUB gsub;
HB_GPOS gpos;
HB_Bool supported_scripts[HB_ScriptCount];
HB_Buffer buffer;
HB_Script current_script;
int current_flags; /* HB_ShaperFlags */
HB_Bool has_opentype_kerning;
HB_Bool glyphs_substituted;
HB_GlyphAttributes *tmpAttributes;
unsigned int *tmpLogClusters;
int length;
int orig_nglyphs;
} HB_FaceRec, *HB_Face;
typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);
HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);
void HB_FreeFace(HB_Face face);
typedef struct {
HB_Fixed x, y;
HB_Fixed width, height;
HB_Fixed xOffset, yOffset;
} HB_GlyphMetrics;
typedef struct {
HB_Bool (*stringToGlyphs)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);
void (*getAdvances)(HB_Font font, const HB_Glyph *glyphs, int numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);
HB_Bool (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);
/* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */
HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
void (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
HB_Fixed (*getAscent)(HB_Font font);
} HB_FontClass;
typedef struct HB_Font_ {
const HB_FontClass *klass;
/* Metrics */
HB_UShort x_ppem, y_ppem;
HB_16Dot16 x_scale, y_scale;
void *faceData;
void *userData;
} HB_FontRec;
typedef struct {
const HB_UChar16 *string;
hb_uint32 stringLength;
HB_ScriptItem item;
HB_Font font;
HB_Face face;
int shaperFlags; /* HB_ShaperFlags */
HB_Bool glyphIndicesPresent; /* set to true if the glyph indicies are already setup in the glyphs array */
hb_uint32 initialGlyphCount;
hb_uint32 num_glyphs; /* in: available glyphs out: glyphs used/needed */
HB_Glyph *glyphs; /* out parameter */
HB_GlyphAttributes *attributes; /* out */
HB_Fixed *advances; /* out */
HB_FixedPoint *offsets; /* out */
unsigned short *log_clusters; /* out */
/* internal */
HB_Bool kerning_applied; /* out: kerning applied by shaper */
} HB_ShaperItem;
HB_Bool HB_ShapeItem(HB_ShaperItem *item);
HB_END_HEADER
#endif
|