-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
@@ -346,87 +448,6 @@ impl FreeTypeRasterizer { | |||
Ok(glyph.font_key) | |||
} | |||
|
|||
fn get_rendered_glyph(&mut self, glyph_key: GlyphKey) -> Result<RasterizedGlyph, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be no reason for this to be a separate method, so I decided to just inline it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
advance
field 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
kerning
method whichreturns the relative offset of the second of two glyphs. Kerning for
OpenType fonts implemented in a
GPOS
table is not supported.