ReactOS 0.4.15-dev-7942-gd23573b
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.

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

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 }
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static char memory[1024 *256]
Definition: process.c:116
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 530 of file afmparse.c.

534 {
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 */
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 }
@ AFM_STREAM_STATUS_EOL
Definition: afmparse.c:43
#define NULL
Definition: types.h:112
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_NEW(ptr)
Definition: ftmemory.h:331
int FT_Error
Definition: fttypes.h:300
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 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 &&
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 &&
489 continue;
490
491 break;
492 }
493 }
494
495 if ( len )
497 : 0;
498
499 return key;
500 }
#define AFM_STREAM_KEY_LEN(stream, key)
Definition: afmparse.c:80
#define AFM_STATUS_EOC(stream)
Definition: afmparse.c:83
#define AFM_STATUS_EOF(stream)
Definition: afmparse.c:89
#define AFM_STATUS_EOL(stream)
Definition: afmparse.c:86
static char * afm_stream_read_one(AFM_Stream stream)
Definition: afmparse.c:122
@ AFM_STREAM_STATUS_NORMAL
Definition: afmparse.c:41
static char * afm_stream_read_string(AFM_Stream stream)
Definition: afmparse.c:163
size_t FT_Offset
Definition: fttypes.h:324
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 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;
869 FT_Int metrics_sets = 0;
870
871
872 if ( !fi )
873 return FT_THROW( Invalid_Argument );
874
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
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
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
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
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 }
static FT_Error afm_parser_skip_section(AFM_Parser parser, FT_Int n, AFM_Token end_section)
Definition: afmparse.c:832
static FT_Error afm_parse_kern_data(AFM_Parser parser)
Definition: afmparse.c:790
afm_parser_read_vals(AFM_Parser parser, AFM_Value vals, FT_Int n)
Definition: afmparse.c:372
static FT_Error afm_parser_read_int(AFM_Parser parser, FT_Int *aint)
Definition: afmparse.c:568
@ AFM_TOKEN_STARTKERNDATA
Definition: afmparse.c:254
@ AFM_TOKEN_ASCENDER
Definition: afmparse.c:205
@ AFM_TOKEN_FONTBBOX
Definition: afmparse.c:231
@ AFM_TOKEN_STARTCHARMETRICS
Definition: afmparse.c:250
@ AFM_TOKEN_DESCENDER
Definition: afmparse.c:219
@ AFM_TOKEN_ENDCHARMETRICS
Definition: afmparse.c:222
@ AFM_TOKEN_ENDFONTMETRICS
Definition: afmparse.c:225
@ AFM_TOKEN_ISCIDFONT
Definition: afmparse.c:235
@ AFM_TOKEN_METRICSSETS
Definition: afmparse.c:245
afm_parser_next_key(AFM_Parser parser, FT_Bool line, FT_Offset *len)
Definition: afmparse.c:446
static AFM_Token afm_tokenize(const char *key, FT_Offset len)
Definition: afmparse.c:504
int Fail
Definition: ehthrow.cxx:24
#define FT_THROW(e)
Definition: ftdebug.h:213
#define ft_strncmp
Definition: ftstdlib.h:89
#define FT_ERR(e)
Definition: fttypes.h:586
signed int FT_Int
Definition: fttypes.h:220
GLdouble n
Definition: glext.h:7729
FT_Fixed Ascender
Definition: t1types.h:173
AFM_KernPair KernPairs
Definition: t1types.h:177
FT_Fixed Descender
Definition: t1types.h:174
FT_Bool IsCIDFont
Definition: t1types.h:171
FT_UInt NumKernPair
Definition: t1types.h:178
AFM_TrackKern TrackKerns
Definition: t1types.h:175
FT_UInt NumTrackKern
Definition: t1types.h:176
FT_BBox FontBBox
Definition: t1types.h:172
FT_UInt u
Definition: afmparse.h:64
enum AFM_ValueType_ type
Definition: afmparse.h:58
FT_Pos xMin
Definition: ftimage.h:117
FT_Pos yMax
Definition: ftimage.h:118
FT_Pos yMin
Definition: ftimage.h:117
FT_Pos xMax
Definition: ftimage.h:118

◆ 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 {
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 {
404 {
405 FT_Memory memory = parser->memory;
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
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 }
#define AFM_MAX_ARGUMENTS
Definition: afmparse.h:71
#define FT_QALLOC(ptr, size)
Definition: ftmemory.h:316
#define ft_memcpy
Definition: ftstdlib.h:82
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_BOOL(x)
Definition: fttypes.h:578
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:162
PS_Conv_ToFixed(FT_Byte **cursor, FT_Byte *limit, FT_Long power_ten)
Definition: psconv.c:196
const WCHAR * str

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