* Source/GSHorizontalTypesetter.m: (_addExtraLineFragment) get paragraph style and

font from NSLayoutManager's typing attributes. Fixes insertion point height for empty
        text objects (NSTextView, NSTexField etc.).
This commit is contained in:
Sergii Stoian 2019-12-10 02:09:13 +02:00
parent 76d6047d56
commit 5415783c56
2 changed files with 22 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2019-12-10 Sergii Stoian <stoyan255@gmail.com>
* Source/GSHorizontalTypesetter.m: (_addExtraLineFragment) get paragraph style and
font from NSLayoutManager's typing attributes. Fixes insertion point height for empty
text objects (NSTextView, NSTexField etc.).
2019-12-09 Sergii Stoian <stoyan255@gmail.com>
* Source/NSStringDrawing.m: fixed incorrect string drawing (shortened, misplaced)

View file

@ -40,6 +40,8 @@
#import "AppKit/NSTextAttachment.h"
#import "AppKit/NSTextContainer.h"
#import "AppKit/NSTextStorage.h"
#import "AppKit/NSLayoutManager.h"
#import "AppKit/NSTextView.h"
#import "GNUstepGUI/GSLayoutManager.h"
#import "GNUstepGUI/GSHorizontalTypesetter.h"
@ -534,9 +536,20 @@ For bigger values the width gets ignored.
}
else
{
// FIXME These should come from the typing attributes
curParagraphStyle = [NSParagraphStyle defaultParagraphStyle];
curFont = [NSFont userFontOfSize: 0];
NSLayoutManager *layoutManager = [[curTextContainer textView] layoutManager];
if (layoutManager)
{
NSDictionary *typingAttributes = layoutManager->_typingAttributes;
curParagraphStyle = [typingAttributes
objectForKey: NSParagraphStyleAttributeName];
curFont = [typingAttributes objectForKey: NSFontAttributeName];
}
else
{
curParagraphStyle = [NSParagraphStyle defaultParagraphStyle];
curFont = [NSFont userFontOfSize: 0];
}
}
line_height = [curFont defaultLineHeightForFont];