mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
font: calculate correct offset for non-scalable emoji fonts
This commit is contained in:
@ -209,11 +209,25 @@ pub fn renderGlyph(self: Face, alloc: Allocator, atlas: *Atlas, glyph_index: u32
|
|||||||
atlas.set(region, buffer);
|
atlas.set(region, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Y offset is the offset of the top of our bitmap PLUS our
|
const offset_y = offset_y: {
|
||||||
// baseline calculation. The baseline calculation is so that everything
|
// For non-scalable colorized fonts, we assume they are pictographic
|
||||||
// is properly centered when we render it out into a monospace grid.
|
// and just center the glyph. So far this has only applied to emoji
|
||||||
// Note: we add here because our X/Y is actually reversed, adding goes UP.
|
// fonts. Emoji fonts don't always report a correct ascender/descender
|
||||||
const offset_y = glyph.*.bitmap_top + @floatToInt(c_int, self.metrics.cell_baseline);
|
// (mainly Apple Emoji) so we just center them. Also, since emoji font
|
||||||
|
// aren't scalable, cell_baseline is incorrect anyways.
|
||||||
|
//
|
||||||
|
// NOTE(mitchellh): I don't know if this is right, this doesn't
|
||||||
|
// _feel_ right, but it makes all my limited test cases work.
|
||||||
|
if (self.face.hasColor() and !self.face.isScalable()) {
|
||||||
|
break :offset_y @intCast(c_int, tgt_h);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Y offset is the offset of the top of our bitmap PLUS our
|
||||||
|
// baseline calculation. The baseline calculation is so that everything
|
||||||
|
// is properly centered when we render it out into a monospace grid.
|
||||||
|
// Note: we add here because our X/Y is actually reversed, adding goes UP.
|
||||||
|
break :offset_y glyph.*.bitmap_top + @floatToInt(c_int, self.metrics.cell_baseline);
|
||||||
|
};
|
||||||
|
|
||||||
// Store glyph metadata
|
// Store glyph metadata
|
||||||
return Glyph{
|
return Glyph{
|
||||||
|
Reference in New Issue
Block a user