mirror of
https://github.com/zhigang1992/CurvyText.git
synced 2026-03-25 17:55:05 +08:00
Handle invalidations
This commit is contained in:
@@ -99,22 +99,25 @@ struct PathTextLayoutManager {
|
||||
return GlyphRun(run: run, locations: locations)
|
||||
}
|
||||
|
||||
updateGlyphPositions()
|
||||
needsGlyphGeneration = false
|
||||
}
|
||||
|
||||
private mutating func updateGlyphPositions() {
|
||||
if needsGlyphGeneration { updateGlyphRuns() }
|
||||
var tangents = TangentGenerator(path: path)
|
||||
glyphRuns = glyphRuns.map {
|
||||
var glyphRun = $0
|
||||
glyphRun.updatePositions(withTangents: &tangents)
|
||||
return glyphRun
|
||||
}
|
||||
|
||||
needsLayout = false
|
||||
}
|
||||
|
||||
public mutating func draw(in context: CGContext) {
|
||||
// FIXME: Check if needed
|
||||
updateGlyphRuns()
|
||||
updateGlyphPositions()
|
||||
if needsLayout {
|
||||
updateGlyphPositions()
|
||||
}
|
||||
|
||||
// FIXME: Check if flip is needed (macos)
|
||||
context.textMatrix = CGAffineTransform(translationX: 0, y:0).scaledBy(x: 1, y: -1)
|
||||
|
||||
@@ -87,7 +87,6 @@ public class PathTextView: UIView {
|
||||
|
||||
public override func draw(_ rect: CGRect) {
|
||||
let context = UIGraphicsGetCurrentContext()!
|
||||
|
||||
layoutManager.draw(in: context)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user