Commit 5f85bb23 authored by Carlo Landmeter's avatar Carlo Landmeter
Browse files

testing/freetype-infinality: new aport

parent d926a7a1
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer:
pkgname=freetype-infinality
pkgver=2.4.4
pkgrel=0
pkgdesc="TrueType font rendering library with infinality patch"
url="http://www.infinality.net"
arch="all"
license="GPL"
depends=
depends_dev="zlib-dev freetype-dev"
makedepends="$depends_dev"
install=""
subpackages="$pkgname-dev"
replaces="freetype"
source="http://downloads.sourceforge.net/sourceforge/freetype/freetype-$pkgver.tar.bz2
freetype-add-subpixel-hinting-infinality-20101114-1.patch
freetype-enable-subpixel-hinting-infinality-20100909-1.patch
freetype-entire-infinality-patchset-20101114-1.patch
infinality-settings
freetype-2.2.1-enable-valid.patch
freetype2-infinality-protect_null_pointer-goddesse.patch"
_builddir="$srcdir/freetype-$pkgver"
prepare() {
local i
cd "$_builddir"
for i in $source; do
case $i in
*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
esac
done
}
build() {
cd "$_builddir"
./configure --prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man
make || return 1
}
package() {
cd "$_builddir"
make DESTDIR="$pkgdir" install || return 1
install -Dm644 "$srcdir/infinality-settings" "$pkgdir/etc/infinality-settings"
}
md5sums="b3e2b6e2f1c3e0dffa1fd2a0f848b671 freetype-2.4.4.tar.bz2
799a2d229c2997a5bb2d5b7c9f92fdba freetype-add-subpixel-hinting-infinality-20101114-1.patch
a88b1a66da44a90c1fdcdeaa39a2dc09 freetype-enable-subpixel-hinting-infinality-20100909-1.patch
6725774b17820f5413cb6a3cf7547f53 freetype-entire-infinality-patchset-20101114-1.patch
416154ff9eb8dfb27e46080f678785b8 infinality-settings
214119610444c9b02766ccee5e220680 freetype-2.2.1-enable-valid.patch
316d2986f9a08e7ceb51fb9d5a5cab38 freetype2-infinality-protect_null_pointer-goddesse.patch"
--- freetype-2.2.1/modules.cfg.orig 2006-07-07 21:01:09.000000000 -0400
+++ freetype-2.2.1/modules.cfg 2006-07-07 21:01:54.000000000 -0400
@@ -110,7 +110,7 @@
AUX_MODULES += cache
# TrueType GX/AAT table validation. Needs ftgxval.c below.
-# AUX_MODULES += gxvalid
+AUX_MODULES += gxvalid
# Support for streams compressed with gzip (files with suffix .gz).
#
@@ -124,7 +124,7 @@
# OpenType table validation. Needs ftotval.c below.
#
-# AUX_MODULES += otvalid
+AUX_MODULES += otvalid
# Auxiliary PostScript driver component to share common code.
#
Infinality Freetype Truetype Subpixel Hinting Patch
-------------------------------------------------------------------
Should patch cleanly to freetype-2.4.3
Changes for 2010-11-14:
* Rule tweaks on various fonts. Fixed the Cyrillic y issue and e issue
with Trebuchet, and the ^ issue with Arial. Other issues
(firefox and @font-face) are still present to a degree.
* A couple new rules to deal with various issues. (work in progress)
* Additional commenting.
* Some cleanup of obsolete code.
* Added some debugging code for potential future enhancements. Please
ignore the mess.
Changes for 2010-10-22:
* I'm refocusing on just getting the subpixel looking nice, so I've stripped
back the rendering modes to just 2. The standard SUBPIXEL_HINTING and
the ADDITIONAL_TWEAKS. The rules structure is still in place. I recommend
using ADDITIONAL_TWEAKS mode.
* Fixed an issue with monochrome rendering that made fonts look really bad.
There is still an issue with them, but they are at least tolerable to
look at now.
* Added some testing code for detecting inline delta functions. Not sure
if this is useful yet.
* Added more rules to deal with certain artifacts on various fonts, like the
issue with < > and ^. Created some "exception" rules for certain rules.
* Reverted back to older rounding functions. The new experimental ones I
was trying were causing artifacts on some fonts.
* Some code cleanup.
Changes for 2010-10-08:
* Fix PDF crashes.
Changes for 2010-10-04:
* Update to freetype-2.4.3
Changes for 2010-10-03:
* There are lots of changes for this one, some big, some small, and some
that still are not implemented. Not sure if I can remember them all
but I will try! THIS IS A POINT RELEASE THAT IS NOT
INTENDED TO WORK 100%. Some fonts and compile options may be broken
and the code may be inefficient and/or not syntactiacally correct.
That said, I do plan on using this on my system right away.
* There are now "rendering modes" for the subpixel hinting, with the idea
that this will enventually be able to be controlled by fontconfig. The 4
modes of enhanced hinting defined so far are:
1) NATIVE HINTING - this is what freetype TT interpreter does by default.
2) FIXED NATIVE HINTING - A slighly tweaked version of the above that
does "better" native rendering when displaying on LCD, for those
that still seem to like incorrect, thin fonts, which were only ever
there due to technical limitations.
3) SUBPIXEL OPTIMIZED HINTING - this is straight up subpixel hinting with
very few tweaks. Just enough to get it working.
4) COMPATIBILITY MODE HINTING - this is the sweet spot I'm working on
that will hopefully supplant #3 because it will work so well with all
fonts. The idea here is to tweak all available fonts so that each
renders well.
All of these modes either turn on or off switches in the interpreter
to make the fonts render properly for each mode. Right now these are only
compile-time options.
* Subpixel-related code has been broken out into its own files, so as to not
clutter up the existing code.
* The rasterizer now pays attention to the additional bits of MS rasterizer
v. 37, meaning that it can now indicate to fonts that it can handle
subpixel rendering.
* The rounding functions have been adapted to accept a grid resolution
variable, which lets them work on pixel and subpixel boundaries
automatically. Y still needs to be implemented.
* Additional conditions have been added to the switches, to further refine
how they are applied to different fonts.
* What all this means qualitatively is that legacy fonts now render much
better. There are still some that need a bit of love, like Courier New.
- Courier New has some fixes, and some breakage (Ghost pixels above bold
fonts, too thin on regular font)
- Times New Roman has some fixes and breakage (serifs, particularly)
- Tahoma and Trebuchet MS have been cleaned up
- Arial now snaps to grid better, but that causes breakage on a few glyphs
- Verdana 13 is now set to grid fit, but some glyhs are broken (mwxyz)
- Geneva and Geneva CY no longer look like turds
- Lucida Sans Unicode now looks arguably better than Lucida Grande
Changes for 2010-09-16:
* The changes from 2010-09-14 regarding subpixel when LIGHT hinting enabled
have been reverted due to problems. The old behavior is back.
* Disable grayscale when subpixel is enabled. This results in better
behavior of some TT instructions within some fonts, like Times New Roman.
* Some modification of the tweaks, in light of above.
Changes for 2010-09-14:
/************************** NO LONGER IN PLACE *****************************/
* Subpixel hinting is now used when the LIGHT hinting method and the TT
hinting is called. If FULL hinting is requested it will do the usual
behavior of the TT hinter.
This allows for all previously existing behavior, plus the new subpixel
hinting behavior, all in the same compile, and it makes sense in that
the slight hinting of the autohinter is essentially doing the same thing
as this, which is not forcing X-direction hints.
Previously, even if TT was selected, but LIGHT hinting was used, the
autohinter would still be forced. Other than this, autohint is not affected.
/***************************************************************************/
* Added a couple more conditionals around things to test whether subpixel
hinting is enabled. There were a few missing that ended up causing some
goofy hinting if subpixel was not enabled, but compiled in.
diff -Nur freetype-2.4.3.orig/include/freetype/config/ftoption.h freetype-2.4.3.new/include/freetype/config/ftoption.h
--- freetype-2.4.3.orig/include/freetype/config/ftoption.h 2010-07-04 23:38:55.000000000 -0500
+++ freetype-2.4.3.new/include/freetype/config/ftoption.h 2010-10-23 21:47:20.476211579 -0500
@@ -501,6 +501,48 @@
/*************************************************************************/
/* */
+ /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */
+ /* EXPERIMENTAL subpixel hinting support into the TrueType driver. */
+ /* This will replace the native TrueType hinting mechanism when */
+ /* anything but FT_RENDER_MODE_MONO is requested. */
+ /* */
+ /* Enabling this causes the TrueType driver to ignore instructions */
+ /* under certain conditions. This is done in accordance with the */
+ /* guide here, with some minor differences: */
+ /* */
+ /* http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
+ /* */
+ /* By undefining this, you will only compile the code necessary to */
+ /* hint TrueType glyphs with native TT hinting. */
+ /* */
+ /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */
+ /* defined. */
+ /* */
+/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+
+ /*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS if you */
+ /* want to enable additional subpixel hinting tweaks of individual fonts,*/
+ /* glyphs, styles and sizes. The idea here is that some glyphs and */
+ /* fonts still do not render in a desirable way with */
+ /* TT_CONFIG_OPTION_SUBPIXEL_HINTING. */
+ /* */
+ /* This is disabled by default, as some people may not care, or may not */
+ /* want the additional overhead involved in doing this. */
+ /* */
+ /* By undefining this, you will only compile the code necessary to */
+ /* do subpixel hinting as defined above. */
+ /* */
+ /* This option requires TT_CONFIG_OPTION_SUBPIXEL_HINTING to be */
+ /* defined. */
+ /* */
+/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING_ADDITIONAL_TWEAKS */
+
+
+ /*************************************************************************/
+ /* */
/* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version */
/* of the TrueType bytecode interpreter is used that doesn't implement */
/* any of the patented opcodes and algorithms. The patents related to */
diff -Nur freetype-2.4.3.orig/include/freetype/internal/ftobjs.h freetype-2.4.3.new/include/freetype/internal/ftobjs.h
--- freetype-2.4.3.orig/include/freetype/internal/ftobjs.h 2010-07-18 11:07:31.000000000 -0500
+++ freetype-2.4.3.new/include/freetype/internal/ftobjs.h 2010-11-07 11:18:19.681501081 -0600
@@ -81,6 +81,14 @@
#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 )
#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
+ /*
+ * These are used in ttinterp.c for subpixel hinting with an
+ * adjustable grids-per-pixel value.
+ */
+#define FT_PIX_FLOOR_GRID( x, n ) ( (x) & ~(64 / n - 1) )
+#define FT_PIX_ROUND_GRID( x, n ) FT_PIX_FLOOR_GRID( (x) + 32 / n, n)
+#define FT_PIX_CEIL_GRID( x, n ) FT_PIX_FLOOR_GRID( (x) + 63 / n, n)
+
/*
* Return the highest power of 2 that is <= value; this correspond to
diff -Nur freetype-2.4.3.orig/src/truetype/rules.mk freetype-2.4.3.new/src/truetype/rules.mk
--- freetype-2.4.3.orig/src/truetype/rules.mk 2009-03-14 08:45:26.000000000 -0500
+++ freetype-2.4.3.new/src/truetype/rules.mk 2010-10-22 19:25:46.060977607 -0500
@@ -30,7 +30,8 @@
$(TT_DIR)/ttgload.c \
$(TT_DIR)/ttinterp.c \
$(TT_DIR)/ttgxvar.c \
- $(TT_DIR)/ttdriver.c
+ $(TT_DIR)/ttdriver.c \
+ $(TT_DIR)/ttsubpixel.c
# TrueType driver headers
#
diff -Nur freetype-2.4.3.orig/src/truetype/truetype.c freetype-2.4.3.new/src/truetype/truetype.c
--- freetype-2.4.3.orig/src/truetype/truetype.c 2009-07-03 08:28:24.000000000 -0500
+++ freetype-2.4.3.new/src/truetype/truetype.c 2010-10-22 19:25:46.061853066 -0500
@@ -27,6 +27,7 @@
#ifdef TT_USE_BYTECODE_INTERPRETER
#include "ttinterp.c"
+#include "ttsubpixel.c"
#endif
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
diff -Nur freetype-2.4.3.orig/src/truetype/ttgload.c freetype-2.4.3.new/src/truetype/ttgload.c
--- freetype-2.4.3.orig/src/truetype/ttgload.c 2010-09-14 02:00:35.000000000 -0500
+++ freetype-2.4.3.new/src/truetype/ttgload.c 2010-11-14 09:07:50.835981062 -0600
@@ -33,7 +33,7 @@
#endif
#include "tterrors.h"
-
+#include "ttsubpixel.h"
/*************************************************************************/
/* */
@@ -166,6 +166,12 @@
loader->top_bearing = top_bearing;
loader->vadvance = advance_height;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( loader->exec ) loader->exec->sph_tweak_flags = 0x00000;
+ /* this may not be the right place for this, but it works */
+ if ( loader->exec && loader->exec->enhanced ) sph_set_tweaks( loader, glyph_index );
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
if ( !loader->linear_def )
{
loader->linear_def = 1;
@@ -1683,13 +1689,23 @@
IS_HINTED( loader->load_flags ) )
{
FT_Byte* widthp;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_Bool enhanced;
+ enhanced =
+ FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags )
+ != FT_RENDER_MODE_MONO );
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
widthp = tt_face_get_device_metrics( face,
size->root.metrics.x_ppem,
glyph_index );
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( ( !enhanced || BITMAP_WIDTHS ) && widthp )
+#else
if ( widthp )
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
glyph->metrics.horiAdvance = *widthp << 6;
}
@@ -1883,8 +1899,13 @@
{
TT_ExecContext exec;
FT_Bool grayscale;
-
-
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_Bool subpixel_hinting;
+ FT_Bool grayscale_hinting;
+ /*FT_Bool compatible_widths;
+ FT_Bool symmetrical_smoothing;
+ FT_Bool bgr;*/
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
if ( !size->cvt_ready )
{
FT_Error error = tt_size_ready_bytecode( size );
@@ -1898,20 +1919,75 @@
if ( !exec )
return TT_Err_Could_Not_Find_Context;
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ subpixel_hinting =
+ FT_BOOL( (FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO)
+ && SET_SUBPIXEL );
+
+ if ( subpixel_hinting ) grayscale = grayscale_hinting = FALSE;
+ else if ( SET_GRAYSCALE )
+ {
+ grayscale = grayscale_hinting = TRUE;
+ subpixel_hinting = FALSE;
+ }
+
+ exec->enhanced = ( subpixel_hinting
+ || grayscale_hinting );
+
+ exec->rasterizer_version = SET_RASTERIZER_VERSION;
+
+ exec->compatible_widths = SET_COMPATIBLE_WIDTHS;
+ /*FT_BOOL( FT_LOAD_TARGET_MODE( load_flags )
+ != TT_LOAD_COMPATIBLE_WIDTHS );*/
+
+ exec->symmetrical_smoothing = FALSE;
+ /*FT_BOOL( FT_LOAD_TARGET_MODE( load_flags )
+ != TT_LOAD_SYMMETRICAL_SMOOTHING );*/
+
+ exec->bgr = FALSE;
+ /*FT_BOOL( FT_LOAD_TARGET_MODE( load_flags )
+ != TT_LOAD_BGR );*/
+#else
grayscale =
FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO );
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
TT_Load_Context( exec, face, size );
- /* a change from mono to grayscale rendering (and vice versa) */
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+ /* a change from mono to subpixel rendering (and vice versa) */
/* requires a re-execution of the CVT program */
- if ( grayscale != exec->grayscale )
+ if ( subpixel_hinting != exec->subpixel_hinting )
+ {
+ FT_UInt i;
+
+ exec->subpixel_hinting = subpixel_hinting;
+
+ for ( i = 0; i < size->cvt_size; i++ )
+ size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
+ tt_size_run_prep( size );
+ }
+
+ /* a change from mono to grayscale rendering (and vice versa) */
+ /* requires a re-execution of the CVT program */
+ if ( grayscale != exec->grayscale_hinting )
{
FT_UInt i;
+ exec->grayscale_hinting = grayscale_hinting;
- FT_TRACE4(( "tt_loader_init: grayscale change,"
- " re-executing `prep' table\n" ));
+ for ( i = 0; i < size->cvt_size; i++ )
+ size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
+ tt_size_run_prep( size );
+ }
+#else
+
+ /* a change from mono to grayscale rendering (and vice versa) */
+ /* requires a re-execution of the CVT program */
+ if ( grayscale != exec->grayscale )
+ {
+ FT_UInt i;
exec->grayscale = grayscale;
@@ -1919,6 +1995,7 @@
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
tt_size_run_prep( size );
}
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* see whether the cvt program has disabled hinting */
if ( exec->GS.instruct_control & 1 )
@@ -2050,6 +2127,7 @@
if ( face->postscript.isFixedPitch &&
( load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ) == 0 )
glyph->linearHoriAdvance = face->horizontal.advance_Width_Max;
+
}
return TT_Err_Ok;
@@ -2125,6 +2203,9 @@
}
else
glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
+
+
+
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
diff -Nur freetype-2.4.3.orig/src/truetype/ttinterp.c freetype-2.4.3.new/src/truetype/ttinterp.c
--- freetype-2.4.3.orig/src/truetype/ttinterp.c 2010-10-01 01:08:19.000000000 -0500
+++ freetype-2.4.3.new/src/truetype/ttinterp.c 2010-11-14 09:25:21.736322597 -0600
@@ -27,10 +27,12 @@
#include "tterrors.h"
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#include "ttsubpixel.h"
+#endif
#ifdef TT_USE_BYTECODE_INTERPRETER
-
#define TT_MULFIX FT_MulFix
#define TT_MULDIV FT_MulDiv
#define TT_MULDIV_NO_ROUND FT_MulDiv_No_Round
@@ -150,11 +152,11 @@
#define NORMalize( x, y, v ) \
Normalize( EXEC_ARG_ x, y, v )
-#define SET_SuperRound( scale, flags ) \
- SetSuperRound( EXEC_ARG_ scale, flags )
+#define SET_SuperRound( scale, flags, res ) \
+ SetSuperRound( EXEC_ARG_ scale, flags, res )
-#define ROUND_None( d, c ) \
- Round_None( EXEC_ARG_ d, c )
+#define ROUND_None( d, c, e ) \
+ Round_None( EXEC_ARG_ d, c, e )
#define INS_Goto_CodeRange( range, ip ) \
Ins_Goto_CodeRange( EXEC_ARG_ range, ip )
@@ -165,8 +167,8 @@
#define CUR_Func_move_orig( z, p, d ) \
CUR.func_move_orig( EXEC_ARG_ z, p, d )
-#define CUR_Func_round( d, c ) \
- CUR.func_round( EXEC_ARG_ d, c )
+#define CUR_Func_round( d, c, e ) \
+ CUR.func_round( EXEC_ARG_ d, c, e )
#define CUR_Func_read_cvt( index ) \
CUR.func_read_cvt( EXEC_ARG_ index )
@@ -246,6 +248,12 @@
#define GUESS_VECTOR( V )
#endif
+
+ /*FT_Int CUR.num_delta_funcs;*/
+ /*FT_ULong inline_delta_funcs[5];*/
+ /*FT_Long CUR.infunc;*/
+
+
/*************************************************************************/
/* */
/* CODERANGE FUNCTIONS */
@@ -1838,24 +1846,33 @@
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
- v = CUR.GS.freeVector.x;
-
- if ( v != 0 )
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ if ( !CUR.enhanced || CUR.sph_tweak_flags & SPH_TWEAK_ALLOW_DMOVE_FREEV )
{
- zone->cur[point].x += TT_MULDIV( distance,
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+
+ v = CUR.GS.freeVector.x;
+
+ if ( v != 0 )
+ {
+ zone->cur[point].x += TT_MULDIV( distance,
v * 0x10000L,
CUR.F_dot_P );
- zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
+ zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
+ }
+
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
}
+#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
v = CUR.GS.freeVector.y;
if ( v != 0 )
{
zone->cur[point].y += TT_MULDIV( distance,
- v * 0x10000L,
- CUR.F_dot_P );
+ v * 0x10000L,
+ CUR.F_dot_P );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
@@ -1895,18 +1912,17 @@
if ( v != 0 )
zone->org[point].x += TT_MULDIV( distance,
- v * 0x10000L,
- CUR.F_dot_P );
+ v * 0x10000L,
+ CUR.F_dot_P );
v = CUR.GS.freeVector.y;
if ( v != 0 )
zone->org[point].y += TT_MULDIV( distance,
- v * 0x10000L,
- CUR.F_dot_P );
+ v * 0x10000L,
+ CUR.F_dot_P );
}
-