• R/O
  • HTTP
  • SSH
  • HTTPS

hengbandosx: 提交

The master and develop branches track hengband.

OS X development happens on the macos-1-6-2, macos-2-2-1, and macos-develop branches.


Commit MetaInfo

修订版b9521a4f258cc8d53c174f328c41acb121538b2c (tree)
时间2020-11-22 11:06:11
作者Eric Branlund <ebranlund@fast...>
CommiterEric Branlund

Log Message

In drawWChar(), allow for the unlikely possibility that the character to be rendered requires two UniChars (as a surrogate pair). Previously had assumed that only one UniChar was needed and cast the whcar_t to a UniChar.

更改概述

差异

--- a/src/main-cocoa.m
+++ b/src/main-cocoa.m
@@ -2466,13 +2466,21 @@ static int compare_advances(const void *ap, const void *bp)
24662466 {
24672467 CGFloat tileOffsetY = self.fontAscender;
24682468 CGFloat tileOffsetX = 0.0;
2469- UniChar unicharString[2] = {(UniChar)wchar, 0};
2469+ UniChar unicharString[2];
2470+ int nuni;
2471+
2472+ if (CFStringGetSurrogatePairForLongCharacter(wchar, unicharString)) {
2473+ nuni = 2;
2474+ } else {
2475+ unicharString[0] = (UniChar) wchar;
2476+ nuni = 1;
2477+ }
24702478
24712479 /* Get glyph and advance */
2472- CGGlyph thisGlyphArray[1] = { 0 };
2473- CGSize advances[1] = { { 0, 0 } };
2480+ CGGlyph thisGlyphArray[2] = { 0, 0 };
2481+ CGSize advances[2] = { { 0, 0 }, { 0, 0 } };
24742482 CTFontGetGlyphsForCharacters(
2475- (CTFontRef)font, unicharString, thisGlyphArray, 1);
2483+ (CTFontRef)font, unicharString, thisGlyphArray, nuni);
24762484 CGGlyph glyph = thisGlyphArray[0];
24772485 CTFontGetAdvancesForGlyphs(
24782486 (CTFontRef)font, kCTFontHorizontalOrientation, thisGlyphArray,
Show on old repository browser