From e2f72ecffcb786a78ca560318faa2c72780d69d2 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Thu, 18 Jun 2015 20:23:00 +0200 Subject: [PATCH] prepare baseline support --- AppKit/CPTextView/CPTextView.j | 2 +- AppKit/CPTextView/CPTypesetter.j | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 36061b515..162c1b11d 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -2128,7 +2128,7 @@ var _CPCopyPlaceholder = '-'; + (void)initialize { _CPNativeInputField = document.createElement("div"); - _CPNativeInputField.contentEditable=YES; + _CPNativeInputField.contentEditable = YES; _CPNativeInputField.onkeyup = function(e) { diff --git a/AppKit/CPTextView/CPTypesetter.j b/AppKit/CPTextView/CPTypesetter.j index 4a3c5b59a..daed9094e 100644 --- a/AppKit/CPTextView/CPTypesetter.j +++ b/AppKit/CPTextView/CPTypesetter.j @@ -119,6 +119,8 @@ var CPSystemTypesetterFactory; float _lineWidth; unsigned _indexOfCurrentContainer; + + CPArray _lineFragments; } @@ -174,6 +176,7 @@ var CPSystemTypesetterFactory; containerSize = aContainer._size; [_layoutManager setTextContainer:_currentTextContainer forGlyphRange:lineRange]; // creates a new lineFragment + _lineFragments.push([_layoutManager._lineFragments lastObject]); [_layoutManager setLineFragmentRect:rect forGlyphRange:lineRange usedRect:rect]; switch ([_currentParagraph alignment]) @@ -194,7 +197,10 @@ var CPSystemTypesetterFactory; [_layoutManager setLocation:CPMakePoint(myX, _lineBase) forStartOfGlyphRange:lineRange]; [_layoutManager _setAdvancements:advancements forGlyphRange:lineRange]; -//FIXME: sameLine should result in fixing the previous linefragments of this line, e.g. when fontsizes differ + if (!sameLine) + { +//FIXME: sameLine should result in fixing the _lineFragments, e.g. when fontsizes differ + } if (!lineCount) // do not rescue on first line return NO; @@ -239,7 +245,7 @@ var CPSystemTypesetterFactory; prevRangeWidth = 0, measuringRange = CPMakeRange(glyphIndex, 0), currentAnchor = 0, - _previousFont; + previousFont; if (glyphIndex > 0) lineOrigin = CGPointCreateCopy([_layoutManager lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:nil].origin); @@ -253,6 +259,8 @@ var CPSystemTypesetterFactory; if (![_textStorage length]) return; + _lineFragments = []; + for (; numLines != maxNumLines && glyphIndex < numberOfGlyphs; glyphIndex++) { if (!CPLocationInRange(glyphIndex, _attributesRange)) @@ -269,11 +277,11 @@ var CPSystemTypesetterFactory; leading = (ascent - descent) * 0.2; // FAKE leading } - if (_previousFont !== _currentFont) + if (previousFont !== _currentFont) { measuringRange = CPMakeRange(glyphIndex, 0); currentAnchor = prevRangeWidth; - _previousFont = _currentFont; + previousFont = _currentFont; } lineRange.length++; @@ -360,6 +368,7 @@ var CPSystemTypesetterFactory; lineOrigin.x = 0; numLines++; isNewline = NO; + _lineFragments = []; } _lineWidth = 0;