You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve vertical text alignment of OxyPlot.SvgExporter #1531
It looks like the Skia svg exporter doesn't touch the dominant-baseline alignment, which is the svg parameter that has little browser support. It 'defaults' to baseline, which is a problem, because the Svg exporter has no idea where this is (MeasureText only tells it the height). This means the best we can do is to 'guess' where the baseline is (e.g. ~1/4 of the way up) unless we extend some interfaces.
An implementation of this 'just sort of guess where the baseline might be' approach is implemented in 6790236 and produces results like these when using ImageSharp for text measurement.
That commit also does a few other things:
Adds an ImageSharp based Svg exporter
Changes everything to use the SVG vertical text workaround by default, since support for dominant-baseline is extremely limited.
Changes multi-line support in various places to split on the regex "\r?\n" rather than "\r\n"
I'll wait until the nightmare inducing ImageSharp changes have been pulled/rejected/whatever before I add a PR for any of this, and will probably break it up into separate PRs (assuming the descent kludge is acceptable at least for the time being).
While I'm typing, I noticed that the PortableDocumentFont stuff doesn't add gaps between lines (which explains some of the deficiencies in the SvgRenderContext I lazily didn't fix last time round).
It 'defaults' to baseline, which is a problem, because the Svg exporter has no idea where this is (MeasureText only tells it the height). This means the best we can do is to 'guess' where the baseline is (e.g. ~1/4 of the way up) unless we extend some interfaces.
Could we improve this by overriding DrawText in an e.g. ImageSharp-based SvgRenderContext implementation? There we have access to more sophisticated text measurements and should be able to properly align the text using the baseline only, right?
@Jonarw yeah, good idea. I keep thinking we'd have to modify IRenderContext to do this properly, but there's nothing stopping us doing Svg specific work as you suggest.
Activity
Improve OxyPlot.SvgRenderContext text rendering (oxyplot#1531)
VisualMelon commentedon May 6, 2020
It looks like the Skia svg exporter doesn't touch the
dominant-baselinealignment, which is the svg parameter that has little browser support. It 'defaults' to baseline, which is a problem, because the Svg exporter has no idea where this is (MeasureTextonly tells it the height). This means the best we can do is to 'guess' where the baseline is (e.g. ~1/4 of the way up) unless we extend some interfaces.An implementation of this 'just sort of guess where the baseline might be' approach is implemented in 6790236 and produces results like these when using ImageSharp for text measurement.
That commit also does a few other things:
I'll wait until the nightmare inducing ImageSharp changes have been pulled/rejected/whatever before I add a PR for any of this, and will probably break it up into separate PRs (assuming the descent kludge is acceptable at least for the time being).
While I'm typing, I noticed that the PortableDocumentFont stuff doesn't add gaps between lines (which explains some of the deficiencies in the SvgRenderContext I lazily didn't fix last time round).
Jonarw commentedon May 8, 2020
Could we improve this by overriding
DrawTextin an e.g. ImageSharp-basedSvgRenderContextimplementation? There we have access to more sophisticated text measurements and should be able to properly align the text using the baseline only, right?VisualMelon commentedon May 8, 2020
@Jonarw yeah, good idea. I keep thinking we'd have to modify
IRenderContextto do this properly, but there's nothing stopping us doing Svg specific work as you suggest.Improve OxyPlot.SvgRenderContext text rendering (oxyplot#1531)
Improve OxyPlot.SvgRenderContext text rendering (oxyplot#1531)
Improve OxyPlot.SvgRenderContext text rendering (oxyplot#1531)
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1554, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1554, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1554, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…
Overhaul text arrangement and trimming (oxyplot#1531, oxyplot#1551, o…