improve text rendering#420
Conversation
| // Draw into a quad 1px larger on every side so the SDF's antialiased edge isn't | ||
| // clipped at the shape's cardinal points (most visible on perfect circles). The | ||
| // extra ring is effectively zero-alpha for the shape itself. | ||
| GPU_RectangleFilled(rawPointer, gpuRect(rect.insetBy(dx: -1, dy: -1)), color: color.sdlColor) |
There was a problem hiding this comment.
I don't know if this change is just fighting a symptom tbh
There was a problem hiding this comment.
It seems like it is fighting a symptom – it sounds like the antialising shader is antialiasing "outward", which isn't unreasonable but could cause this. I wonder if it's easy enough to adjust that shader rather than fudging pixels in seemingly unrelated places?
| } | ||
|
|
||
| @MainActor | ||
| public class NSAttributedString { |
There was a problem hiding this comment.
hmm. are we sure NSAttributedString is @MainActor in its Foundation implementation? It's not impossible but I would be surprised
| public var pointSize: CGFloat | ||
| public var lineHeight: CGFloat { | ||
| return CGFloat(renderer?.getLineHeight() ?? 0) / UIScreen.main.scale | ||
| return CGFloat(renderer?.getLineHeight() ?? 0) / (UIScreen.main?.scale ?? 2) |
There was a problem hiding this comment.
This is unfortunately still incorrect and a growing source of potential "incorrectness".
A better solution here would be to have a @MainActor static internal variable lastKnownScreenScale: CGFloat which itself defaults to 2.0 but is set whenever UIScreen.main is initialized. Then we should reference that cached value internally whenever we don't have a screen. I know it's not directly related to this PR but it would be amazing if this could happen sooner rather than later, so I would also welcome that change in this PR 🙏🏼
ephemer
left a comment
There was a problem hiding this comment.
Looks good! Left some minor comments that aren't really blocking, but would be good to see improvements in sooner rather than later 🙏🏼 Thanks for this @michaelknoch !

Type of change: feature
Motivation (current vs expected behavior)
lineBreakMode byTruncatingTail(p.s. The headline is repeated 2x in the screenshot to demonstrate the line truncation)

Please check if the PR fulfills these requirements