mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-22 02:15:24 +01:00
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