Skip to content

Commit

Permalink
test(shapers): Add variable font shaping test
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jan 5, 2023
1 parent 9e8074c commit 31629bb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Makefile-fonts
Expand Up @@ -41,6 +41,12 @@ TESTFONTFILES += NotoSerifCJK-Regular.ttc
TESTFONTFILES += SBL_Hbrw.ttf
TESTFONTFILES += TwemojiMozilla.ttf

if FONT_VARIATIONS
TESTFONTFILES += Tourney[wdth,wght].ttf
endif

comma = ,
varencode = $(subst $(comma),%2C,$(subst [,%5B,$(subst ],%5D,$(1))))
notobase = $(shell echo $(notdir $1) | sed -e 's/-.*//')

# Tell make how to download individual font files directly (when available)
Expand All @@ -60,6 +66,9 @@ notobase = $(shell echo $(notdir $1) | sed -e 's/-.*//')
.fonts/Symbola.otf: | .fonts
$(CURL) -fsSL https://github.com/ChiefMikeK/ttf-symbola/raw/master/Symbola-13.otf -o $@

.fonts/Tourney%: | .fonts
$(CURL) -fsSL https://raw.githubusercontent.com/Etcetera-Type-Co/Tourney/643f1026ad6d41b4527f42cd93c776414fdd6503/fonts/variable/$(call varencode,$(notdir $@)) -o $@

.fonts/TwemojiMozilla.ttf: | .fonts
$(CURL) -fsSL https://github.com/mozilla/twemoji-colr/releases/download/v0.5.1/$(notdir $@) -o $@

Expand Down
9 changes: 9 additions & 0 deletions Makefile.am
Expand Up @@ -22,6 +22,15 @@ include Makefile-luarocks
# Actual rules for downloading test fonts are in a separate file
include Makefile-fonts

# Our regression test suite includes test for all features. Anything that is
# only expected to work with code behind a feature flag needs to be filtered
# out if we are configured with the feature disabled.
if !FONT_VARIATIONS
TESTSRCS ?= $_TESTSRCS
else
TESTSRCS ?= $(filter-out tests/variations-%,$(_TESTSRCS))
endif

# Since we can't use $(wildcard ...) in automake file lists, we generate a file
# with a script that builds our dynamic file lists instead. This is tricky,
# because if we just include the file automake will flatten this include. By
Expand Down
2 changes: 1 addition & 1 deletion build-aux/list-dist-files.sh.in
Expand Up @@ -16,7 +16,7 @@ finder lua-libraries -name '*.lua'
printf '\n%s' "LUAMODULES ="
finder lua_modules -not -name "'*~'"

printf '\n%s' "TESTSRCS ?="
printf '\n%s' "TESTSRCS :="
finder tests -maxdepth 1 -name '*.sil'
finder tests -maxdepth 1 -name '*.xml'
finder tests -maxdepth 1 -name '*.lua'
Expand Down
16 changes: 16 additions & 0 deletions tests/variations-axis.expected
@@ -0,0 +1,16 @@
Set paper size 297.6377985 419.5275636
Begin page
Mx 14.8819
My 56.9764
Set font Tourney;48;400;;normal;;wght=150,wdth=120;LTR
T 68 369 369 w=104.0880 (Foo)
Mx 138.3008
T 272 244 408 w=101.0400 (bar)
Mx 14.8819
My 114.5764
Set font Tourney;48;750;;normal;;wdth=80;LTR
T 68 369 369 w=68.3520 (Foo)
Mx 95.6771
T 272 244 408 w=72.2880 (bar)
End page
Finish
7 changes: 7 additions & 0 deletions tests/variations-axis.sil
@@ -0,0 +1,7 @@
\begin[papersize=a6]{document}
\neverindent
\nofolios
\font[family=Tourney,size=48pt]
\font[variations="wght=150,wdth=120"]{Foo bar}\par
\font[weight=750,variations=wdth=80]{Foo bar}
\end{document}

0 comments on commit 31629bb

Please sign in to comment.