             let glyphIndex = self.glyphIndexForCharacter(at: charIndex)
             
             let path: CGPath
-            if let cache = pathCache[invisible] {
+            if let cache = pathCache[codeUnit] {
                 path = cache
             } else {
                 let glyphWidth: CGFloat

        let baselineOffset = (textContainer.layoutOrientation == .vertical)
            ? baselineOffset - (self.textFont.ascender - self.textFont.capHeight) / 2  // adjust to center symbols
            : baselineOffset
        var pathCache: [Invisible: CGPath] = [:]
        
        // setup drawing parameters
        NSGraphicsContext.saveGraphicsState()

                }
                
                path = invisible.path(in: CGSize(width: glyphWidth, height: glyphHeight), isRTL: isRTL)
                if invisible != .tab {
                    pathCache[codeUnit] = path
                }
            }
            
