-
Notifications
You must be signed in to change notification settings - Fork 56
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
Font selection? #312
Comments
No idea 🙂 Is the problem that a font can't be found? |
' but the standard CSS2 generic family names, ("serif", "sans-serif", "cursive", "fantasy", "monospace"), are likely to work as expected.' in https://www.cairographics.org/manual/cairo-text.html. |
This is the builder for fontconfig: https://github.com/JuliaPackaging/Yggdrasil/blob/326831d236096ac147cece2dd2f53aee28d5b536/F/Fontconfig/build_tarballs.jl |
Maybe you want to check the list of fonts found by fontconfig with using Cairo
fc_list = joinpath(dirname(Cairo.Fontconfig_jll.libfontconfig_path), "..", "bin", "fc-list")
run(`$(fc_list)`) |
The good news is Fontconfig_jll has reasonable defaults for paths and finds major part of my local fonts, so e.g. "DejaVu Sans" works. I'm still looking into the cairo build, how the defaults for 'sans' 'serif' etc. are build. |
vs.
|
Where is DejaVuSans.ttf? Does running fc-cache help? |
DejaVu Sans isn't the problem
|
So |
No (#312 (comment)) fc_list is misleading here, fc-match is called. |
I know, in fact I said Honestly, I'm a bit lost about what's the problem here 🙂 |
Cairo.jl should support the generic "Sans" "Serif" "Mono", but at least not providing a serif font for Sans. |
So is this a Fontconfig problem that it's picking up a serif font when asking for a sans-serif one? |
At least i see clearer now: The top-level font.conf is read from an artifact and hard coded. |
Could you please elaborate? I still fail to understand where the problem is exactly. |
With latest version of julia> using Fontconfig_jll
julia> run(`cmp $(Fontconfig_jll.fonts_conf) /etc/fonts/fonts.conf`)
Process(`cmp /home/mose/.julia/artifacts/b20d3b4e71d9209bc0d83410b048e97b4f8c7096/etc/fonts/fonts.conf /etc/fonts/fonts.conf`, ProcessExited(0)) We've now removed all references to paths in the build environment. Note that calling julia> fc_match() do fc_match_exe
run(`$fc_match_exe Sans`)
end
DejaVuSans.ttf: "DejaVu Sans" "Book"
Process(`/home/mose/.julia/artifacts/b20d3b4e71d9209bc0d83410b048e97b4f8c7096/bin/fc-match Sans`, ProcessExited(0)) while directly calling the executable doesn't: julia> run(`/home/mose/.julia/artifacts/b20d3b4e71d9209bc0d83410b048e97b4f8c7096/bin/fc-match Sans`)
LinLibertine_R.otf: "Linux Libertine O" "Regular"
Process(`/home/mose/.julia/artifacts/b20d3b4e71d9209bc0d83410b048e97b4f8c7096/bin/fc-match Sans`, ProcessExited(0)) We probably need to set some more environment variables to get this working. |
It turned out it's just julia> withenv(Fontconfig_jll.LIBPATH_env => Fontconfig_jll.LIBPATH) do
run(`/home/mose/.julia/artifacts/b20d3b4e71d9209bc0d83410b048e97b4f8c7096/bin/fc-match Sans`)
end
DejaVuSans.ttf: "DejaVu Sans" "Book"
Process(`/home/mose/.julia/artifacts/b20d3b4e71d9209bc0d83410b048e97b4f8c7096/bin/fc-match Sans`, ProcessExited(0)) However setting this environment variable doesn't seem to help with |
I have similar issues. Observations: LinuxBreaks going from Cairo v0.6.0 to v0.7.0 (Using Julia v1.3.1) Does not appear to be caused by changes in Julia itself: EDIT: Observations: Linux + Local FontsAs mentioned by @lobingera, local fonts still appear to work: Observations: Windows 10"built-in" font aliases NOT broken, even for Cairo v0.8.0 (Using Julia v1.1.1) So, it appears NOT to be an issue in Windows (no idea about mac). |
@lobingera what I would like to understand, and I hope you can help me on this, is what is choosing the font in Cairo.jl? Can you track down where the selection happens? That could tell us where to look further. As far as I can tell, the executable |
afaiu, libcairo actually wants you to select a font and hand over some function handles via the renderer (or the outline conversion if the output isn't a bitmap). However there is a fallback/toy font solution that uses the means provided and configured at built time. If you build on linux this is mostliklely Fontconfig + FreeType. You can see a little bit of that in cairo-ft-font.c _cairo_ft_unscaled_font_create_for_pattern. So. I'd expect the provided fc-pattern and fc-match to resolve names like 'serif' and 'sans-serif' to resolve to a TTF that could be loaded. |
They do: julia> using Fontconfig_jll
julia> fc_match(cmd -> run(`$cmd Sans`));
DejaVuSans.ttf: "DejaVu Sans" "Book"
julia> fc_match(cmd -> run(`$cmd Serif`));
DejaVuSerif.ttf: "DejaVu Serif" "Book" |
Well ...
|
Try setting ENV["FONTCONFIG_FILE"] = fonts_conf |
|
For example what do you get with julia> fc_list(cmd -> run(`$cmd "DejaVu Sans"`));
/usr/share/fonts/TTF/DejaVuSansCondensed.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
/usr/share/fonts/TTF/DejaVuSans-BoldOblique.ttf: DejaVu Sans:style=Bold Oblique
/usr/share/fonts/TTF/DejaVuSansCondensed-Oblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
/usr/share/fonts/TTF/DejaVuSansCondensed-BoldOblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique
/usr/share/fonts/TTF/DejaVuSans-ExtraLight.ttf: DejaVu Sans,DejaVu Sans Light:style=ExtraLight
/usr/share/fonts/TTF/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique
/usr/share/fonts/TTF/DejaVuSansCondensed-Bold.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
/usr/share/fonts/TTF/DejaVuSans.ttf: DejaVu Sans:style=Book
/usr/share/fonts/TTF/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
julia> fc_list(cmd -> run(`$cmd "DejaVu Serif"`));
/usr/share/fonts/TTF/DejaVuSerifCondensed.ttf: DejaVu Serif,DejaVu Serif Condensed:style=Condensed,Book
/usr/share/fonts/TTF/DejaVuSerifCondensed-Bold.ttf: DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold,Bold
/usr/share/fonts/TTF/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/usr/share/fonts/TTF/DejaVuSerif.ttf: DejaVu Serif:style=Book
/usr/share/fonts/TTF/DejaVuSerifCondensed-Italic.ttf: DejaVu Serif,DejaVu Serif Condensed:style=Condensed Italic,Italic
/usr/share/fonts/TTF/DejaVuSerif-BoldItalic.ttf: DejaVu Serif:style=Bold Italic
/usr/share/fonts/TTF/DejaVuSerifCondensed-BoldItalic.ttf: DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold Italic,Bold Italic
/usr/share/fonts/TTF/DejaVuSerif-Italic.ttf: DejaVu Serif:style=Italic ? |
|
Is this different from what you get with system |
Hmm.
vs.
|
I'm not sure shell> fc-list | grep Deja is doing what you expect. You can't pipe in that way in Julia's shell mode REPL |
And i thought, there is a reason, why this is called shell mode ... Doing a simple fc-list (in julia) i can see in the terminal some DejaVu in the above paths |
There is a reason why it's called "Julia's shell mode" and not "your system's shell": it's Julia doing the parsing of the commands, not your shell. |
I see. |
With JuliaPackaging/Yggdrasil#1287 I finally get a sans serif font in the example, as expected. Could you please confirm that it works also for you after updating the packages in the registry? You should get For comparison, the image in |
I might come up with some questions, but i put them then to the Yggdrasil issue... |
I was looking into #311 and downloading the first time a 1.0.0 Cairo - including the binary dependencies.
I didn't expect this:
as the selected font in sample_text.jl is "Sans".
@giordano Any idea, what went wrong?
The text was updated successfully, but these errors were encountered: