ReactOS 0.4.16-dev-1019-g2c2cdfd
afglobal.c File Reference
#include "afglobal.h"
#include "afranges.h"
#include "afshaper.h"
#include "afwrtsys.h"
#include "aferrors.h"
#include "afscript.h"
#include "afstyles.h"
Include dependency graph for afglobal.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   afglobal
 
#define WRITING_SYSTEM(ws, WS)   /* empty */
 
#define SCRIPT(s, S, d, h, H, ss)
 
#define STYLE(s, S, d, ws, sc, ss, c)
 
#define WRITING_SYSTEM(ws, WS)    &af_ ## ws ## _writing_system_class,
 
#define SCRIPT(s, S, d, h, H, ss)    &af_ ## s ## _script_class,
 
#define STYLE(s, S, d, ws, sc, ss, c)    &af_ ## s ## _style_class,
 

Functions

static FT_Error af_face_globals_compute_style_coverage (AF_FaceGlobals globals)
 
 af_face_globals_new (FT_Face face, AF_FaceGlobals *aglobals, AF_Module module)
 
 af_face_globals_free (AF_FaceGlobals globals)
 
 af_face_globals_get_metrics (AF_FaceGlobals globals, FT_UInt gindex, FT_UInt options, AF_StyleMetrics *ametrics)
 
 af_face_globals_is_digit (AF_FaceGlobals globals, FT_UInt gindex)
 

Variables

 af_writing_system_classes []
 
 af_script_classes []
 
 af_style_classes []
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   afglobal

Definition at line 32 of file afglobal.c.

◆ SCRIPT [1/2]

#define SCRIPT (   s,
  S,
  d,
  h,
  H,
  ss 
)
Value:
af_ ## s ## _script_class, \
AF_SCRIPT_ ## S, \
af_ ## s ## _uniranges, \
af_ ## s ## _nonbase_uniranges, \
AF_ ## H, \
ss )
#define AF_DEFINE_SCRIPT_CLASS( script_class, script, ranges, nonbase_ranges, top_to_bottom, std_charstring)
Definition: aftypes.h:526
GLdouble s
Definition: gl.h:2039
#define ss
Definition: i386-dis.c:441
#define H
Definition: movable.cpp:9

Definition at line 84 of file afglobal.c.

◆ SCRIPT [2/2]

#define SCRIPT (   s,
  S,
  d,
  h,
  H,
  ss 
)     &af_ ## s ## _script_class,

Definition at line 84 of file afglobal.c.

◆ STYLE [1/2]

#define STYLE (   s,
  S,
  d,
  ws,
  sc,
  ss,
  c 
)
Value:
af_ ## s ## _style_class, \
AF_STYLE_ ## S, \
ws, \
sc, \
ss, \
c )
#define AF_DEFINE_STYLE_CLASS( style_class, style, writing_system, script, blue_stringset, coverage)
Definition: aftypes.h:548
const GLubyte * c
Definition: glext.h:8905

Definition at line 98 of file afglobal.c.

◆ STYLE [2/2]

#define STYLE (   s,
  S,
  d,
  ws,
  sc,
  ss,
  c 
)     &af_ ## s ## _style_class,

Definition at line 98 of file afglobal.c.

◆ WRITING_SYSTEM [1/2]

#define WRITING_SYSTEM (   ws,
  WS 
)    /* empty */

Definition at line 70 of file afglobal.c.

◆ WRITING_SYSTEM [2/2]

#define WRITING_SYSTEM (   ws,
  WS 
)     &af_ ## ws ## _writing_system_class,

Definition at line 70 of file afglobal.c.

Function Documentation

◆ af_face_globals_compute_style_coverage()

static FT_Error af_face_globals_compute_style_coverage ( AF_FaceGlobals  globals)
static

Definition at line 130 of file afglobal.c.

131 {
133 FT_Face face = globals->face;
134 FT_CharMap old_charmap = face->charmap;
135 FT_UShort* gstyles = globals->glyph_styles;
136 FT_UInt ss;
137 FT_UInt i;
138 FT_UInt dflt = ~0U; /* a non-valid value */
139
140
141 /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
142 for ( i = 0; i < (FT_UInt)globals->glyph_count; i++ )
143 gstyles[i] = AF_STYLE_UNASSIGNED;
144
145 error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
146 if ( error )
147 {
148 /*
149 * Ignore this error; we simply use the fallback style.
150 * XXX: Shouldn't we rather disable hinting?
151 */
153 goto Exit;
154 }
155
156 /* scan each style in a Unicode charmap */
157 for ( ss = 0; af_style_classes[ss]; ss++ )
158 {
159 AF_StyleClass style_class =
161 AF_ScriptClass script_class =
162 af_script_classes[style_class->script];
164
165
166 if ( !script_class->script_uni_ranges )
167 continue;
168
169 /*
170 * Scan all Unicode points in the range and set the corresponding
171 * glyph style index.
172 */
173 if ( style_class->coverage == AF_COVERAGE_DEFAULT )
174 {
175 if ( (FT_UInt)style_class->script ==
176 globals->module->default_script )
177 dflt = ss;
178
179 for ( range = script_class->script_uni_ranges;
180 range->first != 0;
181 range++ )
182 {
183 FT_ULong charcode = range->first;
184 FT_UInt gindex;
185
186
187 gindex = FT_Get_Char_Index( face, charcode );
188
189 if ( gindex != 0 &&
190 gindex < (FT_ULong)globals->glyph_count &&
191 ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
192 gstyles[gindex] = (FT_UShort)ss;
193
194 for (;;)
195 {
196 charcode = FT_Get_Next_Char( face, charcode, &gindex );
197
198 if ( gindex == 0 || charcode > range->last )
199 break;
200
201 if ( gindex < (FT_ULong)globals->glyph_count &&
202 ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
203 gstyles[gindex] = (FT_UShort)ss;
204 }
205 }
206
207 /* do the same for the script's non-base characters */
208 for ( range = script_class->script_uni_nonbase_ranges;
209 range->first != 0;
210 range++ )
211 {
212 FT_ULong charcode = range->first;
213 FT_UInt gindex;
214
215
216 gindex = FT_Get_Char_Index( face, charcode );
217
218 if ( gindex != 0 &&
219 gindex < (FT_ULong)globals->glyph_count &&
220 ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
221 gstyles[gindex] |= AF_NONBASE;
222
223 for (;;)
224 {
225 charcode = FT_Get_Next_Char( face, charcode, &gindex );
226
227 if ( gindex == 0 || charcode > range->last )
228 break;
229
230 if ( gindex < (FT_ULong)globals->glyph_count &&
231 ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
232 gstyles[gindex] |= AF_NONBASE;
233 }
234 }
235 }
236 else
237 {
238 /* get glyphs not directly addressable by cmap */
239 af_shaper_get_coverage( globals, style_class, gstyles, 0 );
240 }
241 }
242
243 /* handle the remaining default OpenType features ... */
244 for ( ss = 0; af_style_classes[ss]; ss++ )
245 {
246 AF_StyleClass style_class = af_style_classes[ss];
247
248
249 if ( style_class->coverage == AF_COVERAGE_DEFAULT )
250 af_shaper_get_coverage( globals, style_class, gstyles, 0 );
251 }
252
253 /* ... and finally the default OpenType features of the default script */
254 af_shaper_get_coverage( globals, af_style_classes[dflt], gstyles, 1 );
255
256 /* mark ASCII digits */
257 for ( i = 0x30; i <= 0x39; i++ )
258 {
259 FT_UInt gindex = FT_Get_Char_Index( face, i );
260
261
262 if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
263 gstyles[gindex] |= AF_DIGIT;
264 }
265
266 Exit:
267 /*
268 * By default, all uncovered glyphs are set to the fallback style.
269 * XXX: Shouldn't we disable hinting or do something similar?
270 */
271 if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED )
272 {
273 FT_Long nn;
274
275
276 for ( nn = 0; nn < globals->glyph_count; nn++ )
277 {
278 if ( ( gstyles[nn] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
279 {
280 gstyles[nn] &= ~AF_STYLE_MASK;
281 gstyles[nn] |= globals->module->fallback_style;
282 }
283 }
284 }
285
286#ifdef FT_DEBUG_LEVEL_TRACE
287
288 FT_TRACE4(( "\n"
289 "style coverage\n"
290 "==============\n"
291 "\n" ));
292
293 for ( ss = 0; af_style_classes[ss]; ss++ )
294 {
295 AF_StyleClass style_class = af_style_classes[ss];
296 FT_UInt count = 0;
297 FT_Long idx;
298
299
300 FT_TRACE4(( "%s:\n", af_style_names[style_class->style] ));
301
302 for ( idx = 0; idx < globals->glyph_count; idx++ )
303 {
304 if ( ( gstyles[idx] & AF_STYLE_MASK ) == style_class->style )
305 {
306 if ( !( count % 10 ) )
307 FT_TRACE4(( " " ));
308
309 FT_TRACE4(( " %d", idx ));
310 count++;
311
312 if ( !( count % 10 ) )
313 FT_TRACE4(( "\n" ));
314 }
315 }
316
317 if ( !count )
318 FT_TRACE4(( " (none)\n" ));
319 if ( count % 10 )
320 FT_TRACE4(( "\n" ));
321 }
322
323#endif /* FT_DEBUG_LEVEL_TRACE */
324
325 FT_Set_Charmap( face, old_charmap );
326 return error;
327 }
af_script_classes[]
Definition: afglobal.c:88
af_style_classes[]
Definition: afglobal.c:102
#define AF_STYLE_UNASSIGNED
Definition: afglobal.h:79
#define AF_STYLE_MASK
Definition: afglobal.h:77
#define AF_DIGIT
Definition: afglobal.h:82
#define AF_NONBASE
Definition: afglobal.h:84
FT_Error af_shaper_get_coverage(AF_FaceGlobals globals, AF_StyleClass style_class, FT_UShort *gstyles, FT_Bool default_script)
Definition: afshaper.c:577
@ AF_COVERAGE_DEFAULT
Definition: aftypes.h:414
#define U(x)
Definition: wordpad.c:45
unsigned int idx
Definition: utils.c:41
FT_Get_Char_Index(FT_Face face, FT_ULong charcode)
Definition: ftobjs.c:3711
FT_Select_Charmap(FT_Face face, FT_Encoding encoding)
Definition: ftobjs.c:3501
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3765
FT_Set_Charmap(FT_Face face, FT_CharMap charmap)
Definition: ftobjs.c:3544
return FT_Err_Ok
Definition: ftbbox.c:527
#define FT_TRACE4(varformat)
Definition: ftdebug.h:189
unsigned long FT_ULong
Definition: fttypes.h:253
int FT_Error
Definition: fttypes.h:299
signed long FT_Long
Definition: fttypes.h:242
unsigned short FT_UShort
Definition: fttypes.h:209
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLenum GLint * range
Definition: glext.h:7539
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define error(str)
Definition: mkdosfs.c:1605
static void Exit(void)
Definition: sock.c:1330
FT_UShort * glyph_styles
Definition: afglobal.h:109
AF_Module module
Definition: afglobal.h:137
FT_Long glyph_count
Definition: afglobal.h:108
AF_Script_UniRange script_uni_nonbase_ranges
Definition: aftypes.h:346
AF_Script_UniRange script_uni_ranges
Definition: aftypes.h:345
AF_Style style
Definition: aftypes.h:449
AF_Script script
Definition: aftypes.h:452
AF_Coverage coverage
Definition: aftypes.h:454

Referenced by af_face_globals_new().

◆ af_face_globals_free()

af_face_globals_free ( AF_FaceGlobals  globals)

Definition at line 382 of file afglobal.c.

383 {
384 if ( globals )
385 {
386 FT_Memory memory = globals->face->memory;
387 FT_UInt nn;
388
389
390 for ( nn = 0; nn < AF_STYLE_MAX; nn++ )
391 {
392 if ( globals->metrics[nn] )
393 {
394 AF_StyleClass style_class =
396 AF_WritingSystemClass writing_system_class =
398
399
400 if ( writing_system_class->style_metrics_done )
401 writing_system_class->style_metrics_done( globals->metrics[nn] );
402
403 FT_FREE( globals->metrics[nn] );
404 }
405 }
406
407#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
408 hb_font_destroy( globals->hb_font );
409 hb_buffer_destroy( globals->hb_buf );
410#endif
411
412 /* no need to free `globals->glyph_styles'; */
413 /* it is part of the `globals' array */
414 FT_FREE( globals );
415 }
416 }
af_writing_system_classes[]
Definition: afglobal.c:74
@ AF_STYLE_MAX
Definition: aftypes.h:442
#define FT_FREE(ptr)
Definition: ftmemory.h:328
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:65
static char memory[1024 *256]
Definition: process.c:116
AF_StyleMetrics metrics[AF_STYLE_MAX]
Definition: afglobal.h:119
AF_WritingSystem writing_system
Definition: aftypes.h:451
AF_WritingSystem_DoneMetricsFunc style_metrics_done
Definition: aftypes.h:285
FT_Memory memory
Definition: freetype.h:1085

Referenced by af_face_globals_new(), af_loader_reset(), and af_property_get_face_globals().

◆ af_face_globals_get_metrics()

af_face_globals_get_metrics ( AF_FaceGlobals  globals,
FT_UInt  gindex,
FT_UInt  options,
AF_StyleMetrics ametrics 
)

Definition at line 420 of file afglobal.c.

424 {
426
428 AF_WritingSystemClass writing_system_class;
429 AF_StyleClass style_class;
430
432
433
434 if ( gindex >= (FT_ULong)globals->glyph_count )
435 {
436 error = FT_THROW( Invalid_Argument );
437 goto Exit;
438 }
439
440 /* if we have a forced style (via `options'), use it, */
441 /* otherwise look into `glyph_styles' array */
442 if ( style == AF_STYLE_NONE_DFLT || style + 1 >= AF_STYLE_MAX )
443 style = (AF_Style)( globals->glyph_styles[gindex] &
445
446 style_class = af_style_classes[style];
447 writing_system_class = af_writing_system_classes
448 [style_class->writing_system];
449
450 metrics = globals->metrics[style];
451 if ( !metrics )
452 {
453 /* create the global metrics object if necessary */
454 FT_Memory memory = globals->face->memory;
455
456
457 if ( FT_ALLOC( metrics, writing_system_class->style_metrics_size ) )
458 goto Exit;
459
460 metrics->style_class = style_class;
461 metrics->globals = globals;
462
463 if ( writing_system_class->style_metrics_init )
464 {
465 error = writing_system_class->style_metrics_init( metrics,
466 globals->face );
467 if ( error )
468 {
469 if ( writing_system_class->style_metrics_done )
470 writing_system_class->style_metrics_done( metrics );
471
472 FT_FREE( metrics );
473 goto Exit;
474 }
475 }
476
477 globals->metrics[style] = metrics;
478 }
479
480 Exit:
481 *ametrics = metrics;
482
483 return error;
484 }
Arabic default style
Definition: afstyles.h:94
enum AF_Style_ AF_Style
#define NULL
Definition: types.h:112
#define FT_THROW(e)
Definition: ftdebug.h:241
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:302
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
Definition: glext.h:11745
FT_Offset style_metrics_size
Definition: aftypes.h:282
AF_WritingSystem_InitMetricsFunc style_metrics_init
Definition: aftypes.h:283

Referenced by af_loader_load_glyph().

◆ af_face_globals_is_digit()

af_face_globals_is_digit ( AF_FaceGlobals  globals,
FT_UInt  gindex 
)

Definition at line 488 of file afglobal.c.

490 {
491 if ( gindex < (FT_ULong)globals->glyph_count )
492 return FT_BOOL( globals->glyph_styles[gindex] & AF_DIGIT );
493
494 return FT_BOOL( 0 );
495 }
#define FT_BOOL(x)
Definition: fttypes.h:591

Referenced by af_loader_load_glyph().

◆ af_face_globals_new()

af_face_globals_new ( FT_Face  face,
AF_FaceGlobals aglobals,
AF_Module  module 
)

Definition at line 331 of file afglobal.c.

334 {
337 AF_FaceGlobals globals = NULL;
338
339
340 memory = face->memory;
341
342 /* we allocate an AF_FaceGlobals structure together */
343 /* with the glyph_styles array */
344 if ( FT_ALLOC( globals,
345 sizeof ( *globals ) +
346 (FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
347 goto Exit;
348
349 globals->face = face;
350 globals->glyph_count = face->num_glyphs;
351 /* right after the globals structure come the glyph styles */
352 globals->glyph_styles = (FT_UShort*)( globals + 1 );
353 globals->module = module;
354 globals->stem_darkening_for_ppem = 0;
355 globals->darken_x = 0;
356 globals->darken_y = 0;
357 globals->standard_vertical_width = 0;
358 globals->standard_horizontal_width = 0;
359 globals->scale_down_factor = 0;
360
361#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
362 globals->hb_font = hb_ft_font_create( face, NULL );
363 globals->hb_buf = hb_buffer_create();
364#endif
365
367 if ( error )
368 {
369 af_face_globals_free( globals );
370 globals = NULL;
371 }
372 else
374
375 Exit:
376 *aglobals = globals;
377 return error;
378 }
af_face_globals_free(AF_FaceGlobals globals)
Definition: afglobal.c:382
static FT_Error af_face_globals_compute_style_coverage(AF_FaceGlobals globals)
Definition: afglobal.c:130
#define AF_PROP_INCREASE_X_HEIGHT_MAX
Definition: afglobal.h:88
WORD face[3]
Definition: mesh.c:4747
FT_UShort stem_darkening_for_ppem
Definition: afglobal.h:123
FT_Pos standard_horizontal_width
Definition: afglobal.h:129
FT_Pos standard_vertical_width
Definition: afglobal.h:126
FT_UInt increase_x_height
Definition: afglobal.h:117
FT_Fixed scale_down_factor
Definition: afglobal.h:136
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by af_loader_reset(), and af_property_get_face_globals().

Variable Documentation

◆ af_script_classes

af_script_classes[]

◆ af_style_classes

af_style_classes[]

◆ af_writing_system_classes

af_writing_system_classes[]