From 3a507ecec035a656d16be9f7d0bb413eb0f9e8f2 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Wed, 11 Nov 2020 09:54:05 +0100 Subject: check the renderer used for the Arabic font. (Thanks to M. Krueger and U. Fischer for telling me how do do this.) --- arabluatex.lua | 92 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 14 deletions(-) (limited to 'arabluatex.lua') diff --git a/arabluatex.lua b/arabluatex.lua index 7372e86..8e97fa1 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -276,6 +276,16 @@ local function takeoutarb(str) return str end +-- I owe this function to M. Krüger and U. Fischer. Thank to them both. +local function getrenderer() + local a = nil + if font.getfont(font.current()).specification + then + a=font.getfont(font.current()).specification.features.normal.mode + end + return a +end + local function voc(str, rules) str = string.gsub(str, "\\arb(%b{})", function(inside) inside = string.sub(inside, 2, -2) @@ -311,8 +321,16 @@ local function voc(str, rules) for i = 1,#shortv do inside = string.gsub(inside, shortv[i].a, shortv[i].b) end - for i = 1,#punctuation do - inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + if getrenderer() == "harf" + then + for i = 1,#punctuationhb do + inside = string.gsub(inside, punctuationhb[i].a, + punctuationhb[i].b) + end + else + for i = 1,#punctuation do + inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + end end for i = 1,#null do inside = string.gsub(inside, null[i].a, null[i].b) @@ -347,8 +365,16 @@ local function voceasy(str) for i = 1,#shortv do inside = string.gsub(inside, shortv[i].a, shortv[i].b) end - for i = 1,#punctuation do - inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + if getrenderer() == "harf" + then + for i = 1,#punctuationhb do + inside = string.gsub(inside, punctuationhb[i].a, + punctuationhb[i].b) + end + else + for i = 1,#punctuation do + inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + end end for i = 1,#null do inside = string.gsub(inside, null[i].a, null[i].b) @@ -400,8 +426,16 @@ local function fullvoc(str, rules) for i = 1,#shortv do inside = string.gsub(inside, shortv[i].a, shortv[i].b) end - for i = 1,#punctuation do - inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + if getrenderer() == "harf" + then + for i = 1,#punctuationhb do + inside = string.gsub(inside, punctuationhb[i].a, + punctuationhb[i].b) + end + else + for i = 1,#punctuation do + inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + end end for i = 1,#null do inside = string.gsub(inside, null[i].a, null[i].b) @@ -448,8 +482,16 @@ local function fullvoceasy(str, rules) for i = 1,#shortv do inside = string.gsub(inside, shortv[i].a, shortv[i].b) end - for i = 1,#punctuation do - inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + if getrenderer() == "harf" + then + for i = 1,#punctuationhb do + inside = string.gsub(inside, punctuationhb[i].a, + punctuationhb[i].b) + end + else + for i = 1,#punctuation do + inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + end end for i = 1,#null do inside = string.gsub(inside, null[i].a, null[i].b) @@ -484,8 +526,16 @@ local function novoc(str) for i = 1,#shortvnv do inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b) end - for i = 1,#punctuation do - inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + if getrenderer() == "harf" + then + for i = 1,#punctuationhb do + inside = string.gsub(inside, punctuationhb[i].a, + punctuationhb[i].b) + end + else + for i = 1,#punctuation do + inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + end end for i = 1,#null do inside = string.gsub(inside, null[i].a, null[i].b) @@ -520,8 +570,16 @@ local function novoceasy(str) for i = 1,#shortvnv do inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b) end - for i = 1,#punctuation do - inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + if getrenderer() == "harf" + then + for i = 1,#punctuationhb do + inside = string.gsub(inside, punctuationhb[i].a, + punctuationhb[i].b) + end + else + for i = 1,#punctuation do + inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + end end for i = 1,#null do inside = string.gsub(inside, null[i].a, null[i].b) @@ -1174,8 +1232,14 @@ function arabluatex.abjadify(n) end function arabluatex.abraces(str) - if tex.textdir == "TRT" then - str = "\\}"..str.."\\{" + if tex.textdir == "TRT" + then + if getrenderer() == "harf" + then + str = "\\{"..str.."\\}" + else + str = "\\}"..str.."\\{" + end elseif tex.textdir == "TLT" then str = "\\{"..str.."\\}" end -- cgit v1.2.3