freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 1bae8dc: [ftbench] Fix up charmap benchmarking.


From: Werner Lemberg
Subject: [freetype2-demos] master 1bae8dc: [ftbench] Fix up charmap benchmarking.
Date: Fri, 11 Nov 2022 11:38:55 -0500 (EST)

branch: master
commit 1bae8dcc9c88fcec28b3b6c5ffc47eb40bdb9ea4
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [ftbench] Fix up charmap benchmarking.
    
    * src/ftbench.c (main): Parse and process the charmap index option.
    (header): Report the active charmap index.
    (usage): Document it.
    (test_cmap_cache): Call `FTC_CMapCache_Lookup` with correct argument.
    (test_cmap_iter): Do not count idle charmaps.
    
    * man/ftbench.1: Document the charmap selection.
---
 man/ftbench.1 |  8 +++++++-
 src/ftbench.c | 23 ++++++++++++++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/man/ftbench.1 b/man/ftbench.1
index 65698b1..66c857e 100644
--- a/man/ftbench.1
+++ b/man/ftbench.1
@@ -72,6 +72,12 @@ Use at most
 iterations for each test (0 means time limited).
 .
 .TP
+.BI \-e \ e
+Use charmap with index
+.I e
+instead of the default unicode.
+.
+.TP
 .BI \-f \ l
 Use
 .B hexadecimal
@@ -105,7 +111,7 @@ Forward or reverse range of glyph indices to use
 (default is from 0 to the number of glyphs minus one).
 .
 .TP
-.BI \-m \ m
+.BI \-m \ M
 Set maximum cache size to
 .I M
 KiByte (default is 1024).
diff --git a/src/ftbench.c b/src/ftbench.c
index ea791b9..207f65b 100644
--- a/src/ftbench.c
+++ b/src/ftbench.c
@@ -149,6 +149,8 @@
   static int  last_index  = INT_MAX;
   static int  incr_index  = 1;
 
+  static int  cmap_index  = -1;
+
 #define FOREACH( i )  for ( i = first_index ;                          \
                             ( first_index <= i && i <= last_index ) || \
                             ( first_index >= i && i >= last_index ) ;  \
@@ -608,7 +610,7 @@
     {
       if ( FTC_CMapCache_Lookup( cmap_cache,
                                  font_type.face_id,
-                                 0,
+                                 cmap_index,
                                  charset->code[i] ) )
         done++;
     }
@@ -700,6 +702,7 @@
   {
     FT_UInt   idx;
     FT_ULong  charcode;
+    int       done;
 
     FT_UNUSED( user_data );
 
@@ -707,12 +710,14 @@
     TIMER_START( timer );
 
     charcode = FT_Get_First_Char( face, &idx );
+    done = ( idx != 0 );
+
     while ( idx != 0 )
       charcode = FT_Get_Next_Char( face, charcode, &idx );
 
     TIMER_STOP( timer );
 
-    return 1;
+    return done;
   }
 
 
@@ -889,12 +894,14 @@
             "driver: %s %s\n"
             "target: %s\n"
             " flags: 0x%X\n"
+            "  cmap: %d\n"
             "glyphs: %ld\n",
             face->family_name,
             face->style_name,
             module_name, hinting_engine,
             target,
             load_flags,
+            FT_Get_Charmap_Index( face->charmap ),
             face->num_glyphs );
   }
 
@@ -1004,6 +1011,7 @@
       "  -C        Compare with cached version (if available).\n"
       "  -c N      Use at most N iterations for each test\n"
       "            (0 means time limited).\n"
+      "  -e E      Set specific charmap index E.\n"
       "  -f L      Use hex number L as load flags (see `FT_LOAD_XXX').\n"
       "  -H NAME   Use PS hinting engine NAME.\n"
       "            Available versions are %s; default is `%s'.\n"
@@ -1141,7 +1149,7 @@
       int  opt;
 
 
-      opt = getopt( argc, argv, "b:Cc:f:H:I:i:l:m:pr:s:t:v" );
+      opt = getopt( argc, argv, "b:Cc:e:f:H:I:i:l:m:pr:s:t:v" );
 
       if ( opt == -1 )
         break;
@@ -1162,6 +1170,10 @@
           max_iter = -max_iter;
         break;
 
+      case 'e':
+        cmap_index = atoi( optarg );
+        break;
+
       case 'f':
         load_flags = strtol( optarg, NULL, 16 );
         break;
@@ -1323,6 +1335,11 @@
       putchar( '-' );
     putchar( '\n' );
 
+    if ( cmap_index >= face->num_charmaps )
+      cmap_index = -1;
+    if ( cmap_index >= 0 )
+      face->charmap = face->charmaps[cmap_index];
+
     header( face );
 
     if ( !face->num_glyphs )



reply via email to

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