diff options
author | Robert Alessi <alessi@robertalessi.net> | 2020-11-11 09:54:05 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2020-11-11 09:54:05 +0100 |
commit | 3a507ecec035a656d16be9f7d0bb413eb0f9e8f2 (patch) | |
tree | 93a36f5481e81f44e2d93e880940f101e734d679 | |
parent | 979c54ddc6b64d582f676b18518a119aca327b5e (diff) | |
download | arabluatex-3a507ecec035a656d16be9f7d0bb413eb0f9e8f2.tar.gz |
check the renderer used for the Arabic font. (Thanks to M. Krueger and U. Fischer for telling me how do do this.)
-rw-r--r-- | arabluatex.dtx | 2 | ||||
-rw-r--r-- | arabluatex.lua | 92 | ||||
-rw-r--r-- | arabluatex_voc.lua | 13 |
3 files changed, 92 insertions, 15 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx index f7278f1..2972c0d 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx | |||
@@ -159,11 +159,11 @@ | |||
159 | \end{filecontents} | 159 | \end{filecontents} |
160 | \usepackage[letterpaper,margin=1.25in,left=50mm,nohead]{geometry} | 160 | \usepackage[letterpaper,margin=1.25in,left=50mm,nohead]{geometry} |
161 | \usepackage{fontspec} | 161 | \usepackage{fontspec} |
162 | \defaultfontfeatures{Renderer=Harfbuzz} | ||
162 | \usepackage[english]{babel} | 163 | \usepackage[english]{babel} |
163 | \usepackage{dox} | 164 | \usepackage{dox} |
164 | \doxitem{Option}{option}{options} | 165 | \doxitem{Option}{option}{options} |
165 | \usepackage{microtype} | 166 | \usepackage{microtype} |
166 | \defaultfontfeatures{Renderer=Harfbuzz} | ||
167 | \babelfont{rm}{Old Standard} | 167 | \babelfont{rm}{Old Standard} |
168 | \babelfont{sf}{NewComputerModern Sans} | 168 | \babelfont{sf}{NewComputerModern Sans} |
169 | \babelfont{tt}{NewComputerModern Mono} | 169 | \babelfont{tt}{NewComputerModern Mono} |
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) | |||
276 | return str | 276 | return str |
277 | end | 277 | end |
278 | 278 | ||
279 | -- I owe this function to M. Krüger and U. Fischer. Thank to them both. | ||
280 | local function getrenderer() | ||
281 | local a = nil | ||
282 | if font.getfont(font.current()).specification | ||
283 | then | ||
284 | a=font.getfont(font.current()).specification.features.normal.mode | ||
285 | end | ||
286 | return a | ||
287 | end | ||
288 | |||
279 | local function voc(str, rules) | 289 | local function voc(str, rules) |
280 | str = string.gsub(str, "\\arb(%b{})", function(inside) | 290 | str = string.gsub(str, "\\arb(%b{})", function(inside) |
281 | inside = string.sub(inside, 2, -2) | 291 | inside = string.sub(inside, 2, -2) |
@@ -311,8 +321,16 @@ local function voc(str, rules) | |||
311 | for i = 1,#shortv do | 321 | for i = 1,#shortv do |
312 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) | 322 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) |
313 | end | 323 | end |
314 | for i = 1,#punctuation do | 324 | if getrenderer() == "harf" |
315 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | 325 | then |
326 | for i = 1,#punctuationhb do | ||
327 | inside = string.gsub(inside, punctuationhb[i].a, | ||
328 | punctuationhb[i].b) | ||
329 | end | ||
330 | else | ||
331 | for i = 1,#punctuation do | ||
332 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | ||
333 | end | ||
316 | end | 334 | end |
317 | for i = 1,#null do | 335 | for i = 1,#null do |
318 | inside = string.gsub(inside, null[i].a, null[i].b) | 336 | inside = string.gsub(inside, null[i].a, null[i].b) |
@@ -347,8 +365,16 @@ local function voceasy(str) | |||
347 | for i = 1,#shortv do | 365 | for i = 1,#shortv do |
348 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) | 366 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) |
349 | end | 367 | end |
350 | for i = 1,#punctuation do | 368 | if getrenderer() == "harf" |
351 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | 369 | then |
370 | for i = 1,#punctuationhb do | ||
371 | inside = string.gsub(inside, punctuationhb[i].a, | ||
372 | punctuationhb[i].b) | ||
373 | end | ||
374 | else | ||
375 | for i = 1,#punctuation do | ||
376 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | ||
377 | end | ||
352 | end | 378 | end |
353 | for i = 1,#null do | 379 | for i = 1,#null do |
354 | inside = string.gsub(inside, null[i].a, null[i].b) | 380 | inside = string.gsub(inside, null[i].a, null[i].b) |
@@ -400,8 +426,16 @@ local function fullvoc(str, rules) | |||
400 | for i = 1,#shortv do | 426 | for i = 1,#shortv do |
401 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) | 427 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) |
402 | end | 428 | end |
403 | for i = 1,#punctuation do | 429 | if getrenderer() == "harf" |
404 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | 430 | then |
431 | for i = 1,#punctuationhb do | ||
432 | inside = string.gsub(inside, punctuationhb[i].a, | ||
433 | punctuationhb[i].b) | ||
434 | end | ||
435 | else | ||
436 | for i = 1,#punctuation do | ||
437 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | ||
438 | end | ||
405 | end | 439 | end |
406 | for i = 1,#null do | 440 | for i = 1,#null do |
407 | inside = string.gsub(inside, null[i].a, null[i].b) | 441 | inside = string.gsub(inside, null[i].a, null[i].b) |
@@ -448,8 +482,16 @@ local function fullvoceasy(str, rules) | |||
448 | for i = 1,#shortv do | 482 | for i = 1,#shortv do |
449 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) | 483 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) |
450 | end | 484 | end |
451 | for i = 1,#punctuation do | 485 | if getrenderer() == "harf" |
452 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | 486 | then |
487 | for i = 1,#punctuationhb do | ||
488 | inside = string.gsub(inside, punctuationhb[i].a, | ||
489 | punctuationhb[i].b) | ||
490 | end | ||
491 | else | ||
492 | for i = 1,#punctuation do | ||
493 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | ||
494 | end | ||
453 | end | 495 | end |
454 | for i = 1,#null do | 496 | for i = 1,#null do |
455 | inside = string.gsub(inside, null[i].a, null[i].b) | 497 | inside = string.gsub(inside, null[i].a, null[i].b) |
@@ -484,8 +526,16 @@ local function novoc(str) | |||
484 | for i = 1,#shortvnv do | 526 | for i = 1,#shortvnv do |
485 | inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b) | 527 | inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b) |
486 | end | 528 | end |
487 | for i = 1,#punctuation do | 529 | if getrenderer() == "harf" |
488 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | 530 | then |
531 | for i = 1,#punctuationhb do | ||
532 | inside = string.gsub(inside, punctuationhb[i].a, | ||
533 | punctuationhb[i].b) | ||
534 | end | ||
535 | else | ||
536 | for i = 1,#punctuation do | ||
537 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | ||
538 | end | ||
489 | end | 539 | end |
490 | for i = 1,#null do | 540 | for i = 1,#null do |
491 | inside = string.gsub(inside, null[i].a, null[i].b) | 541 | inside = string.gsub(inside, null[i].a, null[i].b) |
@@ -520,8 +570,16 @@ local function novoceasy(str) | |||
520 | for i = 1,#shortvnv do | 570 | for i = 1,#shortvnv do |
521 | inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b) | 571 | inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b) |
522 | end | 572 | end |
523 | for i = 1,#punctuation do | 573 | if getrenderer() == "harf" |
524 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | 574 | then |
575 | for i = 1,#punctuationhb do | ||
576 | inside = string.gsub(inside, punctuationhb[i].a, | ||
577 | punctuationhb[i].b) | ||
578 | end | ||
579 | else | ||
580 | for i = 1,#punctuation do | ||
581 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | ||
582 | end | ||
525 | end | 583 | end |
526 | for i = 1,#null do | 584 | for i = 1,#null do |
527 | inside = string.gsub(inside, null[i].a, null[i].b) | 585 | inside = string.gsub(inside, null[i].a, null[i].b) |
@@ -1174,8 +1232,14 @@ function arabluatex.abjadify(n) | |||
1174 | end | 1232 | end |
1175 | 1233 | ||
1176 | function arabluatex.abraces(str) | 1234 | function arabluatex.abraces(str) |
1177 | if tex.textdir == "TRT" then | 1235 | if tex.textdir == "TRT" |
1178 | str = "\\}"..str.."\\{" | 1236 | then |
1237 | if getrenderer() == "harf" | ||
1238 | then | ||
1239 | str = "\\{"..str.."\\}" | ||
1240 | else | ||
1241 | str = "\\}"..str.."\\{" | ||
1242 | end | ||
1179 | elseif tex.textdir == "TLT" then | 1243 | elseif tex.textdir == "TLT" then |
1180 | str = "\\{"..str.."\\}" | 1244 | str = "\\{"..str.."\\}" |
1181 | end | 1245 | end |
diff --git a/arabluatex_voc.lua b/arabluatex_voc.lua index 4ec0fe3..7301540 100644 --- a/arabluatex_voc.lua +++ b/arabluatex_voc.lua | |||
@@ -873,6 +873,19 @@ shortv = { | |||
873 | {a="i", b="ِ"} | 873 | {a="i", b="ِ"} |
874 | } | 874 | } |
875 | 875 | ||
876 | punctuationhb = { | ||
877 | {a="%(%(", b="﴿"}, | ||
878 | {a="%)%)", b="﴾"}, | ||
879 | {a="%.", b="."}, | ||
880 | -- replaced with the next two rules to make the Arabic comma work | ||
881 | -- after \abraces{} | ||
882 | -- {a="([^0-9])%,", b="%1،"}, | ||
883 | {a="%,", b="،"}, | ||
884 | {a="([%d])%،", b="%1,"}, | ||
885 | {a="%?", b="؟"}, | ||
886 | {a="%;", b="؛"}, | ||
887 | } | ||
888 | |||
876 | punctuation = { | 889 | punctuation = { |
877 | {a="%(%(", b="﴿"}, | 890 | {a="%(%(", b="﴿"}, |
878 | {a="%)%)", b="﴾"}, | 891 | {a="%)%)", b="﴾"}, |