Skip to content

.ai import: stroked type in an envelope maps from its glyphs grown by half its stroke - #6535

Merged
bflatastic merged 1 commit into
storytold:mainfrom
jmverges:fix/3179-half-stroke-box
Nov 11, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
jmverges:fix/3179-half-stroke-box

Conversation

@jmverges

@jmverges jmverges commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Part of #3179. Follows #6508.

#6508 tries stroked type in an envelope with Distort Appearance on a second time, mapped from the type's bounds with strokes. For a stroke on the type's appearance, or on a group round it, those bounds reach as far as a miter join may at a corner: the miter limit times half the weight. In our files the drawn art maps from a smaller box, the glyphs grown by what the strokes paint along a side (half the weight of a centred stroke). On one design the bounds-with-strokes candidate is 13 times over the drawn-art threshold; the half-stroke box is at 0.19 of it.

The candidate now maps from that box (half_stroked_box):

  • type: its glyph outlines grown by the larger of its characters' stroke outset (the measure its bounds with strokes already use, with no miter allowance) and its appearance strokes' side_reach;
  • a group without a clipping path: its members' boxes grown by its own appearance strokes' side_reach;
  • anything else: its bounds with strokes, as before.

Character-stroke-only type maps from the same box as before, upright, turned or stretched.

How it was tested

  • ai::envelope::tests::stroked_type_is_tried_mapped_from_its_glyphs_grown_by_half_its_stroke (an appearance stroke with miter joins) and a_stroke_on_a_group_of_type_grows_the_box_by_half_its_weight fail with the full-reach box. type_with_a_character_stroke_is_tried_mapped_from_its_bounds_with_strokes pins down that character strokes keep their box, for upright, turned and stretched type. It failed against a first version that scaled character strokes by the transform's row sums.
  • With Rust 1.99.1 on Linux x86_64, on this change rebased on main at 99cbdf9: fmt, clippy, the workspace tests, doctests, layers and wasm pass. The other cargo xtask ci steps (no-bundled-fonts, pdf-deps, assets, brands, cursors, i18n-report) passed on the same change on top of .ai import: warps of type open as mesh envelopes on their saved grid #6508. After rebasing again on the latest main I re-ran fmt, clippy and cargo test -p vectorcraft-eps (1387 passed). As before, I skipped vectorcraft-text's tests::harakat::coloured_harakat_keep_kashida, which picks up the Arial installed here. vectorcraft-eps's wall-clock test many_tiling_patterns_and_spot_inks_read_in_linear_time timed out once under load in a full run, and passes alone.
  • Measured on 224 of our own garment files, used locally (never committed), against main with .ai import: warps of type open as mesh envelopes on their saved grid #6508: envelopes of type that open live go from 113 to 120 (of 203). All 7 are warps in one file. No file loses a live envelope.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm), apart from the one machine-specific vectorcraft-text test above.
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how).
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md (none added).

Summary by CodeRabbit

  • Bug Fixes
    • Improved the handling of stroked text in envelopes when importing .ai and EPS files. Text bounds now account for stroke weight and appearance strokes, including strokes on groups, helping preserve the expected envelope appearance.
  • Documentation
    • Updated import parity notes to describe how stroked text bounds are handled during envelope imports.

… half its stroke

With Distort Appearance, the stroked candidate for type in an envelope
mapped from the type's bounds with strokes, which for a stroke on the
type's appearance (or on a group round it) reach as far as a miter join
may at a corner, the miter limit times half the weight. In users' files
the drawn art maps from the glyphs grown by what the strokes paint along
a side: half the weight of a centred stroke. The candidate now uses that
box. Character strokes keep the measure the type's bounds with strokes
already give them (they have no miter allowance), and other objects in
the contents keep their bounds with strokes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Envelope import now calculates Distort Appearance bounds using glyph bounds expanded by visible stroke reach. Tests cover appearance strokes, character strokes under transforms, and strokes on groups containing text. Documentation describes the updated mapping.

Changes: Envelope stroke bounds

Layer / File(s) Summary
Calculate and apply half-stroke bounds
crates/eps/src/import/ai/envelope.rs, docs/file-format-parity.md, docs/target-app-parity.md
Envelope bounds use glyph bounds expanded by character-stroke outset or appearance-stroke side reach. Unclipped groups include their own stroke reach; other nodes retain stroked bounds. Tests cover miter joins, transformed character strokes, and group appearance strokes. Documentation describes the updated envelope mapping.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: dotcoocoo

Merge Risk: Low · up to 6701a

The import change has no confirmed functional blocker, but its required roadmap update is missing. It is mergeable with that follow-up tracked.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: mapping stroked type in an envelope from glyph bounds grown by half the stroke.
Docstring Coverage Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is complete and follows the required template. It explains the change and rationale, documents targeted tests and broader validation, reports known environment-specific exceptions, and…
Full details: Docstring Coverage

Explanation

Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 7 functions across 1 files. (2 skipped: 2 unsupported.)

Full details: Description check

Explanation

The description is complete and follows the required template. It explains the change and rationale, documents targeted tests and broader validation, reports known environment-specific exceptions, and addresses every checklist item.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

LanguageTool

docs/target-app-parity.md

LanguageTool checks are incomplete because the per-file request limit of 5 was reached. Remaining text was skipped; findings from completed checks are retained.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8b6c744 and 6701a1f.

Files selected for processing: 3

  • crates/eps/src/import/ai/envelope.rs
  • docs/file-format-parity.md
  • docs/target-app-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@bflatastic
bflatastic merged commit 7771355 into storytold:main Nov 11, 2026
7 checks passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thanks @jmverges! It passed its CI checks.

bflatastic pushed a commit that referenced this pull request Nov 13, 2026
…what it paints (#6824)

With Envelope Options > Distort Appearance on, the import tries type in an
envelope mapped from its glyphs, and from its glyphs grown by half its
strokes' weight (#6535), on its own warp and on its saved grid. In users'
files the drawn art of some stroked type maps from the box of what the type
paints instead, which differs from those where:

- the type has sharp corners at its edges (slanted stems, pointed feet) and
  miter joins: the miter tip pokes out past half the weight, as far as the
  miter limit lets it, though not as far as the bounds with strokes allow
  (a miter at every corner);
- a stroke carries a Transform effect that moves it (a drop shadow): the
  moved stroke paints past the glyphs on that side;
- a glyph holds a contour of zero length at its edge, which paints nothing:
  the glyphs' box counts it.

Such an envelope failed the drawn-art check and kept its drawn art.

After every way it was tried before, and before a grid moved onto its drawn
art, the envelope is now also tried mapped from what its type paints, where
that box is another: its glyph outlines with their fills and strokes baked
as the envelope bakes them under Distort Appearance (geometry effects
applied), each piece measured by its visual bounds. Those are exact for
miter joins (a tip counts where the limit keeps it) and round joins, and an
upper bound for bevel joins, miters the limit cuts, width profiles and
square-capped dashes. Effects on the type object itself are left out, as
VectorCraft applies them after the envelope bends the type. Groups round
type and other objects in the contents are measured as before. A side
within 1e-4 pt of another box's counts as that side, so a box measured two
ways isn't tried twice. The box is measured only when its try comes and a
check is left for it, and once for an envelope: on a synthetic file of 256
envelopes of 2,000 characters each the import takes 13.3 s, as before,
where measuring it up front took 14.7 s.

On 224 of our own files (used locally, never committed), envelopes of type
that open live go from 154 in 45 files to 161 in 50, none fewer in any
file; no file changes whether it opens from its layers or its PDF part.

Tests: ai::envelope::tests::
mitred_type_is_also_tried_mapped_from_what_its_stroke_paints_miter_tips_included,
type_with_a_mitred_character_stroke_is_also_tried_mapped_from_what_it_paints,
a_stroke_moved_by_a_transform_effect_counts_where_it_paints,
round_joined_type_is_not_tried_twice_for_the_same_box,
a_contour_of_zero_length_paints_nothing,
a_side_within_the_slack_of_the_geometric_box_is_that_side, and
tests_native::a_warp_of_mitred_type_maps_from_what_its_stroke_paints_where_its_drawn_art_does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants