• R/O
  • HTTP
  • SSH
  • HTTPS

hengbandosx: Commit

The master and For2.2.2-Refactoring branches track hengband.

OS X development happens on the version-1-6-2, version-2-2-1, and For2.2.2-Refactoring-Cooca2 branches.


Commit MetaInfo

Revisiona7ee8e8af9d9c6a7d5eeca15fea21aa3bd7041dc (tree)
Time2020-11-22 10:03:43
AuthorEric 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.

Change Summary

Incremental Difference

--- a/src/main-cocoa.m
+++ b/src/main-cocoa.m
@@ -2445,13 +2445,21 @@ static int compare_advances(const void *ap, const void *bp)
24452445 {
24462446 CGFloat tileOffsetY = self.fontAscender;
24472447 CGFloat tileOffsetX = 0.0;
2448- UniChar unicharString[2] = {(UniChar)wchar, 0};
2448+ UniChar unicharString[2];
2449+ int nuni;
2450+
2451+ if (CFStringGetSurrogatePairForLongCharacter(wchar, unicharString)) {
2452+ nuni = 2;
2453+ } else {
2454+ unicharString[0] = (UniChar) wchar;
2455+ nuni = 1;
2456+ }
24492457
24502458 /* Get glyph and advance */
2451- CGGlyph thisGlyphArray[1] = { 0 };
2452- CGSize advances[1] = { { 0, 0 } };
2459+ CGGlyph thisGlyphArray[2] = { 0, 0 };
2460+ CGSize advances[2] = { { 0, 0 }, { 0, 0 } };
24532461 CTFontGetGlyphsForCharacters(
2454- (CTFontRef)font, unicharString, thisGlyphArray, 1);
2462+ (CTFontRef)font, unicharString, thisGlyphArray, nuni);
24552463 CGGlyph glyph = thisGlyphArray[0];
24562464 CTFontGetAdvancesForGlyphs(
24572465 (CTFontRef)font, kCTFontHorizontalOrientation, thisGlyphArray,
Show on old repository browser