ReactOS  0.4.14-dev-1007-g90d795b
afmparse.h File Reference
#include <ft2build.h>
Include dependency graph for afmparse.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  AFM_ValueRec_
 

Macros

#define AFM_MAX_ARGUMENTS   5
 

Typedefs

typedef struct AFM_ValueRec_ AFM_ValueRec
 
typedef struct AFM_ValueRec_AFM_Value
 

Enumerations

enum  AFM_ValueType_ {
  AFM_VALUE_TYPE_STRING, AFM_VALUE_TYPE_NAME, AFM_VALUE_TYPE_FIXED, AFM_VALUE_TYPE_INTEGER,
  AFM_VALUE_TYPE_BOOL, AFM_VALUE_TYPE_INDEX
}
 

Functions

FT_BEGIN_HEADER afm_parser_init (AFM_Parser parser, FT_Memory memory, FT_Byte *base, FT_Byte *limit)
 
 afm_parser_done (AFM_Parser parser)
 
 afm_parser_parse (AFM_Parser parser)
 
 afm_parser_read_vals (AFM_Parser parser, AFM_Value vals, FT_Int n)
 
 afm_parser_next_key (AFM_Parser parser, FT_Bool line, FT_Offset *len)
 

Macro Definition Documentation

◆ AFM_MAX_ARGUMENTS

#define AFM_MAX_ARGUMENTS   5

Definition at line 71 of file afmparse.h.

Typedef Documentation

◆ AFM_Value

◆ AFM_ValueRec

Enumeration Type Documentation

◆ AFM_ValueType_

Enumerator
AFM_VALUE_TYPE_STRING 
AFM_VALUE_TYPE_NAME 
AFM_VALUE_TYPE_FIXED 
AFM_VALUE_TYPE_INTEGER 
AFM_VALUE_TYPE_BOOL 
AFM_VALUE_TYPE_INDEX 

Definition at line 45 of file afmparse.h.

Function Documentation

◆ afm_parser_done()

afm_parser_done ( AFM_Parser  parser)

Definition at line 558 of file afmparse.c.

559  {
560  FT_Memory memory = parser->memory;
561 
562 
563  FT_FREE( parser->stream );
564  }
static char memory[1024 *256]
Definition: process.c:116
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
Definition: import.c:85

◆ afm_parser_init()

FT_BEGIN_HEADER afm_parser_init ( AFM_Parser  parser,
FT_Memory  memory,
FT_Byte base,
FT_Byte limit 
)

Definition at line 530 of file afmparse.c.

534  {
536  FT_Error error;
537 
538 
539  if ( FT_NEW( stream ) )
540  return error;
541 
542  stream->cursor = stream->base = base;
543  stream->limit = limit;
544 
545  /* don't skip the first line during the first call */
546  stream->status = AFM_STREAM_STATUS_EOL;
547 
548  parser->memory = memory;
549  parser->stream = stream;
550  parser->FontInfo = NULL;
551  parser->get_index = NULL;
552 
553  return FT_Err_Ok;
554  }
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
GLuint base
Definition: 3dtext.c:35
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
Definition: import.c:85
#define FT_NEW(ptr)
Definition: ftmemory.h:331

◆ afm_parser_next_key()

afm_parser_next_key ( AFM_Parser  parser,
FT_Bool  line,
FT_Offset len 
)

Definition at line 446 of file afmparse.c.

449  {
450  AFM_Stream stream = parser->stream;
451  char* key = NULL; /* make stupid compiler happy */
452 
453 
454  if ( line )
455  {
456  while ( 1 )
457  {
458  /* skip current line */
459  if ( !AFM_STATUS_EOL( stream ) )
461 
464 
465  /* skip empty line */
466  if ( !key &&
467  !AFM_STATUS_EOF( stream ) &&
469  continue;
470 
471  break;
472  }
473  }
474  else
475  {
476  while ( 1 )
477  {
478  /* skip current column */
479  while ( !AFM_STATUS_EOC( stream ) )
481 
484 
485  /* skip empty column */
486  if ( !key &&
487  !AFM_STATUS_EOF( stream ) &&
489  continue;
490 
491  break;
492  }
493  }
494 
495  if ( len )
497  : 0;
498 
499  return key;
500  }
#define AFM_STATUS_EOC(stream)
Definition: afmparse.c:83
static char * afm_stream_read_one(AFM_Stream stream)
Definition: afmparse.c:122
#define AFM_STATUS_EOF(stream)
Definition: afmparse.c:89
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define AFM_STATUS_EOL(stream)
Definition: afmparse.c:86
static char * afm_stream_read_string(AFM_Stream stream)
Definition: afmparse.c:163
Definition: parse.h:22
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
Definition: import.c:85
#define AFM_STREAM_KEY_LEN(stream, key)
Definition: afmparse.c:80
size_t FT_Offset
Definition: fttypes.h:324
Definition: path.c:41

Referenced by afm_parse_kern_data(), afm_parse_kern_pairs(), afm_parse_track_kern(), afm_parser_parse(), and afm_parser_skip_section().

◆ afm_parser_parse()

afm_parser_parse ( AFM_Parser  parser)

Definition at line 862 of file afmparse.c.

863  {
864  FT_Memory memory = parser->memory;
865  AFM_FontInfo fi = parser->FontInfo;
866  FT_Error error = FT_ERR( Syntax_Error );
867  char* key;
868  FT_Offset len;
869  FT_Int metrics_sets = 0;
870 
871 
872  if ( !fi )
873  return FT_THROW( Invalid_Argument );
874 
875  key = afm_parser_next_key( parser, 1, &len );
876  if ( !key || len != 16 ||
877  ft_strncmp( key, "StartFontMetrics", 16 ) != 0 )
878  return FT_THROW( Unknown_File_Format );
879 
880  while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
881  {
882  AFM_ValueRec shared_vals[4];
883 
884 
885  switch ( afm_tokenize( key, len ) )
886  {
888  if ( afm_parser_read_int( parser, &metrics_sets ) )
889  goto Fail;
890 
891  if ( metrics_sets != 0 && metrics_sets != 2 )
892  {
893  error = FT_THROW( Unimplemented_Feature );
894 
895  goto Fail;
896  }
897  break;
898 
899  case AFM_TOKEN_ISCIDFONT:
900  shared_vals[0].type = AFM_VALUE_TYPE_BOOL;
901  if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
902  goto Fail;
903 
904  fi->IsCIDFont = shared_vals[0].u.b;
905  break;
906 
907  case AFM_TOKEN_FONTBBOX:
908  shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
909  shared_vals[1].type = AFM_VALUE_TYPE_FIXED;
910  shared_vals[2].type = AFM_VALUE_TYPE_FIXED;
911  shared_vals[3].type = AFM_VALUE_TYPE_FIXED;
912  if ( afm_parser_read_vals( parser, shared_vals, 4 ) != 4 )
913  goto Fail;
914 
915  fi->FontBBox.xMin = shared_vals[0].u.f;
916  fi->FontBBox.yMin = shared_vals[1].u.f;
917  fi->FontBBox.xMax = shared_vals[2].u.f;
918  fi->FontBBox.yMax = shared_vals[3].u.f;
919  break;
920 
921  case AFM_TOKEN_ASCENDER:
922  shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
923  if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
924  goto Fail;
925 
926  fi->Ascender = shared_vals[0].u.f;
927  break;
928 
929  case AFM_TOKEN_DESCENDER:
930  shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
931  if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
932  goto Fail;
933 
934  fi->Descender = shared_vals[0].u.f;
935  break;
936 
938  {
939  FT_Int n = 0;
940 
941 
942  if ( afm_parser_read_int( parser, &n ) )
943  goto Fail;
944 
947  if ( error )
948  return error;
949  }
950  break;
951 
954  if ( error )
955  goto Fail;
956  /* fall through since we only support kern data */
957 
959  return FT_Err_Ok;
960 
961  default:
962  break;
963  }
964  }
965 
966  Fail:
967  FT_FREE( fi->TrackKerns );
968  fi->NumTrackKern = 0;
969 
970  FT_FREE( fi->KernPairs );
971  fi->NumKernPair = 0;
972 
973  fi->IsCIDFont = 0;
974 
975  return error;
976  }
int FT_Error
Definition: fttypes.h:300
FT_Fixed Descender
Definition: t1types.h:174
#define ft_strncmp
Definition: ftstdlib.h:89
AFM_KernPair KernPairs
Definition: t1types.h:177
FT_Bool IsCIDFont
Definition: t1types.h:171
#define error(str)
Definition: mkdosfs.c:1605
signed int FT_Int
Definition: fttypes.h:220
GLdouble n
Definition: glext.h:7729
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
afm_parser_next_key(AFM_Parser parser, FT_Bool line, FT_Offset *len)
Definition: afmparse.c:446
AFM_TrackKern TrackKerns
Definition: t1types.h:175
#define FT_THROW(e)
Definition: ftdebug.h:213
afm_parser_read_vals(AFM_Parser parser, AFM_Value vals, FT_Int n)
Definition: afmparse.c:372
FT_Pos yMax
Definition: ftimage.h:118
FT_BBox FontBBox
Definition: t1types.h:172
#define FT_FREE(ptr)
Definition: ftmemory.h:329
#define FT_ERR(e)
Definition: fttypes.h:586
FT_UInt NumKernPair
Definition: t1types.h:178
FT_Pos xMin
Definition: ftimage.h:117
static FT_Error afm_parser_skip_section(AFM_Parser parser, FT_Int n, AFM_Token end_section)
Definition: afmparse.c:832
FT_Pos xMax
Definition: ftimage.h:118
static FT_Error afm_parse_kern_data(AFM_Parser parser)
Definition: afmparse.c:790
enum AFM_ValueType_ type
Definition: afmparse.h:58
HKEY key
Definition: reg.c:42
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLsizei len
Definition: glext.h:6722
Definition: hiveinit.c:368
static FT_Error afm_parser_read_int(AFM_Parser parser, FT_Int *aint)
Definition: afmparse.c:568
FT_Pos yMin
Definition: ftimage.h:117
FT_UInt NumTrackKern
Definition: t1types.h:176
static AFM_Token afm_tokenize(const char *key, FT_Offset len)
Definition: afmparse.c:504
Definition: import.c:85
FT_Fixed Ascender
Definition: t1types.h:173
FT_UInt u
Definition: afmparse.h:64
size_t FT_Offset
Definition: fttypes.h:324
Definition: path.c:41

◆ afm_parser_read_vals()

afm_parser_read_vals ( AFM_Parser  parser,
AFM_Value  vals,
FT_Int  n 
)

Definition at line 372 of file afmparse.c.

375  {
376  AFM_Stream stream = parser->stream;
377  char* str;
378  FT_Int i;
379 
380 
381  if ( n > AFM_MAX_ARGUMENTS )
382  return 0;
383 
384  for ( i = 0; i < n; i++ )
385  {
386  FT_Offset len;
387  AFM_Value val = vals + i;
388 
389 
390  if ( val->type == AFM_VALUE_TYPE_STRING )
392  else
394 
395  if ( !str )
396  break;
397 
399 
400  switch ( val->type )
401  {
403  case AFM_VALUE_TYPE_NAME:
404  {
405  FT_Memory memory = parser->memory;
406  FT_Error error;
407 
408 
409  if ( !FT_QALLOC( val->u.s, len + 1 ) )
410  {
411  ft_memcpy( val->u.s, str, len );
412  val->u.s[len] = '\0';
413  }
414  }
415  break;
416 
418  val->u.f = PS_Conv_ToFixed( (FT_Byte**)(void*)&str,
419  (FT_Byte*)str + len, 0 );
420  break;
421 
423  val->u.i = PS_Conv_ToInt( (FT_Byte**)(void*)&str,
424  (FT_Byte*)str + len );
425  break;
426 
427  case AFM_VALUE_TYPE_BOOL:
428  val->u.b = FT_BOOL( len == 4 &&
429  !ft_strncmp( str, "true", 4 ) );
430  break;
431 
433  if ( parser->get_index )
434  val->u.i = parser->get_index( str, len, parser->user_data );
435  else
436  val->u.i = 0;
437  break;
438  }
439  }
440 
441  return i;
442  }
int FT_Error
Definition: fttypes.h:300
#define ft_strncmp
Definition: ftstdlib.h:89
#define error(str)
Definition: mkdosfs.c:1605
PS_Conv_ToFixed(FT_Byte **cursor, FT_Byte *limit, FT_Long power_ten)
Definition: psconv.c:196
signed int FT_Int
Definition: fttypes.h:220
GLdouble n
Definition: glext.h:7729
static char * afm_stream_read_one(AFM_Stream stream)
Definition: afmparse.c:122
#define FT_QALLOC(ptr, size)
Definition: ftmemory.h:316
static char memory[1024 *256]
Definition: process.c:116
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 char FT_Byte
Definition: fttypes.h:154
const WCHAR * str
GLuint GLfloat * val
Definition: glext.h:7180
static char * afm_stream_read_string(AFM_Stream stream)
Definition: afmparse.c:163
Definition: parse.h:22
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLsizei len
Definition: glext.h:6722
#define FT_BOOL(x)
Definition: fttypes.h:578
Definition: import.c:85
#define AFM_STREAM_KEY_LEN(stream, key)
Definition: afmparse.c:80
PS_Conv_ToInt(FT_Byte **cursor, FT_Byte *limit)
Definition: psconv.c:162
#define ft_memcpy
Definition: ftstdlib.h:82
#define AFM_MAX_ARGUMENTS
Definition: afmparse.h:71
size_t FT_Offset
Definition: fttypes.h:324

Referenced by afm_parse_kern_pairs(), afm_parse_track_kern(), afm_parser_parse(), and afm_parser_read_int().