ReactOS 0.4.16-dev-2332-g4cba65d
ttload.h File Reference
Include dependency graph for ttload.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FT_BEGIN_HEADER tt_face_lookup_table (TT_Face face, FT_ULong tag)
 
 tt_face_goto_table (TT_Face face, FT_ULong tag, FT_Stream stream, FT_ULong *length)
 
 tt_face_load_font_dir (TT_Face face, FT_Stream stream)
 
 tt_face_load_any (TT_Face face, FT_ULong tag, FT_Long offset, FT_Byte *buffer, FT_ULong *length)
 
 tt_face_load_head (TT_Face face, FT_Stream stream)
 
 tt_face_load_cmap (TT_Face face, FT_Stream stream)
 
 tt_face_load_maxp (TT_Face face, FT_Stream stream)
 
 tt_face_load_name (TT_Face face, FT_Stream stream)
 
 tt_face_load_os2 (TT_Face face, FT_Stream stream)
 
 tt_face_load_post (TT_Face face, FT_Stream stream)
 
 tt_face_load_pclt (TT_Face face, FT_Stream stream)
 
 tt_face_free_name (TT_Face face)
 
 tt_face_load_gasp (TT_Face face, FT_Stream stream)
 

Function Documentation

◆ tt_face_free_name()

tt_face_free_name ( TT_Face  face)

Definition at line 1024 of file ttload.c.

1025 {
1026 FT_Memory memory = face->root.driver->root.memory;
1027 TT_NameTable table = &face->name_table;
1028
1029
1030 if ( table->names )
1031 {
1032 TT_Name entry = table->names;
1033 TT_Name limit = entry + table->numNameRecords;
1034
1035
1036 for ( ; entry < limit; entry++ )
1037 FT_FREE( entry->string );
1038
1039 FT_FREE( table->names );
1040 }
1041
1042 if ( table->langTags )
1043 {
1044 TT_LangTag entry = table->langTags;
1045 TT_LangTag limit = entry + table->numLangTagRecords;
1046
1047
1048 for ( ; entry < limit; entry++ )
1049 FT_FREE( entry->string );
1050
1051 FT_FREE( table->langTags );
1052 }
1053
1054 table->numNameRecords = 0;
1055 table->numLangTagRecords = 0;
1056 table->format = 0;
1057 table->storageOffset = 0;
1058 }
#define FT_FREE(ptr)
Definition: ftmemory.h:337
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLint limit
Definition: glext.h:10326
uint32_t entry
Definition: isohybrid.c:63
static char memory[1024 *256]
Definition: process.c:122

◆ tt_face_goto_table()

tt_face_goto_table ( TT_Face  face,
FT_ULong  tag,
FT_Stream  stream,
FT_ULong length 
)

Definition at line 131 of file ttload.c.

135 {
138
139
141 if ( table )
142 {
143 if ( length )
144 *length = table->Length;
145
146 if ( FT_STREAM_SEEK( table->Offset ) )
147 goto Exit;
148 }
149 else
150 error = FT_THROW( Table_Missing );
151
152 Exit:
153 return error;
154 }
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:525
int FT_Error
Definition: fttypes.h:299
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define error(str)
Definition: mkdosfs.c:1605
static void Exit(void)
Definition: sock.c:1330
Definition: ecma_167.h:138
tt_face_lookup_table(TT_Face face, FT_ULong tag)
Definition: ttload.c:57

◆ tt_face_load_any()

tt_face_load_any ( TT_Face  face,
FT_ULong  tag,
FT_Long  offset,
FT_Byte buffer,
FT_ULong length 
)

Definition at line 561 of file ttload.c.

566 {
571
572
573 if ( tag != 0 )
574 {
575 /* look for tag in font directory */
577 if ( !table )
578 {
579 error = FT_THROW( Table_Missing );
580 goto Exit;
581 }
582
583 offset += table->Offset;
584 size = table->Length;
585 }
586 else
587 /* tag == 0 -- the user wants to access the font file directly */
588 size = face->root.stream->size;
589
590 if ( length && *length == 0 )
591 {
592 *length = size;
593
594 return FT_Err_Ok;
595 }
596
597 if ( length )
598 size = *length;
599
600 stream = face->root.stream;
601 /* the `if' is syntactic sugar for picky compilers */
603 goto Exit;
604
605 Exit:
606 return error;
607 }
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_STREAM_READ_AT(position, buffer, count)
Definition: ftstream.h:538
unsigned long FT_ULong
Definition: fttypes.h:253
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
Definition: parse.h:23

◆ tt_face_load_cmap()

tt_face_load_cmap ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 1082 of file ttload.c.

1084 {
1086
1087
1088 error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
1089 if ( error )
1090 goto Exit;
1091
1092 if ( FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
1093 face->cmap_size = 0;
1094
1095 Exit:
1096 return error;
1097 }
#define FT_FRAME_EXTRACT(size, bytes)
Definition: ftstream.h:556
#define TTAG_cmap
Definition: tttags.h:47

◆ tt_face_load_font_dir()

tt_face_load_font_dir ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 343 of file ttload.c.

345 {
348 FT_Memory memory = stream->memory;
349 FT_UShort nn, valid_entries = 0;
350
351 static const FT_Frame_Field offset_table_fields[] =
352 {
353#undef FT_STRUCTURE
354#define FT_STRUCTURE SFNT_HeaderRec
355
356 FT_FRAME_START( 8 ),
357 FT_FRAME_USHORT( num_tables ),
358 FT_FRAME_USHORT( search_range ),
359 FT_FRAME_USHORT( entry_selector ),
360 FT_FRAME_USHORT( range_shift ),
362 };
363
364
365 FT_TRACE2(( "tt_face_load_font_dir: %p\n", (void *)face ));
366
367 /* read the offset table */
368
369 sfnt.offset = FT_STREAM_POS();
370
371 if ( FT_READ_ULONG( sfnt.format_tag ) ||
372 FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) )
373 goto Exit;
374
375 /* many fonts don't have these fields set correctly */
376#if 0
377 if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) ||
378 sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )
379 return FT_THROW( Unknown_File_Format );
380#endif
381
382 /* load the table directory */
383
384 FT_TRACE2(( "-- Number of tables: %10u\n", sfnt.num_tables ));
385 FT_TRACE2(( "-- Format version: 0x%08lx\n", sfnt.format_tag ));
386
387 if ( sfnt.format_tag != TTAG_OTTO )
388 {
389 /* check first */
390 error = check_table_dir( &sfnt, stream, &valid_entries );
391 if ( error )
392 {
393 FT_TRACE2(( "tt_face_load_font_dir:"
394 " invalid table directory for TrueType\n" ));
395 goto Exit;
396 }
397 }
398 else
399 {
400 valid_entries = sfnt.num_tables;
401 if ( !valid_entries )
402 {
403 FT_TRACE2(( "tt_face_load_font_dir: no valid tables found\n" ));
404 error = FT_THROW( Unknown_File_Format );
405 goto Exit;
406 }
407 }
408
409 face->num_tables = valid_entries;
410 face->format_tag = sfnt.format_tag;
411
412 if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )
413 goto Exit;
414
415 if ( FT_STREAM_SEEK( sfnt.offset + 12 ) ||
416 FT_FRAME_ENTER( sfnt.num_tables * 16L ) )
417 goto Exit;
418
419 FT_TRACE2(( "\n"
420 " tag offset length checksum\n"
421 " ----------------------------------\n" ));
422
423 valid_entries = 0;
424 for ( nn = 0; nn < sfnt.num_tables; nn++ )
425 {
427 FT_UShort i;
428 FT_Bool duplicate;
429
430
431 entry.Tag = FT_GET_TAG4();
432 entry.CheckSum = FT_GET_ULONG();
433 entry.Offset = FT_GET_ULONG();
434 entry.Length = FT_GET_ULONG();
435
436 /* ignore invalid tables that can't be sanitized */
437
438 if ( entry.Offset > stream->size )
439 continue;
440 else if ( entry.Length > stream->size - entry.Offset )
441 {
442 if ( entry.Tag == TTAG_hmtx ||
443 entry.Tag == TTAG_vmtx )
444 {
445#ifdef FT_DEBUG_LEVEL_TRACE
446 FT_ULong old_length = entry.Length;
447#endif
448
449
450 /* make metrics table length a multiple of 4 */
451 entry.Length = ( stream->size - entry.Offset ) & ~3U;
452
453 FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx"
454 " (sanitized; original length %08lx)",
455 (FT_Char)( entry.Tag >> 24 ),
456 (FT_Char)( entry.Tag >> 16 ),
457 (FT_Char)( entry.Tag >> 8 ),
458 (FT_Char)( entry.Tag ),
459 entry.Offset,
460 entry.Length,
461 entry.CheckSum,
462 old_length ));
463 }
464 else
465 continue;
466 }
467#ifdef FT_DEBUG_LEVEL_TRACE
468 else
469 FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx",
470 (FT_Char)( entry.Tag >> 24 ),
471 (FT_Char)( entry.Tag >> 16 ),
472 (FT_Char)( entry.Tag >> 8 ),
473 (FT_Char)( entry.Tag ),
474 entry.Offset,
475 entry.Length,
476 entry.CheckSum ));
477#endif
478
479 /* ignore duplicate tables – the first one wins */
480 duplicate = 0;
481 for ( i = 0; i < valid_entries; i++ )
482 {
483 if ( face->dir_tables[i].Tag == entry.Tag )
484 {
485 duplicate = 1;
486 break;
487 }
488 }
489 if ( duplicate )
490 {
491 FT_TRACE2(( " (duplicate, ignored)\n" ));
492 continue;
493 }
494 else
495 {
496 FT_TRACE2(( "\n" ));
497
498 /* we finally have a valid entry */
499 face->dir_tables[valid_entries++] = entry;
500 }
501 }
502
503 /* final adjustment to number of tables */
504 face->num_tables = valid_entries;
505
507
508 FT_TRACE2(( "table directory loaded\n\n" ));
509
510 Exit:
511 return error;
512 }
#define FT_TRACE2(varformat)
Definition: ftdebug.h:189
#define FT_QNEW_ARRAY(ptr, count)
Definition: ftmemory.h:350
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:548
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_GET_ULONG()
Definition: ftstream.h:315
#define FT_READ_ULONG(var)
Definition: ftstream.h:343
#define FT_STREAM_POS()
Definition: ftstream.h:522
#define FT_GET_TAG4()
Definition: ftstream.h:316
#define FT_FRAME_EXIT()
Definition: ftstream.h:553
#define FT_STREAM_READ_FIELDS(fields, object)
Definition: ftstream.h:544
#define FT_FRAME_START(size)
Definition: ftstream.h:117
#define FT_FRAME_USHORT(f)
Definition: ftstream.h:123
signed char FT_Char
Definition: fttypes.h:143
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
unsigned short FT_UShort
Definition: fttypes.h:209
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
unsigned int size
Definition: parse.h:27
SFNT_Service sfnt
Definition: ttdriver.c:208
static FT_Error check_table_dir(SFNT_Header sfnt, FT_Stream stream, FT_UShort *valid)
Definition: ttload.c:175
#define TTAG_hmtx
Definition: tttags.h:70
#define TTAG_OTTO
Definition: tttags.h:89
#define TTAG_vmtx
Definition: tttags.h:106

◆ tt_face_load_gasp()

tt_face_load_gasp ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 1407 of file ttload.c.

1409 {
1411 FT_Memory memory = stream->memory;
1412
1413 FT_UInt j,num_ranges;
1414 TT_GaspRange gaspranges = NULL;
1415
1416
1417 /* the gasp table is optional */
1418 error = face->goto_table( face, TTAG_gasp, stream, 0 );
1419 if ( error )
1420 goto Exit;
1421
1422 if ( FT_FRAME_ENTER( 4L ) )
1423 goto Exit;
1424
1425 face->gasp.version = FT_GET_USHORT();
1426 face->gasp.numRanges = FT_GET_USHORT();
1427
1428 FT_FRAME_EXIT();
1429
1430 /* only support versions 0 and 1 of the table */
1431 if ( face->gasp.version >= 2 )
1432 {
1433 face->gasp.numRanges = 0;
1434 error = FT_THROW( Invalid_Table );
1435 goto Exit;
1436 }
1437
1438 num_ranges = face->gasp.numRanges;
1439 FT_TRACE3(( "numRanges: %u\n", num_ranges ));
1440
1441 if ( FT_QNEW_ARRAY( face->gasp.gaspRanges, num_ranges ) ||
1442 FT_FRAME_ENTER( num_ranges * 4L ) )
1443 goto Exit;
1444
1445 gaspranges = face->gasp.gaspRanges;
1446
1447 for ( j = 0; j < num_ranges; j++ )
1448 {
1449 gaspranges[j].maxPPEM = FT_GET_USHORT();
1450 gaspranges[j].gaspFlag = FT_GET_USHORT();
1451
1452 FT_TRACE3(( "gaspRange %d: rangeMaxPPEM %5d, rangeGaspBehavior 0x%x\n",
1453 j,
1454 gaspranges[j].maxPPEM,
1455 gaspranges[j].gaspFlag ));
1456 }
1457
1458 FT_FRAME_EXIT();
1459
1460 Exit:
1461 return error;
1462 }
#define NULL
Definition: types.h:112
#define FT_TRACE3(varformat)
Definition: ftdebug.h:190
#define FT_GET_USHORT()
Definition: ftstream.h:311
unsigned int FT_UInt
Definition: fttypes.h:231
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 GLint GLint j
Definition: glfuncs.h:250
FT_UShort gaspFlag
Definition: tttypes.h:347
FT_UShort maxPPEM
Definition: tttypes.h:346
#define TTAG_gasp
Definition: tttags.h:60

◆ tt_face_load_head()

tt_face_load_head ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 683 of file ttload.c.

685 {
687 }
static FT_Error tt_face_load_generic_header(TT_Face face, FT_Stream stream, FT_ULong tag)
Definition: ttload.c:629
#define TTAG_head
Definition: tttags.h:68

◆ tt_face_load_maxp()

tt_face_load_maxp ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 721 of file ttload.c.

723 {
725 TT_MaxProfile* maxProfile = &face->max_profile;
726
727 static const FT_Frame_Field maxp_fields[] =
728 {
729#undef FT_STRUCTURE
730#define FT_STRUCTURE TT_MaxProfile
731
732 FT_FRAME_START( 6 ),
736 };
737
738 static const FT_Frame_Field maxp_fields_extra[] =
739 {
740 FT_FRAME_START( 26 ),
741 FT_FRAME_USHORT( maxPoints ),
742 FT_FRAME_USHORT( maxContours ),
743 FT_FRAME_USHORT( maxCompositePoints ),
744 FT_FRAME_USHORT( maxCompositeContours ),
745 FT_FRAME_USHORT( maxZones ),
746 FT_FRAME_USHORT( maxTwilightPoints ),
747 FT_FRAME_USHORT( maxStorage ),
748 FT_FRAME_USHORT( maxFunctionDefs ),
749 FT_FRAME_USHORT( maxInstructionDefs ),
750 FT_FRAME_USHORT( maxStackElements ),
751 FT_FRAME_USHORT( maxSizeOfInstructions ),
752 FT_FRAME_USHORT( maxComponentElements ),
753 FT_FRAME_USHORT( maxComponentDepth ),
755 };
756
757
758 error = face->goto_table( face, TTAG_maxp, stream, 0 );
759 if ( error )
760 goto Exit;
761
762 if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )
763 goto Exit;
764
765 maxProfile->maxPoints = 0;
766 maxProfile->maxContours = 0;
767 maxProfile->maxCompositePoints = 0;
768 maxProfile->maxCompositeContours = 0;
769 maxProfile->maxZones = 0;
770 maxProfile->maxTwilightPoints = 0;
771 maxProfile->maxStorage = 0;
772 maxProfile->maxFunctionDefs = 0;
773 maxProfile->maxInstructionDefs = 0;
774 maxProfile->maxStackElements = 0;
775 maxProfile->maxSizeOfInstructions = 0;
776 maxProfile->maxComponentElements = 0;
777 maxProfile->maxComponentDepth = 0;
778
779 if ( maxProfile->version >= 0x10000L )
780 {
781 if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )
782 goto Exit;
783
784 /* XXX: an adjustment that is necessary to load certain */
785 /* broken fonts like `Keystrokes MT' :-( */
786 /* */
787 /* We allocate 64 function entries by default when */
788 /* the maxFunctionDefs value is smaller. */
789
790 if ( maxProfile->maxFunctionDefs < 64 )
791 maxProfile->maxFunctionDefs = 64;
792
793 /* we add 4 phantom points later */
794 if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
795 {
796 FT_TRACE0(( "tt_face_load_maxp:"
797 " too much twilight points in `maxp' table;\n"
798 " "
799 " some glyphs might be rendered incorrectly\n" ));
800
801 maxProfile->maxTwilightPoints = 0xFFFFU - 4;
802 }
803 }
804
805 FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
806
807 Exit:
808 return error;
809 }
static const WCHAR version[]
Definition: asmname.c:66
#define FT_TRACE0(varformat)
Definition: ftdebug.h:187
#define FT_FRAME_LONG(f)
Definition: ftstream.h:120
GLenum const GLvoid GLbitfield GLsizei numGlyphs
Definition: glext.h:11715
FT_UShort maxZones
Definition: tttables.h:575
FT_UShort maxComponentElements
Definition: tttables.h:582
FT_UShort maxPoints
Definition: tttables.h:571
FT_UShort maxStackElements
Definition: tttables.h:580
FT_UShort maxInstructionDefs
Definition: tttables.h:579
FT_UShort maxStorage
Definition: tttables.h:577
FT_Fixed version
Definition: tttables.h:569
FT_UShort maxContours
Definition: tttables.h:572
FT_UShort numGlyphs
Definition: tttables.h:570
FT_UShort maxTwilightPoints
Definition: tttables.h:576
FT_UShort maxCompositeContours
Definition: tttables.h:574
FT_UShort maxComponentDepth
Definition: tttables.h:583
FT_UShort maxCompositePoints
Definition: tttables.h:573
FT_UShort maxSizeOfInstructions
Definition: tttables.h:581
FT_UShort maxFunctionDefs
Definition: tttables.h:578
#define TTAG_maxp
Definition: tttags.h:79

◆ tt_face_load_name()

tt_face_load_name ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 831 of file ttload.c.

833 {
835 FT_Memory memory = stream->memory;
836 FT_ULong table_pos, table_len;
837 FT_ULong storage_start, storage_limit;
839
840 static const FT_Frame_Field name_table_fields[] =
841 {
842#undef FT_STRUCTURE
843#define FT_STRUCTURE TT_NameTableRec
844
845 FT_FRAME_START( 6 ),
847 FT_FRAME_USHORT( numNameRecords ),
848 FT_FRAME_USHORT( storageOffset ),
850 };
851
852 static const FT_Frame_Field name_record_fields[] =
853 {
854#undef FT_STRUCTURE
855#define FT_STRUCTURE TT_NameRec
856
857 /* no FT_FRAME_START */
858 FT_FRAME_USHORT( platformID ),
859 FT_FRAME_USHORT( encodingID ),
860 FT_FRAME_USHORT( languageID ),
861 FT_FRAME_USHORT( nameID ),
862 FT_FRAME_USHORT( stringLength ),
863 FT_FRAME_USHORT( stringOffset ),
865 };
866
867 static const FT_Frame_Field langTag_record_fields[] =
868 {
869#undef FT_STRUCTURE
870#define FT_STRUCTURE TT_LangTagRec
871
872 /* no FT_FRAME_START */
873 FT_FRAME_USHORT( stringLength ),
874 FT_FRAME_USHORT( stringOffset ),
876 };
877
878
879 table = &face->name_table;
880 table->stream = stream;
881
882 error = face->goto_table( face, TTAG_name, stream, &table_len );
883 if ( error )
884 goto Exit;
885
886 table_pos = FT_STREAM_POS();
887
888 if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) )
889 goto Exit;
890
891 /* Some popular Asian fonts have an invalid `storageOffset' value (it */
892 /* should be at least `6 + 12*numNameRecords'). However, the string */
893 /* offsets, computed as `storageOffset + entry->stringOffset', are */
894 /* valid pointers within the name table... */
895 /* */
896 /* We thus can't check `storageOffset' right now. */
897 /* */
898 storage_start = table_pos + 6 + 12 * table->numNameRecords;
899 storage_limit = table_pos + table_len;
900
901 if ( storage_start > storage_limit )
902 {
903 FT_ERROR(( "tt_face_load_name: invalid `name' table\n" ));
904 error = FT_THROW( Name_Table_Missing );
905 goto Exit;
906 }
907
908 /* `name' format 1 contains additional language tag records, */
909 /* which we load first */
910 if ( table->format == 1 )
911 {
912 if ( FT_STREAM_SEEK( storage_start ) ||
913 FT_READ_USHORT( table->numLangTagRecords ) )
914 goto Exit;
915
916 storage_start += 2 + 4 * table->numLangTagRecords;
917
918 /* allocate language tag records array */
919 if ( FT_NEW_ARRAY( table->langTags, table->numLangTagRecords ) ||
920 FT_FRAME_ENTER( table->numLangTagRecords * 4 ) )
921 goto Exit;
922
923 /* load language tags */
924 {
925 TT_LangTag entry = table->langTags;
926 TT_LangTag limit = FT_OFFSET( entry, table->numLangTagRecords );
927
928
929 for ( ; entry < limit; entry++ )
930 {
931 (void)FT_STREAM_READ_FIELDS( langTag_record_fields, entry );
932
933 /* check that the langTag string is within the table */
934 entry->stringOffset += table_pos + table->storageOffset;
935 if ( entry->stringOffset < storage_start ||
936 entry->stringOffset + entry->stringLength > storage_limit )
937 {
938 /* invalid entry; ignore it */
939 entry->stringLength = 0;
940 }
941 }
942 }
943
945
946 (void)FT_STREAM_SEEK( table_pos + 6 );
947 }
948
949 /* allocate name records array */
950 if ( FT_NEW_ARRAY( table->names, table->numNameRecords ) ||
951 FT_FRAME_ENTER( table->numNameRecords * 12 ) )
952 goto Exit;
953
954 /* load name records */
955 {
956 TT_Name entry = table->names;
957 FT_UInt count = table->numNameRecords;
958
959
960 for ( ; count > 0; count-- )
961 {
962 if ( FT_STREAM_READ_FIELDS( name_record_fields, entry ) )
963 continue;
964
965 /* check that the name is not empty */
966 if ( entry->stringLength == 0 )
967 continue;
968
969 /* check that the name string is within the table */
970 entry->stringOffset += table_pos + table->storageOffset;
971 if ( entry->stringOffset < storage_start ||
972 entry->stringOffset + entry->stringLength > storage_limit )
973 {
974 /* invalid entry; ignore it */
975 continue;
976 }
977
978 /* assure that we have a valid language tag ID, and */
979 /* that the corresponding langTag entry is valid, too */
980 if ( table->format == 1 && entry->languageID >= 0x8000U )
981 {
982 if ( entry->languageID - 0x8000U >= table->numLangTagRecords ||
983 !table->langTags[entry->languageID - 0x8000U].stringLength )
984 {
985 /* invalid entry; ignore it */
986 continue;
987 }
988 }
989
990 entry++;
991 }
992
993 /* reduce array size to the actually used elements */
994 count = (FT_UInt)( entry - table->names );
995 (void)FT_RENEW_ARRAY( table->names,
996 table->numNameRecords,
997 count );
998 table->numNameRecords = count;
999 }
1000
1001 FT_FRAME_EXIT();
1002
1003 /* everything went well, update face->num_names */
1004 face->num_names = (FT_UShort)table->numNameRecords;
1005
1006 Exit:
1007 return error;
1008 }
#define FT_ERROR(varformat)
Definition: ftdebug.h:211
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:341
#define FT_OFFSET(base, count)
Definition: ftmemory.h:66
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:344
#define FT_READ_USHORT(var)
Definition: ftstream.h:339
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: format.c:58
#define TTAG_name
Definition: tttags.h:86

◆ tt_face_load_os2()

tt_face_load_os2 ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 1120 of file ttload.c.

1122 {
1124 TT_OS2* os2;
1125
1126 static const FT_Frame_Field os2_fields[] =
1127 {
1128#undef FT_STRUCTURE
1129#define FT_STRUCTURE TT_OS2
1130
1131 FT_FRAME_START( 78 ),
1133 FT_FRAME_SHORT ( xAvgCharWidth ),
1134 FT_FRAME_USHORT( usWeightClass ),
1135 FT_FRAME_USHORT( usWidthClass ),
1136 FT_FRAME_SHORT ( fsType ),
1137 FT_FRAME_SHORT ( ySubscriptXSize ),
1138 FT_FRAME_SHORT ( ySubscriptYSize ),
1139 FT_FRAME_SHORT ( ySubscriptXOffset ),
1140 FT_FRAME_SHORT ( ySubscriptYOffset ),
1141 FT_FRAME_SHORT ( ySuperscriptXSize ),
1142 FT_FRAME_SHORT ( ySuperscriptYSize ),
1143 FT_FRAME_SHORT ( ySuperscriptXOffset ),
1144 FT_FRAME_SHORT ( ySuperscriptYOffset ),
1145 FT_FRAME_SHORT ( yStrikeoutSize ),
1146 FT_FRAME_SHORT ( yStrikeoutPosition ),
1147 FT_FRAME_SHORT ( sFamilyClass ),
1148 FT_FRAME_BYTE ( panose[0] ),
1149 FT_FRAME_BYTE ( panose[1] ),
1150 FT_FRAME_BYTE ( panose[2] ),
1151 FT_FRAME_BYTE ( panose[3] ),
1152 FT_FRAME_BYTE ( panose[4] ),
1153 FT_FRAME_BYTE ( panose[5] ),
1154 FT_FRAME_BYTE ( panose[6] ),
1155 FT_FRAME_BYTE ( panose[7] ),
1156 FT_FRAME_BYTE ( panose[8] ),
1157 FT_FRAME_BYTE ( panose[9] ),
1158 FT_FRAME_ULONG ( ulUnicodeRange1 ),
1159 FT_FRAME_ULONG ( ulUnicodeRange2 ),
1160 FT_FRAME_ULONG ( ulUnicodeRange3 ),
1161 FT_FRAME_ULONG ( ulUnicodeRange4 ),
1162 FT_FRAME_BYTE ( achVendID[0] ),
1163 FT_FRAME_BYTE ( achVendID[1] ),
1164 FT_FRAME_BYTE ( achVendID[2] ),
1165 FT_FRAME_BYTE ( achVendID[3] ),
1166
1167 FT_FRAME_USHORT( fsSelection ),
1168 FT_FRAME_USHORT( usFirstCharIndex ),
1169 FT_FRAME_USHORT( usLastCharIndex ),
1170 FT_FRAME_SHORT ( sTypoAscender ),
1171 FT_FRAME_SHORT ( sTypoDescender ),
1172 FT_FRAME_SHORT ( sTypoLineGap ),
1173 FT_FRAME_USHORT( usWinAscent ),
1174 FT_FRAME_USHORT( usWinDescent ),
1176 };
1177
1178 /* `OS/2' version 1 and newer */
1179 static const FT_Frame_Field os2_fields_extra1[] =
1180 {
1181 FT_FRAME_START( 8 ),
1182 FT_FRAME_ULONG( ulCodePageRange1 ),
1183 FT_FRAME_ULONG( ulCodePageRange2 ),
1185 };
1186
1187 /* `OS/2' version 2 and newer */
1188 static const FT_Frame_Field os2_fields_extra2[] =
1189 {
1190 FT_FRAME_START( 10 ),
1191 FT_FRAME_SHORT ( sxHeight ),
1192 FT_FRAME_SHORT ( sCapHeight ),
1193 FT_FRAME_USHORT( usDefaultChar ),
1194 FT_FRAME_USHORT( usBreakChar ),
1195 FT_FRAME_USHORT( usMaxContext ),
1197 };
1198
1199 /* `OS/2' version 5 and newer */
1200 static const FT_Frame_Field os2_fields_extra5[] =
1201 {
1202 FT_FRAME_START( 4 ),
1203 FT_FRAME_USHORT( usLowerOpticalPointSize ),
1204 FT_FRAME_USHORT( usUpperOpticalPointSize ),
1206 };
1207
1208
1209 /* We now support old Mac fonts where the OS/2 table doesn't */
1210 /* exist. Simply put, we set the `version' field to 0xFFFF */
1211 /* and test this value each time we need to access the table. */
1212 error = face->goto_table( face, TTAG_OS2, stream, 0 );
1213 if ( error )
1214 goto Exit;
1215
1216 os2 = &face->os2;
1217
1218 if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) )
1219 goto Exit;
1220
1221 os2->ulCodePageRange1 = 0;
1222 os2->ulCodePageRange2 = 0;
1223 os2->sxHeight = 0;
1224 os2->sCapHeight = 0;
1225 os2->usDefaultChar = 0;
1226 os2->usBreakChar = 0;
1227 os2->usMaxContext = 0;
1228 os2->usLowerOpticalPointSize = 0;
1229 os2->usUpperOpticalPointSize = 0xFFFF;
1230
1231 if ( os2->version >= 0x0001 )
1232 {
1233 /* only version 1 tables */
1234 if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) )
1235 goto Exit;
1236
1237 if ( os2->version >= 0x0002 )
1238 {
1239 /* only version 2 tables */
1240 if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) )
1241 goto Exit;
1242
1243 if ( os2->version >= 0x0005 )
1244 {
1245 /* only version 5 tables */
1246 if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) )
1247 goto Exit;
1248 }
1249 }
1250 }
1251
1252 FT_TRACE3(( "sTypoAscender: %4d\n", os2->sTypoAscender ));
1253 FT_TRACE3(( "sTypoDescender: %4d\n", os2->sTypoDescender ));
1254 FT_TRACE3(( "usWinAscent: %4u\n", os2->usWinAscent ));
1255 FT_TRACE3(( "usWinDescent: %4u\n", os2->usWinDescent ));
1256 FT_TRACE3(( "fsSelection: 0x%2x\n", os2->fsSelection ));
1257
1258 Exit:
1259 return error;
1260 }
#define FT_FRAME_SHORT(f)
Definition: ftstream.h:122
#define FT_FRAME_BYTE(f)
Definition: ftstream.h:126
#define FT_FRAME_ULONG(f)
Definition: ftstream.h:121
FT_Short sTypoDescender
Definition: tttables.h:407
FT_UShort version
Definition: tttables.h:377
FT_ULong ulCodePageRange1
Definition: tttables.h:414
FT_UShort fsSelection
Definition: tttables.h:403
FT_UShort usMaxContext
Definition: tttables.h:423
FT_UShort usBreakChar
Definition: tttables.h:422
FT_Short sxHeight
Definition: tttables.h:419
FT_UShort usWinDescent
Definition: tttables.h:410
FT_UShort usLowerOpticalPointSize
Definition: tttables.h:427
FT_Short sTypoAscender
Definition: tttables.h:406
FT_UShort usUpperOpticalPointSize
Definition: tttables.h:428
FT_Short sCapHeight
Definition: tttables.h:420
FT_ULong ulCodePageRange2
Definition: tttables.h:415
FT_UShort usWinAscent
Definition: tttables.h:409
FT_UShort usDefaultChar
Definition: tttables.h:421
#define TTAG_OS2
Definition: tttags.h:88

◆ tt_face_load_pclt()

tt_face_load_pclt ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 1344 of file ttload.c.

1346 {
1347 static const FT_Frame_Field pclt_fields[] =
1348 {
1349#undef FT_STRUCTURE
1350#define FT_STRUCTURE TT_PCLT
1351
1352 FT_FRAME_START( 54 ),
1354 FT_FRAME_ULONG ( FontNumber ),
1355 FT_FRAME_USHORT( Pitch ),
1356 FT_FRAME_USHORT( xHeight ),
1358 FT_FRAME_USHORT( TypeFamily ),
1359 FT_FRAME_USHORT( CapHeight ),
1360 FT_FRAME_USHORT( SymbolSet ),
1361 FT_FRAME_BYTES ( TypeFace, 16 ),
1362 FT_FRAME_BYTES ( CharacterComplement, 8 ),
1363 FT_FRAME_BYTES ( FileName, 6 ),
1364 FT_FRAME_CHAR ( StrokeWeight ),
1365 FT_FRAME_CHAR ( WidthType ),
1366 FT_FRAME_BYTE ( SerifStyle ),
1369 };
1370
1372 TT_PCLT* pclt = &face->pclt;
1373
1374
1375 /* optional table */
1376 error = face->goto_table( face, TTAG_PCLT, stream, 0 );
1377 if ( error )
1378 goto Exit;
1379
1380 if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) )
1381 goto Exit;
1382
1383 Exit:
1384 return error;
1385 }
const DWORD Style
Definition: appswitch.c:72
#define FT_FRAME_BYTES(field, count)
Definition: ftstream.h:140
#define FT_FRAME_CHAR(f)
Definition: ftstream.h:127
#define TTAG_PCLT
Definition: tttags.h:90
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Reserved_ PVOID Reserved
Definition: winddi.h:3974

◆ tt_face_load_post()

tt_face_load_post ( TT_Face  face,
FT_Stream  stream 
)

Definition at line 1282 of file ttload.c.

1284 {
1286 TT_Postscript* post = &face->postscript;
1287
1288 static const FT_Frame_Field post_fields[] =
1289 {
1290#undef FT_STRUCTURE
1291#define FT_STRUCTURE TT_Postscript
1292
1293 FT_FRAME_START( 32 ),
1294 FT_FRAME_LONG ( FormatType ),
1295 FT_FRAME_LONG ( italicAngle ),
1296 FT_FRAME_SHORT( underlinePosition ),
1297 FT_FRAME_SHORT( underlineThickness ),
1298 FT_FRAME_ULONG( isFixedPitch ),
1299 FT_FRAME_ULONG( minMemType42 ),
1300 FT_FRAME_ULONG( maxMemType42 ),
1301 FT_FRAME_ULONG( minMemType1 ),
1302 FT_FRAME_ULONG( maxMemType1 ),
1304 };
1305
1306
1307 error = face->goto_table( face, TTAG_post, stream, 0 );
1308 if ( error )
1309 return error;
1310
1311 if ( FT_STREAM_READ_FIELDS( post_fields, post ) )
1312 return error;
1313
1314 /* we don't load the glyph names, we do that in another */
1315 /* module (ttpost). */
1316
1317 FT_TRACE3(( "FormatType: 0x%lx\n", post->FormatType ));
1318 FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch
1319 ? " yes" : " no" ));
1320
1321 return FT_Err_Ok;
1322 }
FT_Fixed FormatType
Definition: tttables.h:452
FT_ULong isFixedPitch
Definition: tttables.h:456
#define TTAG_post
Definition: tttags.h:92

◆ tt_face_lookup_table()

FT_BEGIN_HEADER tt_face_lookup_table ( TT_Face  face,
FT_ULong  tag 
)

Definition at line 57 of file ttload.c.

59 {
62#ifdef FT_DEBUG_LEVEL_TRACE
63 FT_Bool zero_length = FALSE;
64#endif
65
66
67 FT_TRACE4(( "tt_face_lookup_table: %p, `%c%c%c%c' -- ",
68 (void *)face,
69 (FT_Char)( tag >> 24 ),
70 (FT_Char)( tag >> 16 ),
71 (FT_Char)( tag >> 8 ),
72 (FT_Char)( tag ) ));
73
74 entry = face->dir_tables;
75 limit = entry + face->num_tables;
76
77 for ( ; entry < limit; entry++ )
78 {
79 /* For compatibility with Windows, we consider */
80 /* zero-length tables the same as missing tables. */
81 if ( entry->Tag == tag )
82 {
83 if ( entry->Length != 0 )
84 {
85 FT_TRACE4(( "found table.\n" ));
86 return entry;
87 }
88#ifdef FT_DEBUG_LEVEL_TRACE
89 zero_length = TRUE;
90#endif
91 }
92 }
93
94#ifdef FT_DEBUG_LEVEL_TRACE
95 if ( zero_length )
96 FT_TRACE4(( "ignoring empty table\n" ));
97 else
98 FT_TRACE4(( "could not find table\n" ));
99#endif
100
101 return NULL;
102 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FT_TRACE4(varformat)
Definition: ftdebug.h:191

Referenced by sfnt_load_face(), tt_face_goto_table(), and tt_face_load_any().