ReactOS  0.4.15-dev-2144-g2282205
pfrload.c File Reference
#include "pfrload.h"
#include "pfrerror.h"
Include dependency graph for pfrload.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_pfr
 
#define FT_STRUCTURE   PFR_HeaderRec
 

Functions

 pfr_extra_items_skip (FT_Byte **pp, FT_Byte *limit)
 
 pfr_extra_items_parse (FT_Byte **pp, FT_Byte *limit, PFR_ExtraItem item_list, FT_Pointer item_data)
 
 pfr_header_load (PFR_Header header, FT_Stream stream)
 
 pfr_header_check (PFR_Header header)
 
 pfr_log_font_count (FT_Stream stream, FT_UInt32 section_offset, FT_Long *acount)
 
 pfr_log_font_load (PFR_LogFont log_font, FT_Stream stream, FT_UInt idx, FT_UInt32 section_offset, FT_Bool size_increment)
 
 pfr_extra_item_load_bitmap_info (FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
 
 pfr_extra_item_load_font_id (FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
 
 pfr_extra_item_load_stem_snaps (FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
 
 pfr_extra_item_load_kerning_pairs (FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
 
static FT_Error pfr_aux_name_load (FT_Byte *p, FT_UInt len, FT_Memory memory, FT_String **astring)
 
 pfr_phy_font_done (PFR_PhyFont phy_font, FT_Memory memory)
 
 pfr_phy_font_load (PFR_PhyFont phy_font, FT_Stream stream, FT_UInt32 offset, FT_UInt32 size)
 

Variables

static const FT_Frame_Field pfr_header_fields []
 
static const PFR_ExtraItemRec pfr_phy_font_extra_items []
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_pfr

Definition at line 26 of file pfrload.c.

◆ FT_STRUCTURE

#define FT_STRUCTURE   PFR_HeaderRec

Function Documentation

◆ pfr_aux_name_load()

static FT_Error pfr_aux_name_load ( FT_Byte p,
FT_UInt  len,
FT_Memory  memory,
FT_String **  astring 
)
static

Definition at line 736 of file pfrload.c.

740  {
742  FT_String* result = NULL;
743  FT_UInt n, ok;
744 
745 
746  if ( *astring )
747  FT_FREE( *astring );
748 
749  if ( len > 0 && p[len - 1] == 0 )
750  len--;
751 
752  /* check that each character is ASCII */
753  /* for making sure not to load garbage */
754  ok = ( len > 0 );
755  for ( n = 0; n < len; n++ )
756  if ( p[n] < 32 || p[n] > 127 )
757  {
758  ok = 0;
759  break;
760  }
761 
762  if ( ok )
763  {
764  if ( FT_ALLOC( result, len + 1 ) )
765  goto Exit;
766 
767  FT_MEM_COPY( result, p, len );
768  result[len] = 0;
769  }
770 
771  Exit:
772  *astring = result;
773  return error;
774  }
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
GLuint64EXT * result
Definition: glext.h:11304
GLdouble n
Definition: glext.h:7729
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_FREE(ptr)
Definition: ftmemory.h:329
char FT_String
Definition: fttypes.h:187
static void Exit(void)
Definition: sock.c:1331
GLenum GLsizei len
Definition: glext.h:6722
unsigned int FT_UInt
Definition: fttypes.h:231
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:228
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by pfr_phy_font_load().

◆ pfr_extra_item_load_bitmap_info()

pfr_extra_item_load_bitmap_info ( FT_Byte p,
FT_Byte limit,
PFR_PhyFont  phy_font 
)

Definition at line 456 of file pfrload.c.

459  {
460  FT_Memory memory = phy_font->memory;
461  PFR_Strike strike;
462  FT_UInt flags0;
463  FT_UInt n, count, size1;
465 
466 
467  PFR_CHECK( 5 );
468 
469  p += 3; /* skip bctSize */
470  flags0 = PFR_NEXT_BYTE( p );
471  count = PFR_NEXT_BYTE( p );
472 
473  /* re-allocate when needed */
474  if ( phy_font->num_strikes + count > phy_font->max_strikes )
475  {
476  FT_UInt new_max = FT_PAD_CEIL( phy_font->num_strikes + count, 4 );
477 
478 
479  if ( FT_RENEW_ARRAY( phy_font->strikes,
480  phy_font->num_strikes,
481  new_max ) )
482  goto Exit;
483 
484  phy_font->max_strikes = new_max;
485  }
486 
487  size1 = 1 + 1 + 1 + 2 + 2 + 1;
488  if ( flags0 & PFR_STRIKE_2BYTE_XPPM )
489  size1++;
490 
491  if ( flags0 & PFR_STRIKE_2BYTE_YPPM )
492  size1++;
493 
494  if ( flags0 & PFR_STRIKE_3BYTE_SIZE )
495  size1++;
496 
497  if ( flags0 & PFR_STRIKE_3BYTE_OFFSET )
498  size1++;
499 
500  if ( flags0 & PFR_STRIKE_2BYTE_COUNT )
501  size1++;
502 
503  strike = phy_font->strikes + phy_font->num_strikes;
504 
505  PFR_CHECK( count * size1 );
506 
507  for ( n = 0; n < count; n++, strike++ )
508  {
509  strike->x_ppm = ( flags0 & PFR_STRIKE_2BYTE_XPPM )
510  ? PFR_NEXT_USHORT( p )
511  : PFR_NEXT_BYTE( p );
512 
513  strike->y_ppm = ( flags0 & PFR_STRIKE_2BYTE_YPPM )
514  ? PFR_NEXT_USHORT( p )
515  : PFR_NEXT_BYTE( p );
516 
517  strike->flags = PFR_NEXT_BYTE( p );
518 
519  strike->bct_size = ( flags0 & PFR_STRIKE_3BYTE_SIZE )
520  ? PFR_NEXT_ULONG( p )
521  : PFR_NEXT_USHORT( p );
522 
523  strike->bct_offset = ( flags0 & PFR_STRIKE_3BYTE_OFFSET )
524  ? PFR_NEXT_ULONG( p )
525  : PFR_NEXT_USHORT( p );
526 
527  strike->num_bitmaps = ( flags0 & PFR_STRIKE_2BYTE_COUNT )
528  ? PFR_NEXT_USHORT( p )
529  : PFR_NEXT_BYTE( p );
530  }
531 
532  phy_font->num_strikes += count;
533 
534  Exit:
535  return error;
536 
537  Too_Short:
538  error = FT_THROW( Invalid_Table );
539  FT_ERROR(( "pfr_extra_item_load_bitmap_info:"
540  " invalid bitmap info table\n" ));
541  goto Exit;
542  }
FT_UInt flags
Definition: pfrtypes.h:138
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
#define PFR_STRIKE_2BYTE_COUNT
Definition: pfrtypes.h:131
#define PFR_STRIKE_3BYTE_OFFSET
Definition: pfrtypes.h:130
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
FT_UInt32 bct_size
Definition: pfrtypes.h:143
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_PAD_CEIL(x, n)
Definition: ftobjs.h:90
#define FT_THROW(e)
Definition: ftdebug.h:213
FT_UInt num_strikes
Definition: pfrtypes.h:228
#define PFR_CHECK
Definition: pfrload.h:40
FT_UInt32 bct_offset
Definition: pfrtypes.h:144
#define PFR_STRIKE_2BYTE_XPPM
Definition: pfrtypes.h:127
static void Exit(void)
Definition: sock.c:1331
FT_UInt y_ppm
Definition: pfrtypes.h:137
FT_UInt max_strikes
Definition: pfrtypes.h:229
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:336
#define PFR_STRIKE_3BYTE_SIZE
Definition: pfrtypes.h:129
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
FT_UInt x_ppm
Definition: pfrtypes.h:136
unsigned int FT_UInt
Definition: fttypes.h:231
#define PFR_NEXT_BYTE(p)
Definition: pfrload.h:43
FT_UInt num_bitmaps
Definition: pfrtypes.h:147
FT_Memory memory
Definition: pfrtypes.h:207
#define PFR_NEXT_USHORT(p)
Definition: pfrload.h:46
#define PFR_NEXT_ULONG(p)
Definition: pfrload.h:48
GLfloat GLfloat p
Definition: glext.h:8902
PFR_StrikeRec * strikes
Definition: pfrtypes.h:230
#define PFR_STRIKE_2BYTE_YPPM
Definition: pfrtypes.h:128

◆ pfr_extra_item_load_font_id()

pfr_extra_item_load_font_id ( FT_Byte p,
FT_Byte limit,
PFR_PhyFont  phy_font 
)

Definition at line 556 of file pfrload.c.

559  {
561  FT_Memory memory = phy_font->memory;
562  FT_UInt len = (FT_UInt)( limit - p );
563 
564 
565  if ( phy_font->font_id )
566  goto Exit;
567 
568  if ( FT_ALLOC( phy_font->font_id, len + 1 ) )
569  goto Exit;
570 
571  /* copy font ID name, and terminate it for safety */
572  FT_MEM_COPY( phy_font->font_id, p, len );
573  phy_font->font_id[len] = 0;
574 
575  Exit:
576  return error;
577  }
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
GLint limit
Definition: glext.h:10326
FT_String * font_id
Definition: pfrtypes.h:224
static void Exit(void)
Definition: sock.c:1331
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLsizei len
Definition: glext.h:6722
unsigned int FT_UInt
Definition: fttypes.h:231
FT_Memory memory
Definition: pfrtypes.h:207
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:228
GLfloat GLfloat p
Definition: glext.h:8902

◆ pfr_extra_item_load_kerning_pairs()

pfr_extra_item_load_kerning_pairs ( FT_Byte p,
FT_Byte limit,
PFR_PhyFont  phy_font 
)

Definition at line 627 of file pfrload.c.

630  {
633  FT_Memory memory = phy_font->memory;
634 
635 
636  if ( FT_NEW( item ) )
637  goto Exit;
638 
639  PFR_CHECK( 4 );
640 
641  item->pair_count = PFR_NEXT_BYTE( p );
642  item->base_adj = PFR_NEXT_SHORT( p );
643  item->flags = PFR_NEXT_BYTE( p );
644  item->offset = phy_font->offset +
645  (FT_Offset)( p - phy_font->cursor );
646 
647 #ifndef PFR_CONFIG_NO_CHECKS
648  item->pair_size = 3;
649 
650  if ( item->flags & PFR_KERN_2BYTE_CHAR )
651  item->pair_size += 2;
652 
653  if ( item->flags & PFR_KERN_2BYTE_ADJ )
654  item->pair_size += 1;
655 
656  PFR_CHECK( item->pair_count * item->pair_size );
657 #endif
658 
659  /* load first and last pairs into the item to speed up */
660  /* lookup later... */
661  if ( item->pair_count > 0 )
662  {
663  FT_UInt char1, char2;
664  FT_Byte* q;
665 
666 
667  if ( item->flags & PFR_KERN_2BYTE_CHAR )
668  {
669  q = p;
670  char1 = PFR_NEXT_USHORT( q );
671  char2 = PFR_NEXT_USHORT( q );
672 
673  item->pair1 = PFR_KERN_INDEX( char1, char2 );
674 
675  q = p + item->pair_size * ( item->pair_count - 1 );
676  char1 = PFR_NEXT_USHORT( q );
677  char2 = PFR_NEXT_USHORT( q );
678 
679  item->pair2 = PFR_KERN_INDEX( char1, char2 );
680  }
681  else
682  {
683  q = p;
684  char1 = PFR_NEXT_BYTE( q );
685  char2 = PFR_NEXT_BYTE( q );
686 
687  item->pair1 = PFR_KERN_INDEX( char1, char2 );
688 
689  q = p + item->pair_size * ( item->pair_count - 1 );
690  char1 = PFR_NEXT_BYTE( q );
691  char2 = PFR_NEXT_BYTE( q );
692 
693  item->pair2 = PFR_KERN_INDEX( char1, char2 );
694  }
695 
696  /* add new item to the current list */
697  item->next = NULL;
698  *phy_font->kern_items_tail = item;
699  phy_font->kern_items_tail = &item->next;
700  phy_font->num_kern_pairs += item->pair_count;
701  }
702  else
703  {
704  /* empty item! */
705  FT_FREE( item );
706  }
707 
708  Exit:
709  return error;
710 
711  Too_Short:
712  FT_FREE( item );
713 
714  error = FT_THROW( Invalid_Table );
715  FT_ERROR(( "pfr_extra_item_load_kerning_pairs:"
716  " invalid kerning pairs table\n" ));
717  goto Exit;
718  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_FREE(ptr)
Definition: ftmemory.h:329
FT_UInt num_kern_pairs
Definition: pfrtypes.h:241
#define PFR_CHECK
Definition: pfrload.h:40
#define PFR_KERN_2BYTE_CHAR
Definition: pfrtypes.h:261
static void Exit(void)
Definition: sock.c:1331
FT_UInt32 offset
Definition: pfrtypes.h:208
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
PFR_KernItem * kern_items_tail
Definition: pfrtypes.h:243
FT_Byte * cursor
Definition: pfrtypes.h:247
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static ATOM item
Definition: dde.c:856
#define PFR_KERN_2BYTE_ADJ
Definition: pfrtypes.h:262
unsigned int FT_UInt
Definition: fttypes.h:231
#define PFR_KERN_INDEX(g1, g2)
Definition: pfrtypes.h:193
#define NULL
Definition: types.h:112
#define PFR_NEXT_BYTE(p)
Definition: pfrload.h:43
#define FT_NEW(ptr)
Definition: ftmemory.h:331
FT_Memory memory
Definition: pfrtypes.h:207
#define PFR_NEXT_USHORT(p)
Definition: pfrload.h:46
GLfloat GLfloat p
Definition: glext.h:8902
#define PFR_NEXT_SHORT(p)
Definition: pfrload.h:45
size_t FT_Offset
Definition: fttypes.h:324

◆ pfr_extra_item_load_stem_snaps()

pfr_extra_item_load_stem_snaps ( FT_Byte p,
FT_Byte limit,
PFR_PhyFont  phy_font 
)

Definition at line 582 of file pfrload.c.

585  {
586  FT_UInt count, num_vert, num_horz;
587  FT_Int* snaps = NULL;
589  FT_Memory memory = phy_font->memory;
590 
591 
592  if ( phy_font->vertical.stem_snaps )
593  goto Exit;
594 
595  PFR_CHECK( 1 );
596  count = PFR_NEXT_BYTE( p );
597 
598  num_vert = count & 15;
599  num_horz = count >> 4;
600  count = num_vert + num_horz;
601 
602  PFR_CHECK( count * 2 );
603 
604  if ( FT_NEW_ARRAY( snaps, count ) )
605  goto Exit;
606 
607  phy_font->vertical.stem_snaps = snaps;
608  phy_font->horizontal.stem_snaps = snaps + num_vert;
609 
610  for ( ; count > 0; count--, snaps++ )
611  *snaps = FT_NEXT_SHORT( p );
612 
613  Exit:
614  return error;
615 
616  Too_Short:
617  error = FT_THROW( Invalid_Table );
618  FT_ERROR(( "pfr_extra_item_load_stem_snaps:"
619  " invalid stem snaps table\n" ));
620  goto Exit;
621  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
signed int FT_Int
Definition: fttypes.h:220
GLuint GLuint GLsizei count
Definition: gl.h:1545
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
PFR_DimensionRec horizontal
Definition: pfrtypes.h:221
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
#define PFR_CHECK
Definition: pfrload.h:40
static void Exit(void)
Definition: sock.c:1331
FT_Int * stem_snaps
Definition: pfrtypes.h:171
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333
unsigned int FT_UInt
Definition: fttypes.h:231
#define NULL
Definition: types.h:112
#define PFR_NEXT_BYTE(p)
Definition: pfrload.h:43
PFR_DimensionRec vertical
Definition: pfrtypes.h:222
FT_Memory memory
Definition: pfrtypes.h:207
#define FT_NEXT_SHORT(buffer)
Definition: ftstream.h:223
GLfloat GLfloat p
Definition: glext.h:8902

◆ pfr_extra_items_parse()

pfr_extra_items_parse ( FT_Byte **  pp,
FT_Byte limit,
PFR_ExtraItem  item_list,
FT_Pointer  item_data 
)

Definition at line 134 of file pfrload.c.

138  {
140  FT_Byte* p = *pp;
141  FT_UInt num_items, item_type, item_size;
142 
143 
144  PFR_CHECK( 1 );
145  num_items = PFR_NEXT_BYTE( p );
146 
147  for ( ; num_items > 0; num_items-- )
148  {
149  PFR_CHECK( 2 );
150  item_size = PFR_NEXT_BYTE( p );
151  item_type = PFR_NEXT_BYTE( p );
152 
153  PFR_CHECK( item_size );
154 
155  if ( item_list )
156  {
157  PFR_ExtraItem extra = item_list;
158 
159 
160  for ( extra = item_list; extra->parser != NULL; extra++ )
161  {
162  if ( extra->type == item_type )
163  {
164  error = extra->parser( p, p + item_size, item_data );
165  if ( error )
166  goto Exit;
167 
168  break;
169  }
170  }
171  }
172 
173  p += item_size;
174  }
175 
176  Exit:
177  *pp = p;
178  return error;
179 
180  Too_Short:
181  FT_ERROR(( "pfr_extra_items_parse: invalid extra items table\n" ));
182  error = FT_THROW( Invalid_Table );
183  goto Exit;
184  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
#define PFR_CHECK
Definition: pfrload.h:40
Definition: id3.c:95
static void Exit(void)
Definition: sock.c:1331
unsigned int FT_UInt
Definition: fttypes.h:231
#define NULL
Definition: types.h:112
#define PFR_NEXT_BYTE(p)
Definition: pfrload.h:43
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by pfr_extra_items_skip(), and pfr_phy_font_load().

◆ pfr_extra_items_skip()

pfr_extra_items_skip ( FT_Byte **  pp,
FT_Byte limit 
)

Definition at line 126 of file pfrload.c.

128  {
129  return pfr_extra_items_parse( pp, limit, NULL, NULL );
130  }
GLint limit
Definition: glext.h:10326
pfr_extra_items_parse(FT_Byte **pp, FT_Byte *limit, PFR_ExtraItem item_list, FT_Pointer item_data)
Definition: pfrload.c:134
#define NULL
Definition: types.h:112

Referenced by pfr_glyph_load_compound(), pfr_glyph_load_simple(), and pfr_log_font_load().

◆ pfr_header_check()

pfr_header_check ( PFR_Header  header)

Definition at line 261 of file pfrload.c.

262  {
263  FT_Bool result = 1;
264 
265 
266  /* check signature and header size */
267  if ( header->signature != 0x50465230L || /* "PFR0" */
268  header->version > 4 ||
269  header->header_size < 58 ||
270  header->signature2 != 0x0D0A ) /* CR/LF */
271  {
272  result = 0;
273  }
274 
275  return result;
276  }
GLuint64EXT * result
Definition: glext.h:11304
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108

Referenced by pfr_face_init().

◆ pfr_header_load()

pfr_header_load ( PFR_Header  header,
FT_Stream  stream 
)

Definition at line 241 of file pfrload.c.

243  {
244  FT_Error error;
245 
246 
247  /* read header directly */
248  if ( !FT_STREAM_SEEK( 0 ) &&
250  {
251  /* make a few adjustments to the header */
252  header->phy_font_max_size +=
253  (FT_UInt32)header->phy_font_max_size_high << 16;
254  }
255 
256  return error;
257  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
static const FT_Frame_Field pfr_header_fields[]
Definition: pfrload.c:195
#define FT_STREAM_READ_FIELDS(fields, object)
Definition: ftstream.h:508
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489

Referenced by pfr_face_init().

◆ pfr_log_font_count()

pfr_log_font_count ( FT_Stream  stream,
FT_UInt32  section_offset,
FT_Long acount 
)

Definition at line 289 of file pfrload.c.

292  {
293  FT_Error error;
294  FT_UInt count;
295  FT_UInt result = 0;
296 
297 
298  if ( FT_STREAM_SEEK( section_offset ) ||
299  FT_READ_USHORT( count ) )
300  goto Exit;
301 
302  /* check maximum value and a rough minimum size: */
303  /* - no more than 13106 log fonts */
304  /* - we need 5 bytes for a log header record */
305  /* - we need at least 18 bytes for a log font record */
306  /* - the overall size is at least 95 bytes plus the */
307  /* log header and log font records */
308  if ( count > ( ( 1 << 16 ) - 2 ) / 5 ||
309  2 + count * 5 >= stream->size - section_offset ||
310  95 + count * ( 5 + 18 ) >= stream->size )
311  {
312  FT_ERROR(( "pfr_log_font_count:"
313  " invalid number of logical fonts\n" ));
314  error = FT_THROW( Invalid_Table );
315  goto Exit;
316  }
317 
318  result = count;
319 
320  Exit:
321  *acount = (FT_Long)result;
322  return error;
323  }
int FT_Error
Definition: fttypes.h:300
signed long FT_Long
Definition: fttypes.h:242
#define error(str)
Definition: mkdosfs.c:1605
GLuint64EXT * result
Definition: glext.h:11304
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FT_READ_USHORT(var)
Definition: ftstream.h:309
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
static void Exit(void)
Definition: sock.c:1331
unsigned int size
Definition: parse.h:27
Definition: parse.h:22
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
unsigned int FT_UInt
Definition: fttypes.h:231

Referenced by pfr_face_init().

◆ pfr_log_font_load()

pfr_log_font_load ( PFR_LogFont  log_font,
FT_Stream  stream,
FT_UInt  idx,
FT_UInt32  section_offset,
FT_Bool  size_increment 
)

Definition at line 327 of file pfrload.c.

332  {
333  FT_UInt num_log_fonts;
334  FT_UInt flags;
335  FT_UInt32 offset;
336  FT_UInt32 size;
337  FT_Error error;
338 
339 
340  if ( FT_STREAM_SEEK( section_offset ) ||
341  FT_READ_USHORT( num_log_fonts ) )
342  goto Exit;
343 
344  if ( idx >= num_log_fonts )
345  return FT_THROW( Invalid_Argument );
346 
347  if ( FT_STREAM_SKIP( idx * 5 ) ||
348  FT_READ_USHORT( size ) ||
349  FT_READ_UOFF3 ( offset ) )
350  goto Exit;
351 
352  /* save logical font size and offset */
353  log_font->size = size;
354  log_font->offset = offset;
355 
356  /* now, check the rest of the table before loading it */
357  {
358  FT_Byte* p;
359  FT_Byte* limit;
360  FT_UInt local;
361 
362 
363  if ( FT_STREAM_SEEK( offset ) ||
364  FT_FRAME_ENTER( size ) )
365  goto Exit;
366 
367  p = stream->cursor;
368  limit = p + size;
369 
370  PFR_CHECK( 13 );
371 
372  log_font->matrix[0] = PFR_NEXT_LONG( p );
373  log_font->matrix[1] = PFR_NEXT_LONG( p );
374  log_font->matrix[2] = PFR_NEXT_LONG( p );
375  log_font->matrix[3] = PFR_NEXT_LONG( p );
376 
377  flags = PFR_NEXT_BYTE( p );
378 
379  local = 0;
380  if ( flags & PFR_LOG_STROKE )
381  {
382  local++;
383  if ( flags & PFR_LOG_2BYTE_STROKE )
384  local++;
385 
387  local += 3;
388  }
389  if ( flags & PFR_LOG_BOLD )
390  {
391  local++;
392  if ( flags & PFR_LOG_2BYTE_BOLD )
393  local++;
394  }
395 
396  PFR_CHECK( local );
397 
398  if ( flags & PFR_LOG_STROKE )
399  {
401  ? PFR_NEXT_SHORT( p )
402  : PFR_NEXT_BYTE( p );
403 
405  log_font->miter_limit = PFR_NEXT_LONG( p );
406  }
407 
408  if ( flags & PFR_LOG_BOLD )
409  {
410  log_font->bold_thickness = ( flags & PFR_LOG_2BYTE_BOLD )
411  ? PFR_NEXT_SHORT( p )
412  : PFR_NEXT_BYTE( p );
413  }
414 
415  if ( flags & PFR_LOG_EXTRA_ITEMS )
416  {
418  if ( error )
419  goto Fail;
420  }
421 
422  PFR_CHECK( 5 );
423  log_font->phys_size = PFR_NEXT_USHORT( p );
424  log_font->phys_offset = PFR_NEXT_ULONG( p );
425  if ( size_increment )
426  {
427  PFR_CHECK( 1 );
428  log_font->phys_size += (FT_UInt32)PFR_NEXT_BYTE( p ) << 16;
429  }
430  }
431 
432  Fail:
433  FT_FRAME_EXIT();
434 
435  Exit:
436  return error;
437 
438  Too_Short:
439  FT_ERROR(( "pfr_log_font_load: invalid logical font table\n" ));
440  error = FT_THROW( Invalid_Table );
441  goto Fail;
442  }
FT_Int32 matrix[4]
Definition: pfrtypes.h:83
int FT_Error
Definition: fttypes.h:300
#define PFR_NEXT_LONG(p)
Definition: pfrload.h:47
#define error(str)
Definition: mkdosfs.c:1605
#define PFR_LOG_STROKE
Definition: pfrtypes.h:100
#define FT_READ_UOFF3(var)
Definition: ftstream.h:311
int Fail
Definition: ehthrow.cxx:24
#define FT_READ_USHORT(var)
Definition: ftstream.h:309
#define PFR_LOG_2BYTE_STROKE
Definition: pfrtypes.h:101
GLint limit
Definition: glext.h:10326
FT_Int stroke_thickness
Definition: pfrtypes.h:85
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
FT_Int32 miter_limit
Definition: pfrtypes.h:87
FT_UInt32 phys_size
Definition: pfrtypes.h:89
unsigned int idx
Definition: utils.c:41
pfr_extra_items_skip(FT_Byte **pp, FT_Byte *limit)
Definition: pfrload.c:126
#define FT_STREAM_SKIP(distance)
Definition: ftstream.h:493
FT_UInt32 offset
Definition: pfrtypes.h:81
FT_Int bold_thickness
Definition: pfrtypes.h:86
#define PFR_CHECK
Definition: pfrload.h:40
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
static void Exit(void)
Definition: sock.c:1331
GLbitfield flags
Definition: glext.h:7161
FT_UInt32 phys_offset
Definition: pfrtypes.h:90
Definition: parse.h:22
#define PFR_LOG_2BYTE_BOLD
Definition: pfrtypes.h:103
#define FT_FRAME_EXIT()
Definition: ftstream.h:517
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
#define local
Definition: zutil.h:30
unsigned int FT_UInt
Definition: fttypes.h:231
FT_UInt32 size
Definition: pfrtypes.h:80
#define PFR_NEXT_BYTE(p)
Definition: pfrload.h:43
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:512
#define PFR_LOG_BOLD
Definition: pfrtypes.h:102
#define PFR_NEXT_USHORT(p)
Definition: pfrload.h:46
#define PFR_NEXT_ULONG(p)
Definition: pfrload.h:48
#define PFR_LOG_EXTRA_ITEMS
Definition: pfrtypes.h:104
#define PFR_LINE_JOIN_MITER
Definition: pfrtypes.h:95
GLfloat GLfloat p
Definition: glext.h:8902
#define PFR_LINE_JOIN_MASK
Definition: pfrtypes.h:98
#define PFR_NEXT_SHORT(p)
Definition: pfrload.h:45

Referenced by pfr_face_init().

◆ pfr_phy_font_done()

pfr_phy_font_done ( PFR_PhyFont  phy_font,
FT_Memory  memory 
)

Definition at line 778 of file pfrload.c.

780  {
781  FT_FREE( phy_font->font_id );
782  FT_FREE( phy_font->family_name );
783  FT_FREE( phy_font->style_name );
784 
785  FT_FREE( phy_font->vertical.stem_snaps );
786  phy_font->vertical.num_stem_snaps = 0;
787 
788  phy_font->horizontal.stem_snaps = NULL;
789  phy_font->horizontal.num_stem_snaps = 0;
790 
791  FT_FREE( phy_font->strikes );
792  phy_font->num_strikes = 0;
793  phy_font->max_strikes = 0;
794 
795  FT_FREE( phy_font->chars );
796  phy_font->num_chars = 0;
797  phy_font->chars_offset = 0;
798 
799  FT_FREE( phy_font->blue_values );
800  phy_font->num_blue_values = 0;
801 
802  {
804 
805 
806  item = phy_font->kern_items;
807  while ( item )
808  {
809  next = item->next;
810  FT_FREE( item );
811  item = next;
812  }
813  phy_font->kern_items = NULL;
814  phy_font->kern_items_tail = NULL;
815  }
816 
817  phy_font->num_kern_pairs = 0;
818  }
FT_String * style_name
Definition: pfrtypes.h:226
FT_UInt num_blue_values
Definition: pfrtypes.h:232
PFR_DimensionRec horizontal
Definition: pfrtypes.h:221
PFR_KernItem kern_items
Definition: pfrtypes.h:242
#define FT_FREE(ptr)
Definition: ftmemory.h:329
FT_String * font_id
Definition: pfrtypes.h:224
FT_UInt num_stem_snaps
Definition: pfrtypes.h:170
FT_UInt num_kern_pairs
Definition: pfrtypes.h:241
FT_UInt num_strikes
Definition: pfrtypes.h:228
FT_Int * blue_values
Definition: pfrtypes.h:233
FT_UInt max_strikes
Definition: pfrtypes.h:229
FT_Offset chars_offset
Definition: pfrtypes.h:238
FT_Int * stem_snaps
Definition: pfrtypes.h:171
PFR_KernItem * kern_items_tail
Definition: pfrtypes.h:243
FT_UInt num_chars
Definition: pfrtypes.h:237
static unsigned __int64 next
Definition: rand_nt.c:6
static ATOM item
Definition: dde.c:856
FT_String * family_name
Definition: pfrtypes.h:225
#define NULL
Definition: types.h:112
PFR_DimensionRec vertical
Definition: pfrtypes.h:222
PFR_StrikeRec * strikes
Definition: pfrtypes.h:230
PFR_Char chars
Definition: pfrtypes.h:239

Referenced by pfr_face_done().

◆ pfr_phy_font_load()

pfr_phy_font_load ( PFR_PhyFont  phy_font,
FT_Stream  stream,
FT_UInt32  offset,
FT_UInt32  size 
)

Definition at line 822 of file pfrload.c.

826  {
827  FT_Error error;
828  FT_Memory memory = stream->memory;
829  FT_UInt flags;
830  FT_ULong num_aux;
831  FT_Byte* p;
832  FT_Byte* limit;
833 
834 
835  phy_font->memory = memory;
836  phy_font->offset = offset;
837 
838  phy_font->kern_items = NULL;
839  phy_font->kern_items_tail = &phy_font->kern_items;
840 
841  if ( FT_STREAM_SEEK( offset ) ||
842  FT_FRAME_ENTER( size ) )
843  goto Exit;
844 
845  phy_font->cursor = stream->cursor;
846 
847  p = stream->cursor;
848  limit = p + size;
849 
850  PFR_CHECK( 15 );
851  phy_font->font_ref_number = PFR_NEXT_USHORT( p );
852  phy_font->outline_resolution = PFR_NEXT_USHORT( p );
853  phy_font->metrics_resolution = PFR_NEXT_USHORT( p );
854  phy_font->bbox.xMin = PFR_NEXT_SHORT( p );
855  phy_font->bbox.yMin = PFR_NEXT_SHORT( p );
856  phy_font->bbox.xMax = PFR_NEXT_SHORT( p );
857  phy_font->bbox.yMax = PFR_NEXT_SHORT( p );
858  phy_font->flags = flags = PFR_NEXT_BYTE( p );
859 
860  /* get the standard advance for non-proportional fonts */
861  if ( !(flags & PFR_PHY_PROPORTIONAL) )
862  {
863  PFR_CHECK( 2 );
864  phy_font->standard_advance = PFR_NEXT_SHORT( p );
865  }
866 
867  /* load the extra items when present */
868  if ( flags & PFR_PHY_EXTRA_ITEMS )
869  {
871  pfr_phy_font_extra_items, phy_font );
872 
873  if ( error )
874  goto Fail;
875  }
876 
877  /* In certain fonts, the auxiliary bytes contain interesting */
878  /* information. These are not in the specification but can be */
879  /* guessed by looking at the content of a few PFR0 fonts. */
880  PFR_CHECK( 3 );
881  num_aux = PFR_NEXT_ULONG( p );
882 
883  if ( num_aux > 0 )
884  {
885  FT_Byte* q = p;
886  FT_Byte* q2;
887 
888 
889  PFR_CHECK_SIZE( num_aux );
890  p += num_aux;
891 
892  while ( num_aux > 0 )
893  {
895 
896 
897  if ( q + 4 > p )
898  break;
899 
900  length = PFR_NEXT_USHORT( q );
901  if ( length < 4 || length > num_aux )
902  break;
903 
904  q2 = q + length - 2;
905  type = PFR_NEXT_USHORT( q );
906 
907  switch ( type )
908  {
909  case 1:
910  /* this seems to correspond to the font's family name, padded to */
911  /* an even number of bytes with a zero byte appended if needed */
913  &phy_font->family_name );
914  if ( error )
915  goto Exit;
916  break;
917 
918  case 2:
919  if ( q + 32 > q2 )
920  break;
921 
922  q += 10;
923  phy_font->ascent = PFR_NEXT_SHORT( q );
924  phy_font->descent = PFR_NEXT_SHORT( q );
925  phy_font->leading = PFR_NEXT_SHORT( q );
926  break;
927 
928  case 3:
929  /* this seems to correspond to the font's style name, padded to */
930  /* an even number of bytes with a zero byte appended if needed */
932  &phy_font->style_name );
933  if ( error )
934  goto Exit;
935  break;
936 
937  default:
938  ;
939  }
940 
941  q = q2;
942  num_aux -= length;
943  }
944  }
945 
946  /* read the blue values */
947  {
948  FT_UInt n, count;
949 
950 
951  PFR_CHECK( 1 );
952  phy_font->num_blue_values = count = PFR_NEXT_BYTE( p );
953 
954  PFR_CHECK( count * 2 );
955 
956  if ( FT_NEW_ARRAY( phy_font->blue_values, count ) )
957  goto Fail;
958 
959  for ( n = 0; n < count; n++ )
960  phy_font->blue_values[n] = PFR_NEXT_SHORT( p );
961  }
962 
963  PFR_CHECK( 8 );
964  phy_font->blue_fuzz = PFR_NEXT_BYTE( p );
965  phy_font->blue_scale = PFR_NEXT_BYTE( p );
966 
967  phy_font->vertical.standard = PFR_NEXT_USHORT( p );
968  phy_font->horizontal.standard = PFR_NEXT_USHORT( p );
969 
970  /* read the character descriptors */
971  {
972  FT_UInt n, count, Size;
973 
974 
975  phy_font->num_chars = count = PFR_NEXT_USHORT( p );
976  phy_font->chars_offset = offset + (FT_Offset)( p - stream->cursor );
977 
978  Size = 1 + 1 + 2;
980  Size += 1;
981 
982  if ( flags & PFR_PHY_PROPORTIONAL )
983  Size += 2;
984 
985  if ( flags & PFR_PHY_ASCII_CODE )
986  Size += 1;
987 
989  Size += 1;
990 
992  Size += 1;
993 
995 
996  if ( FT_NEW_ARRAY( phy_font->chars, count ) )
997  goto Fail;
998 
999  for ( n = 0; n < count; n++ )
1000  {
1001  PFR_Char cur = &phy_font->chars[n];
1002 
1003 
1004  cur->char_code = ( flags & PFR_PHY_2BYTE_CHARCODE )
1005  ? PFR_NEXT_USHORT( p )
1006  : PFR_NEXT_BYTE( p );
1007 
1008  cur->advance = ( flags & PFR_PHY_PROPORTIONAL )
1009  ? PFR_NEXT_SHORT( p )
1010  : phy_font->standard_advance;
1011 
1012 #if 0
1013  cur->ascii = ( flags & PFR_PHY_ASCII_CODE )
1014  ? PFR_NEXT_BYTE( p )
1015  : 0;
1016 #else
1017  if ( flags & PFR_PHY_ASCII_CODE )
1018  p += 1;
1019 #endif
1020  cur->gps_size = ( flags & PFR_PHY_2BYTE_GPS_SIZE )
1021  ? PFR_NEXT_USHORT( p )
1022  : PFR_NEXT_BYTE( p );
1023 
1024  cur->gps_offset = ( flags & PFR_PHY_3BYTE_GPS_OFFSET )
1025  ? PFR_NEXT_ULONG( p )
1026  : PFR_NEXT_USHORT( p );
1027  }
1028  }
1029 
1030  /* that's it! */
1031 
1032  Fail:
1033  FT_FRAME_EXIT();
1034 
1035  /* save position of bitmap info */
1036  phy_font->bct_offset = FT_STREAM_POS();
1037  phy_font->cursor = NULL;
1038 
1039  Exit:
1040  return error;
1041 
1042  Too_Short:
1043  error = FT_THROW( Invalid_Table );
1044  FT_ERROR(( "pfr_phy_font_load: invalid physical font table\n" ));
1045  goto Fail;
1046  }
int FT_Error
Definition: fttypes.h:300
FT_BBox bbox
Definition: pfrtypes.h:213
unsigned long FT_ULong
Definition: fttypes.h:253
FT_UInt flags
Definition: pfrtypes.h:214
FT_UInt blue_fuzz
Definition: pfrtypes.h:234
#define error(str)
Definition: mkdosfs.c:1605
static const PFR_ExtraItemRec pfr_phy_font_extra_items[]
Definition: pfrload.c:721
FT_UInt outline_resolution
Definition: pfrtypes.h:211
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define PFR_CHECK_SIZE(x)
Definition: pfrload.h:30
#define U(x)
Definition: wordpad.c:45
FT_Int standard_advance
Definition: pfrtypes.h:215
GLdouble n
Definition: glext.h:7729
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
FT_String * style_name
Definition: pfrtypes.h:226
#define PFR_PHY_2BYTE_CHARCODE
Definition: pfrtypes.h:253
int Fail
Definition: ehthrow.cxx:24
static char memory[1024 *256]
Definition: process.c:116
GLint limit
Definition: glext.h:10326
FT_Int descent
Definition: pfrtypes.h:218
FT_ULong bct_offset
Definition: pfrtypes.h:246
#define PFR_PHY_EXTRA_ITEMS
Definition: pfrtypes.h:258
FT_UInt num_blue_values
Definition: pfrtypes.h:232
#define PFR_PHY_ASCII_CODE
Definition: pfrtypes.h:255
PFR_DimensionRec horizontal
Definition: pfrtypes.h:221
static FT_Error pfr_aux_name_load(FT_Byte *p, FT_UInt len, FT_Memory memory, FT_String **astring)
Definition: pfrload.c:736
FT_UInt font_ref_number
Definition: pfrtypes.h:210
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PFR_KernItem kern_items
Definition: pfrtypes.h:242
FT_Pos yMax
Definition: ftimage.h:118
FT_Int * blue_values
Definition: pfrtypes.h:233
#define PFR_CHECK
Definition: pfrload.h:40
FT_UInt metrics_resolution
Definition: pfrtypes.h:212
GLsizeiptr size
Definition: glext.h:5919
FT_Pos xMin
Definition: ftimage.h:117
GLintptr offset
Definition: glext.h:5920
static void Exit(void)
Definition: sock.c:1331
#define PFR_PHY_PROPORTIONAL
Definition: pfrtypes.h:254
FT_UInt32 offset
Definition: pfrtypes.h:208
FT_Pos xMax
Definition: ftimage.h:118
FT_Offset chars_offset
Definition: pfrtypes.h:238
#define PFR_PHY_2BYTE_GPS_SIZE
Definition: pfrtypes.h:256
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLbitfield flags
Definition: glext.h:7161
PFR_KernItem * kern_items_tail
Definition: pfrtypes.h:243
pfr_extra_items_parse(FT_Byte **pp, FT_Byte *limit, PFR_ExtraItem item_list, FT_Pointer item_data)
Definition: pfrload.c:134
FT_Byte * cursor
Definition: pfrtypes.h:247
Definition: parse.h:22
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define FT_FRAME_EXIT()
Definition: ftstream.h:517
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
FT_UInt num_chars
Definition: pfrtypes.h:237
FxCollectionEntry * cur
#define FT_STREAM_POS()
Definition: ftstream.h:486
#define PFR_PHY_3BYTE_GPS_OFFSET
Definition: pfrtypes.h:257
FT_String * family_name
Definition: pfrtypes.h:225
unsigned int FT_UInt
Definition: fttypes.h:231
FT_Pos yMin
Definition: ftimage.h:117
#define NULL
Definition: types.h:112
#define PFR_NEXT_BYTE(p)
Definition: pfrload.h:43
PFR_DimensionRec vertical
Definition: pfrtypes.h:222
FT_Int ascent
Definition: pfrtypes.h:217
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:512
FT_Int leading
Definition: pfrtypes.h:219
FT_Memory memory
Definition: pfrtypes.h:207
#define PFR_NEXT_USHORT(p)
Definition: pfrload.h:46
#define PFR_NEXT_ULONG(p)
Definition: pfrload.h:48
FT_UInt standard
Definition: pfrtypes.h:169
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLfloat GLfloat p
Definition: glext.h:8902
FT_UInt blue_scale
Definition: pfrtypes.h:235
#define PFR_NEXT_SHORT(p)
Definition: pfrload.h:45
size_t FT_Offset
Definition: fttypes.h:324
PFR_Char chars
Definition: pfrtypes.h:239

Referenced by pfr_face_init().

Variable Documentation

◆ pfr_header_fields

const FT_Frame_Field pfr_header_fields[]
static

Definition at line 195 of file pfrload.c.

Referenced by pfr_header_load().

◆ pfr_phy_font_extra_items

const PFR_ExtraItemRec pfr_phy_font_extra_items[]
static
Initial value:
=
{
{ 0, NULL }
}
pfr_extra_item_load_stem_snaps(FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
Definition: pfrload.c:582
pfr_extra_item_load_bitmap_info(FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
Definition: pfrload.c:456
FT_Error(* PFR_ExtraItem_ParseFunc)(FT_Byte *p, FT_Byte *limit, FT_Pointer data)
Definition: pfrload.h:54
pfr_extra_item_load_kerning_pairs(FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
Definition: pfrload.c:627
#define NULL
Definition: types.h:112
pfr_extra_item_load_font_id(FT_Byte *p, FT_Byte *limit, PFR_PhyFont phy_font)
Definition: pfrload.c:556

Definition at line 721 of file pfrload.c.

Referenced by pfr_phy_font_load().