From 4466687a3a53e7868bd157ed6f8eac637ea182b5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 1 May 2013 15:41:49 +0200 Subject: draft for new auxlib --- tests/font_patch.tex | 6 +++++- tests/pln-aux-1.tex | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/pln-aux-1.tex (limited to 'tests') 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..f33ef21 --- /dev/null +++ b/tests/pln-aux-1.tex @@ -0,0 +1,45 @@ +\input luaotfload.sty +\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 -- cgit v1.2.3 From 7cf60286cb69e8b5ffc47c06bdc9a18bb941e306 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 1 May 2013 18:34:44 +0200 Subject: add feature related functionality to auxlib --- tests/pln-aux-1.tex | 4 +++ tests/pln-aux-2.tex | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 tests/pln-aux-2.tex (limited to 'tests') diff --git a/tests/pln-aux-1.tex b/tests/pln-aux-1.tex index f33ef21..a504850 100644 --- a/tests/pln-aux-1.tex +++ b/tests/pln-aux-1.tex @@ -1,4 +1,8 @@ \input luaotfload.sty + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% usage for glyph tests +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \baselineskip=17.28pt \font\iwonaregular=name:iwona at 14.4pt 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 -- cgit v1.2.3 From b5e475547fbd9cc6f9f9fe883f6ccd05d277b081 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 1 May 2013 20:18:38 +0200 Subject: add basic access functions for math dimensions --- tests/pln-aux-3.tex | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/pln-aux-3.tex (limited to 'tests') 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 -- cgit v1.2.3 From c0f5ff48cd1685b69bc7570ff4fb98bea7142993 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 1 May 2013 21:08:07 +0200 Subject: add glyph name <-> codepoint resolver --- tests/pln-aux-4.tex | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/pln-aux-4.tex (limited to 'tests') diff --git a/tests/pln-aux-4.tex b/tests/pln-aux-4.tex new file mode 100644 index 0000000..b025561 --- /dev/null +++ b/tests/pln-aux-4.tex @@ -0,0 +1,40 @@ +\input luaotfload.sty + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% unicode character mappings +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\font\ptserifregular = file:PTF55F.ttf \ptserifregular + +%% here we map the function luaotfload.aux.name_of_codepoint +%% on a short text, printing a list of letters, their codepoints +%% 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_codepoint(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 -- cgit v1.2.3 From eb4fdd2afe34627abece6f75187a2cd691bcf6db Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 2 May 2013 12:34:41 +0200 Subject: =?UTF-8?q?use=20=E2=80=9Cslots=E2=80=9D=20instead=20of=20?= =?UTF-8?q?=E2=80=9Ccodepoints=E2=80=9D=20in=20auxlib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/pln-aux-4.tex | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/pln-aux-4.tex b/tests/pln-aux-4.tex index b025561..80ffc0b 100644 --- a/tests/pln-aux-4.tex +++ b/tests/pln-aux-4.tex @@ -6,9 +6,10 @@ \font\ptserifregular = file:PTF55F.ttf \ptserifregular -%% here we map the function luaotfload.aux.name_of_codepoint -%% on a short text, printing a list of letters, their codepoints -%% and names (as specified in the Adobe Glyph List). +%% 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 @@ -21,7 +22,7 @@ for chr in string.utfcharacters(str) do local val = unicode.utf8.byte(chr) local line = chr .. " <> " .. tostring(val) - line = line .. " <> " .. (aux.name_of_codepoint(val) or "") + line = line .. " <> " .. (aux.name_of_slot(val) or "") res[\string#res+1] = line end return table.concat(res, [[\endgraf]]) -- cgit v1.2.3