-
-
Notifications
You must be signed in to change notification settings - Fork 801
Shape outside support #2668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Shape outside support #2668
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,4 @@ | |
| /docs/_build | ||
| /pytest_cache | ||
| /tests/draw/results | ||
| /venv | ||
| /venv | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -846,3 +846,85 @@ form fields as PDF form fields (supported for text inputs, check boxes, text | |
| areas, and select only). | ||
|
|
||
| The ``accent-color`` property is **not** supported. | ||
|
|
||
| .. _CSS Basic User Interface Module Level 3/4: https://www.w3.org/TR/css-ui-4/ | ||
|
|
||
| CSS Shapes Module Level 1 | ||
| +++++++++++++++++++++++++ | ||
|
|
||
| The `CSS Shapes Module Level 1`_ "defines the ``shape-outside`` property | ||
| that controls how exclusion areas are computed around floated elements, | ||
| enabling text to wrap around complex shapes rather than just rectangular boxes." | ||
|
|
||
| WeasyPrint supports the following features: | ||
|
|
||
| **Box keywords** for ``shape-outside``: | ||
|
|
||
| - ``none`` (default) | ||
| - ``margin-box`` | ||
| - ``border-box`` | ||
| - ``padding-box`` | ||
| - ``content-box`` | ||
|
|
||
| **Basic shape functions**: | ||
|
|
||
| - ``circle()`` with radius keywords (``closest-side``, ``farthest-side``), | ||
| explicit lengths/percentages, and position values | ||
| - ``ellipse()`` with radius keywords, explicit lengths/percentages, | ||
| and position values | ||
| - ``polygon()`` with percentage and length coordinates, and fill rules | ||
| (``nonzero``, ``evenodd``) | ||
| - ``inset()`` with 1-4 offset values and optional ``round`` for border-radius | ||
|
|
||
| **Shape modifiers**: | ||
|
|
||
| - ``shape-margin`` property to expand the exclusion area by a specified amount | ||
| - Reference box combinations (e.g., ``circle(50%) border-box``) | ||
|
|
||
| **Image-based shapes**: | ||
|
|
||
| - ``url()`` image-based shapes using the image's alpha channel | ||
| - ``shape-image-threshold`` property to define the alpha threshold (0.0-1.0) | ||
| for extracting the shape from an image | ||
|
|
||
| The following features are **not** supported: | ||
|
|
||
| - ``path()`` function | ||
|
|
||
| Example usage: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don’t have many examples in this page, we prefer to keep links to specifications, you can remove this part. |
||
|
|
||
| .. code-block:: css | ||
|
|
||
| .float-circle { | ||
| float: left; | ||
| width: 200px; | ||
| height: 200px; | ||
| shape-outside: circle(50%); | ||
| shape-margin: 10px; | ||
| } | ||
|
|
||
| .float-polygon { | ||
| float: right; | ||
| width: 150px; | ||
| height: 150px; | ||
| shape-outside: polygon(0 0, 100% 0, 100% 100%); | ||
| } | ||
|
|
||
| .float-inset { | ||
| float: left; | ||
| width: 200px; | ||
| height: 200px; | ||
| shape-outside: inset(10px 20px 10px 20px round 15px); | ||
| } | ||
|
|
||
| /* Image-based shape using alpha channel */ | ||
| .float-image { | ||
| float: left; | ||
| width: 200px; | ||
| height: 200px; | ||
| shape-outside: url('shape-mask.png'); | ||
| shape-image-threshold: 0.5; | ||
| shape-margin: 10px; | ||
| } | ||
|
|
||
| .. _CSS Shapes Module Level 1: https://drafts.csswg.org/css-shapes/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,25 @@ Changelog | |
| ========= | ||
|
|
||
|
|
||
| Unreleased | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We write the Changelog when the release is ready, you can remove this change. |
||
| ---------- | ||
|
|
||
| Features: | ||
|
|
||
| * Implement CSS Shapes Level 1 specification (``shape-outside`` property): | ||
|
|
||
| - Support for basic shape functions: ``circle()``, ``ellipse()``, ``inset()``, ``polygon()`` | ||
| - Support for ``shape-margin`` property to add spacing between shapes and text | ||
| - Support for reference box keywords: ``margin-box``, ``border-box``, ``padding-box``, ``content-box`` | ||
| - Support for ``url()`` image-based shapes using alpha channel extraction | ||
| - Support for ``shape-image-threshold`` property to control alpha threshold | ||
| - Text flows naturally around floated elements with custom shapes | ||
|
|
||
| Documentation: | ||
|
|
||
| * Add CSS Shapes Level 1 documentation to API reference | ||
|
|
||
|
|
||
| Version 68.0 | ||
| ------------ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change this newline. 😄