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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix line spacing for sub/superscripts #392

Merged
merged 2 commits into from
Apr 18, 2020

Conversation

bjarthur
Copy link
Member

fixes this problem:

julia> using Compose
[ Info: Precompiling Compose [a81c6b42-2e10-5240-aca2-a61377ecd94b]

julia> img = SVG("text.svg", 400px, 400px)
SVG(105.82010582010584mm, 105.82010582010584mm, IOStream(<file text.svg>), nothing, "img-a0c68168", 0, Compose.SVGPropertyFrame[], Dict{Type,Union{Nothing, Compose.Property}}(), OrderedCollections.OrderedDict{Compose.ClipPrimitive,String}(), Tuple{Compose.FormPrimitive,String}[], Set(AbstractString[]), false, true, "text.svg", true, "", false, 0, Set(AbstractString[]), Set(Tuple{AbstractString,AbstractString}[("Snap.svg", "Snap")]), AbstractString[], false, :none, ())

julia> c = compose(compose(context(),
                                  text(150px, 200px,
                                       "hello &amp; goodbye\nFoo<sub>Sub</sub>Bar<sup>Sup</sup>\nA Third Line\nFoo<sub>Sub</sub>Bar<sup>Sup</sup>Pooh\nAFourth Line\nA Fifth Line")),
                          fill("tomato"))
Context(Measures.BoundingBox{Tuple{Measures.Length{:w,Float64},Measures.Length{:h,Float64}},Tuple{Measures.Length{:w,Float64},Measures.Length{:h,Float64}}}((0.0w, 0.0h), (1.0w, 1.0h)), nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.TextPrimitive{Tuple{Measures.Length{:mm,Float64},Measures.Length{:mm,Float64}},Rotation{Tuple{Measures.Length{:w,Float64},Measures.Length{:h,Float64}}},Tuple{Measures.Length{:mm,Float64},Measures.Length{:mm,Float64}}}}(Compose.TextPrimitive{Tuple{Measures.Length{:mm,Float64},Measures.Length{:mm,Float64}},Rotation{Tuple{Measures.Length{:w,Float64},Measures.Length{:h,Float64}}},Tuple{Measures.Length{:mm,Float64},Measures.Length{:mm,Float64}}}[Compose.TextPrimitive{Tuple{Measures.Length{:mm,Float64},Measures.Length{:mm,Float64}},Rotation{Tuple{Measures.Length{:w,Float64},Measures.Length{:h,Float64}}},Tuple{Measures.Length{:mm,Float64},Measures.Length{:mm,Float64}}}((39.68253968253969mm, 52.91005291005292mm), "hello &amp; goodbye\nFoo<sub>Sub</sub>Bar<sup>Sup</sup>\nA Third Line\nFoo<sub>Sub</sub>Bar<sup>Sup</sup>Pooh\nAFourth Line\nA Fifth Line", Compose.HLeft(), Compose.VBottom(), Rotation{Tuple{Measures.Length{:w,Float64},Measures.Length{:h,Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm))], Symbol(""))]), List([Compose.Property{Compose.FillPrimitive}(Compose.FillPrimitive[Compose.FillPrimitive(RGBA{Float64}(1.0,0.38823529411764707,0.2784313725490196,1.0))])]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(""))

julia> draw(img, c)
false

Screen Shot 2020-03-24 at 8 40 36 PM

@codecov-io
Copy link

Codecov Report

Merging #392 into master will decrease coverage by 0.04%.
The diff coverage is 30.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #392      +/-   ##
==========================================
- Coverage   43.05%   43.01%   -0.05%     
==========================================
  Files          18       18              
  Lines        3226     3229       +3     
==========================================
  Hits         1389     1389              
- Misses       1837     1840       +3
Impacted Files Coverage Δ
src/svg.jl 73.85% <100%> (-0.09%) ⬇️
src/fontfallback.jl 53.57% <28.57%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1749b92...55ddc75. Read the comment docs.

@bjarthur
Copy link
Member Author

bjarthur commented Apr 8, 2020

this might be good to go. output now looks like this:

Screen Shot 2020-04-08 at 11 46 28 AM

moreover, the output is now identical irrespective of whether Fontconfig is imported or not. one caveat here is that to make them the same, the vertical shift specified by pango is now ignored because it is in absolute points, and seemingly it doesn't know the font size at that line in the code. so i changed it to use the same relative shift used by fontfallback, which is in "em" units.

also, to make sure that the output remains the same with or without Fontconfig i refactored the unit tests to run each example in a separate julia process. hard to test for this in the same session as once you've imported Fontconfig you can't unimport it.

@bjarthur bjarthur changed the title WIP: fix SVG line spacing for sub/superscripts fix SVG line spacing for sub/superscripts Apr 8, 2020
@bjarthur bjarthur changed the title fix SVG line spacing for sub/superscripts fix line spacing for sub/superscripts Apr 18, 2020
@bjarthur bjarthur merged commit 2cba77d into GiovineItalia:master Apr 18, 2020
@bjarthur bjarthur deleted the bja/linespacing branch April 18, 2020 12:35
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