mendhak / waveshare-epaper-display

At-a-glance dashboard for Raspberry Pi with a Waveshare ePaper 7.5 Inch HAT. Date/Time, Weather, Alerts, Google/Outlook Calendar
https://code.mendhak.com/raspberrypi-epaper-dashboard/
449 stars 66 forks source link

Go back to using Inkscape in order to support emoji #80

Closed jmason closed 5 months ago

jmason commented 6 months ago

This also requires a minor change to use instead of as Inkscape seems to be stricter (or more reliant on an older idiom, not sure)

jmason commented 6 months ago

Hi @mendhak , I had to make this change on my local version in order to get emojis in the calendar entries to display; it seems cairosvg doesn't support them :(

jmason commented 6 months ago

I'm not sure what to do with the custom-data-temp SVG reference -- it seems xlink:hrefs need an anchor in the target document to link to.

mendhak commented 6 months ago

I have been trying to figure out why inkscape was removed in the first place, I remember it was breaking something, or was having trouble getting it working on newer Raspberry Pi updates, or they kept removing some arguments. I did find this PR where it was removed.

Anyway as before, the command didn't work for me. The -e argument, without-gui, export-png arguments were not recognized, I wonder if you've got some other version of Inkscape. Mine shows Inkscape 1.2.2 (b0a8486541, 2022-12-01) I think that's also part of the reason for removing it, it's a bit unstable currently across versions and troubleshooting is going to be too difficult.

I managed to get it outputting a PNG with

inkscape screen-output-weather.svg  --export-filename=screen-output.png -w $WAVESHARE_WIDTH -h $WAVESHARE_HEIGHT --export-dpi=300

But the emoji part isn't working for me.

In this example the 5/8 is supposed to be a :frog: emoji

image

mendhak commented 6 months ago

So I've been banging my head against fontconfig for hours now. It's supposed to be that if I set multiple fonts in a family, and there's an emoji in the string, it should fallback to the font family that can manage emojis. But no matter what I tried, and tested, despite all indications saying that the emoji font should be loaded, it's not being rendered in the SVG. Might be related to this comment, cairosvg isn't doing fallback fonts.

I am now wondering if there's a better way to do this... what if there could be some code to detect an emoji, and surround it with

<tspan style="font-family:emoji">🐸</tspan>
or
<tspan style="font-family:'Noto Color Emoji'">🐸</tspan>

When I do that manually, the emoji seems to render.

No idea if this is the best way to do it, it's just thinking out loud for now; there seem to be plenty of methods in the emoji package which might be useful.

mendhak commented 5 months ago

OK I've got a way using Python, in a different PR: https://github.com/mendhak/waveshare-epaper-display/pull/81

The changes aren't too great and works with existing setup. I'll close this PR and move to that one.