Add pixel font flag (#402)

This commit is contained in:
callym 2025-07-08 15:58:24 +01:00 committed by GitHub
parent a03faa654d
commit 85b07b4c8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -9,6 +9,8 @@ bitflags::bitflags! {
const FAKE_ITALIC = 1;
/// Disable hinting
const DISABLE_HINTING = 2;
/// Render as a pixel font
const PIXEL_FONT = 4;
}
}

View file

@ -46,7 +46,14 @@ fn swash_image(
// Compute the fractional offset-- you'll likely want to quantize this
// in a real renderer
let offset = Vector::new(cache_key.x_bin.as_float(), cache_key.y_bin.as_float());
let offset = if cache_key.flags.contains(CacheKeyFlags::PIXEL_FONT) {
Vector::new(
cache_key.x_bin.as_float().round() + 1.0,
cache_key.y_bin.as_float().round(),
)
} else {
Vector::new(cache_key.x_bin.as_float(), cache_key.y_bin.as_float())
};
// Select our source order
Render::new(&[