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.
修订版 | b9521a4f258cc8d53c174f328c41acb121538b2c (tree) |
---|---|
时间 | 2020-11-22 11:06:11 |
作者 | Eric Branlund <ebranlund@fast...> |
Commiter | Eric Branlund |
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.
@@ -2466,13 +2466,21 @@ static int compare_advances(const void *ap, const void *bp) | ||
2466 | 2466 | { |
2467 | 2467 | CGFloat tileOffsetY = self.fontAscender; |
2468 | 2468 | 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 | + } | |
2470 | 2478 | |
2471 | 2479 | /* 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 } }; | |
2474 | 2482 | CTFontGetGlyphsForCharacters( |
2475 | - (CTFontRef)font, unicharString, thisGlyphArray, 1); | |
2483 | + (CTFontRef)font, unicharString, thisGlyphArray, nuni); | |
2476 | 2484 | CGGlyph glyph = thisGlyphArray[0]; |
2477 | 2485 | CTFontGetAdvancesForGlyphs( |
2478 | 2486 | (CTFontRef)font, kCTFontHorizontalOrientation, thisGlyphArray, |