diff options
-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 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; } |