[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 5728f90: [ftgrid, ftstring, ftview] Further top
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master 5728f90: [ftgrid, ftstring, ftview] Further top header consolidation. |
Date: |
Thu, 1 Jun 2017 22:34:26 -0400 (EDT) |
branch: master
commit 5728f90e89602abcb43ce731cfd99f3b7afcdcc0
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
[ftgrid, ftstring, ftview] Further top header consolidation.
* src/ftview.c (event_encoding_change): Update `handle'.
(write_header): Move instance, encoding, and the first glyph code
reporting from here...
* src/ftgrid.c (write_header): ... and from here...
* src/ftcommon.c (FTDemo_Draw_Header): ... to here.
* src/ftcommon.h (FTDemo_Draw_Header): Update prototype.
* src/ftstring.c (write_header): Updated.
---
ChangeLog | 12 +++++
src/ftcommon.c | 110 ++++++++++++++++++++++++++++++++++++++++++--
src/ftcommon.h | 1 +
src/ftgrid.c | 54 ++++------------------
src/ftstring.c | 2 +-
src/ftview.c | 143 ++++++---------------------------------------------------
6 files changed, 141 insertions(+), 181 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8d5e905..d4f0744 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-06-01 Alexei Podtelezhnikov <address@hidden>
+
+ [ftgrid, ftstring, ftview] Further top header consolidation.
+
+ * src/ftview.c (event_encoding_change): Update `handle'.
+ (write_header): Move instance, encoding, and the first glyph code
+ reporting from here...
+ * src/ftgrid.c (write_header): ... and from here...
+ * src/ftcommon.c (FTDemo_Draw_Header): ... to here.
+ * src/ftcommon.h (FTDemo_Draw_Header): Update prototype.
+ * src/ftstring.c (write_header): Updated.
+
2017-05-29 Alexei Podtelezhnikov <address@hidden>
[ftgrid, ftstring, ftview] Migrate gamma to `FTDemo_Display'.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index ea6eb93..6561a8c 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -746,6 +746,7 @@
FTDemo_Display* display,
int ptsize,
int res,
+ int idx,
int error_code )
{
FT_Face face;
@@ -773,9 +774,16 @@
grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
buf, display->fore_color );
- /* pt and dpi */
- x = sprintf( buf, "%gpt at %ddpi ",
- ptsize / 64.0, res );
+ /* instance, pt and dpi */
+ if ( face->face_index >> 16 )
+ x = sprintf( buf, "instance %ld/%ld, %gpt at %ddpi ",
+ face->face_index >> 16,
+ face->style_flags >> 16,
+ ptsize / 64.0, res );
+ else
+ x = sprintf( buf, "%gpt at %ddpi ",
+ ptsize / 64.0, res );
+
grWriteCellString( display->bitmap, 0, line * HEADER_HEIGHT,
buf, display->fore_color );
@@ -795,7 +803,7 @@
else
sprintf( buf, "(%dppem)",
face->size->metrics.y_ppem );
- grWriteCellString( display->bitmap, 8 * x, line * HEADER_HEIGHT,
+ grWriteCellString( display->bitmap, 8 * x, line++ * HEADER_HEIGHT,
buf, highlight ? display->warn_color
: display->fore_color );
}
@@ -818,6 +826,100 @@
buf, display->warn_color );
}
+ /* encoding charcode or glyph index, glyph name */
+ if ( idx >= 0 )
+ {
+ const char* encoding = NULL;
+
+
+ switch ( handle->encoding )
+ {
+ case FT_ENCODING_NONE:
+ encoding = "glyph order";
+ break;
+ case FT_ENCODING_MS_SYMBOL:
+ encoding = "MS Symbol";
+ break;
+ case FT_ENCODING_UNICODE:
+ encoding = "Unicode";
+ break;
+ case FT_ENCODING_SJIS:
+ encoding = "SJIS";
+ break;
+ case FT_ENCODING_PRC:
+ encoding = "PRC";
+ break;
+ case FT_ENCODING_BIG5:
+ encoding = "Big5";
+ break;
+ case FT_ENCODING_WANSUNG:
+ encoding = "Wansung";
+ break;
+ case FT_ENCODING_JOHAB:
+ encoding = "Johab";
+ break;
+ case FT_ENCODING_ADOBE_STANDARD:
+ encoding = "Adobe Standard";
+ break;
+ case FT_ENCODING_ADOBE_EXPERT:
+ encoding = "Adobe Expert";
+ break;
+ case FT_ENCODING_ADOBE_CUSTOM:
+ encoding = "Adobe Custom";
+ break;
+ case FT_ENCODING_ADOBE_LATIN_1:
+ encoding = "Latin 1";
+ break;
+ case FT_ENCODING_OLD_LATIN_2:
+ encoding = "Latin 2";
+ break;
+ case FT_ENCODING_APPLE_ROMAN:
+ encoding = "Apple Roman";
+ break;
+ default:
+ encoding = "Other";
+ }
+
+ if ( handle->encoding == FT_ENCODING_NONE )
+ x = sprintf( buf, "%s idx: %d",
+ encoding, idx );
+ else if ( handle->encoding == FT_ENCODING_UNICODE )
+ x = sprintf( buf, "%s charcode: U+%04X (glyph idx %d)",
+ encoding, idx,
+ FTDemo_Get_Index( handle, (FT_UInt32)idx ) );
+ else
+ x = sprintf( buf, "%s charcode: 0x%X (glyph idx %d)",
+ encoding, idx,
+ FTDemo_Get_Index( handle, (FT_UInt32)idx ) );
+
+ if ( FT_HAS_GLYPH_NAMES( face ) )
+ {
+ char* p;
+ const char* format = ", name: ";
+ unsigned int format_len, glyph_idx;
+
+
+ p = buf + x;
+ x = 256 - x;
+
+ format_len = strlen( format );
+
+ if ( x >= format_len + 2 )
+ {
+ glyph_idx = (unsigned int)idx;
+ if ( handle->encoding != FT_ENCODING_NONE )
+ glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)idx );
+
+ strcpy( p, format );
+ if ( FT_Get_Glyph_Name( face, glyph_idx,
+ p + format_len, x - format_len ) )
+ *p = '\0';
+ }
+ }
+ grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
+ buf, display->fore_color );
+ }
+
/* gamma */
if ( display->gamma == 0.0 )
sprintf( buf, "gamma: sRGB" );
diff --git a/src/ftcommon.h b/src/ftcommon.h
index bc598a3..b2f4522 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -267,6 +267,7 @@
FTDemo_Display* display,
int ptsize,
int res,
+ int idx,
int error_code );
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 191ce2f..c014249 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -1700,67 +1700,29 @@
static void
write_header( FT_Error error_code )
{
- FT_Face face;
- const char* format;
-
-
FTDemo_Draw_Header( handle, display, status.ptsize, status.res,
- error_code );
+ status.Num, error_code );
if ( status.header )
grWriteCellString( display->bitmap, 0, 3 * HEADER_HEIGHT,
status.header, display->fore_color );
- error = FTC_Manager_LookupFace( handle->cache_manager,
- handle->scaler.face_id, &face );
- if ( error )
- Fatal( "can't access font file" );
-
if ( status.mm )
{
- format = "%s axis: %.02f, glyph %d";
+ const char* format = "%s axis: %.02f";
+
+
snprintf( status.header_buffer, BUFSIZE, format,
status.axis_name[status.current_axis]
? status.axis_name[status.current_axis]
: status.mm->axis[status.current_axis].name,
- status.design_pos[status.current_axis] / 65536.0,
- status.Num );
- }
- else
- {
- format = "glyph %d";
- snprintf( status.header_buffer, BUFSIZE, format,
- status.Num );
- }
+ status.design_pos[status.current_axis] / 65536.0 );
- if ( FT_HAS_GLYPH_NAMES( face ) )
- {
- char* p;
- unsigned int format_len, gindex, size;
-
-
- size = strlen( status.header_buffer );
- p = status.header_buffer + size;
- size = BUFSIZE - size;
-
- format = ": ";
- format_len = strlen( format );
-
- if ( size >= format_len + 2 )
- {
- gindex = (unsigned int)status.Num;
-
- strcpy( p, format );
- if ( FT_Get_Glyph_Name( face, gindex,
- p + format_len, size - format_len ) )
- *p = '\0';
- }
+ status.header = (const char *)status.header_buffer;
+ grWriteCellString( display->bitmap, 0, 4 * HEADER_HEIGHT,
+ status.header, display->fore_color );
}
- status.header = (const char *)status.header_buffer;
- grWriteCellString( display->bitmap, 0, 2 * HEADER_HEIGHT,
- status.header, display->fore_color );
-
grRefreshSurface( display->surface );
}
diff --git a/src/ftstring.c b/src/ftstring.c
index f201974..49b7214 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -524,7 +524,7 @@
write_header( FT_Error error_code )
{
FTDemo_Draw_Header( handle, display, status.ptsize, status.res,
- error_code );
+ -1, error_code );
if ( status.header )
grWriteCellString( display->bitmap, 0, 2 * HEADER_HEIGHT,
diff --git a/src/ftview.c b/src/ftview.c
index 2891ed0..a6cd6e7 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -1025,6 +1025,8 @@
font->num_indices = 0x10000L;
}
+ handle->encoding = status.encoding;
+
return 1;
}
@@ -1371,137 +1373,14 @@
static void
write_header( FT_Error error_code )
{
- FT_Face face;
- char buf[256];
- const char* format;
-
- int line = 2;
+ char buf[256];
+ int line = 4;
FTDemo_Draw_Header( handle, display, status.ptsize, status.res,
- error_code );
-
- error = FTC_Manager_LookupFace( handle->cache_manager,
- handle->scaler.face_id, &face );
- if ( error )
- Fatal( "can't access font file" );
-
- /* char code, glyph index, glyph name */
- if ( status.encoding == FT_ENCODING_UNICODE ||
- status.render_mode == RENDER_MODE_TEXT ||
- status.render_mode == RENDER_MODE_WATERFALL )
- sprintf( buf, "top left charcode: U+%04X (glyph idx %d)",
- status.topleft,
- FTDemo_Get_Index( handle, (FT_UInt32)status.topleft ) );
- else if ( status.encoding == FT_ENCODING_NONE )
- sprintf( buf, "top left glyph idx: %d",
- status.topleft );
- else
- sprintf( buf, "top left charcode: 0x%X (glyph idx %d)",
- status.topleft,
- FTDemo_Get_Index( handle, (FT_UInt32)status.topleft ) );
-
- if ( FT_HAS_GLYPH_NAMES( face ) )
- {
- char* p;
- unsigned int format_len, glyph_idx, size;
-
-
- size = strlen( buf );
- p = buf + size;
- size = 256 - size;
-
- format = ", name: ";
- format_len = strlen( format );
-
- if ( size >= format_len + 2 )
- {
- glyph_idx = (unsigned int)status.topleft;
- if ( status.encoding != FT_ENCODING_NONE ||
- status.render_mode == RENDER_MODE_TEXT ||
- status.render_mode == RENDER_MODE_WATERFALL )
- glyph_idx = FTDemo_Get_Index( handle, (FT_UInt32)status.topleft );
-
- strcpy( p, format );
- if ( FT_Get_Glyph_Name( face, glyph_idx,
- p + format_len, size - format_len ) )
- *p = '\0';
- }
- }
- grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
- buf, display->fore_color );
-
- line++;
-
- if ( face->face_index >> 16 )
- {
- sprintf( buf, "instance %ld/%ld",
- face->face_index >> 16,
- face->style_flags >> 16 );
-
- grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
- buf, display->fore_color );
- }
- else
- line++;
-
- /* encoding */
- if ( !( status.render_mode == RENDER_MODE_TEXT ||
- status.render_mode == RENDER_MODE_WATERFALL ) )
- {
- const char* encoding = NULL;
-
-
- switch ( status.encoding )
- {
- case FT_ENCODING_NONE:
- encoding = "glyph order";
- break;
- case FT_ENCODING_MS_SYMBOL:
- encoding = "MS Symbol";
- break;
- case FT_ENCODING_UNICODE:
- encoding = "Unicode";
- break;
- case FT_ENCODING_SJIS:
- encoding = "SJIS";
- break;
- case FT_ENCODING_PRC:
- encoding = "PRC";
- break;
- case FT_ENCODING_BIG5:
- encoding = "Big5";
- break;
- case FT_ENCODING_WANSUNG:
- encoding = "Wansung";
- break;
- case FT_ENCODING_JOHAB:
- encoding = "Johab";
- break;
- case FT_ENCODING_ADOBE_STANDARD:
- encoding = "Adobe Standard";
- break;
- case FT_ENCODING_ADOBE_EXPERT:
- encoding = "Adobe Expert";
- break;
- case FT_ENCODING_ADOBE_CUSTOM:
- encoding = "Adobe Custom";
- break;
- case FT_ENCODING_ADOBE_LATIN_1:
- encoding = "Latin 1";
- break;
- case FT_ENCODING_OLD_LATIN_2:
- encoding = "Latin 2";
- break;
- case FT_ENCODING_APPLE_ROMAN:
- encoding = "Apple Roman";
- break;
- default:
- encoding = "Other";
- }
- grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
- encoding, display->fore_color );
- }
+ status.render_mode != RENDER_MODE_TEXT &&
+ status.render_mode != RENDER_MODE_WATERFALL ?
+ status.topleft : -1, error_code );
/* render mode */
{
@@ -1618,11 +1497,15 @@
handle->lcd_mode != LCD_MODE_LIGHT )
{
/* hinting engine */
-
- FT_Module module = &face->driver->root;
+ FT_Face face;
+ FT_Module module;
const char* hinting_engine = NULL;
+ FTC_Manager_LookupFace( handle->cache_manager,
+ handle->scaler.face_id, &face );
+ module = &face->driver->root;
+
if ( !strcmp( module->clazz->module_name, "cff" ) )
{
switch ( status.cff_hinting_engine )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 5728f90: [ftgrid, ftstring, ftview] Further top header consolidation.,
Alexei Podtelezhnikov <=