diff --git a/AppKit/CPTextView/CPLayoutManager.j b/AppKit/CPTextView/CPLayoutManager.j index d6b3f0cd2..70437407c 100644 --- a/AppKit/CPTextView/CPLayoutManager.j +++ b/AppKit/CPTextView/CPLayoutManager.j @@ -1059,6 +1059,7 @@ var _objectsInRange = function(aList, aRange) @implementation _CPLineFragment : CPObject { CPArray _glyphsFrames @accessors(getter=glyphFrames); + CPArray _glyphsOffsets; BOOL _isInvalid; BOOL _isLast; @@ -1147,13 +1148,16 @@ var _objectsInRange = function(aList, aRange) - (void)setAdvancements:(CPArray)someAdvancements { var count = someAdvancements.length, - origin = CGPointMake(_fragmentRect.origin.x + _location.x, _fragmentRect.origin.y); + origin = CGPointMake(_fragmentRect.origin.x + _location.x, _fragmentRect.origin.y), + height = _usedRect.size.height; _glyphsFrames = new Array(count); + _glyphsOffsets = new Array(count); for (var i = 0; i < count; i++) { - _glyphsFrames[i] = CGRectMake(origin.x, origin.y, someAdvancements[i].width, _usedRect.size.height); // FIXME: origin.y+(height-someAdvancements[i].height) for baseline alignment + _glyphsFrames[i] = CGRectMake(origin.x, origin.y - someAdvancements[i].descent, someAdvancements[i].width, height); + _glyphsOffsets[i] = height-someAdvancements[i].height + someAdvancements[i].descent; origin.x += someAdvancements[i].width; } } @@ -1227,7 +1231,7 @@ var _objectsInRange = function(aList, aRange) var loc = run._range.location - _runs[0]._range.location; orig.x = _glyphsFrames[loc].origin.x + aPoint.x; - orig.y = _glyphsFrames[loc].origin.y + aPoint.y; + orig.y = _glyphsFrames[loc].origin.y + aPoint.y + _glyphsOffsets[loc]; run.elem.style.left = (orig.x) + "px"; run.elem.style.top = (orig.y) + "px"; diff --git a/AppKit/CPTextView/CPTypesetter.j b/AppKit/CPTextView/CPTypesetter.j index 65c56b332..4e1934a0d 100644 --- a/AppKit/CPTextView/CPTypesetter.j +++ b/AppKit/CPTextView/CPTypesetter.j @@ -319,7 +319,10 @@ var CPSystemTypesetterFactory; isNewline = YES; } - advancements.push(CPMakeSize(rangeWidth - prevRangeWidth, ascent)); + var advancement = CPMakeSize(rangeWidth - prevRangeWidth, ascent); + advancement.descent=descent; + advancements.push(advancement); + prevRangeWidth = _lineWidth = rangeWidth; if (lineOrigin.x + rangeWidth > containerSize.width)