Center before quantizing bitmap glyphs
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue