freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 147abd3f: [ftgrid, ftstring, ftview] Option to


From: Werner Lemberg
Subject: [freetype2-demos] master 147abd3f: [ftgrid, ftstring, ftview] Option to select charmap by index.
Date: Tue, 24 Jan 2023 22:51:21 -0500 (EST)

branch: master
commit 147abd3f7a8dd61d0b67e86d95a4cef5e2de995f
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [ftgrid,ftstring,ftview] Option to select charmap by index.
    
    * src/ftcommon.c (FTDemo_Install_Font): Accept a charmap index.
    (FTDemo_Make_Encoding_Tag): Fall back on a numeric value to return.
    
    * src/ftgrid.c, src/ftstring.c, src/ftview.c (usage): Updated.
    * man/ftgrid.1, man/ftstring.1, man/ftview.1: Ditto.
---
 man/ftgrid.1   |  2 +-
 man/ftstring.1 |  2 +-
 man/ftview.1   |  2 +-
 src/ftcommon.c | 11 ++++++++---
 src/ftgrid.c   |  3 ++-
 src/ftstring.c |  3 ++-
 src/ftview.c   |  3 ++-
 7 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/man/ftgrid.1 b/man/ftgrid.1
index eec499c9..d2bf688b 100644
--- a/man/ftgrid.1
+++ b/man/ftgrid.1
@@ -73,7 +73,7 @@ Common values:
 .B ADOB
 (Adobe standard),
 .B ADBC
-(Adobe custom).
+(Adobe custom), or a numeric charmap index.
 .
 .TP
 .BI "\-a\ \(dq" "axis1\ axis2\ .\|.\|." \(dq
diff --git a/man/ftstring.1 b/man/ftstring.1
index 1ded1a62..3aa301c8 100644
--- a/man/ftstring.1
+++ b/man/ftstring.1
@@ -71,7 +71,7 @@ Common values:
 .B ADOB
 (Adobe standard),
 .B ADBC
-(Adobe custom).
+(Adobe custom), or a numeric charmap index.
 .
 .TP
 .BI \-m \ text
diff --git a/man/ftview.1 b/man/ftview.1
index 60259a0d..4ce2d15b 100644
--- a/man/ftview.1
+++ b/man/ftview.1
@@ -68,7 +68,7 @@ Common values:
 .B ADOB
 (Adobe standard),
 .B ADBC
-(Adobe custom).
+(Adobe custom), or a numeric charmap index.
 .
 .TP
 .BI \-m \ text
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 79ee02fe..914ceaf1 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -598,9 +598,10 @@
 
         font->face_index = ( j << 16 ) + i;
 
-        if ( handle-> encoding != FT_ENCODING_ORDER                      &&
-             FT_Select_Charmap( face, (FT_Encoding)handle->encoding ) ==
-                                                               FT_Err_Ok )
+        if ( handle->encoding < face->num_charmaps )
+          font->cmap_index = handle->encoding;
+        else if ( handle->encoding != FT_ENCODING_ORDER                     &&
+                  !FT_Select_Charmap( face, (FT_Encoding)handle->encoding ) )
           font->cmap_index = FT_Get_Charmap_Index( face->charmap );
         else
           font->cmap_index = face->num_charmaps;  /* FT_ENCODING_ORDER */
@@ -2038,6 +2039,10 @@
     for ( i = 0; i < 4 && s[i]; i++ )
       l = ( l << 8 ) | s[i];
 
+    /* interpret numerically if too short for a tag */
+    if ( i < 4 && !sscanf( s, "%lu", &l ) )
+      l = FT_ENCODING_ORDER;
+
     return l;
   }
 
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 885fdd8d..2d390a04 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -1690,7 +1690,8 @@
       "  -f index  Specify first index to display (default: 0).\n"
       "  -e enc    Specify encoding tag (default: no encoding).\n"
       "            Common values: `unic' (Unicode), `symb' (symbol),\n"
-      "            `ADOB' (Adobe standard), `ADBC' (Adobe custom).\n"
+      "            `ADOB' (Adobe standard), `ADBC' (Adobe custom),\n"
+      "            or a numeric charmap index.\n"
       "  -a \"axis1 axis2 ...\"\n"
       "            Specify the design coordinates for each\n"
       "            Multiple Master axis at start-up.  Implies `-n'.\n"
diff --git a/src/ftstring.c b/src/ftstring.c
index a93e9a24..a81929cf 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -688,7 +688,8 @@
       "  -r R      Use resolution R dpi (default: 72dpi).\n"
       "  -e enc    Specify encoding tag (default: Unicode).\n"
       "            Common values: `unic' (Unicode), `symb' (symbol),\n"
-      "            `ADOB' (Adobe standard), `ADBC' (Adobe custom).\n"
+      "            `ADOB' (Adobe standard), `ADBC' (Adobe custom),\n"
+      "            or a numeric charmap index.\n"
       "  -m text   Use `text' for rendering.\n"
       "\n"
       "  -v        Show version.\n"
diff --git a/src/ftview.c b/src/ftview.c
index c478f5fe..22bab2a5 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -1647,7 +1647,8 @@
       "  -f index  Specify first index to display (default: 0).\n"
       "  -e enc    Specify encoding tag (default: no encoding).\n"
       "            Common values: `unic' (Unicode), `symb' (symbol),\n"
-      "            `ADOB' (Adobe standard), `ADBC' (Adobe custom).\n"
+      "            `ADOB' (Adobe standard), `ADBC' (Adobe custom),\n"
+      "            or a numeric charmap index.\n"
       "  -m text   Use `text' for rendering.\n" );
     fprintf( stderr,
       "  -l mode   Set start-up rendering mode (0 <= mode <= %d).\n",



reply via email to

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