Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: src/cff/cffdrivr.c

Issue 23555005: Update freetype to the latest version of Android external/freetype (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/fttype1.c ('k') | src/cff/cfferrs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /***************************************************************************/ 1 /***************************************************************************/
2 /* */ 2 /* */
3 /* cffdrivr.c */ 3 /* cffdrivr.c */
4 /* */ 4 /* */
5 /* OpenType font driver implementation (body). */ 5 /* OpenType font driver implementation (body). */
6 /* */ 6 /* */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */ 7 /* Copyright 1996-2012 by */
8 /* 2010 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* */ 9 /* */
11 /* 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, */
12 /* modified, and distributed under the terms of the FreeType project */ 11 /* modified, and distributed under the terms of the FreeType project */
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 /* this file you indicate that you have read the license and */ 13 /* this file you indicate that you have read the license and */
15 /* understand and accept it fully. */ 14 /* understand and accept it fully. */
16 /* */ 15 /* */
17 /***************************************************************************/ 16 /***************************************************************************/
18 17
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 return CFF_Err_Ok; 118 return CFF_Err_Ok;
120 } 119 }
121 120
122 121
123 #undef PAIR_TAG 122 #undef PAIR_TAG
124 123
125 124
126 /*************************************************************************/ 125 /*************************************************************************/
127 /* */ 126 /* */
128 /* <Function> */ 127 /* <Function> */
129 /* Load_Glyph */ 128 /* cff_glyph_load */
130 /* */ 129 /* */
131 /* <Description> */ 130 /* <Description> */
132 /* A driver method used to load a glyph within a given glyph slot. */ 131 /* A driver method used to load a glyph within a given glyph slot. */
133 /* */ 132 /* */
134 /* <Input> */ 133 /* <Input> */
135 /* slot :: A handle to the target slot object where the glyph */ 134 /* slot :: A handle to the target slot object where the glyph */
136 /* will be loaded. */ 135 /* will be loaded. */
137 /* */ 136 /* */
138 /* size :: A handle to the source face size at which the glyph */ 137 /* size :: A handle to the source face size at which the glyph */
139 /* must be scaled, loaded, etc. */ 138 /* must be scaled, loaded, etc. */
140 /* */ 139 /* */
141 /* glyph_index :: The index of the glyph in the font file. */ 140 /* glyph_index :: The index of the glyph in the font file. */
142 /* */ 141 /* */
143 /* load_flags :: A flag indicating what to load for this glyph. The */ 142 /* load_flags :: A flag indicating what to load for this glyph. The */
144 /* FT_LOAD_??? constants can be used to control the */ 143 /* FT_LOAD_??? constants can be used to control the */
145 /* glyph loading process (e.g., whether the outline */ 144 /* glyph loading process (e.g., whether the outline */
146 /* should be scaled, whether to load bitmaps or not, */ 145 /* should be scaled, whether to load bitmaps or not, */
147 /* whether to hint the outline, etc). */ 146 /* whether to hint the outline, etc). */
148 /* */ 147 /* */
149 /* <Return> */ 148 /* <Return> */
150 /* FreeType error code. 0 means success. */ 149 /* FreeType error code. 0 means success. */
151 /* */ 150 /* */
152 FT_CALLBACK_DEF( FT_Error ) 151 FT_CALLBACK_DEF( FT_Error )
153 Load_Glyph( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ 152 cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */
154 FT_Size cffsize, /* CFF_Size */ 153 FT_Size cffsize, /* CFF_Size */
155 FT_UInt glyph_index, 154 FT_UInt glyph_index,
156 FT_Int32 load_flags ) 155 FT_Int32 load_flags )
157 { 156 {
158 FT_Error error; 157 FT_Error error;
159 CFF_GlyphSlot slot = (CFF_GlyphSlot)cffslot; 158 CFF_GlyphSlot slot = (CFF_GlyphSlot)cffslot;
160 CFF_Size size = (CFF_Size)cffsize; 159 CFF_Size size = (CFF_Size)cffsize;
161 160
162 161
163 if ( !slot ) 162 if ( !slot )
164 return CFF_Err_Invalid_Slot_Handle; 163 return CFF_Err_Invalid_Slot_Handle;
165 164
166 /* check whether we want a scaled outline or bitmap */ 165 /* check whether we want a scaled outline or bitmap */
(...skipping 30 matching lines...) Expand all
197 { 196 {
198 FT_UInt nn; 197 FT_UInt nn;
199 FT_Error error = CFF_Err_Ok; 198 FT_Error error = CFF_Err_Ok;
200 FT_GlyphSlot slot = face->glyph; 199 FT_GlyphSlot slot = face->glyph;
201 200
202 201
203 flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; 202 flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
204 203
205 for ( nn = 0; nn < count; nn++ ) 204 for ( nn = 0; nn < count; nn++ )
206 { 205 {
207 error = Load_Glyph( slot, face->size, start + nn, flags ); 206 error = cff_glyph_load( slot, face->size, start + nn, flags );
208 if ( error ) 207 if ( error )
209 break; 208 break;
210 209
211 advances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) 210 advances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
212 ? slot->linearVertAdvance 211 ? slot->linearVertAdvance
213 : slot->linearHoriAdvance; 212 : slot->linearHoriAdvance;
214 } 213 }
215 214
216 return error; 215 return error;
217 } 216 }
(...skipping 15 matching lines...) Expand all
233 FT_UShort sid; 232 FT_UShort sid;
234 FT_Error error; 233 FT_Error error;
235 234
236 235
237 if ( !font->psnames ) 236 if ( !font->psnames )
238 { 237 {
239 FT_ERROR(( "cff_get_glyph_name:" 238 FT_ERROR(( "cff_get_glyph_name:"
240 " cannot get glyph name from CFF & CEF fonts\n" 239 " cannot get glyph name from CFF & CEF fonts\n"
241 " " 240 " "
242 " without the `PSNames' module\n" )); 241 " without the `PSNames' module\n" ));
243 error = CFF_Err_Unknown_File_Format; 242 error = CFF_Err_Missing_Module;
244 goto Exit; 243 goto Exit;
245 } 244 }
246 245
247 /* first, locate the sid in the charset table */ 246 /* first, locate the sid in the charset table */
248 sid = font->charset.sids[glyph_index]; 247 sid = font->charset.sids[glyph_index];
249 248
250 /* now, lookup the name itself */ 249 /* now, lookup the name itself */
251 gname = cff_index_get_sid_string( font, sid ); 250 gname = cff_index_get_sid_string( font, sid );
252 251
253 if ( gname ) 252 if ( gname )
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 357
359 Fail: 358 Fail:
360 return error; 359 return error;
361 } 360 }
362 361
363 362
364 FT_DEFINE_SERVICE_PSINFOREC(cff_service_ps_info, 363 FT_DEFINE_SERVICE_PSINFOREC(cff_service_ps_info,
365 (PS_GetFontInfoFunc) cff_ps_get_font_info, 364 (PS_GetFontInfoFunc) cff_ps_get_font_info,
366 (PS_GetFontExtraFunc) NULL, 365 (PS_GetFontExtraFunc) NULL,
367 (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, 366 (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
368 (PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */ 367 (PS_GetFontPrivateFunc)NULL, /* unsupported with CFF fonts */
368 (PS_GetFontValueFunc) NULL /* not implemented */
369 ) 369 )
370 370
371 371
372 /* 372 /*
373 * POSTSCRIPT NAME SERVICE 373 * POSTSCRIPT NAME SERVICE
374 * 374 *
375 */ 375 */
376 376
377 static const char* 377 static const char*
378 cff_get_ps_name( CFF_Face face ) 378 cff_get_ps_name( CFF_Face face )
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 goto Fail; 459 goto Fail;
460 } 460 }
461 461
462 if ( registry ) 462 if ( registry )
463 { 463 {
464 if ( cff->registry == NULL ) 464 if ( cff->registry == NULL )
465 cff->registry = cff_index_get_sid_string( cff, 465 cff->registry = cff_index_get_sid_string( cff,
466 dict->cid_registry ); 466 dict->cid_registry );
467 *registry = cff->registry; 467 *registry = cff->registry;
468 } 468 }
469 469
470 if ( ordering ) 470 if ( ordering )
471 { 471 {
472 if ( cff->ordering == NULL ) 472 if ( cff->ordering == NULL )
473 cff->ordering = cff_index_get_sid_string( cff, 473 cff->ordering = cff_index_get_sid_string( cff,
474 dict->cid_ordering ); 474 dict->cid_ordering );
475 *ordering = cff->ordering; 475 *ordering = cff->ordering;
476 } 476 }
477 477
478 /* 478 /*
479 * XXX: According to Adobe TechNote #5176, the supplement in CFF 479 * XXX: According to Adobe TechNote #5176, the supplement in CFF
480 * can be a real number. We truncate it to fit public API 480 * can be a real number. We truncate it to fit public API
481 * since freetype-2.3.6. 481 * since freetype-2.3.6.
482 */ 482 */
483 if ( supplement ) 483 if ( supplement )
484 { 484 {
485 if ( dict->cid_supplement < FT_INT_MIN || 485 if ( dict->cid_supplement < FT_INT_MIN ||
486 dict->cid_supplement > FT_INT_MAX ) 486 dict->cid_supplement > FT_INT_MAX )
487 FT_TRACE1(( "cff_get_ros: too large supplement %d is truncated\n", 487 FT_TRACE1(( "cff_get_ros: too large supplement %d is truncated\n",
488 dict->cid_supplement )); 488 dict->cid_supplement ));
489 *supplement = (FT_Int)dict->cid_supplement; 489 *supplement = (FT_Int)dict->cid_supplement;
490 } 490 }
491 } 491 }
492 492
493 Fail: 493 Fail:
494 return error; 494 return error;
495 } 495 }
496 496
497 497
498 static FT_Error 498 static FT_Error
499 cff_get_is_cid( CFF_Face face, 499 cff_get_is_cid( CFF_Face face,
500 FT_Bool *is_cid ) 500 FT_Bool *is_cid )
501 { 501 {
502 FT_Error error = CFF_Err_Ok; 502 FT_Error error = CFF_Err_Ok;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET, 592 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
593 FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET, 593 FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
594 FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET 594 FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET
595 ) 595 )
596 #endif 596 #endif
597 597
598 FT_CALLBACK_DEF( FT_Module_Interface ) 598 FT_CALLBACK_DEF( FT_Module_Interface )
599 cff_get_interface( FT_Module driver, /* CFF_Driver */ 599 cff_get_interface( FT_Module driver, /* CFF_Driver */
600 const char* module_interface ) 600 const char* module_interface )
601 { 601 {
602 FT_Library library;
602 FT_Module sfnt; 603 FT_Module sfnt;
603 FT_Module_Interface result; 604 FT_Module_Interface result;
604 605
605 606
607 /* FT_CFF_SERVICES_GET derefers `library' in PIC mode */
608 #ifdef FT_CONFIG_OPTION_PIC
609 if ( !driver )
610 return NULL;
611 library = driver->library;
612 if ( !library )
613 return NULL;
614 #endif
615
606 result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface ); 616 result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
607 if ( result != NULL ) 617 if ( result != NULL )
608 return result; 618 return result;
609 619
620 /* `driver' is not yet evaluated in non-PIC mode */
621 #ifndef FT_CONFIG_OPTION_PIC
610 if ( !driver ) 622 if ( !driver )
611 return NULL; 623 return NULL;
624 library = driver->library;
625 if ( !library )
626 return NULL;
627 #endif
612 628
613 /* we pass our request to the `sfnt' module */ 629 /* we pass our request to the `sfnt' module */
614 sfnt = FT_Get_Module( driver->library, "sfnt" ); 630 sfnt = FT_Get_Module( library, "sfnt" );
615 631
616 return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0; 632 return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
617 } 633 }
618 634
619 635
620 /* The FT_DriverInterface structure is defined in ftdriver.h. */ 636 /* The FT_DriverInterface structure is defined in ftdriver.h. */
621 637
622 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS 638 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
623 #define CFF_SIZE_SELECT cff_size_select 639 #define CFF_SIZE_SELECT cff_size_select
624 #else 640 #else
625 #define CFF_SIZE_SELECT 0 641 #define CFF_SIZE_SELECT 0
626 #endif 642 #endif
627 643
628 FT_DEFINE_DRIVER(cff_driver_class, 644 FT_DEFINE_DRIVER( cff_driver_class,
645
629 FT_MODULE_FONT_DRIVER | 646 FT_MODULE_FONT_DRIVER |
630 FT_MODULE_DRIVER_SCALABLE | 647 FT_MODULE_DRIVER_SCALABLE |
631 FT_MODULE_DRIVER_HAS_HINTER, 648 FT_MODULE_DRIVER_HAS_HINTER,
632 649
633 sizeof( CFF_DriverRec ), 650 sizeof ( CFF_DriverRec ),
634 "cff", 651 "cff",
635 0x10000L, 652 0x10000L,
636 0x20000L, 653 0x20000L,
637 654
638 0, /* module-specific interface */ 655 0, /* module-specific interface */
639 656
640 cff_driver_init, 657 cff_driver_init,
641 cff_driver_done, 658 cff_driver_done,
642 cff_get_interface, 659 cff_get_interface,
643 660
644 /* now the specific driver fields */ 661 /* now the specific driver fields */
645 sizeof( TT_FaceRec ), 662 sizeof ( TT_FaceRec ),
646 sizeof( CFF_SizeRec ), 663 sizeof ( CFF_SizeRec ),
647 sizeof( CFF_GlyphSlotRec ), 664 sizeof ( CFF_GlyphSlotRec ),
648 665
649 cff_face_init, 666 cff_face_init,
650 cff_face_done, 667 cff_face_done,
651 cff_size_init, 668 cff_size_init,
652 cff_size_done, 669 cff_size_done,
653 cff_slot_init, 670 cff_slot_init,
654 cff_slot_done, 671 cff_slot_done,
655 672
656 ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ 673 ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
657 ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ 674 ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
658 675
659 Load_Glyph, 676 cff_glyph_load,
660 677
661 cff_get_kerning, 678 cff_get_kerning,
662 0, /* FT_Face_AttachFunc */ 679 0, /* FT_Face_AttachFunc */
663 cff_get_advances, /* FT_Face_GetAdvancesFunc */ 680 cff_get_advances,
664 681
665 cff_size_request, 682 cff_size_request,
666 683
667 CFF_SIZE_SELECT 684 CFF_SIZE_SELECT
668 ) 685 )
669 686
670 687
671 /* END */ 688 /* END */
OLDNEW
« no previous file with comments | « src/base/fttype1.c ('k') | src/cff/cfferrs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698