-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
jk/glyph indices #2139
jk/glyph indices #2139
Conversation
jkrumbiegel
commented
Jul 14, 2022
- switch from chars to Culong glyph indices
- save glyph indices in glyphcollection
- draw glyphs by index in cairomakie
- remove new path
- add stub for MathTeXEngine
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 the base branch. 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))
|
@jkrumbiegel It doesn't seem to work, after a quick (and terribly hacky) test. Despite passing the correct font and the correct index in the stub you provide, nothing appear when I use the I tested it by using glyph index 5930 in the NewCMMath-Regular font (from the NewComputerModern family), which should contain an integral symbol, as confirmed by http://fontdrop.info : Unfortunately I couldn't quite understand how to select font in Cairo directly, so I couldn't test if it works in pure Cairo.jl. I'll have another try tomorrow. |
ccall((:cairo_show_glyphs, Cairo.libcairo), | ||
Nothing, (Ptr{Nothing}, Ptr{CairoGlyph}, Cint), | ||
ctx.ptr, cg, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case you might use cairo_show_text_glyphs, which allow text to be highlighted. We had glyph support earlier but AFAIK the text highlighting issue is why we switched away from it. It would also allow the whole GlyphCollection to be rendered at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point I don't have the utf 8 anymore and it's not guaranteed that there is any, as for Mathtexengine
For me it worked when I used the computer modern font and just spliced in the value function show_glyph(ctx, glyph::Culong, x, y)
cg = Ref(CairoGlyph(5930, x, y))
ccall((:cairo_show_glyphs, Cairo.libcairo),
Nothing, (Ptr{Nothing}, Ptr{CairoGlyph}, Cint),
ctx.ptr, cg, 1)
end cm = Makie.FTFont("~/.julia/packages/MathTeXEngine/XFmQJ/assets/fonts/NewComputerModern/NewCMMath-Regular.otf")
s = Scene(camera = campixel!)
text!(s, 100, 100, text = "hi", font = cm)
s So it's definitely possible accessing the glyph. However, what I first did didn't work, returning 5930 from the place where I introduced the error for you. But I assume now that this was because MathTeXEngine actually selected the wrong font for the expression that I did, which was just |
Okay it is on me, I asked too much from Revise. It seems to be all good, and I can work on setuping MathTeXEngine to work with that. |
Great, I think it should be sufficient that TeXChar carries the Culong and then I can build it in from Makie's side. Would need to be a minor version change anyway right? So no compat problem until Makie is ready to integrate |
Yes, on MathTeXEngine side it is breaking, since the font will slightly change as well as the API of TeXChar (slightly). |
I'm making some changes to FreeTypeAbstraction in this PR, you can probably just use the functions there for getting glyph indices instead of duplicating that on your side JuliaGraphics/FreeTypeAbstraction.jl#72 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With these two changes, it is compatible with Kolaru/MathTeXEngine.jl#67
The MathTeXEngine PR will require a bit more work to make sure everything work as it should, but the API shouldn't change.
Co-authored-by: Benoît Richard <[email protected]>
Ok @Kolaru I could use your branch locally, the integral for example looks like this: Seems like there's some wrong boundingbox information on that though? Anyway, you can further test your changes with this branch, then when you tag MathTeXEngine it should be picked up by this PR. I've already bumped compat. |
Hm currently the only thing still problematic is that the word wrapping checks for |
Actually I'm not sure if word wrapping makes much sense for MathTeXEngine at all.. |
I think it does. If you have some formulas you may want other text as latex strings for visual cohesion.
Can't you just compare to |
True, didn't think this way around. Hm yeah maybe, I haven't used latexstrings much and especially not at sizes that require word wrapping. |