ReactOS 0.4.16-dev-2354-g16de117
afmparse.h File Reference
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 70 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 44 of file afmparse.h.

45 {
48 AFM_VALUE_TYPE_FIXED, /* real number */
51 AFM_VALUE_TYPE_INDEX /* glyph index */
52 };
@ AFM_VALUE_TYPE_NAME
Definition: afmparse.h:47
@ AFM_VALUE_TYPE_STRING
Definition: afmparse.h:46
@ AFM_VALUE_TYPE_INDEX
Definition: afmparse.h:51
@ AFM_VALUE_TYPE_INTEGER
Definition: afmparse.h:49
@ AFM_VALUE_TYPE_BOOL
Definition: afmparse.h:50
@ AFM_VALUE_TYPE_FIXED
Definition: afmparse.h:48

Function Documentation

◆ afm_parser_done()

afm_parser_done ( AFM_Parser  parser)

Definition at line 557 of file afmparse.c.

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

◆ afm_parser_init()

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

Definition at line 529 of file afmparse.c.

533 {
536
537
538 if ( FT_NEW( stream ) )
539 return error;
540
541 stream->cursor = stream->base = base;
542 stream->limit = limit;
543
544 /* don't skip the first line during the first call */
546
547 parser->memory = memory;
548 parser->stream = stream;
549 parser->FontInfo = NULL;
550 parser->get_index = NULL;
551
552 return FT_Err_Ok;
553 }
@ AFM_STREAM_STATUS_EOL
Definition: afmparse.c:42
#define NULL
Definition: types.h:112
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_NEW(ptr)
Definition: ftmemory.h:339
int FT_Error
Definition: fttypes.h:299
GLint limit
Definition: glext.h:10326
#define error(str)
Definition: mkdosfs.c:1605
Definition: parse.h:23

◆ afm_parser_next_key()

afm_parser_next_key ( AFM_Parser  parser,
FT_Bool  line,
FT_Offset len 
)

Definition at line 445 of file afmparse.c.

448 {
449 AFM_Stream stream = parser->stream;
450 char* key = NULL; /* make stupid compiler happy */
451
452
453 if ( line )
454 {
455 while ( 1 )
456 {
457 /* skip current line */
458 if ( !AFM_STATUS_EOL( stream ) )
460
463
464 /* skip empty line */
465 if ( !key &&
468 continue;
469
470 break;
471 }
472 }
473 else
474 {
475 while ( 1 )
476 {
477 /* skip current column */
478 while ( !AFM_STATUS_EOC( stream ) )
480
483
484 /* skip empty column */
485 if ( !key &&
488 continue;
489
490 break;
491 }
492 }
493
494 if ( len )
496 : 0;
497
498 return key;
499 }
#define AFM_STREAM_KEY_LEN(stream, key)
Definition: afmparse.c:79
#define AFM_STATUS_EOC(stream)
Definition: afmparse.c:82
#define AFM_STATUS_EOF(stream)
Definition: afmparse.c:88
#define AFM_STATUS_EOL(stream)
Definition: afmparse.c:85
static char * afm_stream_read_one(AFM_Stream stream)
Definition: afmparse.c:121
static char * afm_stream_read_string(AFM_Stream stream)
Definition: afmparse.c:162
@ AFM_STREAM_STATUS_NORMAL
Definition: afmparse.c:40
size_t FT_Offset
Definition: fttypes.h:323
GLenum GLsizei len
Definition: glext.h:6722
Definition: copy.c:22
Definition: parser.c:49

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 861 of file afmparse.c.

862 {
863 FT_Memory memory = parser->memory;
864 AFM_FontInfo fi = parser->FontInfo;
865 FT_Error error = FT_ERR( Syntax_Error );
866 char* key;
868 FT_Int metrics_sets = 0;
869
870
871 if ( !fi )
872 return FT_THROW( Invalid_Argument );
873
875 if ( !key || len != 16 ||
876 ft_strncmp( key, "StartFontMetrics", 16 ) != 0 )
877 return FT_THROW( Unknown_File_Format );
878
879 while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 )
880 {
881 AFM_ValueRec shared_vals[4];
882
883
884 switch ( afm_tokenize( key, len ) )
885 {
887 if ( afm_parser_read_int( parser, &metrics_sets ) )
888 goto Fail;
889
890 if ( metrics_sets != 0 && metrics_sets != 2 )
891 {
892 error = FT_THROW( Unimplemented_Feature );
893
894 goto Fail;
895 }
896 break;
897
899 shared_vals[0].type = AFM_VALUE_TYPE_BOOL;
900 if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
901 goto Fail;
902
903 fi->IsCIDFont = shared_vals[0].u.b;
904 break;
905
907 shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
908 shared_vals[1].type = AFM_VALUE_TYPE_FIXED;
909 shared_vals[2].type = AFM_VALUE_TYPE_FIXED;
910 shared_vals[3].type = AFM_VALUE_TYPE_FIXED;
911 if ( afm_parser_read_vals( parser, shared_vals, 4 ) != 4 )
912 goto Fail;
913
914 fi->FontBBox.xMin = shared_vals[0].u.f;
915 fi->FontBBox.yMin = shared_vals[1].u.f;
916 fi->FontBBox.xMax = shared_vals[2].u.f;
917 fi->FontBBox.yMax = shared_vals[3].u.f;
918 break;
919
921 shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
922 if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
923 goto Fail;
924
925 fi->Ascender = shared_vals[0].u.f;
926 break;
927
929 shared_vals[0].type = AFM_VALUE_TYPE_FIXED;
930 if ( afm_parser_read_vals( parser, shared_vals, 1 ) != 1 )
931 goto Fail;
932
933 fi->Descender = shared_vals[0].u.f;
934 break;
935
937 {
938 FT_Int n = 0;
939
940
941 if ( afm_parser_read_int( parser, &n ) )
942 goto Fail;
943
946 if ( error )
947 return error;
948 }
949 break;
950
953 if ( error )
954 goto Fail;
955 /* we only support kern data, so ... */
956 /* fall through */
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 }
static FT_Error afm_parser_skip_section(AFM_Parser parser, FT_Int n, AFM_Token end_section)
Definition: afmparse.c:831
static FT_Error afm_parse_kern_data(AFM_Parser parser)
Definition: afmparse.c:789
afm_parser_read_vals(AFM_Parser parser, AFM_Value vals, FT_Int n)
Definition: afmparse.c:371
static FT_Error afm_parser_read_int(AFM_Parser parser, FT_Int *aint)
Definition: afmparse.c:567
@ AFM_TOKEN_STARTKERNDATA
Definition: afmparse.c:253
@ AFM_TOKEN_ASCENDER
Definition: afmparse.c:204
@ AFM_TOKEN_FONTBBOX
Definition: afmparse.c:230
@ AFM_TOKEN_STARTCHARMETRICS
Definition: afmparse.c:249
@ AFM_TOKEN_DESCENDER
Definition: afmparse.c:218
@ AFM_TOKEN_ENDCHARMETRICS
Definition: afmparse.c:221
@ AFM_TOKEN_ENDFONTMETRICS
Definition: afmparse.c:224
@ AFM_TOKEN_ISCIDFONT
Definition: afmparse.c:234
@ AFM_TOKEN_METRICSSETS
Definition: afmparse.c:244
afm_parser_next_key(AFM_Parser parser, FT_Bool line, FT_Offset *len)
Definition: afmparse.c:445
static AFM_Token afm_tokenize(const char *key, FT_Offset len)
Definition: afmparse.c:503
int Fail
Definition: ehthrow.cxx:24
#define FT_THROW(e)
Definition: ftdebug.h:243
#define ft_strncmp
Definition: ftstdlib.h:89
#define FT_ERR(e)
Definition: fttypes.h:599
signed int FT_Int
Definition: fttypes.h:220
GLdouble n
Definition: glext.h:7729
FT_Fixed Ascender
Definition: t1types.h:175
AFM_KernPair KernPairs
Definition: t1types.h:179
FT_Fixed Descender
Definition: t1types.h:176
FT_Bool IsCIDFont
Definition: t1types.h:173
FT_UInt NumKernPair
Definition: t1types.h:180
AFM_TrackKern TrackKerns
Definition: t1types.h:177
FT_UInt NumTrackKern
Definition: t1types.h:178
FT_BBox FontBBox
Definition: t1types.h:174
FT_UInt u
Definition: afmparse.h:63
enum AFM_ValueType_ type
Definition: afmparse.h:57
FT_Pos xMin
Definition: ftimage.h:120
FT_Pos yMax
Definition: ftimage.h:121
FT_Pos yMin
Definition: ftimage.h:120
FT_Pos xMax
Definition: ftimage.h:121

◆ afm_parser_read_vals()

afm_parser_read_vals ( AFM_Parser  parser,
AFM_Value  vals,
FT_Int  n 
)

Definition at line 371 of file afmparse.c.

374 {
375 AFM_Stream stream = parser->stream;
376 char* str;
377 FT_Int i;
378
379
380 if ( n > AFM_MAX_ARGUMENTS )
381 return 0;
382
383 for ( i = 0; i < n; i++ )
384 {
386 AFM_Value val = vals + i;
387
388
389 if ( val->type == AFM_VALUE_TYPE_STRING )
391 else
393
394 if ( !str )
395 break;
396
398
399 switch ( val->type )
400 {
403 {
404 FT_Memory memory = parser->memory;
406
407
408 if ( !FT_QALLOC( val->u.s, len + 1 ) )
409 {
410 ft_memcpy( val->u.s, str, len );
411 val->u.s[len] = '\0';
412 }
413 }
414 break;
415
417 val->u.f = PS_Conv_ToFixed( (FT_Byte**)(void*)&str,
418 (FT_Byte*)str + len, 0 );
419 break;
420
422 val->u.i = PS_Conv_ToInt( (FT_Byte**)(void*)&str,
423 (FT_Byte*)str + len );
424 break;
425
427 val->u.b = FT_BOOL( len == 4 &&
428 !ft_strncmp( str, "true", 4 ) );
429 break;
430
432 if ( parser->get_index )
433 val->u.i = parser->get_index( str, len, parser->user_data );
434 else
435 val->u.i = 0;
436 break;
437 }
438 }
439
440 return i;
441 }
#define AFM_MAX_ARGUMENTS
Definition: afmparse.h:70
#define FT_QALLOC(ptr, size)
Definition: ftmemory.h:324
#define ft_memcpy
Definition: ftstdlib.h:82
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_BOOL(x)
Definition: fttypes.h:591
GLuint GLfloat * val
Definition: glext.h:7180
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
PS_Conv_ToInt(FT_Byte **cursor, FT_Byte *limit)
Definition: psconv.c:161
PS_Conv_ToFixed(FT_Byte **cursor, FT_Byte *limit, FT_Long power_ten)
Definition: psconv.c:195
const WCHAR * str

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