Skip to content

Fix superscript and subscript baseline rendering - #32

Open
Rizzz7 wants to merge 1 commit into
JabRef:mainfrom
Rizzz7:fix-baseline-offset-rendering
Open

Rizzz7 wants to merge 1 commit into
JabRef:mainfrom
Rizzz7:fix-baseline-offset-rendering

Conversation

@Rizzz7

@Rizzz7 Rizzz7 commented Nov 7, 2026

Copy link
Copy Markdown

Summary

  • preserve superscript/subscript vertical positioning in RichTextRenderer attributes
  • apply the custom baseline offset to rendered RichTextArea text nodes
  • add model and JavaFX regression coverage

Validation

  • ./gradlew test --no-daemon
  • ./gradlew guiTest --no-daemon
  • ./gradlew guiTest --tests org.jabref.htmltonode.HtmlRichTextAreaTest --no-daemon
  • git diff --check

The offset is scaled from the effective font size and normal text explicitly carries zero to avoid stale translation on recycled nodes.

Copilot AI balanced review requested due to automatic review settings November 7, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Restore superscript and subscript baselines in RichTextArea

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Preserve font-size-scaled baseline offsets in styled text attributes for superscript and subscript
 runs.
• Apply offsets to rendered text nodes, including zero for normal runs to prevent stale positioning.
• Add model and JavaFX regression tests for offsets and related styling.
Diagram

graph TD
    A["Parsed inline styles"] --> B["RichTextRenderer"] --> C["Styled text model"] --> D["HtmlRichTextArea"] --> E["Text nodes"]
Loading
High-Level Assessment

Keep the custom character attribute and segment handler: they fit the existing RichTextArea styling extension point and use the same baseline ratios as FxRenderer. A separate rendering path would add complexity without addressing the model-to-node handoff.

Files changed (4) +100 / -1

Bug fix (2) +15 / -1
HtmlRichTextArea.javaApply baseline offsets through a segment handler +2/-0

Apply baseline offsets through a segment handler

• Registers a handler for the new baseline attribute that sets each rendered segment node's vertical translation.

src/main/java/org/jabref/htmltonode/rich/HtmlRichTextArea.java

RichTextRenderer.javaCarry scaled baseline offsets in text-run attributes +13/-1

Carry scaled baseline offsets in text-run attributes

• Adds a character attribute for baseline position and computes its value from the run's effective font size. Normal runs explicitly receive zero, so reused nodes can return to the baseline.

src/main/java/org/jabref/htmltonode/rich/RichTextRenderer.java

Tests (2) +85 / -0
HtmlRichTextAreaTest.javaCheck rendered subscript and superscript node positions +52/-0

Check rendered subscript and superscript node positions

• Adds a JavaFX test that lays out a RichTextArea and verifies positive subscript and negative superscript text-node translations.

src/test/java/org/jabref/htmltonode/HtmlRichTextAreaTest.java

RichTextRendererTest.javaCover baseline attributes and adjacent styling behavior +33/-0

Cover baseline attributes and adjacent styling behavior

• Tests font-size-scaled subscript and superscript offsets and zero offset on normal text. Also checks inline font attributes and paragraph spacing around superscript text.

src/test/java/org/jabref/htmltonode/RichTextRendererTest.java

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1)

Grey Divider


View low (1)
Informational
1. Docs still say baseline shifts are lost 🐞 Bug
Description
The new BASELINE_OFFSET attribute renders subscript and superscript shifts, but the README and
RichTextRenderer class documentation still list lost baseline shifts as an interim gap. Readers
choosing a renderer, or maintainers reviewing the remaining gaps, are therefore told this fixed
behavior is unsupported.
Code

src/main/java/org/jabref/htmltonode/rich/RichTextRenderer.java[295]

+        builder.set(BASELINE_OFFSET, baselineOffset(style.verticalPosition(), fontSize));
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The rich renderer now applies baseline shifts, but its public documentation still says it loses them.
## Fix Focus Areas
- README.md[152-156]
- src/main/java/org/jabref/htmltonode/rich/RichTextRenderer.java[29-33]
## Recommended Fix
Remove the subscript/superscript baseline-shift item from both lists of interim gaps while retaining the unresolved limitations.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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