Skip to content
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

Merged
merged 3 commits into from
May 7, 2022
Merged

Conversation

chrisduerr
Copy link
Member

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.

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.
@chrisduerr chrisduerr requested a review from kchibisov April 6, 2022 00:36
@@ -346,87 +448,6 @@ impl FreeTypeRasterizer {
Ok(glyph.font_key)
}

fn get_rendered_glyph(&mut self, glyph_key: GlyphKey) -> Result<RasterizedGlyph, Error> {
Copy link
Member Author

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.

Copy link
Member

@kchibisov kchibisov left a 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.
Copy link
Member

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.

@kchibisov
Copy link
Member

@chrisduerr beep.

@chrisduerr
Copy link
Member Author

@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.

@kchibisov
Copy link
Member

@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.

@chrisduerr
Copy link
Member Author

Yeah thanks for the reminder, better safe than sorry.

@chrisduerr
Copy link
Member Author

Emojis work properly now:
tmp

Copy link
Member

@kchibisov kchibisov left a 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.

@chrisduerr chrisduerr merged commit 6056f89 into alacritty:master May 7, 2022
@chrisduerr chrisduerr deleted the props branch May 7, 2022 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants