Skip to main content

Module fonts

Module fonts 

Source
Expand description

Fonts: which ones emoji are drawn with.

Text is shaped and drawn by cosmic-text, which rasterizes glyphs with swash. Left to itself it gets emoji wrong in two ways, and both are put right here, once, before anything is drawn (see prepare).

A font whose glyphs can’t be drawn. Of the ways a font can carry colour glyphs, swash draws bitmaps (CBDT, sbix) and the first version of layered outlines (COLR version 0). It does not draw the second (COLR version 1, with gradients), and a font that has only those gets its glyphs chosen all the same, since it says it has them: they come out as nothing at all. Some distributions ship their emoji font that way. Such fonts are taken out of the list this process chooses from, and what they would have drawn falls to the next font that has it.

A text font that comes first. What the font of the interface has no glyph for is looked for in a list of other fonts, in order, and an emoji font is the last of that list: after text fonts that have a face or a heart of their own, in one colour. So a note would show some emoji in colour and some as line drawings. The fonts for emoji are put at the head of that list instead (see emoji_families): the ones in colour first, then any other that is one by its name. A font for emoji is one that has a glyph for a face (AN_EMOJI) and either colour or the name: a text font with a few emoji among its letters is not one, and neither is a font with colour glyphs that are no emoji.

A font of the applet’s own. Fonts in the fonts directory beside the event store (see own_fonts_dir) are read as well as the system’s, and come before them. That is where to put an emoji font that can be drawn where the system’s can’t, without changing what any other program draws: just emoji-font-setup fetches one.

Nothing is changed outside this process: no file, and no setting.

Structs§

EmojiFirst 🔒
The fonts a glyph is looked for in when the font asked for has none: as the platform has them, with the fonts for emoji before the rest.
Face 🔒
A face, as far as choosing the fonts for emoji goes.

Enums§

Colour 🔒
What a face has of glyphs in colour.

Constants§

AN_EMOJI 🔒
An emoji every font for emoji has a glyph for, and few others: by which one is told.

Functions§

colour 🔒
What font has of glyphs in colour. Its COLR table lists the glyphs of the first kind, and says of which version it is: of version 1 or later with none listed that way, and no bitmaps beside it, there is nothing to draw.
emoji_families 🔒
The families emoji are to be looked for in before any other, in that order, of faces: those that have emoji in colour that can be drawn, the applet’s own before the system’s, then those that have them in one colour and are for emoji by their name. Each once. A font with colour glyphs and no emoji is not one, nor is a text font that has a few emoji among its letters; and none whose glyphs can’t be drawn.
faces 🔒
Every face of fonts, with those under own marked as the applet’s.
own_fonts_dir
Where the applet’s own fonts are: the user’s data directory, beside the event store.
prepare
See that emoji are drawn, and with the fonts for emoji: read the applet’s own fonts, take out the fonts whose colour glyphs can’t be drawn, and have the fonts for emoji looked in before the others. To be called once, before any text is laid out. See the module docs.
read 🔒
What the face numbered index of the font file data has of glyphs in colour, and whether it has emoji: None of a file that is no font.