Skip to content

add tex_annotation!()#43

Open
Moelf wants to merge 4 commits intoMakieOrg:masterfrom
Moelf:master
Open

add tex_annotation!()#43
Moelf wants to merge 4 commits intoMakieOrg:masterfrom
Moelf:master

Conversation

@Moelf
Copy link

@Moelf Moelf commented Feb 3, 2023

julia> using CairoMakie, MakieTex

julia> MakieTeX.CURRENT_TEX_ENGINE[] = `tectonic`

julia> function main()
           f,a,_ = plot(1:3, 1:3)
           MakieTeX.tex_annotation!(a, L"\sqrt{s} = 13~\text{TeV}", 1.5, 1.5;
           scale_factor=2)

           MakieTeX.tex_annotation!(a, L"\sqrt{s} = 13~\text{TeV}", 2.5, 2.5;
           mainfont="DejaVu Sans",
           scale_factor=2.5)

           MakieTeX.tex_annotation!(a, L"\sqrt{s} = 13~\text{TeV}", 1.5, 1.4;
                  mathfont="Nimbus Sans",
                  scale_factor=2)
           CairoMakie.save("/tmp/jl_onm7cZSLiJ.png", f)
       end

image

for #36

@Moelf
Copy link
Author

Moelf commented Feb 3, 2023

user needs to have font installed, on linux, check fc-list

Copy link
Member

@asinghvi17 asinghvi17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty cool! I would prefer we go through the to_plottable_cachedtex pipeline here, and make the mathfont etc changes there, since there is already a lot of logic there surrounding color, fontsize, line spacing, etc.

Comment on lines +238 to +243
$(isnothing(mainfont) ? "" :
"\\setmainfont{$mainfont}[Scale=MatchLowercase, Ligatures=TeX]"
)
$(isnothing(mathfont) ? "" :
"\\setmathfont(Digits,Latin)[Scale=MatchLowercase]{$mathfont}"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa cool! I didn't know you could do that.

Do \bf, \it, \sc etc work correctly with this?

Copy link
Author

@Moelf Moelf Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably, we can probably have a comprehensive test of making 2x2x2 different math on the same canvase as a sanity check

two caveats:

  • I can't find the default font's name
  • I'm yet to fully understand how the exactly interaction between multiple set*font work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default font in Makie is "TeX Gyre Heros Makie", it's in the assets folder of Makie (I think).
I guess we should set the default math font to also be whichever math font relates to TeX Gyre Heros? This is what I was trying to do earlier, in building up a set of known font families for which we have good math fonts.

@Moelf
Copy link
Author

Moelf commented Feb 4, 2023

you can use https://tug.org/FontCatalogue/ to find fonts with math support. https://ctan.org/pkg/tex-gyre-heros?lang=en by the look of it, it's basically Nimbus, but yeah we can default to it. And in that case a good math font is probably https://tug.org/FontCatalogue/urwnimbusroman/

@Moelf
Copy link
Author

Moelf commented Nov 4, 2023

Bump?

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