print/freetype2: fix incorrect line spacing for some fonts

Problem description: After updating to print/freetypw2-2.8.0 using
Bitstream Vera Sans Mono the vertical pitch increases and significantly
add of the size of the window. See attached images.

See PR for lots of links to related reports upstream
and on other platforms.

PR:		219608
Submitted by:	lightside@gmx.com
Reported by:	Kevin Oberman <rkoberman@gmail.com>
This commit is contained in:
Kurt Jaeger 2017-10-26 06:20:53 +00:00
parent ab02d97865
commit 90c5e3c356
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=452905
2 changed files with 62 additions and 3 deletions

View file

@ -3,6 +3,7 @@
PORTNAME= freetype2
PORTVERSION= 2.8
PORTREVISION= 1
CATEGORIES= print
MASTER_SITES= http://savannah.nongnu.org/download/freetype/ \
SF/freetype/${PORTNAME}/${PORTVERSION:C/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/}/ \
@ -36,10 +37,12 @@ PORTDOCS= reference CHANGES formats.txt LICENSE.TXT raster.txt
CPE_PRODUCT= freetype
CPE_VENDOR= freetype
OPTIONS_DEFINE= DEBUG DOCS LCD_FILTERING PNG TABLE_VALIDATION \
TT_SIZE_METRICS
OPTIONS_DEFINE= DEBUG DOCS LCD_FILTERING LONG_PCF_NAMES PNG \
TABLE_VALIDATION
OPTIONS_GROUP= SUBPIXEL_HINTING
OPTIONS_GROUP_SUBPIXEL_HINTING= V38 V40
OPTIONS_RADIO= SIZE_METRICS_CHOICE
OPTIONS_RADIO_SIZE_METRICS_CHOICE= FIX_SIZE_METRICS TT_SIZE_METRICS
OPTIONS_DEFAULT= LCD_FILTERING V40
PNG_DESC= Png compressed OpenType embedded bitmaps support
@ -48,11 +51,16 @@ PNG_CONFIGURE_WITH= png
TABLE_VALIDATION_DESC= TrueType GX/AAT and OpenType table validation
TT_SIZE_METRICS_DESC= TrueType-like size metrics for 'light' (V40) auto-hinting
SIZE_METRICS_CHOICE_DESC= Size metrics for TrueType fonts
FIX_SIZE_METRICS_DESC= Fix metrics on size request for scalable fonts (alternative method)
FIX_SIZE_METRICS_EXTRA_PATCHES= ${FILESDIR}/extra-patch-fix_size_metrics.diff
TT_SIZE_METRICS_DESC= TrueType-like size metrics for 'light' auto-hinting
LCD_FILTERING_DESC?= Sub-pixel rendering (patented)
LCD_FILTERING_CFLAGS= -DFT_CONFIG_OPTION_SUBPIXEL_RENDERING
LONG_PCF_NAMES_DESC= Enable long PCF family names
SUBPIXEL_HINTING_DESC= Sub-pixel hinting support
V38_DESC= v38 mode (Infinality code)
V38_VARS= SUBPIXEL_HINTING_MODE+=1
@ -90,6 +98,11 @@ post-patch-DEBUG-on:
-e 's|.*\(#define FT_DEBUG_MEMORY\).*|\1|' \
${WRKSRC}/include/freetype/config/ftoption.h
post-patch-LONG_PCF_NAMES-on:
@${REINPLACE_CMD} -i '.names.bak' \
-e 's|.*\(#define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES\).*|\1|' \
${WRKSRC}/include/freetype/config/ftoption.h
post-patch-TABLE_VALIDATION-on:
@${REINPLACE_CMD} -e '/valid$$/s|#.*\(AUX_MODULES\)|\1|' \
${WRKSRC}/modules.cfg

View file

@ -0,0 +1,46 @@
# Fix metrics on size request for scalable fonts.
# Based on b0962ac34e66052ccfee7996e5468f30d4bd5a72 commit with changes for new version.
# Reverts bcc74f4dafee25ea89f1d3144646cba7e30f9908 commit for src/truetype/ttdriver.c file.
# Adapts 8ab08cff63eeb23b6c9f2c4470ae9809f2acf244 commit for src/truetype/ttobjs.c file.
--- src/truetype/ttdriver.c.orig 2017-04-29 04:38:17 UTC
+++ src/truetype/ttdriver.c
@@ -357,6 +357,8 @@
if ( FT_IS_SCALABLE( size->face ) )
{
error = tt_size_reset( ttsize, 0 );
+ if ( !error )
+ ttsize->root.metrics = *ttsize->metrics;
#ifdef TT_USE_BYTECODE_INTERPRETER
/* for the `MPS' bytecode instruction we need the point size */
--- src/truetype/ttobjs.c.orig 2017-05-07 11:05:56 UTC
+++ src/truetype/ttobjs.c
@@ -1262,6 +1262,13 @@
/* */
if ( face->header.Flags & 8 )
{
+ if ( !only_height )
+ {
+ size_metrics->x_scale = FT_DivFix( size_metrics->x_ppem << 6,
+ face->root.units_per_EM );
+ size_metrics->y_scale = FT_DivFix( size_metrics->y_ppem << 6,
+ face->root.units_per_EM );
+ }
/* the TT spec always asks for ROUND, not FLOOR or CEIL */
size_metrics->ascender = FT_PIX_ROUND(
FT_MulFix( face->root.ascender,
@@ -1283,11 +1290,12 @@
{
/* base scaling values on integer ppem values, */
/* as mandated by the TrueType specification */
+/*
size_metrics->x_scale = FT_DivFix( size_metrics->x_ppem << 6,
face->root.units_per_EM );
size_metrics->y_scale = FT_DivFix( size_metrics->y_ppem << 6,
face->root.units_per_EM );
-
+*/
size_metrics->max_advance = FT_PIX_ROUND(
FT_MulFix( face->root.max_advance_width,
size_metrics->x_scale ) );