Skip to content

Commit

Permalink
[bugfix] Chinese characters are chopped migueldeicaza#227
Browse files Browse the repository at this point in the history
  • Loading branch information
andy380743909 committed Jun 10, 2022
1 parent 7976db8 commit 6a0c89b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Sources/SwiftTerm/Apple/AppleTerminalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,34 @@ extension TerminalView {
count = runGlyphsCount
}

#if false
var positions = runGlyphs.enumerated().map { (i: Int, glyph: CGGlyph) -> CGPoint in
CGPoint(x: lineOrigin.x + (cellDimension.width * CGFloat(col + i)), y: lineOrigin.y + ceil(lineLeading + lineDescent))
}


#else
/**
let range = CFRangeMake(i, 1)
let glyph: UnsafeMutablePointer<CGGlyph> = UnsafeMutablePointer<CGGlyph>.allocate(capacity: 1)
let position: UnsafeMutablePointer<CGPoint> = UnsafeMutablePointer<CGPoint>.allocate(capacity: 1)
glyph.initialize(to: 0)
position.initialize(to: .zero)
CTRunGetGlyphs(singleGlyphBits, range, glyph)
CTRunGetPositions(singleGlyphBits, range, position);
*/
let ctPositions = [CGPoint](unsafeUninitializedCapacity: runGlyphsCount) { (bufferPointer, count) in
CTRunGetPositions(run, CFRange(), bufferPointer.baseAddress!)
count = runGlyphsCount
}

var positions = ctPositions.enumerated().map { (i: Int, position: CGPoint) -> CGPoint in
CGPoint(x: lineOrigin.x + position.x, y: lineOrigin.y + ceil(lineLeading + lineDescent))
}

#endif

var backgroundColor: TTColor?
if runAttributes.keys.contains(.selectionBackgroundColor) {
backgroundColor = runAttributes[.selectionBackgroundColor] as? TTColor
Expand Down

0 comments on commit 6a0c89b

Please sign in to comment.