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

Emoji support #311

Open
cormullion opened this issue Dec 19, 2019 · 6 comments
Open

Emoji support #311

cormullion opened this issue Dec 19, 2019 · 6 comments

Comments

@cormullion
Copy link
Member

cormullion commented Dec 19, 2019

I believe Cairo now supports emoji (https://www.phoronix.com/scan.php?page=news_item&px=Cairo-1.15.8-Colored-Emoji) as of 1.15.8. I think Cairo.jl is now based on 1.16.0. So I thought it should be possible to display emoji...

Changing sample_text.jl to contain this:

select_font_face(cr, "AppleColorEmoji", Cairo.FONT_SLANT_NORMAL,
                Cairo.FONT_WEIGHT_BOLD)
set_font_size(cr, 90.0)

move_to(cr, 10.0, 135.0)
show_text(cr, "🙩🙪🙫🙬🙭🙮🙯🙰🙱🙲🙳🙴🙵🙶🙷🙸🙹🙺🙻🙼🙽🙾🙿🚀🚁") 

just produces empty boxes. Is there a trick to getting them showing? Perhaps it's a FontConfig/FreeType thing?

Edit: I see that on some devices Github can’t display some of the emojis in that string either... But they’re rendered correctly in Julia (n the REPL and in my editor (Atom)).

@lobingera
Copy link
Contributor

Glyph boxes are usually a sign of not defined. Have you ensured, that this font is actually opened and does display any glyph?

@cormullion
Copy link
Member Author

Actually, the boxes are the second string, "void"... so it looks like there aren't any boxes...

select_font_face(cr, "AppleColorEmoji", Cairo.FONT_SLANT_NORMAL, Cairo.FONT_WEIGHT_NORMAL)
set_font_size(cr, 10.0)

move_to(cr, 10.0, 135.0)
show_text(cr, "123🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊")

move_to(cr, 70.0, 165.0)
text_path(cr, "void")
set_source_rgb(cr, 0.5, 0.5, 1)
fill_preserve(cr)
set_source_rgb(cr, 0, 0, 0)
set_line_width(cr, 2.56)
stroke(cr)

# draw helping lines
set_source_rgba(cr, 1, 0.2, 0.2, 0.6)
arc(cr, 10.0, 135.0, 5.12, 0, 2*pi)
close_path(cr)
arc(cr, 70.0, 165.0, 5.12, 0, 2*pi)
fill(cr)

displays

sample_text

so the digits (they're also in the font) appear, but the emoji characters don't.

@curio-sitas
Copy link

I there. Is there a package that does draw emojis ?

@cormullion
Copy link
Member Author

Perhaps a plotting package like Plots.jl or Makie.jl might be able to do it. Or work with the terminal with Term.jl etc...

Using Cairo.jl and FreeType will get you only black and white images, although I'd love to be proved wrong...

using FreeTypeAbstraction
using FixedPointNumbers
using Luxor
using Colors

face = FTFont("/Library/FontLibrary/S/Segoe UI Emoji/seguiemj_0.ttf")
img, metric = renderface(face, Char(0x1F608), 256)
imgg = reinterpret(N0f8, permutedims(img, (2, 1)))
@draw begin
    placeimage(convert.(Colors.RGB, imgg), centered=true)
end

Screenshot 2022-10-02 at 17 15 45

@curio-sitas
Copy link

curio-sitas commented Oct 2, 2022

Perhaps a plotting package like Plots.jl or Makie.jl might be able to do it. Or work with the terminal with Term.jl etc...

Using Cairo.jl and FreeType will get you only black and white images, although I'd love to be proved wrong...

using FreeTypeAbstraction
using FixedPointNumbers
using Luxor
using Colors

face = FTFont("/Library/FontLibrary/S/Segoe UI Emoji/seguiemj_0.ttf")
img, metric = renderface(face, Char(0x1F608), 256)
imgg = reinterpret(N0f8, permutedims(img, (2, 1)))
@draw begin
    placeimage(convert.(Colors.RGB, imgg), centered=true)
end
Screenshot 2022-10-02 at 17 15 45

Thank's. I was wondering if there was a way to draw a text containing a native emoji but that does not seem to be possible without drawing an emoji alone and not correctly. Is the package abandonned ?, there have been no update in the last two years.

@cormullion
Copy link
Member Author

cormullion commented Oct 2, 2022

Cairo.jl? No it's stable, as far as I know. (See also the library.)

In general, Julia support for fonts and typography is quite limited and spread piecemeal across various packages. Plotting package developers often write their own stuff as needed rather than develop a full-featured typography package. Cross-platform typography support is quite a tough problem...

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

3 participants