Commit Graph
662 Commits
Author SHA1 Message Date
BFlat db9acab4da Merge pull request #9004 from dotCooCoo/fix/retype-even-odd-turned-counters
Retype: a glyph in an even-odd compound matches with only some of its contours reversed
2026-11-22 11:38:53 +07:00
BFlat b9c9e82f74 Merge pull request #8943 from dotCooCoo/fix/font-version-rescan-and-steady-gate
Fonts: a rescan clears the version record after it publishes its catalog
2026-11-22 11:36:13 +07:00
dotCooCoo c8d02b0dbd Retype: a glyph in an even-odd compound matches with only some of its contours reversed
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.
2026-11-21 01:58:44 -08:00
dotCooCoo c6d9298540 Merge main into fix/retype-remeasure-budget 2026-11-20 22:30:12 -08:00
dotCooCoo 7f3888c59d Fonts: a rescan clears the version record after it publishes its catalog
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.
2026-11-20 21:07:47 -08:00
BFlat 9fff48d88f Merge pull request #8910 from dotCooCoo/fix/similar-fonts-thai-scan
Type: the font scan tells whether a family sets Thai as loading it does
2026-11-21 11:03:21 +07:00
BFlat f558297963 Merge pull request #8681 from dotCooCoo/feat/retype-near-matches
Retype: near matches within a tolerance, and words outlined as one compound path
2026-11-21 10:38:18 +07:00
BFlat de11798f93 Merge pull request #8892 from dotCooCoo/fix/kinsoku-paste-relayout-test
Kinsoku sets: tests for pasted type and shaped lines under a custom set
2026-11-21 10:36:41 +07:00
dotCooCoo 0b5620cf78 Type: the font scan tells whether a family sets Thai as loading it does
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.
2026-11-20 19:25:52 -08:00
BFlat 83d6c2133c Merge pull request #8876 from dotCooCoo/fix/single-line-composer-geometry-tests
Type: tests check where the Single-line Composer sets lines around text wrap
2026-11-21 10:19:16 +07:00
dotCooCoo 91e2551f47 Kinsoku sets: tests for pasted type and shaped lines under a custom set
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.
2026-11-20 16:38:04 -08:00
dotCooCoo adda7c1c6e Tests: font changes on other threads wait while a Type layout count runs
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.
2026-11-20 15:40:31 -08:00
dotCooCoo 4ed194779e Type: tests check where the Single-line Composer sets lines around text wrap
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.
2026-11-20 15:37:59 -08:00
dotCooCoo 4e5345968b Retype: ranking near-match candidates counts against the comparison budget
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.
2026-11-20 01:59:28 -08:00
dotCooCoo dc89097a96 Retype: spaces after the measured glyphs keep the pair check on a short budget
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.
2026-11-19 21:23:14 -08:00
dotCooCoo 5f5559b710 Retype: the glyphs after the measured ones read a word space only where it fits better than the joined pair
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.
2026-11-19 19:46:43 -08:00
dotCooCoo fe7d225d6f Retype: a contour reaching outside a concave one is no counter of it, and a rejected split gives way to another
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.
2026-11-19 17:07:50 -08:00
dotCooCoo 8158107e82 Retype: a counter too narrow in any direction, or an outline too large to probe, keeps the shape 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.
2026-11-19 16:40:10 -08:00
dotCooCoo b0de3d983e Merge main into feat/retype-near-matches 2026-11-19 13:59:32 -08:00
dotCooCoo 782b6782ff Retype: a split compound must paint what the compound paints, and counters too narrow to probe stay outlines
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.
2026-11-19 13:29:45 -08:00
dotCooCoo 744f32977a Retype: near-only glyphs stay out of exact matching, and a glyph must paint the shape's area
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.
2026-11-19 11:52:00 -08:00
dotCooCoo 9dcc6913d8 Metafile import: text in the opaque background mode fills its character cells
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.
2026-11-19 05:28:52 -08:00
dotCooCoo 67fa32374d Retype: near matches within a tolerance, and words outlined as one compound path
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
2026-11-19 00:47:08 -08:00
BFlat bccb824be6 Merge pull request #8619 from dotCooCoo/feat/retype-matching-fonts
Retype: the Retype panel lists the fonts that match outlined text
2026-11-19 15:18:29 +07:00
BFlat fd0ff592b7 Merge pull request #8624 from dotCooCoo/fix/followup-8408
Type: the missing-font question takes its answer through tool.setOption
2026-11-19 15:06:39 +07:00
BFlat 8e55ffdddf Merge pull request #7229 from dotCooCoo/feat/kinsoku-sets
Type: Kinsoku Shori sets can be created, edited and chosen per paragraph
2026-11-19 14:54:38 +07:00
dotCooCoo 7d44690b52 Merge main into feat/retype-matching-fonts 2026-11-18 18:52:29 -08:00
dotCooCoo d94d3ef097 Type: the missing-font question takes its answer through tool.setOption
- `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.
2026-11-18 15:41:34 -08:00
dotCooCoo b6f310c421 Merge main into feat/docinfo-font-details 2026-11-18 13:14:52 -08:00
dotCooCoo 734582bd81 Retype: the Retype panel lists the fonts that match outlined text
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.
2026-11-18 12:35:02 -08:00
dotCooCoo fe17b6ebee Merge main into feat/kinsoku-sets 2026-11-18 10:26:50 -08:00
BFlat ca812ef78e Merge pull request #8408 from dotCooCoo/feat/type-missing-font-edit-confirm
Type: editing type set in a missing font asks to confirm first
2026-11-19 00:42:06 +07:00
BFlat 16e7216c16 Merge pull request #8441 from ruchirguitar/feat/4934-retype
Type › Retype, phase 1: outlined text that matches an available font becomes live type (#4934)
2026-11-19 00:38:40 +07:00
dotCooCoo 2db6ae68df Merge main into feat/docinfo-font-details 2026-11-18 08:16:53 -08:00
dotCooCoo 83bb31c9e2 Merge main into feat/type-missing-font-edit-confirm 2026-11-18 07:33:32 -08:00
dotCooCoo b2c14dbf87 Merge main into feat/kinsoku-sets 2026-11-18 07:26:37 -08:00
ruchirguitar 4c44f3c66c Merge remote-tracking branch 'upstream/main' into feat/4934-retype
# Conflicts:
#	crates/text/src/fontdb/lookup.rs
2026-11-18 20:38:09 +05:30
bflatastic 11b6ae8203 text: pin craft-font-catalog to craft-libs main and restore the shared outline call 2026-11-18 22:02:41 +07:00
Dylan M. Taylor c758d60942 Merge pull request #7904 from storytold/codex/shared-ligature-carets-caller
Use shared ligature caret mapping
2026-11-18 09:53:58 -05:00
bflatastic 585c0aaa70 fmt: reflow the fontdb lookup imports after #7877 2026-11-18 21:52:24 +07:00
Dylan M. Taylor 4c57169a87 Merge remote-tracking branch 'origin/main' into pr-7904
# Conflicts:
#	Cargo.lock
#	crates/text/Cargo.toml
#	crates/text/src/fontdb/lookup.rs
2026-11-18 09:50:09 -05:00
Dylan M. Taylor 64458d0a5a Merge remote-tracking branch 'origin/main' into pr-7904 2026-11-18 09:21:45 -05:00
Dylan M. Taylor 1b150df493 Merge remote-tracking branch 'origin/main' into pr-7877 2026-11-18 09:21:41 -05:00
ruchirguitar 4fe27f830c M7/G4: retype bounds readings tried and glyphs laid out (#4934)
Readings of a shape are capped by those tried, not those kept, so a shape
whose every reading fails stops at the cap. The layout check grows a
window from each line start, doubling while the type draws the outlines,
and starts the next line at a mismatch, so a line split at every glyph
costs about twice its glyphs, not half their square; a glyph budget
leaves anything past it as outlines. A tracked line of 450 glyphs: 259 ms.
2026-11-18 19:39:40 +05:30
ruchirguitar 1cffa0b862 M7/G4: retype review: tracked letters, outline check cost, poses (#4934)
The lone-glyph rule looks at lines as the outlines lie, before the layout
check splits them, so tracked one-contour letters (L, I, T, H, E) become
type. A shape keeps every glyph and pose it fits exactly, upright first
(an L, and a turned L half round; an I upright or upside down), and the
line around it chooses; a one-glyph line may turn to another candidate
to take the next glyph.

The whole-outline check flattens the shape once per shape, samples every
corner and points twice the tolerance apart, and asks a flat uniform grid
of segments. With Microsoft YaHei loaded: 300 CJK outlines in 350 ms
(1.9 s before), one line in 25 ms. FontDb::outline reuses
outline_uncached, and the compositing test covers knockout_shape.
2026-11-18 18:58:52 +05:30
ruchirguitar c1613f2bf5 M7/G4: retype checks points along every edge; keys charged once (#4934)
The whole-outline check tests points along every edge, so outlines with
the same corners joined another way do not match; past a work limit it
rejects. Face keys another Retype kept meanwhile are reused and charged
once. The fonts parameter test uses outlines that would match. The parity
note states the search limits.
2026-11-18 15:25:41 +05:30
ruchirguitar 06e8ce62b9 M7/G4: retype matching reads contours as drawn, checks whole outlines (#4934)
Contours are read from a starting corner that does not depend on where
the path starts (every tied corner tried), with straight edges split in
two, degenerate curves and empty segments read as one line. A sampled
fit only shortlists a glyph: its whole outline, turned onto the shape,
must lie on it. Face keys are compact hashes, kept per process within a
budget; kept keys stay when new ones do not fit, and go when fonts are
added or rescanned.

A compound path with a locked or hidden part stays whole. A group with
an Attributes note, or any other extra, keeps its type inside. Faces are
counted once against the cap, and no font is read when every shape stays
an outline.
2026-11-18 15:07:47 +05:30
ruchirguitar 783437f775 M7/G4: retype review: hidden art, compositing, half turns, cost (#4934)
Hidden and locked shapes stay outlines and end the line. Isolated and
knockout groups keep their type inside. Type turned 180 degrees stays
one object (angles compared wrapped). A lone one-contour glyph beside
other shapes stays an outline unless it is the only shape selected.

The index samples only glyphs whose key (segments per contour) a selected
shape has, reads outlines past the shared outline cache, keeps each
face's keys once worked out, and loads no more faces than it takes. With
Microsoft YaHei (29,905 glyphs) loaded: 877 ms the first time, 23 ms
after.
2026-11-18 11:58:41 +05:30
dotCooCoo 4ed1839274 Merge main into feat/kinsoku-sets 2026-11-17 22:11:34 -08:00
dotCooCoo ec882bb4d2 Merge main into feat/docinfo-font-details 2026-11-17 21:39:52 -08:00