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

Side by Side Diff: third_party/freetype/src/type1/t1driver.c

Issue 1413673003: Update bundled freetype to 2.6.1 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: DEPS for corpus Created 5 years, 1 month 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 | « third_party/freetype/src/type1/t1driver.h ('k') | third_party/freetype/src/type1/t1errors.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 /* t1driver.c */ 3 /* t1driver.c */
4 /* */ 4 /* */
5 /* Type 1 driver interface (body). */ 5 /* Type 1 driver interface (body). */
6 /* */ 6 /* */
7 /* Copyright 1996-2004, 2006, 2007, 2009, 2011, 2013, 2014 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
18 18
19 #include <ft2build.h> 19 #include <ft2build.h>
20 #include "t1driver.h" 20 #include "t1driver.h"
21 #include "t1gload.h" 21 #include "t1gload.h"
22 #include "t1load.h" 22 #include "t1load.h"
23 23
24 #include "t1errors.h" 24 #include "t1errors.h"
25 25
26 #ifndef T1_CONFIG_OPTION_NO_AFM 26 #ifndef T1_CONFIG_OPTION_NO_AFM
27 #include "t1afm.h" 27 #include "t1afm.h"
28 #endif 28 #endif
29 29
30 #include FT_INTERNAL_DEBUG_H 30 #include FT_INTERNAL_DEBUG_H
31 #include FT_INTERNAL_STREAM_H 31 #include FT_INTERNAL_STREAM_H
32 32
33 #include FT_SERVICE_MULTIPLE_MASTERS_H 33 #include FT_SERVICE_MULTIPLE_MASTERS_H
34 #include FT_SERVICE_GLYPH_DICT_H 34 #include FT_SERVICE_GLYPH_DICT_H
35 #include FT_SERVICE_XFREE86_NAME_H 35 #include FT_SERVICE_FONT_FORMAT_H
36 #include FT_SERVICE_POSTSCRIPT_NAME_H 36 #include FT_SERVICE_POSTSCRIPT_NAME_H
37 #include FT_SERVICE_POSTSCRIPT_CMAPS_H 37 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
38 #include FT_SERVICE_POSTSCRIPT_INFO_H 38 #include FT_SERVICE_POSTSCRIPT_INFO_H
39 #include FT_SERVICE_KERNING_H 39 #include FT_SERVICE_KERNING_H
40 40
41 41
42 /*************************************************************************/ 42 /*************************************************************************/
43 /* */ 43 /* */
44 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ 44 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
45 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ 45 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 return FT_Err_Ok; 170 return FT_Err_Ok;
171 } 171 }
172 172
173 173
174 static FT_Long 174 static FT_Long
175 t1_ps_get_font_value( FT_Face face, 175 t1_ps_get_font_value( FT_Face face,
176 PS_Dict_Keys key, 176 PS_Dict_Keys key,
177 FT_UInt idx, 177 FT_UInt idx,
178 void *value, 178 void *value,
179 FT_Long value_len ) 179 FT_Long value_len_ )
180 { 180 {
181 FT_Long retval = -1; 181 FT_ULong retval = 0; /* always >= 1 if valid */
182 FT_ULong value_len = value_len_ < 0 ? 0 : (FT_ULong)value_len_;
183
182 T1_Face t1face = (T1_Face)face; 184 T1_Face t1face = (T1_Face)face;
183 T1_Font type1 = &t1face->type1; 185 T1_Font type1 = &t1face->type1;
184 186
185 187
186 switch ( key ) 188 switch ( key )
187 { 189 {
188 case PS_DICT_FONT_TYPE: 190 case PS_DICT_FONT_TYPE:
189 retval = sizeof ( type1->font_type ); 191 retval = sizeof ( type1->font_type );
190 if ( value && value_len >= retval ) 192 if ( value && value_len >= retval )
191 *((FT_Byte *)value) = type1->font_type; 193 *((FT_Byte *)value) = type1->font_type;
(...skipping 26 matching lines...) Expand all
218 } 220 }
219 *((FT_Fixed *)value) = val; 221 *((FT_Fixed *)value) = val;
220 } 222 }
221 } 223 }
222 break; 224 break;
223 225
224 case PS_DICT_FONT_BBOX: 226 case PS_DICT_FONT_BBOX:
225 if ( idx < sizeof ( type1->font_bbox ) / 227 if ( idx < sizeof ( type1->font_bbox ) /
226 sizeof ( type1->font_bbox.xMin ) ) 228 sizeof ( type1->font_bbox.xMin ) )
227 { 229 {
228 FT_Fixed val = 0; 230 FT_Fixed val = 0;
229 231
230 232
231 retval = sizeof ( val ); 233 retval = sizeof ( val );
232 if ( value && value_len >= retval ) 234 if ( value && value_len >= retval )
233 { 235 {
234 switch ( idx ) 236 switch ( idx )
235 { 237 {
236 case 0: 238 case 0:
237 val = type1->font_bbox.xMin; 239 val = type1->font_bbox.xMin;
238 break; 240 break;
(...skipping 12 matching lines...) Expand all
251 } 253 }
252 break; 254 break;
253 255
254 case PS_DICT_PAINT_TYPE: 256 case PS_DICT_PAINT_TYPE:
255 retval = sizeof ( type1->paint_type ); 257 retval = sizeof ( type1->paint_type );
256 if ( value && value_len >= retval ) 258 if ( value && value_len >= retval )
257 *((FT_Byte *)value) = type1->paint_type; 259 *((FT_Byte *)value) = type1->paint_type;
258 break; 260 break;
259 261
260 case PS_DICT_FONT_NAME: 262 case PS_DICT_FONT_NAME:
261 retval = (FT_Long)( ft_strlen( type1->font_name ) + 1 ); 263 retval = ft_strlen( type1->font_name ) + 1;
262 if ( value && value_len >= retval ) 264 if ( value && value_len >= retval )
263 ft_memcpy( value, (void *)( type1->font_name ), retval ); 265 ft_memcpy( value, (void *)( type1->font_name ), retval );
264 break; 266 break;
265 267
266 case PS_DICT_UNIQUE_ID: 268 case PS_DICT_UNIQUE_ID:
267 retval = sizeof ( type1->private_dict.unique_id ); 269 retval = sizeof ( type1->private_dict.unique_id );
268 if ( value && value_len >= retval ) 270 if ( value && value_len >= retval )
269 *((FT_Int *)value) = type1->private_dict.unique_id; 271 *((FT_Int *)value) = type1->private_dict.unique_id;
270 break; 272 break;
271 273
272 case PS_DICT_NUM_CHAR_STRINGS: 274 case PS_DICT_NUM_CHAR_STRINGS:
273 retval = sizeof ( type1->num_glyphs ); 275 retval = sizeof ( type1->num_glyphs );
274 if ( value && value_len >= retval ) 276 if ( value && value_len >= retval )
275 *((FT_Int *)value) = type1->num_glyphs; 277 *((FT_Int *)value) = type1->num_glyphs;
276 break; 278 break;
277 279
278 case PS_DICT_CHAR_STRING_KEY: 280 case PS_DICT_CHAR_STRING_KEY:
279 if ( idx < (FT_UInt)type1->num_glyphs ) 281 if ( idx < (FT_UInt)type1->num_glyphs )
280 { 282 {
281 retval = (FT_Long)( ft_strlen( type1->glyph_names[idx] ) + 1 ); 283 retval = ft_strlen( type1->glyph_names[idx] ) + 1;
282 if ( value && value_len >= retval ) 284 if ( value && value_len >= retval )
283 { 285 {
284 ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval ); 286 ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval );
285 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0'; 287 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
286 } 288 }
287 } 289 }
288 break; 290 break;
289 291
290 case PS_DICT_CHAR_STRING: 292 case PS_DICT_CHAR_STRING:
291 if ( idx < (FT_UInt)type1->num_glyphs ) 293 if ( idx < (FT_UInt)type1->num_glyphs )
292 { 294 {
293 retval = (FT_Long)( type1->charstrings_len[idx] + 1 ); 295 retval = type1->charstrings_len[idx] + 1;
294 if ( value && value_len >= retval ) 296 if ( value && value_len >= retval )
295 { 297 {
296 ft_memcpy( value, (void *)( type1->charstrings[idx] ), 298 ft_memcpy( value, (void *)( type1->charstrings[idx] ),
297 retval - 1 ); 299 retval - 1 );
298 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0'; 300 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
299 } 301 }
300 } 302 }
301 break; 303 break;
302 304
303 case PS_DICT_ENCODING_TYPE: 305 case PS_DICT_ENCODING_TYPE:
304 retval = sizeof ( type1->encoding_type ); 306 retval = sizeof ( type1->encoding_type );
305 if ( value && value_len >= retval ) 307 if ( value && value_len >= retval )
306 *((T1_EncodingType *)value) = type1->encoding_type; 308 *((T1_EncodingType *)value) = type1->encoding_type;
307 break; 309 break;
308 310
309 case PS_DICT_ENCODING_ENTRY: 311 case PS_DICT_ENCODING_ENTRY:
310 if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY && 312 if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY &&
311 idx < (FT_UInt)type1->encoding.num_chars ) 313 idx < (FT_UInt)type1->encoding.num_chars )
312 { 314 {
313 retval = (FT_Long)( ft_strlen( type1->encoding.char_name[idx] ) + 1 ); 315 retval = ft_strlen( type1->encoding.char_name[idx] ) + 1;
314 if ( value && value_len >= retval ) 316 if ( value && value_len >= retval )
315 { 317 {
316 ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ), 318 ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ),
317 retval - 1 ); 319 retval - 1 );
318 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0'; 320 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
319 } 321 }
320 } 322 }
321 break; 323 break;
322 324
323 case PS_DICT_NUM_SUBRS: 325 case PS_DICT_NUM_SUBRS:
324 retval = sizeof ( type1->num_subrs ); 326 retval = sizeof ( type1->num_subrs );
325 if ( value && value_len >= retval ) 327 if ( value && value_len >= retval )
326 *((FT_Int *)value) = type1->num_subrs; 328 *((FT_Int *)value) = type1->num_subrs;
327 break; 329 break;
328 330
329 case PS_DICT_SUBR: 331 case PS_DICT_SUBR:
330 if ( idx < (FT_UInt)type1->num_subrs ) 332 if ( idx < (FT_UInt)type1->num_subrs )
331 { 333 {
332 retval = (FT_Long)( type1->subrs_len[idx] + 1 ); 334 retval = type1->subrs_len[idx] + 1;
333 if ( value && value_len >= retval ) 335 if ( value && value_len >= retval )
334 { 336 {
335 ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 ); 337 ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 );
336 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0'; 338 ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
337 } 339 }
338 } 340 }
339 break; 341 break;
340 342
341 case PS_DICT_STD_HW: 343 case PS_DICT_STD_HW:
342 retval = sizeof ( type1->private_dict.standard_width[0] ); 344 retval = sizeof ( type1->private_dict.standard_width[0] );
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 *((FT_UShort *)value) = type1->font_info.underline_thickness; 518 *((FT_UShort *)value) = type1->font_info.underline_thickness;
517 break; 519 break;
518 520
519 case PS_DICT_FS_TYPE: 521 case PS_DICT_FS_TYPE:
520 retval = sizeof ( type1->font_extra.fs_type ); 522 retval = sizeof ( type1->font_extra.fs_type );
521 if ( value && value_len >= retval ) 523 if ( value && value_len >= retval )
522 *((FT_UShort *)value) = type1->font_extra.fs_type; 524 *((FT_UShort *)value) = type1->font_extra.fs_type;
523 break; 525 break;
524 526
525 case PS_DICT_VERSION: 527 case PS_DICT_VERSION:
526 retval = (FT_Long)( ft_strlen( type1->font_info.version ) + 1 ); 528 retval = ft_strlen( type1->font_info.version ) + 1;
527 if ( value && value_len >= retval ) 529 if ( value && value_len >= retval )
528 ft_memcpy( value, (void *)( type1->font_info.version ), retval ); 530 ft_memcpy( value, (void *)( type1->font_info.version ), retval );
529 break; 531 break;
530 532
531 case PS_DICT_NOTICE: 533 case PS_DICT_NOTICE:
532 retval = (FT_Long)( ft_strlen( type1->font_info.notice ) + 1 ); 534 retval = ft_strlen( type1->font_info.notice ) + 1;
533 if ( value && value_len >= retval ) 535 if ( value && value_len >= retval )
534 ft_memcpy( value, (void *)( type1->font_info.notice ), retval ); 536 ft_memcpy( value, (void *)( type1->font_info.notice ), retval );
535 break; 537 break;
536 538
537 case PS_DICT_FULL_NAME: 539 case PS_DICT_FULL_NAME:
538 retval = (FT_Long)( ft_strlen( type1->font_info.full_name ) + 1 ); 540 retval = ft_strlen( type1->font_info.full_name ) + 1;
539 if ( value && value_len >= retval ) 541 if ( value && value_len >= retval )
540 ft_memcpy( value, (void *)( type1->font_info.full_name ), retval ); 542 ft_memcpy( value, (void *)( type1->font_info.full_name ), retval );
541 break; 543 break;
542 544
543 case PS_DICT_FAMILY_NAME: 545 case PS_DICT_FAMILY_NAME:
544 retval = (FT_Long)( ft_strlen( type1->font_info.family_name ) + 1 ); 546 retval = ft_strlen( type1->font_info.family_name ) + 1;
545 if ( value && value_len >= retval ) 547 if ( value && value_len >= retval )
546 ft_memcpy( value, (void *)( type1->font_info.family_name ), retval ); 548 ft_memcpy( value, (void *)( type1->font_info.family_name ), retval );
547 break; 549 break;
548 550
549 case PS_DICT_WEIGHT: 551 case PS_DICT_WEIGHT:
550 retval = (FT_Long)( ft_strlen( type1->font_info.weight ) + 1 ); 552 retval = ft_strlen( type1->font_info.weight ) + 1;
551 if ( value && value_len >= retval ) 553 if ( value && value_len >= retval )
552 ft_memcpy( value, (void *)( type1->font_info.weight ), retval ); 554 ft_memcpy( value, (void *)( type1->font_info.weight ), retval );
553 break; 555 break;
554 556
555 case PS_DICT_ITALIC_ANGLE: 557 case PS_DICT_ITALIC_ANGLE:
556 retval = sizeof ( type1->font_info.italic_angle ); 558 retval = sizeof ( type1->font_info.italic_angle );
557 if ( value && value_len >= retval ) 559 if ( value && value_len >= retval )
558 *((FT_Long *)value) = type1->font_info.italic_angle; 560 *((FT_Long *)value) = type1->font_info.italic_angle;
559 break; 561 break;
560 } 562 }
561 563
562 return retval; 564 return retval == 0 ? -1 : (FT_Long)retval;
563 } 565 }
564 566
565 567
566 static const FT_Service_PsInfoRec t1_service_ps_info = 568 static const FT_Service_PsInfoRec t1_service_ps_info =
567 { 569 {
568 (PS_GetFontInfoFunc) t1_ps_get_font_info, 570 (PS_GetFontInfoFunc) t1_ps_get_font_info,
569 (PS_GetFontExtraFunc) t1_ps_get_font_extra, 571 (PS_GetFontExtraFunc) t1_ps_get_font_extra,
570 (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names, 572 (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names,
571 (PS_GetFontPrivateFunc)t1_ps_get_font_private, 573 (PS_GetFontPrivateFunc)t1_ps_get_font_private,
572 (PS_GetFontValueFunc) t1_ps_get_font_value, 574 (PS_GetFontValueFunc) t1_ps_get_font_value,
(...skipping 10 matching lines...) Expand all
583 585
584 /* 586 /*
585 * SERVICE LIST 587 * SERVICE LIST
586 * 588 *
587 */ 589 */
588 590
589 static const FT_ServiceDescRec t1_services[] = 591 static const FT_ServiceDescRec t1_services[] =
590 { 592 {
591 { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name }, 593 { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name },
592 { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict }, 594 { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict },
593 { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_1 }, 595 { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_1 },
594 { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info }, 596 { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info },
595 597
596 #ifndef T1_CONFIG_OPTION_NO_AFM 598 #ifndef T1_CONFIG_OPTION_NO_AFM
597 { FT_SERVICE_ID_KERNING, &t1_service_kerning }, 599 { FT_SERVICE_ID_KERNING, &t1_service_kerning },
598 #endif 600 #endif
599 601
600 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT 602 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
601 { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters }, 603 { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters },
602 #endif 604 #endif
603 { NULL, NULL } 605 { NULL, NULL }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 Get_Kerning, 716 Get_Kerning,
715 T1_Read_Metrics, 717 T1_Read_Metrics,
716 #endif 718 #endif
717 T1_Get_Advances, 719 T1_Get_Advances,
718 T1_Size_Request, 720 T1_Size_Request,
719 0 /* FT_Size_SelectFunc */ 721 0 /* FT_Size_SelectFunc */
720 }; 722 };
721 723
722 724
723 /* END */ 725 /* END */
OLDNEW
« no previous file with comments | « third_party/freetype/src/type1/t1driver.h ('k') | third_party/freetype/src/type1/t1errors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698