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

Basic emoji support in calendar entries #81

Closed mendhak closed 5 months ago

mendhak commented 5 months ago

Using the emoji library to escape emojis and surround them with a <tspan style="font-family:emoji">. The reason this is needed is that cairo/inkscape don't appear to fallback on fonts, so this is the workaround - specifically tell it which font to use. Using the fallback font name emoji instead of a specific font name (like 'Noto Color Emoji') should serve as a system font I think.

To allow the above tspans, in all the templates I've removed the CDATA for calendars.
Instead I'm now doing the XML safety escape in the Python.

image

Limitation: 'combined' fonts don't appear as one. For example, 👨‍🚀 astronaut will appear as 👨🚀

mendhak commented 5 months ago

Tested on a freshly formatted Raspberry Pi Zero with Raspberry Pi OS lite. It was missing a cairo dependency so I've added an instruction for that.

jmason commented 5 months ago

It's funny that my version of inkscape worked ok -- it could be something to do with the build, alright. For what it's worth I am on Inkscape 0.92.4 (5da689c313, 2019-01-14), from Raspbian 10 (Buster). Anyway -- this looks great, I'll give it a go!

jmason commented 5 months ago

This worked pretty nicely for me; one thing is that I wanted to get it working with monochrome emoji, and that's a bit tricky on Raspbian 10.

I got it working by downloading the Noto Emoji TTFs from https://fonts.google.com/noto/specimen/Noto+Emoji , installing them to /usr/local/share/fonts/ :

ls -l /usr/local/share/fonts/
total 4312
-rw-r--r-- 1 root staff 877472 Apr  9 23:58 NotoEmoji-Bold.ttf
-rw-r--r-- 1 root staff 878928 Apr  9 23:58 NotoEmoji-Light.ttf
-rw-r--r-- 1 root staff 879128 Apr  9 23:58 NotoEmoji-Medium.ttf
-rw-r--r-- 1 root staff 878928 Apr  9 23:58 NotoEmoji-Regular.ttf
-rw-r--r-- 1 root staff 878980 Apr  9 23:58 NotoEmoji-SemiBold.ttf

then running:

sudo apt remove fonts-noto-color-emoji

It'd be nice if there was a way to override the font config files to avoid using the color emoji font, but I couldn't get it working without the uninstall.