Merge pull request #7974 from dotCooCoo/feat/composite-font-sample

Type: Composite Fonts' Show Sample draws the font picked with its metric lines
This commit is contained in:
BFlat
2026-11-16 10:36:14 +07:00
committed by GitHub
36 changed files with 741 additions and 9 deletions
+5
View File
@@ -356,6 +356,11 @@ impl FontFace {
pub fn x_height(&self) -> f64 {
self.x_height
}
/// The height of the capital letters in font units, positive (estimated from the ascent when
/// the font has no OS/2 value).
pub fn cap_height(&self) -> f64 {
self.cap_height
}
/// The line gap the font asks for between lines, in font units (from the same table as
/// [`vertical_metrics`](Self::vertical_metrics); 0 when it has none).
pub fn line_gap(&self) -> f64 {
+5 -1
View File
@@ -654,12 +654,16 @@ pub(crate) fn parent(d: &Dialog) -> Option<Dialog> {
/// `ui.dialog.set` changed `field` of the open dialog from `old`: a choice that sets other fields
/// sets them as choosing it in the dialog does (Export for Screens' `exportPreset`), a change
/// to Export for Screens' sub-folder controls ends an applied preset's item folders, as it does in
/// the dialog, and Transform Each's Relative / Absolute keeps the Scale fields' size.
/// the dialog, and Transform Each's Relative / Absolute keeps the Scale fields' size. A value
/// Composite Fonts' Show Sample can't take is refused.
pub(crate) fn field_set(app: &mut VectorcraftApp, field: &str, old: Option<&Value>) -> Result<(), String> {
if app.ui.dialog.as_ref().is_some_and(|d| d.kind == transform_each::KIND) {
transform_each::field_set(app, field, old);
return Ok(());
}
if let Some(d) = app.ui.dialog.as_ref().filter(|d| d.kind == composite_fonts::KIND) {
return composite_fonts::field_set(d, field);
}
let Some(d) = app.ui.dialog.as_mut().filter(|d| d.kind == export_for_screens::KIND) else { return Ok(()) };
match field {
"exportPreset" => export_for_screens::preset_set(app),
+30 -4
View File
@@ -5,14 +5,17 @@
//! out, Import… adds the fonts of a file and Export… writes the one picked to a file. Custom shows
//! the custom character sets of the font picked: New adds a set based on the one picked, Delete Set
//! takes it out, and Add puts the characters typed (Direct Entry) or the character of a Unicode code
//! into it; Delete takes the character picked out. Nothing changes in the document until OK, which
//! into it; Delete takes the character picked out. Show Sample draws a sample of the font picked
//! with lines that mark its metrics ([`sample`]). Nothing changes in the document until OK, which
//! runs `type.compositeFonts.set` with every font as one undo step; Cancel leaves them as they were.
//!
//! Fields: `fonts` (the composite fonts as `type.compositeFonts.set` takes them), `selected` (the
//! index of the one picked) and `name` (its name as typed); `custom` (whether the custom character
//! sets show), `set` (the index of the set picked), `setName` (its name as typed), `entryMode`
//! (`direct` or `unicode`), `entry` (the characters or code typed) and `char` (the index of the
//! character picked in the set).
//! character picked in the set); `sample` (whether the sample shows), `zoom` (its magnification in
//! percent) and `lineIcfBox`, `lineEmBox`, `lineBaseline`, `lineCapHeight`, `lineAscentDescent`,
//! `lineAscender` and `lineXHeight` (whether each of its lines shows).
//!
//! Behavior reference (public documentation):
//! <https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=347>,
@@ -29,6 +32,8 @@ use crate::picks::PickRequest;
use crate::state::Dialog;
use crate::{FilePick, VectorcraftApp, widgets};
mod sample;
/// The dialog kind of Composite Fonts.
pub const KIND: &str = "compositeFonts";
@@ -53,15 +58,22 @@ pub(super) const SPEC: DialogSpec = DialogSpec {
};
/// Open Composite Fonts on the active document's composite fonts, the first one picked, with the
/// custom character sets hidden and nothing typed.
/// custom character sets and the sample hidden and nothing typed.
pub fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
let fonts = app.session.active().ok_or("no document open")?.doc.composite_fonts.to_vec();
let mut d = Dialog::new(KIND, json!({ "fonts": fonts, "selected": 0, "custom": false, "entryMode": "direct", "entry": "" }));
sample::defaults(&mut d.fields);
show_selected(&mut d);
app.ui.dialog = Some(d);
Ok(Value::Null)
}
/// Why `ui.dialog.set` can't set `field` of Composite Fonts `d` to the value it now holds (Show
/// Sample's fields, [`sample::check_field`]).
pub(super) fn field_set(d: &Dialog, field: &str) -> Result<(), String> {
sample::check_field(d, field)
}
/// The fonts the dialog holds.
fn fonts(d: &Dialog) -> Vec<CompositeFont> {
d.fields.get("fonts").and_then(|v| serde_json::from_value(v.clone()).ok()).unwrap_or_default()
@@ -138,6 +150,8 @@ enum Action {
Export,
/// Custom: show or hide the custom character sets.
Custom,
/// Show Sample or Hide Sample.
Sample,
NewSet,
DeleteSet,
/// Add the characters typed, or the character of the code typed, to the set picked.
@@ -178,6 +192,10 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
if ui.add_enabled_ui(!list.is_empty(), |ui| widgets::flat_button(ui, tl!("Custom"), 64.0)).inner.clicked() {
act = Some(Action::Custom);
}
let label = if d.bool("sample") { tl!("Hide Sample") } else { tl!("Show Sample") };
if ui.add_enabled_ui(!list.is_empty(), |ui| widgets::flat_button(ui, label, 96.0)).inner.clicked() {
act = Some(Action::Sample);
}
});
if let Some(k) = picked {
select(d, k);
@@ -192,6 +210,10 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
f.name = d.str("name");
ui.add_space(8.0);
parts_table(app, ui, f);
if d.bool("sample") {
ui.add_space(8.0);
sample::show(ui, d, f);
}
if d.bool("custom") {
ui.add_space(8.0);
ui.separator();
@@ -319,6 +341,10 @@ fn run(app: &mut VectorcraftApp, d: &mut Dialog, act: Action) -> Result<(), Stri
let open = !d.bool("custom");
d.fields.insert("custom".into(), json!(open));
}
Action::Sample => {
let open = !d.bool("sample");
d.fields.insert("sample".into(), json!(open));
}
Action::NewSet | Action::DeleteSet | Action::AddChars | Action::DeleteChar => {
let f = list.get_mut(i).ok_or("no composite font")?;
let at = edit_sets(d, f, act)?;
@@ -389,7 +415,7 @@ fn edit_sets(d: &mut Dialog, f: &mut CompositeFont, act: Action) -> Result<Optio
d.fields.remove("char");
Ok(None)
}
Action::New | Action::Delete | Action::Import | Action::Export | Action::Custom => Ok(None),
Action::New | Action::Delete | Action::Import | Action::Export | Action::Custom | Action::Sample => Ok(None),
}
}
@@ -0,0 +1,384 @@
//! Show Sample in Composite Fonts: the font picked set in a line of sample text, with lines that
//! mark its ICF box, em box, baseline, cap height, highest ascent and lowest descent, highest
//! ascender and x-height, each shown or hidden by its button, at the size Zoom picks.
//!
//! The sample text, the zoom steps, the size at 100% and what each line measures are VectorCraft's
//! own: the em box and ICF box are those of the face of the part that sets the sample's first Kanji
//! (the Kanji part, or a custom set that holds that character)
//! ([`vectorcraft_text::FontFace::ideographic_centre`], [`vectorcraft_text::FontFace::icf_margins`]),
//! the cap height and x-height those of the face the Roman letters are drawn in, Max Ascent/Descent
//! the highest ascent and lowest descent among the faces the sample is drawn in (fallback faces
//! included), and Max Ascender the top of the sample's tallest glyph. Each takes its part's size,
//! baseline and vertical scale.
//!
//! Behavior reference (public documentation):
//! <https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=352>,
//! <https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=348>.
use std::hash::{DefaultHasher, Hash, Hasher};
use egui::{Color32, Rect, Sense, Stroke, Ui, vec2};
use serde_json::{Value, json};
use vectorcraft_doc::{CharClass, CharStyle, CompositeClass, CompositeFont, FontHeightReference, TextObject};
use vectorcraft_geom::kurbo::BezPath;
use vectorcraft_geom::{Affine, Point};
use vectorcraft_text::FontDb;
use crate::state::Dialog;
use crate::widgets;
/// The text the sample sets: two Kanji, two kana, two punctuation marks, a symbol, Roman letters
/// with an ascender and a descender, and two numerals, then the first character of each custom set.
pub(super) const TEXT: &str = "永国あア、。※Agh12";
/// The Zoom menu's magnifications, in percent.
pub(super) const ZOOMS: [u64; 7] = [25, 50, 75, 100, 200, 400, 800];
/// The size the sample is set at with Zoom at 100%, in points.
const SIZE: f64 = 36.0;
/// How tall the sample is drawn, in points.
const HEIGHT: f32 = 150.0;
/// How far the sample text starts from the left edge, in points.
const INSET: f64 = 12.0;
/// The width of the column of line buttons and Zoom beside the sample, in points.
const BUTTONS: f32 = 190.0;
/// The narrowest and widest the sample is drawn, in points.
const WIDTH: std::ops::RangeInclusive<f32> = 240.0..=720.0;
/// The name the sample lends the font under, so a name that is empty, being typed or shared with
/// another font still draws.
const NAME: &str = "VectorCraft Composite Sample";
/// A line Show Sample can mark.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum Mark {
IcfBox,
EmBox,
Baseline,
CapHeight,
AscentDescent,
Ascender,
XHeight,
}
impl Mark {
/// The marks, in the order their buttons show.
pub(super) const ALL: [Self; 7] =
[Self::IcfBox, Self::EmBox, Self::Baseline, Self::CapHeight, Self::AscentDescent, Self::Ascender, Self::XHeight];
/// The dialog field that holds whether the mark shows.
pub(super) fn field(self) -> &'static str {
match self {
Self::IcfBox => "lineIcfBox",
Self::EmBox => "lineEmBox",
Self::Baseline => "lineBaseline",
Self::CapHeight => "lineCapHeight",
Self::AscentDescent => "lineAscentDescent",
Self::Ascender => "lineAscender",
Self::XHeight => "lineXHeight",
}
}
fn label(self) -> &'static str {
match self {
Self::IcfBox => tl!("ICF Box"),
Self::EmBox => tl!("Em Box"),
Self::Baseline => tl!("Baseline"),
Self::CapHeight => tl!("Cap Height"),
Self::AscentDescent => tl!("Max Ascent/Descent"),
Self::Ascender => tl!("Max Ascender"),
Self::XHeight => tl!("x-height"),
}
}
/// Shown when the dialog opens: the em box, the ICF box and the baseline.
pub(super) fn shown_at_first(self) -> bool {
matches!(self, Self::IcfBox | Self::EmBox | Self::Baseline)
}
fn color(self) -> Color32 {
match self {
Self::IcfBox => Color32::from_rgb(0, 150, 170),
Self::EmBox => Color32::from_rgb(220, 60, 60),
Self::Baseline => Color32::from_rgb(40, 110, 230),
Self::CapHeight => Color32::from_rgb(40, 160, 70),
Self::AscentDescent => Color32::from_rgb(230, 140, 30),
Self::Ascender => Color32::from_rgb(150, 80, 200),
Self::XHeight => Color32::from_rgb(200, 60, 160),
}
}
}
/// The fields Show Sample adds to the dialog when it opens: hidden, at 100%, with the marks of
/// [`Mark::shown_at_first`].
pub(super) fn defaults(fields: &mut serde_json::Map<String, Value>) {
fields.insert("sample".into(), json!(false));
fields.insert("zoom".into(), json!(100));
for m in Mark::ALL {
fields.insert(m.field().into(), json!(m.shown_at_first()));
}
}
/// Why `ui.dialog.set` can't set Show Sample's `field` to the value `d` now holds: `sample` and the
/// marks take true or false, and `zoom` one of [`ZOOMS`].
pub(super) fn check_field(d: &Dialog, field: &str) -> Result<(), String> {
let v = d.fields.get(field);
let key = field;
if field == "sample" || Mark::ALL.iter().any(|m| m.field() == field) {
if !v.is_some_and(Value::is_boolean) {
return Err(format!("`{key}` must be true or false"));
}
} else if field == "zoom" && !v.and_then(Value::as_u64).is_some_and(|z| ZOOMS.contains(&z)) {
return Err(format!("`{key}` must be one of {}", ZOOMS.map(|z| z.to_string()).join(", ")));
}
Ok(())
}
/// The Zoom `d` holds, 100 when it holds none of [`ZOOMS`].
fn zoom(d: &Dialog) -> u64 {
d.fields.get("zoom").and_then(Value::as_u64).filter(|z| ZOOMS.contains(z)).unwrap_or(100)
}
/// The heights the marks are drawn at, in points above the baseline (a mark's line is not drawn
/// when its height is `None`). The baseline is at 0.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub(super) struct Heights {
/// The em box's bottom and top.
pub em_box: Option<(f64, f64)>,
/// The ICF box's bottom and top.
pub icf_box: Option<(f64, f64)>,
pub cap_height: Option<f64>,
pub x_height: Option<f64>,
/// The lowest descent and the highest ascent.
pub ascent_descent: Option<(f64, f64)>,
/// The top of the tallest glyph.
pub ascender: Option<f64>,
}
impl Heights {
/// The heights of mark `m`.
fn of(&self, m: Mark) -> Vec<f64> {
let pair = |p: Option<(f64, f64)>| p.map_or_else(Vec::new, |(a, b)| vec![a, b]);
match m {
Mark::IcfBox => pair(self.icf_box),
Mark::EmBox => pair(self.em_box),
Mark::Baseline => vec![0.0],
Mark::CapHeight => self.cap_height.into_iter().collect(),
Mark::AscentDescent => pair(self.ascent_descent),
Mark::Ascender => self.ascender.into_iter().collect(),
Mark::XHeight => self.x_height.into_iter().collect(),
}
}
}
/// `f` as the sample sets it: named [`NAME`], without its custom sets when one of them can't be
/// used (a set whose name is empty or shared while it is typed).
fn sample_font(f: &CompositeFont) -> CompositeFont {
let mut s = f.clone();
s.name = NAME.to_string();
if s.check().is_err() {
s.custom.clear();
}
s
}
/// [`TEXT`], then the first character of each of `f`'s custom sets that it does not hold yet.
pub(super) fn text(f: &CompositeFont) -> String {
let mut t = TEXT.to_string();
for c in f.custom.iter().filter_map(|s| s.characters.chars().next()) {
if !t.contains(c) {
t.push(c);
}
}
t
}
/// The outlines of the sample of `f` set at `size` points with its baseline at y 0 (y down), and
/// the heights of its marks.
pub(super) fn measure(f: &CompositeFont, size: f64) -> (BezPath, Heights) {
let db = FontDb::global();
let font = sample_font(f);
let _lent = db.lend_composite_fonts(std::slice::from_ref(&font));
let text = text(&font);
let style = CharStyle { font_family: NAME.to_string(), size, ..Default::default() };
let layout = vectorcraft_text::layout(db, &TextObject::point(Point::ZERO, &text, style));
let path = layout.to_bezpath();
let classes = font.classes();
// The face of character `c`'s part, the face layout draws it in (a fallback face when the part's
// font lacks it), the size of its em and the shift of its baseline (points), and its part's
// vertical scale, as layout sets them: Kana scaled at center keep the middle of their part's em
// box where it is.
let placed = |c: char| {
let (part_face, _) = db.composite_resolve(NAME, c)?;
let drawn = text.find(c).and_then(|at| layout.glyphs.iter().find(|g| g.byte == at)).and_then(|g| db.face_by_id(g.font_id));
let class = classes.of(c);
let p = font.part(class).unwrap_or(&font.parts.kanji);
let em = size * p.size / 100.0;
let mut shift = size * p.baseline / 100.0;
if class == CompositeClass::Fixed(CharClass::Kana) && p.scale_at_center && p.v_scale != 100.0 {
shift += em * part_face.ideographic_centre() * (1.0 - p.v_scale / 100.0);
}
let drawn = drawn.unwrap_or_else(|| part_face.clone());
Some((part_face, drawn, em, shift, p.v_scale / 100.0))
};
let mut h = Heights::default();
// The em box and ICF box are those of the part that sets the sample's first Kanji (the Kanji
// part, or a custom set that holds that character), as layout measures that part's face for
// Scale at Center.
if let Some((face, _, em, shift, v)) = TEXT.chars().next().and_then(placed) {
let tall = em * v;
let mid = shift + face.ideographic_centre() * tall;
let (bottom, top) = (mid - tall * 0.5, mid + tall * 0.5);
let m = face.icf_margins();
h.em_box = Some((bottom, top));
h.icf_box = Some((bottom + m.bottom * tall, top - m.top * tall));
}
if let Some((_, face, em, shift, v)) = placed('A') {
let height = |r| face.font_height(r, false);
let cap = height(FontHeightReference::CapHeight).unwrap_or_else(|| face.cap_height() / face.units_per_em());
h.cap_height = Some(shift + cap * em * v);
let x = height(FontHeightReference::XHeight).unwrap_or_else(|| face.x_height() / face.units_per_em());
h.x_height = Some(shift + x * em * v);
}
let mut seen = Vec::new();
for c in text.chars().filter(|c| !c.is_whitespace()) {
let Some((_, face, em, shift, v)) = placed(c) else { continue };
if seen.contains(&(face.id(), em.to_bits(), shift.to_bits(), v.to_bits())) {
continue;
}
seen.push((face.id(), em.to_bits(), shift.to_bits(), v.to_bits()));
let (ascent, descent) = face.vertical_metrics();
let scale = em * v / face.units_per_em();
let (low, high) = (shift - descent * scale, shift + ascent * scale);
h.ascent_descent = Some(h.ascent_descent.map_or((low, high), |(l, t)| (l.min(low), t.max(high))));
}
// Outlines, color glyphs and bitmap glyphs alike.
h.ascender = layout.ink_bounds().filter(|ink| ink.height() > 0.0).map(|ink| -ink.y0);
(path, h)
}
/// The sample drawn for a key, kept until the font, zoom, size, display scale, text color or the
/// fonts installed change.
struct Drawn {
key: u64,
texture: Option<egui::TextureHandle>,
heights: Heights,
}
thread_local! {
static DRAWN: crate::graphics::TexCache<Option<Drawn>> = crate::graphics::TexCache::default();
static RENDERER: std::cell::RefCell<vectorcraft_render::Renderer> = std::cell::RefCell::new(vectorcraft_render::Renderer::new());
}
/// Show Sample's area under the table: the sample of `f` with its marks, then the mark buttons and
/// Zoom beside it.
pub(super) fn show(ui: &mut Ui, d: &mut Dialog, f: &CompositeFont) {
let zoom = zoom(d);
ui.horizontal(|ui| {
let width = (ui.available_width() - BUTTONS).clamp(*WIDTH.start(), *WIDTH.end());
let (rect, _) = ui.allocate_exact_size(vec2(width, HEIGHT), Sense::hover());
paint(ui, rect, d, f, zoom);
ui.vertical(|ui| {
ui.spacing_mut().item_spacing.y = 2.0;
for m in Mark::ALL {
let on = d.bool(m.field());
ui.horizontal(|ui| {
let (swatch, _) = ui.allocate_exact_size(vec2(10.0, 10.0), Sense::hover());
ui.painter().rect_filled(swatch, 1.0, m.color());
if ui.add(egui::Button::selectable(on, m.label())).clicked() {
d.fields.insert(m.field().into(), json!(!on));
}
});
}
ui.add_space(4.0);
ui.horizontal(|ui| {
widgets::dim_label(ui, tl!("Zoom"));
let names: Vec<String> = ZOOMS.iter().map(|z| format!("{z}%")).collect();
let options: Vec<&str> = names.iter().map(String::as_str).collect();
let current = format!("{zoom}%");
if let Some(k) = widgets::dropdown(ui, "composite-fonts-zoom", &current, &options, 80.0)
&& let Some(z) = ZOOMS.get(k)
{
d.fields.insert("zoom".into(), json!(z));
}
});
});
});
}
/// Draw the sample of `f` at `zoom` percent into `rect`, its em box centered in it, with the marks
/// `d` shows.
fn paint(ui: &Ui, rect: Rect, d: &Dialog, f: &CompositeFont, zoom: u64) {
let painter = ui.painter_at(rect);
let visuals = ui.visuals();
painter.rect_filled(rect, 2.0, visuals.extreme_bg_color);
let ppp = ui.ctx().pixels_per_point();
let ink = visuals.text_color();
let mut h = DefaultHasher::new();
serde_json::to_string(f).unwrap_or_default().hash(&mut h);
(zoom, ppp.to_bits(), rect.width().to_bits(), rect.height().to_bits(), ink.to_array(), FontDb::global().generation()).hash(&mut h);
let key = h.finish();
let size = SIZE * zoom as f64 / 100.0;
let (texture, heights) = DRAWN.with(|cache| {
let mut cache = cache.borrow_mut();
if let Some(drawn) = cache.as_ref().filter(|c| c.key == key) {
return (drawn.texture.clone(), drawn.heights);
}
let (_, heights) = measure(f, size);
let texture = render(ui.ctx(), f, size, baseline(&heights, size, rect), rect, ppp, ink);
*cache = Some(Drawn { key, texture: texture.clone(), heights });
(texture, heights)
});
if let Some(t) = &texture {
painter.image(t.id(), rect, Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), Color32::WHITE);
}
let base = rect.top() + baseline(&heights, size, rect) as f32;
for m in Mark::ALL.into_iter().filter(|m| d.bool(m.field())) {
for y in heights.of(m) {
painter.hline(rect.x_range(), base - y as f32, Stroke::new(1.0, m.color()));
}
}
painter.rect_stroke(rect, 2.0, visuals.widgets.noninteractive.bg_stroke, egui::StrokeKind::Inside);
}
/// Where the baseline goes, in points down from the top of `rect`: the em box's middle (else
/// 0.38 em above the baseline) at the middle of `rect`.
fn baseline(h: &Heights, size: f64, rect: Rect) -> f64 {
let mid = h.em_box.map_or(size * 0.38, |(bottom, top)| (bottom + top) * 0.5);
f64::from(rect.height()) * 0.5 + mid
}
/// The sample of `f` drawn into a texture the size of `rect` in pixels ([`draw`]). `None` when
/// `rect` is empty or larger than the largest texture.
fn render(ctx: &egui::Context, f: &CompositeFont, size: f64, baseline: f64, rect: Rect, ppp: f32, ink: Color32) -> Option<egui::TextureHandle> {
let (w, h) = ((rect.width() * ppp).round(), (rect.height() * ppp).round());
let max = ctx.input(|i| i.max_texture_side) as f32;
if w < 1.0 || h < 1.0 || w > max || h > max || w > f32::from(u16::MAX) || h > f32::from(u16::MAX) {
return None;
}
let image = draw(f, size, baseline, (w as u16, h as u16), ppp, ink);
Some(ctx.load_texture("composite-font-sample", crate::canvas::color_image_owned(image), egui::TextureOptions::LINEAR))
}
/// The sample of `f` set at `size` points in `ink`, its baseline `baseline` points down from the
/// top, drawn by the renderer as the canvas draws type (color and bitmap glyphs in their own
/// colors) into `px` pixels at `ppp` pixels per point.
pub(super) fn draw(f: &CompositeFont, size: f64, baseline: f64, px: (u16, u16), ppp: f32, ink: Color32) -> vectorcraft_render::Rendered {
let (w, h) = px;
let mut doc = vectorcraft_doc::Document::new(f64::from(w) / f64::from(ppp), f64::from(h) / f64::from(ppp));
let font = sample_font(f);
let sample = text(&font);
*doc.composite_fonts = vec![font];
let [r, g, b, _] = ink.to_normalized_gamma_f32();
let fill = vectorcraft_color::Paint::solid(vectorcraft_color::Color::rgb(r, g, b));
let style = CharStyle { font_family: NAME.to_string(), size, fill, ..Default::default() };
let t = TextObject::point(Point::new(INSET, baseline), &sample, style);
let node = std::sync::Arc::new(vectorcraft_doc::Node::new(doc.alloc_id(), vectorcraft_doc::NodeKind::Text(Box::new(t))));
let view = Affine::scale(f64::from(ppp));
let empty = || vectorcraft_render::Rendered { width: u32::from(w), height: u32::from(h), pixels: vec![0; usize::from(w) * usize::from(h) * 4] };
RENDERER.with(|r| r.borrow_mut().render_node(&doc, &node, w, h, view)).unwrap_or_else(empty)
}
@@ -280,3 +280,193 @@ fn custom_sets_sharing_a_name_keep_the_dialog_open() {
assert!(app.ui.dialog.is_some());
assert!(names(&app).is_empty());
}
/// A composite font set in Inter, with its Roman part as `roman` changes it.
fn inter_font(roman: impl FnOnce(&mut vectorcraft_doc::CompositePart)) -> CompositeFont {
let mut parts = vectorcraft_doc::CompositeParts::all(vectorcraft_doc::CompositePart::new("Inter", "Regular"));
roman(&mut parts.roman);
CompositeFont { name: "UI Composite Sample".into(), parts, custom: Vec::new() }
}
/// Show Sample opens hidden at 100% with the ICF box, em box and baseline shown; its button shows
/// and hides the sample, which draws with every line shown and at every zoom; nothing changes in
/// the document.
#[test]
fn show_sample_shows_and_hides_the_sample() {
let mut app = app();
open(&mut app).unwrap();
let d = dialog(&mut app);
assert!(!d.bool("sample"));
assert_eq!(d.fields.get("zoom"), Some(&json!(100)));
let shown: Vec<bool> = sample::Mark::ALL.iter().map(|m| d.bool(m.field())).collect();
assert_eq!(shown, [true, true, true, false, false, false, false]);
press(&mut app, Action::New);
press(&mut app, Action::Sample);
assert!(dialog(&mut app).bool("sample"));
frame(&mut app);
for m in sample::Mark::ALL {
dialog(&mut app).fields.insert(m.field().into(), json!(true));
}
for z in sample::ZOOMS {
dialog(&mut app).fields.insert("zoom".into(), json!(z));
frame(&mut app);
}
press(&mut app, Action::Sample);
assert!(!dialog(&mut app).bool("sample"));
super::super::cancel(&mut app);
assert!(names(&app).is_empty());
}
/// `ui.dialog.set` takes `sample`, `zoom` and the line fields; a zoom outside the Zoom menu or a
/// line that is not true or false is refused and leaves the dialog as it was.
#[test]
fn sample_fields_are_set_and_checked() {
let mut app = app();
let ctx = egui::Context::default();
open(&mut app).unwrap();
let set = |app: &mut VectorcraftApp, field: &str, value: Value| {
let (req, _) = crate::control::ControlRequest::new("ui.dialog.set", json!({"field": field, "value": value}));
let crate::control::Outcome::Done(r) = crate::control::handle(app, &ctx, &req) else { panic!("not done") };
r
};
for (field, value) in [("sample", json!(true)), ("zoom", json!(400)), ("lineCapHeight", json!(true)), ("lineBaseline", json!(false))] {
let r = set(&mut app, field, value.clone());
assert!(r.get("error").is_none(), "{field}: {r}");
assert_eq!(dialog(&mut app).fields.get(field), Some(&value), "{field}");
}
for (field, value) in [("zoom", json!(30)), ("zoom", json!("200")), ("sample", json!(1)), ("lineXHeight", json!("yes"))] {
let r = set(&mut app, field, value.clone());
assert!(r.get("error").is_some(), "{field} {value}: {r}");
}
let d = dialog(&mut app);
assert_eq!((d.fields.get("zoom"), d.bool("sample"), d.bool("lineXHeight")), (Some(&json!(400)), true, false));
}
/// The sample's lines: the em box and ICF box of the face the Kanji are set in (a face without
/// ideographs centers its em box 0.38 em above the baseline), the cap height and x-height of the
/// Roman part's face raised by its baseline and scaled by its vertical scale, the lowest descent
/// and highest ascent, and the top of the tallest glyph; all of them grow with the size.
#[test]
fn sample_lines_follow_the_parts() {
let close = |a: f64, b: f64| (a - b).abs() < 1e-6;
let (path, h) = sample::measure(&inter_font(|_| {}), 36.0);
assert!(!path.elements().is_empty());
let (bottom, top) = h.em_box.unwrap();
assert!(close(bottom, -0.12 * 36.0) && close(top, 0.88 * 36.0), "{h:?}");
let (ib, it) = h.icf_box.unwrap();
assert!(ib >= bottom && it <= top && ib < it, "{h:?}");
let (cap, x) = (h.cap_height.unwrap(), h.x_height.unwrap());
assert!(0.0 < x && x < cap && cap < top, "{h:?}");
let (low, high) = h.ascent_descent.unwrap();
assert!(low < 0.0 && high > cap, "{h:?}");
assert!(h.ascender.unwrap() > x, "{h:?}");
// The Roman part raised by 10% and squeezed to half height moves its lines; the Kanji's stay.
let (_, raised) = sample::measure(
&inter_font(|p| {
p.baseline = 10.0;
p.v_scale = 50.0;
}),
36.0,
);
assert!(close(raised.cap_height.unwrap(), 3.6 + cap * 0.5), "{raised:?}");
assert!(close(raised.x_height.unwrap(), 3.6 + x * 0.5), "{raised:?}");
assert_eq!(raised.em_box, h.em_box);
// At 200% every line is twice as far from the baseline.
let (_, double) = sample::measure(&inter_font(|_| {}), 72.0);
assert!(close(double.cap_height.unwrap(), cap * 2.0) && close(double.em_box.unwrap().1, top * 2.0), "{double:?}");
}
/// The ICF box is the Kanji face's ideographic character face inside its em box, and a Roman face
/// without an OS/2 cap height still gets a Cap Height line, estimated from its ascent.
#[test]
fn sample_lines_read_the_icf_box_and_estimate_a_missing_cap_height() {
use vectorcraft_text::test_fonts::{HEIGHT_FAMILY, HEIGHTLESS_FAMILY, height_font};
let db = vectorcraft_text::FontDb::global();
db.add_font(height_font(true).expect("the test font builds"));
db.add_font(height_font(false).expect("the test font builds"));
let close = |a: f64, b: f64| (a - b).abs() < 1e-6;
let mut f = inter_font(|p| p.font = HEIGHTLESS_FAMILY.into());
f.parts.kanji.font = HEIGHT_FAMILY.into();
let (_, h) = sample::measure(&f, 36.0);
let (bottom, top) = h.icf_box.unwrap();
assert!(close(bottom, -0.07 * 36.0) && close(top, 0.83 * 36.0), "{h:?}");
let cap = h.cap_height.expect("an estimated cap height");
assert!(cap > h.x_height.unwrap() && cap < h.ascent_descent.unwrap().1, "{h:?}");
}
/// A character its part's font lacks is drawn in a fallback face, and the lines measure that face:
/// in a font whose box runs to 0.9 em and which maps no `A`, `g`, `h`, `1` or `2`, the highest
/// ascent is the fallback face's.
#[test]
fn sample_lines_measure_the_faces_that_draw_the_glyphs() {
use vectorcraft_text::test_fonts::{PATH_ALIGN_HHEA_FAMILY, path_align_font};
vectorcraft_text::FontDb::global().add_font(path_align_font(PATH_ALIGN_HHEA_FAMILY).expect("the test font builds"));
let mut f = inter_font(|_| {});
f.parts = vectorcraft_doc::CompositeParts::all(vectorcraft_doc::CompositePart::new(PATH_ALIGN_HHEA_FAMILY, "Regular"));
let (_, h) = sample::measure(&f, 36.0);
let (_, high) = h.ascent_descent.unwrap();
assert!(high > 0.9 * 36.0 + 0.5, "{h:?}");
}
/// The lines follow a vertical scale as the glyphs do: a custom set that holds the first Kanji at
/// half height halves the em box about its baseline, and Kana scaled at center keep the middle of
/// their em box, so their ascent moves up by the half they lose below it.
#[test]
fn sample_lines_follow_vertical_scale() {
let close = |a: f64, b: f64| (a - b).abs() < 1e-6;
let mut f = inter_font(|_| {});
let mut half = vectorcraft_doc::CompositePart::new("Inter", "Regular");
half.v_scale = 50.0;
f.custom = vec![CustomCharSet { name: "Half".into(), characters: "永".into(), part: half }];
let (_, h) = sample::measure(&f, 36.0);
let (bottom, top) = h.em_box.unwrap();
assert!(close(bottom, (0.38 - 0.5) * 18.0) && close(top, (0.38 + 0.5) * 18.0), "{h:?}");
let kana = |at_center: bool| {
let mut f = inter_font(|_| {});
f.parts.kana.size = 300.0;
f.parts.kana.v_scale = 50.0;
f.parts.kana.scale_at_center = at_center;
sample::measure(&f, 36.0).1.ascent_descent.unwrap()
};
// The Kana, at three times the size, give the highest ascent either way.
let ((_, high), (_, raised)) = (kana(false), kana(true));
assert!(close(raised, high + 0.38 * 108.0 * 0.5), "{high} {raised}");
}
/// The sample adds the first character of each custom set it does not hold yet, and a font whose
/// sets can't be used yet (two sharing a name while it is typed) still draws, without them.
#[test]
fn the_sample_takes_the_custom_sets() {
let mut f = inter_font(|_| {});
let set = |name: &str, characters: &str| CustomCharSet {
name: name.into(),
characters: characters.into(),
part: vectorcraft_doc::CompositePart::new("Inter", "Regular"),
};
f.custom = vec![set("Marks", "〒※"), set("Letters", "A")];
assert_eq!(sample::text(&f), format!("{}〒", sample::TEXT));
f.custom = vec![set("Marks", "〒"), set("marks", "〒")];
let (path, h) = sample::measure(&f, 36.0);
assert!(!path.elements().is_empty() && h.cap_height.is_some());
}
/// The sample draws a color font's glyphs in their own colors, not in the dialog's text color.
#[test]
fn the_sample_draws_color_glyphs_in_their_colors() {
use vectorcraft_text::test_fonts::{COLOUR_CHAR, colr_family, colr_font};
vectorcraft_text::FontDb::global().add_font(colr_font(false).expect("the test font builds"));
let mut f = inter_font(|_| {});
let mut colr = vectorcraft_doc::CompositePart::new(colr_family(false), "Regular");
colr.size = 300.0;
f.custom = vec![CustomCharSet { name: "Color".into(), characters: COLOUR_CHAR.to_string(), part: colr }];
let img = sample::draw(&f, 36.0, 120.0, (900, 160), 1.0, egui::Color32::BLACK);
let red = (0..img.height).flat_map(|y| (0..img.width).map(move |x| (x, y))).any(|(x, y)| {
let p = img.pixel(x, y);
p[0] > 200 && p[1] < 60 && p[2] < 60 && p[3] > 200
});
assert!(red, "the glyph's red layer is drawn");
// Max Ascender reaches the top of the color glyph, three times the size of the rest.
let (_, plain) = sample::measure(&inter_font(|_| {}), 36.0);
let (_, tall) = sample::measure(&f, 36.0);
assert!(tall.ascender.unwrap() > plain.ascender.unwrap() * 1.5, "{plain:?} {tall:?}");
}
+4
View File
@@ -5035,6 +5035,10 @@ axis Both И двете
Em Box Квадратна касетка (Em Box)
x-Height Височина на x
ICF Box Касетка ICF
Show Sample Показване на образец
Hide Sample Скриване на образец
Max Ascent/Descent Макс. височина нагоре/надолу
Max Ascender Макс. възходящ елемент
@msg `id` is the step reference {r}, which only `run` and `command_batch` resolve `id` е референцията за стъпка {r}, която се разрешава само от `run` и `command_batch`
@msg `ids` must be an array of object ids, not {v} `ids` трябва да бъде масив от идентификатори на обекти, а не {v}
@msg `colors` must be an array of colors, not {v} `colors` трябва да бъде масив от цветове, а не {v}
Can't render this file because it is too large.
+4
View File
@@ -1678,6 +1678,10 @@ digits Malayalam Malajalam
Em Box Em okvir
x-Height Visina malih slova
ICF Box ICF okvir
Show Sample Prikaži uzorak
Hide Sample Sakrij uzorak
Max Ascent/Descent Maks. visina gore/dolje
Max Ascender Maks. gornji produžetak
Copy Color Value (Hex) Kopiraj vrijednost boje (hex)
Create New Swatch… Kreiraj novi uzorak boje…
Name 40% Naziv 40%
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -7065,6 +7065,10 @@ theme Appearance Aparença
Em Box Caixa em
x-Height Alçada de la x
ICF Box Caixa ICF
Show Sample Mostra l'exemple
Hide Sample Amaga l'exemple
Max Ascent/Descent Alçada/profunditat màx.
Max Ascender Ascendent màx.
# Average & Join (Object › Path, Cmd+Alt+Shift+J).
Average & Join… Mitjana i unió…
Average & Join Mitjana i unió
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -1749,6 +1749,10 @@ digits Malayalam Malajálamské
Em Box Čtverčík
x-Height Výška x
ICF Box Rámeček ICF
Show Sample Zobrazit ukázku
Hide Sample Skrýt ukázku
Max Ascent/Descent Max. výška/hloubka
Max Ascender Max. horní dotah
Copy Color Value (Hex) Kopírovat hodnotu barvy (hex)
Create New Swatch… Vytvořit novou položku vzorníku…
Name 40% Název 40 %
Can't render this file because it is too large.
+4
View File
@@ -4319,6 +4319,10 @@ digits Malayalam Malayalam
Em Box Em-felt
x-Height x-højde
ICF Box ICF-felt
Show Sample Vis eksempel
Hide Sample Skjul eksempel
Max Ascent/Descent Maks. højde/dybde
Max Ascender Maks. overhøjde
Copy Color Value (Hex) Kopiér farveværdi (hex)
Create New Swatch… Opret ny farveprøve…
Name 40% Navn 40%
Can't render this file because it is too large.
+4
View File
@@ -5360,6 +5360,10 @@ liquify-list-end {0}, {1} {0} und {1}
Cap Height Versalhöhe
x-Height x-Höhe
ICF Box ICF-Rahmen
Show Sample Muster einblenden
Hide Sample Muster ausblenden
Max Ascent/Descent Max. Höhe/Tiefe
Max Ascender Max. Oberlänge
@msg `id` is the step reference {r}, which only `run` and `command_batch` resolve `id` ist der Schrittverweis {r}, den nur `run` und `command_batch` auflösen
@msg `ids` must be an array of object ids, not {v} `ids` muss ein Array von Objekt-IDs sein, nicht {v}
@msg `colors` must be an array of colors, not {v} `colors` muss ein Array von Farben sein, nicht {v}
Can't render this file because it is too large.
+4
View File
@@ -5406,6 +5406,10 @@ digits Malayalam Μαλαγιάλαμ
Em Box Τετράγωνο em
x-Height Ύψος x
ICF Box Πλαίσιο ICF
Show Sample Εμφάνιση δείγματος
Hide Sample Απόκρυψη δείγματος
Max Ascent/Descent Μέγ. ύψος/βάθος
Max Ascender Μέγ. άνω επέκταση
@msg `id` is the step reference {r}, which only `run` and `command_batch` resolve το `id` είναι η αναφορά βήματος {r}, την οποία αναλύουν μόνο τα `run` και `command_batch`
@msg `ids` must be an array of object ids, not {v} το `ids` πρέπει να είναι πίνακας αναγνωριστικών αντικειμένων, όχι {v}
@msg `colors` must be an array of colors, not {v} το `colors` πρέπει να είναι πίνακας χρωμάτων, όχι {v}
Can't render this file because it is too large.
+4
View File
@@ -1036,6 +1036,10 @@ font-technology Variable Variables
Em Box Cuadro eme
x-Height Altura de la x
ICF Box Cuadro ICF
Show Sample Mostrar muestra
Hide Sample Ocultar muestra
Max Ascent/Descent Altura/profundidad máx.
Max Ascender Ascendente máx.
Em Dash Raya
Em Space Espacio eme
Embed Incrustar
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -1722,6 +1722,10 @@ digits Malayalam Malajalam
Em Box Em-laatikko
x-Height x-korkeus
ICF Box ICF-laatikko
Show Sample Näytä näyte
Hide Sample Piilota näyte
Max Ascent/Descent Suurin korkeus/syvyys
Max Ascender Suurin yläpidennys
Copy Color Value (Hex) Kopioi väriarvo (heksa)
Create New Swatch… Luo uusi värimalli…
Name 40% Nimi 40%
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -5423,6 +5423,10 @@ liquify-list-end {0}, {1} {0} et {1}
Em Box Cadratin
x-Height Hauteur d’x
ICF Box Cadre ICF
Show Sample Afficher l'échantillon
Hide Sample Masquer l'échantillon
Max Ascent/Descent Hauteur/profondeur max.
Max Ascender Jambage ascendant max.
ICF Top/Right ICF haut/droite
ICF Bottom/Left ICF bas/gauche
@msg `id` is the step reference {r}, which only `run` and `command_batch` resolve `id` est la référence d’étape {r}, que seuls `run` et `command_batch` résolvent
Can't render this file because it is too large.
+4
View File
@@ -1741,6 +1741,10 @@
ICC Profile ICC પ્રોફાઇલ
ICF Bottom/Left ICF નીચે/ડાબે
ICF Box ICF બૉક્સ
Show Sample નમૂનો બતાવો
Hide Sample નમૂનો છુપાવો
Max Ascent/Descent મહત્તમ એસેન્ટ/ડિસેન્ટ
Max Ascender મહત્તમ એસેન્ડર
ICF Top/Right ICF ઉપર/જમણે
ID: {id} ID: {id}
Identify Objects By ઑબ્જેક્ટ્સ આ રીતે ઓળખો
Can't render this file because it contains an unexpected character in line 72 and column 5.
+4
View File
@@ -2377,6 +2377,10 @@ antiAlias Sharp शार्प
ICC Profile ICC प्रोफ़ाइल
ICF Bottom/Left ICF बॉटम/लेफ्ट
ICF Box ICF बॉक्स
Show Sample नमूना दिखाएँ
Hide Sample नमूना छिपाएँ
Max Ascent/Descent अधिकतम एसेंट/डिसेंट
Max Ascender अधिकतम एसेंडर
ICF Top/Right ICF ऊपर/दाएँ
Identify Objects By ऑब्जेक्ट्स की पहचान करके
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. अगर ड्रॉइंग टैबलेट के पेन से ड्रॉ नहीं हो रहा, तो X11 (XWayland) ऑप्शन चुनें।
Can't render this file because it is too large.
+4
View File
@@ -2157,6 +2157,10 @@ file-filter Templates Sablonok
Em Box Kvirtmező
x-Height x-magasság
ICF Box ICF-mező
Show Sample Minta megjelenítése
Hide Sample Minta elrejtése
Max Ascent/Descent Max. magasság/mélység
Max Ascender Max. felnyúló szár
ICF Top/Right ICF teteje/jobb oldala
Identify Objects By Objektumok azonosítása
Ignore Kihagy
Can't render this file because it is too large.
+4
View File
@@ -1605,6 +1605,10 @@ digits Malayalam Malayalam
Em Box Em Box
x-Height Tinggi x
ICF Box Kotak ICF
Show Sample Tampilkan contoh
Hide Sample Sembunyikan contoh
Max Ascent/Descent Tinggi/kedalaman maks.
Max Ascender Ascender maks.
Copy Color Value (Hex) Salin nilai warna (Hex)
Create New Swatch… Buat swatch baru…
Name 40% Nama 40%
1 # Indonesian (id) catalog. Same format as zh-hant.tsv: context <TAB> source <TAB> translation
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
+4
View File
@@ -1045,6 +1045,10 @@ font-technology Variable Variabili
Cap Height Altezza maiuscole
x-Height Altezza x
ICF Box Riquadro ICF
Show Sample Mostra campione
Hide Sample Nascondi campione
Max Ascent/Descent Altezza/profondità max
Max Ascender Ascendente max
Em Dash Lineetta
Em Space Spazio em
Embed Incorpora
Can't render this file because it is too large.
+4
View File
@@ -49,6 +49,10 @@ font-technology Variable バリアブル
Cap Height キャップハイト
x-Height x ハイト
ICF Box 平均字面
Show Sample サンプルを表示
Hide Sample サンプルを隠す
Max Ascent/Descent 最大アセント/ディセント
Max Ascender 最大アセンダ
Proportional Metrics プロポーショナルメトリクス
H or V Style 横組み・縦組み用かな
Roman Italics 欧文イタリック
Can't render this file because it is too large.
+4
View File
@@ -3670,6 +3670,10 @@ digits Malayalam მალაიალამური
Em Box Em-ბლოკი
x-Height x-სიმაღლე
ICF Box ICF-ბლოკი
Show Sample ნიმუშის ჩვენება
Hide Sample ნიმუშის დამალვა
Max Ascent/Descent მაქს. სიმაღლე/სიღრმე
Max Ascender მაქს. ზედა გამონაშვერი
Copy Color Value (Hex) ფერის მნიშვნელობის კოპირება (Hex)
Create New Swatch… ახალი ფერის ნიმუშის შექმნა…
Name 40% სახელი 40%
Can't render this file because it is too large.
+4
View File
@@ -43,6 +43,10 @@ font-technology Variable 가변
Cap Height 대문자 높이
x-Height x 높이
ICF Box ICF 박스
Show Sample 샘플 표시
Hide Sample 샘플 숨기기
Max Ascent/Descent 최대 어센트/디센트
Max Ascender 최대 어센더
Proportional Metrics 비례 메트릭
H or V Style 가로 또는 세로 스타일
Roman Italics 로마자 이탤릭
Can't render this file because it is too large.
+4
View File
@@ -2213,6 +2213,10 @@ digits Malayalam Malayalam
Em Box Em-vak
x-Height x-hoogte
ICF Box ICF-vak
Show Sample Voorbeeld tonen
Hide Sample Voorbeeld verbergen
Max Ascent/Descent Max. hoogte/diepte
Max Ascender Max. stijger
Copy Color Value (Hex) Kleurwaarde kopiëren (Hex)
Create New Swatch… Nieuw staal maken…
Name 40% Naam 40%
Can't render this file because it is too large.
+4
View File
@@ -1661,6 +1661,10 @@ digits Malayalam Malajalam
Em Box Ramka firetowa
x-Height Wysokość x
ICF Box Ramka ICF
Show Sample Pokaż próbkę
Hide Sample Ukryj próbkę
Max Ascent/Descent Maks. wysokość/głębokość
Max Ascender Maks. wydłużenie górne
Copy Color Value (Hex) Kopiuj wartość koloru (hex)
Create New Swatch… Utwórz nową próbkę…
Name 40% Nazwa 40%
Can't render this file because it is too large.
+4
View File
@@ -929,6 +929,10 @@ antiAlias Sharp Nítido
Em Box Caixa Eme
x-Height Altura do x
ICF Box Caixa ICF
Show Sample Mostrar Amostra
Hide Sample Ocultar Amostra
Max Ascent/Descent Altura/Profundidade Máx.
Max Ascender Ascendente Máx.
Em Dash Travessão
Em Space Espaço Em
Embed Incorporar
Can't render this file because it is too large.
+4
View File
@@ -1034,6 +1034,10 @@ font-technology Variable Вариативные
Em Box Кегельная площадка
x-Height Высота строчных
ICF Box Рамка ICF
Show Sample Показать образец
Hide Sample Скрыть образец
Max Ascent/Descent Макс. высота/глубина
Max Ascender Макс. выносной элемент вверх
Em Dash Длинное тире
Em Space Круглая шпация
Embed Внедрить
Can't render this file because it is too large.
+4
View File
@@ -5352,6 +5352,10 @@ liquify-list-end {0}, {1} {0} och {1}
Em Box Em-ruta
x-Height x-höjd
ICF Box ICF-ruta
Show Sample Visa exempel
Hide Sample Dölj exempel
Max Ascent/Descent Max höjd/djup
Max Ascender Max uppstapel
@msg `id` is the step reference {r}, which only `run` and `command_batch` resolve `id` är stegreferensen {r}, som bara `run` och `command_batch` löser upp
@msg `ids` must be an array of object ids, not {v} `ids` måste vara en array med objekt-id:n, inte {v}
@msg `colors` must be an array of colors, not {v} `colors` måste vara en array med färger, inte {v}
Can't render this file because it is too large.
+4
View File
@@ -5180,6 +5180,10 @@ liquify-list-end {0}, {1} {0} ve {1}
Em Box Em Kutusu
x-Height x-Yüksekliği
ICF Box ICF Kutusu
Show Sample Örneği Göster
Hide Sample Örneği Gizle
Max Ascent/Descent Maks. Yükseklik/Derinlik
Max Ascender Maks. Yükselen
@msg `colors` must be an array of colors, not {v} `colors` {v} değil, bir renk dizisi olmalıdır
@msg `id` is the step reference {r}, which only `run` and `command_batch` resolve `id`, yalnızca `run` ve `command_batch` komutlarının çözümlediği {r} adım referansıdır
@msg `ids` must be an array of object ids, not {v} `ids` bir nesne kimlikleri dizisi olmalıdır, {v} değil
Can't render this file because it is too large.
+4
View File
@@ -1039,6 +1039,10 @@ font-technology Variable Варіативні
Cap Height Висота великих літер
x-Height Висота малих літер
ICF Box Рамка ICF
Show Sample Показати зразок
Hide Sample Приховати зразок
Max Ascent/Descent Макс. висота/глибина
Max Ascender Макс. виносний елемент вгору
Em Dash Довге тире
Em Space Кругла шпація
Embed Вбудувати
Can't render this file because it is too large.
+4
View File
@@ -2010,6 +2010,10 @@ digits Hindi Hindi
Cap Height Chiều cao chữ hoa
x-Height Chiều cao chữ x
ICF Box Ô ICF
Show Sample Hiện mẫu
Hide Sample Ẩn mẫu
Max Ascent/Descent Độ cao/sâu tối đa
Max Ascender Nét chân chữ trên tối đa
ICF Top/Right ICF Trên/Phải
Identify Objects By Nhận diện đối tượng theo
Ignore Bỏ qua
Can't render this file because it contains an unexpected character in line 205 and column 5.
+4
View File
@@ -976,6 +976,10 @@ antiAlias Sharp 锐利
Cap Height 大写字母高度
x-Height x 字高
ICF Box ICF 框
Show Sample 显示样本
Hide Sample 隐藏样本
Max Ascent/Descent 最大上升/下降
Max Ascender 最大上伸部
Em Dash 长破折号
Em Space 全角空格
Embed 嵌入
Can't render this file because it is too large.
+4
View File
@@ -1007,6 +1007,10 @@ font-technology Variable 可變
Cap Height 大寫字母高度
x-Height x 字高
ICF Box ICF 框
Show Sample 顯示樣本
Hide Sample 隱藏樣本
Max Ascent/Descent 最大上升/下降
Max Ascender 最大上伸部
Em Dash 長破折號
Em Space 全形空格
Embed 嵌入
Can't render this file because it is too large.
+13 -3
View File
@@ -10020,9 +10020,19 @@ font based on the one picked, Delete Font takes it out, Import… adds the fonts
picked. Custom shows the font's custom character sets: Character Set picks one, New adds a set based on the one picked,
Delete Set takes it out, and Name renames it. Character › Direct Entry adds the characters typed, and Character ›
Unicode adds the characters of hexadecimal codes (`3042`, `U+3042`, several separated by spaces or commas); Add skips
characters the set already lists. Delete takes the character picked out of the set. OK runs `type.compositeFonts.set`
with every font as one undo step; a refused font keeps the dialog open. `ui.dialog.set` takes `custom`, `entry` and
`char` (the index of the character picked in the set) as soon as the dialog opens.
characters the set already lists. Delete takes the character picked out of the set. Show Sample (Hide Sample when it
shows) draws the font picked in a line of sample text, with the first character of each custom set added, and a button
beside it for each line it can mark: ICF Box, Em Box, Baseline, Cap Height, Max Ascent/Descent, Max Ascender and
x-height ([Creating composite fonts](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=352)).
The em box and ICF box are those of the font of the part that sets the sample's first Kanji (the Kanji part, or a
custom set that holds that character), the cap height and x-height those of the face the Roman letters are drawn in (a fallback face when the part's font lacks the character), Max Ascent/Descent the highest
ascent and lowest descent of the faces the sample uses, and Max Ascender the top of its tallest glyph; each takes its
part's size, baseline and vertical scale. Zoom draws it at 25% to 800% of 36 pt. The
sample text, the zoom steps and the size are VectorCraft's own. OK runs `type.compositeFonts.set` with every font as one
undo step; a refused font keeps the dialog open. `ui.dialog.set` takes `custom`, `entry` and `char` (the index of the
character picked in the set) as soon as the dialog opens, and `sample` (true or false), `zoom` (25, 50, 75, 100, 200,
400 or 800) and `lineIcfBox`, `lineEmBox`, `lineBaseline`, `lineCapHeight`, `lineAscentDescent`, `lineAscender` and
`lineXHeight` (true or false; the first three start true); another value is refused.
```json
{"name":"run_command","arguments":{"command":"type.compositeFonts.set","params":{"fonts":[{"name":"My Composite","parts":{"kanji":{"font":"Source Han Sans"},"roman":{"font":"Source Sans 3","size":95,"baseline":-2},"numerals":{"font":"Source Sans 3"}}}]}}}
+1
View File
@@ -722,6 +722,7 @@ since 2026-10-01.
- **Composite fonts that two documents define differently:** when two open documents each define a composite font (Type › Composite Fonts…) by the same name with different parts, each document draws and exports its type in its own definition: in a tiled or floating window drawn while the front document draws, when it is placed in a document that defines the name differently, and in an export made while another document is in front. Evidence: `tests::composite::nested_loans_of_one_name_use_each_documents_definition` and `threads_lending_one_name_at_once_use_their_own_definitions` (`crates/text`), `tests::fontchange::a_placed_document_draws_its_own_definition_of_a_name_the_page_defines` (`crates/render`). Scores unchanged (estimated).
- **Composite fonts only another document defines:** a document draws, measures and exports its type only in the composite fonts it defines itself. Type naming a composite font that only another open document, or the document a placed document sits in, defines is set as in a missing font, also when the document defines no composite font: in a window, a thumbnail or an export of a document in the back, in a file being opened and in a placed document. A temporary document drawn while a document draws keeps that document's composite fonts. Evidence: `tests::composite::a_lent_document_does_not_use_another_documents_composite_font` and `a_document_without_composite_fonts_uses_none_and_a_preview_is_unchanged` (`crates/text`), `tests::fontchange::a_placed_document_draws_its_own_definition_of_a_name_the_page_defines` and `a_document_draws_type_in_another_documents_composite_font_as_missing` (`crates/render`), `a_document_replaced_in_the_back_measures_a_font_it_lacks_as_missing` (`crates/engine`). Scores unchanged (estimated).
- **Composite fonts' custom character sets:** Type › Composite Fonts… › Custom adds named character sets to a composite font, each setting the characters it lists in its own font, style, size, baseline and scales ahead of their class; the later of two sets that list a character sets it ([the help page](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=348)). Characters are added by Direct Entry or by Unicode code and deleted one at a time; the sets are saved with the document and in `.vccomposite` files (`custom` in `type.compositeFonts.set`). Evidence: `tests::composite::custom_character_sets_take_their_characters_first` (`crates/text`), `compositefonts::tests::custom_character_sets_set_their_characters` (`crates/engine`), `dialogs::composite_fonts::tests::custom_character_sets_are_edited_in_the_dialog` (`crates/ui-egui`). Scores unchanged (estimated).
- **Composite fonts' Show Sample:** Type › Composite Fonts… › Show Sample draws the font picked in a line of sample text with lines for its ICF box, em box, baseline, cap height, highest ascent and lowest descent, highest ascender and x-height, each shown or hidden by its button, at the magnification Zoom picks ([Creating composite fonts](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=352)). The sample text, the zoom steps and what each line measures are VectorCraft's own. Evidence: `dialogs::composite_fonts::tests::sample_lines_follow_the_parts`, `show_sample_shows_and_hides_the_sample` and `sample_fields_are_set_and_checked` (`crates/ui-egui`). Scores unchanged (estimated).
- **Character-style Auto leading:** capture and explicit style attributes retain Auto as a reset, distinct from omitted leading. Redefine and later numeric updates preserve local leading overrides; the Character Styles marker recognizes Auto correctly. Regression assertions cover partial definitions, Undo/Redo and native save/load serialization. Public references: [Character and paragraph styles](https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html) and [Leading](https://helpx.adobe.com/illustrator/using/line-character-spacing.html).
- **Character-style numeric bounds:** `charStyle.new`, `charStyle.edit`, and `charStyle.setAttrs` accept size from 0.1 to 1296 pt, explicit leading from 0.1 to 5000 pt, horizontal and vertical scale from 1% to 10,000%, and baseline shift and Tate-chu-yoko offsets from -1296 to 1296 pt. Out-of-range input leaves the style and Undo history unchanged; Auto leading remains available. These limits match the Character panel controls.
- **Character Style Options, General and Basic Character Formats:** the dialog edits a style's name and stored character formats together. Empty fields remain unset, checkboxes show an indeterminate unset state, Basic's Reset Panel clears its explicit settings, and Preview can be canceled without changing history. OK saves one undo step; New Character Style offers the same fields from captured text or the interface language's defaults without a selection. Public reference: [Character and paragraph styles](https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html).
+1 -1
View File
@@ -75,7 +75,7 @@ against Illustrator's public documentation; **estimated** unless noted.
| CJK: Standard Vertical Roman Alignment | done | Character panel menu › Standard Vertical Roman Alignment (`text.setFormat` / `text.setRangeStyle {standardVerticalRoman}`), with Show East Asian Options, off by default: in vertical type the marked half-width characters (Latin letters, digits and other characters that would lie on their side) stand upright one below the other, each in its upright cell; spaces keep their width and tate-chu-yoko blocks stay across the column; horizontal type keeps the mark and does not change. Character Style Options has its own checkbox for it. Evidence: `tests_vertical::standard_vertical_roman_alignment_stands_half_width_characters_upright`, `typecmd::standard_vertical_roman_is_a_character_attribute_saved_only_when_on` |
| CJK: East Asian glyph forms | done | Glyphs panel menu › Traditional Forms, Expert Forms, JIS 04, JIS 90, JIS 78 and JIS 83 Forms, Monospaced Full-Width, Half-Width, Third-Width and Quarter-Width Forms, and Revert To Default Forms, with Show East Asian Options ([Format East Asian characters](https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html)): the selected characters are drawn with the font's OpenType feature for that form (`trad`, `expt`, `jp04`, `jp90`, `jp78`, `jp83`, `fwid`, `hwid`, `twid`, `qwid`; [feature list](https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist)), one form at a time (`text.setFormat` / `text.setRangeStyle {glyphForm}`); a form none of the faces that draw the selected text (fallback faces included) has a feature for (in `GSUB`, or for the width forms `GSUB` or `GPOS`) is disabled, and Revert To Default Forms draws the default glyphs. A form other than the default takes away a character's glyph choice, and with a width form Proportional Metrics' `palt` is not applied and the font's pair kerning is off. Saved natively only when set, carried by character styles, drawn on the canvas and in PDF, and written to SVG as `font-feature-settings`. Character Style Options has no field for it. Evidence: `tests::typo::glyph_forms_draw_the_fonts_east_asian_forms`, `typecmd::area_tests::glyph_form_is_one_character_attribute_saved_only_when_set`, `typecmd::area_tests::a_glyph_form_takes_away_the_characters_glyph_choice`, `features::tests::width_forms_turn_off_proportional_metrics`, `panels::glyphs::tests::east_asian_glyph_forms_in_the_panel_menu_set_the_selected_characters_form`, `panels::glyphs::tests::glyph_form_items_at_a_caret_follow_all_the_text`, `panels::glyphs::tests::a_glyph_choice_lets_the_current_form_be_chosen_again` |
| CJK: warichu | done | Character panel menu › Warichu and Warichu Settings… (`text.setFormat` / `text.setRangeStyle {warichu, warichuLines, warichuGap, warichuScale, warichuAlign}`, `ui.warichuSettings`), with Show East Asian Options ([Format East Asian characters](https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html)): marked characters set at a percentage of their size and stacked on 1 to 6 lines inside their line, one above the other in horizontal type and side by side in vertical type, with a line gap and eight alignments; a block stays whole on one line. Saved natively, carried by character styles, drawn on the canvas and in every export (SVG, PDF and `.ai` write such type as outlines). Type on a path sets the characters at their own size. Evidence: `tests::warichu`, `dialogs::warichu::tests`, `typecmd::area_tests::warichu_is_a_character_attribute_set_saved_and_exported` |
| CJK: composite fonts | partial | Type › Composite Fonts… (`type.compositeFonts.set`), with Show East Asian Options: a font made of a font per class of character (Kanji, Kana, Punctuation, Symbols, Roman, Numerals), each with its own style, size and baseline in percent of the type's size, Kana, Roman and Numerals with horizontal and vertical scale, and Kana with Scale at Center; New, Delete Font, Import… and Export… (`.vccomposite`, `type.compositeFonts.import` and `.export`) ([Creating composite fonts](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=347)); custom character sets (Custom: New, Delete Set, characters added by Direct Entry or Unicode code and deleted), each with its own font, style, size, baseline and scales, ahead of the classes, the later set winning a character two list (`custom` in `type.compositeFonts.set`) ([Customize characters in a composite font](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=348)). Composite fonts are listed first in the font menus, saved with the document, and their type is laid out per set and class; SVG and legacy `.ai` write it as outlines. Not yet: the Units menu, Show Sample. Evidence: `text::composite::tests::characters_fall_in_their_classes`, `text::composite::tests::custom_sets_take_their_characters_before_the_classes`, `tests::composite::composite_type_draws_each_class_in_its_font`, `tests::composite::custom_character_sets_take_their_characters_first`, `compositefonts::tests`, `dialogs::composite_fonts::tests` |
| CJK: composite fonts | partial | Type › Composite Fonts… (`type.compositeFonts.set`), with Show East Asian Options: a font made of a font per class of character (Kanji, Kana, Punctuation, Symbols, Roman, Numerals), each with its own style, size and baseline in percent of the type's size, Kana, Roman and Numerals with horizontal and vertical scale, and Kana with Scale at Center; New, Delete Font, Import… and Export… (`.vccomposite`, `type.compositeFonts.import` and `.export`) ([Creating composite fonts](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=347)); custom character sets (Custom: New, Delete Set, characters added by Direct Entry or Unicode code and deleted), each with its own font, style, size, baseline and scales, ahead of the classes, the later set winning a character two list (`custom` in `type.compositeFonts.set`) ([Customize characters in a composite font](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=348)). Composite fonts are listed first in the font menus, saved with the document, and their type is laid out per set and class; SVG and legacy `.ai` write it as outlines. Show Sample draws the font picked with lines for its ICF box, em box, baseline, cap height, highest ascent and lowest descent, highest ascender and x-height, each shown or hidden by its button, at the Zoom picked ([Creating composite fonts](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=352)). Not yet: the Units menu. Evidence: `text::composite::tests::characters_fall_in_their_classes`, `text::composite::tests::custom_sets_take_their_characters_before_the_classes`, `tests::composite::composite_type_draws_each_class_in_its_font`, `tests::composite::custom_character_sets_take_their_characters_first`, `compositefonts::tests`, `dialogs::composite_fonts::tests` |
| CJK: ruby | partial | ruby (ふりがな) for live text (`type.ruby`): a reading over a byte range, above (right of the column in vertical type) or below, start/centre/end alignment, size, overhang or squeeze; saved natively, laid out with its line growing, drawn on the canvas, in SVG and PDF (as outlines where ruby is present), in EPS, EMF/WMF and legacy `.ai` (legacy `.ai` writes type with ruby as outlines), and kept by Create Outlines, Expand Appearance and flattening, each glyph where the layout puts it (`typecmd::ruby_tests::create_outlines_keeps_the_ruby_where_it_is_laid_out`) | #633 |
| Language per character (Character panel › Language, character styles), text shaped in it | done | `text.setFormat` / `text.setRangeStyle {language}` by name or BCP 47 tag, one of Document Setup's languages (Hindi, Marathi, Gujarati, Bengali, Punjabi, Tamil, Telugu, Kannada, Malayalam, Odia and Urdu added, #4943; Assamese and Sanskrit added, #4947; Serbian: Cyrillic, Serbian: Latin and Croatian); the shaper gets the tag, so the font's language forms apply (OpenType `locl`: Turkish keeps `fi` apart and the dot on its i, #4940); new type takes the document's language; saved as the tag only when set, carried by character styles (#4946). English and eleven Indian languages hyphenate by run language; Sanskrit automatic hyphenation awaits allowlisted patterns (#4947). Not yet: `.ai`/PDF import of a text's language, paragraph styles. Evidence: `features::tests::language_picks_the_fonts_forms`, `features::tests::serbian_gets_the_fonts_serbian_forms`, `typecmd::area_tests::language_is_a_character_attribute_saved_only_when_set`, `tests::typo::indic_language_runs_hyphenate_with_both_composers`, `hyphen::tests::sanskrit_without_allowlisted_patterns_uses_only_exceptions`; spelling is checked in each run's Language (`text.spelling.check`, #4936) |
| Language per character (Character panel › Language, character styles), text shaped in it | done | `text.setFormat` / `text.setRangeStyle {language}` by name or BCP 47 tag, one of Document Setup's languages (Hindi, Marathi, Gujarati, Bengali, Punjabi, Tamil, Telugu, Kannada, Malayalam, Odia and Urdu added, #4943; Serbian: Cyrillic, Serbian: Latin and Croatian; Bulgarian, #5945); the shaper gets the tag, so the font's language forms apply (OpenType `locl`: Turkish keeps `fi` apart and the dot on its i, #4940); new type takes the document's language; saved as the tag only when set, carried by character styles (#4946). Not yet: hyphenation by it in languages other than English and the eleven Indian languages above, `.ai`/PDF import of a text's language, paragraph styles. Evidence: `features::tests::language_picks_the_fonts_forms`, `features::tests::serbian_gets_the_fonts_serbian_forms`, `typecmd::area_tests::language_is_a_character_attribute_saved_only_when_set`; spelling is checked in each run's Language (`text.spelling.check`, #4936) |