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
Change text
signature to positions, text = text
#2020
Conversation
Wouldn't a string that mix stretched and unstreched characters cause the same problem (i.e. mixing stuff that were not planned to be mixed)? If not I can think about how to do that properly. |
We have scale, rotation and translation as part of the per character interface so stretching is fine. The bad part is that it's currently using two plot types. Iirc unicode also has a section of characters that are undefined and meant to be overwritten for stuff like this. I think with how GLMakie works we can even reproduce lines one to one as a character. |
The way it works right now is that a string including stylistic attributes is translated to a GlyphCollection and that is then rendered. So it's in principle fine to put a long underscore character in there instead of the separate line elements you're currently using. That would just simplify the implementation but I can imagine that the long underscore could look blurry at the edges in glmakie, due to the bitmap |
I played around a bit with this now. The characters I was thinking of are private use character: https://www.unicode.org/faq/private_use.html. I guess it's not generally safe to use them like this, but we can (and should anyway) restrict ourselves to a font that doesn't use them. My basic idea is to manually create signed distance fields for vline and hline and insert them into the texture atlas linked against characters in the private use section. During latex layouting we can then replace VLine and HLine with the corresponding characters, set up the metrics and be more or less done with it on the GLMakie side. Without thinking carefully if all my scales make sense I get this: scene = Scene()
text!(scene, L"\frac{1}{2}", textsize = 200, align = (:center, :center)) The bit of fuzz on the left is texture bleed I believe. I think that just needs a pixel of padding to be fixed. The size of the sdf in the atlas is |
711243d
to
4e49eb3
Compare
64ad31b
to
f321813
Compare
Missing reference imagesFound 1 new images without existing references. |
Missing reference imagesFound 1 new images without existing references. |
2a331fd
to
3035d61
Compare
Missing reference imagesFound 1 new images without existing references. |
Missing reference imagesFound 1 new images without existing references. |
Compile Times benchmarkNote, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than master. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running: using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(display(fig))
|
Missing reference imagesFound 1 new images without existing references. |
Was there a problem with using underscores as lines? |
Yes they didn't render well in GLMakie at small sizes.. |
Description
Fixes #1468, #1138
The
text
function has an unusual signature compared to the other plotting functions, it takes the string(s) as its positional arg and the positions as a keyword arg. That means positions have to be passed in a specific way (usually as Point or Vector{Point}) because the conversion pipeline that usually applies for PointBased does not apply to attributes. This additionally causes problems for AlgebraOfGraphics, as the expectedmapping(x, y, text = text)
doesn't work, instead one has to construct a vector of points manually.Another side effect is that a text plot initialized with a String cannot be changed to a LaTeXString later, as the signature of
Text
is fixed toString
at that point and any subsequentLaTeXString
will be converted to"$content$"
.This PR changes the default args for
text
such that it's called withtext(positions, text = strings)
. It has the conversion traitPointBased
now so all expected signatures for passing x and y work. All the old signatures still exist and reroute to that new definition. The lastText
in the chain is still the one receiving a vector ofGlyphCollection
s, so the backends hopefully don't need to change much (GLMakie has some problem withgl_convert
right now).TODO
PointBased
conversion traitBlock
s use the new format internally (only Axis so far)Line elements from MathTeXEngine are currently broken because they were implemented with a separate LineSegments plot object and it's not clear how that should work when switching back and forth between String and LaTeXString args. An option could be to render lines as stretched line chars instead, which would mean that no separate LineSegments shenanigans would be needed. (cc @Kolaru)Type of change
Delete options that do not apply:
Checklist