resvg icon indicating copy to clipboard operation
resvg copied to clipboard

Compound/ZWJ-joined emoji

Open si14 opened this issue 1 year ago • 3 comments

As far as I can tell, resvg doesn't render compound emojis:

Screenshot 2024-12-16 at 20 07 30

Am I doing something wrong, or is it indeed not implemented (yet, ever)?

Related: https://github.com/linebender/resvg/pull/735

si14 avatar Dec 16 '24 20:12 si14

I do think it should work, it looks more like resvg wasn't able to find a font with the emoji on your system. Could you maybe send the SVG so I can try it?

LaurenzV avatar Dec 16 '24 22:12 LaurenzV

<svg xmlns="http://www.w3.org/2000/svg" width="1500" height="600" viewBox="0 0 1500 600">
    <text x="50" y="550" text-anchor="start" dominant-baseline="text-after-edge"
          font-family="Nunito" fill="white"
          style="filter:drop-shadow(0 3px 7px black)">
        <tspan x="50" dy="-190" font-size="120px" font-weight="800">
            Every Time ✅
        </tspan>
        <tspan x="50" dy="113" font-size="66px" font-weight="800">12:25</tspan>
        <tspan x="50" dy="97" font-size="66px">London 🇬🇧</tspan>
    </text>
</svg>

Font DB is passed in explicitly and initialised like this:

        let mut fontdb = usvg::fontdb::Database::new();
        fontdb.load_font_data(
            include_bytes!("../fonts/apple_color_emoji/AppleColorEmoji.ttf").to_vec(),
        );
        fontdb.load_font_data(include_bytes!("../fonts/nunito/Nunito-Regular.ttf").to_vec());
        fontdb.load_font_data(include_bytes!("../fonts/nunito/Nunito-ExtraBold.ttf").to_vec());

The first font comes from this repackaged font which, as far as I can tell, does include flags: https://github.com/samuelngs/apple-emoji-linux

If it doesn't reproduce I'm happy to add you to the repo

si14 avatar Dec 16 '24 22:12 si14

Hmm yeah, can reproduce.

The following does indeed not work: <tspan x="50" dy="97" font-size="66px">London 🇬🇧</tspan> image

but if I change it to just containing the flag it works: <tspan x="50" dy="97" font-size="66px"> 🇬🇧</tspan> image

usvg's font fallback logic has unfortunately never been great, it's a hard problem.

LaurenzV avatar Dec 16 '24 22:12 LaurenzV