باختصار
صفحة نماذج كالتي تصدرها مسابك الحروف، فيها المادة نفسها باثنتي عشرة لغة تُكتب بالسيريلية، من الروسية إلى المنغولية. يقسم كل نص كلماته بقواعد لغته، وتُظهر البلغارية والصربية والمقدونية الحروف التي ترسمها بشكل مختلف.
ما الذي ستنضده
نموذج قياسه 205 × 260 مم في أربع صفحات. الغلاف جدار من اثنتي عشرة بلاطة، في كل منها حرف يميّز إحدى الأبجديات. وفي صفحتين متقابلتين اثنتا عشرة بطاقة: ست لغات سلافية على اليسار، والكازاخية والقرغيزية والتتارية والبشكيرية والطاجيكية والمنغولية على اليمين. في كل بطاقة اسم اللغة، وحروفها الخاصة بالأحمر الزنجفري، والمادة الأولى من الإعلان العالمي لحقوق الإنسان في أعمدة مضبوطة الجانبين، وبيت لأحد كتّاب اللغة، ثم الأبجدية. وتعرض الصفحة الأخيرة الأشكال المحلية بحجم كبير، وكلمة «مكتبة» مقسّمة في اللغات الاثنتي عشرة.
تجيب هذه الوصفة عن
- كيف أنضد عدة لغات سيريلية في مستند واحد، لكل منها تقطيعها وأشكال حروفها؟
- كيف أحصل على ضبط أسطر وتقسيم كلمات جيدين لنص إسباني أو فرنسي أو ألماني؟
الجواب المختصر
// The document is Russian, so that is what divides and shapes anything left unnamed. A
// passage names its language on its container:
// :::paragraphs{style="article" lang=bg}
// Its words are divided by Bulgarian patterns and kept together by Bulgarian rules; it is
// measured, painted and embedded with the Bulgarian forms (locl) the font holds, and tagged
// as Bulgarian in the HTML and the PDF. A run inside a line takes :ltr[…]{lang=bg}.
const LOCALE = 'ru';
const bodyText = { // config().bodyText
fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
textAlign: 'justify', firstLineIndent: pt(0),
// 54 mm hold about 32 letters: words are divided at two letters, the spaces give from
// 0.75 to 1.8 of the face's own, and a line takes up to 20 ‰ of tracking.
hyphenation: { leftMin: 2, rightMin: 2 }, minWordSpacing: 0.75, maxWordSpacing: 1.8,
maxJustifyTracking: 20, shapingLanguage: 'document', // the default: locale, then lang
};
const passages = [ // config().paragraphStyles
{ id: 'article', firstLineIndent: pt(0), marginBottom: pt(LEAD / 2) },
{ id: 'line', fontSize: pt(11.2), lineHeight: pt(LEAD), textAlign: 'left',
italicColor: col('red'), hyphenation: { enabled: false }, marginBottom: pt(LEAD / 2) },
{ id: 'abc', ...face(SANS, 8.4, 400, 'muted'), lineHeight: pt(11.4), textAlign: 'left',
hyphenation: { enabled: false } },
];
المكونات
- الميزات
- اللغات الكيريلية لغةً للمستندتقسيم الكلمات ولغة المستندمقاطع بالاتجاه المعاكسكلمات لا تُفصل عند نهاية السطرخط المتنأنماط الفقراتأنماط الحروفمواضع الجدولة ونقاط التوجيهصفحات افتتاح مصمَّمةأنماط العناوينسمات العنوانالنصوص والخطوط والمربعات في تصاميم الصفحةأشرطة النزف وألسنة الإبهامالأغلفة وصفحات العنوان وبيانات النشرهوامش متناظرةلون الورقلوحة ألوان دلاليةالتصدير إلى PDFالخطوط المضمَّنة في PDF
- الخطوط
- Source Serif 4, Source Sans 3 (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · سمِّ لغة كل نص مرتين
الشيفرة هي الجواب المختصر أعلاه. يُسمّي lang في كتلة :::paragraphs لغة نصها: فيختار الأنماط التي تقسم كلماتها، ويُقاس النص ويُرسم ويُضمَّن بالأشكال التي يحفظها الخط لتلك اللغة، ويُوسم بها في PDF وHTML. أما المقطع داخل السطر فيأخذ عزلًا :ltr[…]{lang=bg}. عرض الأعمدة 54 مم، لذلك يجوز التقسيم بعد حرفين ويقبل السطر حتى 20 ‰ من التباعد.
#2 · عنوان واحد وأربعة بيانات
// ## Українська {code="uk" letters="33 буквы" special="Ґ Є І Ї"}
const entry = { level: 2, fontFamily: SERIF, fontSize: pt(21), lineHeight: pt(26), fontWeight: 900,
marginTop: pt(0), marginBottom: pt(LEAD / 4),
advancedDesign: { enabled: true, minHeight: mm(25.4), slot: { elements: [
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(2.5), color: col('ink'),
placement: { ...at('container', 'top-left'), size: { width: 'fill' } } },
text('code', '{attr.code}', face(SANS, 8, 700, 'red', { textTransform: 'uppercase',
letterSpacing: pt(1.2) }), at('container', 'top-left', 0, 2.6)),
text('count', '{attr.letters}', face(SANS, 8, 400, 'muted', { align: 'right' }),
at('container', 'top-right', 0, 2.6)),
text('name', '{titleText}', face(SERIF, 22, 900, 'ink', { lineHeight: 1.1 }),
at('container', 'top-left', 0, 6.6)),
text('special', '{attr.special}', face(SERIF, 17, 700, 'red', { lineHeight: 1.2 }),
at('container', 'top-left', 0, 18)),
] } } };
ينتقل رمز اللغة وعدد حروفها والحروف التي لا توجد في الروسية في العنوان: ## Українська {code="uk" letters="33 буквы" special="Ґ Є І Ї"}. يطبعها التصميم تحت خط سميك، ويمنح minHeight جميع البطاقات رأسًا متساويًا، فتبدأ نصوص الصف الواحد على سطر واحد.
#3 · جدار من الحروف
const [TILE_W, TILE_H] = [TRIM_W / 3, 52]; // mm
const INKS = ['red', 'ink', 'ochre', 'pine', 'cream', 'red', 'ink', 'ochre', 'pine', 'red', 'ink',
'cream']; // ink of each tile, row by row
const tile = (ink, i) => {
const place = { ...at('page', 'top-left', (i % 3) * TILE_W, Math.floor(i / 3) * TILE_H),
size: { width: mm(TILE_W), height: mm(TILE_H) } };
const letter = ink === 'cream' ? 'red' : ink === 'ochre' ? 'ink' : 'cream';
return [{ kind: 'box', id: `tile-${i}`, style: { backgroundColor: col(ink) }, placement: place },
text(`letter-${i}`, `{attr.l${i + 1}}`, face(SERIF, 108, 900, letter, { align: 'center',
verticalAlign: 'center', lineHeight: 1 }), place)];
};
const cover = { id: 'cover', breakBefore: { enabled: true, parity: 'any' },
header: { elements: [] }, footer: { elements: [] },
advancedDesign: { enabled: true, minHeight: mm(200), slot: { elements: [
...INKS.flatMap(tile),
text('title', '{titleText}', face(SERIF, 40, 900, 'ink', { lineHeight: 1.05, align: 'left' }),
{ ...at('page', 'top-left', SIDE, 4 * TILE_H + 10), size: { width: mm(TRIM_W - 2 * SIDE) } }),
text('subtitle', '{subtitle}', face(SANS, 13, 400, 'muted', { lineHeight: 1.3, align: 'left' }),
{ ...at('#title', 'below', 0, 2), size: { width: 'fill' } }),
] } } };
حروف الغلاف الاثنا عشر هي الخصائص l1 إلى l12 في عنوانه، ويبني التصميم لكل حرف صندوقًا ونصًا من قائمة أحبار. ولتغيير حرف يكفي تغيير Markdown. توضع البلاطات من زاوية الصفحة وتصل إلى حد القص.
#4 · الأشكال المحلية سطرًا بعد سطر
const tabs = (...at) => at.map((x) => ({ position: mm(x), align: 'start' }));
const formsStyles = [ // config().paragraphStyles
{ id: 'forms', fontSize: pt(29), lineHeight: pt(3 * LEAD), textAlign: 'left',
tabStops: tabs(26, 78), hyphenation: { enabled: false } },
{ id: 'weights', fontSize: pt(15.5), lineHeight: pt(2 * LEAD), textAlign: 'left',
hyphenation: { enabled: false } },
{ id: 'cuts', fontSize: pt(12), lineHeight: pt(1.5 * LEAD), textAlign: 'left', tabStops: tabs(22),
hyphenation: { enabled: false } },
{ id: 'colophon', ...face(SANS, 7.8, 400, 'muted'), lineHeight: pt(11), textAlign: 'left',
marginTop: pt(3 * LEAD), hyphenation: { locale: LANG, enabled: false } },
];
تمر السلسلة نفسها في الخط بالروسية ثم بالبلغارية؛ وبالمائل بالروسية والصربية والمقدونية. في Source Serif 4 المجموعات الثلاث. تصف علامات الجدولة السطور، وكل سطر عزل بلغته. وتجد في التوكيد والأشكال المحلية الحروف التي تتغير.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 209 · Twelve Cyrillic languages in one type specimen ═══════
// https://postext.dev/en/cookbook/cyrillic-specimen-twelve-languages
// Code: MIT · Text: UDHR, article 1 (UN, PD) and lines by twelve authors (PD) · Pictures: none
// Fonts: Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.100.0
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the colophon ('en' | 'es' | 'ru')
const RECIPE = 'cyrillic-specimen-twelve-languages';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// The sheet of a type foundry between the wars: black, vermilion and two dull inks on cream.
const palette = {
ink: '#1d1b1a', // text, heavy rules, the dark tiles
red: '#b8321e', // the letters Russian lacks, the plates' titles, red tiles
pine: '#1f4b4a', // green tiles
ochre: '#d59b3a', // ochre tiles
cream: '#f6efdf', // the paper and the letters on the tiles
muted: '#655d51', // alphabets, author names, the colophon
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.red })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [SERIF, SANS] = ['Source Serif 4', 'Source Sans 3']; // both draw local forms by language
const [BODY, LEAD] = [10.5, 14]; // pt
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, overflow: 'wrap',
...look, placement });
const face = (fontFamily, size, fontWeight, color, extra = {}) => ({ fontFamily,
fontSize: pt(size), fontWeight, color: col(color), ...extra });
// #region page: 84 × 108/16, 205 × 260 mm trimmed, three columns to a plate
const [TRIM_W, SIDE] = [205, 15]; // mm
const page = { sizePreset: '84x108/16', dpi: 150, backgroundColor: col('cream'),
margins: { top: mm(18), bottom: mm(17), left: mm(SIDE), right: mm(SIDE), mirror: true } };
const COLUMN_GAP = 6; // mm
// #endregion
// #region answer: each passage named in its own language, for its breaks and its letters
// The document is Russian, so that is what divides and shapes anything left unnamed. A
// passage names its language on its container:
// :::paragraphs{style="article" lang=bg}
// Its words are divided by Bulgarian patterns and kept together by Bulgarian rules; it is
// measured, painted and embedded with the Bulgarian forms (locl) the font holds, and tagged
// as Bulgarian in the HTML and the PDF. A run inside a line takes :ltr[…]{lang=bg}.
const LOCALE = 'ru';
const bodyText = { // config().bodyText
fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
أخطاء شائعة
- يجب أن يحوي الخط هذه الأشكال. ليس في PT Serif شيء منها لهذه اللغات، وفي Vollkorn وLora البلغارية والصربية. وإن غابت ظل العزل يقطّع النص ويسمه، لكن الحروف تبقى روسية الشكل.
- ويجب أن يحوي الحروف أيضًا. الحروف Ә وҒ وҢ وҘ وҶ وӮ في ملف
cyrillic-extمن العائلة، ويحمّلهkitCyrillicFonts؛ وينقص بعضها في Literata وSpectral.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- Article 1 of the Universal Declaration of Human Rights in eleven languages, from the plain texts of the UDHR in XML project, with four misprints of the Kazakh, Kyrgyz and Tatar files corrected · United Nations · ملك عام
- Article 1 in Bashkir · United Nations · ملك عام
- Opening lines and sayings of Pushkin, Shevchenko, Kupala, Vazov, Vuk Karadžić, Racin, Abai, Toktogul, Tukay, Akmulla, Rudaki and Natsagdorj · The authors named · ملك عام
- The titles, the alphabets and the colophon · Postext Cookbook · أصلي
- الخطوط
- Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


