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 capability to fetch alternate glyphs #59

Open
Kolaru opened this issue Jul 3, 2021 · 1 comment
Open

Add capability to fetch alternate glyphs #59

Kolaru opened this issue Jul 3, 2021 · 1 comment

Comments

@Kolaru
Copy link

Kolaru commented Jul 3, 2021

Some characters in some fonts have multiple glyph that can represent them. Typically the integral sign in math font has one version for inline math and one one for block equations.

Currently, it looks like the alternate glyph can be retrieved as follow:

julia> font = FTFont("assets/fonts/NewCMMath-Regular.otf")
FTFont(Ptr{FreeType.__JL_FT_FaceRec_} @0x000000001e67a810, true, Dict{Char, FontExtent{Float32}}())

julia> glyph_id = FT_Get_Name_Index(font, "integral.v1")
0x0000172a

julia> res = FT_Load_Glyph(font, glyph_id, FT_LOAD_NO_SCALE)
0

So I guess that adding methods to get_extent, get_extent_internal and load_char to load from a glyph name may do the trick.

Ideally it would be good to retrieve the information on whether a char has alternate glyphs directly from the font, but I am no sure FreeType support that.

@jkrumbiegel
Copy link
Collaborator

jkrumbiegel commented Jul 14, 2022

Ideally it would be good to retrieve the information on whether a char has alternate glyphs directly from the font, but I am no sure FreeType support that.

https://freetype.org/freetype2/docs/reference/ft2-glyph_variants.html

I think everything we need is here. I think what we need to do is make a new function load_glyph and then a couple methods:

load_glyph(::Char) -> look up glyph via unicode char in charmap (via FT_Load_Char)
load_glyph(::Int) -> look up glyph via index in font (via FT_Load_Glyph)
load_glyph(::Char, ::Char) -> look up glyph modified with modifier (not sure about the type of the second argument)
load_glyph(::String or ::Symbol) -> look up glyph via name

And then Makie would actually just use the glyph index representation inside glyphcollection because that is more generic than the unicode we use right now.

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

No branches or pull requests

2 participants