[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master e935138 2/4: [ftview] Simplify engine managemen
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2-demos] master e935138 2/4: [ftview] Simplify engine management. |
Date: |
Fri, 13 Nov 2020 14:44:08 -0500 (EST) |
branch: master
commit e935138a1612217fe815878768705a4444afd524
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[ftview] Simplify engine management.
* src/ftview.c (Process_Event): Use `FTDemo_Hinting_Engine_Change'.
(write_header): Do not report engine and reformat to make more room.
(main): Remove engine accounting.
---
ChangeLog | 8 ++
src/ftview.c | 259 +++--------------------------------------------------------
2 files changed, 20 insertions(+), 247 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 382aef6..6e62348 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2020-11-13 Alexei Podtelezhnikov <apodtele@gmail.com>
+ [ftview] Simplify engine management.
+
+ * src/ftview.c (Process_Event): Use `FTDemo_Hinting_Engine_Change'.
+ (write_header): Do not report engine and reformat to make more room.
+ (main): Remove engine accounting.
+
+2020-11-13 Alexei Podtelezhnikov <apodtele@gmail.com>
+
Universal hinting engine switch.
* src/ftcommon.[ch] (FTDemo_Hinting_Engine_Change): Implement it.
diff --git a/src/ftview.c b/src/ftview.c
index 811e6a3..80ce80b 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -21,10 +21,6 @@
#include "mlgetopt.h"
#include <stdio.h>
- /* showing driver name */
-#include FT_MODULE_H
-#include <freetype/internal/ftobjs.h>
-
#include FT_STROKER_H
#include FT_SYNTHESIS_H
#include FT_LCD_FILTER_H
@@ -41,7 +37,7 @@
#endif
#define CEIL( x ) ( ( (x) + 63 ) >> 6 )
-#define START_X 18 * 8
+#define START_X 16 * 8
#define START_Y 3 * HEADER_HEIGHT
#define INIT_SIZE( size, start_x, start_y, step_y, x, y ) \
@@ -107,14 +103,6 @@
double radius;
double slant;
- unsigned int cff_hinting_engine;
- unsigned int type1_hinting_engine;
- unsigned int t1cid_hinting_engine;
- unsigned int tt_interpreter_versions[3];
- int num_tt_interpreter_versions;
- int tt_interpreter_version_idx;
- FT_Bool warping;
-
int font_idx;
int offset; /* as selected by the user */
int topleft; /* as displayed by ftview */
@@ -128,7 +116,6 @@
} status = { 1,
"", DIM, NULL, 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,
FT_LCD_FILTER_DEFAULT, { 0x08, 0x4D, 0x56, 0x4D, 0x08 }, 2 };
@@ -846,8 +833,8 @@
grWriteln( " engines (if available)
" );
grWriteln( "f toggle forced auto- Tab cycle
through charmaps " );
grWriteln( " hinting (if hinting)
" );
- grWriteln( "w toggle warping P print PNG
file " );
- grWriteln( " (if available) q, ESC quit
ftview " );
+ grWriteln( " P print PNG
file " );
+ grWriteln( " q, ESC quit
ftview " );
/* |----------------------------------|
|----------------------------------| */
grLn();
grLn();
@@ -858,53 +845,6 @@
}
- static int
- event_tt_interpreter_version_change( void )
- {
- status.tt_interpreter_version_idx += 1;
- status.tt_interpreter_version_idx %= status.num_tt_interpreter_versions;
-
- error = FT_Property_Set( handle->library,
- "truetype",
- "interpreter-version",
- &status.tt_interpreter_versions[
- status.tt_interpreter_version_idx] );
-
- if ( !error )
- return 1;
-
- return 0;
- }
-
-
- static int
- event_warping_change( void )
- {
- if ( handle->lcd_mode == LCD_MODE_AA && handle->autohint )
- {
- FT_Bool new_warping_state = !status.warping;
-
-
- error = FT_Property_Set( handle->library,
- "autofitter",
- "warping",
- &new_warping_state );
-
- if ( !error )
- {
- /* Resetting the cache is perhaps a bit harsh, but I'm too */
- /* lazy to walk over all loaded fonts to check whether they */
- /* are auto-hinted, then unloading them explicitly. */
- FTC_Manager_Reset( handle->cache_manager );
- status.warping = new_warping_state;
- return 1;
- }
- }
-
- return 0;
- }
-
-
static void
event_fw_change( int delta )
{
@@ -1234,46 +1174,7 @@
break;
case grKEY( 'H' ):
- if ( !handle->autohint &&
- handle->lcd_mode != LCD_MODE_LIGHT )
- {
- FT_Face face;
- FT_Module module;
-
-
- error = FTC_Manager_LookupFace( handle->cache_manager,
- handle->scaler.face_id, &face );
- if ( !error )
- {
- module = &face->driver->root;
-
- if ( !strcmp( module->clazz->module_name, "cff" ) )
- status.update = FTDemo_Event_Cff_Hinting_Engine_Change(
- handle->library,
- &status.cff_hinting_engine,
- 1 );
- else if ( !strcmp( module->clazz->module_name, "type1" ) )
- status.update = FTDemo_Event_Type1_Hinting_Engine_Change(
- handle->library,
- &status.type1_hinting_engine,
- 1 );
- else if ( !strcmp( module->clazz->module_name, "t1cid" ) )
- status.update = FTDemo_Event_T1cid_Hinting_Engine_Change(
- handle->library,
- &status.t1cid_hinting_engine,
- 1 );
- else if ( !strcmp( module->clazz->module_name, "truetype" ) )
- status.update = event_tt_interpreter_version_change();
-
- if ( status.update )
- {
- /* Resetting the cache is perhaps a bit harsh, but I'm too */
- /* lazy to walk over all loaded fonts to check whether they */
- /* are of type TTF, then unloading them explicitly. */
- FTC_Manager_Reset( handle->cache_manager );
- }
- }
- }
+ status.update = FTDemo_Hinting_Engine_Change( handle );
break;
case grKEY( 'l' ):
@@ -1288,10 +1189,6 @@
status.update = 1;
break;
- case grKEY( 'w' ):
- status.update = event_warping_change();
- break;
-
case grKeySpace:
event_render_mode_change( 1 );
status.update = 1;
@@ -1574,16 +1471,16 @@
lcd_mode = "light AA";
break;
case LCD_MODE_RGB:
- lcd_mode = "LCD (horiz. RGB)";
+ lcd_mode = "LCD (h-RGB)";
break;
case LCD_MODE_BGR:
- lcd_mode = "LCD (horiz. BGR)";
+ lcd_mode = "LCD (h-BGR)";
break;
case LCD_MODE_VRGB:
- lcd_mode = "LCD (vert. RGB)";
+ lcd_mode = "LCD (v-RGB)";
break;
case LCD_MODE_VBGR:
- lcd_mode = "LCD (vert. BGR)";
+ lcd_mode = "LCD (v-BGR)";
break;
default:
handle->lcd_mode = 0;
@@ -1595,103 +1492,12 @@
/* hinting */
snprintf( buf, sizeof ( buf ), "hinting: %s",
- handle->hinted ? "on" : "off" );
+ !handle->hinted ? "off"
+ : ( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ) ? "auto" : "on" );
grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
buf, display->fore_color );
- if ( handle->hinted )
- {
- /* auto-hinting */
- snprintf( buf, sizeof( buf ), " forced auto: %s",
- ( handle->autohint ||
- handle->lcd_mode == LCD_MODE_LIGHT ) ? "on" : "off" );
- grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
- buf, display->fore_color );
- }
-
- if ( !handle->autohint &&
- handle->lcd_mode != LCD_MODE_LIGHT )
- {
- /* hinting engine */
- FT_Module module;
- const char* hinting_engine = NULL;
-
-
- module = &face->driver->root;
-
- if ( !strcmp( module->clazz->module_name, "cff" ) )
- {
- switch ( status.cff_hinting_engine )
- {
- case FT_HINTING_FREETYPE:
- hinting_engine = "FreeType";
- break;
- case FT_HINTING_ADOBE:
- hinting_engine = "Adobe";
- break;
- }
- }
-
- else if ( !strcmp( module->clazz->module_name, "type1" ) )
- {
- switch ( status.type1_hinting_engine )
- {
- case FT_HINTING_FREETYPE:
- hinting_engine = "FreeType";
- break;
- case FT_HINTING_ADOBE:
- hinting_engine = "Adobe";
- break;
- }
- }
-
- else if ( !strcmp( module->clazz->module_name, "t1cid" ) )
- {
- switch ( status.t1cid_hinting_engine )
- {
- case FT_HINTING_FREETYPE:
- hinting_engine = "FreeType";
- break;
- case FT_HINTING_ADOBE:
- hinting_engine = "Adobe";
- break;
- }
- }
-
- else if ( !strcmp( module->clazz->module_name, "truetype" ) )
- {
- switch ( status.tt_interpreter_versions[
- status.tt_interpreter_version_idx] )
- {
- case TT_INTERPRETER_VERSION_35:
- hinting_engine = "v35";
- break;
- case TT_INTERPRETER_VERSION_38:
- hinting_engine = "v38";
- break;
- case TT_INTERPRETER_VERSION_40:
- hinting_engine = "v40";
- break;
- }
- }
-
- if ( hinting_engine )
- {
- snprintf( buf, sizeof ( buf ), "engine: %s",
- hinting_engine );
- grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
- buf, display->fore_color );
- }
- }
-
- if ( handle->lcd_mode == LCD_MODE_AA && handle->autohint )
- {
- snprintf( buf, sizeof ( buf ), "warping: %s",
- status.warping ? "on" : "off" );
- grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
- buf, display->fore_color );
- }
-
line++;
/* embedded bitmaps */
@@ -1719,7 +1525,7 @@
buf, display->fore_color );
/* color palette */
- snprintf( buf, sizeof ( buf ), " palette idx: %d",
+ snprintf( buf, sizeof ( buf ), " palette: %d",
handle->current_font->palette_index );
grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
buf, display->fore_color );
@@ -1956,13 +1762,6 @@
main( int argc,
char* argv[] )
{
- unsigned int dflt_tt_interpreter_version;
- int i;
- unsigned int versions[3] = { TT_INTERPRETER_VERSION_35,
- TT_INTERPRETER_VERSION_38,
- TT_INTERPRETER_VERSION_40 };
-
-
/* Initialize engine */
handle = FTDemo_New();
@@ -1972,40 +1771,6 @@
FT_Library_SetLcdFilter( handle->library,
(FT_LcdFilter)status.lcd_filter );
- /* get the default values as compiled into FreeType */
- FT_Property_Get( handle->library,
- "cff",
- "hinting-engine", &status.cff_hinting_engine );
- FT_Property_Get( handle->library,
- "type1",
- "hinting-engine", &status.type1_hinting_engine );
- FT_Property_Get( handle->library,
- "t1cid",
- "hinting-engine", &status.t1cid_hinting_engine );
-
- /* collect all available versions, then set again the default */
- FT_Property_Get( handle->library,
- "truetype",
- "interpreter-version", &dflt_tt_interpreter_version );
- for ( i = 0; i < 3; i++ )
- {
- error = FT_Property_Set( handle->library,
- "truetype",
- "interpreter-version", &versions[i] );
- if ( !error )
- status.tt_interpreter_versions[
- status.num_tt_interpreter_versions++] = versions[i];
- if ( versions[i] == dflt_tt_interpreter_version )
- status.tt_interpreter_version_idx = i;
- }
- FT_Property_Set( handle->library,
- "truetype",
- "interpreter-version", &dflt_tt_interpreter_version );
-
- FT_Property_Get( handle->library,
- "autofitter",
- "warping", &status.warping );
-
if ( status.preload )
FTDemo_Set_Preload( handle, 1 );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master e935138 2/4: [ftview] Simplify engine management.,
Alexei Podtelezhnikov <=