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

Add Fontconfig font search to the rich-text scheme #2400

Closed
wants to merge 4 commits into from

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented Nov 4, 2022

Description

This PR builds off jk/rich-text. It doesn't modify that code at all, but introduces a method to use Fontconfig to find and create font sets.

Basically, what this does is introduce 3 main methods.

  1. The ability to obtain all styles in a font family (populate_font_family) - returns a NamedTuple of Symbol styles => FTFont (Makie.NativeFont).
  2. The ability to search for a particular style within a font family, along with some basic fallbacks (regular can be roman or book, for example, if there is no style called regular) - search_font
  3. The ability to cache font families and regularize some names, so that (:regular, :bold, :italic, :bold_italic) are always available, even if the font has obliques instead of italics. Individual styles can still be referred to by their original names. This is the FontFamily interface, which is, additionally, editable. It also automatically searches for a style if it can't exactly match, making it a bit more dynamic.

This results in the following:

FontFamily("TeX Gyre Heros Makie")
FontFamily("TeX Gyre Heros Makie", Attributes with 5 entries:
  bold => FTFont (family = TeX Gyre Heros Makie, style = Bold)
  bold italic => FTFont (family = TeX Gyre Heros Makie, style = Bold Italic)
  bold_italic => FTFont (family = TeX Gyre Heros Makie, style = Bold Italic)
  italic => FTFont (family = TeX Gyre Heros Makie, style = Italic)
  regular => FTFont (family = TeX Gyre Heros Makie, style = Regular))

and fonts = "TeX Gyre Heros Makie" is equivalent to fonts = FontFamily("TeX Gyre Heros Makie"), which is what has been provided in the default theme. This way, people can access the exact font style (Extracondensed Semibold or what have you) as well as some basic shortcuts.

Type of change

Delete options that do not apply:

  • New feature (non-breaking change which adds functionality)

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

basically allows automatic pre-filling for an entire font family, which 
you can then customize as normal with Attributes.  Also enables more 
flexible search for fonts.
@asinghvi17 asinghvi17 mentioned this pull request Nov 4, 2022
5 tasks
@SimonDanisch
Copy link
Member

Cool! Can we move most of this to FontConfig.jl?

@SimonDanisch
Copy link
Member

It would be important to make Fontconfig well tested across platforms in the Fontconfig.jl CI, to actually take it on as a dependency ;)

@asinghvi17
Copy link
Member Author

Definitely! The only code which would have to live in Makie would be the extension of to_font, really.

I seem to recall you mentioning that you had some issues with Fontconfig.jl on Ubuntu @SimonDanisch - have those been resolved since?

Looking at CI: I think the tests as they stand now are pretty alright? Of course, some tests for the new code would be added.

It looks like Travis CI tests Linux, Windows and OSX for Fontconfig...which should be sufficient? If necessary I could add Github Actions as well, but it doesn't seem needed yet. Will definitely have it test on Julia 1.3, release and nightly though.

@SimonDanisch
Copy link
Member

have those been resolved since?

I have no idea^^ That's why it'd be nice to have some relevant tests run all platforms :)

I think the tests as they stand now are pretty alright

That'd be great :) Haven't looked at them yet ;)

If necessary I could add Github Actions

I think we should get rid of Travis and test ubuntu, linux and osx with github actions!
And I'd just test on 1.6 and higher ;)

@SimonDanisch
Copy link
Member

I think the tests as they stand now are pretty alright

Hm...they only seem to test that nothing is crashing:
https://github.com/JuliaGraphics/Fontconfig.jl/blob/master/test/runtests.jl
Doesn't even make sure, that fonts can be found etc, so I think they're not really great :D
From what I remember, the main cross platform issue was, that it wasn't finding any fonts on some platforms.

I think we should at least test something like this:
https://github.com/JuliaGraphics/FreeTypeAbstraction.jl/blob/master/test/runtests.jl#L240-L271

@jkrumbiegel jkrumbiegel deleted the branch MakieOrg:jk/rich-text November 23, 2022 15:05
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.

3 participants