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:
1 parent
37b6ba1c4f
commit
af29bbf7ac
47 files changed
+1921
-135
No files matched your search
@@ -93,24 +93,28 @@ strings_t Document_class::resolved_font_names()
|
||||
add(m_resolved_serif);
|
||||
add(m_resolved_sans);
|
||||
add(m_resolved_mono);
|
||||
// Typefaces a @typeface klammer asked for: each needs its own <link>
|
||||
// to the localized css, which is what carries the @font-face.
|
||||
for (const auto& rf : m_resolved_extra)
|
||||
add(rf);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Document_class::font_definitions()
|
||||
{
|
||||
std::stringstream ss {};
|
||||
if (!m_serif_font.empty() || !m_sans_font.empty() || !m_mono_font.empty()) {
|
||||
if (!m_serif_typeface.empty() || !m_sans_typeface.empty() || !m_mono_typeface.empty()) {
|
||||
// Family names are quoted: an unquoted name with a digit-initial
|
||||
// word ("Source Sans 3") is invalid CSS, and a font-family using
|
||||
// var() with such a value computes to inherit, silently losing
|
||||
// the font.
|
||||
ss << ":root {\n";
|
||||
if (!m_serif_font.empty())
|
||||
ss << " --serif: \"" << m_serif_font << "\", serif;\n";
|
||||
if (!m_sans_font.empty())
|
||||
ss << " --sans-serif: \"" << m_sans_font << "\", sans-serif;\n";
|
||||
if (!m_mono_font.empty())
|
||||
ss << " --monospace: \"" << m_mono_font << "\", monospace;\n";
|
||||
if (!m_serif_typeface.empty())
|
||||
ss << " --serif: \"" << m_serif_typeface << "\", serif;\n";
|
||||
if (!m_sans_typeface.empty())
|
||||
ss << " --sans-serif: \"" << m_sans_typeface << "\", sans-serif;\n";
|
||||
if (!m_mono_typeface.empty())
|
||||
ss << " --monospace: \"" << m_mono_typeface << "\", monospace;\n";
|
||||
ss << "}\n";
|
||||
}
|
||||
// Font-size normalization across families is no longer emitted from
|
||||
@@ -120,11 +124,11 @@ std::string Document_class::font_definitions()
|
||||
// factors did from build-time OS/2 metrics, but applied to EVERY family
|
||||
// switch instead of the four CSS sites that remembered to multiply.
|
||||
// The metric extraction in the font store remains (the tex path and
|
||||
// kdesc --font still use it).
|
||||
// kdesc --typeface still use it).
|
||||
// Global font scale: applied to body font-size
|
||||
if (m_font_scale != 1.0f) {
|
||||
if (m_text_scale != 1.0f) {
|
||||
char buf[16];
|
||||
std::snprintf(buf, sizeof(buf), "%.4f", m_font_scale);
|
||||
std::snprintf(buf, sizeof(buf), "%.4f", m_text_scale);
|
||||
ss << "body { font-size: " << buf << "rem; }\n";
|
||||
}
|
||||
return ss.str();
|
||||
@@ -743,6 +747,22 @@ std::string Document_class::html()
|
||||
std::string output_directory = create_html_output_directories();
|
||||
save_string_input_as_file();
|
||||
process_input_files();
|
||||
// @typeface markers are collected AFTER processing (a klammer cannot
|
||||
// declare a typeface itself) but BEFORE the page is assembled, so the
|
||||
// localized files and the <link> to each typeface's css are in place
|
||||
// when make_*_html_page() runs. The markers survive into the page
|
||||
// CACHE deliberately: a cached file must still declare its typefaces
|
||||
// on a later run, so the stripping happens here, on the assembled
|
||||
// components, not before write_to_cache().
|
||||
for (auto& [basename, text] : m_file_components) {
|
||||
collect_typefaces(text);
|
||||
}
|
||||
for (const auto& rf : m_resolved_extra) {
|
||||
install_resolved_font(rf, output_directory);
|
||||
}
|
||||
for (auto& [basename, text] : m_file_components) {
|
||||
text = strip_typeface_markers(text);
|
||||
}
|
||||
auto headings = insert_section_numbers();
|
||||
insert_section_numbers("___NUM2___", false);
|
||||
insert_html_caption_numbers();
|
||||
|
||||
Reference in new issue
Block a user