freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master ed82906: [ftdump] New compact charmap coverage


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master ed82906: [ftdump] New compact charmap coverage format.
Date: Wed, 3 Oct 2018 21:48:05 -0400 (EDT)

branch: master
commit ed82906f795957119f1f4765546282c059f91c63
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [ftdump] New compact charmap coverage format.
    
    * src/ftdump.c (Print_Charmaps): Implement it.
    (main): Change corresponding options.
    * src/ftdump.1, src/ftdump.c (usage): Document it.
---
 ChangeLog    |  8 ++++++++
 src/ftdump.1 |  8 ++++----
 src/ftdump.c | 51 +++++++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b4536a0..3cc534b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-10-03  Alexei Podtelezhnikov  <address@hidden>
+
+       [ftdump] New compact charmap coverage format.
+
+       * src/ftdump.c (Print_Charmaps): Implement it.
+       (main): Change corresponding options.
+       * src/ftdump.1, src/ftdump.c (usage): Document it.
+
 2018-10-01  Alexei Podtelezhnikov  <address@hidden>
 
        * graph/x11/grx11.c: Remove unused fields and function.
diff --git a/src/ftdump.1 b/src/ftdump.1
index a85fdbb..07e38f9 100644
--- a/src/ftdump.1
+++ b/src/ftdump.1
@@ -25,6 +25,10 @@ This program is part of the FreeType demos package.
 .SH OPTIONS
 .
 .TP
+.B \-c, \-C
+Print charmap coverage.
+.
+.TP
 .B \-n
 Print SFNT name tables.
 .
@@ -41,10 +45,6 @@ Print SFNT table list.
 Emit UTF-8.
 .
 .TP
-.B \-V
-Be verbose.
-.
-.TP
 .B \-v
 Show version.
 .
diff --git a/src/ftdump.c b/src/ftdump.c
index af65335..c276a65 100644
--- a/src/ftdump.c
+++ b/src/ftdump.c
@@ -42,7 +42,7 @@
   static FT_Error  error;
 
   static int  comma_flag  = 0;
-  static int  verbose     = 0;
+  static int  coverage    = 0;
   static int  name_tables = 0;
   static int  bytecode    = 0;
   static int  tables      = 0;
@@ -94,11 +94,11 @@
              execname );
 
     fprintf( stderr,
+      "  -c, -C    Print charmap coverage.\n"
       "  -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"
       "  -v        Show version.\n"
       "\n" );
@@ -483,7 +483,7 @@
 
       printf ( "\n" );
 
-      if ( verbose )
+      if ( coverage == 2 )
       {
         FT_ULong   charcode;
         FT_UInt    gindex;
@@ -505,6 +505,37 @@
         }
         printf( "\n" );
       }
+      else if ( coverage == 1 )
+      {
+        FT_ULong   next, last = ~1;
+        FT_UInt    gindex;
+        FT_String  buf[8] = "     ";
+        FT_Char    r = ',';
+
+
+        FT_Set_Charmap( face, face->charmaps[i] );
+
+        next = FT_Get_First_Char( face, &gindex );
+        while ( gindex )
+        {
+          if ( next == last + 1 )
+          {
+            sprintf( buf + 1, "%04lx,", next );
+            buf[0] = r;
+            r      = '-';
+          }
+          else
+          {
+            printf( "%s%04lx", buf, next );
+            buf[0] = ','; buf[1] = '\0';
+            r      = ',';
+          }
+
+          last = next;
+          next = FT_Get_Next_Char( face, last, &gindex );
+        }
+        printf( "%s\b \n", buf );
+      }
     }
   }
 
@@ -794,13 +825,21 @@
 
     while ( 1 )
     {
-      option = getopt( argc, argv, "nptuvV" );
+      option = getopt( argc, argv, "Ccnptuv" );
 
       if ( option == -1 )
         break;
 
       switch ( option )
       {
+      case 'C':
+        coverage = 2;
+        break;
+
+      case 'c':
+        coverage = 1;
+        break;
+
       case 'n':
         name_tables = 1;
         break;
@@ -832,10 +871,6 @@
         }
         /* break; */
 
-      case 'V':
-        verbose = 1;
-        break;
-
       default:
         usage( library, execname );
         break;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]