Fix scaling and translation text drawing issues#1254
Conversation
|
|
||
| @implementation NSString (UIKitAdditions) | ||
|
|
||
| static CTTextAlignment __UITextAlignmentToCTTextAlignment(UITextAlignment alignment) { |
There was a problem hiding this comment.
not like this - look at what I did in UIKitTypes.h for NS, UI, CT LineBreakMode. Then you can change it back to a static_cast below. #ByDesign
There was a problem hiding this comment.
Double checked - the values between CT/UI are different, and we can't change the values of NS/UI because our internal test app (and presumably others) are depending on those values staying the same
There was a problem hiding this comment.
There was a problem hiding this comment.
add a comment here about the non-agreeing order and why we need this
In reply to: 85579206 [](ancestors = 85579206,85569934)
|
|
| } | ||
| if (priv->contentsScale != 1.0f) { | ||
| CGContextScaleCTM(drawContext, priv->contentsScale, priv->contentsScale); | ||
|
|
There was a problem hiding this comment.
This scale is for Cairo's sake and needs to be done.
Perhaps we should keep it and apply an inverse scale based on the DPI to the D2D context instead of eliminating it here.
|
🕐 |
| enum { | ||
| UITextAlignmentLeft, | ||
| UITextAlignmentLeft = 0, | ||
| UITextAlignmentCenter, |
There was a problem hiding this comment.
make this an NE_ENUM, such as above?
There was a problem hiding this comment.
This makes UI/NS unable to be coerced, which I don't believe is intended behavior
There was a problem hiding this comment.
Perhaps NS should just be implemented in terms of UI?
In reply to: 85553544 [](ancestors = 85553544)
There was a problem hiding this comment.
There was a problem hiding this comment.
We had this as NS_ENUM before; it's somewhat silly but it makes it unable to be used itnerchangeably with NSTextAlignment.
In reply to: 85448628 [](ancestors = 85448628)
There was a problem hiding this comment.
Look in the history for this file for potentially more info!
In reply to: 85629604 [](ancestors = 85629604,85448628)
| CGFloat ascent; | ||
| CTLineGetTypographicBounds(static_cast<CTLineRef>(lines[i]), &ascent, nullptr, nullptr); | ||
| CGContextSetTextPosition(context, origins[i].x + rect.origin.x, origins[i].y + rect.origin.y - ascent / 2.0); | ||
| // Need to set text position so each line will be drawn in the correct position relative to eachother |
There was a problem hiding this comment.
eachother [](start = 100, length = 9)
each other
|
|
||
| // TODO 1077:: Remove once D2D render target is implemented | ||
| _CGContextSetScaleFactor(drawContext, priv->contentsScale); | ||
| CGContextScaleCTM(drawContext, priv->contentsScale, priv->contentsScale); |
There was a problem hiding this comment.
simply revert all changes in this file?
|
|
|
New iteration correctly addresses drawing problems on high dpi devices |
|
|
||
| CGFloat ascent, leading; | ||
| CTLineGetTypographicBounds(line, &ascent, nullptr, &leading); | ||
| CGContextSetTextPosition(curCtx, _lineOrigins[curLine].x, -(_lineOrigins[curLine].y + ascent + leading)); |
There was a problem hiding this comment.
descent missing here intentionally?
CALayers were being scaled twice, and NSString draw methods were being translated twice, causing issues in internal test apps
This change is