mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-04 04:22:43 +00:00
Center before quantizing bitmap glyphs
This commit is contained in:
committed by
Mitchell Hashimoto
parent
071621a8c2
commit
96fbff681b
@@ -378,16 +378,6 @@ pub const Face = struct {
|
||||
var width = glyph_size.width;
|
||||
var height = glyph_size.height;
|
||||
|
||||
// If this is a bitmap glyph, it will always render as full pixels,
|
||||
// not fractional pixels, so we need to quantize its position and
|
||||
// size accordingly to align to full pixels so we get good results.
|
||||
if (sbix) {
|
||||
width = cell_width - @round(cell_width - width - x) - @round(x);
|
||||
height = cell_height - @round(cell_height - height - y) - @round(y);
|
||||
x = @round(x);
|
||||
y = @round(y);
|
||||
}
|
||||
|
||||
// We center all glyphs within the pixel-rounded and adjusted
|
||||
// cell width if it's larger than the face width, so that they
|
||||
// aren't weirdly off to the left.
|
||||
@@ -400,6 +390,16 @@ pub const Face = struct {
|
||||
x += (cell_width - metrics.face_width) / 2;
|
||||
}
|
||||
|
||||
// If this is a bitmap glyph, it will always render as full pixels,
|
||||
// not fractional pixels, so we need to quantize its position and
|
||||
// size accordingly to align to full pixels so we get good results.
|
||||
if (sbix) {
|
||||
width = cell_width - @round(cell_width - width - x) - @round(x);
|
||||
height = cell_height - @round(cell_height - height - y) - @round(y);
|
||||
x = @round(x);
|
||||
y = @round(y);
|
||||
}
|
||||
|
||||
// Our whole-pixel bearings for the final glyph.
|
||||
// The fractional portion will be included in the rasterized position.
|
||||
const px_x: i32 = @intFromFloat(@floor(x));
|
||||
|
||||
@@ -492,16 +492,6 @@ pub const Face = struct {
|
||||
var x = glyph_size.x;
|
||||
var y = glyph_size.y;
|
||||
|
||||
// If this is a bitmap glyph, it will always render as full pixels,
|
||||
// not fractional pixels, so we need to quantize its position and
|
||||
// size accordingly to align to full pixels so we get good results.
|
||||
if (glyph.*.format == freetype.c.FT_GLYPH_FORMAT_BITMAP) {
|
||||
width = cell_width - @round(cell_width - width - x) - @round(x);
|
||||
height = cell_height - @round(cell_height - height - y) - @round(y);
|
||||
x = @round(x);
|
||||
y = @round(y);
|
||||
}
|
||||
|
||||
// We center all glyphs within the pixel-rounded and adjusted
|
||||
// cell width if it's larger than the face width, so that they
|
||||
// aren't weirdly off to the left.
|
||||
@@ -520,6 +510,16 @@ pub const Face = struct {
|
||||
x += @round((cell_width - metrics.face_width) / 2);
|
||||
}
|
||||
|
||||
// If this is a bitmap glyph, it will always render as full pixels,
|
||||
// not fractional pixels, so we need to quantize its position and
|
||||
// size accordingly to align to full pixels so we get good results.
|
||||
if (glyph.*.format == freetype.c.FT_GLYPH_FORMAT_BITMAP) {
|
||||
width = cell_width - @round(cell_width - width - x) - @round(x);
|
||||
height = cell_height - @round(cell_height - height - y) - @round(y);
|
||||
x = @round(x);
|
||||
y = @round(y);
|
||||
}
|
||||
|
||||
// Now we can render the glyph.
|
||||
var bitmap: freetype.c.FT_Bitmap = undefined;
|
||||
_ = freetype.c.FT_Bitmap_Init(&bitmap);
|
||||
|
||||
Reference in New Issue
Block a user