From a15a711d0f8afd69f685da822dd3fd58a570927f Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda Date: Sat, 17 Feb 2024 11:16:20 +0100 Subject: [PATCH] =?UTF-8?q?P=C5=99echot=20na=20LuaTeX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formatitko.tex | 66 +++++++++++++++++++++++++++++++++ src/formatitko/tex_generator.py | 14 +++---- 2 files changed, 71 insertions(+), 9 deletions(-) diff --git a/formatitko.tex b/formatitko.tex index 47c5605..912ecb8 100644 --- a/formatitko.tex +++ b/formatitko.tex @@ -1,5 +1,41 @@ +\input ltluatex.tex \input luatex85.sty \input ucwmac2.tex +\ucwmodule{luaofs} +\ucwmodule{verb} +\ucwmodule{link} +\clickablefalse + + +\input minim-xmp.tex +\startmetadata + pdfaid:part 2 + pdfaid:conformance U + stopmetadata + + +\pdfobjcompresslevel=0 +% \pdfobj{/Alternate /DeviceRGB} + + +%Create an OutputIntent in order to correctly specify colours +\immediate\pdfobj stream attr{/N 3} file{sRGB.icc} +\pdfcatalog{% + /OutputIntents [ + << + /Type /OutputIntent + /S /GTS_PDFA1 + /DestOutputProfile \the\pdflastobj\space 0 R + /OutputConditionIdentifier (sRGB) + /Info (sRGB) + >> + ] +} + + + + + \parskip=5pt plus 3pt minus 2pt \parindent=0sp @@ -28,3 +64,33 @@ \long\def\blockquote#1{\vskip\lineskip\vskip\parskip\hbox{\vrule\hskip5pt\vbox{#1}}} \def\strikeout#1{FIXME: Strikeout not implemented} \def\underline#1{FIXME: Underline not implemented} + + +% Math (compatibility with KaTeX) +\font\mft=msbm10 +\def\mathbb#1{\hbox{\mft #1}} + + + +% Fonty +\ofsdeclarefamily [Pagella] {% + \loadtextfam qplr;% + qplb;% + qpli;% + qplbi;;% +} + +\def\MSfeat#1{:mode=node;script=latn;+tlig} +\registertfm qplr - file:texgyrepagella-regular.otf\MSfeat{} +\registertfm qplb - file:texgyrepagella-bold.otf\MSfeat{} +\registertfm qpli - file:texgyrepagella-italic.otf\MSfeat{} +\registertfm qplbi - file:texgyrepagella-bolditalic.otf\MSfeat{} + +\setfonts[Pagella/10] +\def\h{\it} % hint +\def\bh{\bi} % bold hint + +\def\N{{\mathbb N}} +\def\R{{\mathbb R}} +\def\O{{\cal O}} +\def\SYM{{\rm SYM}} diff --git a/src/formatitko/tex_generator.py b/src/formatitko/tex_generator.py index c97b90d..9222a5d 100644 --- a/src/formatitko/tex_generator.py +++ b/src/formatitko/tex_generator.py @@ -67,21 +67,17 @@ class UCWTexGenerator(OutputGenerator): self.writepar(r"\vskip5pt\hrule\hfil\vskip5pt{}") def generate_Doc(self, e: Doc): - self.writeln(r"\input ucwmac2.tex") - self.writeln(r"\ucwmodule{ofs}") - self.writeln(r"\ucwmodule{verb}") - self.writeln(r"\ucwmodule{link}") self.writeln(r"\input formatitko.tex") self.generate(e.content) self.writeln(r"\bye") def get_language_macro(self, lang: str): if lang == "cs": - return r"\chyph\lefthyphenmin=2\righthyphenmin=2{}" + return r"\uselanguage{czech}\frenchspacing\lefthyphenmin=2\righthyphenmin=2{}" elif lang == "sk": - return r"\shyph\lefthyphenmin=2\righthyphenmin=2{}" + return r"\uselanguage{slovak}\frenchspacing\lefthyphenmin=2\righthyphenmin=2{}" elif lang == "en": - return r"\ehyph\lefthyphenmin=2\righthyphenmin=2{}" + return r"\uselanguage{english}\nofrenchspacing\lefthyphenmin=2\righthyphenmin=2{}" else: return "" @@ -192,11 +188,11 @@ class UCWTexGenerator(OutputGenerator): def generate_Math(self, e: Math): if e.format == "DisplayMath": - self.ensure_empty(2) + self.ensure_empty(1) self.writeraw("$$") self.writeraw(e.text.strip()) self.writeraw("$$") - self.ensure_empty(2) + self.ensure_empty(1) else: self.write("$") self.write(e.text)