From 1c0c5a1f9a2cc17b8dcbec0f07f61311e398378c Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 28 Nov 2013 14:02:28 +1100 Subject: [PATCH] freetype/truetype: upgrade testdata to C Freetype 2.5.1. R=bsiegert CC=golang-dev, remyoudompheng https://codereview.appspot.com/33650044 --- cmd/print-glyph-points/main.c | 7 +------ freetype/truetype/truetype_test.go | 24 +++++++++++++++++++++++- testdata/luxisr-12pt-sans-hinting.txt | 1 + testdata/luxisr-12pt-with-hinting.txt | 1 + testdata/make-other-hinting-txts.sh | 4 ++++ 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/cmd/print-glyph-points/main.c b/cmd/print-glyph-points/main.c index 24d7308..9957b1e 100644 --- a/cmd/print-glyph-points/main.c +++ b/cmd/print-glyph-points/main.c @@ -43,12 +43,7 @@ int main(int argc, char** argv) { return 1; } FT_Library_Version(library, &major, &minor, &patch); - if ((major < 2) || ((major == 2) && (minor < 5))) { - fprintf(stderr, "%s needs freetype version >= 2.5.\n" - "Try setting LD_LIBRARY_PATH=/path/to/freetype_built_from_src/objs/.libs/\n", - argv[0]); - return 1; - } + printf("freetype version %d.%d.%d\n", major, minor, patch); error = FT_New_Face(library, argv[2], 0, &face); if (error) { fprintf(stderr, "FT_New_Face: error #%d\n", error); diff --git a/freetype/truetype/truetype_test.go b/freetype/truetype/truetype_test.go index cea20c1..e6465d4 100644 --- a/freetype/truetype/truetype_test.go +++ b/freetype/truetype/truetype_test.go @@ -262,9 +262,14 @@ var scalingTestCases = []struct { } var scalingExceptions = map[string]map[int]bool{ - // TODO: remove these exceptions when C Freetype version 2.5.1 is released: + // TODO: fix these exceptions now that C Freetype version 2.5.1 is released: // see http://lists.nongnu.org/archive/html/freetype/2013-11/msg00004.html "x-deja-vu-sans-oblique": map[int]bool{ + 269: true, + 733: true, + 734: true, + 2071: true, + 2072: true, 2077: true, 2078: true, 2171: true, @@ -299,6 +304,23 @@ func testScaling(t *testing.T, hinter *Hinter) { wants := [][]Point{} scanner := bufio.NewScanner(f) + if scanner.Scan() { + major, minor, patch := 0, 0, 0 + _, err := fmt.Sscanf(scanner.Text(), "freetype version %d.%d.%d", &major, &minor, &patch) + if err != nil { + t.Errorf("%s: version information: %v", tc.name, err) + } + if (major < 2) || (major == 2 && minor < 5) || (major == 2 && minor == 5 && patch < 1) { + t.Errorf("%s: need freetype version >= 2.5.1.\n"+ + "Try setting LD_LIBRARY_PATH=/path/to/freetype_built_from_src/objs/.libs/\n"+ + "and re-running testdata/make-other-hinting-txts.sh", + tc.name) + continue + } + } else { + t.Errorf("%s: no version information", tc.name) + continue + } for scanner.Scan() { wants = append(wants, scalingTestParse(scanner.Text())) } diff --git a/testdata/luxisr-12pt-sans-hinting.txt b/testdata/luxisr-12pt-sans-hinting.txt index f76e6f4..f901a7c 100644 --- a/testdata/luxisr-12pt-sans-hinting.txt +++ b/testdata/luxisr-12pt-sans-hinting.txt @@ -1,3 +1,4 @@ +freetype version 2.5.1 21 0 1, 21 555 1, 192 555 1, 192 0 1, 171 21 1, 171 534 1, 43 534 1, 43 21 1 diff --git a/testdata/luxisr-12pt-with-hinting.txt b/testdata/luxisr-12pt-with-hinting.txt index 8eb9aef..928e1a4 100644 --- a/testdata/luxisr-12pt-with-hinting.txt +++ b/testdata/luxisr-12pt-with-hinting.txt @@ -1,3 +1,4 @@ +freetype version 2.5.1 0 0 1, 0 576 1, 192 576 1, 192 0 1, 128 64 1, 128 512 1, 64 512 1, 64 64 1 diff --git a/testdata/make-other-hinting-txts.sh b/testdata/make-other-hinting-txts.sh index 6af1465..de165c3 100755 --- a/testdata/make-other-hinting-txts.sh +++ b/testdata/make-other-hinting-txts.sh @@ -18,6 +18,10 @@ ln -sf $FONTDIR/ttf-dejavu/DejaVuSans-Oblique.ttf x-deja-vu-sans-oblique.ttf ${CC:=gcc} ../cmd/print-glyph-points/main.c $(pkg-config --cflags --libs freetype2) -o print-glyph-points +# Uncomment these lines to also recreate the luxisr-*-hinting.txt files. +# ./print-glyph-points 12 luxisr.ttf sans_hinting > luxisr-12pt-sans-hinting.txt +# ./print-glyph-points 12 luxisr.ttf with_hinting > luxisr-12pt-with-hinting.txt + ./print-glyph-points 9 x-droid-sans-japanese.ttf sans_hinting > x-droid-sans-japanese-9pt-sans-hinting.txt ./print-glyph-points 9 x-droid-sans-japanese.ttf with_hinting > x-droid-sans-japanese-9pt-with-hinting.txt ./print-glyph-points 11 x-arial-bold.ttf sans_hinting > x-arial-bold-11pt-sans-hinting.txt