aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/ScintillaView.mm8
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;
}