mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Merge pull request #3240 from daboe01/baseline-fix
Fixed: baseline alignment in _CPLineFragment to prevent overlapping text descenders
This commit is contained in:
@@ -965,16 +965,11 @@ _oncontextmenuhandler = function () { return false; };
|
||||
if (frame)
|
||||
{
|
||||
var correctedRect = CGRectCreateCopy(frame);
|
||||
correctedRect.size.height -= frame._descent;
|
||||
correctedRect.origin.y -= frame._descent;
|
||||
|
||||
if (!rect)
|
||||
rect = CGRectCreateCopy(correctedRect);
|
||||
else
|
||||
rect = CGRectUnion(rect, correctedRect);
|
||||
|
||||
if (_isNewlineCharacter([[_textStorage string] characterAtIndex:MAX(0, CPMaxRange(selectedCharRange) - 1)]))
|
||||
rect.size.width = containerSize.width - rect.origin.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1348,7 +1343,10 @@ var _objectsInRange = function(aList, aRange)
|
||||
{
|
||||
_glyphsFrames[i] = CGRectMake(origin.x, origin.y, someAdvancements[i].width, height);
|
||||
_glyphsFrames[i]._descent = someAdvancements[i].descent;
|
||||
_glyphsOffsets[i] = height - someAdvancements[i].height;
|
||||
|
||||
// Align the run's baseline with the common line baseline (_location.y)
|
||||
_glyphsOffsets[i] = _location.y - someAdvancements[i].height;
|
||||
|
||||
origin.x += someAdvancements[i].width;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2337,17 +2337,15 @@ Sets the selection to a range of characters in response to user action.
|
||||
|
||||
var loc = (_selectionRange.location == numberOfGlyphs) ? _selectionRange.location - 1 : _selectionRange.location,
|
||||
caretOffset = [_layoutManager _characterOffsetAtLocation:loc],
|
||||
oldYPosition = CGRectGetMaxY(caretRect),
|
||||
caretDescend = [_layoutManager _descentAtLocation:loc];
|
||||
font = [_textStorage attribute:CPFontAttributeName atIndex:loc effectiveRange:nil] || [self font];
|
||||
|
||||
if (caretOffset > 0)
|
||||
{
|
||||
caretRect.origin.y += caretOffset;
|
||||
caretRect.size.height = oldYPosition - caretRect.origin.y;
|
||||
}
|
||||
|
||||
if (caretDescend < 0)
|
||||
caretRect.size.height -= caretDescend;
|
||||
// Set the caret height to match the size of the active font
|
||||
caretRect.size.height = [font size];
|
||||
|
||||
if (_selectionRange.location == numberOfGlyphs)
|
||||
caretRect.origin.x += caretRect.size.width;
|
||||
@@ -2356,7 +2354,7 @@ Sets the selection to a range of characters in response to user action.
|
||||
caretRect.origin.y += _textContainerOrigin.y;
|
||||
|
||||
caretRect.size.width = MAX(1.0, caretRect.size.width);
|
||||
caretRect.size.height = MAX(1.0, caretRect.size.height);
|
||||
caretRect.size.height = MAX(1.0, caretRect.size.height) + 2;
|
||||
|
||||
return caretRect;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user