Add support for alignment-baseline and dominant-baseline#68
Open
djberg96 wants to merge 1 commit intoapache:mainfrom
Open
Add support for alignment-baseline and dominant-baseline#68djberg96 wants to merge 1 commit intoapache:mainfrom
djberg96 wants to merge 1 commit intoapache:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Courtesy of Claude Opus 4.6. I don't know Java very well or this project's details, but it's used by Vassal under the hood, so I would like to have support for these attributes.
https://issues.apache.org/jira/browse/BATIK-1306
If there's any updates or additions you would like to see, just let me know and I'll throw Claude at it.
From Claude:
Summary
Batik already had the CSS parsing infrastructure for alignment-baseline and dominant-baseline (property constants, value managers, and engine registration), but the properties were never propagated through the text rendering pipeline. Here's what was added:
GVTAttributedCharacterIterator.java:313-322
Added two new TextAttribute constants — DOMINANT_BASELINE and ALIGNMENT_BASELINE — to carry baseline values through the attributed character iterator.
TextUtilities.java:289-323
Added convertDominantBaseline() and convertAlignmentBaseline() converter methods that read the computed CSS values and return the baseline identifier string (or null for default/auto values).
SVGTextElementBridge.java
Added constant aliases for DOMINANT_BASELINE and ALIGNMENT_BASELINE
Added both CSS property indices to SVGTextElementBridge.java:719-720 so changes trigger text re-layout
Added reading of both properties in SVGTextElementBridge.java:1617-1628 to inject them into the ACI attribute map
GlyphLayout.java
Added constant aliases and registered both attributes in the runAtts set for run-break detection
GlyphLayout.java:1114-1115 from the ACI during explicit glyph layout
GlyphLayout.java:1242-1253 using dominant-baseline minus alignment-baseline and applies the result as a glyph position adjustment (horizontal offset for vertical text, vertical offset for horizontal text)
Added GlyphLayout.java:2077-2127 helper that maps SVG baseline names to vertical offsets using font metrics: alphabetic=0, central=(ascent−descent)/2, middle≈strikethroughOffset, hanging≈80% ascent, mathematical≈strikethroughOffset+10% ascent, ideographic=−descent, text-before-edge/text-top=ascent, text-after-edge/text-bottom=−descent