Handle invalidations

This commit is contained in:
Rob Napier
2020-01-01 17:42:12 -05:00
parent 7de452fa50
commit 363af726fa
2 changed files with 7 additions and 5 deletions

View File

@@ -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)

View File

@@ -87,7 +87,6 @@ public class PathTextView: UIView {
public override func draw(_ rect: CGRect) {
let context = UIGraphicsGetCurrentContext()!
layoutManager.draw(in: context)
}
}