aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2019-06-24 08:54:24 +1000
committerNeil Hodgson <nyamatongwe@gmail.com>2019-06-24 08:54:24 +1000
commit0ca537117555a617536bf70cc176525484611be5 (patch)
tree63ec4b0e7c3faa9634e889dbffeed288cdaad079
parent9c8aa71e5d2ff653819b33a9a755934f93c13796 (diff)
downloadscintilla-mirror-0ca537117555a617536bf70cc176525484611be5.tar.gz
Backport: On Cocoa, stop internal failures for missing fonts.
Avoid propagating terminating NULs from SCI_STYLEGETFONT and SCI_TARGETASUTF8. Backport of changeset 7601:b3e8143194f8.
-rw-r--r--cocoa/ScintillaView.mm8
1 files changed, 5 insertions, 3 deletions
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm
index d61c00e6b..ad8d7dc01 100644
--- a/cocoa/ScintillaView.mm
+++ b/cocoa/ScintillaView.mm
@@ -443,7 +443,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 = [NSString stringWithUTF8String: text.c_str()];
@@ -453,12 +453,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 = [NSString stringWithUTF8String: 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;
}