[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master c9b1ece: [ftdump] List SFNT tables.
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master c9b1ece: [ftdump] List SFNT tables. |
Date: |
Sat, 24 Jun 2017 13:33:42 -0400 (EDT) |
branch: master
commit c9b1ece3cb8af14953c83083726c7be590efa319
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
[ftdump] List SFNT tables.
* src/ftdump.c (Print_Sfnt_Tables): New feature, list SFNT tables with
their first 4 bytes with version for some tables.
(usage, main): Updated.
* src/ftdump.1: Updated
---
ChangeLog | 10 ++++++++++
src/ftcommon.c | 24 +++++++++++++++++-------
src/ftdump.1 | 4 ++++
src/ftdump.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
4 files changed, 85 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f17114d..1c313f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-06-24 Alexei Podtelezhnikov <address@hidden>
+
+ [ftdump] List SFNT tables.
+
+ * src/ftdump.c (Print_Sfnt_Tables): New feature, list SFNT tables with
+ their first 4 bytes with version for some tables.
+ (usage, main): Updated.
+
+ * src/ftdump.1: Updated
+
2017-06-22 Werner Lemberg <address@hidden>
[compos] Make it compile.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 4aed753..bdb3904 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -899,18 +899,28 @@
if ( FT_HAS_GLYPH_NAMES( face ) )
{
- unsigned int glyph_idx;
+ char* p;
+ const char* format = ", name: ";
+ unsigned int format_len, glyph_idx;
- x += sprintf( buf + x, ", name: " );
+ p = buf + x;
+ x = 256 - x;
- glyph_idx = (unsigned int)idx;
- if ( handle->encoding != FT_ENCODING_ORDER )
- glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)idx );
+ format_len = strlen( format );
- FT_Get_Glyph_Name( face, glyph_idx, buf + x, 256 - x );
+ if ( x >= (signed int)format_len + 2 )
+ {
+ glyph_idx = (unsigned int)idx;
+ if ( handle->encoding != FT_ENCODING_ORDER )
+ glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)idx );
+
+ strcpy( p, format );
+ if ( FT_Get_Glyph_Name( face, glyph_idx,
+ p + format_len, x - format_len ) )
+ *p = '\0';
+ }
}
-
grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
buf, display->fore_color );
}
diff --git a/src/ftdump.1 b/src/ftdump.1
index 34dcee8..a0a05c8 100644
--- a/src/ftdump.1
+++ b/src/ftdump.1
@@ -33,6 +33,10 @@ Print SFNT name tables.
Print TrueType programs.
.
.TP
+.B \-t
+Print SFNT table list.
+.
+.TP
.B \-u
Emit UTF-8.
.
diff --git a/src/ftdump.c b/src/ftdump.c
index 5e4bd27..be9e874 100644
--- a/src/ftdump.c
+++ b/src/ftdump.c
@@ -2,7 +2,7 @@
/* */
/* The FreeType project -- a free and portable quality TrueType renderer. */
/* */
-/* Copyright 1996-2000, 2003-2007, 2010, 2012-2013 */
+/* Copyright 1996-2017 */
/* D. Turner, R.Wilhelm, and W. Lemberg */
/* */
/****************************************************************************/
@@ -39,6 +39,7 @@
static int verbose = 0;
static int name_tables = 0;
static int bytecode = 0;
+ static int tables = 0;
static int utf8 = 0;
@@ -83,6 +84,7 @@
fprintf( stderr,
" -n Print SFNT name tables.\n"
" -p Print TrueType programs.\n"
+ " -t Print SFNT table list.\n"
" -u Emit UTF8.\n"
" -V Be verbose.\n"
"\n"
@@ -368,6 +370,43 @@
static void
+ Print_Sfnt_Tables( FT_Face face )
+ {
+ FT_ULong num_tables, i;
+ FT_ULong tag, length;
+ FT_Byte buffer[4];
+
+
+ FT_Sfnt_Table_Info( face, 0, NULL, &num_tables );
+
+ printf( "font tables (%lu)\n", num_tables );
+
+ for ( i = 0; i < num_tables; i++ )
+ {
+ FT_Sfnt_Table_Info( face, (FT_UInt)i, &tag, &length );
+
+ if ( length >= 4 )
+ {
+ length = 4;
+ FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
+ }
+ else
+ continue;
+
+ printf( " %2lu: %c%c%c%c %02X%02X%02X%02X...\n", i,
+ (FT_Char)( tag >> 24 ),
+ (FT_Char)( tag >> 16 ),
+ (FT_Char)( tag >> 8 ),
+ (FT_Char)( tag ),
+ (FT_UInt)buffer[0],
+ (FT_UInt)buffer[1],
+ (FT_UInt)buffer[2],
+ (FT_UInt)buffer[3] );
+ }
+ }
+
+
+ static void
Print_Fixed( FT_Face face )
{
int i;
@@ -401,7 +440,7 @@
active = FT_Get_Charmap_Index( face->charmap );
/* CharMaps */
- printf( "charmaps\n" );
+ printf( "charmaps (%d)\n", face->num_charmaps );
for( i = 0; i < face->num_charmaps; i++ )
{
@@ -410,13 +449,13 @@
if ( format >= 0 )
- printf( " %d: format %2ld, platform %u, encoding %2u",
+ printf( " %2d: format %2ld, platform %u, encoding %2u",
i,
format,
face->charmaps[i]->platform_id,
face->charmaps[i]->encoding_id );
else
- printf( " %d: synthetic, platform %u, encoding %2u",
+ printf( " %2d: synthetic, platform %u, encoding %2u",
i,
face->charmaps[i]->platform_id,
face->charmaps[i]->encoding_id );
@@ -737,7 +776,7 @@
while ( 1 )
{
- option = getopt( argc, argv, "npuvV" );
+ option = getopt( argc, argv, "nptuvV" );
if ( option == -1 )
break;
@@ -752,6 +791,10 @@
bytecode = 1;
break;
+ case 't':
+ tables = 1;
+ break;
+
case 'u':
utf8 = 1;
break;
@@ -849,6 +892,12 @@
Print_Sfnt_Names( face );
}
+ if ( tables && FT_IS_SFNT( face ) )
+ {
+ printf( "\n" );
+ Print_Sfnt_Tables( face );
+ }
+
if ( bytecode && FT_IS_SFNT( face ) )
{
printf( "\n" );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master c9b1ece: [ftdump] List SFNT tables.,
Alexei Podtelezhnikov <=