windows: Work around font rendering clipping issue (#14075)

Release Notes:

- N/A
This commit is contained in:
张小白 2024-07-11 03:38:49 +08:00 committed by GitHub
parent 3ff738fa03
commit fa9360f78d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -583,6 +583,18 @@ impl DirectWriteState {
DWRITE_MEASURING_MODE_NATURAL,
)?
};
// todo(windows)
// This is a walkaround, deleted when figured out.
let y_offset;
let extra_height;
if params.is_emoji {
y_offset = 0;
extra_height = 0;
} else {
// make some room for scaler.
y_offset = -1;
extra_height = 2;
}
if bounds.right < bounds.left {
Ok(Bounds {
@ -593,11 +605,13 @@ impl DirectWriteState {
Ok(Bounds {
origin: point(
((bounds.left * params.scale_factor).ceil() as i32).into(),
((bounds.top * params.scale_factor).ceil() as i32).into(),
((bounds.top * params.scale_factor).ceil() as i32 + y_offset).into(),
),
size: size(
(((bounds.right - bounds.left) * params.scale_factor).ceil() as i32).into(),
(((bounds.bottom - bounds.top) * params.scale_factor).ceil() as i32).into(),
(((bounds.bottom - bounds.top) * params.scale_factor).ceil() as i32
+ extra_height)
.into(),
),
})
}