[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 4e9b0d7: Support new `slight' auto-hinting mode
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 4e9b0d7: Support new `slight' auto-hinting mode. |
Date: |
Mon, 1 May 2017 03:43:10 -0400 (EDT) |
branch: master
commit 4e9b0d75c7a8463c3d982907e000fa7f48f49e07
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
Support new `slight' auto-hinting mode.
Note that currently only `ftdiff' shows what the new mode really can
do – `ftview' uses integer advance values, which doesn't work well
with the `slight' mode.
* src/ftcommon.h (LCD_MODE_SLIGHT): New enumeration.
* src/ftcommon.c (FTDemo_Update_Current_Flags,
FTDemo_Glyph_To_Bitmap): Handle `LCD_MODE_SLIGHT'.
* src/ftdiff.c (HintMode): Add `HINT_MODE_AUTOHINT_SLIGHT'.
(render_mode_names): Updated.
(render_state_draw): Handle `HINT_MODE_AUTOHINT_SLIGHT'.
* src/ftgrid.c (event_lcd_mode_change): Handle `LCD_MODE_SLIGHT'.
(Process_Event): Updated.
* src/ftstring.c (event_lcdmode_change): Handle `LCD_MODE_SLIGHT'.
* src/ftview.c (event_help): Updated; we now have keys A-H to
directly select rendering modes.
(Process_Event, write_header): Updated.
* src/ftinspect.h (AntiAliasing): Add `AntiAliasing_Light'.
* src/ftinspect.cpp (Engine::update): Handle `AntiAliasing_Light',
update `AntiAliasing_Slight'.
(MainGUI::checkHinting, MainGUI::checkAutoHinting,
MainGUI::checkAntiAliasing, MainGUI::createLayout): Updated.
---
ChangeLog | 33 +++++++++++++++++++++++++
src/ftcommon.c | 8 +++++++
src/ftcommon.h | 1 +
src/ftdiff.c | 20 ++++++++++++----
src/ftgrid.c | 38 ++++++++++++++++++++++-------
src/ftinspect.cpp | 15 ++++++++++--
src/ftinspect.h | 1 +
src/ftstring.c | 3 +++
src/ftview.c | 72 ++++++++++++++++++++++++++++++-------------------------
9 files changed, 142 insertions(+), 49 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0be1359..cc61c17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2017-04-19 Werner Lemberg <address@hidden>
+
+ Support new `slight' auto-hinting mode.
+
+ Note that currently only `ftdiff' shows what the new mode really can
+ do – `ftview' uses integer advance values, which doesn't work well
+ with the `slight' mode.
+
+ * src/ftcommon.h (LCD_MODE_SLIGHT): New enumeration.
+
+ * src/ftcommon.c (FTDemo_Update_Current_Flags,
+ FTDemo_Glyph_To_Bitmap): Handle `LCD_MODE_SLIGHT'.
+
+ * src/ftdiff.c (HintMode): Add `HINT_MODE_AUTOHINT_SLIGHT'.
+ (render_mode_names): Updated.
+ (render_state_draw): Handle `HINT_MODE_AUTOHINT_SLIGHT'.
+
+ * src/ftgrid.c (event_lcd_mode_change): Handle `LCD_MODE_SLIGHT'.
+ (Process_Event): Updated.
+
+ * src/ftstring.c (event_lcdmode_change): Handle `LCD_MODE_SLIGHT'.
+
+ * src/ftview.c (event_help): Updated; we now have keys A-H to
+ directly select rendering modes.
+ (Process_Event, write_header): Updated.
+
+ * src/ftinspect.h (AntiAliasing): Add `AntiAliasing_Light'.
+
+ * src/ftinspect.cpp (Engine::update): Handle `AntiAliasing_Light',
+ update `AntiAliasing_Slight'.
+ (MainGUI::checkHinting, MainGUI::checkAutoHinting,
+ MainGUI::checkAntiAliasing, MainGUI::createLayout): Updated.
+
2014-04-19 Werner Lemberg <address@hidden>
[ftgrid] Fix out-of-array memory access.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index ab0f22f..b85971b 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -622,6 +622,10 @@
target = FT_LOAD_TARGET_LIGHT;
break;
+ case LCD_MODE_SLIGHT:
+ target = FT_LOAD_TARGET_SLIGHT;
+ break;
+
case LCD_MODE_RGB:
case LCD_MODE_BGR:
target = FT_LOAD_TARGET_LCD;
@@ -718,6 +722,10 @@
render_mode = FT_RENDER_MODE_LIGHT;
break;
+ case LCD_MODE_SLIGHT:
+ render_mode = FT_RENDER_MODE_SLIGHT;
+ break;
+
case LCD_MODE_RGB:
case LCD_MODE_BGR:
render_mode = FT_RENDER_MODE_LCD;
diff --git a/src/ftcommon.h b/src/ftcommon.h
index f8e642f..d51c934 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -137,6 +137,7 @@
LCD_MODE_MONO = 0,
LCD_MODE_AA,
LCD_MODE_LIGHT,
+ LCD_MODE_SLIGHT,
LCD_MODE_RGB,
LCD_MODE_BGR,
LCD_MODE_VRGB,
diff --git a/src/ftdiff.c b/src/ftdiff.c
index d65e7f6..3a53e1b 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -156,6 +156,7 @@
HINT_MODE_UNHINTED,
HINT_MODE_AUTOHINT,
HINT_MODE_AUTOHINT_LIGHT,
+ HINT_MODE_AUTOHINT_SLIGHT,
HINT_MODE_BYTECODE,
HINT_MODE_MAX
@@ -166,6 +167,7 @@
"unhinted",
"auto-hinter",
"light auto-hinter",
+ "slight auto-hinter",
"native hinter"
};
@@ -611,6 +613,9 @@
if ( rmode == HINT_MODE_AUTOHINT_LIGHT )
load_flags = FT_LOAD_TARGET_LIGHT;
+ if ( rmode == HINT_MODE_AUTOHINT_SLIGHT )
+ load_flags = FT_LOAD_TARGET_SLIGHT;
+
if ( rmode == HINT_MODE_UNHINTED )
load_flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
@@ -697,7 +702,8 @@
x_origin += vec.x;
}
- if ( column->use_deltas )
+ if ( rmode != HINT_MODE_AUTOHINT_SLIGHT &&
+ column->use_deltas )
{
if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 )
x_origin -= 64;
@@ -706,8 +712,10 @@
}
prev_rsb_delta = face->glyph->rsb_delta;
- /* implement sub-pixel positioning for un-hinted mode */
- if ( rmode == HINT_MODE_UNHINTED &&
+ /* implement sub-pixel positioning for */
+ /* un-hinted and slight hinting mode */
+ if ( ( rmode == HINT_MODE_UNHINTED ||
+ rmode == HINT_MODE_AUTOHINT_SLIGHT ) &&
slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
FT_Pos shift = x_origin & 63;
@@ -732,7 +740,8 @@
}
else
{
- if ( rmode == HINT_MODE_UNHINTED )
+ if ( rmode == HINT_MODE_UNHINTED ||
+ rmode == HINT_MODE_AUTOHINT_SLIGHT )
xmax = slot->linearHoriAdvance >> 10;
else
xmax = slot->advance.x;
@@ -773,7 +782,8 @@
(int)map->width, (int)map->rows,
map->pitch, map->buffer );
}
- if ( rmode == HINT_MODE_UNHINTED )
+ if ( rmode == HINT_MODE_UNHINTED ||
+ rmode == HINT_MODE_AUTOHINT_SLIGHT )
x_origin += slot->linearHoriAdvance >> 10;
else
x_origin += slot->advance.x;
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 565da46..3a395f8 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -1176,6 +1176,9 @@
case LCD_MODE_LIGHT:
lcd_mode = "light AA";
break;
+ case LCD_MODE_SLIGHT:
+ lcd_mode = "slight AA";
+ break;
case LCD_MODE_RGB:
lcd_mode = "LCD (horiz. RGB)";
break;
@@ -1189,6 +1192,10 @@
lcd_mode = "LCD (vert. BGR)";
break;
}
+
+ if ( delta )
+ FTC_Manager_Reset( handle->cache_manager );
+
sprintf( status.header_buffer, "rendering mode changed to %s",
lcd_mode );
@@ -1500,8 +1507,10 @@
#ifdef FT_DEBUG_AUTOFIT
case grKEY( '1' ):
- if ( handle->hinted &&
- ( handle->autohint || handle->lcd_mode == LCD_MODE_LIGHT ) )
+ if ( handle->hinted &&
+ ( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ||
+ handle->lcd_mode == LCD_MODE_SLIGHT ) )
{
status.header = "dumping glyph edges to stdout";
af_glyph_hints_dump_edges( _af_debug_hints, 1 );
@@ -1509,8 +1518,10 @@
break;
case grKEY( '2' ):
- if ( handle->hinted &&
- ( handle->autohint || handle->lcd_mode == LCD_MODE_LIGHT ) )
+ if ( handle->hinted &&
+ ( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ||
+ handle->lcd_mode == LCD_MODE_SLIGHT ) )
{
status.header = "dumping glyph segments to stdout";
af_glyph_hints_dump_segments( _af_debug_hints, 1 );
@@ -1518,8 +1529,10 @@
break;
case grKEY( '3' ):
- if ( handle->hinted &&
- ( handle->autohint || handle->lcd_mode == LCD_MODE_LIGHT ) )
+ if ( handle->hinted &&
+ ( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ||
+ handle->lcd_mode == LCD_MODE_SLIGHT ) )
{
status.header = "dumping glyph points to stdout";
af_glyph_hints_dump_points( _af_debug_hints, 1 );
@@ -1548,6 +1561,7 @@
status.header = handle->hinted ? "glyph hinting is now active"
: "glyph hinting is now ignored";
+ FTC_Manager_Reset( handle->cache_manager );
FTDemo_Update_Current_Flags( handle );
break;
@@ -1572,7 +1586,9 @@
break;
case grKEY( 'H' ):
- if ( !( handle->autohint || handle->lcd_mode == LCD_MODE_LIGHT ) )
+ if ( !( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ||
+ handle->lcd_mode == LCD_MODE_SLIGHT ) )
{
FT_Face face;
FT_Module module;
@@ -1606,7 +1622,9 @@
#ifdef FT_DEBUG_AUTOFIT
case grKEY( 'V' ):
- if ( handle->autohint || handle->lcd_mode == LCD_MODE_LIGHT )
+ if ( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ||
+ handle->lcd_mode == LCD_MODE_SLIGHT )
{
status.do_vert_hints = !status.do_vert_hints;
status.header = status.do_vert_hints ? "vertical hinting enabled"
@@ -1617,7 +1635,9 @@
break;
case grKEY( 'B' ):
- if ( handle->autohint || handle->lcd_mode == LCD_MODE_LIGHT )
+ if ( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ||
+ handle->lcd_mode == LCD_MODE_SLIGHT )
{
status.do_blue_hints = !status.do_blue_hints;
status.header = status.do_blue_hints ? "blue zone hinting enabled"
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 6f68255..2759381 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -572,10 +572,14 @@ Engine::update()
{
switch (index)
{
- case MainGUI::AntiAliasing_Slight:
+ case MainGUI::AntiAliasing_Light:
target = FT_LOAD_TARGET_LIGHT;
break;
+ case MainGUI::AntiAliasing_Slight:
+ target = FT_LOAD_TARGET_SLIGHT;
+ break;
+
case MainGUI::AntiAliasing_LCD:
case MainGUI::AntiAliasing_LCD_BGR:
target = FT_LOAD_TARGET_LCD;
@@ -1513,6 +1517,7 @@ MainGUI::checkHinting()
segmentDrawingCheckBox->setEnabled(false);
warpingCheckBox->setEnabled(false);
+ antiAliasingComboBoxx->setItemEnabled(AntiAliasing_Light, false);
antiAliasingComboBoxx->setItemEnabled(AntiAliasing_Slight, false);
}
@@ -1556,6 +1561,7 @@ MainGUI::checkAutoHinting()
if (engine->haveWarping)
warpingCheckBox->setEnabled(true);
+ antiAliasingComboBoxx->setItemEnabled(AntiAliasing_Light, true);
antiAliasingComboBoxx->setItemEnabled(AntiAliasing_Slight, true);
}
else
@@ -1573,9 +1579,11 @@ MainGUI::checkAutoHinting()
segmentDrawingCheckBox->setEnabled(false);
warpingCheckBox->setEnabled(false);
+ antiAliasingComboBoxx->setItemEnabled(AntiAliasing_Light, false);
antiAliasingComboBoxx->setItemEnabled(AntiAliasing_Slight, false);
- if (antiAliasingComboBoxx->currentIndex() == AntiAliasing_Slight)
+ if (antiAliasingComboBoxx->currentIndex() == AntiAliasing_Light
+ || antiAliasingComboBoxx->currentIndex() == AntiAliasing_Slight)
antiAliasingComboBoxx->setCurrentIndex(AntiAliasing_Normal);
}
@@ -1590,6 +1598,7 @@ MainGUI::checkAntiAliasing()
if (index == AntiAliasing_None
|| index == AntiAliasing_Normal
+ || index == AntiAliasing_Light
|| index == AntiAliasing_Slight)
{
lcdFilterLabel->setEnabled(false);
@@ -1993,6 +2002,8 @@ MainGUI::createLayout()
tr("None"));
antiAliasingComboBoxx->insertItem(AntiAliasing_Normal,
tr("Normal"));
+ antiAliasingComboBoxx->insertItem(AntiAliasing_Light,
+ tr("Light"));
antiAliasingComboBoxx->insertItem(AntiAliasing_Slight,
tr("Slight"));
antiAliasingComboBoxx->insertItem(AntiAliasing_LCD,
diff --git a/src/ftinspect.h b/src/ftinspect.h
index bf6e9af..47da549 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -517,6 +517,7 @@ private:
{
AntiAliasing_None,
AntiAliasing_Normal,
+ AntiAliasing_Light,
AntiAliasing_Slight,
AntiAliasing_LCD,
AntiAliasing_LCD_BGR,
diff --git a/src/ftstring.c b/src/ftstring.c
index 179e1ee..912b1ae 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -257,6 +257,9 @@
case LCD_MODE_LIGHT:
lcd_mode = " light AA";
break;
+ case LCD_MODE_SLIGHT:
+ lcd_mode = " slight AA";
+ break;
case LCD_MODE_RGB:
lcd_mode = " LCD (horiz. RGB)";
break;
diff --git a/src/ftview.c b/src/ftview.c
index 127cf35..bd08f5e 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -735,33 +735,33 @@
grWriteln( " 1 all glyphs A monochrome
" );
grWriteln( " 2 all glyphs fancy B normal
" );
grWriteln( " (emboldened / slanted) C light
" );
- grWriteln( " 3 all glyphs stroked D horizontal
RGB (LCD) " );
- grWriteln( " 4 text string E horizontal
BGR (LCD) " );
- grWriteln( " 5 waterfall F vertical
RGB (LCD) " );
- grWriteln( " space cycle forwards G vertical
BGR (LCD) " );
- grWriteln( " backspace cycle backwards k, l cycle back
and forth " );
- grWriteln( "
" );
- grWriteln( "b toggle embedded bitmaps x, X adjust
horizontal " );
- grWriteln( "c toggle color glyphs
emboldening (in mode 2)" );
- grWriteln( "K toggle cache modes y, Y adjust
vertical " );
- grWriteln( "
emboldening (in mode 2)" );
- grWriteln( "p, n previous/next font s, S adjust
slanting " );
- grWriteln( " (in mode
2) " );
- grWriteln( "Up, Down adjust size by 1 unit r, R adjust
stroking radius " );
- grWriteln( "PgUp, PgDn adjust size by 10 units (in mode
3) " );
- grWriteln( "
" );
- grWriteln( "Left, Right adjust index by 1 L cycle
through " );
- grWriteln( "F7, F8 adjust index by 16 LCD
filtering " );
- grWriteln( "F9, F10 adjust index by 256 [, ] select
custom LCD " );
- grWriteln( "F11, F12 adjust index by 4096 filter
weight " );
- grWriteln( " (if
custom filtering) " );
- grWriteln( "h toggle hinting -, +(=) adjust
selected custom " );
- grWriteln( "H cycle through hinting LCD
filter weight " );
- grWriteln( " engines (if available)
" );
- grWriteln( "f toggle forced auto- g, v adjust
gamma value " );
- grWriteln( " hinting (if hinting)
" );
- grWriteln( "w toggle warping (in light Tab cycle
through charmaps " );
- grWriteln( " AA mode, if available)
" );
+ grWriteln( " 3 all glyphs stroked D slight
" );
+ grWriteln( " 4 text string E horizontal
RGB (LCD) " );
+ grWriteln( " 5 waterfall F horizontal
BGR (LCD) " );
+ grWriteln( " space cycle forwards G vertical
RGB (LCD) " );
+ grWriteln( " backspace cycle backwards H vertical
BGR (LCD) " );
+ grWriteln( " k, l cycle back
and forth " );
+ grWriteln( "b toggle embedded bitmaps
" );
+ grWriteln( "c toggle color glyphs x, X adjust
horizontal " );
+ grWriteln( "K toggle cache modes
emboldening (in mode 2)" );
+ grWriteln( " y, Y adjust
vertical " );
+ grWriteln( "p, n previous/next font
emboldening (in mode 2)" );
+ grWriteln( " s, S adjust
slanting " );
+ grWriteln( "Up, Down adjust size by 1 unit (in mode
2) " );
+ grWriteln( "PgUp, PgDn adjust size by 10 units r, R adjust
stroking radius " );
+ grWriteln( " (in mode
3) " );
+ grWriteln( "Left, Right adjust index by 1
" );
+ grWriteln( "F7, F8 adjust index by 16 L cycle
through " );
+ grWriteln( "F9, F10 adjust index by 256 LCD
filtering " );
+ grWriteln( "F11, F12 adjust index by 4096 [, ] select
custom LCD " );
+ grWriteln( " filter
weight " );
+ grWriteln( "h toggle hinting (if
custom filtering) " );
+ grWriteln( "H cycle through hinting -, +(=) adjust
selected custom " );
+ grWriteln( " engines (if available) LCD
filter weight " );
+ grWriteln( "f toggle forced auto-
" );
+ grWriteln( " hinting (if hinting) g, v adjust
gamma value " );
+ grWriteln( "w toggle warping (in light
" );
+ grWriteln( " AA mode, if available) Tab cycle
through charmaps " );
grWriteln( "
" );
grWriteln( " q, ESC quit
ftview " );
/* |----------------------------------|
|----------------------------------| */
@@ -1135,8 +1135,9 @@
break;
case grKEY( 'H' ):
- if ( !handle->autohint &&
- handle->lcd_mode != LCD_MODE_LIGHT )
+ if ( !handle->autohint &&
+ handle->lcd_mode != LCD_MODE_LIGHT &&
+ handle->lcd_mode != LCD_MODE_SLIGHT )
{
FT_Face face;
FT_Module module;
@@ -1626,6 +1627,9 @@
case LCD_MODE_LIGHT:
lcd_mode = "light AA";
break;
+ case LCD_MODE_SLIGHT:
+ lcd_mode = "slight AA";
+ break;
case LCD_MODE_RGB:
lcd_mode = "LCD (horiz. RGB)";
break;
@@ -1656,14 +1660,16 @@
{
/* auto-hinting */
sprintf( buf, " forced auto: %s",
- ( handle->autohint ||
- handle->lcd_mode == LCD_MODE_LIGHT ) ? "on" : "off" );
+ ( handle->autohint ||
+ handle->lcd_mode == LCD_MODE_LIGHT ||
+ handle->lcd_mode == LCD_MODE_SLIGHT ) ? "on" : "off" );
grWriteCellString( display->bitmap, 0, (line++) * HEADER_HEIGHT,
buf, display->fore_color );
}
- if ( !handle->autohint &&
- handle->lcd_mode != LCD_MODE_LIGHT )
+ if ( !handle->autohint &&
+ handle->lcd_mode != LCD_MODE_LIGHT &&
+ handle->lcd_mode != LCD_MODE_SLIGHT )
{
/* hinting engine */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 4e9b0d7: Support new `slight' auto-hinting mode.,
Werner LEMBERG <=