David Turner pushed to branch master at FreeType / FreeType
Commits:
-
6f273f68
by David Turner at 2021-06-16T10:28:47+02:00
-
f8c5c546
by David Turner at 2021-06-16T10:31:12+02:00
8 changed files:
- .gitignore
- meson.build
- meson_options.txt
- src/autofit/afglobal.c
- + tests/README.md
- + tests/issue-1063/main.c
- + tests/meson.build
- + tests/scripts/download-test-fonts.sh
Changes:
... | ... | @@ -4,3 +4,4 @@ include/dlg/ |
4 | 4 |
src/dlg/dlg.c
|
5 | 5 |
subprojects/*
|
6 | 6 |
!subprojects/*.wrap
|
7 |
+/tests/data/*
|
... | ... | @@ -369,6 +369,9 @@ pkgconfig.generate(ft2_lib, |
369 | 369 |
version: ft2_pkgconfig_version,
|
370 | 370 |
)
|
371 | 371 |
|
372 |
+if get_option('tests').enabled()
|
|
373 |
+ subdir('tests')
|
|
374 |
+endif
|
|
372 | 375 |
|
373 | 376 |
# NOTE: Unlike the old `make refdoc` command, this generates the
|
374 | 377 |
# documentation under `$BUILD/docs/` since Meson doesn't support modifying
|
... | ... | @@ -35,6 +35,11 @@ option('harfbuzz', |
35 | 35 |
+ ' If available, many glyphs not directly addressable'
|
36 | 36 |
+ ' by a font\'s character map will be hinted also.')
|
37 | 37 |
|
38 |
+option('tests',
|
|
39 |
+ type: 'feature',
|
|
40 |
+ value: 'disabled',
|
|
41 |
+ description: 'Enable FreeType unit and regression tests.')
|
|
42 |
+ |
|
38 | 43 |
option('brotli',
|
39 | 44 |
type: 'feature',
|
40 | 45 |
value: 'auto',
|
... | ... | @@ -478,6 +478,10 @@ |
478 | 478 |
{
|
479 | 479 |
style = (AF_Style)( globals->glyph_styles[gindex] &
|
480 | 480 |
AF_STYLE_UNASSIGNED );
|
481 |
+ /* IMPORTANT: Clear the error code, see
|
|
482 |
+ * https://gitlab.freedesktop.org/freetype/freetype/-/issues/1063
|
|
483 |
+ */
|
|
484 |
+ error = 0;
|
|
481 | 485 |
goto Again;
|
482 | 486 |
}
|
483 | 487 |
|
1 |
+# Unit and regression tests for the FreeType library
|
|
2 |
+ |
|
3 |
+## Quick Start
|
|
4 |
+ |
|
5 |
+### Download test fonts
|
|
6 |
+ |
|
7 |
+Run the `tests/scripts/download-fonts.sh` script, which will
|
|
8 |
+download test fonts to the `tests/data/` directory first.
|
|
9 |
+ |
|
10 |
+### Build the test programs
|
|
11 |
+ |
|
12 |
+The tests are only built with the Meson build system, and
|
|
13 |
+are disabled by default, enable the 'tests' option to compile
|
|
14 |
+them, as in:
|
|
15 |
+ |
|
16 |
+ meson setup out -Dtests=enabled
|
|
17 |
+ meson compile -C out
|
|
18 |
+ |
|
19 |
+### Run the test programs
|
|
20 |
+ |
|
21 |
+ meson test -C out
|
|
22 |
+ |
1 |
+#include <stdio.h>
|
|
2 |
+ |
|
3 |
+#include <freetype/freetype.h>
|
|
4 |
+#include <ft2build.h>
|
|
5 |
+ |
|
6 |
+int
|
|
7 |
+main( void )
|
|
8 |
+{
|
|
9 |
+ FT_Library library;
|
|
10 |
+ FT_Face face;
|
|
11 |
+ |
|
12 |
+ /* Assumes this is run from out/ build directory though 'meson test -C out' */
|
|
13 |
+ const char* filepath = "../tests/data/As.I.Lay.Dying.ttf";
|
|
14 |
+ |
|
15 |
+ FT_Init_FreeType( &library );
|
|
16 |
+ FT_New_Face( library, filepath, 0, &face );
|
|
17 |
+ if ( !face )
|
|
18 |
+ {
|
|
19 |
+ fprintf( stderr, "Could not open file: %s\n", filepath );
|
|
20 |
+ return 1;
|
|
21 |
+ }
|
|
22 |
+ |
|
23 |
+ for ( FT_ULong i = 59; i < 171; i++ )
|
|
24 |
+ {
|
|
25 |
+ FT_UInt gid = FT_Get_Char_Index( face, i );
|
|
26 |
+ FT_Error code = FT_Load_Glyph( face, gid, FT_LOAD_DEFAULT );
|
|
27 |
+ if ( code )
|
|
28 |
+ printf( "unknown %d for char %lu, gid %u\n", code, i, gid );
|
|
29 |
+ }
|
|
30 |
+ |
|
31 |
+ return 0;
|
|
32 |
+}
|
1 |
+test_issue_1063 = executable('issue-1063',
|
|
2 |
+ files([ 'issue-1063/main.c' ]),
|
|
3 |
+ dependencies: freetype_dep,
|
|
4 |
+)
|
|
5 |
+ |
|
6 |
+test('issue-1063', test_issue_1063, suite: 'regression')
|
|
7 |
+ |
1 |
+#!/usr/bin/bash
|
|
2 |
+# Download test fonts used by the FreeType regression test programs.
|
|
3 |
+# These will be copied to $FREETYPE/tests/data/
|
|
4 |
+# Each font file contains an 8-hexchar prefix corresponding to its md5sum
|
|
5 |
+ |
|
6 |
+set -e
|
|
7 |
+ |
|
8 |
+export LANG=C
|
|
9 |
+export LC_ALL=C
|
|
10 |
+ |
|
11 |
+PROGDIR=$(dirname "$0")
|
|
12 |
+PROGNAME=$(basename "$0")
|
|
13 |
+ |
|
14 |
+# Download a file from a given URL
|
|
15 |
+#
|
|
16 |
+# $1: URL
|
|
17 |
+# $2: Destination directory
|
|
18 |
+# $3: If not empty, destination file name. Default is to take
|
|
19 |
+# the URL's basename.
|
|
20 |
+#
|
|
21 |
+download_file () {
|
|
22 |
+ local URL=$1
|
|
23 |
+ local DST_DIR=$2
|
|
24 |
+ local DST_FILE=$3
|
|
25 |
+ if [[ -z "$DST_FILE" ]]; then
|
|
26 |
+ DST_FILE=$(basename "$URL")
|
|
27 |
+ fi
|
|
28 |
+ echo "URL: $URL"
|
|
29 |
+ wget -q -O "$DST_DIR/$DST_FILE" "$URL"
|
|
30 |
+}
|
|
31 |
+ |
|
32 |
+# $1: URL
|
|
33 |
+# $2: Destination directory
|
|
34 |
+# $3+: Optional file list, otherwise the full archive is extracted to $2
|
|
35 |
+download_and_extract_zip () {
|
|
36 |
+ local URL=$1
|
|
37 |
+ local DST_DIR=$2
|
|
38 |
+ shift
|
|
39 |
+ shift
|
|
40 |
+ TEMP_DST_DIR=$(mktemp -d)
|
|
41 |
+ TEMP_DST_NAME="a.zip"
|
|
42 |
+ download_file "$URL" "$TEMP_DST_DIR" "$TEMP_DST_NAME"
|
|
43 |
+ unzip -qo "$TEMP_DST_DIR/$TEMP_DST_NAME" -d "$DST_DIR" "$@"
|
|
44 |
+ rm -rf "$TEMP_DST_DIR"
|
|
45 |
+}
|
|
46 |
+ |
|
47 |
+# $1: File path
|
|
48 |
+# $2: Expected md5sum
|
|
49 |
+md5sum_check () {
|
|
50 |
+ local FILE=$1
|
|
51 |
+ local EXPECTED=$2
|
|
52 |
+ local HASH=$(md5sum "$FILE" | cut -d" " -f1)
|
|
53 |
+ if [[ "$EXPECTED" != "$HASH" ]]; then
|
|
54 |
+ echo "$FILE: Invalid md5sum $HASH expected $EXPECTED"
|
|
55 |
+ return 1
|
|
56 |
+ fi
|
|
57 |
+}
|
|
58 |
+ |
|
59 |
+INSTALL_DIR=$(cd $PROGDIR/.. && pwd)/data
|
|
60 |
+ |
|
61 |
+mkdir -p "$INSTALL_DIR"
|
|
62 |
+ |
|
63 |
+# See https://gitlab.freedesktop.org/freetype/freetype/-/issues/1063
|
|
64 |
+download_and_extract_zip "https://github.com/python-pillow/Pillow/files/6622147/As.I.Lay.Dying.zip" "$INSTALL_DIR"
|
|
65 |
+mv "$INSTALL_DIR/As I Lay Dying.ttf" "$INSTALL_DIR/As.I.Lay.Dying.ttf"
|
|
66 |
+md5sum_check "$INSTALL_DIR/As.I.Lay.Dying.ttf" e153d60e66199660f7cfe99ef4705ad7
|