diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/font_patch.tex | 6 | ||||
-rw-r--r-- | tests/pln-aux-1.tex | 49 | ||||
-rw-r--r-- | tests/pln-aux-2.tex | 102 | ||||
-rw-r--r-- | tests/pln-aux-3.tex | 39 | ||||
-rw-r--r-- | tests/pln-aux-4.tex | 41 | ||||
-rw-r--r-- | tests/pln-request-4-slashed.tex | 12 | ||||
-rw-r--r-- | tests/pln-request-5-cached.tex | 18 | ||||
-rw-r--r-- | tests/pln-subfont-1.tex | 12 | ||||
-rw-r--r-- | tests/pln-tfm.tex | 10 |
9 files changed, 288 insertions, 1 deletions
diff --git a/tests/font_patch.tex b/tests/font_patch.tex index d41ff48..d3bba07 100644 --- a/tests/font_patch.tex +++ b/tests/font_patch.tex @@ -8,7 +8,11 @@ mc.DisplayOperatorMinHeight = 2800 / em * sz end end - luatexbase.add_to_callback("luaotfload.patch_font", patch, "cambria.domh") + %% part of luaotfload-auxiliary + %luatexbase.add_to_callback( + %"luaotfload.patch_font", + %patch, + %"luaotfload.aux.patch_cambria_domh") } \font\4={name:Cambria Math:mode=base;script=math} at 10pt diff --git a/tests/pln-aux-1.tex b/tests/pln-aux-1.tex new file mode 100644 index 0000000..a504850 --- /dev/null +++ b/tests/pln-aux-1.tex @@ -0,0 +1,49 @@ +\input luaotfload.sty + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% usage for glyph tests +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\baselineskip=17.28pt + +\font\iwonaregular=name:iwona at 14.4pt +\font\lmromanten=file:lmroman10-regular.otf at 14.4pt +\font\cmuregular=file:cmunrm.otf at 14.4pt + +%% wrap tests in macros (could move to style file) +\def\doifglyphelse#1#2#3{% + \directlua{ + luaotfload.aux.do_if_glyph_else([[#1]], [[#2]], [[#3]]) + }% +} + +\def\doifglyph#1#2{\doifglyphelse{#1}{#2}{}} + +%% no otf font loaded yet, so both fail: +first: +\doifglyphelse{a}{true}{false} +\doifglyph {a}{yep} + +%% load lm and try repeat: +\lmromanten +second: +\doifglyphelse{a}{true}{false} +\doifglyph {a}{yep} + +%% let’s test some more free fonts +\def\checkglyphset{% + \doifglyphelse ö{ö}{nope} + \doifglyphelse п{п}{nope} + \doifglyphelse α{α}{nope} + \doifglyphelse Æ{Æ}{nope} + \doifglyphelse ą{ą}{nope} + \doifglyphelse ř{ř}{nope} + \doifglyphelse ˝{˝}{nope} + \doifglyphelse ѩ{ѩ}{nope} + \endgraf +} + +\iwonaregular \checkglyphset +\lmromanten \checkglyphset +\cmuregular \checkglyphset + +\bye diff --git a/tests/pln-aux-2.tex b/tests/pln-aux-2.tex new file mode 100644 index 0000000..62192a5 --- /dev/null +++ b/tests/pln-aux-2.tex @@ -0,0 +1,102 @@ +\input luaotfload.sty +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% script, features, and language +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\font\minionregular=file:MinionPro_Regular.otf at 9pt +\font\biolinum=file:LinBiolinum_R.otf at 9pt +\font\cmuregular=file:cmunrm.otf at 9pt + +%% (1) luaotfload.aux.provides_script(font_id, script) +%% #1 defined font; #2 OT script tag +\def\providesscript[#1][#2]{% + \bgroup#1% + let’s see whether \detokenize{#1} has script #2: + \directlua{ + local aux = luaotfload.aux + local succ = aux.provides_script(font.current(), [[#2]]) + if succ then tex.sprint"true" else tex.sprint"false" end + }% + \egroup + \endgraf% +} + +\providesscript [\minionregular][latn]%% Latin +\providesscript [\biolinum][latn] +\providesscript [\cmuregular][latn] +\providesscript [\minionregular][cyrl]%% Cyrillic +\providesscript [\biolinum][cyrl] +\providesscript [\cmuregular][cyrl] +\providesscript [\minionregular][tibt]%% Tibetan +\providesscript [\biolinum][tibt] +\providesscript [\cmuregular][tibt] + +\hrule % -------------------------------------------------------------- + +%% (2) luaotfload.aux.provides_language(font_id, script, language) +%% #1 defined font; #2 OT script tag; #3 OT language tag +\def\provideslanguage[#1][#2][#3]{% + \bgroup#1% + let’s see whether \detokenize{#1} supports language #3 for script #2: + \directlua{ + local aux = luaotfload.aux + local succ = aux.provides_language(font.current(), [[#2]], [[#3]]) + if succ then tex.sprint"true" else tex.sprint"false" end + }% + \egroup + \endgraf% +} + +\provideslanguage [\minionregular][latn][nld]%% Latin/Dutch +\provideslanguage [\biolinum][latn][nld] +\provideslanguage [\cmuregular][latn][nld] +\provideslanguage [\minionregular][latn][deu]%% Latin/German +\provideslanguage [\biolinum][latn][deu] +\provideslanguage [\cmuregular][latn][deu] +\provideslanguage [\minionregular][cyrl][rus]%% Cyrillic/Russian +\provideslanguage [\biolinum][cyrl][rus] +\provideslanguage [\cmuregular][cyrl][rus] +\provideslanguage [\minionregular][cyrl][klm]%% Cyrillic/Kalmyk +\provideslanguage [\biolinum][cyrl][klm] +\provideslanguage [\cmuregular][cyrl][klm] +\provideslanguage [\minionregular][cyrl][srb]%% Cyrillic/Serbian +\provideslanguage [\biolinum][cyrl][srb] +\provideslanguage [\cmuregular][cyrl][srb] +\provideslanguage [\minionregular][tibt][tib]%% Tibetan +\provideslanguage [\biolinum][tibt][tib] +\provideslanguage [\cmuregular][tibt][tib] + +\hrule % -------------------------------------------------------------- + +%% (3) luaotfload.aux.provides_feature( +%% font_id, script, language, feature) +%% #1 defined font; #2 OT script tag; +%% #3 OT language tag; #4 OT feature +\def\providesfeature[#1][#2][#3][#4]{%this is getting ridiculous + \bgroup#1% + let’s see whether \detokenize{#1} supports feature #4 for the + combination of script #2 with language #3: + \directlua{ + local aux = luaotfload.aux + local succ = aux.provides_feature( + font.current(), [[#2]], [[#3]], [[#4]]) + if succ then tex.sprint"true" else tex.sprint"false" end + }% + \egroup + \endgraf% +} + +\providesfeature [\minionregular][latn][nld][liga]%% Latin/Dutch +\providesfeature [\biolinum][latn][nld][liga] +\providesfeature [\cmuregular][latn][nld][liga] +\providesfeature [\minionregular][latn][deu][liga]%% Latin/German +\providesfeature [\biolinum][latn][deu][liga] +\providesfeature [\cmuregular][latn][deu][liga] +\providesfeature [\minionregular][cyrl][srb][liga]%% Cyrillic/Serbian +\providesfeature [\biolinum][cyrl][srb][liga] +\providesfeature [\cmuregular][cyrl][srb][liga] +\providesfeature [\minionregular][tibt][tib][liga]%% Tibetan +\providesfeature [\biolinum][tibt][tib][liga] +\providesfeature [\cmuregular][tibt][tib][liga] + +\bye diff --git a/tests/pln-aux-3.tex b/tests/pln-aux-3.tex new file mode 100644 index 0000000..12a80cf --- /dev/null +++ b/tests/pln-aux-3.tex @@ -0,0 +1,39 @@ +\input luaotfload.sty + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% math dimension getter +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\font\xitsmath=file:xits-math.otf +\font\cambriamath=file:cambria.ttc(1) + +\font\main=file:Iwona-Regular.otf at 12pt\main + +\directlua{ + local aux = luaotfload.aux + local test_a = function (fontname, dimension) + tex.sprint( + "(", fontname, " (", dimension, " ", + aux.get_math_dimension(fontname, dimension), + [[))\endgraf ]]) + end + + local test_b = function (fontname, dimension) + aux.sprint_math_dimension(fontname, dimension) + tex.print[[\endgraf ]] + end + + test_a("xitsmath", "AxisHeight") + test_a("xitsmath", "RadicalVerticalGap") + test_a("cambriamath", "StackTopShiftUp") + test_a("cambriamath", "FractionNumeratorGapMin") + + test_b("xitsmath", "AxisHeight") + test_b("xitsmath", "RadicalVerticalGap") + test_b("cambriamath", "StackTopShiftUp") + test_b("cambriamath", "FractionNumeratorGapMin") +} + +foo bar baz + +\bye diff --git a/tests/pln-aux-4.tex b/tests/pln-aux-4.tex new file mode 100644 index 0000000..80ffc0b --- /dev/null +++ b/tests/pln-aux-4.tex @@ -0,0 +1,41 @@ +\input luaotfload.sty + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% unicode character mappings +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\font\ptserifregular = file:PTF55F.ttf \ptserifregular + +%% here we map the function luaotfload.aux.name_of_slot +%% on a short text, printing a list of letters, their +%% code points and names (as specified in the Adobe +%% Glyph List). + +\directlua{ + local aux = luaotfload.aux + local cbk = function (str) + if string.match(str, "^EOF") then + luatexbase.remove_from_callback("process_input_buffer", "weird") + return [[the end!]] + end + local res = { } + for chr in string.utfcharacters(str) do + local val = unicode.utf8.byte(chr) + local line = chr .. " <> " .. tostring(val) + line = line .. " <> " .. (aux.name_of_slot(val) or "") + res[\string#res+1] = line + end + return table.concat(res, [[\endgraf]]) + end + + luatexbase.add_to_callback("process_input_buffer", cbk, "weird") +} + +Я узнал что у меня +Есть огромная семья +И тропинка и лесок +В поле каждый колосок + +EOF + +\bye diff --git a/tests/pln-request-4-slashed.tex b/tests/pln-request-4-slashed.tex new file mode 100644 index 0000000..5e7d99e --- /dev/null +++ b/tests/pln-request-4-slashed.tex @@ -0,0 +1,12 @@ +\ifdefined\directlua\input luaotfload.sty\fi +\font\iwona =iwona at 20pt +\font\iwonabold =iwona/b at 20pt +\font\iwonaitalic =iwona/i at 20pt +\font\iwonabolditalic =iwona/bi at 20pt + +\def\test{foo bar baz \endgraf} +{\iwona \test} +{\iwonabold \test} +{\iwonaitalic \test} +{\iwonabolditalic \test} +\bye diff --git a/tests/pln-request-5-cached.tex b/tests/pln-request-5-cached.tex new file mode 100644 index 0000000..8ba4a5e --- /dev/null +++ b/tests/pln-request-5-cached.tex @@ -0,0 +1,18 @@ +\ifdefined\directlua + \directlua{config = config or { luaotfload = { } } + config.luaotfload.resolver = "cached" + config.luaotfload.loglevel = 5 } + \input luaotfload.sty +\fi + +\font\iwona =name:iwona at 20pt +\font\iwonabold =name:iwona/b at 20pt +\font\iwonaitalic =name:iwona/i at 20pt +\font\iwonabolditalic =name:iwona/bi at 20pt + +\def\test{foo bar baz \endgraf} +{\iwona \test} +{\iwonabold \test} +{\iwonaitalic \test} +{\iwonabolditalic \test} +\bye diff --git a/tests/pln-subfont-1.tex b/tests/pln-subfont-1.tex new file mode 100644 index 0000000..fb8e1e7 --- /dev/null +++ b/tests/pln-subfont-1.tex @@ -0,0 +1,12 @@ +\ifdefined\directlua\input luaotfload.sty\fi +%% This requires the Cambria fonts from MS. +\directlua{ + inspect(fontloader.info"cambria.ttc") +} +%% Here we load both subfonts in the collection +%% with the not-quite documented subfont syntax. +\font\subfontone="file:cambria.ttc(0)" at 42pt +\font\subfonttwo="file:cambria.ttc(1)" at 42pt +\subfontone foo bar baz \endgraf +\subfonttwo foo bar baz \endgraf +\bye diff --git a/tests/pln-tfm.tex b/tests/pln-tfm.tex new file mode 100644 index 0000000..16ae41a --- /dev/null +++ b/tests/pln-tfm.tex @@ -0,0 +1,10 @@ +\ifdefined\directlua\input luaotfload.sty \fi +%% TFM’s can be loaded with a file: request ... +\font\antykwatorunska="file:rm-anttr" +%% or with an anonymous request, like in þe olde TeX: +\font\antykwatorunskabcap=ec-anttbcap +\font\lmromanten={file:ec-lmr10} at 10pt +\antykwatorunska foo bar +\antykwatorunskabcap baz xyzzy +\lmromanten Donde, está, la biblioteca. Me llamo T-Bone La araña discoteca. +\bye |