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

Go to the source code of this file.

Classes

struct  AFM_StreamRec_
 

Macros

#define EOF   -1
 
#define AFM_IS_NEWLINE(ch)   ( (ch) == '\r' || (ch) == '\n' )
 
#define AFM_IS_EOF(ch)   ( (ch) == EOF || (ch) == '\x1a' )
 
#define AFM_IS_SPACE(ch)   ( (ch) == ' ' || (ch) == '\t' )
 
#define AFM_IS_SEP(ch)   ( (ch) == ';' )
 
#define AFM_GETC()
 
#define AFM_STREAM_KEY_BEGIN(stream)   (char*)( (stream)->cursor - 1 )
 
#define AFM_STREAM_KEY_LEN(stream, key)   (FT_Offset)( (char*)(stream)->cursor - key - 1 )
 
#define AFM_STATUS_EOC(stream)   ( (stream)->status >= AFM_STREAM_STATUS_EOC )
 
#define AFM_STATUS_EOL(stream)   ( (stream)->status >= AFM_STREAM_STATUS_EOL )
 
#define AFM_STATUS_EOF(stream)   ( (stream)->status >= AFM_STREAM_STATUS_EOF )
 
#define KERN_INDEX(g1, g2)   ( ( (FT_ULong)g1 << 16 ) | g2 )
 

Typedefs

typedef struct AFM_StreamRec_ AFM_StreamRec
 
typedef enum AFM_Token_ AFM_Token
 

Enumerations

enum  { AFM_STREAM_STATUS_NORMAL, AFM_STREAM_STATUS_EOC, AFM_STREAM_STATUS_EOL, AFM_STREAM_STATUS_EOF }
 
enum  AFM_Token_ {
  AFM_TOKEN_ASCENDER, AFM_TOKEN_AXISLABEL, AFM_TOKEN_AXISTYPE, AFM_TOKEN_B,
  AFM_TOKEN_BLENDAXISTYPES, AFM_TOKEN_BLENDDESIGNMAP, AFM_TOKEN_BLENDDESIGNPOSITIONS, AFM_TOKEN_C,
  AFM_TOKEN_CC, AFM_TOKEN_CH, AFM_TOKEN_CAPHEIGHT, AFM_TOKEN_CHARWIDTH,
  AFM_TOKEN_CHARACTERSET, AFM_TOKEN_CHARACTERS, AFM_TOKEN_DESCENDER, AFM_TOKEN_ENCODINGSCHEME,
  AFM_TOKEN_ENDAXIS, AFM_TOKEN_ENDCHARMETRICS, AFM_TOKEN_ENDCOMPOSITES, AFM_TOKEN_ENDDIRECTION,
  AFM_TOKEN_ENDFONTMETRICS, AFM_TOKEN_ENDKERNDATA, AFM_TOKEN_ENDKERNPAIRS, AFM_TOKEN_ENDTRACKKERN,
  AFM_TOKEN_ESCCHAR, AFM_TOKEN_FAMILYNAME, AFM_TOKEN_FONTBBOX, AFM_TOKEN_FONTNAME,
  AFM_TOKEN_FULLNAME, AFM_TOKEN_ISBASEFONT, AFM_TOKEN_ISCIDFONT, AFM_TOKEN_ISFIXEDPITCH,
  AFM_TOKEN_ISFIXEDV, AFM_TOKEN_ITALICANGLE, AFM_TOKEN_KP, AFM_TOKEN_KPH,
  AFM_TOKEN_KPX, AFM_TOKEN_KPY, AFM_TOKEN_L, AFM_TOKEN_MAPPINGSCHEME,
  AFM_TOKEN_METRICSSETS, AFM_TOKEN_N, AFM_TOKEN_NOTICE, AFM_TOKEN_PCC,
  AFM_TOKEN_STARTAXIS, AFM_TOKEN_STARTCHARMETRICS, AFM_TOKEN_STARTCOMPOSITES, AFM_TOKEN_STARTDIRECTION,
  AFM_TOKEN_STARTFONTMETRICS, AFM_TOKEN_STARTKERNDATA, AFM_TOKEN_STARTKERNPAIRS, AFM_TOKEN_STARTKERNPAIRS0,
  AFM_TOKEN_STARTKERNPAIRS1, AFM_TOKEN_STARTTRACKKERN, AFM_TOKEN_STDHW, AFM_TOKEN_STDVW,
  AFM_TOKEN_TRACKKERN, AFM_TOKEN_UNDERLINEPOSITION, AFM_TOKEN_UNDERLINETHICKNESS, AFM_TOKEN_VV,
  AFM_TOKEN_VVECTOR, AFM_TOKEN_VERSION, AFM_TOKEN_W, AFM_TOKEN_W0,
  AFM_TOKEN_W0X, AFM_TOKEN_W0Y, AFM_TOKEN_W1, AFM_TOKEN_W1X,
  AFM_TOKEN_W1Y, AFM_TOKEN_WX, AFM_TOKEN_WY, AFM_TOKEN_WEIGHT,
  AFM_TOKEN_WEIGHTVECTOR, AFM_TOKEN_XHEIGHT, N_AFM_TOKENS, AFM_TOKEN_UNKNOWN
}
 

Functions

static int afm_stream_skip_spaces (AFM_Stream stream)
 
static charafm_stream_read_one (AFM_Stream stream)
 
static charafm_stream_read_string (AFM_Stream stream)
 
 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)
 
static AFM_Token afm_tokenize (const char *key, FT_Offset len)
 
 afm_parser_init (AFM_Parser parser, FT_Memory memory, FT_Byte *base, FT_Byte *limit)
 
 afm_parser_done (AFM_Parser parser)
 
static FT_Error afm_parser_read_int (AFM_Parser parser, FT_Int *aint)
 
static FT_Error afm_parse_track_kern (AFM_Parser parser)
 
 afm_compare_kern_pairs (const void *a, const void *b)
 
static FT_Error afm_parse_kern_pairs (AFM_Parser parser)
 
static FT_Error afm_parse_kern_data (AFM_Parser parser)
 
static FT_Error afm_parser_skip_section (AFM_Parser parser, FT_Int n, AFM_Token end_section)
 
 afm_parser_parse (AFM_Parser parser)
 

Variables

static const char *const afm_key_table [N_AFM_TOKENS]
 

Macro Definition Documentation

◆ AFM_GETC

#define AFM_GETC ( )
Value:
( ( (stream)->cursor < (stream)->limit ) ? *(stream)->cursor++ \
: EOF )
#define EOF
Definition: afmparse.c:60
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
const char cursor[]
Definition: icontest.c:13

Definition at line 73 of file afmparse.c.

◆ AFM_IS_EOF

#define AFM_IS_EOF (   ch)    ( (ch) == EOF || (ch) == '\x1a' )

Definition at line 67 of file afmparse.c.

◆ AFM_IS_NEWLINE

#define AFM_IS_NEWLINE (   ch)    ( (ch) == '\r' || (ch) == '\n' )

Definition at line 65 of file afmparse.c.

◆ AFM_IS_SEP

#define AFM_IS_SEP (   ch)    ( (ch) == ';' )

Definition at line 71 of file afmparse.c.

◆ AFM_IS_SPACE

#define AFM_IS_SPACE (   ch)    ( (ch) == ' ' || (ch) == '\t' )

Definition at line 68 of file afmparse.c.

◆ AFM_STATUS_EOC

#define AFM_STATUS_EOC (   stream)    ( (stream)->status >= AFM_STREAM_STATUS_EOC )

Definition at line 83 of file afmparse.c.

◆ AFM_STATUS_EOF

#define AFM_STATUS_EOF (   stream)    ( (stream)->status >= AFM_STREAM_STATUS_EOF )

Definition at line 89 of file afmparse.c.

◆ AFM_STATUS_EOL

#define AFM_STATUS_EOL (   stream)    ( (stream)->status >= AFM_STREAM_STATUS_EOL )

Definition at line 86 of file afmparse.c.

◆ AFM_STREAM_KEY_BEGIN

#define AFM_STREAM_KEY_BEGIN (   stream)    (char*)( (stream)->cursor - 1 )

Definition at line 77 of file afmparse.c.

◆ AFM_STREAM_KEY_LEN

#define AFM_STREAM_KEY_LEN (   stream,
  key 
)    (FT_Offset)( (char*)(stream)->cursor - key - 1 )

Definition at line 80 of file afmparse.c.

◆ EOF

#define EOF   -1

Definition at line 60 of file afmparse.c.

◆ KERN_INDEX

#define KERN_INDEX (   g1,
  g2 
)    ( ( (FT_ULong)g1 << 16 ) | g2 )

Definition at line 667 of file afmparse.c.

Typedef Documentation

◆ AFM_StreamRec

◆ AFM_Token

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
AFM_STREAM_STATUS_NORMAL 
AFM_STREAM_STATUS_EOC 
AFM_STREAM_STATUS_EOL 
AFM_STREAM_STATUS_EOF 

Definition at line 39 of file afmparse.c.

◆ AFM_Token_

Enumerator
AFM_TOKEN_ASCENDER 
AFM_TOKEN_AXISLABEL 
AFM_TOKEN_AXISTYPE 
AFM_TOKEN_B 
AFM_TOKEN_BLENDAXISTYPES 
AFM_TOKEN_BLENDDESIGNMAP 
AFM_TOKEN_BLENDDESIGNPOSITIONS 
AFM_TOKEN_C 
AFM_TOKEN_CC 
AFM_TOKEN_CH 
AFM_TOKEN_CAPHEIGHT 
AFM_TOKEN_CHARWIDTH 
AFM_TOKEN_CHARACTERSET 
AFM_TOKEN_CHARACTERS 
AFM_TOKEN_DESCENDER 
AFM_TOKEN_ENCODINGSCHEME 
AFM_TOKEN_ENDAXIS 
AFM_TOKEN_ENDCHARMETRICS 
AFM_TOKEN_ENDCOMPOSITES 
AFM_TOKEN_ENDDIRECTION 
AFM_TOKEN_ENDFONTMETRICS 
AFM_TOKEN_ENDKERNDATA 
AFM_TOKEN_ENDKERNPAIRS 
AFM_TOKEN_ENDTRACKKERN 
AFM_TOKEN_ESCCHAR 
AFM_TOKEN_FAMILYNAME 
AFM_TOKEN_FONTBBOX 
AFM_TOKEN_FONTNAME 
AFM_TOKEN_FULLNAME 
AFM_TOKEN_ISBASEFONT 
AFM_TOKEN_ISCIDFONT 
AFM_TOKEN_ISFIXEDPITCH 
AFM_TOKEN_ISFIXEDV 
AFM_TOKEN_ITALICANGLE 
AFM_TOKEN_KP 
AFM_TOKEN_KPH 
AFM_TOKEN_KPX 
AFM_TOKEN_KPY 
AFM_TOKEN_L 
AFM_TOKEN_MAPPINGSCHEME 
AFM_TOKEN_METRICSSETS 
AFM_TOKEN_N 
AFM_TOKEN_NOTICE 
AFM_TOKEN_PCC 
AFM_TOKEN_STARTAXIS 
AFM_TOKEN_STARTCHARMETRICS 
AFM_TOKEN_STARTCOMPOSITES 
AFM_TOKEN_STARTDIRECTION 
AFM_TOKEN_STARTFONTMETRICS 
AFM_TOKEN_STARTKERNDATA 
AFM_TOKEN_STARTKERNPAIRS 
AFM_TOKEN_STARTKERNPAIRS0 
AFM_TOKEN_STARTKERNPAIRS1 
AFM_TOKEN_STARTTRACKKERN 
AFM_TOKEN_STDHW 
AFM_TOKEN_STDVW 
AFM_TOKEN_TRACKKERN 
AFM_TOKEN_UNDERLINEPOSITION 
AFM_TOKEN_UNDERLINETHICKNESS 
AFM_TOKEN_VV 
AFM_TOKEN_VVECTOR 
AFM_TOKEN_VERSION 
AFM_TOKEN_W 
AFM_TOKEN_W0 
AFM_TOKEN_W0X 
AFM_TOKEN_W0Y 
AFM_TOKEN_W1 
AFM_TOKEN_W1X 
AFM_TOKEN_W1Y 
AFM_TOKEN_WX 
AFM_TOKEN_WY 
AFM_TOKEN_WEIGHT 
AFM_TOKEN_WEIGHTVECTOR 
AFM_TOKEN_XHEIGHT 
N_AFM_TOKENS 
AFM_TOKEN_UNKNOWN 

Definition at line 203 of file afmparse.c.

204  {
208  AFM_TOKEN_B,
212  AFM_TOKEN_C,
213  AFM_TOKEN_CC,
214  AFM_TOKEN_CH,
239  AFM_TOKEN_KP,
243  AFM_TOKEN_L,
246  AFM_TOKEN_N,
264  AFM_TOKEN_VV,
267  AFM_TOKEN_W,
268  AFM_TOKEN_W0,
271  AFM_TOKEN_W1,
274  AFM_TOKEN_WX,
275  AFM_TOKEN_WY,
279  N_AFM_TOKENS,
281 
282  } AFM_Token;
enum AFM_Token_ AFM_Token

Function Documentation

◆ afm_compare_kern_pairs()

afm_compare_kern_pairs ( const void a,
const void b 
)

Definition at line 672 of file afmparse.c.

674  {
675  AFM_KernPair kp1 = (AFM_KernPair)a;
676  AFM_KernPair kp2 = (AFM_KernPair)b;
677 
678  FT_ULong index1 = KERN_INDEX( kp1->index1, kp1->index2 );
679  FT_ULong index2 = KERN_INDEX( kp2->index1, kp2->index2 );
680 
681 
682  if ( index1 > index2 )
683  return 1;
684  else if ( index1 < index2 )
685  return -1;
686  else
687  return 0;
688  }
struct AFM_KernPairRec_ * AFM_KernPair
unsigned long FT_ULong
Definition: fttypes.h:253
#define KERN_INDEX(g1, g2)
Definition: afmparse.c:667
FT_UInt index2
Definition: t1types.h:163
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
FT_UInt index1
Definition: t1types.h:162
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by afm_parse_kern_pairs().

◆ afm_parse_kern_data()

static FT_Error afm_parse_kern_data ( AFM_Parser  parser)
static

Definition at line 790 of file afmparse.c.

791  {
792  FT_Error error;
793  char* key;
794  FT_Offset len;
795 
796 
797  while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
798  {
799  switch ( afm_tokenize( key, len ) )
800  {
803  if ( error )
804  return error;
805  break;
806 
810  if ( error )
811  return error;
812  break;
813 
816  return FT_Err_Ok;
817 
818  case AFM_TOKEN_UNKNOWN:
819  break;
820 
821  default:
822  goto Fail;
823  }
824  }
825 
826  Fail:
827  return FT_THROW( Syntax_Error );
828  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
static FT_Error afm_parse_kern_pairs(AFM_Parser parser)
Definition: afmparse.c:692
return FT_Err_Ok
Definition: ftbbox.c:511
afm_parser_next_key(AFM_Parser parser, FT_Bool line, FT_Offset *len)
Definition: afmparse.c:446
static FT_Error afm_parse_track_kern(AFM_Parser parser)
Definition: afmparse.c:588
#define FT_THROW(e)
Definition: ftdebug.h:213
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
Definition: hiveinit.c:368
static AFM_Token afm_tokenize(const char *key, FT_Offset len)
Definition: afmparse.c:504
Definition: import.c:85
size_t FT_Offset
Definition: fttypes.h:324
Definition: path.c:41

Referenced by afm_parser_parse().

◆ afm_parse_kern_pairs()

static FT_Error afm_parse_kern_pairs ( AFM_Parser  parser)
static

Definition at line 692 of file afmparse.c.

693  {
694  AFM_FontInfo fi = parser->FontInfo;
695  AFM_KernPair kp;
696  char* key;
697  FT_Offset len;
698  int n = -1;
699  FT_Int tmp;
700 
701 
702  if ( afm_parser_read_int( parser, &tmp ) )
703  goto Fail;
704 
705  if ( tmp < 0 )
706  goto Fail;
707 
708  fi->NumKernPair = (FT_UInt)tmp;
709 
710  if ( fi->NumKernPair )
711  {
712  FT_Memory memory = parser->memory;
713  FT_Error error;
714 
715 
716  if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) )
717  return error;
718  }
719 
720  while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
721  {
723 
724 
725  switch ( token )
726  {
727  case AFM_TOKEN_KP:
728  case AFM_TOKEN_KPX:
729  case AFM_TOKEN_KPY:
730  {
731  FT_Int r;
732  AFM_ValueRec shared_vals[4];
733 
734 
735  n++;
736 
737  if ( n >= (int)fi->NumKernPair )
738  goto Fail;
739 
740  kp = fi->KernPairs + n;
741 
742  shared_vals[0].type = AFM_VALUE_TYPE_INDEX;
743  shared_vals[1].type = AFM_VALUE_TYPE_INDEX;
744  shared_vals[2].type = AFM_VALUE_TYPE_INTEGER;
745  shared_vals[3].type = AFM_VALUE_TYPE_INTEGER;
746  r = afm_parser_read_vals( parser, shared_vals, 4 );
747  if ( r < 3 )
748  goto Fail;
749 
750  /* index values can't be negative */
751  kp->index1 = shared_vals[0].u.u;
752  kp->index2 = shared_vals[1].u.u;
753  if ( token == AFM_TOKEN_KPY )
754  {
755  kp->x = 0;
756  kp->y = shared_vals[2].u.i;
757  }
758  else
759  {
760  kp->x = shared_vals[2].u.i;
761  kp->y = ( token == AFM_TOKEN_KP && r == 4 )
762  ? shared_vals[3].u.i : 0;
763  }
764  }
765  break;
766 
770  fi->NumKernPair = (FT_UInt)( n + 1 );
771  ft_qsort( fi->KernPairs, fi->NumKernPair,
774  return FT_Err_Ok;
775 
776  case AFM_TOKEN_UNKNOWN:
777  break;
778 
779  default:
780  goto Fail;
781  }
782  }
783 
784  Fail:
785  return FT_THROW( Syntax_Error );
786  }
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 * u
Definition: glfuncs.h:240
int FT_Error
Definition: fttypes.h:300
AFM_KernPair KernPairs
Definition: t1types.h:177
#define error(str)
Definition: mkdosfs.c:1605
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
signed int FT_Int
Definition: fttypes.h:220
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
#define FT_QNEW_ARRAY(ptr, count)
Definition: ftmemory.h:342
FT_UInt index2
Definition: t1types.h:163
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
#define ft_qsort
Definition: ftstdlib.h:122
#define FT_THROW(e)
Definition: ftdebug.h:213
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 token
Definition: glfuncs.h:210
afm_parser_read_vals(AFM_Parser parser, AFM_Value vals, FT_Int n)
Definition: afmparse.c:372
FT_UInt NumKernPair
Definition: t1types.h:178
enum AFM_ValueType_ type
Definition: afmparse.h:58
afm_compare_kern_pairs(const void *a, const void *b)
Definition: afmparse.c:672
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
enum AFM_Token_ AFM_Token
Definition: hiveinit.c:368
unsigned int FT_UInt
Definition: fttypes.h:231
static FT_Error afm_parser_read_int(AFM_Parser parser, FT_Int *aint)
Definition: afmparse.c:568
static AFM_Token afm_tokenize(const char *key, FT_Offset len)
Definition: afmparse.c:504
FT_UInt index1
Definition: t1types.h:162
Definition: import.c:85
FT_UInt u
Definition: afmparse.h:64
size_t FT_Offset
Definition: fttypes.h:324
Definition: path.c:41

Referenced by afm_parse_kern_data().

◆ afm_parse_track_kern()

static FT_Error afm_parse_track_kern ( AFM_Parser  parser)
static

Definition at line 588 of file afmparse.c.

589  {
590  AFM_FontInfo fi = parser->FontInfo;
591  AFM_TrackKern tk;
592  char* key;
593  FT_Offset len;
594  int n = -1;
595  FT_Int tmp;
596 
597 
598  if ( afm_parser_read_int( parser, &tmp ) )
599  goto Fail;
600 
601  if ( tmp < 0 )
602  goto Fail;
603 
604  fi->NumTrackKern = (FT_UInt)tmp;
605 
606  if ( fi->NumTrackKern )
607  {
608  FT_Memory memory = parser->memory;
609  FT_Error error;
610 
611 
612  if ( FT_QNEW_ARRAY( fi->TrackKerns, fi->NumTrackKern ) )
613  return error;
614  }
615 
616  while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
617  {
618  AFM_ValueRec shared_vals[5];
619 
620 
621  switch ( afm_tokenize( key, len ) )
622  {
623  case AFM_TOKEN_TRACKKERN:
624  n++;
625 
626  if ( n >= (int)fi->NumTrackKern )
627  goto Fail;
628 
629  tk = fi->TrackKerns + n;
630 
631  shared_vals[0].type = AFM_VALUE_TYPE_INTEGER;
632  shared_vals[1].type = AFM_VALUE_TYPE_FIXED;
633  shared_vals[2].type = AFM_VALUE_TYPE_FIXED;
634  shared_vals[3].type = AFM_VALUE_TYPE_FIXED;
635  shared_vals[4].type = AFM_VALUE_TYPE_FIXED;
636  if ( afm_parser_read_vals( parser, shared_vals, 5 ) != 5 )
637  goto Fail;
638 
639  tk->degree = shared_vals[0].u.i;
640  tk->min_ptsize = shared_vals[1].u.f;
641  tk->min_kern = shared_vals[2].u.f;
642  tk->max_ptsize = shared_vals[3].u.f;
643  tk->max_kern = shared_vals[4].u.f;
644 
645  break;
646 
650  fi->NumTrackKern = (FT_UInt)( n + 1 );
651  return FT_Err_Ok;
652 
653  case AFM_TOKEN_UNKNOWN:
654  break;
655 
656  default:
657  goto Fail;
658  }
659  }
660 
661  Fail:
662  return FT_THROW( Syntax_Error );
663  }
FT_Fixed max_kern
Definition: t1types.h:156
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
FT_Fixed min_ptsize
Definition: t1types.h:153
signed int FT_Int
Definition: fttypes.h:220
GLdouble n
Definition: glext.h:7729
#define FT_QNEW_ARRAY(ptr, count)
Definition: ftmemory.h:342
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_Fixed min_kern
Definition: t1types.h:154
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
unsigned int FT_UInt
Definition: fttypes.h:231
static FT_Error afm_parser_read_int(AFM_Parser parser, FT_Int *aint)
Definition: afmparse.c:568
FT_UInt NumTrackKern
Definition: t1types.h:176
static AFM_Token afm_tokenize(const char *key, FT_Offset len)
Definition: afmparse.c:504
FT_Fixed max_ptsize
Definition: t1types.h:155
Definition: import.c:85
FT_UInt u
Definition: afmparse.h:64
size_t FT_Offset
Definition: fttypes.h:324
Definition: path.c:41

Referenced by afm_parse_kern_data().

◆ 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()

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_int()

static FT_Error afm_parser_read_int ( AFM_Parser  parser,
FT_Int aint 
)
static

Definition at line 568 of file afmparse.c.

570  {
572 
573 
575 
576  if ( afm_parser_read_vals( parser, &val, 1 ) == 1 )
577  {
578  *aint = val.u.i;
579 
580  return FT_Err_Ok;
581  }
582  else
583  return FT_THROW( Syntax_Error );
584  }
return FT_Err_Ok
Definition: ftbbox.c:511
#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
GLuint GLfloat * val
Definition: glext.h:7180
Definition: import.c:85

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

◆ 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().

◆ afm_parser_skip_section()

static FT_Error afm_parser_skip_section ( AFM_Parser  parser,
FT_Int  n,
AFM_Token  end_section 
)
static

Definition at line 832 of file afmparse.c.

835  {
836  char* key;
837  FT_Offset len;
838 
839 
840  while ( n-- > 0 )
841  {
843  if ( !key )
844  goto Fail;
845  }
846 
847  while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
848  {
850 
851 
852  if ( token == end_section || token == AFM_TOKEN_ENDFONTMETRICS )
853  return FT_Err_Ok;
854  }
855 
856  Fail:
857  return FT_THROW( Syntax_Error );
858  }
GLdouble n
Definition: glext.h:7729
return FT_Err_Ok
Definition: ftbbox.c:511
afm_parser_next_key(AFM_Parser parser, FT_Bool line, FT_Offset *len)
Definition: afmparse.c:446
#define FT_THROW(e)
Definition: ftdebug.h:213
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 token
Definition: glfuncs.h:210
smooth NULL
Definition: ftsmooth.c:416
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
enum AFM_Token_ AFM_Token
Definition: hiveinit.c:368
static AFM_Token afm_tokenize(const char *key, FT_Offset len)
Definition: afmparse.c:504
Definition: import.c:85
size_t FT_Offset
Definition: fttypes.h:324
Definition: path.c:41

Referenced by afm_parser_parse().

◆ afm_stream_read_one()

static char* afm_stream_read_one ( AFM_Stream  stream)
static

Definition at line 122 of file afmparse.c.

123  {
124  char* str;
125 
126 
128  if ( AFM_STATUS_EOC( stream ) )
129  return NULL;
130 
132 
133  while ( 1 )
134  {
135  int ch = AFM_GETC();
136 
137 
138  if ( AFM_IS_SPACE( ch ) )
139  break;
140  else if ( AFM_IS_NEWLINE( ch ) )
141  {
142  stream->status = AFM_STREAM_STATUS_EOL;
143  break;
144  }
145  else if ( AFM_IS_SEP( ch ) )
146  {
147  stream->status = AFM_STREAM_STATUS_EOC;
148  break;
149  }
150  else if ( AFM_IS_EOF( ch ) )
151  {
152  stream->status = AFM_STREAM_STATUS_EOF;
153  break;
154  }
155  }
156 
157  return str;
158  }
#define AFM_STATUS_EOC(stream)
Definition: afmparse.c:83
#define AFM_IS_SPACE(ch)
Definition: afmparse.c:68
#define AFM_IS_NEWLINE(ch)
Definition: afmparse.c:65
#define AFM_STREAM_KEY_BEGIN(stream)
Definition: afmparse.c:77
#define AFM_GETC()
Definition: afmparse.c:73
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
#define AFM_IS_SEP(ch)
Definition: afmparse.c:71
static int afm_stream_skip_spaces(AFM_Stream stream)
Definition: afmparse.c:94
#define AFM_IS_EOF(ch)
Definition: afmparse.c:67

Referenced by afm_parser_next_key(), and afm_parser_read_vals().

◆ afm_stream_read_string()

static char* afm_stream_read_string ( AFM_Stream  stream)
static

Definition at line 163 of file afmparse.c.

164  {
165  char* str;
166 
167 
169  if ( AFM_STATUS_EOL( stream ) )
170  return NULL;
171 
173 
174  /* scan to eol */
175  while ( 1 )
176  {
177  int ch = AFM_GETC();
178 
179 
180  if ( AFM_IS_NEWLINE( ch ) )
181  {
182  stream->status = AFM_STREAM_STATUS_EOL;
183  break;
184  }
185  else if ( AFM_IS_EOF( ch ) )
186  {
187  stream->status = AFM_STREAM_STATUS_EOF;
188  break;
189  }
190  }
191 
192  return str;
193  }
#define AFM_IS_NEWLINE(ch)
Definition: afmparse.c:65
#define AFM_STREAM_KEY_BEGIN(stream)
Definition: afmparse.c:77
#define AFM_GETC()
Definition: afmparse.c:73
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define AFM_STATUS_EOL(stream)
Definition: afmparse.c:86
Definition: parse.h:22
static int afm_stream_skip_spaces(AFM_Stream stream)
Definition: afmparse.c:94
#define AFM_IS_EOF(ch)
Definition: afmparse.c:67

Referenced by afm_parser_next_key(), and afm_parser_read_vals().

◆ afm_stream_skip_spaces()

static int afm_stream_skip_spaces ( AFM_Stream  stream)
static

Definition at line 94 of file afmparse.c.

95  {
96  int ch = 0; /* make stupid compiler happy */
97 
98 
99  if ( AFM_STATUS_EOC( stream ) )
100  return ';';
101 
102  while ( 1 )
103  {
104  ch = AFM_GETC();
105  if ( !AFM_IS_SPACE( ch ) )
106  break;
107  }
108 
109  if ( AFM_IS_NEWLINE( ch ) )
110  stream->status = AFM_STREAM_STATUS_EOL;
111  else if ( AFM_IS_SEP( ch ) )
112  stream->status = AFM_STREAM_STATUS_EOC;
113  else if ( AFM_IS_EOF( ch ) )
114  stream->status = AFM_STREAM_STATUS_EOF;
115 
116  return ch;
117  }
#define AFM_STATUS_EOC(stream)
Definition: afmparse.c:83
#define AFM_IS_SPACE(ch)
Definition: afmparse.c:68
#define AFM_IS_NEWLINE(ch)
Definition: afmparse.c:65
#define AFM_GETC()
Definition: afmparse.c:73
Definition: parse.h:22
#define AFM_IS_SEP(ch)
Definition: afmparse.c:71
#define AFM_IS_EOF(ch)
Definition: afmparse.c:67

Referenced by afm_stream_read_one(), and afm_stream_read_string().

◆ afm_tokenize()

static AFM_Token afm_tokenize ( const char key,
FT_Offset  len 
)
static

Definition at line 504 of file afmparse.c.

506  {
507  int n;
508 
509 
510  for ( n = 0; n < N_AFM_TOKENS; n++ )
511  {
512  if ( *( afm_key_table[n] ) == *key )
513  {
514  for ( ; n < N_AFM_TOKENS; n++ )
515  {
516  if ( *( afm_key_table[n] ) != *key )
517  return AFM_TOKEN_UNKNOWN;
518 
519  if ( ft_strncmp( afm_key_table[n], key, len ) == 0 )
520  return (AFM_Token) n;
521  }
522  }
523  }
524 
525  return AFM_TOKEN_UNKNOWN;
526  }
static const char *const afm_key_table[N_AFM_TOKENS]
Definition: afmparse.c:285
#define ft_strncmp
Definition: ftstdlib.h:89
GLdouble n
Definition: glext.h:7729
GLenum GLsizei len
Definition: glext.h:6722
enum AFM_Token_ AFM_Token
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().

Variable Documentation

◆ afm_key_table

const char* const afm_key_table[N_AFM_TOKENS]
static

Definition at line 285 of file afmparse.c.

Referenced by afm_tokenize().