[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 23ea418 2/2: [ftview, ftstring, ftgrid] Change
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master 23ea418 2/2: [ftview, ftstring, ftgrid] Change dimension options. |
Date: |
Wed, 23 May 2018 22:17:04 -0400 (EDT) |
branch: master
commit 23ea4188ad1af4bc307fe2409ddf34b521cafa96
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
[ftview, ftstring, ftgrid] Change dimension options.
* src/ftcommon.[hc] (FTDemo_Dispay_New): Use single dimension string as
an argument, parse it, and initialize accordingly.
* src/ftgrid.c (usage, parse_cmdline, status): Use single dimension
string option.
* src/ftstring.c (usage, parse_cmdline, status): Ditto.
* src/ftview.c (usage, parse_cmdline, status): Ditto, rename variable
axis option.
* src/ftdiff.c, src/ftgamma.c: Updated.
---
ChangeLog | 15 +++++++++++++++
src/ftcommon.c | 35 +++++++++++++++++++++++++++--------
src/ftcommon.h | 7 ++-----
src/ftdiff.c | 11 ++++-------
src/ftgamma.c | 7 ++++---
src/ftgrid.c | 37 +++++++++++--------------------------
src/ftstring.c | 33 +++++++++------------------------
src/ftview.c | 34 ++++++++++------------------------
8 files changed, 82 insertions(+), 97 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cf8eae0..31ae55d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2018-05-23 Alexei Podtelezhnikov <address@hidden>
+ [ftview, ftstring, ftgrid] Change dimension options.
+
+ * src/ftcommon.[hc] (FTDemo_Dispay_New): Use single dimension string as
+ an argument, parse it, and initialize accordingly.
+
+ * src/ftgrid.c (usage, parse_cmdline, status): Use single dimension
+ string option.
+ * src/ftstring.c (usage, parse_cmdline, status): Ditto.
+ * src/ftview.c (usage, parse_cmdline, status): Ditto, rename variable
+ axis option.
+
+ * src/ftdiff.c, src/ftgamma.c: Updated.
+
+2018-05-23 Alexei Podtelezhnikov <address@hidden>
+
* Makefile [unixdev]: Uncouple harfbuzz and libpng.
2018-05-21 Alexei Podtelezhnikov <address@hidden>
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 5dfa45b..b8780ff 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -95,21 +95,39 @@
FTDemo_Display*
- FTDemo_Display_New( grPixelMode mode,
- int width,
- int height )
+ FTDemo_Display_New( const char* dims )
{
FTDemo_Display* display;
+ grPixelMode mode;
grSurface* surface;
grBitmap bit;
+ int width, height, depth = 24;
- display = (FTDemo_Display *)malloc( sizeof ( FTDemo_Display ) );
- if ( !display )
+ if ( sscanf( dims, "%dx%dx%d", &width, &height, &depth ) < 2 )
return NULL;
- if ( mode != gr_pixel_mode_gray &&
- mode != gr_pixel_mode_rgb24 )
+ switch ( depth )
+ {
+ case 8:
+ mode = gr_pixel_mode_gray;
+ break;
+ case 15:
+ mode = gr_pixel_mode_rgb555;
+ break;
+ case 16:
+ mode = gr_pixel_mode_rgb565;
+ break;
+ case 32:
+ mode = gr_pixel_mode_rgb32;
+ break;
+ default:
+ mode = gr_pixel_mode_rgb24;
+ break;
+ }
+
+ display = (FTDemo_Display *)malloc( sizeof ( FTDemo_Display ) );
+ if ( !display )
return NULL;
grInitDevices();
@@ -810,7 +828,8 @@
sprintf( buf, "gamma: sRGB" );
else
sprintf( buf, "gamma = %.1f", display->gamma );
- grWriteCellString( display->bitmap, DIM_X - 8 * 11, line * HEADER_HEIGHT,
+ grWriteCellString( display->bitmap,
+ display->bitmap->width - 8 * 11, line * HEADER_HEIGHT,
buf, display->fore_color );
line++;
diff --git a/src/ftcommon.h b/src/ftcommon.h
index 02605c9..e793de6 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -59,8 +59,7 @@
/* default window dimensions */
-#define DIM_X 640
-#define DIM_Y 480
+#define DIM "640x480"
/* baseline distance between header lines */
#define HEADER_HEIGHT 12
@@ -88,9 +87,7 @@
FTDemo_Display*
- FTDemo_Display_New( grPixelMode mode,
- int width,
- int height );
+ FTDemo_Display_New( const char* dims );
void
diff --git a/src/ftdiff.c b/src/ftdiff.c
index 930d569..afc9d99 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -52,11 +52,8 @@
" `.afm' or `.pfm').\n"
"\n" );
fprintf( stderr,
- " -w W Set the window width to W pixels (default: %dpx).\n"
- " -h H Set the window height to H pixels (default: %dpx).\n"
- "\n",
- DIM_X, DIM_Y );
- fprintf( stderr,
+ " -w W Set the window width to W pixels (default: 640px).\n"
+ " -h H Set the window height to H pixels (default: 480px).\n"
" -r R Use resolution R dpi (default: 72dpi).\n"
" -s S Set character size to S points (default: 16pt).\n"
" -f TEXTFILE Change displayed text, using text in TEXTFILE\n"
@@ -1505,8 +1502,8 @@
ADisplayRec adisplay[1];
RenderStateRec state[1];
DisplayRec display[1];
- int width = DIM_X;
- int height = DIM_Y;
+ int width = 640;
+ int height = 480;
int resolution = -1;
double size = -1;
const char* textfile = NULL;
diff --git a/src/ftgamma.c b/src/ftgamma.c
index 80eee46..693e04e 100644
--- a/src/ftgamma.c
+++ b/src/ftgamma.c
@@ -366,7 +366,7 @@
char buf[4];
int i;
- display = FTDemo_Display_New( gr_pixel_mode_rgb24, DIM_X, DIM_Y );
+ display = FTDemo_Display_New( DIM );
if ( !display )
{
PanicZ( "could not allocate display surface" );
@@ -412,8 +412,9 @@
display->fore_color );
}
- grWriteCellString( display->bitmap, DIM_X / 2 - 20, 410, "Gamma",
- display->fore_color );
+ grWriteCellString( display->bitmap,
+ display->bitmap->width / 2 - 20, 410,
+ "Gamma", display->fore_color );
grRefreshSurface( display->surface );
grListenSurface( display->surface, 0, &event );
diff --git a/src/ftgrid.c b/src/ftgrid.c
index cf55ecd..2990317 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -95,8 +95,7 @@
typedef struct GridStatusRec_
{
- int width;
- int height;
+ const char* dims;
int ptsize;
int res;
@@ -163,8 +162,7 @@
static void
grid_status_init( GridStatus st )
{
- st->width = DIM_X;
- st->height = DIM_Y;
+ st->dims = DIM;
st->res = 72;
st->scale = 64;
@@ -1843,17 +1841,13 @@
" `.afm' or `.pfm').\n"
"\n" );
fprintf( stderr,
- " -w W Set the window width to W pixels (default: %dpx).\n"
- " -h H Set the window height to H pixels (default: %dpx).\n"
- "\n",
- DIM_X, DIM_Y );
- fprintf( stderr,
+ " -d WxHxD Set the window width, height, and color depth.\n"
" -r R Use resolution R dpi (default: 72dpi).\n"
" -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"
- " -d \"axis1 axis2 ...\"\n"
+ " -a \"axis1 axis2 ...\"\n"
" Specify the design coordinates for each\n"
" Multiple Master axis at start-up. Implies `-n'.\n"
" -n Don't display named instances of variation fonts.\n"
@@ -1877,14 +1871,14 @@
while ( 1 )
{
- option = getopt( *argc, *argv, "d:e:f:h:nr:vw:" );
+ option = getopt( *argc, *argv, "a:d:e:f:nr:v" );
if ( option == -1 )
break;
switch ( option )
{
- case 'd':
+ case 'a':
{
FT_UInt cnt;
FT_Fixed* pos = status.requested_pos;
@@ -1904,6 +1898,10 @@
}
break;
+ case 'd':
+ status.dims = optarg;
+ break;
+
case 'e':
handle->encoding = FTDemo_Make_Encoding_Tag( optarg );
status.Num = 0x20;
@@ -1913,12 +1911,6 @@
status.Num = atoi( optarg );
break;
- case 'h':
- status.height = atoi( optarg );
- if ( status.height < 1 )
- usage( execname );
- break;
-
case 'n':
status.no_named_instances = 1;
break;
@@ -1944,12 +1936,6 @@
}
/* break; */
- case 'w':
- status.width = atoi( optarg );
- if ( status.width < 1 )
- usage( execname );
- break;
-
default:
usage( execname );
break;
@@ -2038,8 +2024,7 @@
if ( handle->num_fonts == 0 )
Fatal( "could not find/open any font file" );
- display = FTDemo_Display_New( gr_pixel_mode_rgb24,
- status.width, status.height );
+ display = FTDemo_Display_New( status.dims );
if ( !display )
Fatal( "could not allocate display surface" );
diff --git a/src/ftstring.c b/src/ftstring.c
index c275c15..0abbe14 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -80,8 +80,7 @@
static struct status_
{
- int width;
- int height;
+ const char* dims;
int render_mode;
unsigned long encoding;
@@ -98,8 +97,7 @@
char* header;
char header_buffer[256];
- } status = { DIM_X, DIM_Y,
- RENDER_MODE_STRING, FT_ENCODING_UNICODE, 72, 48, 0, NULL,
+ } status = { DIM, RENDER_MODE_STRING, FT_ENCODING_UNICODE, 72, 48, 0, NULL,
{ 0, 0, 0x8000, 0, NULL },
{ 0 }, { 0, 0, 0, 0 }, 0, NULL, { 0 } };
@@ -562,11 +560,7 @@
" `.afm' or `.pfm').\n"
"\n" );
fprintf( stderr,
- " -w W Set the window width to W pixels (default: %dpx).\n"
- " -h H Set the window height to H pixels (default: %dpx).\n"
- "\n",
- DIM_X, DIM_Y );
- fprintf( stderr,
+ " -d WxHxD Set the window width, height, and color depth.\n"
" -r R Use resolution R dpi (default: 72dpi).\n"
" -e enc Specify encoding tag (default: no encoding).\n"
" Common values: `unic' (Unicode), `symb' (symbol),\n"
@@ -592,21 +586,19 @@
while ( 1 )
{
- option = getopt( *argc, *argv, "e:h:m:r:vw:" );
+ option = getopt( *argc, *argv, "d:e:h:m:r:v" );
if ( option == -1 )
break;
switch ( option )
{
- case 'e':
- status.encoding = FTDemo_Make_Encoding_Tag( optarg );
+ case 'd':
+ status.dims = optarg;
break;
- case 'h':
- status.height = atoi( optarg );
- if ( status.height < 1 )
- usage( execname );
+ case 'e':
+ status.encoding = FTDemo_Make_Encoding_Tag( optarg );
break;
case 'm':
@@ -636,12 +628,6 @@
}
/* break; */
- case 'w':
- status.width = atoi( optarg );
- if ( status.width < 1 )
- usage( execname );
- break;
-
default:
usage( execname );
break;
@@ -698,8 +684,7 @@
if ( handle->num_fonts == 0 )
PanicZ( "could not open any font file" );
- display = FTDemo_Display_New( gr_pixel_mode_rgb24,
- status.width, status.height );
+ display = FTDemo_Display_New( status.dims );
if ( !display )
PanicZ( "could not allocate display surface" );
diff --git a/src/ftview.c b/src/ftview.c
index c8c816b..2430b49 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -96,8 +96,7 @@
{
int update;
- int width;
- int height;
+ const char* dims;
int render_mode;
int res;
@@ -127,7 +126,7 @@
int fw_idx;
} status = { 1,
- DIM_X, DIM_Y, RENDER_MODE_ALL,
+ DIM, RENDER_MODE_ALL,
72, 48, 1, 0.04, 0.04, 0.02, 0.22,
0, 0, 0, { 0 }, 0, 0, 0, /* default values are set at runtime */
0, 0, 0, 0, 0,
@@ -586,7 +585,7 @@
have_topleft = 0;
- pt_height = 64 * 72 * status.height / status.res;
+ pt_height = 64 * 72 * display->bitmap->rows / status.res;
step = ( mid_size * mid_size / pt_height + 64 ) & ~63;
pt_size = mid_size - step * ( mid_size / step ); /* remainder */
@@ -1632,11 +1631,7 @@
" `.afm' or `.pfm').\n"
"\n" );
fprintf( stderr,
- " -w W Set the window width to W pixels (default: %dpx).\n"
- " -h H Set the window height to H pixels (default: %dpx).\n"
- "\n",
- DIM_X, DIM_Y );
- fprintf( stderr,
+ " -d WxHxD Set the window width, height, and color depth.\n"
" -r R Use resolution R dpi (default: 72dpi).\n"
" -f index Specify first index to display (default: 0).\n"
" -e enc Specify encoding tag (default: no encoding).\n"
@@ -1668,13 +1663,17 @@
while ( 1 )
{
- option = getopt( *argc, *argv, "e:f:h:l:m:pr:vw:" );
+ option = getopt( *argc, *argv, "d:e:f:l:m:pr:v" );
if ( option == -1 )
break;
switch ( option )
{
+ case 'd':
+ status.dims = optarg;
+ break;
+
case 'e':
handle->encoding = FTDemo_Make_Encoding_Tag( optarg );
break;
@@ -1683,12 +1682,6 @@
status.offset = atoi( optarg );
break;
- case 'h':
- status.height = atoi( optarg );
- if ( status.height < 1 )
- usage( execname );
- break;
-
case 'l':
status.lcd_idx = atoi( optarg );
if ( status.lcd_idx < 0 || status.lcd_idx >= N_LCD_IDXS )
@@ -1730,12 +1723,6 @@
}
/* break; */
- case 'w':
- status.width = atoi( optarg );
- if ( status.width < 1 )
- usage( execname );
- break;
-
default:
usage( execname );
break;
@@ -1819,8 +1806,7 @@
if ( handle->num_fonts == 0 )
Fatal( "could not find/open any font file" );
- display = FTDemo_Display_New( gr_pixel_mode_rgb24,
- status.width, status.height );
+ display = FTDemo_Display_New( status.dims );
if ( !display )
Fatal( "could not allocate display surface" );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 23ea418 2/2: [ftview, ftstring, ftgrid] Change dimension options.,
Alexei Podtelezhnikov <=