OLD | NEW |
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-2013 by */ | 7 /* Copyright 1996-2015 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 10 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "cffdrivr.h" | 29 #include "cffdrivr.h" |
30 #include "cffgload.h" | 30 #include "cffgload.h" |
31 #include "cffload.h" | 31 #include "cffload.h" |
32 #include "cffcmap.h" | 32 #include "cffcmap.h" |
33 #include "cffparse.h" | 33 #include "cffparse.h" |
34 | 34 |
35 #include "cfferrs.h" | 35 #include "cfferrs.h" |
36 #include "cffpic.h" | 36 #include "cffpic.h" |
37 | 37 |
38 #include FT_SERVICE_XFREE86_NAME_H | 38 #include FT_SERVICE_FONT_FORMAT_H |
39 #include FT_SERVICE_GLYPH_DICT_H | 39 #include FT_SERVICE_GLYPH_DICT_H |
40 #include FT_SERVICE_PROPERTIES_H | 40 #include FT_SERVICE_PROPERTIES_H |
41 #include FT_CFF_DRIVER_H | 41 #include FT_CFF_DRIVER_H |
42 | 42 |
43 | 43 |
44 /*************************************************************************/ | 44 /*************************************************************************/ |
45 /* */ | 45 /* */ |
46 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ | 46 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
47 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ | 47 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
48 /* messages during execution. */ | 48 /* messages during execution. */ |
49 /* */ | 49 /* */ |
50 #undef FT_COMPONENT | 50 #undef FT_COMPONENT |
51 #define FT_COMPONENT trace_cffdriver | 51 #define FT_COMPONENT trace_cffdriver |
52 | 52 |
53 | 53 |
54 /*************************************************************************/ | 54 /*************************************************************************/ |
55 /*************************************************************************/ | 55 /*************************************************************************/ |
56 /*************************************************************************/ | 56 /*************************************************************************/ |
57 /**** ****/ | 57 /**** ****/ |
58 /**** ****/ | 58 /**** ****/ |
59 /**** F A C E S ****/ | 59 /**** F A C E S ****/ |
60 /**** ****/ | 60 /**** ****/ |
61 /**** ****/ | 61 /**** ****/ |
62 /*************************************************************************/ | 62 /*************************************************************************/ |
63 /*************************************************************************/ | 63 /*************************************************************************/ |
64 /*************************************************************************/ | 64 /*************************************************************************/ |
65 | 65 |
66 | 66 |
67 #undef PAIR_TAG | |
68 #define PAIR_TAG( left, right ) ( ( (FT_ULong)left << 16 ) | \ | |
69 (FT_ULong)right ) | |
70 | |
71 | |
72 /*************************************************************************/ | 67 /*************************************************************************/ |
73 /* */ | 68 /* */ |
74 /* <Function> */ | 69 /* <Function> */ |
75 /* cff_get_kerning */ | 70 /* cff_get_kerning */ |
76 /* */ | 71 /* */ |
77 /* <Description> */ | 72 /* <Description> */ |
78 /* A driver method used to return the kerning vector between two */ | 73 /* A driver method used to return the kerning vector between two */ |
79 /* glyphs of the same face. */ | 74 /* glyphs of the same face. */ |
80 /* */ | 75 /* */ |
81 /* <Input> */ | 76 /* <Input> */ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 kerning->x = 0; | 109 kerning->x = 0; |
115 kerning->y = 0; | 110 kerning->y = 0; |
116 | 111 |
117 if ( sfnt ) | 112 if ( sfnt ) |
118 kerning->x = sfnt->get_kerning( face, left_glyph, right_glyph ); | 113 kerning->x = sfnt->get_kerning( face, left_glyph, right_glyph ); |
119 | 114 |
120 return FT_Err_Ok; | 115 return FT_Err_Ok; |
121 } | 116 } |
122 | 117 |
123 | 118 |
124 #undef PAIR_TAG | |
125 | |
126 | |
127 /*************************************************************************/ | 119 /*************************************************************************/ |
128 /* */ | 120 /* */ |
129 /* <Function> */ | 121 /* <Function> */ |
130 /* cff_glyph_load */ | 122 /* cff_glyph_load */ |
131 /* */ | 123 /* */ |
132 /* <Description> */ | 124 /* <Description> */ |
133 /* A driver method used to load a glyph within a given glyph slot. */ | 125 /* A driver method used to load a glyph within a given glyph slot. */ |
134 /* */ | 126 /* */ |
135 /* <Input> */ | 127 /* <Input> */ |
136 /* slot :: A handle to the target slot object where the glyph */ | 128 /* slot :: A handle to the target slot object where the glyph */ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 FT_UInt start, | 188 FT_UInt start, |
197 FT_UInt count, | 189 FT_UInt count, |
198 FT_Int32 flags, | 190 FT_Int32 flags, |
199 FT_Fixed* advances ) | 191 FT_Fixed* advances ) |
200 { | 192 { |
201 FT_UInt nn; | 193 FT_UInt nn; |
202 FT_Error error = FT_Err_Ok; | 194 FT_Error error = FT_Err_Ok; |
203 FT_GlyphSlot slot = face->glyph; | 195 FT_GlyphSlot slot = face->glyph; |
204 | 196 |
205 | 197 |
| 198 if ( FT_IS_SFNT( face ) ) |
| 199 { |
| 200 /* OpenType 1.7 mandates that the data from `hmtx' table be used; */ |
| 201 /* it is no longer necessary that those values are identical to */ |
| 202 /* the values in the `CFF' table */ |
| 203 |
| 204 TT_Face ttface = (TT_Face)face; |
| 205 FT_Short dummy; |
| 206 |
| 207 |
| 208 if ( flags & FT_LOAD_VERTICAL_LAYOUT ) |
| 209 { |
| 210 /* check whether we have data from the `vmtx' table at all; */ |
| 211 /* otherwise we extract the info from the CFF glyphstrings */ |
| 212 /* (instead of synthesizing a global value using the `OS/2' */ |
| 213 /* table) */ |
| 214 if ( !ttface->vertical_info ) |
| 215 goto Missing_Table; |
| 216 |
| 217 for ( nn = 0; nn < count; nn++ ) |
| 218 { |
| 219 FT_UShort ah; |
| 220 |
| 221 |
| 222 ( (SFNT_Service)ttface->sfnt )->get_metrics( ttface, |
| 223 1, |
| 224 start + nn, |
| 225 &dummy, |
| 226 &ah ); |
| 227 |
| 228 FT_TRACE5(( " idx %d: advance height %d font units\n", |
| 229 start + nn, ah )); |
| 230 advances[nn] = ah; |
| 231 } |
| 232 } |
| 233 else |
| 234 { |
| 235 /* check whether we have data from the `hmtx' table at all */ |
| 236 if ( !ttface->horizontal.number_Of_HMetrics ) |
| 237 goto Missing_Table; |
| 238 |
| 239 for ( nn = 0; nn < count; nn++ ) |
| 240 { |
| 241 FT_UShort aw; |
| 242 |
| 243 |
| 244 ( (SFNT_Service)ttface->sfnt )->get_metrics( ttface, |
| 245 0, |
| 246 start + nn, |
| 247 &dummy, |
| 248 &aw ); |
| 249 |
| 250 FT_TRACE5(( " idx %d: advance width %d font units\n", |
| 251 start + nn, aw )); |
| 252 advances[nn] = aw; |
| 253 } |
| 254 } |
| 255 |
| 256 return error; |
| 257 } |
| 258 |
| 259 Missing_Table: |
206 flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; | 260 flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; |
207 | 261 |
208 for ( nn = 0; nn < count; nn++ ) | 262 for ( nn = 0; nn < count; nn++ ) |
209 { | 263 { |
210 error = cff_glyph_load( slot, face->size, start + nn, flags ); | 264 error = cff_glyph_load( slot, face->size, start + nn, flags ); |
211 if ( error ) | 265 if ( error ) |
212 break; | 266 break; |
213 | 267 |
214 advances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) | 268 advances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) |
215 ? slot->linearVertAdvance | 269 ? slot->linearVertAdvance |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 dict->notice ); | 399 dict->notice ); |
346 font_info->full_name = cff_index_get_sid_string( cff, | 400 font_info->full_name = cff_index_get_sid_string( cff, |
347 dict->full_name ); | 401 dict->full_name ); |
348 font_info->family_name = cff_index_get_sid_string( cff, | 402 font_info->family_name = cff_index_get_sid_string( cff, |
349 dict->family_name ); | 403 dict->family_name ); |
350 font_info->weight = cff_index_get_sid_string( cff, | 404 font_info->weight = cff_index_get_sid_string( cff, |
351 dict->weight ); | 405 dict->weight ); |
352 font_info->italic_angle = dict->italic_angle; | 406 font_info->italic_angle = dict->italic_angle; |
353 font_info->is_fixed_pitch = dict->is_fixed_pitch; | 407 font_info->is_fixed_pitch = dict->is_fixed_pitch; |
354 font_info->underline_position = (FT_Short)dict->underline_position; | 408 font_info->underline_position = (FT_Short)dict->underline_position; |
355 font_info->underline_thickness = (FT_Short)dict->underline_thickness; | 409 font_info->underline_thickness = (FT_UShort)dict->underline_thickness; |
356 | 410 |
357 cff->font_info = font_info; | 411 cff->font_info = font_info; |
358 } | 412 } |
359 | 413 |
360 if ( cff ) | 414 if ( cff ) |
361 *afont_info = *cff->font_info; | 415 *afont_info = *cff->font_info; |
362 | 416 |
363 Fail: | 417 Fail: |
364 return error; | 418 return error; |
365 } | 419 } |
(...skipping 10 matching lines...) Expand all Loading... |
376 | 430 |
377 | 431 |
378 /* | 432 /* |
379 * POSTSCRIPT NAME SERVICE | 433 * POSTSCRIPT NAME SERVICE |
380 * | 434 * |
381 */ | 435 */ |
382 | 436 |
383 static const char* | 437 static const char* |
384 cff_get_ps_name( CFF_Face face ) | 438 cff_get_ps_name( CFF_Face face ) |
385 { | 439 { |
386 CFF_Font cff = (CFF_Font)face->extra.data; | 440 CFF_Font cff = (CFF_Font)face->extra.data; |
| 441 SFNT_Service sfnt = (SFNT_Service)face->sfnt; |
387 | 442 |
388 | 443 |
| 444 /* following the OpenType specification 1.7, we return the name stored */ |
| 445 /* in the `name' table for a CFF wrapped into an SFNT container */ |
| 446 |
| 447 if ( sfnt ) |
| 448 { |
| 449 FT_Library library = FT_FACE_LIBRARY( face ); |
| 450 FT_Module sfnt_module = FT_Get_Module( library, "sfnt" ); |
| 451 FT_Service_PsFontName service = |
| 452 (FT_Service_PsFontName)ft_module_get_service( |
| 453 sfnt_module, |
| 454 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME ); |
| 455 |
| 456 |
| 457 if ( service && service->get_ps_font_name ) |
| 458 return service->get_ps_font_name( FT_FACE( face ) ); |
| 459 } |
| 460 |
389 return (const char*)cff->font_name; | 461 return (const char*)cff->font_name; |
390 } | 462 } |
391 | 463 |
392 | 464 |
393 FT_DEFINE_SERVICE_PSFONTNAMEREC( | 465 FT_DEFINE_SERVICE_PSFONTNAMEREC( |
394 cff_service_ps_name, | 466 cff_service_ps_name, |
395 (FT_PsName_GetFunc)cff_get_ps_name | 467 (FT_PsName_GetFunc)cff_get_ps_name |
396 ) | 468 ) |
397 | 469 |
398 | 470 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 /**** D R I V E R I N T E R F A C E ****/ | 788 /**** D R I V E R I N T E R F A C E ****/ |
717 /**** ****/ | 789 /**** ****/ |
718 /**** ****/ | 790 /**** ****/ |
719 /*************************************************************************/ | 791 /*************************************************************************/ |
720 /*************************************************************************/ | 792 /*************************************************************************/ |
721 /*************************************************************************/ | 793 /*************************************************************************/ |
722 | 794 |
723 #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES | 795 #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES |
724 FT_DEFINE_SERVICEDESCREC7( | 796 FT_DEFINE_SERVICEDESCREC7( |
725 cff_services, | 797 cff_services, |
726 FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF, | 798 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
727 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, | 799 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, |
728 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, | 800 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, |
729 FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, | 801 FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, |
730 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, | 802 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, |
731 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, | 803 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, |
732 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET | 804 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET |
733 ) | 805 ) |
734 #else | 806 #else |
735 FT_DEFINE_SERVICEDESCREC6( | 807 FT_DEFINE_SERVICEDESCREC6( |
736 cff_services, | 808 cff_services, |
737 FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF, | 809 FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, |
738 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, | 810 FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, |
739 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, | 811 FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, |
740 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, | 812 FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, |
741 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, | 813 FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, |
742 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET | 814 FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET |
743 ) | 815 ) |
744 #endif | 816 #endif |
745 | 817 |
746 | 818 |
747 FT_CALLBACK_DEF( FT_Module_Interface ) | 819 FT_CALLBACK_DEF( FT_Module_Interface ) |
748 cff_get_interface( FT_Module driver, /* CFF_Driver */ | 820 cff_get_interface( FT_Module driver, /* CFF_Driver */ |
749 const char* module_interface ) | 821 const char* module_interface ) |
750 { | 822 { |
751 FT_Library library; | 823 FT_Library library; |
752 FT_Module sfnt; | 824 FT_Module sfnt; |
753 FT_Module_Interface result; | 825 FT_Module_Interface result; |
754 | 826 |
755 | 827 |
756 /* CFF_SERVICES_GET derefers `library' in PIC mode */ | 828 /* CFF_SERVICES_GET dereferences `library' in PIC mode */ |
757 #ifdef FT_CONFIG_OPTION_PIC | 829 #ifdef FT_CONFIG_OPTION_PIC |
758 if ( !driver ) | 830 if ( !driver ) |
759 return NULL; | 831 return NULL; |
760 library = driver->library; | 832 library = driver->library; |
761 if ( !library ) | 833 if ( !library ) |
762 return NULL; | 834 return NULL; |
763 #endif | 835 #endif |
764 | 836 |
765 result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface ); | 837 result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface ); |
766 if ( result != NULL ) | 838 if ( result != NULL ) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 0, /* FT_Face_AttachFunc */ | 898 0, /* FT_Face_AttachFunc */ |
827 cff_get_advances, | 899 cff_get_advances, |
828 | 900 |
829 cff_size_request, | 901 cff_size_request, |
830 | 902 |
831 CFF_SIZE_SELECT | 903 CFF_SIZE_SELECT |
832 ) | 904 ) |
833 | 905 |
834 | 906 |
835 /* END */ | 907 /* END */ |
OLD | NEW |