30 #include FT_INTERNAL_DEBUG_H
31 #include FT_INTERNAL_STREAM_H
32 #include FT_INTERNAL_OBJECTS_H
47 #define FT_COMPONENT trace_pcfread
50 #ifdef FT_DEBUG_LEVEL_TRACE
51 static const char*
const tableNames[] =
53 "prop",
"accl",
"mtrcs",
"bmps",
"imtrcs",
54 "enc",
"swidth",
"names",
"accel"
63 #define FT_STRUCTURE PCF_TocRec
76 #define FT_STRUCTURE PCF_TableRec
101 return PCF_Err_Cannot_Open_Resource;
106 return PCF_Err_Invalid_File_Format;
109 return PCF_Err_Out_Of_Memory;
112 for ( n = 0; n < toc->
count; n++ )
124 for ( n = 0; n < toc->
count - 1; n++ )
131 for ( i = 0; i < toc->
count - 1 -
n; i++ )
139 tables[
i] = tables[i + 1];
145 if ( ( tables[i].
size > tables[i + 1].
offset ) ||
147 return PCF_Err_Invalid_Offset;
154 #ifdef FT_DEBUG_LEVEL_TRACE
158 const char*
name =
"?";
166 for ( i = 0; i < toc->
count; i++ )
168 for ( j = 0; j <
sizeof ( tableNames ) /
sizeof ( tableNames[0] );
171 name = tableNames[
j];
173 FT_TRACE4((
" %d: type=%s, format=0x%X, "
174 "size=%ld (0x%lX), offset=%ld (0x%lX)\n",
177 tables[i].
size, tables[i].size,
178 tables[i].
offset, tables[i].offset ));
192 #define PCF_METRIC_SIZE 12
198 #define FT_STRUCTURE PCF_MetricRec
215 #define FT_STRUCTURE PCF_MetricRec
228 #define PCF_COMPRESSED_METRIC_SIZE 5
234 #define FT_STRUCTURE PCF_Compressed_MetricRec
261 ? pcf_metric_msb_header
301 for ( i = 0; i < ntables; i++ )
302 if ( tables[i].type == type )
304 if ( stream->
pos > tables[i].offset )
306 error = PCF_Err_Invalid_Stream_Skip;
312 error = PCF_Err_Invalid_Stream_Skip;
316 *asize = tables[
i].size;
317 *aformat = tables[
i].format;
336 for ( i = 0; i < ntables; i++ )
337 if ( tables[i].type == type )
344 #define PCF_PROPERTY_SIZE 9
350 #define FT_STRUCTURE PCF_ParsePropertyRec
364 #define FT_STRUCTURE PCF_ParsePropertyRec
383 for ( i = 0 ; i < face->nprops && !found; i++ )
390 return properties + i - 1;
424 FT_TRACE4((
" format = %ld\n", format ));
436 FT_TRACE4((
" nprop = %d (truncate %d props)\n",
437 (
int)nprops, nprops - (
int)nprops ));
439 nprops = (
int)nprops;
444 error = PCF_Err_Invalid_Table;
453 for ( i = 0; i < nprops; i++ )
474 i = 4 - ( nprops & 3 );
477 error = PCF_Err_Invalid_Stream_Skip;
489 FT_TRACE4((
" string_size = %ld\n", string_size ));
494 error = PCF_Err_Invalid_Table;
511 for ( i = 0; i < nprops; i++ )
516 if ( ( name_offset < 0 ) ||
517 ( (
FT_ULong)name_offset > string_size ) )
519 error = PCF_Err_Invalid_Offset;
523 if (
FT_STRDUP( properties[i].
name, strings + name_offset ) )
526 FT_TRACE4((
" %s:", properties[i].name ));
530 if ( props[i].isString )
535 if ( ( value_offset < 0 ) ||
536 ( (
FT_ULong)value_offset > string_size ) )
538 error = PCF_Err_Invalid_Offset;
590 return PCF_Err_Invalid_File_Format;
607 return PCF_Err_Invalid_File_Format;
612 return PCF_Err_Invalid_Table;
616 FT_TRACE4((
" number of metrics: %d\n", nmetrics ));
622 return PCF_Err_Invalid_Table;
627 return PCF_Err_Invalid_Table;
631 return PCF_Err_Out_Of_Memory;
634 for ( i = 0; i < nmetrics; i++ )
641 "lsb=%d, rsb=%d, ascent=%d, descent=%d, swidth=%d\n",
643 ( metrics + i )->characterWidth,
644 ( metrics + i )->leftSideBearing,
645 ( metrics + i )->rightSideBearing,
646 ( metrics + i )->ascent,
647 ( metrics + i )->descent,
648 ( metrics + i )->attributes ));
696 return PCF_Err_Invalid_File_Format;
700 FT_TRACE4((
" number of bitmaps: %d\n", nbitmaps ));
704 return PCF_Err_Invalid_File_Format;
709 for ( i = 0; i < nbitmaps; i++ )
716 FT_TRACE5((
" bitmap %d: offset %ld (0x%lX)\n",
717 i, offsets[i], offsets[i] ));
733 FT_TRACE4((
" padding %d implies a size of %ld\n", i, bitmapSizes[i] ));
736 FT_TRACE4((
" %d bitmaps, padding index %ld\n",
739 FT_TRACE4((
" bitmap size = %d\n", sizebitmaps ));
743 for ( i = 0; i < nbitmaps; i++ )
746 if ( ( offsets[i] < 0 ) ||
750 " invalid offset to bitmap data of glyph %d\n", i ));
771 int firstCol, lastCol;
772 int firstRow, lastRow;
773 int nencoding, encodingOffset;
813 return PCF_Err_Invalid_File_Format;
817 FT_TRACE4((
" firstCol %d, lastCol %d, firstRow %d, lastRow %d\n",
818 firstCol, lastCol, firstRow, lastRow ));
820 nencoding = ( lastCol - firstCol + 1 ) * ( lastRow - firstRow + 1 );
823 return PCF_Err_Out_Of_Memory;
829 for ( i = 0, j = 0 ; i < nencoding; i++ )
836 if ( encodingOffset != -1 )
838 tmpEncoding[
j].
enc = ( ( ( i / ( lastCol - firstCol + 1 ) ) +
840 ( ( i % ( lastCol - firstCol + 1 ) ) +
845 FT_TRACE5((
" code %d (0x%04X): idx %d\n",
846 tmpEncoding[j].enc, tmpEncoding[j].enc,
847 tmpEncoding[j].glyph ));
857 for ( i = 0; i <
j; i++ )
859 encoding[
i].enc = tmpEncoding[
i].
enc;
860 encoding[
i].glyph = tmpEncoding[
i].
glyph;
880 #define FT_STRUCTURE PCF_AccelRec
902 #define FT_STRUCTURE PCF_AccelRec
1016 strings[2] = ( *(prop->
value.
atom) ==
'O' ||
1017 *(prop->
value.
atom) ==
'o' ) ? (
char *)
"Oblique"
1026 strings[1] = (
char *)
"Bold";
1033 strings[3] = (
char *)(prop->
value.
atom);
1039 strings[0] = (
char *)(prop->
value.
atom);
1041 for ( len = 0, nn = 0; nn < 4; nn++ )
1047 len += lengths[nn] + 1;
1053 strings[0] = (
char *)
"Regular";
1055 len = lengths[0] + 1;
1067 for ( nn = 0; nn < 4; nn++ )
1069 char*
src = strings[nn];
1085 if ( nn == 0 || nn == 3 )
1090 for ( mm = 0; mm <
len; mm++ )
1125 if ( !hasBDFAccelerators )
1148 if ( hasBDFAccelerators )
1169 if ( face->accel.constantWidth )
1199 FT_Short resolution_x = 0, resolution_y = 0;
1205 bsize->
height = face->accel.maxbounds.ascent << 6;
1208 face->accel.fontDescent );
1220 (
FT_Pos)( ( prop->
value.
l * 64 * 7200 + 36135L ) / 72270L );
1240 if ( resolution_x && resolution_y )
1241 bsize->
x_ppem = bsize->
y_ppem * resolution_x / resolution_y;
1248 PCF_Property charset_registry = 0, charset_encoding = 0;
1254 if ( charset_registry && charset_registry->
isString &&
1255 charset_encoding && charset_encoding->isString )
1258 charset_encoding->value.atom ) ||
1271 error = PCF_Err_Invalid_File_Format;
#define FT_ALLOC(ptr, size)
FT_Stream_EnterFrame(FT_Stream stream, FT_ULong count)
GLenum GLuint GLsizei const GLenum * props
FT_Short rightSideBearing
static const FT_Frame_Field pcf_property_msb_header[]
FT_BEGIN_HEADER typedef signed long FT_Pos
#define FT_READ_USHORT_LE(var)
static const FT_Frame_Field pcf_metric_msb_header[]
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
#define PCF_BDF_ENCODINGS
static const FT_Frame_Field pcf_accel_msb_header[]
#define FT_MEM_ZERO(dest, count)
#define FT_FACE_FLAG_FAST_GLYPHS
#define PCF_ACCEL_W_INKBOUNDS
static FT_Bool pcf_has_table_type(PCF_Table tables, FT_ULong ntables, FT_ULong type)
FT_BEGIN_HEADER struct PCF_TableRec_ * PCF_Table
pcf_find_property(PCF_Face face, const FT_String *prop)
FT_BEGIN_HEADER struct PCF_TableRec_ PCF_TableRec
GLuint GLsizei GLsizei GLfloat * metrics
GLuint GLsizei const GLuint const GLintptr * offsets
FT_Bitmap_Size * available_sizes
#define FT_FACE_FLAG_FIXED_SIZES
#define FT_FRAME_SHORT_LE(f)
EGLImageKHR EGLint * name
#define PCF_DEFAULT_FORMAT
#define FT_READ_USHORT(var)
PCF_MetricRec ink_maxbounds
#define FT_FRAME_ULONG_LE(f)
GLsizei const GLchar const GLint * lengths
#define PCF_BDF_ACCELERATORS
FT_BEGIN_HEADER typedef unsigned char FT_Bool
static FT_Error pcf_get_metric(FT_Stream stream, FT_ULong format, PCF_Metric metric)
static const FT_Frame_Field pcf_compressed_metric_header[]
#define PCF_COMPRESSED_METRICS
#define PCF_GLYPH_PAD_INDEX(f)
#define FT_STYLE_FLAG_BOLD
#define FT_FRAME_SKIP_BYTES(count)
#define FT_ARRAY_MAX(ptr)
union PCF_PropertyRec_::@37 value
#define FT_TRACE4(varformat)
static FT_Error pcf_get_properties(FT_Stream stream, PCF_Face face)
#define FT_STREAM_READ_FIELDS(fields, object)
#define PCF_BYTE_ORDER(f)
static FT_Error pcf_interpret_style(PCF_Face pcf)
static const FT_Frame_Field pcf_accel_header[]
#define FT_STREAM_SKIP(distance)
#define PCF_PROPERTY_SIZE
#define FT_FACE_FLAG_FIXED_WIDTH
FT_Stream_Read(FT_Stream stream, FT_Byte *buffer, FT_ULong count)
static const FT_Frame_Field pcf_property_header[]
#define FT_READ_ULONG(var)
#define FT_TRACE0(varformat)
#define FT_FACE_FLAG_HORIZONTAL
static const FT_Frame_Field pcf_table_header[]
static FT_Error pcf_get_metrics(FT_Stream stream, PCF_Face face)
GLsizei const GLchar ** strings
#define FT_GET_SHORT_LE()
static const FT_Frame_Field pcf_metric_header[]
PCF_MetricRec ink_minbounds
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
static FT_Error pcf_get_bitmaps(FT_Stream stream, PCF_Face face)
#define FT_READ_ULONG_LE(var)
#define FT_READ_LONG(var)
#define PCF_FORMAT_MATCH(a, b)
#define FT_READ_LONG_LE(var)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
#define FT_STREAM_SEEK(position)
EGLSurface EGLint void ** value
static const FT_Frame_Field pcf_toc_header[]
pcf_load_font(FT_Stream, PCF_Face)
static FT_Error pcf_read_TOC(FT_Stream stream, PCF_Face face)
#define FT_TRACE5(varformat)
static FT_Error pcf_get_accel(FT_Stream stream, PCF_Face face, FT_ULong type)
FT_Stream_ExitFrame(FT_Stream stream)
static FT_Error pcf_get_encodings(FT_Stream stream, PCF_Face face)
#define FT_STRDUP(dst, str)
static FT_Error pcf_seek_to_table_type(FT_Stream stream, PCF_Table tables, FT_ULong ntables, FT_ULong type, FT_ULong *aformat, FT_ULong *asize)
#define FT_FRAME_LONG_LE(f)
#define FT_STYLE_FLAG_ITALIC
#define FT_FRAME_SHORT(f)
#define PCF_COMPRESSED_METRIC_SIZE
#define FT_FRAME_START(size)
#define FT_GET_ULONG_LE()