Unicode sequences, @typeface, and the font/typeface distinction

A run of Unicode code points now needs one pair of carets, not one pair
each: ^9053 53EF 9053^ renders the characters adjacently, and a single
character inside such a run stands for itself.  An invalid code point is
an error naming the position that wrote it, rather than an apology
rendered into the finished document; noncharacters are refused alongside
surrogates; and a code point that lands on a Klammertext special is safe
through the re-reads that assemble a document.  The character tables now
produce the precomposed form, so a diacritic written as ^a" and one typed
directly are the same text to a search or a copy-paste.

"kdesc -u" describes how to write a Unicode character, with tables of
glyphs beside the codes that produce them.  It is new and not yet
complete: it predates the sequence form and the typeface klammer below.

A typeface and a style are no longer both called "font".  A typeface is a
family resolved by name; a style code is the one letter naming a type
style.  So @document takes :serif_typeface and its siblings, a table takes
:style, captions take :caption_style and :caption_size, the uniform scale
is :text_scale, and the command is "kdesc --typeface".  This renames
arguments a document may already use; an old name is a located error
rather than a silent omission.

@typeface sets a passage in another typeface for the length of that
passage:

    @typeface Noto Sans Egyptian Hieroglyphs | ^132AA 133CF^ :scale 1.5 @

Writing the klammer is the whole declaration -- the document resolves the
typeface, embeds it in what it produces, and carries its license along.
Two typefaces for scripts no text font covers now ship with Klammertext:
Noto Sans Egyptian Hieroglyphs and Noto Sans Cuneiform.  Every typeface in
the distribution now carries its license file.

(from dev 61e598698891)
This commit is contained in:
ack committed 2026-08-25 23:30:55 +02:00
1 parent 37b6ba1c4f
commit af29bbf7ac
47 files changed
+1921 -135

No files matched your search

+25 -4
View File
@@ -121,14 +121,35 @@ public:
strings_t m_font_dirs {};
std::string m_serif_font {};
std::string m_sans_font {};
std::string m_mono_font {};
float m_font_scale = 1.0f;
std::string m_serif_typeface {};
std::string m_sans_typeface {};
std::string m_mono_typeface {};
float m_text_scale = 1.0f;
Resolved_font m_resolved_serif {};
Resolved_font m_resolved_sans {};
Resolved_font m_resolved_mono {};
// Typefaces requested by @typeface klammers inside the document, in
// first-appearance order, each with the scale it was asked for. A
// klammer cannot declare a typeface itself (see font.py's
// typeface_marker), so it leaves a marker and @document collects them
// here, resolves and localizes each, declares it, and replaces every
// marker with the target's inline switch.
// SYNC: typeface_marker() in sks/font/font.py builds this marker.
std::vector<std::pair<std::string, std::string>> m_extra_typefaces {};
std::vector<Resolved_font> m_resolved_extra {};
// Collect the (typeface, scale) pairs of `text` into
// m_extra_typefaces, resolving each typeface once. Returns nothing;
// the markers are replaced by the per-target functions below.
void collect_typefaces(const std::string& text);
// html: the marker carries no inline switch (the span holds the family
// name), so each is replaced by nothing.
std::string strip_typeface_markers(const std::string& text);
// tex: each distinct (typeface, scale) gets a \newfontfamily command in
// the preamble; the marker is replaced by that command.
std::string resolve_typeface_markers(const std::string& text);
std::string typeface_preamble();
std::string prolog {};
std::string paper_size {};
bool m_two_column = false;