mirror of
https://github.com/servo/servo.git
synced 2025-08-01 19:50:30 +01:00
gfx: Use subpixel positioning for glyphs.
Improves text rendering significantly.
This commit is contained in:
parent
c7915028b4
commit
dbdfce0695
2 changed files with 8 additions and 2 deletions
|
@ -110,8 +110,8 @@ impl ScaledFontExtensionMethods for ScaledFont {
|
||||||
let azglyph = struct__AzGlyph {
|
let azglyph = struct__AzGlyph {
|
||||||
mIndex: glyph.id() as uint32_t,
|
mIndex: glyph.id() as uint32_t,
|
||||||
mPosition: struct__AzPoint {
|
mPosition: struct__AzPoint {
|
||||||
x: (origin.x + glyph_offset.x).to_nearest_px() as AzFloat,
|
x: (origin.x + glyph_offset.x).to_subpx() as AzFloat,
|
||||||
y: (origin.y + glyph_offset.y).to_nearest_px() as AzFloat
|
y: (origin.y + glyph_offset.y).to_subpx() as AzFloat
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
origin = Point2D(origin.x + glyph_advance, origin.y);
|
origin = Point2D(origin.x + glyph_advance, origin.y);
|
||||||
|
|
|
@ -200,6 +200,12 @@ impl Au {
|
||||||
((s as f64) / 60f64).round() as int
|
((s as f64) / 60f64).round() as int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn to_subpx(&self) -> f64 {
|
||||||
|
let Au(s) = *self;
|
||||||
|
(s as f64) / 60f64
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_snapped(&self) -> Au {
|
pub fn to_snapped(&self) -> Au {
|
||||||
let Au(s) = *self;
|
let Au(s) = *self;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue