Files
klammertext/sks/font/font.k
T
ack e4f1307aa9 Characters that killed a render, what may sit next to a klammer, and ref/
A character written in the ^...^ mnemonic form -- ^oe^, ^zz^, ^hello^ --
used to kill ktext outright: no message, no output, and an exit status
that looked like a crash because it was one.  Only the forms that happen
to spell hexadecimal digits escaped, and they were right by luck rather
than by reading.  Any caret form that names no character is now a located
error that quotes what was written.

A klammer may now sit inside square brackets and braces as it already
could inside parentheses, and may be followed by the punctuation that
ends a sentence: [@i word@], {@b word@}, @i word@'s.  The rule is a fixed
list of characters, because none of them can occur inside a klammer name
and so none of them is ambiguous next to a delimiter.  A letter still
cannot: "x@" is the named closing delimiter, so a letter before "@" has
two readings and no rule can separate them.

The abbreviations an author writes -- the hyphen form @i-word, a klammer
glued to its neighbouring punctuation -- are now recognised as author
conveniences only.  They are not applied to @@ definitions or @@@ system
commands, which are written by someone who needs no such shorthand and
whose forms are already whole.

Also fixed, each of them silent: an exported shell function in the
environment broke every @eval in the document; a line break written with
@nl was destroyed when it passed through a klammer that generates a
table, printing as \textbackslash{}newline in the finished PDF; and
"kdesc --coverage" shortened its file column by comparing the spelling of
a path rather than the path, so a klammer set reached by a symbolic link
showed a full path where its neighbours showed a short one.

New in the distribution: ref/, a small klammerset that describes the
Klammermachine's own tables in Klammertext.  It currently provides the
character tables -- the diacritics and the extended Latin letters -- as
klammers that render to any target, so the documentation of what can be
written cannot drift from what the machine accepts.  It is early, and
will grow.

The Klammertext taxonomy now has a section on targets, describes the
@@@klammerset system command alongside the other three, and states the
precedence of "^" -- what a caret means before a letter, a digit, a
punctuation character, and a quote, in one ordered list.

(from dev 6594c7ff8c1f)
2026-09-07 22:37:05 +02:00

149 lines
5.2 KiB
Plaintext

# @@@state font_dirs.list :create Directories containing local fonts @@@
@@@state font_dirs :desc Directories containing local fonts @@@
@@@argtype style_code |
a style code: one letter naming a type style
:pattern r^|i^|b^|s^|t^|c
@@@
@@@argtype style_code_list |
a list of style codes. One or more of 'r' (roman), 'i' (italic),
'b' (bold), 's' (sans-serif), 't' (typewriter or monospace) or 'c'
(code) for each cell in a row. If there are fewer style codes than
cells in a row, the last code is repeated. Extra codes are
ignored.
:pattern ('style_code'^|\s)+
:python_cast (lambda s : s.split())
:default r
@@@
#[
@font was retired 2026-08-25 and replaced by @typeface. It switched the
main font PERMANENTLY (a bare \setmainfont, no group) for tex, and for
html and txt its body was "*fontname*" -- so it printed the NAME of the
font as document text instead of setting anything. @typeface is the
temporary, all-target replacement.
]#
@@typeface.k name | text :scale.float 1.0 :
A temporary change of typeface for *text*: the typeface *name* is
resolved in the Klammertext font store (the directories of
KLAMMERTEXT_FONTS, then the distribution's own), and the document
declares and localizes it automatically -- writing this klammer is the
only declaration needed. *scale* multiplies the surrounding text size,
which a script whose glyphs are drawn small usually wants.
The change ends with *text*: nothing after it is affected. Under the
txt target a typeface cannot be expressed at all, so *text* is emitted
unchanged.
@@
@@typeface.html,tex,txt :: @eval font.Typeface(K) @ @@
@@r.k text : Use the current Roman font for *text* @@
@@r.html :: <span class="plain">*text*</span> @@
@@r.tex :: \textrm{*text*} @@
@@r.txt :: *text* @@
@@b.k text : Use a bold weight of the current font for *text* @@
@@b.html :: <b>*text*</b> @@
@@b.tex :: \textbf{*text*} @@
@@b.txt :: *text* @@
@@i.k text : Use an italic style of the current font for *text* @@
@@i.html :: <i>*text*</i> @@
@@i.tex :: \emph{*text*} @@ # \begin{emph}{*text*}\end{emph} @@
@@i.txt :: *text* @@
@@t.k text : Use the currently defined monospace font for *text* @@
@@t.html :: <span class="tt">*text*</span> @@
@@t.tex :: \texttt{*text*} @@
@@t.txt :: *text* @@
@@s.k text : Use the currently defined sans-serif font for *text* @@
@@s.html :: <span class="text">*text*</span> @@
@@s.tex :: \textsf{*text*} @@
@@s.txt :: *text* @@
@@u.k text : Underline *text* in the current font @@
@@u.tex :: \underline{\botstrut{2pt}*text*} @@
@@ri.k text : Use a roman italic font for *text* (to override monospace environment) @@
@@ri.html :: <span class="ritalic">*text*</span> @@
@@ri.tex :: \textrm{\textit{*text*}} @@
@@ri.txt :: *text* @@
@@ts.k scale.float | text : Resize *text* by *scale* @@
# @@ts.tex :: {\scalefont{*scale*}\em *text*} @@
@@ts.tex :: \scalefont{*scale*}{*text*} @@
@@ts.html :: <span style="font-size: @eval *scale* * 100 @ #- %">*text*</span> @@
@@ts.txt :: *text* @@
@@leading.k n.float : Change LaTeX leading to *n*, multiple of the current line height @@
#@@leading.tex :: \renewcommand{\baselinestretch}{*n*} @@
@@leading.tex :: \setstretch{*n*} @@
@@default_font.k : Default font for documents @@
@@default_font.tex ::
# \setmainfont[Ligatures=TeX,Numbers=Lining]{Garamond Libre}
\setmainfont{Garamond Libre}
@@
#[
Before 2026-08-25 every one of these bodies substituted "*cjk*" while the
declaration named the parameter "text", so @cjk raised "Variable "cjk" not
defined" under EVERY target -- it had never worked. Rewritten on
@typeface, which is what it was reaching for.
The typeface it names is NOT part of the distribution (a usable Noto Sans
CJK is some 16-20 MB per weight, and Chinese line breaking needs more
than a typeface -- xeCJK for the tex path), so this klammer errors with
the list of available typefaces until one is installed with
"kdesc --typeface install". That is the honest behaviour: the klammer
states what it needs and the store reports what it has.
]#
@@cjk.k text : Set *text* in a typeface that supports CJK @@
@@cjk.html,tex,txt :: @typeface Noto Sans CJK SC | *text* @ @@
@@fraktur.k s : Set text *s* in Fraktur @@
@@fraktur.tex :: \textfrak{*s*} @@
@@euro.k f : The Euro symbol, followed by the amount *f* @@
@@euro.html :: &^#x20AC;*f* @@
@@euro.tex,txt :: €\,*f* @@
# TODO: This needs to use MathJax.
# @@math s :center.bool false : @i *s* @ @@
@@sub.k base | script : Subscript: @sub x 2 @ @@
@@sub.html,tex :: @eval font.Subsuper(K, "sub") eval@ @@
@@sup.k base | script : Superscript: @sup x 2 @ @@
@@sup.html,tex :: @eval font.Subsuper(K, "sup") eval@ @@
@@copyright.k : Copyright symbol: © @@
@@copyright.html :: &copy; @@
@@copyright.tex :: {\copyright} @@
@@registered.k : Registered symbol: ® @@
@@registered.html :: <sup>&reg;</sup> @@
@@registered.tex :: \textsuperscript{\textregistered} @@
@@trademark.k : Trademark symbol: ™ @@
@@trademark.html :: <sup>&trade;</sup> @@
@@trademark.tex :: \texttrademark{} @@
@@pi.k : Greek letter pi @@
@@pi.html :: &pi; @@
@@pi.tex :: $\pi$ @@
@@rightarrow.k : Right-pointing arrow: @rightarrow@ @@
@@rightarrow.html :: &^#8594; @@
@@rightarrow.tex :: $\rightarrow$ @@
@@dot.k : Vertically entered dot @@
@@dot.tex :: $\cdot$ @@
@@dot.html :: ^00B7^ @@
@@dot.txt :: ^00B7^ @@