txt section numbering, @typeface :middle/:lift and html scale, NewGardinerOmni, html :leading (from dev 9fa469dd74ed)

Section headings under txt are numbered inside a @document only; @typeface
gains :middle and :lift and its :scale now means the same in html and
pdf; NewGardinerOmni ships (OFL 1.1, Mark-Jan Nederhof) and @egyptian /
@chinese replace @cjk; @table :leading and :colsep reach html; kdesc
--typeface help names the flag; @document.txt is a Python class.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
ackandClaude Fable 5.1 committed 2026-09-18 20:02:44 +02:00
1 parent 0ead40f272
commit 63956c00e5
26 files changed
+437 -173

No files matched your search

+52 -25
View File
@@ -4,6 +4,7 @@
#include "character.h"
#include "error.h"
#include "show.h"
#include "font_store.h"
// extern "C" is needed for dlsym name lookup. Returning std::string from
// C-linkage functions is technically non-standard but works correctly on
@@ -21,8 +22,11 @@ std::string diacritics_examples([[maybe_unused]] Machine& machine)
//std::cout << machine;
std::stringstream kt {};
kt << "@table :caption Diacritics (with typical base characters) :cell_hpos c c l |\n"
<< "@i-Displayed | @i-Written | @i-Name ||\n";
kt << "@s2 Roman letters with a diacritical mark @\n\n";
kt << "@table :caption Diacritics (with typical base characters) :cell_hpos c c l :leading 1.2 |\n"
<< "Displayed | Written | Name ||\n";
for (char symbol : diacritic_symbols_order) {
std::string sym { symbol };
@@ -43,8 +47,10 @@ extern "C"
std::string extended_latin_examples([[maybe_unused]] Machine& machine)
{
std::stringstream kt {};
kt << "@table :caption Extended Latin characters and ligatures :cell_hpos c c l |\n"
<< "@i-Displayed | @i-Written | @i-Name ||\n";
kt << "@s2 Non-Roman characters @\n\n";
kt << "@table :caption Extended Latin characters and ligatures :cell_hpos c c l :leading 1.2 |\n"
<< "Displayed | Written | Name ||\n";
for (const std::string& symbol : extended_latin_symbols) {
auto [code, name] = extended_latin[symbol];
std::string coded = "^" + symbol + "^";
@@ -59,8 +65,10 @@ extern "C"
std::string pinyin_examples([[maybe_unused]] Machine& machine)
{
std::stringstream kt {};
kt << "@table :caption Mandarin pinyin tones (using vowel ``a'') :cell_hpos c c l |\n"
<< " @i-Displayed | @i-Written | @i-Name ||\n";
kt << "@s2 Chinese Pinyin syllable accents @\n\n";
kt << "@table :caption Mandarin pinyin tones (using vowel ``a'') :cell_hpos c c l :leading 1.2 |\n"
<< "Displayed | Written | Name ||\n";
for (auto [symbol, codename] : pinyin_tones) {
auto [code, name] = codename;
@@ -79,33 +87,24 @@ std::string unicode_examples([[maybe_unused]] Machine& machine)
<< "To specify a wide variety of different letter forms, the Unicode Standard "
<< "defines a large set of \"code points\" organized by groups. To include a "
<< "Unicode character in Klammertext, you surround its hexadecimal number with "
<< "the \"^^\" character. For example, the Cyrillic captial letter \"I\" is \"И\", "
<< "included in Klammertext as ^^0418^^.\n\n"
<< "To search for Unicode characters by their description, see: @nl@\n"
<< "the \"^^\" character. For example, the Cyrillic capital letter \"I\" is \"И\", "
<< "included in Klammertext as @t ^^0418^^ @.\n\n"
<< "To search for Unicode characters by their description, see: "
<< "@link https://www.fileformat.info/info/unicode/char/search.htm @\n\n";
kt << "@table :caption Examples of Chinese characters :cell_hpos c c l |\n"
<< " Character | Written | Pinyin ||\n";
kt << "@s3 Egyptian hieroglyphs @\n\n";
for (auto chr : dao) {
std::string code = "^" + chr[1] + "^";
kt << process_unicode_codepoint(code) << " | "
<< "^" << code << "^" << " | "
<< chr[0] << " ||\n";
}
kt << "table@\n\n";
kt << "@table :caption Examples of Egyptian hieroglyphs :cell_hpos c c c l |\n"
kt << "@table :caption Examples of Egyptian hieroglyphs :cell_hpos c c c l :leading 1.1 |\n"
<< "Hieroglyph | Written | Sound | Gardiner ||\n";
// The body font carries no hieroglyphs, so the glyph names the
// typeface it needs (shipped in fnt/); @document declares and localizes
// it. Under txt @typeface passes the text through unchanged.
for (auto glyph : ptolemy) {
kt << "@typeface noto-sans-egyptian-hieroglyphs :scale 1.5 | "
<< process_unicode_codepoint("^" + glyph[2] + "^") << " @ | "
<< "^^" + glyph[2] + "^^ | "
std::string code = "^" + glyph[2] + "^";
kt << "@egyptian "
<< process_unicode_codepoint(code) << " @ | "
<< "@t ^'" << code << "'^ @ | "
<< glyph[1] << " | "
<< glyph[0] << " ||\n";
}
@@ -114,6 +113,34 @@ std::string unicode_examples([[maybe_unused]] Machine& machine)
<< "the Unicode codepoint in the second column of the \"List of hieroglyphs\" "
<< "table is the number in the ^^...^^ code used by Klammertext.\n\n";
kt << "@s3 Chinese characters @\n\n";
bool chinese = font_installed("Noto Serif SC");
std::string target = machine.m_state.get("K_target").m_value;
const bool txt_or_ansi = target == "txt"|| target == "ansi";
if (txt_or_ansi || chinese) {
kt << "@table :caption Examples of Chinese characters :cell_hpos c c l :leading 1.2 |\n"
<< " Character | Written | Pinyin ||\n";
for (auto chr : dao) {
std::string code = "^" + chr[1] + "^";
kt << "@chinese " << process_unicode_codepoint(code) << " @ | "
<< "@t ^'" << code << "'^ @" << " | "
<< chr[0] << " ||\n";
}
kt << "table@\n\n";
}
if (!txt_or_ansi && !chinese) {
kt << "To display Chinese characters, you need to install a Chinese typeface, "
"which Klammertext does not ship. "
"Download @i Noto Serif SC @ from Google Fonts, unzip it, and run: \n\n"
" @t kdesc ^-^-typeface install @ ~ @i the-installed-font-directory @ \n\n"
"The font goes into your "
"@t ^~/.klammertext/fonts @ directory or the first directory in the list of "
"directories defined by the @t KLAMMERTEXT_FONTS @ environment variable.\n\n";
}
return kt.str();
}
@@ -136,7 +163,7 @@ std::string argtype_definitions(Machine& machine)
auto filename = argtype.m_loc.m_filename;
if (contains(filename, "argtype_registry")) {
std::string fill(name_width - name.size(), '~');
kt << "\n@c " << name << " c@ @t " << fill << " t@ @i Pattern: i@ @c "
kt << "\n@c " << name << " c@ @t " << fill << " t@ @i Pattern: i@ ~ @c "
<< argtype.m_symbolic_pattern << " c@ |\n"
<< capitalize(trim(argtype.m_desc)) << " ||\n";
} else {