Commit Graph
585 Commits
Author SHA1 Message Date
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
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
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
ruchirguitar c42cfd23b7 M7/G4: retype checks each line against its own layout (#4934)
Each retyped line is laid out and compared glyph by glyph with the
outlines; it splits where its type would draw another glyph or the same
glyph elsewhere (tracking, manual spacing, font substitutions), and a
glyph its type cannot draw stays an outline. Shapes with their own
opacity mask stay outlines. Shapes past the limits are reported as
truncated. Glyphs of plain-shape symbols (box drawing, blocks, geometric
shapes, private use) are not matched, so drawn rectangles stay art.
Type › Retype is in the Type menu.
2026-11-18 10:03:29 +05:30
ruchirguitar 81d38d0d70 Merge remote-tracking branch 'upstream/main' into feat/4934-retype
# Conflicts:
#	docs/target-app-parity.md
2026-11-18 09:15:33 +05:30
BFlat 3d7acda832 Merge pull request #7134 from dotCooCoo/feat/web-korean-devanagari-fonts
Web: Korean and Hindi interface text draws with real glyphs
2026-11-18 10:30:59 +07:00
BFlat 61d3190469 Merge pull request #8181 from dotCooCoo/feat/area-type-first-baseline-em-box
Type: Area Type Options First Baseline offers Em Box Height
2026-11-18 10:22:23 +07:00
ruchirguitar 90b37ad269 M7/G4: retype keeps paint order, groups, transparency and font version (#4934)
An unmatched shape between glyphs ends the line, so the type after it is
still painted over it. Glyphs of different groups, paint or transparency
never share a line, and the new type takes the glyphs' own opacity and
blend mode. The type names the font version that matched. The glyph
budget holds inside a face too.
2026-11-18 03:02:33 +05:30
ruchirguitar 957712ca71 M7/G4: retype float checks without negated comparisons (#4934) 2026-11-18 02:48:38 +05:30
ruchirguitar 24a37f8ba3 M7/G4: Type › Retype, phase 1 (#4934)
type.retype turns selected outlined text back into live point text when
each glyph shape is exactly a glyph of a loaded font, a font the document
uses or a family named in fonts: the same up to uniform scale, rotation
and translation. Matched glyphs map back to characters through the cmap
and become point text in that font and size at the same baseline and
turn, one object per line, with the first glyph's fill and stroke, in one
undo step. Shapes that match no font stay and are reported.

Matching (vectorcraft_text::retype) samples each contour at equal steps of
arc length and fits a similarity transform; it is bounded (faces, glyphs,
path elements, contours) and panic-free. Near matches, the ranked font
list, installed fonts not yet loaded and images are phase 2.
2026-11-18 02:20:06 +05:30
BFlat e1b12a5640 Merge pull request #8060 from dotCooCoo/feat/hyphenation-languages
Type: text hyphenates in Bulgarian, Turkish and Russian, and in German, Polish, Portuguese and Italian with CRAFT_I18N_DIR
2026-11-18 03:22:00 +07:00
BFlat 5088d9c6ec Merge pull request #8272 from dotCooCoo/feat/emf-font-width-scale
Metafile import: a LOGFONT average character width becomes Horizontal Scale
2026-11-18 03:21:07 +07:00
Dylan M. Taylor 2dd120c0fe Use shared contextual run shaping (#7878) 2026-11-17 08:14:14 -05:00
HassanKhan 0c3e886675 Merge remote-tracking branch 'upstream/main' into fix-7821-harakat-tsume-arial 2026-11-17 11:34:26 +05:00
Dylan M. Taylor 6d91dde84c Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/text/src/fontdb/lookup.rs
2026-11-16 23:23:16 -05:00
BFlat 968882fa8f Merge pull request #8227 from dotCooCoo/feat/font-menu-recently-added
Font menu: a Recently Added filter lists the families installed in the last 30 days, newest first
2026-11-17 09:49:44 +07:00
dotCooCoo d1b588279f Text: a variable font's Windows cell height takes its MVAR changes
FontFace::win_cell_height adds the MVAR `hcla` and `hcld` deltas to
usWinAscent and usWinDescent at the face's location, so EMF and WMF
type with a positive font height is sized against the instance it is
drawn in. The variable test font gains the two records, and a test
checks that Bold's cell is 200 units taller than Regular's.

The comments and docs/mcp.md also say that characters the mapped face
has no glyph for are drawn from other faces at the same size and
Horizontal Scale.
2026-11-16 17:00:27 -08:00
dotCooCoo fb927525f6 Metafile import: a LOGFONT average character width becomes Horizontal Scale
Follows #7608. EMF and WMF type ignored the font's average character
width, and a positive font height was read as a fixed 0.85 of the cell.
Both changes are to how the importer reads a LOGFONT's size fields.

- When the face gives an average width (OS/2 xAvgCharWidth), a font's
  average character width becomes Horizontal Scale: the face's average
  width at the type size is stretched or narrowed to the font's width,
  also when the size is held at its 5000 pt limit. A negative width is
  read as its absolute value, and the width is ignored when the height
  is 0.
- A positive height is the character cell. The em is the cell times
  unitsPerEm divided by the face's usWinAscent plus usWinDescent (its
  ascent plus descent when it has no OS/2 table). Type with a positive
  height in existing files changes size.
- A font the system lacks is measured in the face VectorCraft draws it
  in.
- FontFace gets win_cell_height and average_char_width.

LOGFONT: https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-logfontw
MS-EMF 2.2.13 LogFont: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-emf/1cd7cb7a-1a7c-48d2-b4a4-c218f9d12100
2026-11-16 16:28:21 -08:00
dotCooCoo dd05a39106 Merge main into feat/type-on-path-desired-spacing 2026-11-16 10:46:53 -08:00
dotCooCoo 4fdeeb0223 Font menu: a Recently Added filter lists the families installed in the last 30 days, newest first
The font menu's Recently Added chip, on its own row under Font Technology,
lists only the installed families with a font file created in the last 30
days, the newest at the top. It combines with the search, script, kind,
Variable, star and Document filters, lists the recently used families in
the same order without the Recent Fonts section, leaves Show Similar Fonts
to order only these families, steers the closed field's wheel, and is
shared by every font menu for the session.

The font scan keeps each file's creation time, and
FontDb::recently_added(now) dates a family by its newest file at or
before `now`, the 30th day included. Files without a creation time or
dated in the future do not count, and families added at the same instant
are in name order. The open menu lists a family no longer once its 30
days end.
2026-11-16 09:58:48 -08:00
dotCooCoo 27295b0530 Merge main into feat/area-type-first-baseline-em-box 2026-11-16 09:55:33 -08:00
dotCooCoo 39d776aa2b Merge main into feat/web-korean-devanagari-fonts 2026-11-16 09:54:01 -08:00
BFlat c19024b6cc Merge pull request #8120 from dotCooCoo/perf/glyphs-panel-cmap-once
Glyphs: read a face's character list once instead of on every frame
2026-11-16 23:53:24 +07:00
dotCooCoo 5c789eb818 Merge main into feat/area-type-first-baseline-em-box 2026-11-16 08:15:17 -08:00
dotCooCoo 24e528abcf Type: Area Type Options First Baseline offers Em Box Height
First Baseline gains Em Box Height (`text.areaOptions {firstBaseline:
"emBoxHeight"}`, and the Area Type Options dropdown). The top of the
first line's ideographic em box, the largest on a line of several sizes,
touches the top of the type area inside the inset, in each row/column
cell and in vertical type. It is the em box that Top-to-Top leading
uses. Min is the least distance, as with the other kinds.

Native files save it as `emBoxHeight`. The .ai reader reads editing-data
kind 5 as Em Box Height and the writer writes it back; Legacy (6) and
unknown kinds keep today's fallback.

The dropdown's Ascent and x Height labels, and Fixed in Gujarati, get
the catalog rows nine languages were missing, beside the new label in
every catalog.

Help page: https://helpx.adobe.com/illustrator/desktop/design-with-text/add-manage-text/add-margins-to-text-and-adjust-the-first-baseline.html
2026-11-16 07:40:47 -08:00
dotCooCoo 6a66f9ad94 Type: decomposed Cyrillic and capital words hyphenate as their composed spelling
A Russian or Bulgarian word written with a combining breve (`и` + U+0306
for `й`) failed the Cyrillic script check and stayed whole; the check now
reads the composed word, so it breaks at the same characters as `чайник`.
A stress mark, which composes with nothing, still keeps the word whole.

The all-capitals guard skipped a decomposed capital such as `O` + U+0308,
since a combining mark has no case, so `ÖĞRENCİ` spelled that way was
hyphenated in Turkish; the guard now counts only the letters.
2026-11-16 07:33:39 -08:00
dotCooCoo 9973247dfc Type: test that Show Similar Fonts puts a family without numbers first when asked about it
The test now lists that family last, so it passes only when the family
asked about is moved to the front and the others keep their order.
2026-11-16 06:00:19 -08:00
dotCooCoo 10edf89f36 Glyphs: read a face's character list once instead of on every frame
The Glyphs panel asked the face for its characters on every frame, and
each call read the whole cmap, sorted it and removed repeated
characters. A face now keeps the list the first time it is asked for
(FontFace::mapped_chars) and shares it; FontFace::chars returns a copy
of it, in the same order. The panel finds a Unicode subset's characters
by searching the sorted list, and Entire Font uses the face's shared
list of unencoded glyphs instead of copying it each frame. The cells the
panel shows do not change.

Measured in one release process, old read and shared list alternating,
median of 7 samples of 100 calls, wall-clock times from a single run:
- Source Sans 3 Regular, 1,614 characters: 0.0101 ms to 0.000004 ms
- a test font of 50,000 characters: 0.2347 ms to 0.000004 ms
The saving matters for fonts with large character maps, such as CJK
fonts.
2026-11-16 04:35:29 -08:00
dotCooCoo 52bbca2ecb Type: Show Similar Fonts lists a family with no numbers in common after the measured ones
FontLikeness::distance left out every number either face does not give,
so a family whose faces give none of them (static faces with no OS/2 or
post table) was 0 from every family, and Show Similar Fonts could list
it right after the chosen family, as an exact match. Faces that share
no number to compare are now f32::INFINITY apart, so such a family
comes after every family of its script group that shares one, and
families equally far keep their order. The order of measured families
does not change. This is VectorCraft's own rule.

Builds on #7983, which added Show Similar Fonts.
2026-11-16 03:47:51 -08:00
dotCooCoo cbf0ce838b Type: type on a path takes Justification's Desired spacing and glyph scaling
Each paragraph of type on a path now sets its glyphs at its Desired word
spacing, letter spacing and glyph scaling, as point and area type do. The
spaced glyphs feed the steps along the path, alignment, the hangs and the
overflow, so text after a wider gap starts further along and a right or
centered line is aligned by its spaced length. Minimum and Maximum are not
used, vertical type is not glyph scaled, and a list marker keeps its width.

This changes existing documents: type on a path whose paragraphs carry
non-default Desired values now spaces differently and can overflow where
it did not.

SVG export writes such type as outlines with a warning, since a
<textPath> places its characters at their own advances.

Docs: docs/mcp.md, docs/type-parity.md, docs/gaps.md,
docs/target-app-parity.md.
2026-11-15 23:59:19 -08:00
dotCooCoo a6c3ffe90f Type: text hyphenates in Bulgarian, Turkish and Russian, and in German, Polish, Portuguese and Italian with CRAFT_I18N_DIR
A run whose language is German, Polish, Portuguese or Italian (any region)
now breaks at that language's hyph-utf8 patterns from craft-proof, and a
Bulgarian, Turkish or Russian run at that language's syllable rules. The
paragraph's Hyphenation options and the Preferences exceptions apply as
before, and points that would split a grapheme are dropped.

For Bulgarian, Turkish and Russian, craft-proof hyphenates a word outside
the language's script as English. For German, Polish, Portuguese and
Italian it can also return points from its own heuristics. Those points
are refused, so a word outside its language's script stays whole.
German, Polish, Portuguese and Italian need craft-proof built with
CRAFT_I18N_DIR; without it they keep today's behavior. Other languages,
English and the eleven Indian languages are unchanged.
2026-11-15 23:01:31 -08:00
HassanKhan ee8c90b6f6 test(text): one tolerance for the Tsume blank-space branch and its movement check (#7821) 2026-11-16 11:19:34 +05:00
HassanKhan fe8cd6660e test(text): Tsume check takes nothing where a cluster has no blank space (#7821)
optical_kerning_keeps_the_tsume_of_a_letter_with_coloured_harakat also
runs on an installed Arabic face. In macOS's Arial (5.01.2x) the initial
beh and its fatha fill their whole cell, so Tsume rightly takes nothing,
but the test required it to move something. The installed-face check now
measures each cluster's blank space first: with some, Tsume must move the
glyphs; with none, it must move nothing. The test font stays strict.
2026-11-16 11:11:39 +05:00
BFlat b3c94280d4 Merge pull request #7974 from dotCooCoo/feat/composite-font-sample
Type: Composite Fonts' Show Sample draws the font picked with its metric lines
2026-11-16 10:36:14 +07:00
BFlat f9efd3ca0f Merge pull request #7983 from dotCooCoo/feat/font-menu-show-similar
Type: the font menu's Show Similar Fonts lists the families that look like a family first
2026-11-16 10:36:06 +07:00
BFlat 9a42e43640 Merge pull request #7915 from dotCooCoo/feat/glyphs-alternates-popup
Glyphs: a cell's corner triangle opens a pop-up of its glyph's alternates
2026-11-16 09:30:57 +07:00
dotCooCoo af67af91f6 Type: Show Similar Fonts reads the loaded faces once for the whole list
similar_families looked up each listed family's traits on its own, and
each look scanned every loaded face, so ordering the font menu took time
in the square of the families loaded. It now gathers the loaded faces'
traits in one pass and reads the scan's catalog once, and family_traits
uses the same helpers, so both give the same traits.
2026-11-15 17:24:30 -08:00
BFlat 5cb5a1895c Merge pull request #7869 from dotCooCoo/feat/kurikaeshi-moji-shori
Paragraph: Kurikaeshi Moji Shori draws a repeat mark that starts a line as the character it repeats
2026-11-16 08:12:54 +07:00
dotCooCoo 3d5a8afdbb Merge main into feat/font-menu-show-similar 2026-11-15 16:48:53 -08:00
BFlat 3e615f7c67 Merge pull request #7972 from dotCooCoo/feat/glyphs-show-opentype-categories
Glyphs: the Show menu lists the font's OpenType glyph categories
2026-11-16 06:56:16 +07:00
dotCooCoo 6c5229c851 Merge main into feat/kurikaeshi-moji-shori 2026-11-15 13:43:06 -08:00
dotCooCoo c26c1f3efd Type: the font menu's Show Similar Fonts lists the families that look like a family first
A ≈ button on a family's row in the font menus orders the listed families by
how alike they look to it: that family first, then the families that set the
same script (Japanese, Thai or neither), then the others, each group nearest
first. The Recent Fonts section is left out while the list is ordered this
way. A ≈ chip under the filters names the family and clears the order, with
that family still highlighted; closing the menu clears it too.

The measure is VectorCraft's own. Each face records its OS/2 PANOSE digits,
weight and width classes, x-height, cap height and average character width,
and its post italic angle; a named instance of a variable font takes its wght
and slnt settings. The system font scan reads the head table and the post
table's header besides the tables it read before, so installed families are
compared by the same numbers without loading them. A family is compared by its
face nearest an upright Regular, a number either face does not give is left
out, and a family of another kind counts as further away.

text.similarFonts {family, limit?} returns the same order, with errors for a
missing or non-string family, a family that is not available or not listed in
the font menus, and a limit that is not a whole number from 1 to 100000.
2026-11-15 13:31:36 -08:00
dotCooCoo 0a6343201f Tests: the repeat mark test font maps the combining voicing mark
The test font mapped ゝ, ゞ, ヽ and ヾ but not U+3099, so the cluster
ゝ U+3099 went to the first fallback face that has both characters.
Built with craft-fonts, that is a Japanese face, which drew the voiced
mark with its own glyph, and
kurikaeshi_moji_shori_draws_a_decomposed_voiced_mark_voiced failed.
The font now maps U+3099, so the cluster is shaped in the test font
with or without craft-fonts.
2026-11-15 13:30:02 -08:00
dotCooCoo 6f853810bf Type: Composite Fonts' Show Sample draws the font picked with its metric lines
Show Sample (Hide Sample when it shows) in Type > Composite Fonts... draws
the font picked in a line of sample text, with the first character of
each custom set added, through the renderer, so color and bitmap glyphs
keep their colors. Buttons beside it show or hide lines for the ICF box,
em box, baseline, cap height, highest ascent and lowest descent, highest
ascender and x-height, and Zoom draws it at 25% to 800% of 36 pt. The em
box and ICF box are the Kanji part's font's; the other lines measure the
faces the glyphs are drawn in, fallback faces included. Each line takes
its part's size, baseline and vertical scale, and Kana scaled at center,
as layout sets them.

ui.dialog.set takes sample, zoom and the seven line fields, and refuses a
zoom outside the menu or a line that is not true or false. FontFace gains
cap_height(), the estimate a face without an OS/2 cap height uses, beside
x_height().

Docs: docs/mcp.md, docs/type-parity.md, docs/target-app-parity.md.
2026-11-15 13:13:32 -08:00
dotCooCoo 1c95aa2b65 Glyphs: the Show menu lists the font's OpenType glyph categories
After Alternates for Current Selection, the Glyphs panel's Show menu
and panel menu list the categories the browsed font's GSUB features
give glyphs to: Ligatures, Swash, Stylistic Alternates, each stylistic
set by the font's name for it (else Set N), Small Caps, Ornaments,
Fractions and Figures. Choosing one shows that category's glyphs, the
characters first and then the glyphs no character maps. A font without
the chosen category shows Entire Font.

- text: FontFace::glyph_categories reads the single, alternate,
  multiple and ligature substitutions of each category's features,
  once per face, leaving out a substitution an earlier subtable of
  its lookup shadows, within a total glyph budget.
- engine: text.glyphCategories {family, style?} lists them.
- ui-egui: the Show menu and panel menu entries, with Ligatures,
  Ornaments and Figures rows in every catalog.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-15 12:56:14 -08:00