Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2813 Improve preview, svg/pdf export of node's label's box #2846

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nathanal
Copy link

@nathanal nathanal commented Aug 30, 2023

Description

#2813 Improve preview, svg/pdf export of node's label's box

  • Remove text outline's fill (avoids doubling text fill) (svg)
  • Boxes no longer have solid fill, but are stroked (svg, pdf)
  • Boxes, labels use transparency (svg)
  • Non-zero outline size no longer affects box stroke (preview)
  • Fix first box size by setting an explicit stroke (preview)
  • Box has consistent sharp corners (preview)
  • Box size accounts for outline size (all)
  • Box size accounts for text's descenders (pdf)
  • Box matches label position and looks roughly centered (svg) dominant-baseline is unsupported by batik at the moment: https://xmlgraphics.apache.org/batik/status.html

Untouched side issues

I stopped at good enough, but hoping this comes in handy for others:

  • dominant-baseline:central works fine without the
    extra displacement (done in code). However the bbox
    ignores it (https://xmlgraphics.apache.org/batik/status.html).
    We could probably use a kludge with dummy text to
    calculate the correct box positioning, but may face
    issues with different fonts and non-latin characters.
  • The issue noted the different box size in Preview,
    this can't be replicated in svg without font metrics.
    This can probably be fixed by kludge or finding the metrics.
    Side effect: the Preview box has fixed-height,
    which looks better in the general case.
  • svg text outline is a separate object, but could just
    be the stroke of existing text (with paint-order changed).
    The outline group is part of an API so I've left it.
  • Padding the label box (must deal with scaling).
  • Label box is not centered, possibly just rounding error? (preview)
  • viewBox cuts off part of label outline/box (svg)
  • Box not using alpha (pdf)

I've edited a few public functions (renderG2D, etc.) to add the boxWidth.
Not sure if there are implications to that, the functions appear
not be called elsewhere and it isn't in API code.

I haven't fully fixed #2813, they also mention the unfixed issues re: box size

They requested dominant-baseline: text-top, but I just removed it because batik
doesn't support it and I don't know what happens with non-latin characters and because
with the labels I did test, there was no different in Inkscape and firefox.

Test cases

Following cases tested in labels_outline.zip:

  • A couple node sizes
  • outline size at 0, 10, and a couple at a larger value
  • proportional size or not proportional
  • fixed node border size

Checklist

  • Merged with master beforehand

Added tests?

  • 馃憤 yes
  • 馃檯 no, because they aren't needed
  • taking this off my todo list atm, but if necessary I will look into it (or I find time to do it). I've spent too long failing to figure out how to run the existing tests (eventually found mvn -P enableTests, I've been searching in modules instead of the root pom.xml 馃う). huh, I can't think of a test that isn't fragile to minor changes and doesn't involve parsing the output or doing a comparison to a reference bitmap.

Added to documentation?

  • 馃憤 README.md
  • 馃憤 API Changes
  • 馃憤 Additional documentation in docs
  • 馃憤 Relevant code documentation
  • 馃檯 no, because they aren鈥檛 needed

- Remove text outline's fill (avoids doubling text fill) (svg)
- Boxes no longer have solid fill, but are stroked (svg, pdf)
- Boxes, labels use transparency (svg)
- Non-zero outline size no longer affects box stroke (preview)
- Fix first box size by setting an explicit stroke (preview)
- Box has consistent sharp corners (preview)
- Box size accounts for outline size (all)
- Box size includes descenders (y,g,p, etc) (pdf)
- Box matches label position and looks roughly centered (svg)
  dominant-baseline is unsupported by batik at the moment:
  https://xmlgraphics.apache.org/batik/status.html
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.

SVG export of label box fails: solid fill and label misalligned
1 participant