mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-20 17:37:10 +01:00
train: #7565
This commit is contained in:
commit
728a2776a0
37 files changed
+360
-29
No files matched your search
@@ -18,7 +18,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Document Info",
|
||||
["Window", "Document Info"],
|
||||
None,
|
||||
"{selectionOnly?, category?: document|objects|graphicStyles|brushes|spotColors|patterns|gradients|symbols|fonts|fontDetails|linkedImages|embeddedImages|repeats (only that one in sections and the text), format?: \"text\" (→ {text}: the report Document Info › Save… and Package write)} → {document: {…, units (English), unitId: the units' Preferences › Units id (points, millimeters, feetInches, …), rasterEffectsPpi, transparency: {gridSize: small|medium|large, gridColors: [#rrggbb, #rrggbb], gridColorsName (a preset's name or Custom), simulatePaper, flattenerPreset} (File › Document Setup's transparency settings, which the document category lists), selectedArtboards: [{index, name, width, height, x, y}] (while the Artboard tool is the current tool, the artboards it has selected, in the document's units, x and y those of the top-left corner from the ruler origin of its active artboard, which the document category lists after the artboards; else empty)}, objects: {paths, compoundPaths, groups, …}, pathLength: pt (the paths' total length, compound paths' included, guides left out), fonts (the type in opacity masks and in the art of symbols and patterns included; with selectionOnly: the selected type's), fontDetails: [{font, match: exact|style|missingWithFallback|missing, family, style, file, embedding: allowed|editing|previewPrint|forbidden|null}] (each font of fonts, in order: how it was found, the face shown (null when none), that face's file name (null for a built-in face) and what its license allows), images, imageObjects: [{name, width, height, linked, file}] (the image objects in the order Linked Images and Embedded Images list them; file: what a linked image's row shows, null for an embedded one), swatches, graphicStyleNames (with selectionOnly: the styles the selected objects are linked to), brushNames (the brushes the art's drawn strokes use, each once; with selectionOnly: those the selected objects' strokes use), brushes: [{name, type: calligraphic|scatter|art|pattern|bristle|null}] (those brushes with their types; null: not in the Brushes panel), panelBrushNames (the Brushes panel's brushes), repeatObjects: [{id, name, type: radial|grid|mirror, instances, rows?, cols?}] (the Repeat objects, those in groups and other repeats included; with selectionOnly: those in the selection), spotObjects: [{id, name, spotColors}] (the objects filled or stroked with a spot color swatch, as a solid color or in the stops of a gradient that color a part of it above opacity 0 (a stop at opacity 0 counts only where it mixes with a stop above opacity 0 over a stretch of some width), at a tint above 0, and grayscale images colorized with one, each once, by the rules patternObjects follows, with the spot colors they use; Registration and process colors are not spot colors; objects.spots counts them), spotColorNames and spotColors (the spot colors those objects use), patternObjects: [{id, name, patterns}] (the objects filled or stroked with a pattern, each once, those in groups and type whose drawn characters use one included, hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, compound path members' own fills and strokes, images' fills and strokes without a shape and characters that draw nothing left out, with the patterns they use, which objects.patterns counts; with selectionOnly: those in the selection), patternNames (the patterns those objects use), gradientObjects: [{id, name, gradients, kinds}] (the objects filled or stroked with a gradient, by the same rules, with the gradients they use: a linked gradient swatch's name, else its kind's name, such as Linear gradient; kinds gives each one's kind, linear|radial|conic|diamond|freeform, when it is named by its kind, else null; objects.gradients counts them), gradientNames (the gradients those objects use), …, sections: [{id, title, rows: [[label, value]]}] (the panel's categories; fontDetails: each font's file and whether its license lets it be embedded)}. An image linked to a file outside the automation read roots has link null, and its Linked Images row names the file alone. brushNames, brushes, spotObjects, patternObjects and gradientObjects leave out hidden objects, objects at an opacity of 0 and the objects inside a hidden group or layer or one at an opacity of 0 (with selectionOnly too), their characters' paints and colorized images included; objects still counts them as paths, groups and the other kinds",
|
||||
"{selectionOnly?, category?: document|objects|graphicStyles|brushes|spotColors|patterns|gradients|symbols|fonts|fontDetails|linkedImages|embeddedImages|repeats (only that one in sections and the text), format?: \"text\" (→ {text}: the report Document Info › Save… and Package write)} → {document: {…, units (English), unitId: the units' Preferences › Units id (points, millimeters, feetInches, …), rasterEffectsPpi, transparency: {gridSize: small|medium|large, gridColors: [#rrggbb, #rrggbb], gridColorsName (a preset's name or Custom), simulatePaper, flattenerPreset} (File › Document Setup's transparency settings, which the document category lists), selectedArtboards: [{index, name, width, height, x, y}] (while the Artboard tool is the current tool, the artboards it has selected, in the document's units, x and y those of the top-left corner from the ruler origin of its active artboard, which the document category lists after the artboards; else empty)}, objects: {paths, compoundPaths, groups, …}, pathLength: pt (the paths' total length, compound paths' included, guides left out), fonts (the type in opacity masks and in the art of symbols and patterns included; with selectionOnly: the selected type's), fontUses: [{font, type: truetype|opentype|unknown, uses}] (each font of fonts, in order: truetype or opentype by the outlines (glyf, or CFF or CFF2) of the face its type is drawn in, unknown for a font not installed in the family and style it names; uses: the text objects set in it, each once however many of its runs use the font, the type in a mask or in a symbol's or pattern's art once however many objects show it; the fonts category's rows give them as `TrueType; 2 uses`), fontDetails: [{font, match: exact|style|missingWithFallback|missing, family, style, file, embedding: allowed|editing|previewPrint|forbidden|null}] (each font of fonts, in order: how it was found, the face shown (null when none), that face's file name (null for a built-in face) and what its license allows), images, imageObjects: [{name, width, height, linked, file}] (the image objects in the order Linked Images and Embedded Images list them; file: what a linked image's row shows, null for an embedded one), swatches, graphicStyleNames (with selectionOnly: the styles the selected objects are linked to), brushNames (the brushes the art's drawn strokes use, each once; with selectionOnly: those the selected objects' strokes use), brushes: [{name, type: calligraphic|scatter|art|pattern|bristle|null}] (those brushes with their types; null: not in the Brushes panel), panelBrushNames (the Brushes panel's brushes), repeatObjects: [{id, name, type: radial|grid|mirror, instances, rows?, cols?}] (the Repeat objects, those in groups and other repeats included; with selectionOnly: those in the selection), spotObjects: [{id, name, spotColors}] (the objects filled or stroked with a spot color swatch, as a solid color or in the stops of a gradient that color a part of it above opacity 0 (a stop at opacity 0 counts only where it mixes with a stop above opacity 0 over a stretch of some width), at a tint above 0, and grayscale images colorized with one, each once, by the rules patternObjects follows, with the spot colors they use; Registration and process colors are not spot colors; objects.spots counts them), spotColorNames and spotColors (the spot colors those objects use), patternObjects: [{id, name, patterns}] (the objects filled or stroked with a pattern, each once, those in groups and type whose drawn characters use one included, hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, compound path members' own fills and strokes, images' fills and strokes without a shape and characters that draw nothing left out, with the patterns they use, which objects.patterns counts; with selectionOnly: those in the selection), patternNames (the patterns those objects use), gradientObjects: [{id, name, gradients, kinds}] (the objects filled or stroked with a gradient, by the same rules, with the gradients they use: a linked gradient swatch's name, else its kind's name, such as Linear gradient; kinds gives each one's kind, linear|radial|conic|diamond|freeform, when it is named by its kind, else null; objects.gradients counts them), gradientNames (the gradients those objects use), …, sections: [{id, title, rows: [[label, value]]}] (the panel's categories; fontDetails: each font's file and whether its license lets it be embedded)}. An image linked to a file outside the automation read roots has link null, and its Linked Images row names the file alone. brushNames, brushes, spotObjects, patternObjects and gradientObjects leave out hidden objects, objects at an opacity of 0 and the objects inside a hidden group or layer or one at an opacity of 0 (with selectionOnly too), their characters' paints and colorized images included; objects still counts them as paths, groups and the other kinds",
|
||||
has_doc,
|
||||
info
|
||||
),
|
||||
@@ -144,6 +144,45 @@ fn font_detail(used: &super::fonts::UsedFont) -> (Value, (String, String)) {
|
||||
(entry, (label, detail))
|
||||
}
|
||||
|
||||
/// The type of a font as Fonts lists it: `truetype` or `opentype` by the outlines of the face the
|
||||
/// type is drawn in (in the version the type names), `unknown` for a font that is not installed in
|
||||
/// the family and style it names, or whose face holds neither kind of outline.
|
||||
fn font_type(used: &super::fonts::UsedFont) -> &'static str {
|
||||
let db = vectorcraft_text::FontDb::global();
|
||||
let (family, style, version) = used;
|
||||
match db.resolve(family, style) {
|
||||
Some((f, vectorcraft_text::FontMatch::Exact)) => match db.face_version(family, style, version.as_deref()).unwrap_or(f).outline_format() {
|
||||
Some(vectorcraft_text::OutlineFormat::TrueType) => "truetype",
|
||||
Some(vectorcraft_text::OutlineFormat::Cff) => "opentype",
|
||||
None => "unknown",
|
||||
},
|
||||
_ => "unknown",
|
||||
}
|
||||
}
|
||||
|
||||
/// A font as Fonts lists it: its `fontUses` entry and its row, which gives the font's type and its
|
||||
/// number of uses (`uses`: the text objects set in it).
|
||||
fn font_use(used: &super::fonts::UsedFont, uses: usize) -> (Value, (String, String)) {
|
||||
let label = super::fonts::font_label(used);
|
||||
let kind = font_type(used);
|
||||
let name = match kind {
|
||||
"truetype" => "TrueType",
|
||||
"opentype" => "OpenType",
|
||||
_ => "unknown type",
|
||||
};
|
||||
let count = if uses == 1 { "1 use".to_string() } else { format!("{uses} uses") };
|
||||
(json!({ "font": label, "type": kind, "uses": uses }), (label, format!("{name}; {count}")))
|
||||
}
|
||||
|
||||
/// Counts text object `t` once for each font its runs are drawn in, a composite font's parts in
|
||||
/// place of its name ([`super::fonts::run_fonts`]).
|
||||
fn count_fonts(fonts: &mut BTreeMap<super::fonts::UsedFont, usize>, t: &vectorcraft_doc::TextObject) {
|
||||
let own: BTreeSet<super::fonts::UsedFont> = t.runs.iter().flat_map(super::fonts::run_fonts).collect();
|
||||
for font in own {
|
||||
*fonts.entry(font).or_default() += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// An image object as Document Info lists it: (name, width, height, linked file).
|
||||
type ImageRow = (String, u32, u32, Option<String>);
|
||||
|
||||
@@ -221,16 +260,16 @@ fn selected_artboard_rows(d: &Document, picked: &[usize], active: usize) -> (Vec
|
||||
}
|
||||
|
||||
/// The Document Info categories of `d` (only `category` when given) from `info` (what
|
||||
/// `document.info` reports), the rows of the artboards the Artboard tool has selected, its fonts
|
||||
/// and their Font Details rows, its image objects, the rows of the brushes its art uses, the rows
|
||||
/// of its Repeat objects and the rows of its objects filled or stroked with a spot color, with a
|
||||
/// pattern and with a gradient.
|
||||
/// `document.info` reports), the rows of the artboards the Artboard tool has selected, the rows of
|
||||
/// its fonts and their Font Details rows, its image objects, the rows of the brushes its art uses,
|
||||
/// the rows of its Repeat objects and the rows of its objects filled or stroked with a spot color,
|
||||
/// with a pattern and with a gradient.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn sections(
|
||||
d: &Document,
|
||||
info: &Value,
|
||||
selected_artboards: &[(String, String)],
|
||||
fonts: &BTreeSet<super::fonts::UsedFont>,
|
||||
fonts: &[(String, String)],
|
||||
font_details: &[(String, String)],
|
||||
images: &[ImageRow],
|
||||
brushes: &[(String, String)],
|
||||
@@ -296,7 +335,7 @@ fn sections(
|
||||
"patterns" => pattern_objects.to_vec(),
|
||||
"gradients" => gradient_objects.to_vec(),
|
||||
"symbols" => names("symbols"),
|
||||
"fonts" => fonts.iter().map(|f| (super::fonts::font_label(f), String::new())).collect(),
|
||||
"fonts" => fonts.to_vec(),
|
||||
"fontDetails" => font_details.to_vec(),
|
||||
"linkedImages" => {
|
||||
images.iter().filter_map(|(name, w, h, link)| Some((name.clone(), format!("{w} × {h} px — {}", link.as_ref()?)))).collect()
|
||||
@@ -627,7 +666,8 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// The paths' total length, as Document Info › Objects shows it (the length of a cut line, a
|
||||
// strip of LEDs along the letters, #1958).
|
||||
let mut path_length = 0.0;
|
||||
let mut fonts = BTreeSet::new();
|
||||
// Each font with the number of text objects set in it.
|
||||
let mut fonts: BTreeMap<super::fonts::UsedFont, usize> = BTreeMap::new();
|
||||
let mut images: BTreeMap<String, Value> = BTreeMap::new();
|
||||
let mut image_rows: Vec<ImageRow> = vec![];
|
||||
// Whether the request being served may read each linked file (a relative path read from the
|
||||
@@ -702,9 +742,7 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
NodeKind::Compound { .. } => Some("compoundPaths"),
|
||||
NodeKind::Text(t) => {
|
||||
for run in &t.runs {
|
||||
fonts.insert((run.style.font_family.clone(), run.style.font_style.clone(), run.style.font_version.clone()));
|
||||
}
|
||||
count_fonts(&mut fonts, t);
|
||||
Some("textObjects")
|
||||
}
|
||||
NodeKind::Image(im) => {
|
||||
@@ -787,12 +825,16 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
}
|
||||
// The document's fonts include those of the type in opacity masks and in the art of its
|
||||
// symbols and patterns, as Find Font lists them.
|
||||
// symbols and patterns, as Find Font lists them. Each of those text objects counts once, however
|
||||
// many objects show it.
|
||||
if !selection_only {
|
||||
fonts.extend(super::fonts::art_texts_of(d).into_iter().flat_map(|(_, t, _)| t.runs.iter().map(|r| super::fonts::font_of(&r.style))));
|
||||
for (_, t, _) in super::fonts::art_texts_of(d) {
|
||||
count_fonts(&mut fonts, t);
|
||||
}
|
||||
}
|
||||
let font_names: Vec<String> = fonts.iter().map(super::fonts::font_label).collect();
|
||||
let (font_entries, font_rows): (Vec<Value>, Vec<(String, String)>) = fonts.iter().map(font_detail).unzip();
|
||||
let font_names: Vec<String> = fonts.keys().map(super::fonts::font_label).collect();
|
||||
let (font_uses, font_use_rows): (Vec<Value>, Vec<(String, String)>) = fonts.iter().map(|(f, n)| font_use(f, *n)).unzip();
|
||||
let (font_entries, font_rows): (Vec<Value>, Vec<(String, String)>) = fonts.keys().map(font_detail).unzip();
|
||||
// The image objects in walk order, as Linked Images and Embedded Images list them: `file` is a
|
||||
// linked image's row value (its path, or its file name alone when the request may not read it),
|
||||
// and null for an embedded one.
|
||||
@@ -820,6 +862,7 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"objects": counts,
|
||||
"pathLength": path_length,
|
||||
"fonts": font_names,
|
||||
"fontUses": font_uses,
|
||||
"fontDetails": font_entries,
|
||||
"images": images,
|
||||
"imageObjects": image_objects,
|
||||
@@ -850,7 +893,7 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
d,
|
||||
&out,
|
||||
&selected_rows,
|
||||
&fonts,
|
||||
&font_use_rows,
|
||||
&font_rows,
|
||||
&image_rows,
|
||||
&brush_rows,
|
||||
@@ -1083,6 +1126,92 @@ mod tests {
|
||||
assert_eq!(fonts(&mut s, json!({"selectionOnly": true})), json!(["Source Sans 3 Regular"]));
|
||||
}
|
||||
|
||||
/// Fonts gives each font's type and its number of uses: the text objects set in it, each once
|
||||
/// however many of its runs use the font. The type in a symbol's art counts once however many
|
||||
/// instances show it, and the type in an opacity mask once. With Selection Only it counts the
|
||||
/// selected type alone. A font that is not installed has an unknown type. The rows, the report
|
||||
/// and `fontUses` give the same facts, in the order of `fonts`.
|
||||
#[test]
|
||||
fn info_fonts_give_each_font_s_type_and_uses() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 200, "height": 200})).unwrap();
|
||||
let id = |v: Value| NodeId(v["id"].as_u64().unwrap());
|
||||
let text =
|
||||
|s: &mut Session, font: &str, y: f64| id(s.execute("text.create", &json!({"x": 10, "y": y, "text": "Hello", "font": font})).unwrap());
|
||||
// Two runs in Source Sans 3 Regular in one text object, a second object in it, and one in Inter.
|
||||
let twice = text(&mut s, "Source Sans 3", 20.0);
|
||||
s.execute("text.setRangeStyle", &json!({"id": twice.0, "start": 0, "end": 2, "size": 30})).unwrap();
|
||||
assert!(matches!(&s.doc().unwrap().doc.node(twice).unwrap().kind, NodeKind::Text(t) if t.runs.len() == 2));
|
||||
let other = text(&mut s, "Source Sans 3", 50.0);
|
||||
text(&mut s, "Inter", 80.0);
|
||||
text(&mut s, "Qx Absent Family", 110.0);
|
||||
// A symbol whose art holds type in Inter, shown by two instances, and a mask holding type in Inter.
|
||||
let in_symbol = text(&mut s, "Inter", 140.0);
|
||||
s.execute("symbol.new", &json!({"name": "Mark", "ids": [in_symbol.0]})).unwrap();
|
||||
s.execute("symbol.place", &json!({"name": "Mark", "x": 100, "y": 100})).unwrap();
|
||||
let masked = id(s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap());
|
||||
let in_mask = text(&mut s, "Inter", 170.0);
|
||||
s.edit("Mask", |d, _| {
|
||||
let art = d.remove(in_mask)?;
|
||||
d.node_mut(masked).unwrap().extras_mut().mask = Some(Box::new(vectorcraft_doc::OpacityMask::new((*art).clone(), true)));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let i = s.execute("document.info", &json!({"category": "fonts"})).unwrap();
|
||||
assert_eq!(i["fonts"], json!(["Inter Regular", "Qx Absent Family Regular", "Source Sans 3 Regular"]));
|
||||
assert_eq!(
|
||||
i["fontUses"],
|
||||
json!([
|
||||
{"font": "Inter Regular", "type": "truetype", "uses": 3},
|
||||
{"font": "Qx Absent Family Regular", "type": "unknown", "uses": 1},
|
||||
{"font": "Source Sans 3 Regular", "type": "truetype", "uses": 2},
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
i["sections"][0]["rows"],
|
||||
json!([
|
||||
["Inter Regular", "TrueType; 3 uses"],
|
||||
["Qx Absent Family Regular", "unknown type; 1 use"],
|
||||
["Source Sans 3 Regular", "TrueType; 2 uses"],
|
||||
])
|
||||
);
|
||||
let report = s.execute("document.info", &json!({"category": "fonts", "format": "text"})).unwrap()["text"].as_str().unwrap().to_string();
|
||||
assert!(report.contains("\nFONTS\nInter Regular: TrueType; 3 uses\nQx Absent Family Regular: unknown type; 1 use\n"), "{report}");
|
||||
// Selection Only: the selected type's fonts and uses.
|
||||
s.execute("select.set", &json!({"ids": [other.0]})).unwrap();
|
||||
let i = s.execute("document.info", &json!({"selectionOnly": true, "category": "fonts"})).unwrap();
|
||||
assert_eq!(i["fontUses"], json!([{"font": "Source Sans 3 Regular", "type": "truetype", "uses": 1}]));
|
||||
assert_eq!(i["sections"][0]["rows"], json!([["Source Sans 3 Regular", "TrueType; 1 use"]]));
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
let i = s.execute("document.info", &json!({"selectionOnly": true, "category": "fonts"})).unwrap();
|
||||
assert_eq!((i["fontUses"].clone(), i["sections"][0]["rows"].clone()), (json!([]), json!([])));
|
||||
}
|
||||
|
||||
/// Type set in a composite font counts as a use of the fonts of the parts its characters fall
|
||||
/// in, as Find Font lists them, not of the composite font's name.
|
||||
#[test]
|
||||
fn info_fonts_count_the_parts_of_a_composite_font() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 200, "height": 200})).unwrap();
|
||||
let font = json!({"name": "DI Uses Composite", "parts": {
|
||||
"kanji": {"font": "Source Sans 3"},
|
||||
"roman": {"font": "JetBrains Mono"},
|
||||
"numerals": {"font": "Inter"},
|
||||
}});
|
||||
s.execute("type.compositeFonts.set", &json!({"fonts": [font]})).unwrap();
|
||||
s.execute("text.create", &json!({"x": 10, "y": 20, "text": "Ab1", "font": "DI Uses Composite"})).unwrap();
|
||||
s.execute("text.create", &json!({"x": 10, "y": 50, "text": "12", "font": "DI Uses Composite"})).unwrap();
|
||||
let i = s.execute("document.info", &json!({"category": "fonts"})).unwrap();
|
||||
assert_eq!(i["fonts"], json!(["Inter Regular", "JetBrains Mono Regular"]));
|
||||
assert_eq!(
|
||||
i["fontUses"],
|
||||
json!([
|
||||
{"font": "Inter Regular", "type": "truetype", "uses": 2},
|
||||
{"font": "JetBrains Mono Regular", "type": "truetype", "uses": 1},
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/// Document Info › Objects gives the paths' total length in the document's units (#1958): an
|
||||
/// open line, a closed rectangle's perimeter and a compound path's pieces count, a guide doesn't.
|
||||
#[test]
|
||||
|
||||
@@ -747,7 +747,9 @@ fn a_font_named_by_another_of_its_names_is_copied() {
|
||||
let zip = unzip(&vectorcraft_format::base64_decode(r["dataBase64"].as_str().unwrap()).unwrap());
|
||||
let report = String::from_utf8(zip["poster Folder/poster Report.txt"].clone()).unwrap();
|
||||
assert!(report.contains("SourceSans3-Semibold Regular → Fonts/"), "{report}");
|
||||
let details = report.lines().find(|l| l.starts_with("SourceSans3-Semibold Regular: ")).unwrap_or_default();
|
||||
// The Font Details row: the Fonts rows above it start with the same label.
|
||||
let font_details = report.split("\nFONT DETAILS\n").nth(1).unwrap_or_default();
|
||||
let details = font_details.lines().find(|l| l.starts_with("SourceSans3-Semibold Regular: ")).unwrap_or_default();
|
||||
assert!(details.contains("embedding allowed") && !details.contains("missing"), "{report}");
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ use face::Instances;
|
||||
#[cfg(test)]
|
||||
pub(crate) use face::MAX_LIVE_INSTANCES;
|
||||
pub(crate) use face::PathAlignHeights;
|
||||
pub use face::{FALLBACK_FAMILY, FontFace, IcfMargins};
|
||||
pub use face::{FALLBACK_FAMILY, FontFace, IcfMargins, OutlineFormat};
|
||||
pub(crate) use glyph_pen::FlipPen;
|
||||
pub use gsub::{GlyphCategory, GlyphCategoryKind, GlyphOrigin, JoiningPosition, Substitution, SubstitutionKind};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
||||
@@ -753,4 +753,54 @@ impl FontFace {
|
||||
use skrifa::raw::TableProvider;
|
||||
self.skrifa().is_some_and(|f| f.glyf().is_ok())
|
||||
}
|
||||
/// The kind of outlines the face's glyphs are drawn from ([`outline_format_of`]).
|
||||
pub fn outline_format(&self) -> Option<OutlineFormat> {
|
||||
self.skrifa().and_then(|f| outline_format_of(&f))
|
||||
}
|
||||
}
|
||||
|
||||
/// The kind of outlines a face's glyphs are drawn from.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum OutlineFormat {
|
||||
/// Quadratic outlines in a `glyf` table.
|
||||
TrueType,
|
||||
/// PostScript outlines in a `CFF ` or `CFF2` table.
|
||||
Cff,
|
||||
}
|
||||
|
||||
/// The kind of outlines `font`'s glyphs are drawn from: TrueType when it has a `glyf` table, else
|
||||
/// CFF when it has a `CFF ` or `CFF2` table. None for a font with neither (outlines in `VARC`
|
||||
/// alone, color bitmaps only).
|
||||
pub(crate) fn outline_format_of(font: &skrifa::FontRef<'_>) -> Option<OutlineFormat> {
|
||||
let has = |tag: &[u8; 4]| font.table_data(skrifa::Tag::new(tag)).is_some();
|
||||
if has(b"glyf") {
|
||||
Some(OutlineFormat::TrueType)
|
||||
} else if has(b"CFF ") || has(b"CFF2") {
|
||||
Some(OutlineFormat::Cff)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// The outline format comes from the tables the font holds.
|
||||
#[test]
|
||||
fn outline_format_follows_the_outline_tables() {
|
||||
let format = |tables: &[(&[u8; 4], &[u8])]| {
|
||||
let font = crate::fontdb::sfnt_of(tables).unwrap_or_default();
|
||||
outline_format_of(&skrifa::FontRef::new(&font).unwrap())
|
||||
};
|
||||
let table = [0_u8; 4];
|
||||
assert_eq!(format(&[(b"glyf", &table), (b"loca", &table)]), Some(OutlineFormat::TrueType));
|
||||
assert_eq!(format(&[(b"CFF ", &table)]), Some(OutlineFormat::Cff));
|
||||
assert_eq!(format(&[(b"CFF2", &table)]), Some(OutlineFormat::Cff));
|
||||
assert_eq!(format(&[(b"VARC", &table)]), None);
|
||||
assert_eq!(format(&[(b"sbix", &table)]), None);
|
||||
// The built-in faces are TrueType.
|
||||
let face = crate::FontDb::global().resolve("Source Sans 3", "Regular").map(|(f, _)| f).unwrap();
|
||||
assert_eq!(face.outline_format(), Some(OutlineFormat::TrueType));
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@ pub use features::{
|
||||
};
|
||||
pub use fontdb::{
|
||||
CompositeCoverage, FALLBACK_FAMILY, FontClass, FontDb, FontFace, FontLikeness, FontMatch, FontTraits, GlyphAlternate, GlyphCategory,
|
||||
GlyphCategoryKind, GlyphOrigin, IcfMargins, JoiningPosition, LentCompositeFonts, PlatformFontFiles, RECENTLY_ADDED_WITHIN, RecentlyAdded,
|
||||
StylisticSet, Substitution, SubstitutionKind, WantedFont, WantedFonts, app_font_dir, is_font_file, is_suitcase, set_app_font_dir,
|
||||
GlyphCategoryKind, GlyphOrigin, IcfMargins, JoiningPosition, LentCompositeFonts, OutlineFormat, PlatformFontFiles, RECENTLY_ADDED_WITHIN,
|
||||
RecentlyAdded, StylisticSet, Substitution, SubstitutionKind, WantedFont, WantedFonts, app_font_dir, is_font_file, is_suitcase, set_app_font_dir,
|
||||
set_platform_font_files, set_user_font_dirs, set_user_font_dirs_confined, style_weight, system_font_dirs, user_font_dirs,
|
||||
};
|
||||
pub use hyphen::{hyphenation_exceptions, set_hyphenation_exceptions};
|
||||
|
||||
@@ -2246,6 +2246,9 @@ font-technology Variable Променливи
|
||||
embedding for preview and print вграждане за преглед и печат
|
||||
embedding allowed вграждането е разрешено
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type неизвестен тип
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} употреба|{n} употреби
|
||||
substituted: shown in {family} {style} ({detail}) заместен: показан с {family} {style} ({detail})
|
||||
missing: shown in {family} {style} липсва: показан с {family} {style}
|
||||
missing липсва
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3524,6 +3524,9 @@ theme Appearance Izgled
|
||||
embedding for preview and print ugrađivanje za pregled i štampu
|
||||
embedding allowed ugrađivanje dozvoljeno
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type nepoznata vrsta
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} upotreba|{n} upotrebe|{n} upotreba
|
||||
substituted: shown in {family} {style} ({detail}) zamijenjen: prikazan fontom {family} {style} ({detail})
|
||||
missing: shown in {family} {style} nedostaje: prikazan fontom {family} {style}
|
||||
missing nedostaje
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3286,6 +3286,9 @@ digits Malayalam Malaiàlam
|
||||
embedding for preview and print incrustació per a la visualització i la impressió
|
||||
embedding allowed incrustació permesa
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type tipus desconegut
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} ús|{n} usos
|
||||
substituted: shown in {family} {style} ({detail}) substituït: es mostra amb {family} {style} ({detail})
|
||||
missing: shown in {family} {style} absent: es mostra amb {family} {style}
|
||||
missing absent
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3624,6 +3624,9 @@ theme Appearance Motiv
|
||||
embedding for preview and print vkládání pro náhled a tisk
|
||||
embedding allowed vkládání povoleno
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type neznámý typ
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} použití|{n} použití|{n} použití
|
||||
substituted: shown in {family} {style} ({detail}) nahrazeno: zobrazeno písmem {family} {style} ({detail})
|
||||
missing: shown in {family} {style} chybí: zobrazeno písmem {family} {style}
|
||||
missing chybí
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6075,6 +6075,9 @@ theme Appearance Udseende
|
||||
embedding for preview and print indlejring til visning og udskrivning
|
||||
embedding allowed indlejring tilladt
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type ukendt type
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} anvendelse|{n} anvendelser
|
||||
substituted: shown in {family} {style} ({detail}) erstattet: vist med {family} {style} ({detail})
|
||||
missing: shown in {family} {style} mangler: vist med {family} {style}
|
||||
missing mangler
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2296,6 +2296,9 @@ file-filter Templates Vorlagen
|
||||
embedding for preview and print Einbetten für Vorschau und Druck
|
||||
embedding allowed Einbetten erlaubt
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type unbekannter Typ
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} Verwendung|{n} Verwendungen
|
||||
substituted: shown in {family} {style} ({detail}) ersetzt: angezeigt in {family} {style} ({detail})
|
||||
missing: shown in {family} {style} fehlt: angezeigt in {family} {style}
|
||||
missing fehlt
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1960,6 +1960,9 @@ font-technology Variable Μεταβλητές
|
||||
embedding for preview and print ενσωμάτωση για προεπισκόπηση και εκτύπωση
|
||||
embedding allowed η ενσωμάτωση επιτρέπεται
|
||||
{file}; {embedding} {file}· {embedding}
|
||||
unknown type άγνωστος τύπος
|
||||
{type}; {uses} {type}· {uses}
|
||||
@plural {n} use|{n} uses {n} χρήση|{n} χρήσεις
|
||||
substituted: shown in {family} {style} ({detail}) αντικαταστάθηκε: εμφανίζεται με {family} {style} ({detail})
|
||||
missing: shown in {family} {style} λείπει: εμφανίζεται με {family} {style}
|
||||
missing λείπει
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2340,6 +2340,9 @@ font-technology Variable Variables
|
||||
embedding for preview and print incrustación para vista previa e impresión
|
||||
embedding allowed incrustación permitida
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type tipo desconocido
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} uso|{n} usos
|
||||
substituted: shown in {family} {style} ({detail}) sustituida: se muestra con {family} {style} ({detail})
|
||||
missing: shown in {family} {style} falta: se muestra con {family} {style}
|
||||
missing falta
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3561,6 +3561,9 @@ theme Appearance Ulkoasu
|
||||
embedding for preview and print upottaminen esikatselua ja tulostusta varten
|
||||
embedding allowed upottaminen sallittu
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type tuntematon tyyppi
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} käyttö|{n} käyttöä
|
||||
substituted: shown in {family} {style} ({detail}) korvattu: näytetään fontilla {family} {style} ({detail})
|
||||
missing: shown in {family} {style} puuttuu: näytetään fontilla {family} {style}
|
||||
missing puuttuu
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2328,6 +2328,9 @@ font-technology Variable Variables
|
||||
embedding for preview and print incorporation pour l’aperçu et l’impression
|
||||
embedding allowed incorporation autorisée
|
||||
{file}; {embedding} {file}, {embedding}
|
||||
unknown type type inconnu
|
||||
{type}; {uses} {type}, {uses}
|
||||
@plural {n} use|{n} uses {n} utilisation|{n} utilisations
|
||||
substituted: shown in {family} {style} ({detail}) remplacée, affichée en {family} {style} ({detail})
|
||||
missing: shown in {family} {style} absente, affichée en {family} {style}
|
||||
missing absente
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4919,6 +4919,9 @@ antiAlias Sharp શાર્પ
|
||||
embedding for preview and print પ્રીવ્યૂ અને પ્રિન્ટ માટે એમ્બેડ કરવાની મંજૂરી
|
||||
embedding allowed એમ્બેડ કરવાની મંજૂરી છે
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type અજ્ઞાત પ્રકાર
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} ઉપયોગ|{n} ઉપયોગ
|
||||
substituted: shown in {family} {style} ({detail}) બદલાયેલ: {family} {style}માં બતાવ્યું ({detail})
|
||||
missing: shown in {family} {style} ગુમ: {family} {style}માં બતાવ્યું
|
||||
missing ગુમ
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -3820,6 +3820,9 @@ antiAlias Sharp शार्प
|
||||
embedding for preview and print पूर्वावलोकन और प्रिंट के लिए एम्बेडिंग
|
||||
embedding allowed एम्बेडिंग की अनुमति है
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type अज्ञात प्रकार
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} उपयोग|{n} उपयोग
|
||||
substituted: shown in {family} {style} ({detail}) प्रतिस्थापित: {family} {style} में दिखाया गया ({detail})
|
||||
missing: shown in {family} {style} अनुपलब्ध: {family} {style} में दिखाया गया
|
||||
missing अनुपलब्ध
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3171,6 +3171,9 @@ file-filter Templates Sablonok
|
||||
embedding for preview and print beágyazás előnézethez és nyomtatáshoz
|
||||
embedding allowed beágyazás engedélyezett
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type ismeretlen típus
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} használat
|
||||
substituted: shown in {family} {style} ({detail}) helyettesítve: megjelenítés ezzel: {family} {style} ({detail})
|
||||
missing: shown in {family} {style} hiányzik: megjelenítés ezzel: {family} {style}
|
||||
missing hiányzik
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3293,6 +3293,9 @@ theme Appearance Tampilan
|
||||
embedding for preview and print penyematan untuk pratinjau dan cetak
|
||||
embedding allowed penyematan diizinkan
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type jenis tidak dikenal
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} penggunaan
|
||||
substituted: shown in {family} {style} ({detail}) diganti: ditampilkan dengan {family} {style} ({detail})
|
||||
missing: shown in {family} {style} tidak ada: ditampilkan dengan {family} {style}
|
||||
missing tidak ada
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2540 and column 5.
|
@@ -2381,6 +2381,9 @@ file-filter Templates Modelli
|
||||
embedding for preview and print incorporamento per anteprima e stampa
|
||||
embedding allowed incorporamento consentito
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type tipo sconosciuto
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} utilizzo|{n} utilizzi
|
||||
substituted: shown in {family} {style} ({detail}) sostituito: mostrato con {family} {style} ({detail})
|
||||
missing: shown in {family} {style} mancante: mostrato con {family} {style}
|
||||
missing mancante
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2580,6 +2580,9 @@ antiAlias Sharp シャープ
|
||||
embedding for preview and print プレビューと印刷用に埋め込み可
|
||||
embedding allowed 埋め込み可
|
||||
{file}; {embedding} {file}、{embedding}
|
||||
unknown type 不明な種類
|
||||
{type}; {uses} {type}、{uses}
|
||||
@plural {n} use|{n} uses 使用 {n} 回
|
||||
substituted: shown in {family} {style} ({detail}) 代替: {family} {style} で表示 ({detail})
|
||||
missing: shown in {family} {style} 見つかりません: {family} {style} で表示
|
||||
missing 見つかりません
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5387,6 +5387,9 @@ theme Appearance იერსახე
|
||||
embedding for preview and print ჩაშენება გადახედვისა და ბეჭდვისთვის
|
||||
embedding allowed ჩაშენება დაშვებულია
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type უცნობი ტიპი
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} გამოყენება
|
||||
substituted: shown in {family} {style} ({detail}) ჩანაცვლებულია: ნაჩვენებია შრიფტით {family} {style} ({detail})
|
||||
missing: shown in {family} {style} აკლია: ნაჩვენებია შრიფტით {family} {style}
|
||||
missing აკლია
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2570,6 +2570,9 @@ antiAlias Sharp 날카롭게
|
||||
embedding for preview and print 미리 보기 및 인쇄용 포함
|
||||
embedding allowed 포함 허용
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type 알 수 없는 유형
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n}회 사용
|
||||
substituted: shown in {family} {style} ({detail}) 대체됨: {family} {style}(으)로 표시({detail})
|
||||
missing: shown in {family} {style} 없음: {family} {style}(으)로 표시
|
||||
missing 없음
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3948,6 +3948,9 @@ theme Appearance Vormgeving
|
||||
embedding for preview and print insluiten voor voorvertoning en afdrukken
|
||||
embedding allowed insluiten toegestaan
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type onbekend type
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} keer gebruikt|{n} keer gebruikt
|
||||
substituted: shown in {family} {style} ({detail}) vervangen: weergegeven in {family} {style} ({detail})
|
||||
missing: shown in {family} {style} ontbreekt: weergegeven in {family} {style}
|
||||
missing ontbreekt
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3503,6 +3503,9 @@ theme Appearance Wygląd
|
||||
embedding for preview and print osadzanie do podglądu i drukowania
|
||||
embedding allowed osadzanie dozwolone
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type nieznany typ
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} użycie|{n} użycia|{n} użyć
|
||||
substituted: shown in {family} {style} ({detail}) zastąpiony: wyświetlany krojem {family} {style} ({detail})
|
||||
missing: shown in {family} {style} brak: wyświetlany krojem {family} {style}
|
||||
missing brak
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1907,6 +1907,9 @@ antiAlias Sharp Nítido
|
||||
embedding for preview and print incorporação para visualização e impressão
|
||||
embedding allowed incorporação permitida
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type tipo desconhecido
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} uso|{n} usos
|
||||
substituted: shown in {family} {style} ({detail}) substituída: exibida em {family} {style} ({detail})
|
||||
missing: shown in {family} {style} ausente: exibida em {family} {style}
|
||||
missing ausente
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2365,6 +2365,9 @@ file-filter Templates Шаблоны
|
||||
embedding for preview and print внедрение для просмотра и печати
|
||||
embedding allowed внедрение разрешено
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type неизвестный тип
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} использование|{n} использования|{n} использований
|
||||
substituted: shown in {family} {style} ({detail}) заменен: показан шрифтом {family} {style} ({detail})
|
||||
missing: shown in {family} {style} отсутствует: показан шрифтом {family} {style}
|
||||
missing отсутствует
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2267,6 +2267,9 @@ font-technology Variable Variabla
|
||||
embedding for preview and print inbäddning för förhandsvisning och utskrift
|
||||
embedding allowed inbäddning tillåten
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type okänd typ
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} användning|{n} användningar
|
||||
substituted: shown in {family} {style} ({detail}) ersatt: visas med {family} {style} ({detail})
|
||||
missing: shown in {family} {style} saknas: visas med {family} {style}
|
||||
missing saknas
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -833,11 +833,13 @@ fn document_info_labels_are_in_complete_catalogs() {
|
||||
|
||||
/// The values Document Info makes and shows in the interface language: the font states and
|
||||
/// embedding permissions, the templates of the font, image, raster effects and Repeat object
|
||||
/// values, the names of gradients named by their kind, the counted instances, rows and columns, and
|
||||
/// the transparency settings' values.
|
||||
/// values, the names of gradients named by their kind, the counted uses, instances, rows and
|
||||
/// columns, and the transparency settings' values.
|
||||
#[test]
|
||||
fn document_info_values_are_in_complete_catalogs() {
|
||||
const VALUES: [&str; 20] = [
|
||||
const VALUES: [&str; 22] = [
|
||||
"unknown type",
|
||||
"{type}; {uses}",
|
||||
"built in",
|
||||
"embedding not allowed",
|
||||
"embedding for editing",
|
||||
@@ -859,7 +861,8 @@ fn document_info_values_are_in_complete_catalogs() {
|
||||
"Diamond gradient",
|
||||
"Freeform gradient",
|
||||
];
|
||||
const COUNTED: [(&str, &str); 3] = [("{n} instance", "{n} instances"), ("{n} row", "{n} rows"), ("{n} column", "{n} columns")];
|
||||
const COUNTED: [(&str, &str); 4] =
|
||||
[("{n} use", "{n} uses"), ("{n} instance", "{n} instances"), ("{n} row", "{n} rows"), ("{n} column", "{n} columns")];
|
||||
// The transparency settings' values: the grid's sizes and color presets, on and off, and the
|
||||
// built-in flattener presets.
|
||||
let transparency = ["Small", "Medium", "Large", "On", "Off", "High Resolution", "Medium Resolution", "Low Resolution"]
|
||||
|
||||
@@ -6811,6 +6811,9 @@ theme Appearance Görünüm
|
||||
embedding for preview and print önizleme ve yazdırma için gömme
|
||||
embedding allowed gömmeye izin veriliyor
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type bilinmeyen tür
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} kullanım
|
||||
substituted: shown in {family} {style} ({detail}) yerine konan: {family} {style} ile gösteriliyor ({detail})
|
||||
missing: shown in {family} {style} eksik: {family} {style} ile gösteriliyor
|
||||
missing eksik
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2373,6 +2373,9 @@ file-filter Templates Шаблони
|
||||
embedding for preview and print вбудовування для перегляду й друку
|
||||
embedding allowed вбудовування дозволено
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type невідомий тип
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} використання|{n} використання|{n} використань
|
||||
substituted: shown in {family} {style} ({detail}) замінено: показано шрифтом {family} {style} ({detail})
|
||||
missing: shown in {family} {style} відсутній: показано шрифтом {family} {style}
|
||||
missing відсутній
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2996,6 +2996,9 @@ digits Hindi Hindi
|
||||
embedding for preview and print nhúng để xem trước và in
|
||||
embedding allowed cho phép nhúng
|
||||
{file}; {embedding} {file}; {embedding}
|
||||
unknown type loại không xác định
|
||||
{type}; {uses} {type}; {uses}
|
||||
@plural {n} use|{n} uses {n} lần dùng
|
||||
substituted: shown in {family} {style} ({detail}) đã thay thế: hiển thị bằng {family} {style} ({detail})
|
||||
missing: shown in {family} {style} thiếu: hiển thị bằng {family} {style}
|
||||
missing thiếu
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2236,6 +2236,9 @@ file-filter Templates 模板
|
||||
embedding for preview and print 允许嵌入以供预览和打印
|
||||
embedding allowed 允许嵌入
|
||||
{file}; {embedding} {file};{embedding}
|
||||
unknown type 未知类型
|
||||
{type}; {uses} {type};{uses}
|
||||
@plural {n} use|{n} uses 使用 {n} 次
|
||||
substituted: shown in {family} {style} ({detail}) 已替换:以 {family} {style} 显示 ({detail})
|
||||
missing: shown in {family} {style} 缺失:以 {family} {style} 显示
|
||||
missing 缺失
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3573,6 +3573,9 @@ liquify-list-end {0}, {1} {0}和{1}
|
||||
embedding for preview and print 允許內嵌以供預覽和列印
|
||||
embedding allowed 允許內嵌
|
||||
{file}; {embedding} {file};{embedding}
|
||||
unknown type 未知類型
|
||||
{type}; {uses} {type};{uses}
|
||||
@plural {n} use|{n} uses 使用 {n} 次
|
||||
substituted: shown in {family} {style} ({detail}) 已替代:以 {family} {style} 顯示 ({detail})
|
||||
missing: shown in {family} {style} 遺失:以 {family} {style} 顯示
|
||||
missing 遺失
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -107,7 +107,7 @@ fn brush_value(value: &str) -> &str {
|
||||
/// Row `k` of Document Info section `id` (`label` and `value` as `document.info` gives them, the
|
||||
/// label a name when `named`) with its value in the interface language, built from what
|
||||
/// `document.info` (`info`) gives as values: the
|
||||
/// units, the raster effects resolution, each brush's type, each font's file, match and
|
||||
/// units, the raster effects resolution, each brush's type, each font's type and uses, each font's file, match and
|
||||
/// embedding permission, each image's size and file, each Repeat object's kind and counts, and the
|
||||
/// kinds of the gradients no swatch names. Names (fonts, files, faces, swatches) stay as they are.
|
||||
/// None when the row's value is shown as `document.info` gives it, or the values do not match the
|
||||
@@ -130,6 +130,7 @@ fn shown_value(info: &Value, id: &str, k: usize, (label, value): (&str, &str), n
|
||||
_ => None,
|
||||
},
|
||||
"brushes" => Some(brush_value(value).to_string()),
|
||||
"fonts" => font_use_value(entry("fontUses")?),
|
||||
"fontDetails" => font_detail_value(entry("fontDetails")?),
|
||||
"linkedImages" | "embeddedImages" => {
|
||||
let linked = id == "linkedImages";
|
||||
@@ -181,6 +182,19 @@ fn fill(template: &str, args: &[(&str, &str)]) -> String {
|
||||
crate::i18n::fill_once(template, args)
|
||||
}
|
||||
|
||||
/// A `fontUses` entry as Fonts shows it: the font's type (the format names TrueType and OpenType
|
||||
/// stay as they are) and its number of uses in the language's plural forms.
|
||||
fn font_use_value(e: &Value) -> Option<String> {
|
||||
let kind = match e["type"].as_str()? {
|
||||
"truetype" => "TrueType",
|
||||
"opentype" => "OpenType",
|
||||
"unknown" => tl!("unknown type"),
|
||||
_ => return None,
|
||||
};
|
||||
let uses = crate::i18n::tn(e["uses"].as_u64()?, "{n} use", "{n} uses");
|
||||
Some(fill(tl!("{type}; {uses}"), &[("type", kind), ("uses", &uses)]))
|
||||
}
|
||||
|
||||
/// A `fontDetails` entry as Font Details shows it: the font's file (or that it is built in) and
|
||||
/// what its license allows, the face shown in place of a style the family lacks, the face shown in
|
||||
/// place of a font that is not installed, or that it is missing.
|
||||
@@ -456,7 +470,7 @@ mod tests {
|
||||
assert!(objects.contains("\nOBJECTS\n") && objects.contains("Paths: 1") && objects.contains("Text Objects: 1"), "{objects}");
|
||||
assert!(!objects.contains("\nDOCUMENT\n") && !objects.contains("\nFONTS\n"), "only Objects: {objects}");
|
||||
let fonts = saved_from_menu(&mut app, "fonts", false);
|
||||
assert!(fonts.contains("\nFONTS\n") && fonts.contains("Source Sans 3"), "{fonts}");
|
||||
assert!(fonts.contains("\nFONTS\nSource Sans 3 Regular: TrueType; 1 use\n"), "{fonts}");
|
||||
assert!(!fonts.contains("\nOBJECTS\n") && !fonts.contains("\nFONT DETAILS\n"), "only Fonts: {fonts}");
|
||||
let all = saved_from_menu(&mut app, "", false);
|
||||
assert!(
|
||||
@@ -593,6 +607,49 @@ mod tests {
|
||||
assert!(report.contains("Units: Millimeters\n") && report.contains("Radial Repeat, 6 instances"), "{report}");
|
||||
}
|
||||
|
||||
/// Fonts shows each font's type and number of uses in the interface language, in the
|
||||
/// language's plural forms; the format names TrueType and OpenType and the font names stay as
|
||||
/// they are, and `document.info` and the saved report keep the English values.
|
||||
#[test]
|
||||
fn font_types_and_uses_show_in_the_interface_language() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
app.session.execute("text.create", &json!({"x": 10, "y": 20, "text": "Hi"})).unwrap();
|
||||
app.session.execute("text.create", &json!({"x": 10, "y": 50, "text": "Hi"})).unwrap();
|
||||
app.session.execute("text.create", &json!({"x": 10, "y": 80, "text": "Gone", "font": "Qx Absent Family"})).unwrap();
|
||||
let info = app.session.execute("document.info", &json!({})).unwrap();
|
||||
let rows = |info: &Value| shown_rows(info, "fonts");
|
||||
let english = vec![
|
||||
("Qx Absent Family Regular".to_string(), "unknown type; 1 use".to_string()),
|
||||
("Source Sans 3 Regular".into(), "TrueType; 2 uses".into()),
|
||||
];
|
||||
assert_eq!(rows(&info), english);
|
||||
let fonts = |app: &mut VectorcraftApp| {
|
||||
crate::tests_labels::painted_text(app, |app, ui| {
|
||||
set_pstate(ui.ctx(), "docinfo-category", "fonts".to_string());
|
||||
show(app, ui);
|
||||
})
|
||||
};
|
||||
let Some(de) = crate::i18n::Lang::from_code("de") else { panic!("no German catalog") };
|
||||
crate::i18n::set_current(de);
|
||||
let (german, painted) = (rows(&info), fonts(&mut app));
|
||||
let one_opentype = font_use_value(&json!({"type": "opentype", "uses": 1}));
|
||||
let Some(ru) = crate::i18n::Lang::from_code("ru") else { panic!("no Russian catalog") };
|
||||
crate::i18n::set_current(ru);
|
||||
let russian = [1, 3, 5].map(|n| font_use_value(&json!({"type": "truetype", "uses": n})));
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
assert_eq!(german[0], ("Qx Absent Family Regular".to_string(), "unbekannter Typ; 1 Verwendung".to_string()));
|
||||
assert_eq!(german[1], ("Source Sans 3 Regular".to_string(), "TrueType; 2 Verwendungen".to_string()));
|
||||
assert!(painted.contains("Source Sans 3 Regular") && painted.contains("TrueType; 2 Verwendungen"), "{painted}");
|
||||
assert_eq!(one_opentype.as_deref(), Some("OpenType; 1 Verwendung"));
|
||||
assert_eq!(russian.map(Option::unwrap_or_default), ["TrueType; 1 использование", "TrueType; 3 использования", "TrueType; 5 использований"]);
|
||||
// An unknown type id is shown as `document.info` gives the row.
|
||||
assert_eq!(font_use_value(&json!({"type": "bitmap", "uses": 1})), None);
|
||||
let report =
|
||||
app.session.execute("document.info", &json!({"category": "fonts", "format": "text"})).unwrap()["text"].as_str().unwrap().to_string();
|
||||
assert!(report.contains("Source Sans 3 Regular: TrueType; 2 uses\n"), "{report}");
|
||||
}
|
||||
|
||||
/// Document shows the transparency settings with their values in the interface language (two
|
||||
/// custom grid colors as they are), and while the Artboard tool is the current tool the
|
||||
/// artboards it has selected, following its selection without an edit to the document.
|
||||
|
||||
+8
-3
@@ -9038,9 +9038,14 @@ result carries the same files as a zip (`{name: "<name>.zip", dataBase64}`, entr
|
||||
`document.info {selectionOnly?, category?, format?: "text"}` adds `sections` (`[{id, title, rows: [[label, value]]}]`:
|
||||
document, objects, graphicStyles, brushes, spotColors, patterns, gradients, symbols, fonts, fontDetails, linkedImages,
|
||||
embeddedImages, repeats), `fonts` (the fonts the document's type uses, the type in opacity masks and in the art of
|
||||
its symbols and pattern swatches included, which the fonts and fontDetails categories list; with `selectionOnly`, the
|
||||
fonts of the selected type), `fontDetails` (`[{font, match, family, style, file, embedding}]`: each font of `fonts`,
|
||||
in order, as the fontDetails category's rows give it: `match` is `exact`, `style` (a style the family lacks, shown in
|
||||
its symbols and pattern swatches included, type in a composite font giving the fonts of the parts its characters fall
|
||||
in, which the fonts and fontDetails categories list; with `selectionOnly`, the fonts of the selected type),
|
||||
`fontUses` (`[{font, type, uses}]`: each font of `fonts`, in order, as the fonts
|
||||
category's rows give it, such as `TrueType; 2 uses`: `type` is `truetype` or `opentype` by the outlines of the face
|
||||
the type is drawn in (`glyf`, or `CFF` or `CFF2`), `unknown` for a font not installed in the family and style it
|
||||
names; `uses` is the number of text objects set in the font, each counted once however many of its runs use it, the
|
||||
type in a mask or in a symbol's or pattern's art once however many objects show it), `fontDetails`
|
||||
(`[{font, match, family, style, file, embedding}]`: each font of `fonts`, in order, as the fontDetails category's rows give it: `match` is `exact`, `style` (a style the family lacks, shown in
|
||||
`family` `style`), `missingWithFallback` (not installed, shown in `family` `style`) or `missing`; `file` is the face's
|
||||
file name, null for a built-in face; `embedding` is `allowed`, `editing`, `previewPrint` or `forbidden`, null when no
|
||||
face is found), `imageObjects` (`[{name, width, height, linked, file}]`: the image objects in the order the
|
||||
|
||||
@@ -1900,6 +1900,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
In the Brushes panel, Shift-click selects a range of brushes and Ctrl/Cmd-click adds or removes one. Delete Brush and Duplicate Brush then act on all of them (`brush.delete {names}`, `brush.duplicate {names}`).
|
||||
The Brushes panel's Delete Brush button and panel menu item ask "Delete the selected brushes?" with Yes and No when none of the brushes is in use. Alt-click (Option-click on macOS) on the button deletes them without asking, as the [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists for panel deletion outside the Layers panel (archived copy). When a stroke uses one of the brushes, the button, Alt-click and the menu item all ask with Remove Strokes and Cancel; Remove Strokes deletes the brushes and the strokes that used them become plain strokes. Tests: `panels::brushes::tests`, `dialogs::brush_delete::tests`.
|
||||
Document Info has a Brushes category after Graphic Styles. It lists the names and types of the brushes applied to the artwork, as the [Document Info panel](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) page describes, or with Selection Only the brushes that the selected objects' strokes use. The Document Info report and Package's report list them too (`document.info {category: "brushes"}`, `brushNames`, `brushes`). Listing each brush once, leaving out the Brushes panel's brushes no art uses (`panelBrushNames` lists the panel's brushes), hidden strokes, strokes at an opacity of 0, strokes with no paint or width, guides, paths with no segment, type that draws no characters, a group's or layer's own strokes, a compound path member's own strokes and an image's strokes without a shape, and listing a brush the panel does not hold as missing, are VectorCraft's own rules. Tests: `cmd::docinfo::tests::info_lists_the_brushes` and `info_brushes_skip_undrawn_strokes_and_name_missing_brushes` (vectorcraft-engine).
|
||||
Document Info's Fonts category gives each font's type and number of uses beside its name, as the [help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) describes, for the whole document or with Selection Only for the selected type. The Document Info report and Package's report give them too (`document.info {category: "fonts"}`, `fontUses`), and the panel shows the type and count in the interface language. Counting a use as a text object set in the font (once however many of its runs use it, and the type in a mask or in a symbol's or pattern's art once however many objects show it), naming the type by the face's outlines (TrueType for `glyf`, OpenType for `CFF` or `CFF2`) and showing an unknown type for a font that is not installed in the family and style the type names are VectorCraft's own rules. Tests: `cmd::docinfo::tests::info_fonts_give_each_font_s_type_and_uses` (vectorcraft-engine), `panels::doc_info::tests::font_types_and_uses_show_in_the_interface_language` (vectorcraft-ui-egui), `fontdb::face::tests::outline_format_follows_the_outline_tables` (vectorcraft-text).
|
||||
Document Info has a Repeat Objects category after Embedded Images. It lists each radial, grid and mirror Repeat object by name with its kind and the number of instances it makes. For a grid it gives the rows and columns instead, followed by the number of instances it draws when that is fewer. With Selection Only it lists the Repeat objects in the selection. The Document Info report and Package's report list them too (`document.info {category: "repeats"}`, `repeatObjects`).
|
||||
Document Info's Pattern Objects category lists the objects whose fill or stroke is a pattern, the category the [Document Info panel](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) page describes, each by name with the patterns it uses. With Selection Only it lists those in the selection, and the Document Info report and Package's report list them too (`document.info {category: "patterns"}`, `patternObjects`). Listing an object with a pattern fill and a pattern stroke once, listing objects inside groups and type objects whose characters use a pattern, and leaving out hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, a compound path member's own fills and strokes, an image's fills and strokes without a shape, characters the type does not draw and patterns no art uses, and counting the listed objects in Objects, are VectorCraft's own rules. Test: `cmd::docinfo::tests::info_lists_the_pattern_objects` (vectorcraft-engine).
|
||||
Document Info's Gradient Objects category lists the objects whose fill or stroke is a gradient, the category the [Document Info panel](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) page describes as the count of objects with gradient fills or strokes. Each object is listed by name with the gradients it uses. With Selection Only it lists those in the selection, and the Document Info report and Package's report list them too (`document.info {category: "gradients"}`, `gradientObjects`). Naming a linked gradient by its swatch and any other gradient by its kind, and leaving out paint that draws nothing by the rules Pattern Objects follows, gradient swatches no art uses, gradient meshes and gradients drawn by effects, are VectorCraft's own rules. Objects counts the listed objects as Gradient Objects. Test: `cmd::docinfo::tests::info_lists_the_gradient_objects` (vectorcraft-engine).
|
||||
|
||||
Reference in new issue
Block a user