From 58509f2fb1a557b90c4d4090b9c57d8a435d4fe9 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 06 2019 08:28:56 +0000 Subject: import freetype-2.8-14.el7 --- diff --git a/SOURCES/freetype-2.8-bw-hinting.patch b/SOURCES/freetype-2.8-bw-hinting.patch new file mode 100644 index 0000000..a715f8e --- /dev/null +++ b/SOURCES/freetype-2.8-bw-hinting.patch @@ -0,0 +1,24 @@ +From 24e256ab005c68a3894845ef3b7764338f9442a4 Mon Sep 17 00:00:00 2001 +From: Nikolaus Waxweiler +Date: Fri, 4 Aug 2017 08:25:31 +0200 +Subject: [truetype] Fix metrics of B/W hinting in v40 mode. + +Phantom points are now saved outside v40 backwards compatibility +mode. This fixes the jumping glyphs when switching between v35 and +v40 monochrome mode. + +* src/truetype/ttgload.c (TT_Hint_Glyph): Fix inversed bool logic. + +diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c +index 086ebca52..bfda76175 100644 +--- a/src/truetype/ttgload.c ++++ b/src/truetype/ttgload.c +@@ -825,7 +825,7 @@ + /* compatibility mode, where no movement on the x axis means no reason */ + /* to change bearings or advance widths. */ + if ( !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 && +- !loader->exec->backward_compatibility ) ) ++ loader->exec->backward_compatibility ) ) + { + #endif + loader->pp1 = zone->cur[zone->n_points - 4]; diff --git a/SOURCES/freetype-2.8-bw-rendering.patch b/SOURCES/freetype-2.8-bw-rendering.patch new file mode 100644 index 0000000..b272bc1 --- /dev/null +++ b/SOURCES/freetype-2.8-bw-rendering.patch @@ -0,0 +1,152 @@ +From a0455468fdb8dd1959596d0c8c8a3ff07ee495a3 Mon Sep 17 00:00:00 2001 +From: Nikolaus Waxweiler +Date: Sat, 20 May 2017 07:28:46 +0200 +Subject: [truetype] Always use interpreter v35 for B/W rendering (#51051). + +* src/truetype/ttgload.c (tt_loader_init) +[TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL]: Adjust +`subpixel_hinting_lean', `grayscale_cleartype', and +`vertical_lcd_lean' accordingly. + +* src/truetype/ttinterp.c (Ins_GETINFO): Updated. +(TT_RunIns): Update `backward_compatibility' flag. + +diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c +index 68a9b4ad5..e5a3da37a 100644 +--- a/src/truetype/ttgload.c ++++ b/src/truetype/ttgload.c +@@ -2339,13 +2339,19 @@ + #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL + if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 ) + { +- subpixel_hinting_lean = TRUE; +- grayscale_cleartype = !FT_BOOL( load_flags & +- FT_LOAD_TARGET_LCD || +- load_flags & +- FT_LOAD_TARGET_LCD_V ); +- exec->vertical_lcd_lean = FT_BOOL( load_flags & +- FT_LOAD_TARGET_LCD_V ); ++ subpixel_hinting_lean = ++ FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != ++ FT_RENDER_MODE_MONO ); ++ grayscale_cleartype = ++ FT_BOOL( subpixel_hinting_lean && ++ !( ( load_flags & ++ FT_LOAD_TARGET_LCD ) || ++ ( load_flags & ++ FT_LOAD_TARGET_LCD_V ) ) ); ++ exec->vertical_lcd_lean = ++ FT_BOOL( subpixel_hinting_lean && ++ ( load_flags & ++ FT_LOAD_TARGET_LCD_V ) ); + } + else + { +diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c +index af31408cb..0c48c2562 100644 +--- a/src/truetype/ttinterp.c ++++ b/src/truetype/ttinterp.c +@@ -7345,7 +7345,7 @@ + /* */ + /* The only smoothing method FreeType supports unless someone sets */ + /* FT_LOAD_TARGET_MONO. */ +- if ( ( args[0] & 2048 ) != 0 ) ++ if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean ) + K |= 1 << 18; + + /********************************/ +@@ -7589,11 +7589,21 @@ + #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ + + #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL +- /* Toggle backward compatibility according to what font says, except */ +- /* when it's a `tricky' font that heavily relies on the interpreter to */ +- /* render glyphs correctly, e.g. DFKai-SB. Backward compatibility */ +- /* hacks may break it. */ ++ /* ++ * Toggle backward compatibility according to what font wants, except ++ * when ++ * ++ * 1) we have a `tricky' font that heavily relies on the interpreter to ++ * render glyphs correctly, for example DFKai-SB, or ++ * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested. ++ * ++ * In those cases, backward compatibility needs to be turned off to get ++ * correct rendering. The rendering is then completely up to the ++ * font's programming. ++ * ++ */ + if ( SUBPIXEL_HINTING_MINIMAL && ++ exc->subpixel_hinting_lean && + !FT_IS_TRICKY( &exc->face->root ) ) + exc->backward_compatibility = !( exc->GS.instruct_control & 4 ); + else +diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h +index 55e472091..abbecfcee 100644 +--- a/src/truetype/ttinterp.h ++++ b/src/truetype/ttinterp.h +@@ -253,23 +253,38 @@ FT_BEGIN_HEADER + + #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL + /* +- * Modern TrueType fonts are usually rendered through Microsoft's +- * collection of rendering techniques called ClearType (e.g., subpixel +- * rendering and subpixel hinting). When ClearType was introduced, most +- * fonts were not ready. Microsoft decided to implement a backward +- * compatibility mode that employed several simple to complicated +- * assumptions and tricks that modified the interpretation of the +- * bytecode contained in these fonts to make them look ClearType-y +- * somehow. Most (web)fonts that were released since then have come to +- * rely on these hacks to render correctly, even some of Microsoft's +- * flagship ClearType fonts (Calibri, Cambria, Segoe UI). ++ * FreeType supports ClearType-like hinting of TrueType fonts through ++ * the version 40 interpreter. This is achieved through several hacks ++ * in the base (v35) interpreter, as detailed below. + * +- * The minimal subpixel hinting code (interpreter version 40) employs a +- * small list of font-agnostic hacks to bludgeon non-native-ClearType +- * fonts (except tricky ones[1]) into submission. It will not try to +- * toggle hacks for specific fonts for performance and complexity +- * reasons. The focus is on modern (web)fonts rather than legacy fonts +- * that were made for black-and-white rendering. ++ * ClearType is an umbrella term for several rendering techniques ++ * employed by Microsoft's various GUI and rendering toolkit ++ * implementations, most importantly: subpixel rendering for using the ++ * RGB subpixels of LCDs to approximately triple the perceived ++ * resolution on the x-axis and subpixel hinting for positioning stems ++ * on subpixel borders. TrueType programming is explicit, i.e., fonts ++ * must be programmed to take advantage of ClearType's possibilities. ++ * ++ * When ClearType was introduced, it seemed unlikely that all fonts ++ * would be reprogrammed, so Microsoft decided to implement a backward ++ * compatibility mode. It employs several simple to complicated ++ * assumptions and tricks, many of them font-dependent, that modify the ++ * interpretation of the bytecode contained in these fonts to retrofit ++ * them into a ClearType-y look. The quality of the results varies. ++ * Most (web)fonts that were released since then have come to rely on ++ * these hacks to render correctly, even some of Microsoft's flagship ++ * fonts (e.g., Calibri, Cambria, Segoe UI). ++ * ++ * FreeType's minimal subpixel hinting code (interpreter version 40) ++ * employs a small list of font-agnostic hacks loosely based on the ++ * public information available on Microsoft's compatibility mode[2]. ++ * The focus is on modern (web)fonts rather than legacy fonts that were ++ * made for monochrome rendering. It will not match ClearType rendering ++ * exactly. Unlike the `Infinality' code (interpreter version 38) that ++ * came before, it will not try to toggle hacks for specific fonts for ++ * performance and complexity reasons. It will fall back to version 35 ++ * behavior for tricky fonts[1] or when monochrome rendering is ++ * requested. + * + * Major hacks + * +@@ -347,7 +362,8 @@ FT_BEGIN_HEADER + * + */ + +- /* Using v40 implies subpixel hinting. Used to detect interpreter */ ++ /* Using v40 implies subpixel hinting, unless FT_RENDER_MODE_MONO has been ++ * requested. Used to detect interpreter */ + /* version switches. `_lean' to differentiate from the Infinality */ + /* `subpixel_hinting', which is managed differently. */ + FT_Bool subpixel_hinting_lean; diff --git a/SPECS/freetype.spec b/SPECS/freetype.spec index f7f06f5..3a027dc 100644 --- a/SPECS/freetype.spec +++ b/SPECS/freetype.spec @@ -7,7 +7,7 @@ Summary: A free and portable font rendering engine Name: freetype Version: 2.8 -Release: 12%{?dist}.1 +Release: 14%{?dist} License: (FTL or GPLv2+) and BSD and MIT and Public Domain and zlib with acknowledgement Group: System Environment/Libraries URL: http://www.freetype.org @@ -46,6 +46,10 @@ Patch9: freetype-2.8-getvariation.patch Patch10: freetype-2.8-2.4.11-API.patch Patch11: freetype-2.8-avar-table-load.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1657479 +Patch12: freetype-2.8-bw-rendering.patch +Patch13: freetype-2.8-bw-hinting.patch + BuildRequires: libX11-devel BuildRequires: libpng-devel BuildRequires: zlib-devel @@ -113,6 +117,8 @@ popd %patch9 -p1 -b .getvariation %patch10 -p1 -b .2.4.11-api %patch11 -p1 -b .avar-table-load +%patch12 -p1 -b .bw-rendering +%patch13 -p1 -b .bw-hinting %build @@ -228,9 +234,13 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.{a,la} %{_mandir}/man1/* %changelog -* Thu Nov 22 2018 Marek Kasik - 2.8-12.el7_6.1 +* Mon Mar 11 2019 Marek Kasik - 2.8-14 +- Fix rendering in monochrome mode +- Resolves: #1657479 + +* Tue Nov 13 2018 Marek Kasik - 2.8-13 - Fix definition of constant ft_encoding_gb2312 in freetype.h -- Resolves: #1652187 +- Resolves: #1645218 * Fri Jun 08 2018 Marek Kasik - 2.8-12 - Fix loading of avar tables