[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 37c0131: [ttdebug] Add option `-d' to select va
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 37c0131: [ttdebug] Add option `-d' to select variation font instance. |
Date: |
Fri, 24 May 2019 03:06:03 -0400 (EDT) |
branch: master
commit 37c0131a95cd5c7caf8186f8b63dbd49636f18ac
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
[ttdebug] Add option `-d' to select variation font instance.
* src/ttdebug.c: Include `ctype.h'.
(requested_pos, requested_cnt): New global variables.
(parse_design_coords): New auxiliary function.
(Usage): Updated.
(main): Handle option`-d'.
* src/ttdebug.1: Updated.
---
ChangeLog | 12 +++++++++
src/ttdebug.1 | 4 +++
src/ttdebug.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 90 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4eab9db..8a7d13f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2019-05-24 Werner Lemberg <address@hidden>
+
+ [ttdebug] Add option `-d' to select variation font instance.
+
+ * src/ttdebug.c: Include `ctype.h'.
+ (requested_pos, requested_cnt): New global variables.
+ (parse_design_coords): New auxiliary function.
+ (Usage): Updated.
+ (main): Handle option`-d'.
+
+ * src/ttdebug.1: Updated.
+
2019-05-22 Werner Lemberg <address@hidden>
[ttdebug] New key `O' to show opcode help string.
diff --git a/src/ttdebug.1 b/src/ttdebug.1
index bc1f47e..6a49f50 100644
--- a/src/ttdebug.1
+++ b/src/ttdebug.1
@@ -51,6 +51,10 @@ To access member font
(default zero) in TTCs.
.
.TP
+.BI "\-d\ \(dq" "axis1\ axis2\ .\|.\|." \(dq
+Specify the design coordinates for each variation axis at start-up.
+.
+.TP
.B \-v
Show version.
.
diff --git a/src/ttdebug.c b/src/ttdebug.c
index 76f1d52..6f62419 100644
--- a/src/ttdebug.c
+++ b/src/ttdebug.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#ifdef UNIX
@@ -78,6 +79,8 @@
static TT_GlyphSlot glyph; /* truetype glyph slot */
static FT_MM_Var *multimaster;
+ static FT_Fixed* requested_pos;
+ static unsigned int requested_cnt;
static unsigned int tt_interpreter_versions[3];
static int num_tt_interpreter_versions;
@@ -1532,6 +1535,42 @@
}
+ static void
+ parse_design_coords( char* arg )
+ {
+ unsigned int i;
+ char* s;
+
+
+ /* get number of coordinates; */
+ /* a group of non-whitespace characters is handled as one argument */
+ s = arg;
+ for ( requested_cnt = 0; *s; requested_cnt++ )
+ {
+ while ( isspace( *s ) )
+ s++;
+
+ while ( *s && !isspace( *s ) )
+ s++;
+ }
+
+ requested_pos = (FT_Fixed*)malloc( sizeof ( FT_Fixed ) * requested_cnt );
+
+ s = arg;
+ for ( i = 0; i < requested_cnt; i++ )
+ {
+ requested_pos[i] = (FT_Fixed)( strtod( s, &s ) * 65536.0 );
+ /* skip until next whitespace in case of junk */
+ /* that `strtod' doesn't handle */
+ while ( *s && !isspace( *s ) )
+ s++;
+
+ while ( isspace( *s ) )
+ s++;
+ }
+ }
+
+
/******************************************************************
*
* Function: Calc_Length
@@ -1967,18 +2006,18 @@
save_pts.n_points = pts.n_points;
save_pts.n_contours = pts.n_contours;
- save_pts.org = (FT_Vector*)malloc( 2 * sizeof( FT_F26Dot6 ) *
+ save_pts.org = (FT_Vector*)malloc( 2 * sizeof ( FT_F26Dot6 ) *
save_pts.n_points );
- save_pts.cur = (FT_Vector*)malloc( 2 * sizeof( FT_F26Dot6 ) *
+ save_pts.cur = (FT_Vector*)malloc( 2 * sizeof ( FT_F26Dot6 ) *
save_pts.n_points );
save_pts.tags = (FT_Byte*)malloc( save_pts.n_points );
save_twilight.n_points = twilight.n_points;
save_twilight.n_contours = twilight.n_contours;
- save_twilight.org = (FT_Vector*)malloc( 2 * sizeof( FT_F26Dot6 ) *
+ save_twilight.org = (FT_Vector*)malloc( 2 * sizeof ( FT_F26Dot6 ) *
save_twilight.n_points );
- save_twilight.cur = (FT_Vector*)malloc( 2 * sizeof( FT_F26Dot6 ) *
+ save_twilight.cur = (FT_Vector*)malloc( 2 * sizeof ( FT_F26Dot6 ) *
save_twilight.n_points );
save_twilight.tags = (FT_Byte*)malloc( save_twilight.n_points );
@@ -2786,9 +2825,12 @@
" size The size of the glyph in pixels (ppem).\n"
" font The TrueType font file to debug.\n"
"\n"
- " -I ver Use TT interpreter version VER.\n"
+ " -I ver Use TrueType interpreter version VER.\n"
" Available versions are %s; default is version %d.\n"
" -f idx Access font IDX if input file is a TTC (default: 0).\n"
+ " -d \"axis1 axis2 ...\"\n"
+ " Specify the design coordinates for each variation axis\n"
+ " at start-up (ignored if not a variation font).\n"
" -v Show version.\n"
"\n"
"While running, press the `?' key for help.\n"
@@ -2869,7 +2911,7 @@
while ( 1 )
{
- option = getopt( argc, argv, "I:f:v" );
+ option = getopt( argc, argv, "I:d:f:v" );
if ( option == -1 )
break;
@@ -2903,6 +2945,10 @@
}
break;
+ case 'd':
+ parse_design_coords( optarg );
+ break;
+
case 'f':
face_index = atoi( optarg );
break;
@@ -2969,6 +3015,26 @@
error = FT_Get_MM_Var( (FT_Face)face, &multimaster );
if ( error )
multimaster = NULL;
+ else
+ {
+ unsigned int n;
+
+
+ if ( requested_cnt > multimaster->num_axis )
+ requested_cnt = multimaster->num_axis;
+
+ for ( n = 0; n < requested_cnt; n++ )
+ {
+ if ( requested_pos[n] < multimaster->axis[n].minimum )
+ requested_pos[n] = multimaster->axis[n].minimum;
+ else if ( requested_pos[n] > multimaster->axis[n].maximum )
+ requested_pos[n] = multimaster->axis[n].maximum;
+ }
+
+ FT_Set_Var_Design_Coordinates( (FT_Face)face,
+ requested_cnt,
+ requested_pos );
+ }
size = (TT_Size)face->root.size;
@@ -2998,6 +3064,8 @@
FT_Done_FreeType( library );
+ free( requested_pos );
+
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 37c0131: [ttdebug] Add option `-d' to select variation font instance.,
Werner LEMBERG <=