mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
🐛 Measure latin chars with subpixel font scaling
This commit is contained in:
@@ -2893,12 +2893,12 @@ describe "TextEditorComponent", ->
|
||||
|
||||
describe "when changing the font", ->
|
||||
it "measures the default char width and the double width char width", ->
|
||||
expect(editor.getDefaultCharWidth()).toBe(12)
|
||||
expect(editor.getDefaultCharWidth()).toBeCloseTo(12, 0)
|
||||
|
||||
component.setFontSize(10)
|
||||
nextAnimationFrame()
|
||||
|
||||
expect(editor.getDefaultCharWidth()).toBe(6)
|
||||
expect(editor.getDefaultCharWidth()).toBeCloseTo(6, 0)
|
||||
expect(editor.getDoubleWidthCharWidth()).toBe(10)
|
||||
|
||||
describe "hiding and showing the editor", ->
|
||||
|
||||
@@ -266,7 +266,7 @@ class DisplayBuffer extends Model
|
||||
@getEditorWidthInChars()
|
||||
|
||||
getSoftWrapColumnForTokenizedLine: (tokenizedLine) ->
|
||||
lineMaxWidth = Math.round(@getSoftWrapColumn() * @getDefaultCharWidth())
|
||||
lineMaxWidth = @getSoftWrapColumn() * @getDefaultCharWidth()
|
||||
iterator = tokenizedLine.getTokenIterator()
|
||||
column = 0
|
||||
currentWidth = 0
|
||||
|
||||
@@ -7,7 +7,9 @@ DummyLineNode.className = 'line'
|
||||
DummyLineNode.style.position = 'absolute'
|
||||
DummyLineNode.style.visibility = 'hidden'
|
||||
DummyLineNode.appendChild(document.createElement('span'))
|
||||
DummyLineNode.firstChild.textContent = 'xフ'
|
||||
DummyLineNode.appendChild(document.createElement('span'))
|
||||
DummyLineNode.children[0].textContent = 'x'
|
||||
DummyLineNode.children[1].textContent = '我'
|
||||
|
||||
RangeForMeasurement = document.createRange()
|
||||
|
||||
@@ -81,14 +83,8 @@ class LinesComponent extends TiledComponent
|
||||
textNode = DummyLineNode.firstChild.childNodes[0]
|
||||
|
||||
lineHeightInPixels = DummyLineNode.getBoundingClientRect().height
|
||||
|
||||
RangeForMeasurement.setStart(textNode, 0)
|
||||
RangeForMeasurement.setEnd(textNode, 1)
|
||||
defaultCharWidth = RangeForMeasurement.getBoundingClientRect().width
|
||||
|
||||
RangeForMeasurement.setStart(textNode, 1)
|
||||
RangeForMeasurement.setEnd(textNode, 2)
|
||||
doubleWidthCharWidth = RangeForMeasurement.getBoundingClientRect().width
|
||||
defaultCharWidth = DummyLineNode.children[0].getBoundingClientRect().width
|
||||
doubleWidthCharWidth = DummyLineNode.children[1].getBoundingClientRect().width
|
||||
|
||||
@domNode.removeChild(DummyLineNode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user