Fix measurement in release builds
This commit is contained in:
parent
3f1ea63d7a
commit
c55e9dcd8b
@ -370,9 +370,17 @@ public class CVText {
|
||||
|
||||
textStorage.addLayoutManager(layoutManager)
|
||||
|
||||
layoutManager.glyphRange(for: textContainer)
|
||||
let size = layoutManager.usedRect(for: textContainer).size
|
||||
|
||||
// For some reason, in production builds, the textStorage
|
||||
// seems to get optimized out in many circumstances. This
|
||||
// results in `usedRect` measuring an empty string and a
|
||||
// size of 0,0.
|
||||
// TODO: Figure out a better way to fix this. For now,
|
||||
// by just using the textStorage later it ensures that it
|
||||
// is properly measured.
|
||||
_ = textStorage
|
||||
|
||||
return size.ceil
|
||||
}
|
||||
|
||||
@ -492,9 +500,17 @@ public class CVText {
|
||||
|
||||
textStorage.addLayoutManager(layoutManager)
|
||||
|
||||
layoutManager.glyphRange(for: textContainer)
|
||||
let size = layoutManager.usedRect(for: textContainer).size
|
||||
|
||||
// For some reason, in production builds, the textStorage
|
||||
// seems to get optimized out in many circumstances. This
|
||||
// results in `usedRect` measuring an empty string and a
|
||||
// size of 0,0.
|
||||
// TODO: Figure out a better way to fix this. For now,
|
||||
// by just using the textStorage later it ensures that it
|
||||
// is properly measured.
|
||||
_ = textStorage
|
||||
|
||||
return size.ceil
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user