mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-08 00:10:11 +00:00
Type: translate the numbered stylistic set label
StylisticSet.name now holds only a name the font supplies. The OpenType panel shows a set without one as `Set {n}` through tl!, so the label is translated, and each UI catalog has a `Set {n}` row.
This commit is contained in:
@@ -8,11 +8,11 @@ use super::FontFace;
|
||||
use super::names::name;
|
||||
|
||||
/// One `ss01`–`ss20` feature in a face. `number` is the tag's number; `name` is the font's UI
|
||||
/// label when it supplies one, otherwise `Set 1` through `Set 20`.
|
||||
/// label when it supplies one, and `None` otherwise.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct StylisticSet {
|
||||
pub number: u8,
|
||||
pub name: String,
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
/// The `ssNN` number in a feature tag, if it is one of the twenty registered sets.
|
||||
@@ -25,8 +25,9 @@ fn number(tag: [u8; 4]) -> Option<usize> {
|
||||
}
|
||||
|
||||
/// Collect registered set records from either layout table. Fonts may carry a set in GSUB, GPOS,
|
||||
/// or both. A readable custom name takes precedence over the numbered fallback.
|
||||
fn collect(font: &skrifa::FontRef<'_>, features: FeatureList<'_>, labels: &mut [Option<String>; 20]) {
|
||||
/// or both. `labels[n - 1]` is `Some` once set `n` is found, holding its readable custom name if
|
||||
/// any record supplies one.
|
||||
fn collect(font: &skrifa::FontRef<'_>, features: FeatureList<'_>, labels: &mut [Option<Option<String>>; 20]) {
|
||||
for record in features.feature_records().iter().take(4096) {
|
||||
let Some(n) = number(record.feature_tag().to_be_bytes()) else { continue };
|
||||
let Ok(feature) = record.feature(features.offset_data()) else { continue };
|
||||
@@ -38,10 +39,10 @@ fn collect(font: &skrifa::FontRef<'_>, features: FeatureList<'_>, labels: &mut [
|
||||
_ => None,
|
||||
});
|
||||
let slot = &mut labels[n - 1];
|
||||
if let Some(custom) = custom {
|
||||
if custom.is_some() {
|
||||
*slot = Some(custom);
|
||||
} else if slot.is_none() {
|
||||
*slot = Some(format!("Set {n}"));
|
||||
*slot = Some(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +52,7 @@ impl FontFace {
|
||||
/// skipped, and no more than 4096 feature records from either table are read.
|
||||
pub fn stylistic_sets(&self) -> Vec<StylisticSet> {
|
||||
let Some(font) = self.skrifa() else { return Vec::new() };
|
||||
let mut labels: [Option<String>; 20] = std::array::from_fn(|_| None);
|
||||
let mut labels: [Option<Option<String>>; 20] = std::array::from_fn(|_| None);
|
||||
if let Ok(gsub) = font.gsub()
|
||||
&& let Ok(features) = gsub.feature_list()
|
||||
{
|
||||
@@ -120,9 +121,6 @@ mod tests {
|
||||
let db = super::super::FontDb::with_font_dirs(vec![]);
|
||||
assert_eq!(db.add_font(builder.build()), 1);
|
||||
let face = db.face("Stylistic Test Sans", "Regular").unwrap();
|
||||
assert_eq!(
|
||||
face.stylistic_sets(),
|
||||
[StylisticSet { number: 1, name: "Curved Capitals".into() }, StylisticSet { number: 3, name: "Set 3".into() }]
|
||||
);
|
||||
assert_eq!(face.stylistic_sets(), [StylisticSet { number: 1, name: Some("Curved Capitals".into()) }, StylisticSet { number: 3, name: None }]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3238,6 +3238,7 @@ digits Malayalam Малаялам
|
||||
Swap start and end arrowheads Размяна на началната и крайната стрелка
|
||||
Swap the selected object for the file, keeping its place and transform Замяна на избрания обект с файла, като се запазват мястото и трансформациите му
|
||||
Stylistic Alternates Стилистични алтернативи
|
||||
Set {n} Набор {n}
|
||||
Swash Декоративен елемент
|
||||
Swatch Conflict Конфликт на образци
|
||||
Swatch Conflicts Конфликти на образци
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1816,6 +1816,7 @@ digits Malayalam Malajalam
|
||||
Select text to set its OpenType features. Odaberite tekst da postavite njegove OpenType mogućnosti.
|
||||
Standard Ligatures Standardne ligature
|
||||
Stylistic Alternates Stilske alternative
|
||||
Set {n} Skup {n}
|
||||
Swash Ukrasni potez
|
||||
Tabular Lining Tabelarne brojke
|
||||
Tabular Oldstyle Tabelarne stare brojke
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6021,6 +6021,7 @@ anchor Points: Punts:
|
||||
Character Color Color del caràcter
|
||||
OpenType Features Funcions OpenType
|
||||
Stylistic Sets Jocs estilístics
|
||||
Set {n} Joc {n}
|
||||
@msg features lists at most {max} tags features admet com a màxim {max} etiquetes
|
||||
@msg unknown OpenType feature `{t}` funció OpenType desconeguda `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} ha de ser un nombre superior a 0 i com a màxim {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6037,6 +6037,7 @@ anchor Points: Body:
|
||||
Character Color Barva znaků
|
||||
OpenType Features Funkce OpenType
|
||||
Stylistic Sets Stylistické sady
|
||||
Set {n} Sada {n}
|
||||
@msg features lists at most {max} tags features obsahuje nejvýše {max} značek
|
||||
@msg unknown OpenType feature `{t}` neznámá funkce OpenType `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} musí být číslo větší než 0 a nejvýše {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1656,6 +1656,7 @@ digits Malayalam Malayalam
|
||||
Select text to set its OpenType features. Markér tekst for at angive dens OpenType-funktioner.
|
||||
Standard Ligatures Standardligaturer
|
||||
Stylistic Alternates Stilistiske alternativer
|
||||
Set {n} Sæt {n}
|
||||
Swash Sving
|
||||
Tabular Lining Tabulære versalcifre
|
||||
Tabular Oldstyle Tabulære mediævalcifre
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5622,6 +5622,7 @@ anchor Points: Punkte:
|
||||
Character Color Zeichenfarbe
|
||||
OpenType Features OpenType-Funktionen
|
||||
Stylistic Sets Stilsätze
|
||||
Set {n} Satz {n}
|
||||
@msg features lists at most {max} tags features enthält höchstens {max} Tags
|
||||
@msg unknown OpenType feature `{t}` unbekannte OpenType-Funktion `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} muss eine Zahl über 0 und höchstens {max} sein
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5988,6 +5988,7 @@ anchor Points: Σημεία:
|
||||
Character Color Χρώμα χαρακτήρων
|
||||
OpenType Features Χαρακτηριστικά OpenType
|
||||
Stylistic Sets Στιλιστικά σύνολα
|
||||
Set {n} Σύνολο {n}
|
||||
@msg features lists at most {max} tags Το features περιέχει έως {max} ετικέτες
|
||||
@msg unknown OpenType feature `{t}` άγνωστο χαρακτηριστικό OpenType `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} Το {label} πρέπει να είναι αριθμός μεγαλύτερος από 0 και έως {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 163 and column 5.
|
@@ -5979,6 +5979,7 @@ anchor Points: Puntos:
|
||||
Character Color Color de los caracteres
|
||||
OpenType Features Funciones OpenType
|
||||
Stylistic Sets Conjuntos estilísticos
|
||||
Set {n} Conjunto {n}
|
||||
@msg features lists at most {max} tags features admite como máximo {max} etiquetas
|
||||
@msg unknown OpenType feature `{t}` función OpenType desconocida `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} debe ser un número mayor que 0 y como máximo {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6067,6 +6067,7 @@ anchor Points: Pisteet:
|
||||
Character Color Merkin väri
|
||||
OpenType Features OpenType-ominaisuudet
|
||||
Stylistic Sets Tyylisarjat
|
||||
Set {n} Sarja {n}
|
||||
@msg features lists at most {max} tags features sisältää enintään {max} tunnistetta
|
||||
@msg unknown OpenType feature `{t}` tuntematon OpenType-ominaisuus `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} on oltava luku, joka on yli 0 ja enintään {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6032,6 +6032,7 @@ anchor Points: Points :
|
||||
Character Color Couleur des caractères
|
||||
OpenType Features Fonctions OpenType
|
||||
Stylistic Sets Jeux stylistiques
|
||||
Set {n} Jeu {n}
|
||||
@msg features lists at most {max} tags features contient au plus {max} balises
|
||||
@msg unknown OpenType feature `{t}` fonction OpenType inconnue `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} doit être un nombre supérieur à 0 et au plus égal à {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6021,6 +6021,7 @@ anchor Points: Pontok:
|
||||
Character Color Karakterszín
|
||||
OpenType Features OpenType-funkciók
|
||||
Stylistic Sets Stíluskészletek
|
||||
Set {n} {n}. készlet
|
||||
@msg features lists at most {max} tags a features legfeljebb {max} címkét tartalmazhat
|
||||
@msg unknown OpenType feature `{t}` ismeretlen OpenType-funkció: `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} 0-nál nagyobb és legfeljebb {max} értékű szám kell legyen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1656,6 +1656,7 @@ digits Malayalam Malayalam
|
||||
Select text to set its OpenType features. Pilih teks untuk mengatur fitur OpenType-nya.
|
||||
Standard Ligatures Ligatur standar
|
||||
Stylistic Alternates Alternatif gaya
|
||||
Set {n} Set {n}
|
||||
Swash Swash
|
||||
Tabular Lining Lining tabular
|
||||
Tabular Oldstyle Oldstyle tabular
|
||||
|
||||
|
@@ -5656,6 +5656,7 @@ anchor Points: Punti:
|
||||
Character Color Colore carattere
|
||||
OpenType Features Funzioni OpenType
|
||||
Stylistic Sets Set stilistici
|
||||
Set {n} Set {n}
|
||||
@msg features lists at most {max} tags features contiene al massimo {max} tag
|
||||
@msg unknown OpenType feature `{t}` funzione OpenType sconosciuta `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} deve essere un numero maggiore di 0 e al massimo {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5721,6 +5721,7 @@ anchor Points: ポイント:
|
||||
Character Color 文字カラー
|
||||
OpenType Features OpenType 機能
|
||||
Stylistic Sets スタイルセット
|
||||
Set {n} セット {n}
|
||||
@msg features lists at most {max} tags features に指定できるタグは {max} 個までです
|
||||
@msg unknown OpenType feature `{t}` 不明な OpenType 機能 `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} には 0 より大きく {max} 以下の数値を指定してください
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6033,6 +6033,7 @@ anchor Points: წერტილები:
|
||||
Character Color სიმბოლოს ფერი
|
||||
OpenType Features OpenType შესაძლებლობები
|
||||
Stylistic Sets სტილისტური ნაკრებები
|
||||
Set {n} ნაკრები {n}
|
||||
@msg features lists at most {max} tags features შეიძლება შეიცავდეს არაუმეტეს {max} ტეგს
|
||||
@msg unknown OpenType feature `{t}` უცნობი OpenType შესაძლებლობა `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} უნდა იყოს 0-ზე მეტი და არაუმეტეს {max}-ისა რიცხვი
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5617,6 +5617,7 @@ anchor Points: 포인트:
|
||||
Character Color 문자 색상
|
||||
OpenType Features OpenType 기능
|
||||
Stylistic Sets 스타일 세트
|
||||
Set {n} 세트 {n}
|
||||
@msg features lists at most {max} tags features에는 태그를 최대 {max}개까지 지정할 수 있습니다
|
||||
@msg unknown OpenType feature `{t}` 알 수 없는 OpenType 기능 `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label}은(는) 0 초과 {max} 이하의 숫자여야 합니다
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1670,6 +1670,7 @@ digits Malayalam Malayalam
|
||||
Select text to set its OpenType features. Selecteer tekst om de OpenType-functies in te stellen.
|
||||
Standard Ligatures Standaardligaturen
|
||||
Stylistic Alternates Stilistische alternatieven
|
||||
Set {n} Set {n}
|
||||
Swash Swash
|
||||
Tabular Lining Tabulaire lining
|
||||
Tabular Oldstyle Tabulaire oldstyle
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5891,6 +5891,7 @@ anchor Points: Punkty:
|
||||
Character Color Kolor znaków
|
||||
OpenType Features Funkcje OpenType
|
||||
Stylistic Sets Zestawy stylistyczne
|
||||
Set {n} Zestaw {n}
|
||||
@msg features lists at most {max} tags features może zawierać najwyżej {max} znaczników
|
||||
@msg unknown OpenType feature `{t}` nieznana funkcja OpenType `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} musi być liczbą większą od 0 i nie większą niż {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5953,6 +5953,7 @@ anchor Points: Pontos:
|
||||
Character Color Cor do Caractere
|
||||
OpenType Features Recursos OpenType
|
||||
Stylistic Sets Conjuntos Estilísticos
|
||||
Set {n} Conjunto {n}
|
||||
@msg features lists at most {max} tags features aceita no máximo {max} marcas
|
||||
@msg unknown OpenType feature `{t}` recurso OpenType desconhecido `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} deve ser um número maior que 0 e no máximo {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -6014,6 +6014,7 @@ anchor Points: Точки:
|
||||
Character Color Цвет символов
|
||||
OpenType Features Функции OpenType
|
||||
Stylistic Sets Стилистические наборы
|
||||
Set {n} Набор {n}
|
||||
@msg features lists at most {max} tags features содержит не более {max} тегов
|
||||
@msg unknown OpenType feature `{t}` неизвестная функция OpenType `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} должно быть числом больше 0 и не более {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6089,6 +6089,7 @@ shape Open Öppen
|
||||
Character Color Teckenfärg
|
||||
OpenType Features OpenType-funktioner
|
||||
Stylistic Sets Stilistiska uppsättningar
|
||||
Set {n} Uppsättning {n}
|
||||
@msg features lists at most {max} tags features får innehålla högst {max} taggar
|
||||
@msg unknown OpenType feature `{t}` okänd OpenType-funktion `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} måste vara ett tal över 0 och högst {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -5994,6 +5994,7 @@ anchor Points: Noktalar:
|
||||
Character Color Karakter Rengi
|
||||
OpenType Features OpenType Özellikleri
|
||||
Stylistic Sets Stilistik Setler
|
||||
Set {n} Set {n}
|
||||
@msg features lists at most {max} tags features en fazla {max} etiket içerebilir
|
||||
@msg unknown OpenType feature `{t}` bilinmeyen OpenType özelliği `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} 0'ın üzerinde ve en fazla {max} olan bir sayı olmalıdır
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -5636,6 +5636,7 @@ anchor Points: Точки:
|
||||
Character Color Колір символів
|
||||
OpenType Features Функції OpenType
|
||||
Stylistic Sets Стилістичні набори
|
||||
Set {n} Набір {n}
|
||||
@msg features lists at most {max} tags features містить не більше {max} тегів
|
||||
@msg unknown OpenType feature `{t}` невідома функція OpenType `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} має бути числом більше 0 і не більше {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 177 and column 5.
|
@@ -5637,6 +5637,7 @@ anchor Points: Điểm:
|
||||
Character Color Màu ký tự
|
||||
OpenType Features Tính năng OpenType
|
||||
Stylistic Sets Bộ phong cách
|
||||
Set {n} Bộ {n}
|
||||
@msg features lists at most {max} tags features chứa tối đa {max} thẻ
|
||||
@msg unknown OpenType feature `{t}` tính năng OpenType không xác định `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} phải là một số lớn hơn 0 và tối đa {max}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 199 and column 5.
|
@@ -5878,6 +5878,7 @@ anchor Points: 点:
|
||||
Character Color 字符颜色
|
||||
OpenType Features OpenType 特性
|
||||
Stylistic Sets 风格集
|
||||
Set {n} 风格集 {n}
|
||||
@msg features lists at most {max} tags features 最多包含 {max} 个标签
|
||||
@msg unknown OpenType feature `{t}` 未知的 OpenType 特性 `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} 必须是大于 0 且不超过 {max} 的数字
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5674,6 +5674,7 @@ anchor Points: 點:
|
||||
Character Color 字元顏色
|
||||
OpenType Features OpenType 功能
|
||||
Stylistic Sets 風格集
|
||||
Set {n} 風格集 {n}
|
||||
@msg features lists at most {max} tags features 最多包含 {max} 個標籤
|
||||
@msg unknown OpenType feature `{t}` 未知的 OpenType 功能 `{t}`
|
||||
@msg {label} must be a number above 0 and at most {max} {label} 必須是大於 0 且不超過 {max} 的數字
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4,7 +4,7 @@
|
||||
|
||||
use egui::Ui;
|
||||
use serde_json::json;
|
||||
use vectorcraft_text::{EXTRA_FEATURES, FontDb, OtFeatures};
|
||||
use vectorcraft_text::{EXTRA_FEATURES, FontDb, OtFeatures, StylisticSet};
|
||||
|
||||
use super::character::{shared, text_editing, text_style};
|
||||
use crate::VectorcraftApp;
|
||||
@@ -208,7 +208,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
for set in &sets {
|
||||
let flag = Flag::Extra(EXTRA_FEATURES[usize::from(set.number - 1)]);
|
||||
let on = flag.get(&next);
|
||||
if widgets::check(ui, &set.name, on, true) {
|
||||
if widgets::check(ui, &set_label(set), on, true) {
|
||||
change = Some(Change::Toggle(flag, !on));
|
||||
}
|
||||
}
|
||||
@@ -222,6 +222,15 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A Stylistic Sets menu entry: the font's own name for the set, or `Set 1` through `Set 20` in
|
||||
/// the UI language.
|
||||
fn set_label(set: &StylisticSet) -> String {
|
||||
match &set.name {
|
||||
Some(name) => name.clone(),
|
||||
None => crate::i18n::fmt(tl!("Set {n}"), &[("n", &set.number.to_string())]),
|
||||
}
|
||||
}
|
||||
|
||||
/// The panel's checkbox rows, in the order they are drawn.
|
||||
fn rows() -> [Toggle; 9] {
|
||||
[
|
||||
@@ -311,6 +320,21 @@ mod tests {
|
||||
assert_eq!(text_style(&app).unwrap().0.features, ["ss03"]);
|
||||
}
|
||||
|
||||
/// A set the font names keeps the font's name; a set without one gets the numbered label in
|
||||
/// the UI language.
|
||||
#[test]
|
||||
fn stylistic_set_labels_follow_the_ui_language() {
|
||||
let named = StylisticSet { number: 1, name: Some("Curved Capitals".into()) };
|
||||
let numbered = StylisticSet { number: 3, name: None };
|
||||
assert_eq!(set_label(&numbered), "Set 3");
|
||||
let Some(de) = crate::i18n::Lang::from_code("de") else { panic!("no German catalog") };
|
||||
crate::i18n::set_current(de);
|
||||
let (named_de, numbered_de) = (set_label(&named), set_label(&numbered));
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
assert_eq!(named_de, "Curved Capitals");
|
||||
assert_eq!(numbered_de, "Satz 3");
|
||||
}
|
||||
|
||||
/// The Figure menu lists its five entries in order; Proportional Lining sets `pnum` and
|
||||
/// `lnum` and clears `tnum` and `onum`, Tabular Lining clears `pnum`, Proportional Oldstyle
|
||||
/// clears `lnum`, and Default Figure and Tabular Oldstyle clear `pnum` and `lnum`.
|
||||
|
||||
Reference in New Issue
Block a user