OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ttdriver.c */ | 3 /* ttdriver.c */ |
4 /* */ | 4 /* */ |
5 /* TrueType font driver implementation (body). */ | 5 /* TrueType font driver implementation (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2011 by */ | 7 /* Copyright 1996-2012 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 ttsize->root.metrics = ttsize->metrics; | 251 ttsize->root.metrics = ttsize->metrics; |
252 } | 252 } |
253 | 253 |
254 return error; | 254 return error; |
255 } | 255 } |
256 | 256 |
257 | 257 |
258 /*************************************************************************/ | 258 /*************************************************************************/ |
259 /* */ | 259 /* */ |
260 /* <Function> */ | 260 /* <Function> */ |
261 /* Load_Glyph */ | 261 /* tt_glyph_load */ |
262 /* */ | 262 /* */ |
263 /* <Description> */ | 263 /* <Description> */ |
264 /* A driver method used to load a glyph within a given glyph slot. */ | 264 /* A driver method used to load a glyph within a given glyph slot. */ |
265 /* */ | 265 /* */ |
266 /* <Input> */ | 266 /* <Input> */ |
267 /* slot :: A handle to the target slot object where the glyph */ | 267 /* slot :: A handle to the target slot object where the glyph */ |
268 /* will be loaded. */ | 268 /* will be loaded. */ |
269 /* */ | 269 /* */ |
270 /* size :: A handle to the source face size at which the glyph */ | 270 /* size :: A handle to the source face size at which the glyph */ |
271 /* must be scaled, loaded, etc. */ | 271 /* must be scaled, loaded, etc. */ |
272 /* */ | 272 /* */ |
273 /* glyph_index :: The index of the glyph in the font file. */ | 273 /* glyph_index :: The index of the glyph in the font file. */ |
274 /* */ | 274 /* */ |
275 /* load_flags :: A flag indicating what to load for this glyph. The */ | 275 /* load_flags :: A flag indicating what to load for this glyph. The */ |
276 /* FT_LOAD_XXX constants can be used to control the */ | 276 /* FT_LOAD_XXX constants can be used to control the */ |
277 /* glyph loading process (e.g., whether the outline */ | 277 /* glyph loading process (e.g., whether the outline */ |
278 /* should be scaled, whether to load bitmaps or not, */ | 278 /* should be scaled, whether to load bitmaps or not, */ |
279 /* whether to hint the outline, etc). */ | 279 /* whether to hint the outline, etc). */ |
280 /* */ | 280 /* */ |
281 /* <Return> */ | 281 /* <Return> */ |
282 /* FreeType error code. 0 means success. */ | 282 /* FreeType error code. 0 means success. */ |
283 /* */ | 283 /* */ |
284 static FT_Error | 284 static FT_Error |
285 Load_Glyph( FT_GlyphSlot ttslot, /* TT_GlyphSlot */ | 285 tt_glyph_load( FT_GlyphSlot ttslot, /* TT_GlyphSlot */ |
286 FT_Size ttsize, /* TT_Size */ | 286 FT_Size ttsize, /* TT_Size */ |
287 FT_UInt glyph_index, | 287 FT_UInt glyph_index, |
288 FT_Int32 load_flags ) | 288 FT_Int32 load_flags ) |
289 { | 289 { |
290 TT_GlyphSlot slot = (TT_GlyphSlot)ttslot; | 290 TT_GlyphSlot slot = (TT_GlyphSlot)ttslot; |
291 TT_Size size = (TT_Size)ttsize; | 291 TT_Size size = (TT_Size)ttsize; |
292 FT_Face face = ttslot->face; | 292 FT_Face face = ttslot->face; |
293 FT_Error error; | 293 FT_Error error; |
294 | 294 |
295 | 295 |
296 if ( !slot ) | 296 if ( !slot ) |
297 return TT_Err_Invalid_Slot_Handle; | 297 return TT_Err_Invalid_Slot_Handle; |
298 | 298 |
299 if ( !size ) | 299 if ( !size ) |
300 return TT_Err_Invalid_Size_Handle; | 300 return TT_Err_Invalid_Size_Handle; |
301 | 301 |
302 if ( !face ) | 302 if ( !face ) |
303 return TT_Err_Invalid_Argument; | 303 return TT_Err_Invalid_Argument; |
304 | 304 |
305 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 305 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
306 if ( glyph_index >= (FT_UInt)face->num_glyphs && | 306 if ( glyph_index >= (FT_UInt)face->num_glyphs && |
307 !face->internal->incremental_interface ) | 307 !face->internal->incremental_interface ) |
308 #else | 308 #else |
309 if ( glyph_index >= (FT_UInt)face->num_glyphs ) | 309 if ( glyph_index >= (FT_UInt)face->num_glyphs ) |
310 #endif | 310 #endif |
311 return TT_Err_Invalid_Argument; | 311 return TT_Err_Invalid_Argument; |
312 | 312 |
313 if ( load_flags & FT_LOAD_NO_HINTING ) | 313 if ( load_flags & FT_LOAD_NO_HINTING ) |
314 { | 314 { |
315 /* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT */ | 315 /* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT */ |
316 /* are necessary to disable hinting for tricky fonts */ | 316 /* are necessary to disable hinting for tricky fonts */ |
317 | 317 |
318 if ( FT_IS_TRICKY( face ) ) | 318 if ( FT_IS_TRICKY( face ) ) |
319 load_flags &= ~FT_LOAD_NO_HINTING; | 319 load_flags &= ~FT_LOAD_NO_HINTING; |
320 | 320 |
321 if ( load_flags & FT_LOAD_NO_AUTOHINT ) | 321 if ( load_flags & FT_LOAD_NO_AUTOHINT ) |
322 load_flags |= FT_LOAD_NO_HINTING; | 322 load_flags |= FT_LOAD_NO_HINTING; |
323 } | 323 } |
324 | 324 |
325 if ( load_flags & ( FT_LOAD_NO_RECURSE | FT_LOAD_NO_SCALE ) ) | 325 if ( load_flags & ( FT_LOAD_NO_RECURSE | FT_LOAD_NO_SCALE ) ) |
326 { | 326 { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE, | 395 FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE, |
396 FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, | 396 FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, |
397 FT_SERVICE_ID_TT_GLYF, &FT_TT_SERVICE_TRUETYPE_GLYF_GET | 397 FT_SERVICE_ID_TT_GLYF, &FT_TT_SERVICE_TRUETYPE_GLYF_GET |
398 ) | 398 ) |
399 #endif | 399 #endif |
400 | 400 |
401 FT_CALLBACK_DEF( FT_Module_Interface ) | 401 FT_CALLBACK_DEF( FT_Module_Interface ) |
402 tt_get_interface( FT_Module driver, /* TT_Driver */ | 402 tt_get_interface( FT_Module driver, /* TT_Driver */ |
403 const char* tt_interface ) | 403 const char* tt_interface ) |
404 { | 404 { |
| 405 FT_Library library; |
405 FT_Module_Interface result; | 406 FT_Module_Interface result; |
406 FT_Module sfntd; | 407 FT_Module sfntd; |
407 SFNT_Service sfnt; | 408 SFNT_Service sfnt; |
408 | 409 |
| 410 |
| 411 /* FT_TT_SERVICES_GET derefers `library' in PIC mode */ |
| 412 #ifdef FT_CONFIG_OPTION_PIC |
| 413 if ( !driver ) |
| 414 return NULL; |
| 415 library = driver->library; |
| 416 if ( !library ) |
| 417 return NULL; |
| 418 #endif |
| 419 |
409 result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface ); | 420 result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface ); |
410 if ( result != NULL ) | 421 if ( result != NULL ) |
411 return result; | 422 return result; |
412 | 423 |
| 424 #ifndef FT_CONFIG_OPTION_PIC |
413 if ( !driver ) | 425 if ( !driver ) |
414 return NULL; | 426 return NULL; |
| 427 library = driver->library; |
| 428 if ( !library ) |
| 429 return NULL; |
| 430 #endif |
415 | 431 |
416 /* only return the default interface from the SFNT module */ | 432 /* only return the default interface from the SFNT module */ |
417 sfntd = FT_Get_Module( driver->library, "sfnt" ); | 433 sfntd = FT_Get_Module( library, "sfnt" ); |
418 if ( sfntd ) | 434 if ( sfntd ) |
419 { | 435 { |
420 sfnt = (SFNT_Service)( sfntd->clazz->module_interface ); | 436 sfnt = (SFNT_Service)( sfntd->clazz->module_interface ); |
421 if ( sfnt ) | 437 if ( sfnt ) |
422 return sfnt->get_interface( driver, tt_interface ); | 438 return sfnt->get_interface( driver, tt_interface ); |
423 } | 439 } |
424 | 440 |
425 return 0; | 441 return 0; |
426 } | 442 } |
427 | 443 |
428 | 444 |
429 /* The FT_DriverInterface structure is defined in ftdriver.h. */ | 445 /* The FT_DriverInterface structure is defined in ftdriver.h. */ |
430 | 446 |
431 #ifdef TT_USE_BYTECODE_INTERPRETER | 447 #ifdef TT_USE_BYTECODE_INTERPRETER |
432 #define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER | 448 #define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER |
433 #else | 449 #else |
434 #define TT_HINTER_FLAG 0 | 450 #define TT_HINTER_FLAG 0 |
435 #endif | 451 #endif |
436 | 452 |
437 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS | 453 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS |
438 #define TT_SIZE_SELECT tt_size_select | 454 #define TT_SIZE_SELECT tt_size_select |
439 #else | 455 #else |
440 #define TT_SIZE_SELECT 0 | 456 #define TT_SIZE_SELECT 0 |
441 #endif | 457 #endif |
442 | 458 |
443 FT_DEFINE_DRIVER(tt_driver_class, | 459 FT_DEFINE_DRIVER( tt_driver_class, |
444 | 460 |
445 | 461 FT_MODULE_FONT_DRIVER | |
446 FT_MODULE_FONT_DRIVER | | 462 FT_MODULE_DRIVER_SCALABLE | |
447 FT_MODULE_DRIVER_SCALABLE | | |
448 TT_HINTER_FLAG, | 463 TT_HINTER_FLAG, |
449 | 464 |
450 sizeof ( TT_DriverRec ), | 465 sizeof ( TT_DriverRec ), |
451 | 466 |
452 "truetype", /* driver name */ | 467 "truetype", /* driver name */ |
453 0x10000L, /* driver version == 1.0 */ | 468 0x10000L, /* driver version == 1.0 */ |
454 0x20000L, /* driver requires FreeType 2.0 or above */ | 469 0x20000L, /* driver requires FreeType 2.0 or above */ |
455 | 470 |
456 (void*)0, /* driver specific interface */ | 471 (void*)0, /* driver specific interface */ |
457 | 472 |
458 tt_driver_init, | 473 tt_driver_init, |
459 tt_driver_done, | 474 tt_driver_done, |
460 tt_get_interface, | 475 tt_get_interface, |
461 | 476 |
462 sizeof ( TT_FaceRec ), | 477 sizeof ( TT_FaceRec ), |
463 sizeof ( TT_SizeRec ), | 478 sizeof ( TT_SizeRec ), |
464 sizeof ( FT_GlyphSlotRec ), | 479 sizeof ( FT_GlyphSlotRec ), |
465 | 480 |
466 tt_face_init, | 481 tt_face_init, |
467 tt_face_done, | 482 tt_face_done, |
468 tt_size_init, | 483 tt_size_init, |
469 tt_size_done, | 484 tt_size_done, |
470 tt_slot_init, | 485 tt_slot_init, |
471 0, /* FT_Slot_DoneFunc */ | 486 0, /* FT_Slot_DoneFunc */ |
472 | 487 |
473 ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | 488 ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ |
474 ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ | 489 ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ |
475 | 490 |
476 Load_Glyph, | 491 tt_glyph_load, |
477 | 492 |
478 tt_get_kerning, | 493 tt_get_kerning, |
479 0, /* FT_Face_AttachFunc */ | 494 0, /* FT_Face_AttachFunc */ |
480 tt_get_advances, | 495 tt_get_advances, |
481 | 496 |
482 tt_size_request, | 497 tt_size_request, |
483 TT_SIZE_SELECT | 498 TT_SIZE_SELECT |
484 ) | 499 ) |
485 | 500 |
486 | 501 |
487 /* END */ | 502 /* END */ |
OLD | NEW |