diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2019-06-24 08:54:24 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2019-06-24 08:54:24 +1000 |
commit | 42a1e67cb346d2ce4667eb7bb15d72ffe15ebdc3 (patch) | |
tree | 31434ea57dbe1638e66fd0d97277e12f713950f9 /cocoa/ScintillaView.mm | |
parent | b576eacdb617861f870abf117d40e4f70d92bf35 (diff) | |
download | scintilla-mirror-42a1e67cb346d2ce4667eb7bb15d72ffe15ebdc3.tar.gz |
On Cocoa, stop internal failures for missing fonts.
Avoid propagating terminating NULs from SCI_STYLEGETFONT and SCI_TARGETASUTF8.
Diffstat (limited to 'cocoa/ScintillaView.mm')
-rw-r--r-- | cocoa/ScintillaView.mm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index e534a01aa..08eb0aa12 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -415,7 +415,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { } [mOwner message: SCI_SETTARGETRANGE wParam: posRange.location lParam: NSMaxRange(posRange)]; - std::string text([mOwner message: SCI_TARGETASUTF8] + 1, 0); + std::string text([mOwner message: SCI_TARGETASUTF8], 0); [mOwner message: SCI_TARGETASUTF8 wParam: 0 lParam: reinterpret_cast<sptr_t>(&text[0])]; text = FixInvalidUTF8(text); NSString *result = @(text.c_str()); @@ -425,12 +425,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles const char styleByte = static_cast<char>([mOwner message: SCI_GETSTYLEAT wParam: posRange.location]); const long style = static_cast<unsigned char>(styleByte); - std::string fontName([mOwner message: SCI_STYLEGETFONT wParam: style lParam: 0] + 1, 0); + std::string fontName([mOwner message: SCI_STYLEGETFONT wParam: style lParam: 0], 0); [mOwner message: SCI_STYLEGETFONT wParam: style lParam: (sptr_t)&fontName[0]]; const CGFloat fontSize = [mOwner message: SCI_STYLEGETSIZEFRACTIONAL wParam: style] / 100.0f; NSString *sFontName = @(fontName.c_str()); NSFont *font = [NSFont fontWithName: sFontName size: fontSize]; - [asResult addAttribute: NSFontAttributeName value: font range: rangeAS]; + if (font) { + [asResult addAttribute: NSFontAttributeName value: font range: rangeAS]; + } return asResult; } |