summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/plain/pitex/fonts.ptx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/plain/pitex/fonts.ptx')
-rw-r--r--Master/texmf-dist/tex/plain/pitex/fonts.ptx345
1 files changed, 263 insertions, 82 deletions
diff --git a/Master/texmf-dist/tex/plain/pitex/fonts.ptx b/Master/texmf-dist/tex/plain/pitex/fonts.ptx
index 6a3ceb019a8..a504846d6b0 100644
--- a/Master/texmf-dist/tex/plain/pitex/fonts.ptx
+++ b/Master/texmf-dist/tex/plain/pitex/fonts.ptx
@@ -1,44 +1,48 @@
-% I think my version of the following package might be modified.
-% So no way to be sure it'll work but on my computer
-% (anyway I use non-free fonts, so).
-%
-\input luaotfload.sty
+\inputluafile fonts.ptxlua
\pdfadjustspacing=2
-\directlua{%
-% From otfl-font-dum.lua
- local byte = string.byte
- fonts.expansions.setups['threepercent'] = {
-
- stretch = 3, shrink = 3, step = .5, factor = 1,
-
- [byte('A')] = 0.5, [byte('B')] = 0.7, [byte('C')] = 0.7, [byte('D')] = 0.5, [byte('E')] = 0.7,
- [byte('F')] = 0.7, [byte('G')] = 0.5, [byte('H')] = 0.7, [byte('K')] = 0.7, [byte('M')] = 0.7,
- [byte('N')] = 0.7, [byte('O')] = 0.5, [byte('P')] = 0.7, [byte('Q')] = 0.5, [byte('R')] = 0.7,
- [byte('S')] = 0.7, [byte('U')] = 0.7, [byte('W')] = 0.7, [byte('Z')] = 0.7,
- [byte('a')] = 0.7, [byte('b')] = 0.7, [byte('c')] = 0.7, [byte('d')] = 0.7, [byte('e')] = 0.7,
- [byte('g')] = 0.7, [byte('h')] = 0.7, [byte('k')] = 0.7, [byte('m')] = 0.7, [byte('n')] = 0.7,
- [byte('o')] = 0.7, [byte('p')] = 0.7, [byte('q')] = 0.7, [byte('s')] = 0.7, [byte('u')] = 0.7,
- [byte('w')] = 0.7, [byte('z')] = 0.7, [byte('2')] = 0.7, [byte('3')] = 0.7, [byte('6')] = 0.7,
- [byte('8')] = 0.7, [byte('9')] = 0.7,
- }
- }
+
\def\currentfont{}
+\def\currentsize{normal}
\def\currentstyle{rm}
\def\currentweight{rg}
\def\currentcase{lc}
\def\makecurrentfont{%
- \csname\currentfont @\currentstyle @\currentweight @\currentcase\endcsname
+ \csname\currentfont @\currentsize @\currentstyle @\currentweight @\currentcase\endcsname
}
-\def\it{%
- \def\currentstyle{it}%
+\def\normalsize{%
+ \def\currentsize{normal}%
\makecurrentfont
}
-\def\bf{%
- \def\currentweight{bf}%
+\def\small{%
+ \def\currentsize{small}%
\makecurrentfont
- }
-\def\sc{%
- \def\currentcase{sc}%
+ }
+\def\verysmall{%
+ \def\currentsize{verysmall}%
+ \makecurrentfont
+ }
+\def\smaller{%
+ \passexpanded\ifstring\currentsize{normal}%
+ {\def\currentsize{small}}
+ {\def\currentsize{verysmall}}
+ \makecurrentfont
+ }
+\def\big{%
+ \def\currentsize{big}%
+ \makecurrentfont
+ }
+\def\verybig{%
+ \def\currentsize{verybig}%
+ \makecurrentfont
+ }
+\def\bigger{%
+ \passexpanded\ifstring\currentsize{normal}%
+ {\def\currentsize{big}}
+ {\def\currentsize{verybig}}
+ \makecurrentfont
+ }
+\def\it{%
+ \def\currentstyle{it}%
\makecurrentfont
}
\def\rm{%
@@ -46,10 +50,6 @@
\makecurrentfont
}
\def\rmstring{rm}
-\def\ital#1{{\it#1}}
-\def\bold#1{{\bf#1}}
-\def\scap#1{{\sc#1}}
-\def\rom#1{{\rm#1}}
\def\emph{%
\ifx\currentstyle\rmstring
\expandafter\ital
@@ -57,71 +57,252 @@
\expandafter\rom
\fi
}
+\def\bf{%
+ \def\currentweight{bf}%
+ \makecurrentfont
+ }
+%\def\normalweight{%
+\def\rg{%
+ \def\currentweight{rg}%
+ \makecurrentfont
+ }
+\def\sc{%
+ \def\currentcase{sc}%
+ \makecurrentfont
+ }
+%\def\normalcase{%
+\def\lc{%
+ \def\currentcase{lc}%
+ \makecurrentfont
+ }
+\freedef\ital{{\it#1}}
+\freedef\bold{{\bf#1}}
+\freedef\scap{{\sc#1}}
+\freedef\rom{{\rm#1}}
\restrictparameter font :
command % The command to be used to switch to that font.
name % Actually the part common to all files' names for that font.
- type % otf, etc. The font parameter can't even load tfm's...
size % Well, the size.
+ small % Smaller size.
+ verysmall % Smaller yet.
+ big % Bigger.
+ verybig % Insanely big.
+ bold % Modifier for bold font.
+ italic % Modifier for italic font.
+ math % If set to "true", then used for math font.
+ % small, verysmall and italic should be specified
+ % (which shows I don't use it very often).
features % Font features (e.g. +onum, etc.).
- roman % The part of the file's name for the roman.
- bold % The part of the file's name for the bold roman.
- italic % The part of the file's name for the italic.
- bolditalic % The part of the file's name for the bold italic.
- % What happens is: it loads <name><roman>.<type> at <size>
- % then the same with <bold>, etc.
+ slant % A number representing an angle, loading an italic
+ % font if no real italic is a available.
+ slantsc % The same, for small caps.
+
+% The font parameter should disappear some day, it's clumsy.
+\def\setfont#1:{%
+ \setparameter font : command = #1%
+ }
\setparameter metafont : % No relation :)
size = 10pt
- features = +onum;+liga;+trep;expansion=threepercent;
- type = otf % Oh yes, this is default!
+ bold = Bold
+ italic = Italic
+ features = "+onum; +liga; +trep; +tlig; expansion=30 20 5;"
-\setparameter font: meta = metafont\par
+\setparameter font :
+ meta = metafont
\newdimen\ptx@fontsize
+\luacode
+ptx_fonts = {}
+function ptx_getfont(Font, ...)
+ if ptx_fonts[Font] then
+ local tempfont = ptx_fonts[Font]
+ for _, style in ipairs(arg) do
+ if ptx_getstyle[style] then
+ tempfont = tempfont:gsub("(%w+)@(%w+)@(%w+)@(%w+)@(%w+)",ptx_getstyle[style])
+ else
+ tempfont = nil
+ texio.write_nl("! PiTeX error: Unknown font style `style'.")
+ return Font
+ end
+ end
+ return font.id(tempfont)
+ else
+ texio.write_nl("! PiTeX error: " .. Font .. " is not a PiTeX font. It can't be changed.")
+ end
+end
+ptx_getstyle = {
+ normal = "%1@normal@%3@%4@%5",
+ small = "%1@small@%3@%4@%5",
+ verysmall = "%1@verysmall@%3@%4@%5",
+ big = "%1@big@%3@%4@%5",
+ verybig = "%1@verybig@%3@%4@%5",
+ rm = "%1@%2@rm@%4@%5",
+ it = "%1@%2@it@%4@%5",
+ rg = "%1@%2@%3@rg@%5",
+ bf = "%1@%2@%3@bf@%5",
+ lc = "%1@%2@%3@%4@lc",
+ sc = "%1@%2@%3@%4@sc"
+ }
+\luacode/
+
+\newstring{+} \newstring{-}
+\def\ptx@dofont#1#2#3#4#5{%
+ \edef\ptx@temp{\passvaluenobraces\commandtoname font : command }%
+ \ifexpression{ -\ifstring{#4}{normal} & { \ifprefix-{#5} | \ifprefix+{#5} } }
+ {\def\ptx@dofont_size{\dimexpr\usevalue font : size + #5\relax}}
+ {\def\ptx@dofont_size{#5}}%
+ \ptx@dofont_load{\ptx@temp @#4@#1@#2@lc}{#3}{}{\ptx@dofont_size}%
+ \ifstring{#1}{rm}
+ {\ptx@dofont_load{\ptx@temp @#4@#1@#2@sc}{#3}{+smcp;}{\ptx@dofont_size}%
+ \ifattribute font : slant % Loading a slanted version of the font if no italic was given
+ {\ptx@dofont_load{\ptx@temp @#4@it@#2@lc}{#3}{slant=\usevalue font: slant ;}{\ptx@dofont_size}
+ \ifattribute font : slantsc {}
+ {\ptx@dofont_load{\ptx@temp @#4@it@#2@sc}{#3}{+smcp;slant=\usevalue font: slant ;}{\ptx@dofont_size}}}{}%
+ \ifattribute font : slantsc
+ {\ptx@dofont_load{\ptx@temp @#4@it@#2@sc}{#3}{+smcp;slant=\usevalue font: slantsc ;}{\ptx@dofont_size}}{}}%
+ {\ifattribute font : slantsc {}{\ptx@dofont_load{\ptx@temp @#4@it@#2@sc}{#3}{+smcp;}{\ptx@dofont_size}}}
+ }
+
+\def\ptx@dofont_load#1#2#3#4{%
+ \passcs\font{#1}="\usevalue font : name #2:#3\usevalue font : features " at #4\relax
+ \ptx@lua{ptx_fonts[font.id("#1")] = "#1"}%
+ }
+
+
+
\def\dofont#1#2#3{%
- \passcs\font{\passvalue\commandtoname font : command @#1@#2@lc} =
- "\usevalue font : name \usevalue font : #3 .\usevalue font : type :\usevalue font : features " at \usevalue font : size \relax
- \passcs\font{\passvalue\commandtoname font : command @#1@#2@sc} =
- "\usevalue font : name \usevalue font : #3 .\usevalue font : type :+smcp;\usevalue font : features " at \usevalue font : size \relax
+ \passvalue{\ptx@dofont{#1}{#2}{#3}{normal}} font : size
+ \passvalue{\ptx@dofont{#1}{#2}{#3}{small}} font : small
+ \passvalue{\ptx@dofont{#1}{#2}{#3}{verysmall}} font : verysmall
+ \passvalue{\ptx@dofont{#1}{#2}{#3}{big}} font : big
+ \passvalue{\ptx@dofont{#1}{#2}{#3}{verybig}} font : verybig
+%
+ \ifvalue font : math = true
+ {\ifstring{#1#2}{rmrg}
+ {\passcs{\textfont0=}{\passvalue\commandtoname font : command @normal@#1@#2@lc}%
+ \passcs{\scriptfont0=}{\passvalue\commandtoname font : command @small@#1@#2@lc}%
+ \passcs{\scriptscriptfont0=}{\passvalue\commandtoname font : command @verysmall@#1@#2@lc}
+ \passcs{\textfont2=}{\passvalue\commandtoname font : command @normal@#1@#2@lc}%
+ \passcs{\scriptfont2=}{\passvalue\commandtoname font : command @small@#1@#2@lc}%
+ \passcs{\scriptscriptfont2=}{\passvalue\commandtoname font : command @verysmall@#1@#2@lc}}
+ {\iffstring{#1#2}{itrg}
+ {\passcs{\textfont1=}{\passvalue\commandtoname font : command @normal@#1@#2@lc}%
+ \passcs{\scriptfont1=}{\passvalue\commandtoname font : command @verysmall@#1@#2@lc}%
+ \passcs{\scriptscriptfont1=}{\passvalue\commandtoname font : command @verysmall@#1@#2@lc}}}%
+ }{}%
}
+
+\gates new \FontLoader {FontLoader}
+\FontLoader list {fontloader}
+ [fl_command]
+ {%
+ \passvaluenobraces\edef font : command {%
+ \def\noexpand\currentfont{\passvalue\commandtoname font : command }%
+ \noexpand\makecurrentfont}}
+ (fl_load)
+ . ( fl_roman )
+ . . [ fl_doromanregular ]
+ {\dofont{rm}{rg}{}}
+ . . [ fl_doromanbold ] ? {conditional = -\ifvalue font : bold = none }
+ {\dofont{rm}{bf}{/\usevalue font : bold }}
+ . ( fl_italic ) ? {conditional = -\ifvalue font : italic = none }
+ . . [ fl_doitalicregular ]
+ {\dofont{it}{rg}{/\usevalue font : italic }}
+ . . [ fl_doitalicbold ] ? {conditional = -\ifvalue font : bold = none }
+ {\dofont{it}{bf}{/\usevalue font : italic /\usevalue font : bold }}
+ [fl_use] ? {conditional = \ifvalue font : command = {\mainfont} }
+ {\mainfont}
+ (fl_post)
+ . [fl_delete]
+ {\deleteparameter font:}
+ . [fl_meta]
+ {\setattribute font : meta = metafont }
+
\defactiveparameter font {%
- \ifattribute #1 : command
- {%
- \passvaluenobraces\edef #1 : command {%
- \def\noexpand\currentfont{\passvalue\commandtoname #1 : command }%
- \noexpand\makecurrentfont
- }%
- % If #1 = name isn't defined, roman, bold, etc. are supposed to hold the
- % font's full (file) name.
- \ifattribute #1 : roman
- {\dofont{rm}{rg}{roman}%
- \ifattribute #1 : bold
- {\dofont{rm}{bf}{bold}}%
- {}}%
- {}%
- \ifattribute #1 : italic
- {\dofont{it}{rg}{italic}%
- \ifattribute #1 : bolditalic
- {\dofont{it}{bf}{bolditalic}}%
- {}}%
- {}}%
- {}%
- \ifvalue #1 : command = {\mainfont} \mainfont{}% Calls font if it is \mainfont.
- \deleteattribute #1 : command
- \deleteattribute #1 : name
- \deleteattribute #1 : type
- \deleteattribute #1 : size
- \deleteattribute #1 : features
- \deleteattribute #1 : roman
- \deleteattribute #1 : bold
- \deleteattribute #1 : italic
- \deleteattribute #1 : bolditalic
+ \FontLoader execute {fontloader}%
}
-%
+
+
+
+
+
+
+
\long\def\color#1#2{%
\pdfcolorstack0 push {#1 rg #1 RG}%
#2%
\pdfcolorstack0 pop%
- } \ No newline at end of file
+ }
+
+\newattribute\ptx@underline_attribute
+\luacode
+local do_underline = function (head,order,ratio,sign)
+ local item, leader = head, false
+ while item do
+ leader = false
+ if node.has_attribute(item,\attributenumber\ptx@underline_attribute)
+ and not (item.id == 10 and (item.subtype == 8 or item.subtype == 9)) then
+ local item_line = node.new(2)
+ item_line.depth = tex.sp("1.4pt")
+ item_line.height = tex.sp("-1pt")
+ if node.has_field(item,"spec") then
+ item_line.width = item.spec.width
+ if order == 0 then
+ if sign == 1 then
+ item_line.width = item_line.width + ratio * item.spec.stretch
+ else
+ item_line.width = item_line.width - ratio * item.spec.shrink
+ end
+ else
+ if item.spec.stretch_order > 0 or item.spec.shrink_order > 0 then
+ lualog(item.spec.stretch_order)
+ item_line.width = 1
+ item.subtype = 100
+ item.leader = item_line
+ leader = true
+ end
+ end
+ elseif node.has_field(item,"width") then
+ item_line.width = item.width
+ elseif node.has_field(item,"kern") then
+ item_line.width = item.kern
+ end
+ if leader then
+ item = item.next
+ else
+ local item_kern = node.new(11)
+ item_kern.kern = -item_line.width
+ node.insert_after(head,item,item_line)
+ node.insert_after(head,item,item_kern)
+ item = item_line.next
+ end
+ else
+ item = item.next
+ end
+ end
+end
+pitex.misc.underline = function (head)
+ for line in node.traverse_id(0,head) do
+ do_underline(line.list,line.glue_order,line.glue_set,line.glue_sign)
+ end
+ return head
+end
+pitex.callback.register("post_linebreak_filter", "pitex.misc:underline")
+pitex.callback.close("pitex.misc:underline", "post_linebreak_filter")
+\luacode/
+
+\freedef\underline{%
+ \ptx@lua{%
+ pitex.callback.ajar("pitex:underline", "post_linebreak_filter")
+ }
+% local plf = callback.list_functions("post_linebreak_filter")
+% if not plf or not plf["underline"] then
+% callback.add_function(underline, "underline", "post_linebreak_filter")
+% end}%
+ \quitvmode % Otherwise it might also underline the indentation box.
+ \ptx@underline_attribute=0\relax
+ #1\unsetattribute\ptx@underline_attribute
+ }