mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 23:02:35 +03:00
Fix rendering with ligatures turned off
This commit is contained in:
parent
79e837bad6
commit
6c1882094d
@ -66,7 +66,7 @@ class MyView: NSView {
|
||||
)
|
||||
*/
|
||||
|
||||
let runs = (0..<4).map { row in
|
||||
let runs = (4..<5).map { row in
|
||||
AttributesRun(
|
||||
location: CGPoint(x: 0, y: CGFloat(row) * cellSize.height),
|
||||
cells: self.ugrid.cells[row][0..<10],
|
||||
@ -88,6 +88,7 @@ class MyView: NSView {
|
||||
reverse: false
|
||||
)
|
||||
|
||||
self.runDrawer.usesLigatures = false
|
||||
runs.forEach { run in
|
||||
self.runDrawer.draw(
|
||||
runs,
|
||||
@ -181,6 +182,15 @@ class MyView: NSView {
|
||||
chunk: (0..<10).compactMap { String($0) },
|
||||
attrIds: Array(repeating: 0, count: 10)
|
||||
)
|
||||
self.ugrid.update(
|
||||
row: 4,
|
||||
startCol: 0,
|
||||
endCol: 9,
|
||||
clearCol: 9,
|
||||
clearAttr: 0,
|
||||
chunk: ["क", "ख", "ग", "घ", "ड़", "-", ">", " ", "ड़"],
|
||||
attrIds: Array(repeating: 0, count: 9)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
4B17E549209E3E4100265C1D /* RxNeovimApi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B17E548209E3E4100265C1D /* RxNeovimApi.framework */; };
|
||||
4B21ED53213D4AEC009FD017 /* CocoaCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B0C89838D8402BB80BFC /* CocoaCommons.swift */; };
|
||||
4B4A48DC222C7C6A00C8E3A1 /* SharedTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B4A48DB222C7C6A00C8E3A1 /* SharedTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
4B6DFB39223592B90066BB43 /* OSLogCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B39C7DCDA4E9D5220CD8 /* OSLogCommons.swift */; };
|
||||
4B8662E81FDC3F9F007F490D /* com.qvacua.NvimView.vim in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B8662E41FDC3D4F007F490D /* com.qvacua.NvimView.vim */; };
|
||||
4B90F02E1FD2AFAE008A39E0 /* NvimView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B90F0101FD2AFAC008A39E0 /* NvimView.swift */; };
|
||||
4B90F02F1FD2AFAE008A39E0 /* NvimView+Resize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B90F0111FD2AFAC008A39E0 /* NvimView+Resize.swift */; };
|
||||
@ -704,6 +705,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4B6DFB39223592B90066BB43 /* OSLogCommons.swift in Sources */,
|
||||
4B21ED53213D4AEC009FD017 /* CocoaCommons.swift in Sources */,
|
||||
4BF18531213142F900954FE7 /* ColorUtils.swift in Sources */,
|
||||
4BF18532213142F900954FE7 /* FontUtils.swift in Sources */,
|
||||
|
@ -100,11 +100,9 @@ final class Typesetter {
|
||||
let unichars = self.utf16Chars(from: run.nvimUtf16Cells)
|
||||
var glyphs = Array<CGGlyph>(repeating: CGGlyph(), count: unichars.count)
|
||||
|
||||
let gotAllGlyphs = unichars.withUnsafeBufferPointer { pointer in
|
||||
CTFontGetGlyphsForCharacters(
|
||||
font, pointer.baseAddress!, &glyphs, unichars.count
|
||||
)
|
||||
}
|
||||
let gotAllGlyphs = CTFontGetGlyphsForCharacters(
|
||||
font, unichars, &glyphs, unichars.count
|
||||
)
|
||||
if gotAllGlyphs {
|
||||
let startColumnForPositions = startColumn + run.startColumn
|
||||
let endColumn = startColumnForPositions + glyphs.count
|
||||
@ -119,12 +117,9 @@ final class Typesetter {
|
||||
]
|
||||
}
|
||||
|
||||
self.logger.info(
|
||||
"Could not get all glyphs for single-width singe UTF16 character!"
|
||||
)
|
||||
let groupRanges = glyphs.groupedRanges { _, element in element == 0 }
|
||||
let groupRuns: [[FontGlyphRun]] = groupRanges.map { range in
|
||||
if unichars[range.lowerBound] == 0 {
|
||||
if glyphs[range.lowerBound] == 0 {
|
||||
let nvimUtf16Cells = unichars[range].map { [$0] }
|
||||
return self.fontGlyphRunsWithLigatures(
|
||||
nvimUtf16Cells: nvimUtf16Cells,
|
||||
@ -135,16 +130,15 @@ final class Typesetter {
|
||||
)
|
||||
} else {
|
||||
let startColumnForPositions = startColumn + range.lowerBound
|
||||
let endColumn = startColumnForPositions + glyphs.count
|
||||
let endColumn = startColumnForPositions + range.count
|
||||
let positions = (startColumnForPositions..<endColumn).map { i in
|
||||
CGPoint(
|
||||
x: offset.x
|
||||
+ CGFloat(i + startColumn + range.lowerBound) * cellWidth,
|
||||
x: offset.x + CGFloat(i) * cellWidth,
|
||||
y: offset.y
|
||||
)
|
||||
}
|
||||
return [
|
||||
FontGlyphRun(font: font, glyphs: glyphs, positions: positions)
|
||||
FontGlyphRun(font: font, glyphs: Array(glyphs[range]), positions: positions)
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -166,7 +160,7 @@ final class Typesetter {
|
||||
string: String(utf16CodeUnits: utf16Chars, count: utf16Chars.count),
|
||||
attributes: [
|
||||
.font: font,
|
||||
.ligature: 1
|
||||
.ligature: NSNumber(integerLiteral: 0)
|
||||
]
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user