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

+18 -18
View File
@@ -163,10 +163,10 @@ namespace latex {
const std::string& cover,
bool landscape,
const std::string& body,
Resolved_font serif_font,
Resolved_font sans_font,
Resolved_font mono_font,
float font_scale)
Resolved_font serif_typeface,
Resolved_font sans_typeface,
Resolved_font mono_typeface,
float text_scale)
{
(void)K::log(3);
bool book_format = (structure == "book");
@@ -202,10 +202,10 @@ namespace latex {
// x-height: serif_xh / other_xh (matches lowercase)
// cap-height: serif_ch / other_ch (matches capitals)
// average: mean(serif_xh,serif_ch) / mean(other_xh,other_ch)
float serif_xh = serif_font.xheight_ratio;
float serif_ch = serif_font.capheight_ratio;
float serif_xh = serif_typeface.xheight_ratio;
float serif_ch = serif_typeface.capheight_ratio;
float serif_avg = (serif_xh + serif_ch) / 2.0f;
auto font_scale_fn = [&](const Resolved_font& other) -> float {
auto text_scale_fn = [&](const Resolved_font& other) -> float {
float other_avg = (other.xheight_ratio + other.capheight_ratio) / 2.0f;
if (serif_avg > 0.0f && other_avg > 0.0f)
// return serif_xh / other.xheight_ratio; // x-height
@@ -213,21 +213,21 @@ namespace latex {
return serif_avg / other_avg; // average
return 0.0f;
};
// Global font_scale multiplies all font sizes uniformly
float gs = (font_scale != 1.0f) ? font_scale : 0.0f;
float sans_s = font_scale_fn(sans_font);
float mono_s = font_scale_fn(mono_font);
// Global text_scale multiplies all font sizes uniformly
float gs = (text_scale != 1.0f) ? text_scale : 0.0f;
float sans_s = text_scale_fn(sans_typeface);
float mono_s = text_scale_fn(mono_typeface);
// Apply global scale: multiply into per-font scale, or use alone
if (gs > 0.0f) {
sans_s = (sans_s > 0.0f) ? sans_s * font_scale : font_scale;
mono_s = (mono_s > 0.0f) ? mono_s * font_scale : font_scale;
sans_s = (sans_s > 0.0f) ? sans_s * text_scale : text_scale;
mono_s = (mono_s > 0.0f) ? mono_s * text_scale : text_scale;
}
ss << font_command("setmainfont", serif_font, gs);
ss << font_command("setsansfont", sans_font, sans_s);
ss << font_command("setmonofont", mono_font, mono_s);
ss << font_command("setmainfont", serif_typeface, gs);
ss << font_command("setsansfont", sans_typeface, sans_s);
ss << font_command("setmonofont", mono_typeface, mono_s);
// Scale leading proportionally with font_scale
float effective_leading = leading * ((font_scale != 1.0f) ? font_scale : 1.0f);
// Scale leading proportionally with text_scale
float effective_leading = leading * ((text_scale != 1.0f) ? text_scale : 1.0f);
ss << "\n\\setstretch{" << effective_leading << "}\n";
if (ragged_right)
ss << "\\raggedright\n";