Add proportional font support#40
Conversation
Since crossfont was previously used solely by Alacritty, there was no need for anything other than monospaced fonts. This patch adds minimal proportional font support to the FreeType backend. The most relevant part for proportional fonts is using the glyph's individual advance rather than the font metric's advance. This is exposed as a new `advance` field on `RasterizedGlyph`. Besides advance, it's also possible for two rasterized glyphs to be moved closer together by the font in a process called kerning. Crossfont mimics the FreeType API here and provides the `kerning` method which returns the relative offset of the second of two glyphs. Kerning for OpenType fonts implemented in a `GPOS` table is not supported.
| Ok(glyph.font_key) | ||
| } | ||
|
|
||
| fn get_rendered_glyph(&mut self, glyph_key: GlyphKey) -> Result<RasterizedGlyph, Error> { |
There was a problem hiding this comment.
There seems to be no reason for this to be a separate method, so I decided to just inline it.
kchibisov
left a comment
There was a problem hiding this comment.
You should also add a CHANGELOG entry for that, saying that it's linux only for now.
src/ft/mod.rs
Outdated
| } | ||
| } | ||
|
|
||
| // Transform glyphs with the matrix from Fontconfig. Primarily used to generate italics. |
There was a problem hiding this comment.
This comment is now off. Probably should move closer to matrix and not to advance stuff?
Also, have you verified how advance work with emoji fonts and bitmaps? I'm worried that they could a little bit special here, so you'd need to scale advance for them.
|
@chrisduerr beep. |
|
@kchibisov No worries, I haven't lost track of this yet. I've just been sick over the last week so things have gotten a bit delayed. |
Take your time. I've thought that you've changed stuff, but forgot to push or something, since you went through review. |
|
Yeah thanks for the reminder, better safe than sorry. |
kchibisov
left a comment
There was a problem hiding this comment.
That looks good, just some minor style rant, not entirely related to your code.

Since crossfont was previously used solely by Alacritty, there was no
need for anything other than monospaced fonts. This patch adds minimal
proportional font support to the FreeType backend.
The most relevant part for proportional fonts is using the glyph's
individual advance rather than the font metric's advance. This is
exposed as a new
advancefield onRasterizedGlyph.Besides advance, it's also possible for two rasterized glyphs to be
moved closer together by the font in a process called kerning. Crossfont
mimics the FreeType API here and provides the
kerningmethod whichreturns the relative offset of the second of two glyphs. Kerning for
OpenType fonts implemented in a
GPOStable is not supported.