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 FT_THROW( Cannot_Open_Resource );
106 return FT_THROW( Invalid_File_Format );
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 ) ||
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
290 pcf_seek_to_table_type(
FT_Stream stream,
301 for ( i = 0; i < ntables; i++ )
304 if ( stream->
pos > tables[i].offset )
306 error =
FT_THROW( Invalid_Stream_Skip );
312 error =
FT_THROW( 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;
410 error = pcf_seek_to_table_type( stream,
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;
453 for ( i = 0; i < nprops; i++ )
474 i = 4 - ( nprops & 3 );
477 error =
FT_THROW( Invalid_Stream_Skip );
489 FT_TRACE4((
" string_size = %ld\n", string_size ));
511 for ( i = 0; i < nprops; i++ )
516 if ( ( name_offset < 0 ) ||
517 ( (
FT_ULong)name_offset > string_size ) )
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 ) )
576 error = pcf_seek_to_table_type( stream,
590 return FT_THROW( Invalid_File_Format );
607 return FT_THROW( Invalid_File_Format );
616 FT_TRACE4((
" number of metrics: %d\n", nmetrics ));
634 for ( i = 0; i < nmetrics; i++ )
636 error = pcf_get_metric( stream, format, metrics + 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 ));
674 error = pcf_seek_to_table_type( stream,
696 return FT_THROW( Invalid_File_Format );
700 FT_TRACE4((
" number of bitmaps: %d\n", nbitmaps ));
704 return FT_THROW( 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;
778 error = pcf_seek_to_table_type( stream,
813 return FT_THROW( 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 );
830 for ( i = firstRow; i <= lastRow; i++ )
832 for ( j = firstCol; j <= lastCol; j++ )
839 if ( encodingOffset != -1 )
841 encoding[k].
enc = i * 256 + j;
844 FT_TRACE5((
" code %d (0x%04X): idx %d\n",
845 encoding[k].enc, encoding[k].enc, encoding[k].glyph ));
871 #define FT_STRUCTURE PCF_AccelRec 893 #define FT_STRUCTURE PCF_AccelRec 921 error = pcf_seek_to_table_type( stream,
948 error = pcf_get_metric( stream,
954 error = pcf_get_metric( stream,
962 error = pcf_get_metric( stream,
968 error = pcf_get_metric( stream,
1007 strings[2] = ( *(prop->
value.
atom) ==
'O' ||
1008 *(prop->
value.
atom) ==
'o' ) ? (
char *)
"Oblique" 1017 strings[1] = (
char *)
"Bold";
1024 strings[3] = (
char *)(prop->
value.
atom);
1030 strings[0] = (
char *)(prop->
value.
atom);
1032 for ( len = 0, nn = 0; nn < 4; nn++ )
1038 len += lengths[nn] + 1;
1044 strings[0] = (
char *)
"Regular";
1046 len = lengths[0] + 1;
1058 for ( nn = 0; nn < 4; nn++ )
1060 char*
src = strings[nn];
1076 if ( nn == 0 || nn == 3 )
1081 for ( mm = 0; mm <
len; mm++ )
1104 error = pcf_read_TOC( stream, face );
1108 error = pcf_get_properties( stream, face );
1113 hasBDFAccelerators = pcf_has_table_type( face->
toc.
tables,
1116 if ( !hasBDFAccelerators )
1124 error = pcf_get_metrics( stream, face );
1129 error = pcf_get_bitmaps( stream, face );
1134 error = pcf_get_encodings( stream, face );
1139 if ( hasBDFAccelerators )
1163 if ( (
error = pcf_interpret_style( face ) ) != 0 )
1190 FT_Short resolution_x = 0, resolution_y = 0;
1211 (
FT_Pos)( ( prop->
value.
l * 64 * 7200 + 36135L ) / 72270L );
1231 if ( resolution_x && resolution_y )
1232 bsize->
x_ppem = bsize->
y_ppem * resolution_x / resolution_y;
1239 PCF_Property charset_registry = 0, charset_encoding = 0;
1245 if ( charset_registry && charset_registry->
isString &&
1246 charset_encoding && charset_encoding->isString )
1249 charset_encoding->value.atom ) ||
#define FT_ALLOC(ptr, size)
FT_Stream_EnterFrame(FT_Stream stream, FT_ULong count)
FT_Short rightSideBearing
FT_BEGIN_HEADER typedef signed long FT_Pos
#define FT_READ_USHORT_LE(var)
#define PCF_BDF_ENCODINGS
#define FT_MEM_ZERO(dest, count)
#define FT_FACE_FLAG_FAST_GLYPHS
#define PCF_ACCEL_W_INKBOUNDS
GLsizei const GLchar *const * strings
return FT_THROW(Missing_Property)
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
union PCF_PropertyRec_::@27 value
FT_Bitmap_Size * available_sizes
#define FT_FACE_FLAG_FIXED_SIZES
#define FT_FRAME_SHORT_LE(f)
#define PCF_DEFAULT_FORMAT
#define FT_READ_USHORT(var)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
PCF_MetricRec ink_maxbounds
#define FT_FRAME_ULONG_LE(f)
#define PCF_BDF_ACCELERATORS
FT_BEGIN_HEADER typedef unsigned char FT_Bool
GLenum GLuint GLint GLenum face
#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)
#define FT_TRACE4(varformat)
#define FT_STREAM_READ_FIELDS(fields, object)
#define PCF_BYTE_ORDER(f)
#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)
#define FT_READ_ULONG(var)
#define FT_FACE_FLAG_HORIZONTAL
#define FT_GET_SHORT_LE()
PCF_MetricRec ink_minbounds
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
#define FT_READ_ULONG_LE(var)
#define FT_READ_LONG(var)
GLsizei const GLfloat * value
#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)
GLuint const GLchar * name
if(!abbox) return FT_THROW(Invalid_Argument)
pcf_load_font(FT_Stream stream, PCF_Face face)
#define FT_TRACE5(varformat)
FT_Stream_ExitFrame(FT_Stream stream)
GLsizei GLenum GLenum GLuint GLenum GLsizei * lengths
GLuint GLuint GLsizei count
#define FT_STRDUP(dst, str)
FT_TRACE0(("cff_property_set: missing property `%s'\, property_name))
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
#define FT_FRAME_LONG_LE(f)
#define FT_STYLE_FLAG_ITALIC
#define FT_FRAME_SHORT(f)
#define PCF_COMPRESSED_METRIC_SIZE
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define FT_FRAME_START(size)
#define FT_GET_ULONG_LE()