From 1a48711fcceddd74fc10226302ade6c84859955e Mon Sep 17 00:00:00 2001 From: Max Chernoff Date: Sat, 17 Oct 2026 01:05:25 -0600 Subject: [PATCH 1/2] Support table specifications in `luaotfload.define_font` --- src/luaotfload-auxiliary.lua | 4 +- testfiles/define_font.lvt | 26 ++++++++ testfiles/define_font.tlg | 116 +++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 testfiles/define_font.lvt create mode 100644 testfiles/define_font.tlg diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua index e9353abf..bdaca22b 100644 --- a/src/luaotfload-auxiliary.lua +++ b/src/luaotfload-auxiliary.lua @@ -53,7 +53,9 @@ local luaotfload_callbacks = { } local function rewrite_fontname(tfmdata, specification) local format = tfmdata.format or tfmdata.properties.format - if stringfind (specification, " ") then + if type(specification) == "table" then + tfmdata.name = specification.name + elseif stringfind (specification, " ") then tfmdata.name = stringformat ("%q", specification) else --- other specs should parse just fine diff --git a/testfiles/define_font.lvt b/testfiles/define_font.lvt new file mode 100644 index 00000000..02d64ce3 --- /dev/null +++ b/testfiles/define_font.lvt @@ -0,0 +1,26 @@ +\input{regression-test} +\documentclass{article} +\begin{document} +\START + \BEGINBOXTEST{By string} + \directlua{ + tex.definefont("ByString", + luaotfload.define_font("texgyrepagella-regular", tex.sp "10pt") + ) + } + \ByString The quick brown fox jumps over the lazy dog. + \ENDBOXTEST + + \BEGINBOXTEST{By table} + \directlua{ + tex.definefont("ByTable", luaotfload.define_font { + lookup = "file", + name = "texgyrepagella-italic", + size = tex.sp "12pt", + features = {}, + }) + } + \ByTable The quick brown fox jumps over the lazy dog. + \ENDBOXTEST +\END +\end{document} diff --git a/testfiles/define_font.tlg b/testfiles/define_font.tlg new file mode 100644 index 00000000..9efce814 --- /dev/null +++ b/testfiles/define_font.tlg @@ -0,0 +1,116 @@ +This is a generated file for the l3build validation system. +Don't change this file in any respect. +============================================================ +TEST 1: By string +============================================================ +luaotfload | cache : Lookup cache loaded from ../luaotfload-lookup-cache.luc. +> \box...= +\hbox(7.28+2.83)x202.16002, direction TLT +.\ByString T +.\ByString h +.\ByString e +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString q +.\ByString u +.\ByString i +.\ByString c +.\ByString k +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString b +.\ByString r +.\ByString o +.\kern-0.25 (font) +.\ByString w +.\ByString n +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString f +.\kern-0.15 (font) +.\ByString o +.\kern-0.3 (font) +.\ByString x +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString j +.\ByString u +.\ByString m +.\kern-0.2 (font) +.\ByString p +.\ByString s +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString o +.\kern-0.25 (font) +.\ByString v +.\kern-0.4 (font) +.\ByString e +.\ByString r +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString t +.\kern0.15 (font) +.\ByString h +.\ByString e +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString l +.\ByString a +.\ByString z +.\ByString y +.\glue(\spaceskip) 2.5 plus 1.25 minus 0.83333 +.\ByString d +.\ByString o +.\ByString g +.\ByString . +! OK. + \TESTBOX +l. ... \ENDBOXTEST +============================================================ +============================================================ +TEST 2: By table +============================================================ +> \box...= +\hbox(8.796+3.312)x218.988, direction TLT +.\ByTable T +.\ByTable h +.\ByTable e +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable q +.\ByTable u +.\ByTable i +.\ByTable c +.\ByTable k +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable b +.\ByTable r +.\ByTable o +.\ByTable w +.\ByTable n +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable f +.\ByTable o +.\ByTable x +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable j +.\ByTable u +.\ByTable m +.\ByTable p +.\ByTable s +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable o +.\ByTable v +.\ByTable e +.\ByTable r +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable t +.\ByTable h +.\ByTable e +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable l +.\ByTable a +.\ByTable z +.\ByTable y +.\glue(\spaceskip) 3.0 plus 1.5 minus 1.0 +.\ByTable d +.\ByTable o +.\ByTable g +.\ByTable . +! OK. + \TESTBOX +l. ... \ENDBOXTEST +============================================================ From 8119a297c820102d3ad98dafc014c149c310dd3d Mon Sep 17 00:00:00 2001 From: Max Chernoff Date: Sat, 17 Oct 2026 01:09:36 -0600 Subject: [PATCH 2/2] Correctly highlight test files on GitHub --- .gitattributes | 1 + src/luaotfload-auxiliary.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..8abe1de0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.[lp]vt linguist-language=tex diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua index bdaca22b..670e9c0d 100644 --- a/src/luaotfload-auxiliary.lua +++ b/src/luaotfload-auxiliary.lua @@ -54,8 +54,9 @@ local luaotfload_callbacks = { } local function rewrite_fontname(tfmdata, specification) local format = tfmdata.format or tfmdata.properties.format if type(specification) == "table" then - tfmdata.name = specification.name - elseif stringfind (specification, " ") then + specification = specification.name + end + if stringfind (specification, " ") then tfmdata.name = stringformat ("%q", specification) else --- other specs should parse just fine