[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 240a8a2 3/3: [ftgrid] New option `-d' to give s
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 240a8a2 3/3: [ftgrid] New option `-d' to give start-up design coordinates. |
Date: |
Thu, 14 Jul 2016 13:03:05 +0000 (UTC) |
branch: master
commit 240a8a2fbddfeff872c608bef04108f494246808
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
[ftgrid] New option `-d' to give start-up design coordinates.
This code is similar to the one from `ftmulti'.
* src/ftgrid.c: Include `stdlib.h'.
(GridStatusRec): Add `requested_pos' and `reqested_cnt' to hold the
design coordinate data from the command line.
(event_font_change): Handle them.
(parse_cmdline): Handle option `-d'.
(usage): Document `-d'.
(main): Don't load named instances if we have start-up design
coordinates.
* src/ftgrid.1: Updated.
---
ChangeLog | 17 +++++++++++++++++
src/ftgrid.1 | 7 +++++++
src/ftgrid.c | 44 ++++++++++++++++++++++++++++++++++++++++----
3 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 180b490..06eab48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2016-07-14 Werner Lemberg <address@hidden>
+ [ftgrid] New option `-d' to give start-up design coordinates.
+
+ This code is similar to the one from `ftmulti'.
+
+ * src/ftgrid.c: Include `stdlib.h'.
+ (GridStatusRec): Add `requested_pos' and `reqested_cnt' to hold the
+ design coordinate data from the command line.
+ (event_font_change): Handle them.
+ (parse_cmdline): Handle option `-d'.
+ (usage): Document `-d'.
+ (main): Don't load named instances if we have start-up design
+ coordinates.
+
+ * src/ftgrid.1: Updated.
+
+2016-07-14 Werner Lemberg <address@hidden>
+
Prepare suppression of named instances.
No functional change.
diff --git a/src/ftgrid.1 b/src/ftgrid.1
index 9cadd51..2c08d9c 100644
--- a/src/ftgrid.1
+++ b/src/ftgrid.1
@@ -64,6 +64,13 @@ dpi (default: 72dpi).
Specify first index to display (default: 0).
.
.TP
+.BI "\-d\ \(dq" "axis1\ axis2\ .\|.\|." \(dq
+For Multiple Master or GX fonts, specify design coordinates for each axis at
+start-up.
+If this option is given, no named instances are shown.
+Ignored for all other font formats.
+.
+.TP
.B \-v
Show version.
.
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 0b33a85..5933d2e 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -16,6 +16,7 @@
#include "ftcommon.h"
#include "common.h"
#include "output.h"
+#include <stdlib.h>
/* the following header shouldn't be used in normal programs */
#include FT_INTERNAL_DEBUG_H
@@ -146,6 +147,8 @@
FT_MM_Var* mm;
char* axis_name[MAX_MM_AXES];
FT_Fixed design_pos[MAX_MM_AXES];
+ FT_Fixed requested_pos[MAX_MM_AXES];
+ FT_UInt requested_cnt;
FT_UInt current_axis;
FT_UInt used_num_axis;
@@ -203,7 +206,7 @@
FTDemo_Handle* handle )
{
FT_Size size;
- FT_Error err = FTDemo_Get_Size( handle, &size );
+ FT_Error err = FTDemo_Get_Size( handle, &size );
FT_F26Dot6 margin = 4;
@@ -1376,7 +1379,17 @@
for ( n = 0; n < status.used_num_axis; n++ )
{
- if ( FT_IS_NAMED_INSTANCE( size->face ) )
+ if ( status.requested_cnt )
+ {
+ status.design_pos[n] = n < status.requested_cnt
+ ? status.requested_pos[n]
+ : status.mm->axis[n].def;
+ if ( status.design_pos[n] < status.mm->axis[n].minimum )
+ status.design_pos[n] = status.mm->axis[n].minimum;
+ else if ( status.design_pos[n] > status.mm->axis[n].maximum )
+ status.design_pos[n] = status.mm->axis[n].maximum;
+ }
+ else if ( FT_IS_NAMED_INSTANCE( size->face ) )
status.design_pos[n] = status.mm->namedstyle[instance_index].
coords[n];
else
@@ -1804,6 +1817,9 @@
fprintf( stderr,
" -r R Use resolution R dpi (default: 72dpi).\n"
" -f index Specify first index to display (default: 0).\n"
+ " -d \"axis1 axis2 ...\"\n"
+ " Specify the design coordinates for each\n"
+ " Multiple Master axis at start-up.\n"
"\n"
" -v Show version."
"\n" );
@@ -1824,13 +1840,32 @@
while ( 1 )
{
- option = getopt( *argc, *argv, "f:h:r:vw:" );
+ option = getopt( *argc, *argv, "d:f:h:r:vw:" );
if ( option == -1 )
break;
switch ( option )
{
+ case 'd':
+ {
+ FT_UInt cnt;
+ FT_Fixed* pos = status.requested_pos;
+ char* s = optarg;
+
+
+ for ( cnt = 0; cnt < MAX_MM_AXES && *s; cnt++ )
+ {
+ pos[cnt] = (FT_Fixed)( strtod( s, &s ) * 65536.0 );
+
+ while ( *s == ' ' )
+ ++s;
+ }
+
+ status.requested_cnt = cnt;
+ }
+ break;
+
case 'f':
status.Num = atoi( optarg );
break;
@@ -1952,7 +1987,8 @@
for ( ; argc > 0; argc--, argv++ )
{
- error = FTDemo_Install_Font( handle, argv[0], 1, 0 );
+ error = FTDemo_Install_Font( handle, argv[0], 1,
+ status.requested_cnt ? 1 : 0 );
if ( error == FT_Err_Invalid_Argument )
fprintf( stderr, "skipping font `%s' without outlines\n",
argv[0] );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 240a8a2 3/3: [ftgrid] New option `-d' to give start-up design coordinates.,
Werner LEMBERG <=