-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Text is currently being rounded in two places:
-
LibTxt rounds as a legacy feature (from blink) to better align vertical layouts with pixel boundaries to produce sharper text on low-DPI devices. This is no longer necessary as device DPI has increased significantly in recent years, and we now prefer more accurate layout.
-
TextPainterapplies a rounding we call_applyFloatingPointHackto metrics. The reasoning is probably best explained by the todo:// Unfortunately, using full precision floating point here causes bad layouts
// because floating point math isn't associative. If we add and subtract
// padding, for example, we'll get different values when we estimate sizes and
// when we actually compute layout because the operations will end up associated
// differently. To work around this problem for now, we round fractional pixel
// values up to the nearest whole pixel value. The right long-term fix is to do
// layout using fixed precision arithmetic.
We should remove such rounding sooner rather than later, as it will result in < 0.5px (logical) shifts across almost all text in Flutter. Such a change should eventually be made, and the earlier, the less disruption it can cause.