Variable font support (#400)
* Variable font support Here's a pretty naïve solution for variable fonts. The iterator doesn't use the match keys' weight, but instead tries to get the requested ideal weight, if the font is variable, otherwise it is ignored and the actual (non-variable) weight is used. This is because I didn't implement finding variable weight support for match keys; doing so would be impossible without parsing TTF files when matching and I didn't want to add that potentially expensive infrastructure if not entirely necessary. This is a breaking change, and I'm open for ideas on how to fix that if it's an issue. * cargo fmt * Add variable font example to rich-text example
This commit is contained in:
parent
d15011fba5
commit
a03faa654d
10 changed files with 119 additions and 34 deletions
|
|
@ -16,6 +16,8 @@ pub struct LayoutGlyph {
|
|||
pub end: usize,
|
||||
/// Font size of the glyph
|
||||
pub font_size: f32,
|
||||
/// Font weight of the glyph
|
||||
pub font_weight: fontdb::Weight,
|
||||
/// Line height of the glyph, will override buffer setting
|
||||
pub line_height_opt: Option<f32>,
|
||||
/// Font id of the glyph
|
||||
|
|
@ -79,6 +81,7 @@ impl LayoutGlyph {
|
|||
(self.x + x_offset) * scale + offset.0,
|
||||
math::truncf((self.y - y_offset) * scale + offset.1), // Hinting in Y axis
|
||||
),
|
||||
self.font_weight,
|
||||
self.cache_key_flags,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue