VectorCraft's UI moves onto the shared craft UI framework in storytold/craft-libs (`next`; the framework side is storytold/craft-libs#2809), as PhotoCraft's did. The app keeps its engine, document model, file formats, commands and automation; its windows, panels, bars, dialogs and canvas are now built and driven by the framework: shell, docking and panels, hosted dialogs, keyboard, focus, IME and pointer routing, and theme tokens.
About 264,000 lines of VectorCraft's own egui UI code are removed and about 154,000 added. craft-libs is pinned at bf62d509f (in `next`), the egui fork at f5025284.
Tests that drove the old UI were rewritten against the port where only their premise changed, with their assertions kept. The UI tests still failing at merge, and their follow-ups, are listed in the pull request.
Rule 10: every storytold/craft-libs crate is at the same rev, now
205042e406b630cda653990649264a78fea6296b, the merge of #3136 on
craft-libs main. That rev still skips a form already on the drawing
stack (ISO 32000-2 §8.10.1) but no longer reports it as
ContentTruncated, so a 200-shape knockout-mask PDF imports completely.
Also moves the leftover per-crate pins of craft-font-catalog and
craft-web-api onto the same rev.
* PDF import: keep embedded fonts for text whose family isn't installed
Glyphs drawn in an embedded font whose family isn't available are gathered
during import and built into one small TrueType font per family and style,
kept with the document (font/ttf blob). Text objects record the fonts and a
hash of their text: layout and rendering draw them in the kept font until the
text is edited (undo restores it) or the family is installed. Lines are
spaced against the file's own widths with per-glyph placement (#3756).
* PDF import: satisfy crate layering constraints without format dev-dep
* FileFont: negate us_win_descent in i32 to prevent overflow on extreme negative descenders
* PDF import: a kept font carries the file font's licence flags, and the docs say what that means
Review of #4569: the fsType of the file's font is copied to the font built from its glyphs (a test pins it against Embedding), so exports honour it; the docs state the limits, that the file's font program is not parsed, and that a saved file carries third-party glyphs.
* PDF import: a glyph curve far outside any glyph is left out; docs say what the limits and the font program mean
CodeRabbit on #4569: coordinates beyond 1e6 font units are refused before the curve is subdivided. The docs say the 64-font limit is what draws one type object and that the file's font program is read only for its licence flags and metrics.
* PDF import: two programs of one font keep the stricter licence flags; the docs cite their sources
CodeRabbit on #4569: embedded programs of one family and style share one built font, which kept the first program's fsType; it now takes the stricter of the two, whichever came first. The docs entry cites the Acrobat Help pages and the OpenType fsType specification.
* fmt
* PDF import: embedded fonts are on by default, with an opt-out preference
Owner decision on #4568. Preferences > File Handling > Use fonts embedded in imported PDFs (pdfImportEmbeddedFonts, on by default) and the embeddedFonts param of document.open and file.place: off, a PDF's type in a font the machine lacks is set in the fallback font with the missing-font warning, as before. One test each for on and off, one for the preference reaching the options.
* fmt after merging main
* docs: restore the status lines damaged by merges (main's line plus this PR's note)
* PDF import: set embedded_fonts through a builder method (keeps read_opened under the complexity limit)
* PDF import: move the missing-font notes out of read_opened (complexity limit after the merge)
* #4569: isolate file-font resources and reclaim live faces (UNVERIFIED)
* Preserve carried-font ownership across placement and recovery
* Fix carried-font regression test dependencies and unwind probe
* Use explicit OS2 heights in owned-font reference regression
* Keep native font regression artwork inside document layers
* fix(engine): bind file fonts when reading document profiles
* test(engine): initialize file-font leases in new image fixtures
* test: complete file-font lease initialization in image fixtures
* docs: keep the #4568 entry in the file-format parity status line
* fix(pdf): keep a line with another glyph for the same character as outlines (review)
A font kept with the document has one glyph per character. A glyph of the file's font that
differs from the one already kept for its character (a stylistic alternate that maps to the same
Unicode scalar) marks its line, which is imported as outlines so each glyph draws as the file
does.
* docs: resolve the leftover status-line conflict
* Placed document blob: give the new ImageBlob literal its file_font
* Test: a PDF's two glyphs for one character survive a native save and reopen as the file draws them
* Test: move the native save and reopen half of the two-glyphs regression to the engine (layers: no format dev-dep in pdf)
* Fix embedded-font preference help and English fallback checks
* Format embedded-font preference help with the workspace edition
---------
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
Co-authored-by: skylartaylor <hi@skylar.cc>
An even-odd compound paints the same whichever way each contour runs, so
an o's counter may run the same way as its outer contour. Such a part
matched neither as it is nor with all its contours reversed, and stayed
an outline at tolerance 0. A part of a split compound is now also read
with each contour turned the way its depth gives (outer contours one way,
their counters the other), both ways round. In a nonzero compound those
contours paint the counter, and the painted-area check still keeps the
part an outline.
The containment test that splits a compound into glyphs moves into its
own function, `containers`, which the new reading also calls.
Docs: docs/mcp.md, docs/type-parity.md.
A rescan of the font folders cleared the record of families whose other
versions had been looked for before it walked the folders. A version
lookup made during the walk read the old catalog and recorded its family
again, so a version the rescan found stayed hidden until the next scan.
The record is now cleared after the new catalog is written.
- The font gate used by tests: a thread's first SteadyFonts no longer
waits for a font change that is itself waiting for guards other
threads hold, so a guarded test does not hang when another test queues
a change. It still waits for a change under way and for a waiting
change that can start.
- Tests that check a change waits for a guard now read the gate's own
decision, recorded under its lock, instead of the request to change.
The system font scan built each face from its name, fvar, OS/2, head and
post tables only, so a family that was found but not loaded never had
Thai in its traits. The font menus' Thai filter left such families out,
and Show Similar Fonts grouped them with the other scripts until they
were loaded.
- A face sets Thai when its OS/2 table allows it (no OS/2 table, the
Thai Unicode range, bit 24, or the Thai code page, bit 16) and its
character map has Thai, loaded or scanned.
- The scan reads the cmap table of such a face only, up to 16 MiB.
The search for a document's missing fonts reads no cmap table, so
its byte limit covers the same tables as before.
Pasted type whose custom set was edited after the copy is checked against
a fresh layout by its line ends, which move from A to B while the line
count stays the same, so the test fails without the relayout in Relink.
The every-line composer's first-word measure is checked in a frame whose
top is narrower than the word the custom set's Cannot End Line makes, so
the test fails when that measure uses the built-in setting instead.
The Type overlay layout-count tests in vectorcraft-tools held a read lock
that only tests which add fonts or change hyphenation exceptions take for
writing. Other tests still load system fonts on demand (a fallback for a
character no loaded font covers, a cataloged family on first use), which
changes FontDb::global()'s generation, the key of every kept frame layout.
type_overlays_keep_at_most_frame_layouts_max then laid out 2051 frames
instead of 2 in 18 of 21 full `cargo test -p vectorcraft-tools --lib`
runs on Linux.
vectorcraft_text::test_fonts::steady_fonts (test and test-fonts builds
only) now holds back font changes on other threads: adding faces, a
rescan and setting or removing a composite font wait before they publish
anything. A first scan does not wait, and steady_fonts catalogs the
database before it returns. steady_layout_inputs() takes it for the
global database. With it, 0 of 20 full runs failed.
composer_x_mixed_sizes_around_text_wrap and
composer_x_mixed_sizes_overflow_around_text_wrap compared only the
Single-line Composer's line texts with the Every-line Composer's. Both
tests now run their room, overflow and wrap-object checks on each
composer, so a Single-line layout that breaks the same lines but sets a
span past its room or into the object fails.
Near matching ranked every glyph of the shape's contour count and proportion
before comparing the 256 closest, and that ranking was not counted against the
point comparisons each shape and command may make, so a large selection over
many fonts could spend unbounded time there. Each glyph ranked now takes one
comparison per contour and one more from the same budget, the ranking keeps
the closest glyphs without sorting the rest, and the shares of contour length
are read without allocating per glyph.
Laying out the pairs after the glyphs a split measures is now set aside before the tracking is measured, so a short budget no longer leaves those pairs to the gap alone; without enough for both, the rest is not measured. Past the measured glyphs, the number of word spaces in a gap is the count among the rounded, lower and upper counts of the gap and the count of the measured one-space distance that fits best, so kerning against a space no longer adds a second space. The pair check also runs on a gap under half a space wide, so kerning toward a space no longer drops it.
Rounding a measured tracking to a whole number now counts the word spaces as well as the glyphs the tracking moves, so a long spaced run after a split keeps a fractional tracking and stays one object.
A drawn bar, dot or ring can be the same shape as a combining mark in
one of the loaded fonts, and Retype turned it into point text that held
only that mark. On Linux, once other tests had loaded the system fonts,
the 80x40 rectangle in a_drawn_shape_is_reported_and_left_alone matched
U+05BD in DejaVu Sans Bold, so that test failed in full runs of the
engine's tests.
- When a shape would start a line and its first 16 matched glyphs
include another character's glyph, in its own font or another loaded
one, it starts the line as that character. A line's first shape is
not turned into a mark to take the glyph after it.
- When all of them are marks, the shape stays an outline and is listed
in unmatched, and the glyph after it starts the line. A lone
one-contour glyph after it (a dot after a bar) is judged alone, as on
its own.
- A mark left at the start of a part split off where type stops
drawing the outlines in place becomes the other character its shape
matches, on a line of its own, or else stays an outline. The glyphs
after it are measured for tracking again without the mark's gap.
- A mark that follows another glyph on its line is retyped with it, as
before.
- type.retypeFonts does not list a font whose glyphs match the shapes
only as combining marks.
Docs: docs/mcp.md and the params text of type.retype and
type.retypeFonts.
Past the first 32 glyphs of a rest, a gap now reads as a word space only when spaces fit it better than the joined pair does, as the measured glyphs do. A tracking and kerning that make a kerned pair draw like a space no longer add spaces the source lacks.
A contour counts as lying inside another only when up to eight of its anchor points do. When the paint check rejects the split with the longest runs, the split with the shortest runs is tried before the shape stays an outline.
The fill check rejects a counter whose convex hull is narrower than three times the outline tolerance in some direction, so a turned strip is caught as well as an upright one, and rejects a shape whose outline is too large to flatten. Exact parts of a split compound are checked at tolerance 0 even when near matches are allowed, so a split that only exact matching found is not accepted under the wider tolerance. The tracking sentence in docs/type-parity.md names its three-glyph condition.
The parts of a split compound path are set as separate glyphs, so an overlap
that the compound's fill rule leaves unpainted would come out painted. A
split whose parts paint differently from the compound, whose combined outline
is too large to probe, or whose parts' boxes overlap in a strip too thin to
probe, stays an outline. A counter narrower than three times the outline
tolerance cannot be checked by the fill probes, so the shape stays an outline.
The params text says a command errors when no shape becomes type.
Glyphs indexed only for near matching no longer take part in exact matching,
so a curve split in two is no exact match at tolerance 0. Each pose of a match
reports its own residual. A near match spends its comparison allowance from
the shared budget in one step and returns what it leaves, and does no
sampling once the budget is spent. A glyph replaces a filled shape only when
it paints the area the shape paints under the shape's fill rule. The docs
define the tolerance by the outline spread and separate the no-conversion
error from the unmatched list.
A metafile playback starts in the opaque background mode with a white
background color, and text drawn in that mode fills its character cells
with the background color before the glyphs. EMF and WMF import now adds
one filled rectangle of the background color behind each line of such
text, before the type, from the font's OS/2 usWinAscent above the
baseline to its usWinDescent below it, as far as the line's advances
reach (NULs and negative advances included). Files that never set the
background mode now import with a background behind their text.
Top and bottom aligned text now has the top or the bottom of that cell at
the reference point instead of 0.8 and 0.2 of the em. A single line
without advances is aligned as long as its glyphs' advances, trailing
spaces included. NULs after a line break move the start of that line,
and underlined or struck through blanks draw their bars.
Face::win_ascent_descent gives the OS/2 usWinAscent and usWinDescent
separately, at a variable font's instance.
type.retype takes a tolerance (0 to 0.05, default 0 for exact matches
only). Above 0, a shape of up to 8 contours that is no glyph exactly is
read at equal steps of length from any start and in either direction,
with its contours paired with the glyph's by length. It becomes the
closest glyph when the leftover distance, relative to the shape's size,
is at most the tolerance, and the glyph's outline and the shape's each
lie within three times the tolerance of the other. Simplified outlines,
curves split in two and contours in another order or direction match
this way. A near-matched glyph may differ from its line by the tolerance
in size, turn and place; an exact glyph keeps the exact limits unless
the line's first glyph is a near match. Each entry of fonts in the
result has a score from 1 (exact) to 0.
A compound path holding several glyphs (a word made into one compound
path) is split into groups of contours, a contour with the contours
inside it, and matched in runs of up to three groups, longest first
among those that leave the rest matchable, so an i's stem and dot
become one i. Exact matches of the whole shape come first, then exact
matches of its groups, then near matches. The compound becomes type
only when every glyph matches; otherwise it stays and is reported once.
Exact matching of those groups also reads contours that run the other
way round, as Make Compound Path leaves them. A compound path of more
than 256 groups or 512 contours is matched whole only, and so are the
shapes after the first 16,384 contours one command groups.
Near matching compares a shape with at most 256 glyphs, in at most 50
million point comparisons per shape and 2 billion per command, and
looks glyphs up for at most 1,024 distinct shapes and runs per command,
whole shapes first. At most 262,144 glyphs are drawn to check and
32,768 indexed for near matching, shared equally among the faces; a
face's glyphs closest to the selected shapes are indexed first.
The tolerance, the score and the splitting rules are VectorCraft's own.
Part of #4934
- `tool.setOption {key: "missingFontEdit", value: {token, ok}}` now passes
the Type tool's option check, so a client can answer the question that
a click on type in a missing font asks. Before, it failed as an unknown
option.
- A press on such type that reaches the Type tool while another dialog is
open (sent with `pointer_gesture`) leaves that dialog open and starts no
edit, instead of replacing it.
- docs/mcp.md says which double-clicks ask, and that OK starts no edit
when the document changed after the question opened.
- The doc comment of `GENERIC_FAMILIES` notes that `emoji` is kept
although CSS Fonts Module Level 4 dropped it.
Window › Retype shows a panel that lists the fonts whose glyphs the
selected outlined text exactly matches. Find Matching Fonts lists ten,
ranked by how many shapes each matches and then by how closely, and
Find more font matches adds the next five from the same search. Each
row shows a sample in the font, at the size the panel menu sets (Small,
Medium, Large) and with the text typed in the panel. A click on a row
sets the font on the selected live type. Reset Retype Panel clears the
list.
- type.retypeFonts {count?} returns the ranked fonts without changing
the document. It compares shapes with the glyphs of up to 96 loaded
fonts, those of the document's live type first, by type.retype's
matching. A shape counts once for each font it fits. Of two loaded
versions of a font, only the version its name gives is compared.
- RetypeIndex::all_matches returns every fit of a shape, so fonts past
the first 16 fits are ranked too.
- retype.find, retype.list, retype.preview and retype.reset drive the
panel.
- Rows for the panel's labels and the commands' errors in every
complete catalog. The Retype row also translates the Type › Retype
menu item.
Docs: docs/mcp.md (Retype panel), docs/target-app-parity.md,
docs/ui-parity.md, docs/gaps.md, docs/type-parity.md.
Part of #4934. Builds on #8441.