Tight and Through wrapping follow the object's outline (#354) (#360)

Text now wraps around a Tight or Through object's shape instead of its
bounding box. The outline is the object's wrap polygon (wp:wrapPolygon,
in the 21600-unit space of its frame) when it has one; otherwise it is
derived: a shape's geometry (ellipse, triangle, star, heart... flattened),
the convex hull of a picture's opaque pixels (alpha threshold on a coarse
grid, at most 64 points), or the rectangle. The outline turns and flips
with the object, keeps the left/right and top/bottom distances from text,
and is built once per placed object; each line asks it which stretches of
its band it covers. Through also lets text into gaps inside the outline
that are wide enough.

DOCX reads and writes wp:wrapPolygon (with edited) for wrapTight and
wrapThrough; a shape without one gets its outline written, other objects
their rectangle, since the schema requires a polygon. Square, top and
bottom, behind and in front of text are unchanged.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
Valentin Klein
2026-10-11 12:10:48 -04:00
committed by GitHub
co-authored by Claude Opus 5.5 Brandon Thomas
parent 34511263a7
commit 860f4ca260
19 changed files with 819 additions and 47 deletions
Generated
+1
View File
@@ -5141,6 +5141,7 @@ dependencies = [
name = "wordcraft-layout"
version = "0.5.0"
dependencies = [
"image",
"js-sys",
"log",
"serde",