Cairo.jl
Cairo.jl copied to clipboard
Emoji support
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)).
Glyph boxes are usually a sign of not defined. Have you ensured, that this font is actually opened and does display any glyph?
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
so the digits (they're also in the font) appear, but the emoji characters don't.
I there. Is there a package that does draw emojis ?
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

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
![]()
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.
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...