1 | // [Blend2D] |
2 | // 2D Vector Graphics Powered by a JIT Compiler. |
3 | // |
4 | // [License] |
5 | // Zlib - See LICENSE.md file in the package. |
6 | |
7 | #ifndef BLEND2D_BLFONTDEFS_H |
8 | #define BLEND2D_BLFONTDEFS_H |
9 | |
10 | #include "./blgeometry.h" |
11 | |
12 | BL_DIAGNOSTIC_PUSH(BL_DIAGNOSTIC_NO_SHADOW) |
13 | |
14 | //! \addtogroup blend2d_api_text |
15 | //! \{ |
16 | |
17 | // ============================================================================ |
18 | // [Constants] |
19 | // ============================================================================ |
20 | |
21 | //! Flags used by `BLGlyphItem::value` member. |
22 | //! |
23 | //! Glyph flags are only available after code-points were mapped to glyphs as |
24 | //! `BLGlyphItem::value` member contains either the code-point or glyph-id and |
25 | //! glyph flags. |
26 | BL_DEFINE_ENUM(BLGlyphItemFlags) { |
27 | //! Glyph is marked for operation (GSUB/GPOS). This flag should never be |
28 | //! set after glyph processing. It's an internal flag that is used during |
29 | //! processing to mark glyphs that need a second pass, but the engine |
30 | //! should always clear the flag after it processes marked glyphs. |
31 | //! |
32 | //! Used by: |
33 | //! - GSUB::LookupType #2 Format #1 - Multiple Substitution. |
34 | BL_GLYPH_ITEM_FLAG_MARK = 0x80000000u |
35 | }; |
36 | |
37 | //! Placement of glyphs stored in a `BLGlyphRun`. |
38 | BL_DEFINE_ENUM(BLGlyphPlacementType) { |
39 | //! No placement (custom handling by `BLPathSinkFunc`). |
40 | BL_GLYPH_PLACEMENT_TYPE_NONE = 0, |
41 | //! Each glyph has a BLGlyphPlacement (advance + offset). |
42 | BL_GLYPH_PLACEMENT_TYPE_ADVANCE_OFFSET = 1, |
43 | //! Each glyph has a BLPoint offset in design-space units. |
44 | BL_GLYPH_PLACEMENT_TYPE_DESIGN_UNITS = 2, |
45 | //! Each glyph has a BLPoint offset in user-space units. |
46 | BL_GLYPH_PLACEMENT_TYPE_USER_UNITS = 3, |
47 | //! Each glyph has a BLPoint offset in absolute units. |
48 | BL_GLYPH_PLACEMENT_TYPE_ABSOLUTE_UNITS = 4 |
49 | }; |
50 | |
51 | BL_DEFINE_ENUM(BLGlyphRunFlags) { |
52 | //! Glyph-run contains USC-4 string and not glyphs (glyph-buffer only). |
53 | BL_GLYPH_RUN_FLAG_UCS4_CONTENT = 0x10000000u, |
54 | //! Glyph-run was created from text that was not a valid unicode. |
55 | BL_GLYPH_RUN_FLAG_INVALID_TEXT = 0x20000000u, |
56 | //! Not the whole text was mapped to glyphs (contains undefined glyphs). |
57 | BL_GLYPH_RUN_FLAG_UNDEFINED_GLYPHS = 0x40000000u, |
58 | //! Encountered invalid font-data during text / glyph processing. |
59 | BL_GLYPH_RUN_FLAG_INVALID_FONT_DATA = 0x80000000u |
60 | }; |
61 | |
62 | //! Type of a font or font-face. |
63 | BL_DEFINE_ENUM(BLFontFaceType) { |
64 | //! None or unknown font type. |
65 | BL_FONT_FACE_TYPE_NONE = 0, |
66 | //! TrueType/OpenType font type. |
67 | BL_FONT_FACE_TYPE_OPENTYPE = 1, |
68 | |
69 | //! Count of font-face types. |
70 | BL_FONT_FACE_TYPE_COUNT = 2 |
71 | }; |
72 | |
73 | BL_DEFINE_ENUM(BLFontFaceFlags) { |
74 | //! Font uses typographic family and subfamily names. |
75 | BL_FONT_FACE_FLAG_TYPOGRAPHIC_NAMES = 0x00000001u, |
76 | //! Font uses typographic metrics. |
77 | BL_FONT_FACE_FLAG_TYPOGRAPHIC_METRICS = 0x00000002u, |
78 | //! Character to glyph mapping is available. |
79 | BL_FONT_FACE_FLAG_CHAR_TO_GLYPH_MAPPING = 0x00000004u, |
80 | //! Horizontal glyph metrics (advances, side bearings) is available. |
81 | BL_FONT_FACE_FLAG_HORIZONTAL_METIRCS = 0x00000010u, |
82 | //! Vertical glyph metrics (advances, side bearings) is available. |
83 | BL_FONT_FACE_FLAG_VERTICAL_METRICS = 0x00000020u, |
84 | //! Legacy horizontal kerning feature ('kern' table with horizontal kerning data). |
85 | BL_FONT_FACE_FLAG_HORIZONTAL_KERNING = 0x00000040u, |
86 | //! Legacy vertical kerning feature ('kern' table with vertical kerning data). |
87 | BL_FONT_FACE_FLAG_VERTICAL_KERNING = 0x00000080u, |
88 | //! OpenType features (GDEF, GPOS, GSUB) are available. |
89 | BL_FONT_FACE_FLAG_OPENTYPE_FEATURES = 0x00000100u, |
90 | //! OpenType BLFont Variations feature is available. |
91 | BL_FONT_FACE_FLAG_OPENTYPE_VARIATIONS = 0x20000000u, |
92 | //! Panose classification is available. |
93 | BL_FONT_FACE_FLAG_PANOSE_DATA = 0x00000200u, |
94 | //! Unicode coverage information is available. |
95 | BL_FONT_FACE_FLAG_UNICODE_COVERAGE = 0x00000400u, |
96 | //! Unicode variation sequences feature is available. |
97 | BL_FONT_FACE_FLAG_VARIATION_SEQUENCES = 0x10000000u, |
98 | //! This is a symbol font. |
99 | BL_FONT_FACE_FLAG_SYMBOL_FONT = 0x40000000u, |
100 | //! This is a last resort font. |
101 | BL_FONT_FACE_FLAG_LAST_RESORT_FONT = 0x80000000u |
102 | }; |
103 | |
104 | BL_DEFINE_ENUM(BLFontFaceDiagFlags) { |
105 | //! Wront data in 'name' table. |
106 | BL_FONT_FACE_DIAG_WRONG_NAME_DATA = 0x00000001u, |
107 | //! Fixed data read from 'name' table and possibly fixed font family/subfamily name. |
108 | BL_FONT_FACE_DIAG_FIXED_NAME_DATA = 0x00000002u, |
109 | |
110 | //! Wrong data in 'kern' table [kerning disabled]. |
111 | BL_FONT_FACE_DIAG_WRONG_KERN_DATA = 0x00000004u, |
112 | //! Fixed data read from 'kern' table so it can be used. |
113 | BL_FONT_FACE_DIAG_FIXED_KERN_DATA = 0x00000008u, |
114 | |
115 | //! Wrong data in 'cmap' table. |
116 | BL_FONT_FACE_DIAG_WRONG_CMAP_DATA = 0x00000010u, |
117 | //! Wrong format in 'cmap' (sub)table. |
118 | BL_FONT_FACE_DIAG_WRONG_CMAP_FORMAT = 0x00000020u, |
119 | |
120 | //! Wrong data in 'GDEF' table. |
121 | BL_FONT_FACE_DIAG_WRONG_GDEF_DATA = 0x00000100u, |
122 | //! Wrong data in 'GPOS' table. |
123 | BL_FONT_FACE_DIAG_WRONG_GPOS_DATA = 0x00000400u, |
124 | //! Wrong data in 'GSUB' table. |
125 | BL_FONT_FACE_DIAG_WRONG_GSUB_DATA = 0x00001000u |
126 | }; |
127 | |
128 | BL_DEFINE_ENUM(BLFontLoaderFlags) { |
129 | BL_FONT_LOADER_FLAG_COLLECTION = 0x00000001u //!< Font loader contains a font-collection (multiple font-faces). |
130 | }; |
131 | |
132 | //! Format of an outline stored in a font. |
133 | BL_DEFINE_ENUM(BLFontOutlineType) { |
134 | //! None. |
135 | BL_FONT_OUTLINE_TYPE_NONE = 0, |
136 | //! Truetype outlines. |
137 | BL_FONT_OUTLINE_TYPE_TRUETYPE = 1, |
138 | //! OpenType (CFF) outlines. |
139 | BL_FONT_OUTLINE_TYPE_CFF = 2, |
140 | //! OpenType (CFF2) outlines (font variations support). |
141 | BL_FONT_OUTLINE_TYPE_CFF2 = 3 |
142 | }; |
143 | |
144 | //! Font stretch. |
145 | BL_DEFINE_ENUM(BLFontStretch) { |
146 | //! Ultra condensed stretch. |
147 | BL_FONT_STRETCH_ULTRA_CONDENSED = 1, |
148 | //! Extra condensed stretch. |
149 | = 2, |
150 | //! Condensed stretch. |
151 | BL_FONT_STRETCH_CONDENSED = 3, |
152 | //! Semi condensed stretch. |
153 | BL_FONT_STRETCH_SEMI_CONDENSED = 4, |
154 | //! Normal stretch. |
155 | BL_FONT_STRETCH_NORMAL = 5, |
156 | //! Semi expanded stretch. |
157 | BL_FONT_STRETCH_SEMI_EXPANDED = 6, |
158 | //! Expanded stretch. |
159 | BL_FONT_STRETCH_EXPANDED = 7, |
160 | //! Extra expanded stretch. |
161 | BL_FONT_STRETCH_EXTRA_EXPANDED = 8, |
162 | //! Ultra expanded stretch. |
163 | BL_FONT_STRETCH_ULTRA_EXPANDED = 9 |
164 | }; |
165 | |
166 | //! Font style. |
167 | BL_DEFINE_ENUM(BLFontStyle) { |
168 | //! Normal style. |
169 | BL_FONT_STYLE_NORMAL = 0, |
170 | //! Oblique. |
171 | BL_FONT_STYLE_OBLIQUE = 1, |
172 | //! Italic. |
173 | BL_FONT_STYLE_ITALIC = 2, |
174 | |
175 | //! Count of font styles. |
176 | BL_FONT_STYLE_COUNT = 3 |
177 | }; |
178 | |
179 | //! Font weight. |
180 | BL_DEFINE_ENUM(BLFontWeight) { |
181 | //! Thin weight (100). |
182 | BL_FONT_WEIGHT_THIN = 100, |
183 | //! Extra light weight (200). |
184 | = 200, |
185 | //! Light weight (300). |
186 | BL_FONT_WEIGHT_LIGHT = 300, |
187 | //! Semi light weight (350). |
188 | BL_FONT_WEIGHT_SEMI_LIGHT = 350, |
189 | //! Normal weight (400). |
190 | BL_FONT_WEIGHT_NORMAL = 400, |
191 | //! Medium weight (500). |
192 | BL_FONT_WEIGHT_MEDIUM = 500, |
193 | //! Semi bold weight (600). |
194 | BL_FONT_WEIGHT_SEMI_BOLD = 600, |
195 | //! Bold weight (700). |
196 | BL_FONT_WEIGHT_BOLD = 700, |
197 | //! Extra bold weight (800). |
198 | = 800, |
199 | //! Black weight (900). |
200 | BL_FONT_WEIGHT_BLACK = 900, |
201 | //! Extra black weight (950). |
202 | = 950 |
203 | }; |
204 | |
205 | //! Font string identifiers used by OpenType 'name' table. |
206 | BL_DEFINE_ENUM(BLFontStringId) { |
207 | //! Copyright notice. |
208 | BL_FONT_STRING_COPYRIGHT_NOTICE = 0, |
209 | //! Font family name. |
210 | BL_FONT_STRING_FAMILY_NAME = 1, |
211 | //! Font subfamily name. |
212 | BL_FONT_STRING_SUBFAMILY_NAME = 2, |
213 | //! Unique font identifier. |
214 | BL_FONT_STRING_UNIQUE_IDENTIFIER = 3, |
215 | //! Full font name that reflects all family and relevant subfamily descriptors. |
216 | BL_FONT_STRING_FULL_NAME = 4, |
217 | //! Version string. Should begin with the synta `Version <number>.<number>`. |
218 | BL_FONT_STRING_VERSION_STRING = 5, |
219 | //! PostScript name for the font. |
220 | BL_FONT_STRING_POST_SCRIPT_NAME = 6, |
221 | //! Trademark notice/information for this font. |
222 | BL_FONT_STRING_TRADEMARK = 7, |
223 | //! Manufacturer name. |
224 | BL_FONT_STRING_MANUFACTURER_NAME = 8, |
225 | //! Name of the designer of the typeface. |
226 | BL_FONT_STRING_DESIGNER_NAME = 9, |
227 | //! Description of the typeface. |
228 | BL_FONT_STRING_DESCRIPTION = 10, |
229 | //! URL of font vendor. |
230 | BL_FONT_STRING_VENDOR_URL = 11, |
231 | //! URL of typeface designer. |
232 | BL_FONT_STRING_DESIGNER_URL = 12, |
233 | //! Description of how the font may be legally used. |
234 | BL_FONT_STRING_LICENSE_DESCRIPTION = 13, |
235 | //! URL where additional licensing information can be found. |
236 | BL_FONT_STRING_LICENSE_INFO_URL = 14, |
237 | //! Reserved. |
238 | BL_FONT_STRING_RESERVED = 15, |
239 | //! Typographic family name. |
240 | BL_FONT_STRING_TYPOGRAPHIC_FAMILY_NAME = 16, |
241 | //! Typographic subfamily name. |
242 | BL_FONT_STRING_TYPOGRAPHIC_SUBFAMILY_NAME = 17, |
243 | //! Compatible full name (MAC only). |
244 | BL_FONT_STRING_COMPATIBLE_FULL_NAME = 18, |
245 | //! Sample text - font name or any other text from the designer. |
246 | BL_FONT_STRING_SAMPLE_TEXT = 19, |
247 | //! PostScript CID findfont name. |
248 | BL_FONT_STRING_POST_SCRIPT_CID_NAME = 20, |
249 | //! WWS family name. |
250 | BL_FONT_STRING_WWS_FAMILY_NAME = 21, |
251 | //! WWS subfamily name. |
252 | BL_FONT_STRING_WWS_SUBFAMILY_NAME = 22, |
253 | //! Light background palette. |
254 | BL_FONT_STRING_LIGHT_BACKGROUND_PALETTE = 23, |
255 | //! Dark background palette. |
256 | BL_FONT_STRING_DARK_BACKGROUND_PALETTE = 24, |
257 | //! Variations PostScript name prefix. |
258 | BL_FONT_STRING_VARIATIONS_POST_SCRIPT_PREFIX= 25, |
259 | |
260 | //! Count of common font string ids. |
261 | BL_FONT_STRING_COMMON_COUNT = 26, |
262 | //! Start of custom font string ids. |
263 | BL_FONT_STRING_CUSTOM_START_INDEX = 255 |
264 | }; |
265 | |
266 | //! Bit positions in `BLFontUnicodeCoverage` structure. |
267 | //! |
268 | //! Each bit represents a range (or multiple ranges) of unicode characters. |
269 | BL_DEFINE_ENUM(BLFontUnicodeCoverageIndex) { |
270 | BL_FONT_UC_INDEX_BASIC_LATIN, //!< [000000-00007F] Basic Latin. |
271 | BL_FONT_UC_INDEX_LATIN1_SUPPLEMENT, //!< [000080-0000FF] Latin-1 Supplement. |
272 | BL_FONT_UC_INDEX_LATIN_EXTENDED_A, //!< [000100-00017F] Latin Extended-A. |
273 | BL_FONT_UC_INDEX_LATIN_EXTENDED_B, //!< [000180-00024F] Latin Extended-B. |
274 | BL_FONT_UC_INDEX_IPA_EXTENSIONS, //!< [000250-0002AF] IPA Extensions. |
275 | //!< [001D00-001D7F] Phonetic Extensions. |
276 | //!< [001D80-001DBF] Phonetic Extensions Supplement. |
277 | BL_FONT_UC_INDEX_SPACING_MODIFIER_LETTERS, //!< [0002B0-0002FF] Spacing Modifier Letters. |
278 | //!< [00A700-00A71F] Modifier Tone Letters. |
279 | //!< [001DC0-001DFF] Combining Diacritical Marks Supplement. |
280 | BL_FONT_UC_INDEX_COMBINING_DIACRITICAL_MARKS, //!< [000300-00036F] Combining Diacritical Marks. |
281 | BL_FONT_UC_INDEX_GREEK_AND_COPTIC, //!< [000370-0003FF] Greek and Coptic. |
282 | BL_FONT_UC_INDEX_COPTIC, //!< [002C80-002CFF] Coptic. |
283 | BL_FONT_UC_INDEX_CYRILLIC, //!< [000400-0004FF] Cyrillic. |
284 | //!< [000500-00052F] Cyrillic Supplement. |
285 | //!< [002DE0-002DFF] Cyrillic Extended-A. |
286 | //!< [00A640-00A69F] Cyrillic Extended-B. |
287 | BL_FONT_UC_INDEX_ARMENIAN, //!< [000530-00058F] Armenian. |
288 | BL_FONT_UC_INDEX_HEBREW, //!< [000590-0005FF] Hebrew. |
289 | BL_FONT_UC_INDEX_VAI, //!< [00A500-00A63F] Vai. |
290 | BL_FONT_UC_INDEX_ARABIC, //!< [000600-0006FF] Arabic. |
291 | //!< [000750-00077F] Arabic Supplement. |
292 | BL_FONT_UC_INDEX_NKO, //!< [0007C0-0007FF] NKo. |
293 | BL_FONT_UC_INDEX_DEVANAGARI, //!< [000900-00097F] Devanagari. |
294 | BL_FONT_UC_INDEX_BENGALI, //!< [000980-0009FF] Bengali. |
295 | BL_FONT_UC_INDEX_GURMUKHI, //!< [000A00-000A7F] Gurmukhi. |
296 | BL_FONT_UC_INDEX_GUJARATI, //!< [000A80-000AFF] Gujarati. |
297 | BL_FONT_UC_INDEX_ORIYA, //!< [000B00-000B7F] Oriya. |
298 | BL_FONT_UC_INDEX_TAMIL, //!< [000B80-000BFF] Tamil. |
299 | BL_FONT_UC_INDEX_TELUGU, //!< [000C00-000C7F] Telugu. |
300 | BL_FONT_UC_INDEX_KANNADA, //!< [000C80-000CFF] Kannada. |
301 | BL_FONT_UC_INDEX_MALAYALAM, //!< [000D00-000D7F] Malayalam. |
302 | BL_FONT_UC_INDEX_THAI, //!< [000E00-000E7F] Thai. |
303 | BL_FONT_UC_INDEX_LAO, //!< [000E80-000EFF] Lao. |
304 | BL_FONT_UC_INDEX_GEORGIAN, //!< [0010A0-0010FF] Georgian. |
305 | //!< [002D00-002D2F] Georgian Supplement. |
306 | BL_FONT_UC_INDEX_BALINESE, //!< [001B00-001B7F] Balinese. |
307 | BL_FONT_UC_INDEX_HANGUL_JAMO, //!< [001100-0011FF] Hangul Jamo. |
308 | BL_FONT_UC_INDEX_LATIN_EXTENDED_ADDITIONAL, //!< [001E00-001EFF] Latin Extended Additional. |
309 | //!< [002C60-002C7F] Latin Extended-C. |
310 | //!< [00A720-00A7FF] Latin Extended-D. |
311 | BL_FONT_UC_INDEX_GREEK_EXTENDED, //!< [001F00-001FFF] Greek Extended. |
312 | BL_FONT_UC_INDEX_GENERAL_PUNCTUATION, //!< [002000-00206F] General Punctuation. |
313 | //!< [002E00-002E7F] Supplemental Punctuation. |
314 | BL_FONT_UC_INDEX_SUPERSCRIPTS_AND_SUBSCRIPTS, //!< [002070-00209F] Superscripts And Subscripts. |
315 | BL_FONT_UC_INDEX_CURRENCY_SYMBOLS, //!< [0020A0-0020CF] Currency Symbols. |
316 | BL_FONT_UC_INDEX_COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS, //!< [0020D0-0020FF] Combining Diacritical Marks For Symbols. |
317 | BL_FONT_UC_INDEX_LETTERLIKE_SYMBOLS, //!< [002100-00214F] Letterlike Symbols. |
318 | BL_FONT_UC_INDEX_NUMBER_FORMS, //!< [002150-00218F] Number Forms. |
319 | BL_FONT_UC_INDEX_ARROWS, //!< [002190-0021FF] Arrows. |
320 | //!< [0027F0-0027FF] Supplemental Arrows-A. |
321 | //!< [002900-00297F] Supplemental Arrows-B. |
322 | //!< [002B00-002BFF] Miscellaneous Symbols and Arrows. |
323 | BL_FONT_UC_INDEX_MATHEMATICAL_OPERATORS, //!< [002200-0022FF] Mathematical Operators. |
324 | //!< [002A00-002AFF] Supplemental Mathematical Operators. |
325 | //!< [0027C0-0027EF] Miscellaneous Mathematical Symbols-A. |
326 | //!< [002980-0029FF] Miscellaneous Mathematical Symbols-B. |
327 | BL_FONT_UC_INDEX_MISCELLANEOUS_TECHNICAL, //!< [002300-0023FF] Miscellaneous Technical. |
328 | BL_FONT_UC_INDEX_CONTROL_PICTURES, //!< [002400-00243F] Control Pictures. |
329 | BL_FONT_UC_INDEX_OPTICAL_CHARACTER_RECOGNITION, //!< [002440-00245F] Optical Character Recognition. |
330 | BL_FONT_UC_INDEX_ENCLOSED_ALPHANUMERICS, //!< [002460-0024FF] Enclosed Alphanumerics. |
331 | BL_FONT_UC_INDEX_BOX_DRAWING, //!< [002500-00257F] Box Drawing. |
332 | BL_FONT_UC_INDEX_BLOCK_ELEMENTS, //!< [002580-00259F] Block Elements. |
333 | BL_FONT_UC_INDEX_GEOMETRIC_SHAPES, //!< [0025A0-0025FF] Geometric Shapes. |
334 | BL_FONT_UC_INDEX_MISCELLANEOUS_SYMBOLS, //!< [002600-0026FF] Miscellaneous Symbols. |
335 | BL_FONT_UC_INDEX_DINGBATS, //!< [002700-0027BF] Dingbats. |
336 | BL_FONT_UC_INDEX_CJK_SYMBOLS_AND_PUNCTUATION, //!< [003000-00303F] CJK Symbols And Punctuation. |
337 | BL_FONT_UC_INDEX_HIRAGANA, //!< [003040-00309F] Hiragana. |
338 | BL_FONT_UC_INDEX_KATAKANA, //!< [0030A0-0030FF] Katakana. |
339 | //!< [0031F0-0031FF] Katakana Phonetic Extensions. |
340 | BL_FONT_UC_INDEX_BOPOMOFO, //!< [003100-00312F] Bopomofo. |
341 | //!< [0031A0-0031BF] Bopomofo Extended. |
342 | BL_FONT_UC_INDEX_HANGUL_COMPATIBILITY_JAMO, //!< [003130-00318F] Hangul Compatibility Jamo. |
343 | BL_FONT_UC_INDEX_PHAGS_PA, //!< [00A840-00A87F] Phags-pa. |
344 | BL_FONT_UC_INDEX_ENCLOSED_CJK_LETTERS_AND_MONTHS, //!< [003200-0032FF] Enclosed CJK Letters And Months. |
345 | BL_FONT_UC_INDEX_CJK_COMPATIBILITY, //!< [003300-0033FF] CJK Compatibility. |
346 | BL_FONT_UC_INDEX_HANGUL_SYLLABLES, //!< [00AC00-00D7AF] Hangul Syllables. |
347 | BL_FONT_UC_INDEX_NON_PLANE, //!< [00D800-00DFFF] Non-Plane 0 *. |
348 | BL_FONT_UC_INDEX_PHOENICIAN, //!< [010900-01091F] Phoenician. |
349 | BL_FONT_UC_INDEX_CJK_UNIFIED_IDEOGRAPHS, //!< [004E00-009FFF] CJK Unified Ideographs. |
350 | //!< [002E80-002EFF] CJK Radicals Supplement. |
351 | //!< [002F00-002FDF] Kangxi Radicals. |
352 | //!< [002FF0-002FFF] Ideographic Description Characters. |
353 | //!< [003400-004DBF] CJK Unified Ideographs Extension A. |
354 | //!< [020000-02A6DF] CJK Unified Ideographs Extension B. |
355 | //!< [003190-00319F] Kanbun. |
356 | BL_FONT_UC_INDEX_PRIVATE_USE_PLANE0, //!< [00E000-00F8FF] Private Use (Plane 0). |
357 | BL_FONT_UC_INDEX_CJK_STROKES, //!< [0031C0-0031EF] CJK Strokes. |
358 | //!< [00F900-00FAFF] CJK Compatibility Ideographs. |
359 | //!< [02F800-02FA1F] CJK Compatibility Ideographs Supplement. |
360 | BL_FONT_UC_INDEX_ALPHABETIC_PRESENTATION_FORMS, //!< [00FB00-00FB4F] Alphabetic Presentation Forms. |
361 | BL_FONT_UC_INDEX_ARABIC_PRESENTATION_FORMS_A, //!< [00FB50-00FDFF] Arabic Presentation Forms-A. |
362 | BL_FONT_UC_INDEX_COMBINING_HALF_MARKS, //!< [00FE20-00FE2F] Combining Half Marks. |
363 | BL_FONT_UC_INDEX_VERTICAL_FORMS, //!< [00FE10-00FE1F] Vertical Forms. |
364 | //!< [00FE30-00FE4F] CJK Compatibility Forms. |
365 | BL_FONT_UC_INDEX_SMALL_FORM_VARIANTS, //!< [00FE50-00FE6F] Small Form Variants. |
366 | BL_FONT_UC_INDEX_ARABIC_PRESENTATION_FORMS_B, //!< [00FE70-00FEFF] Arabic Presentation Forms-B. |
367 | BL_FONT_UC_INDEX_HALFWIDTH_AND_FULLWIDTH_FORMS, //!< [00FF00-00FFEF] Halfwidth And Fullwidth Forms. |
368 | BL_FONT_UC_INDEX_SPECIALS, //!< [00FFF0-00FFFF] Specials. |
369 | BL_FONT_UC_INDEX_TIBETAN, //!< [000F00-000FFF] Tibetan. |
370 | BL_FONT_UC_INDEX_SYRIAC, //!< [000700-00074F] Syriac. |
371 | BL_FONT_UC_INDEX_THAANA, //!< [000780-0007BF] Thaana. |
372 | BL_FONT_UC_INDEX_SINHALA, //!< [000D80-000DFF] Sinhala. |
373 | BL_FONT_UC_INDEX_MYANMAR, //!< [001000-00109F] Myanmar. |
374 | BL_FONT_UC_INDEX_ETHIOPIC, //!< [001200-00137F] Ethiopic. |
375 | //!< [001380-00139F] Ethiopic Supplement. |
376 | //!< [002D80-002DDF] Ethiopic Extended. |
377 | BL_FONT_UC_INDEX_CHEROKEE, //!< [0013A0-0013FF] Cherokee. |
378 | BL_FONT_UC_INDEX_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, //!< [001400-00167F] Unified Canadian Aboriginal Syllabics. |
379 | BL_FONT_UC_INDEX_OGHAM, //!< [001680-00169F] Ogham. |
380 | BL_FONT_UC_INDEX_RUNIC, //!< [0016A0-0016FF] Runic. |
381 | BL_FONT_UC_INDEX_KHMER, //!< [001780-0017FF] Khmer. |
382 | //!< [0019E0-0019FF] Khmer Symbols. |
383 | BL_FONT_UC_INDEX_MONGOLIAN, //!< [001800-0018AF] Mongolian. |
384 | BL_FONT_UC_INDEX_BRAILLE_PATTERNS, //!< [002800-0028FF] Braille Patterns. |
385 | BL_FONT_UC_INDEX_YI_SYLLABLES_AND_RADICALS, //!< [00A000-00A48F] Yi Syllables. |
386 | //!< [00A490-00A4CF] Yi Radicals. |
387 | BL_FONT_UC_INDEX_TAGALOG_HANUNOO_BUHID_TAGBANWA, //!< [001700-00171F] Tagalog. |
388 | //!< [001720-00173F] Hanunoo. |
389 | //!< [001740-00175F] Buhid. |
390 | //!< [001760-00177F] Tagbanwa. |
391 | BL_FONT_UC_INDEX_OLD_ITALIC, //!< [010300-01032F] Old Italic. |
392 | BL_FONT_UC_INDEX_GOTHIC, //!< [010330-01034F] Gothic. |
393 | BL_FONT_UC_INDEX_DESERET, //!< [010400-01044F] Deseret. |
394 | BL_FONT_UC_INDEX_MUSICAL_SYMBOLS, //!< [01D000-01D0FF] Byzantine Musical Symbols. |
395 | //!< [01D100-01D1FF] Musical Symbols. |
396 | //!< [01D200-01D24F] Ancient Greek Musical Notation. |
397 | BL_FONT_UC_INDEX_MATHEMATICAL_ALPHANUMERIC_SYMBOLS, //!< [01D400-01D7FF] Mathematical Alphanumeric Symbols. |
398 | BL_FONT_UC_INDEX_PRIVATE_USE_PLANE_15_16, //!< [0F0000-0FFFFD] Private Use (Plane 15). |
399 | //!< [100000-10FFFD] Private Use (Plane 16). |
400 | BL_FONT_UC_INDEX_VARIATION_SELECTORS, //!< [00FE00-00FE0F] Variation Selectors. |
401 | //!< [0E0100-0E01EF] Variation Selectors Supplement. |
402 | BL_FONT_UC_INDEX_TAGS, //!< [0E0000-0E007F] Tags. |
403 | BL_FONT_UC_INDEX_LIMBU, //!< [001900-00194F] Limbu. |
404 | BL_FONT_UC_INDEX_TAI_LE, //!< [001950-00197F] Tai Le. |
405 | BL_FONT_UC_INDEX_NEW_TAI_LUE, //!< [001980-0019DF] New Tai Lue. |
406 | BL_FONT_UC_INDEX_BUGINESE, //!< [001A00-001A1F] Buginese. |
407 | BL_FONT_UC_INDEX_GLAGOLITIC, //!< [002C00-002C5F] Glagolitic. |
408 | BL_FONT_UC_INDEX_TIFINAGH, //!< [002D30-002D7F] Tifinagh. |
409 | BL_FONT_UC_INDEX_YIJING_HEXAGRAM_SYMBOLS, //!< [004DC0-004DFF] Yijing Hexagram Symbols. |
410 | BL_FONT_UC_INDEX_SYLOTI_NAGRI, //!< [00A800-00A82F] Syloti Nagri. |
411 | BL_FONT_UC_INDEX_LINEAR_B_SYLLABARY_AND_IDEOGRAMS, //!< [010000-01007F] Linear B Syllabary. |
412 | //!< [010080-0100FF] Linear B Ideograms. |
413 | //!< [010100-01013F] Aegean Numbers. |
414 | BL_FONT_UC_INDEX_ANCIENT_GREEK_NUMBERS, //!< [010140-01018F] Ancient Greek Numbers. |
415 | BL_FONT_UC_INDEX_UGARITIC, //!< [010380-01039F] Ugaritic. |
416 | BL_FONT_UC_INDEX_OLD_PERSIAN, //!< [0103A0-0103DF] Old Persian. |
417 | BL_FONT_UC_INDEX_SHAVIAN, //!< [010450-01047F] Shavian. |
418 | BL_FONT_UC_INDEX_OSMANYA, //!< [010480-0104AF] Osmanya. |
419 | BL_FONT_UC_INDEX_CYPRIOT_SYLLABARY, //!< [010800-01083F] Cypriot Syllabary. |
420 | BL_FONT_UC_INDEX_KHAROSHTHI, //!< [010A00-010A5F] Kharoshthi. |
421 | BL_FONT_UC_INDEX_TAI_XUAN_JING_SYMBOLS, //!< [01D300-01D35F] Tai Xuan Jing Symbols. |
422 | BL_FONT_UC_INDEX_CUNEIFORM, //!< [012000-0123FF] Cuneiform. |
423 | //!< [012400-01247F] Cuneiform Numbers and Punctuation. |
424 | BL_FONT_UC_INDEX_COUNTING_ROD_NUMERALS, //!< [01D360-01D37F] Counting Rod Numerals. |
425 | BL_FONT_UC_INDEX_SUNDANESE, //!< [001B80-001BBF] Sundanese. |
426 | BL_FONT_UC_INDEX_LEPCHA, //!< [001C00-001C4F] Lepcha. |
427 | BL_FONT_UC_INDEX_OL_CHIKI, //!< [001C50-001C7F] Ol Chiki. |
428 | BL_FONT_UC_INDEX_SAURASHTRA, //!< [00A880-00A8DF] Saurashtra. |
429 | BL_FONT_UC_INDEX_KAYAH_LI, //!< [00A900-00A92F] Kayah Li. |
430 | BL_FONT_UC_INDEX_REJANG, //!< [00A930-00A95F] Rejang. |
431 | BL_FONT_UC_INDEX_CHAM, //!< [00AA00-00AA5F] Cham. |
432 | BL_FONT_UC_INDEX_ANCIENT_SYMBOLS, //!< [010190-0101CF] Ancient Symbols. |
433 | BL_FONT_UC_INDEX_PHAISTOS_DISC, //!< [0101D0-0101FF] Phaistos Disc. |
434 | BL_FONT_UC_INDEX_CARIAN_LYCIAN_LYDIAN, //!< [0102A0-0102DF] Carian. |
435 | //!< [010280-01029F] Lycian. |
436 | //!< [010920-01093F] Lydian. |
437 | BL_FONT_UC_INDEX_DOMINO_AND_MAHJONG_TILES, //!< [01F030-01F09F] Domino Tiles. |
438 | //!< [01F000-01F02F] Mahjong Tiles. |
439 | BL_FONT_UC_INDEX_INTERNAL_USAGE_123, //!< Reserved for internal usage (123). |
440 | BL_FONT_UC_INDEX_INTERNAL_USAGE_124, //!< Reserved for internal usage (124). |
441 | BL_FONT_UC_INDEX_INTERNAL_USAGE_125, //!< Reserved for internal usage (125). |
442 | BL_FONT_UC_INDEX_INTERNAL_USAGE_126, //!< Reserved for internal usage (126). |
443 | BL_FONT_UC_INDEX_INTERNAL_USAGE_127 //!< Reserved for internal usage (127). |
444 | }; |
445 | |
446 | //! Text direction. |
447 | BL_DEFINE_ENUM(BLTextDirection) { |
448 | //! Left-to-right direction. |
449 | BL_TEXT_DIRECTION_LTR = 0, |
450 | //! Right-to-left direction. |
451 | BL_TEXT_DIRECTION_RTL = 1, |
452 | |
453 | //! Count of text direction types. |
454 | BL_TEXT_DIRECTION_COUNT = 2 |
455 | }; |
456 | |
457 | //! Text orientation. |
458 | BL_DEFINE_ENUM(BLTextOrientation) { |
459 | //! Horizontal orientation. |
460 | BL_TEXT_ORIENTATION_HORIZONTAL = 0, |
461 | //! Vertical orientation. |
462 | BL_TEXT_ORIENTATION_VERTICAL = 1, |
463 | |
464 | //! Count of text orientation types. |
465 | BL_TEXT_ORIENTATION_COUNT = 2 |
466 | }; |
467 | |
468 | // ============================================================================ |
469 | // [BLGlyphItem] |
470 | // ============================================================================ |
471 | |
472 | //! Glyph item as a data structure that represents either a unicode character |
473 | //! or glyph. It contains data used by `BLGlyphBuffer` and is visible to end |
474 | //! users so they can inspect either the text stored in `BLGlyphBuffer` or its |
475 | //! glyph-run representation. |
476 | struct BLGlyphItem { |
477 | union { |
478 | uint32_t value; |
479 | struct { |
480 | #if BL_BYTE_ORDER == 1234 |
481 | BLGlyphId glyphId; |
482 | uint16_t reserved; |
483 | #else |
484 | uint16_t reserved; |
485 | BLGlyphId glyphId; |
486 | #endif |
487 | }; |
488 | }; |
489 | |
490 | // -------------------------------------------------------------------------- |
491 | #ifdef __cplusplus |
492 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
493 | #endif |
494 | // -------------------------------------------------------------------------- |
495 | }; |
496 | |
497 | // ============================================================================ |
498 | // [BLGlyphInfo] |
499 | // ============================================================================ |
500 | |
501 | //! Glyph information contains additional information to `BLGlyphItem` used by |
502 | //! `BLGlyphBuffer`. |
503 | struct BLGlyphInfo { |
504 | uint32_t cluster; |
505 | uint32_t reserved[2]; |
506 | |
507 | // -------------------------------------------------------------------------- |
508 | #ifdef __cplusplus |
509 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
510 | #endif |
511 | // -------------------------------------------------------------------------- |
512 | }; |
513 | |
514 | // ============================================================================ |
515 | // [BLGlyphPlacement] |
516 | // ============================================================================ |
517 | |
518 | //! Glyph placement. |
519 | //! |
520 | //! Provides information about glyph offset (x/y) and advance (x/y). |
521 | struct BLGlyphPlacement { |
522 | BLPointI placement; |
523 | BLPointI advance; |
524 | |
525 | // -------------------------------------------------------------------------- |
526 | #ifdef __cplusplus |
527 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
528 | #endif |
529 | // -------------------------------------------------------------------------- |
530 | }; |
531 | |
532 | // ============================================================================ |
533 | // [BLGlyphMappingState] |
534 | // ============================================================================ |
535 | |
536 | //! Character to glyph mapping state. |
537 | struct BLGlyphMappingState { |
538 | //! Number of glyphs or glyph-items on output. |
539 | size_t glyphCount; |
540 | //! Index of the first undefined glyph (SIZE_MAX if none). |
541 | size_t undefinedFirst; |
542 | //! Undefined glyph count (chars that have no mapping). |
543 | size_t undefinedCount; |
544 | |
545 | // -------------------------------------------------------------------------- |
546 | #ifdef __cplusplus |
547 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
548 | #endif |
549 | // -------------------------------------------------------------------------- |
550 | }; |
551 | |
552 | // ============================================================================ |
553 | // [BLGlyphOutlineSinkInfo] |
554 | // ============================================================================ |
555 | |
556 | //! Information passed to a `BLPathSinkFunc` sink by `BLFont::getGlyphOutlines()`. |
557 | struct BLGlyphOutlineSinkInfo { |
558 | size_t glyphIndex; |
559 | size_t contourCount; |
560 | }; |
561 | |
562 | // ============================================================================ |
563 | // [BLGlyphRun] |
564 | // ============================================================================ |
565 | |
566 | //! BLGlyphRun describes a set of consecutive glyphs and their placements. |
567 | //! |
568 | //! BLGlyphRun should only be used to pass glyph IDs and their placements to the |
569 | //! rendering context. The purpose of BLGlyphRun is to allow rendering glyphs, |
570 | //! which could be shaped by various shaping engines (Blend2D, Harfbuzz, etc). |
571 | //! |
572 | //! BLGlyphRun allows to render glyphs that are part of a bigger structure (for |
573 | //! example `BLGlyphItem`), raw array like `BLGlyphId[]`, etc. Glyph placements |
574 | //! at the moment use Blend2D's `BLGlyphPlacement` or `BLPoint`, but it's |
575 | //! possible to extend the data type in the future. |
576 | //! |
577 | //! See `BLGlyphRunPlacement` for placement modes provided by Blend2D. |
578 | struct BLGlyphRun { |
579 | //! Glyph id array (abstract, incremented by `glyphIdAdvance`). |
580 | void* glyphIdData; |
581 | //! Glyph placement array (abstract, incremented by `placementAdvance`). |
582 | void* placementData; |
583 | //! Size of the glyph-run in glyph units. |
584 | size_t size; |
585 | //! Size of a `glyphId` - must be either 2 (uint16_t) or 4 (uint32_t) bytes. |
586 | uint8_t glyphIdSize; |
587 | //! Type of the placement, see `BLGlyphPlacementType`. |
588 | uint8_t placementType; |
589 | //! Advance of `glyphIdData` array. |
590 | int8_t glyphIdAdvance; |
591 | //! Advance of `placementData` array. |
592 | int8_t placementAdvance; |
593 | //! Glyph-run flags. |
594 | uint32_t flags; |
595 | |
596 | // -------------------------------------------------------------------------- |
597 | #ifdef __cplusplus |
598 | |
599 | BL_INLINE bool empty() const noexcept { return size == 0; } |
600 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
601 | |
602 | template<typename T> |
603 | BL_INLINE T* glyphIdDataAs() const noexcept { return static_cast<T*>(glyphIdData); } |
604 | |
605 | template<typename T> |
606 | BL_INLINE T* placementDataAs() const noexcept { return static_cast<T*>(placementData); } |
607 | |
608 | BL_INLINE void setGlyphIdData(const BLGlyphId* glyphIds) noexcept { setGlyphIdData(glyphIds, intptr_t(sizeof(BLGlyphId))); } |
609 | BL_INLINE void setGlyphItemData(const BLGlyphItem* itemData) noexcept { setGlyphIdData(itemData, intptr_t(sizeof(BLGlyphItem))); } |
610 | |
611 | BL_INLINE void setGlyphIdData(const void* data, intptr_t advance) noexcept { |
612 | this->glyphIdData = const_cast<void*>(data); |
613 | this->glyphIdAdvance = int8_t(advance); |
614 | } |
615 | |
616 | BL_INLINE void resetGlyphIdData() noexcept { |
617 | this->glyphIdData = nullptr; |
618 | this->glyphIdAdvance = 0; |
619 | } |
620 | |
621 | template<typename T> |
622 | BL_INLINE void setPlacementData(const T* data) noexcept { |
623 | setPlacementData(data, sizeof(T)); |
624 | } |
625 | |
626 | BL_INLINE void setPlacementData(const void* data, intptr_t advance) noexcept { |
627 | this->placementData = const_cast<void*>(data); |
628 | this->placementAdvance = int8_t(advance); |
629 | } |
630 | |
631 | BL_INLINE void resetPlacementData() noexcept { |
632 | this->placementData = nullptr; |
633 | this->placementAdvance = 0; |
634 | } |
635 | |
636 | #endif |
637 | // -------------------------------------------------------------------------- |
638 | }; |
639 | |
640 | // ============================================================================ |
641 | // [BLGlyphRunIterator] |
642 | // ============================================================================ |
643 | |
644 | #ifdef __cplusplus |
645 | //! A helper to iterate over a `BLGlyphRun`. |
646 | //! |
647 | //! Takes into consideration glyph-id advance and glyph-offset advance. |
648 | //! |
649 | //! Example: |
650 | //! |
651 | //! ``` |
652 | //! void inspectGlyphRun(const BLGlyphRun& glyphRun) noexcept { |
653 | //! BLGlyphRunIterator it(glyphRun); |
654 | //! if (it.hasOffsets()) { |
655 | //! while (!it.atEnd()) { |
656 | //! BLGlyphId glyphId = it.glyphId(); |
657 | //! BLPoint offset = it.placement(); |
658 | //! |
659 | //! // Do something with `glyphId` and `offset`. |
660 | //! |
661 | //! it.advance(); |
662 | //! } |
663 | //! } |
664 | //! else { |
665 | //! while (!it.atEnd()) { |
666 | //! BLGlyphId glyphId = it.glyphId(); |
667 | //! |
668 | //! // Do something with `glyphId`. |
669 | //! |
670 | //! it.advance(); |
671 | //! } |
672 | //! } |
673 | //! } |
674 | //! ``` |
675 | class BLGlyphRunIterator { |
676 | public: |
677 | size_t index; |
678 | size_t size; |
679 | void* glyphIdData; |
680 | void* placementData; |
681 | intptr_t glyphIdAdvance; |
682 | intptr_t placementAdvance; |
683 | |
684 | BL_INLINE BLGlyphRunIterator() noexcept { reset(); } |
685 | BL_INLINE explicit BLGlyphRunIterator(const BLGlyphRun& glyphRun) noexcept { reset(glyphRun); } |
686 | |
687 | BL_INLINE void reset() noexcept { |
688 | index = 0; |
689 | size = 0; |
690 | glyphIdData = nullptr; |
691 | placementData = nullptr; |
692 | glyphIdAdvance = 0; |
693 | placementAdvance = 0; |
694 | } |
695 | |
696 | BL_INLINE void reset(const BLGlyphRun& glyphRun) noexcept { |
697 | index = 0; |
698 | size = glyphRun.size; |
699 | glyphIdData = glyphRun.glyphIdData; |
700 | placementData = glyphRun.placementData; |
701 | glyphIdAdvance = glyphRun.glyphIdAdvance; |
702 | placementAdvance = glyphRun.placementAdvance; |
703 | |
704 | if (BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_BE) |
705 | glyphIdData = static_cast<uint8_t*>(glyphIdData) + (blMax<size_t>(glyphRun.glyphIdSize, 2) - 2); |
706 | } |
707 | |
708 | BL_INLINE bool empty() const noexcept { return size == 0; } |
709 | BL_INLINE bool atEnd() const noexcept { return index == size; } |
710 | BL_INLINE bool hasPlacement() const noexcept { return placementData != nullptr; } |
711 | |
712 | BL_INLINE BLGlyphId glyphId() const noexcept { return *static_cast<const BLGlyphId*>(glyphIdData); } |
713 | |
714 | template<typename T> |
715 | BL_INLINE const T& placement() const noexcept { return *static_cast<const T*>(placementData); } |
716 | |
717 | BL_INLINE void advance() noexcept { |
718 | BL_ASSERT(!atEnd()); |
719 | |
720 | index++; |
721 | glyphIdData = static_cast<uint8_t*>(glyphIdData) + glyphIdAdvance; |
722 | placementData = static_cast<uint8_t*>(placementData) + placementAdvance; |
723 | } |
724 | }; |
725 | #endif |
726 | |
727 | // ============================================================================ |
728 | // [BLFontFaceInfo] |
729 | // ============================================================================ |
730 | |
731 | //! Information of `BLFontFace`. |
732 | struct BLFontFaceInfo { |
733 | //! Font-face type, see `BLFontFaceType`. |
734 | uint8_t faceType; |
735 | //! Type of outlines used by the font-face, see `BLFontOutlineType`. |
736 | uint8_t outlineType; |
737 | //! Number of glyphs provided by this font-face. |
738 | uint16_t glyphCount; |
739 | |
740 | //! Face index in a ttf/otf collection (or zero). |
741 | uint32_t faceIndex; |
742 | //! Font-face flags, see `BLFontFaceFlags` |
743 | uint32_t faceFlags; |
744 | //! Font-face diagnostic flags, see`BLFontFaceDiagFlags`. |
745 | uint32_t diagFlags; |
746 | |
747 | // -------------------------------------------------------------------------- |
748 | #ifdef __cplusplus |
749 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
750 | #endif |
751 | // -------------------------------------------------------------------------- |
752 | }; |
753 | |
754 | // ============================================================================ |
755 | // [BLFontTable] |
756 | // ============================================================================ |
757 | |
758 | //! A read only data that represents a font table or its sub-table. |
759 | struct BLFontTable { |
760 | //! Pointer to the beginning of the data interpreted as `uint8_t*`. |
761 | const uint8_t* data; |
762 | //! Size of `data` in bytes. |
763 | size_t size; |
764 | |
765 | // -------------------------------------------------------------------------- |
766 | #ifdef __cplusplus |
767 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
768 | |
769 | template<typename T> |
770 | BL_INLINE const T* dataAs() const noexcept { return reinterpret_cast<const T*>(data); } |
771 | #endif |
772 | // -------------------------------------------------------------------------- |
773 | }; |
774 | |
775 | // ============================================================================ |
776 | // [BLFontFeature] |
777 | // ============================================================================ |
778 | |
779 | //! Associates a value with a generic font feature where `tag` describes the |
780 | //! feature (as provided by the font) and `value` describes its value. Some |
781 | //! features only allow boolean values 0 and 1 and some also allow higher |
782 | //! values up to 65535. |
783 | //! |
784 | //! Registered OpenType features: |
785 | //! - https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags |
786 | //! - https://helpx.adobe.com/typekit/using/open-type-syntax.html |
787 | struct BLFontFeature { |
788 | //! Feature tag (32-bit). |
789 | BLTag tag; |
790 | //! Feature value (should not be greater than 65535). |
791 | uint32_t value; |
792 | |
793 | // -------------------------------------------------------------------------- |
794 | #ifdef __cplusplus |
795 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
796 | #endif |
797 | // -------------------------------------------------------------------------- |
798 | }; |
799 | |
800 | // ============================================================================ |
801 | // [BLFontVariation] |
802 | // ============================================================================ |
803 | |
804 | //! Associates a value with a font variation feature where `tag` describes |
805 | //! variation axis and `value` defines its value. |
806 | struct BLFontVariation { |
807 | //! Variation tag (32-bit). |
808 | BLTag tag; |
809 | //! Variation value. |
810 | float value; |
811 | |
812 | // -------------------------------------------------------------------------- |
813 | #ifdef __cplusplus |
814 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
815 | #endif |
816 | // -------------------------------------------------------------------------- |
817 | }; |
818 | |
819 | // ============================================================================ |
820 | // [BLFontUnicodeCoverage] |
821 | // ============================================================================ |
822 | |
823 | //! Font unicode coverage. |
824 | //! |
825 | //! Unicode coverage describes which unicode characters are provided by a font. |
826 | //! Blend2D accesses this information by reading "OS/2" table, if available. |
827 | struct BLFontUnicodeCoverage { |
828 | uint32_t data[4]; |
829 | |
830 | // -------------------------------------------------------------------------- |
831 | #ifdef __cplusplus |
832 | |
833 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
834 | |
835 | BL_INLINE bool empty() const noexcept { |
836 | return (this->data[0] | this->data[1] | this->data[2] | this->data[3]) == 0; |
837 | } |
838 | |
839 | BL_INLINE bool hasBit(uint32_t index) const noexcept { |
840 | return ((this->data[index / 32] >> (index % 32)) & 0x1) != 0; |
841 | } |
842 | |
843 | BL_INLINE void setBit(uint32_t index) noexcept { |
844 | this->data[index / 32] |= uint32_t(1) << (index % 32); |
845 | } |
846 | |
847 | BL_INLINE void clearBit(uint32_t index) noexcept { |
848 | this->data[index / 32] &= ~(uint32_t(1) << (index % 32)); |
849 | } |
850 | |
851 | BL_INLINE bool equals(const BLFontUnicodeCoverage& other) const noexcept { |
852 | return blEquals(this->data[0], other.data[0]) & |
853 | blEquals(this->data[1], other.data[1]) & |
854 | blEquals(this->data[2], other.data[2]) & |
855 | blEquals(this->data[3], other.data[3]) ; |
856 | } |
857 | |
858 | BL_INLINE bool operator==(const BLFontUnicodeCoverage& other) const noexcept { return equals(other); } |
859 | BL_INLINE bool operator!=(const BLFontUnicodeCoverage& other) const noexcept { return !equals(other); } |
860 | |
861 | #endif |
862 | // -------------------------------------------------------------------------- |
863 | }; |
864 | |
865 | // ============================================================================ |
866 | // [BLFontPanose] |
867 | // ============================================================================ |
868 | |
869 | //! Font PANOSE classification. |
870 | struct BLFontPanose { |
871 | union { |
872 | uint8_t data[10]; |
873 | uint8_t familyKind; |
874 | |
875 | struct { |
876 | uint8_t familyKind; |
877 | uint8_t serifStyle; |
878 | uint8_t weight; |
879 | uint8_t proportion; |
880 | uint8_t contrast; |
881 | uint8_t strokeVariation; |
882 | uint8_t armStyle; |
883 | uint8_t letterform; |
884 | uint8_t midline; |
885 | uint8_t xHeight; |
886 | } text; |
887 | |
888 | struct { |
889 | uint8_t familyKind; |
890 | uint8_t toolKind; |
891 | uint8_t weight; |
892 | uint8_t spacing; |
893 | uint8_t aspectRatio; |
894 | uint8_t contrast; |
895 | uint8_t topology; |
896 | uint8_t form; |
897 | uint8_t finials; |
898 | uint8_t xAscent; |
899 | } script; |
900 | |
901 | struct { |
902 | uint8_t familyKind; |
903 | uint8_t decorativeClass; |
904 | uint8_t weight; |
905 | uint8_t aspect; |
906 | uint8_t contrast; |
907 | uint8_t serifVariant; |
908 | uint8_t treatment; |
909 | uint8_t lining; |
910 | uint8_t topology; |
911 | uint8_t characterRange; |
912 | } decorative; |
913 | |
914 | struct { |
915 | uint8_t familyKind; |
916 | uint8_t symbolKind; |
917 | uint8_t weight; |
918 | uint8_t spacing; |
919 | uint8_t aspectRatioAndContrast; |
920 | uint8_t aspectRatio94; |
921 | uint8_t aspectRatio119; |
922 | uint8_t aspectRatio157; |
923 | uint8_t aspectRatio163; |
924 | uint8_t aspectRatio211; |
925 | } symbol; |
926 | }; |
927 | |
928 | // -------------------------------------------------------------------------- |
929 | #ifdef __cplusplus |
930 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
931 | |
932 | BL_INLINE bool empty() const noexcept { |
933 | return (this->data[0] | this->data[1] | this->data[2] | this->data[3] | this->data[4] | |
934 | this->data[5] | this->data[6] | this->data[7] | this->data[8] | this->data[9] ) == 0; |
935 | } |
936 | #endif |
937 | // -------------------------------------------------------------------------- |
938 | }; |
939 | |
940 | // ============================================================================ |
941 | // [BLFontMatrix] |
942 | // ============================================================================ |
943 | |
944 | //! 2x2 transformation matrix used by `BLFont`. It's similar to `BLMatrix2D`, |
945 | //! however, it doesn't provide a translation part as it's assumed to be zero. |
946 | struct BLFontMatrix { |
947 | union { |
948 | double m[4]; |
949 | struct { |
950 | double m00; |
951 | double m01; |
952 | double m10; |
953 | double m11; |
954 | }; |
955 | }; |
956 | |
957 | // -------------------------------------------------------------------------- |
958 | #ifdef __cplusplus |
959 | |
960 | BL_INLINE BLFontMatrix() noexcept = default; |
961 | BL_INLINE BLFontMatrix(const BLFontMatrix& other) noexcept = default; |
962 | |
963 | BL_INLINE BLFontMatrix(double m00, double m01, double m10, double m11) noexcept |
964 | : m00(m00), m01(m01), m10(m10), m11(m11) {} |
965 | |
966 | BL_INLINE void reset() noexcept { |
967 | this->m00 = 1.0; |
968 | this->m01 = 0.0; |
969 | this->m10 = 0.0; |
970 | this->m11 = 1.0; |
971 | } |
972 | |
973 | BL_INLINE void reset(double m00, double m01, double m10, double m11) noexcept { |
974 | this->m00 = m00; |
975 | this->m01 = m01; |
976 | this->m10 = m10; |
977 | this->m11 = m11; |
978 | } |
979 | |
980 | #endif |
981 | // -------------------------------------------------------------------------- |
982 | }; |
983 | |
984 | // ============================================================================ |
985 | // [BLFontMetrics] |
986 | // ============================================================================ |
987 | |
988 | //! Scaled `BLFontDesignMetrics` based on font size and other properties. |
989 | struct BLFontMetrics { |
990 | //! Font size. |
991 | float size; |
992 | |
993 | union { |
994 | struct { |
995 | //! Font ascent (horizontal orientation). |
996 | float ascent; |
997 | //! Font ascent (vertical orientation). |
998 | float vAscent; |
999 | //! Font descent (horizontal orientation). |
1000 | float descent; |
1001 | //! Font descent (vertical orientation). |
1002 | float vDescent; |
1003 | }; |
1004 | |
1005 | struct { |
1006 | float ascentByOrientation[2]; |
1007 | float descentByOrientation[2]; |
1008 | }; |
1009 | }; |
1010 | |
1011 | //! Line gap. |
1012 | float lineGap; |
1013 | //! Distance between the baseline and the mean line of lower-case letters. |
1014 | float xHeight; |
1015 | //! Maximum height of a capital letter above the baseline. |
1016 | float capHeight; |
1017 | |
1018 | //! Text underline position. |
1019 | float underlinePosition; |
1020 | //! Text underline thickness. |
1021 | float underlineThickness; |
1022 | //! Text strikethrough position. |
1023 | float strikethroughPosition; |
1024 | //! Text strikethrough thickness. |
1025 | float strikethroughThickness; |
1026 | |
1027 | // -------------------------------------------------------------------------- |
1028 | #ifdef __cplusplus |
1029 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
1030 | #endif |
1031 | // -------------------------------------------------------------------------- |
1032 | }; |
1033 | |
1034 | // ============================================================================ |
1035 | // [BLFontDesignMetrics] |
1036 | // ============================================================================ |
1037 | |
1038 | //! Design metrics of a font. |
1039 | //! |
1040 | //! Design metrics is information that `BLFontFace` collected directly from the |
1041 | //! font data. It means that all fields are measured in font design units. |
1042 | //! |
1043 | //! When a new `BLFont` instance is created a scaled metrics `BLFontMetrics` is |
1044 | //! automatically calculated from `BLFontDesignMetrics` including other members |
1045 | //! like transformation, etc... |
1046 | struct BLFontDesignMetrics { |
1047 | //! Units per EM square. |
1048 | int unitsPerEm; |
1049 | //! Line gap. |
1050 | int lineGap; |
1051 | //! Distance between the baseline and the mean line of lower-case letters. |
1052 | int xHeight; |
1053 | //! Maximum height of a capital letter above the baseline. |
1054 | int capHeight; |
1055 | |
1056 | union { |
1057 | struct { |
1058 | //! Ascent (horizontal). |
1059 | int ascent; |
1060 | //! Ascent (vertical). |
1061 | int vAscent; |
1062 | //! Descent (horizontal). |
1063 | int descent; |
1064 | //! Descent (vertical). |
1065 | int vDescent; |
1066 | //! Minimum leading-side bearing (horizontal). |
1067 | int hMinLSB; |
1068 | //! Minimum leading-side bearing (vertical). |
1069 | int vMinLSB; |
1070 | //! Minimum trailing-side bearing (horizontal). |
1071 | int hMinTSB; |
1072 | //! Minimum trailing-side bearing (vertical). |
1073 | int vMinTSB; |
1074 | //! Maximum horizontal advance. |
1075 | int hMaxAdvance; |
1076 | //! Maximum vertical advance. |
1077 | int vMaxAdvance; |
1078 | }; |
1079 | |
1080 | struct { |
1081 | //! Horizontal & vertical ascents. |
1082 | int ascentByOrientation[2]; |
1083 | //! Horizontal & vertical descents. |
1084 | int descentByOrientation[2]; |
1085 | //! Minimum leading-side bearing (horizontal and vertical). |
1086 | int minLSBByOrientation[2]; |
1087 | //! Minimum trailing-side bearing (horizontal and vertical).. |
1088 | int minTSBByOrientation[2]; |
1089 | //! Maximum advance width (horizontal) and height (vertical). |
1090 | int maxAdvanceByOrientation[2]; |
1091 | }; |
1092 | }; |
1093 | |
1094 | //! Text underline position. |
1095 | int underlinePosition; |
1096 | //! Text underline thickness. |
1097 | int underlineThickness; |
1098 | //! Text strikethrough position. |
1099 | int strikethroughPosition; |
1100 | //! Text strikethrough thickness. |
1101 | int strikethroughThickness; |
1102 | |
1103 | // -------------------------------------------------------------------------- |
1104 | #ifdef __cplusplus |
1105 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
1106 | #endif |
1107 | // -------------------------------------------------------------------------- |
1108 | }; |
1109 | |
1110 | // ============================================================================ |
1111 | // [BLTextMetrics] |
1112 | // ============================================================================ |
1113 | |
1114 | //! Text metrics. |
1115 | struct BLTextMetrics { |
1116 | BLPoint advance; |
1117 | BLBox boundingBox; |
1118 | |
1119 | // -------------------------------------------------------------------------- |
1120 | #ifdef __cplusplus |
1121 | BL_INLINE void reset() noexcept { memset(this, 0, sizeof(*this)); } |
1122 | #endif |
1123 | // -------------------------------------------------------------------------- |
1124 | }; |
1125 | |
1126 | //! \} |
1127 | |
1128 | BL_DIAGNOSTIC_POP |
1129 | |
1130 | #endif // BLEND2D_BLFONTDEFS_H |
1131 | |