Mac OS: The 'variation selectors' of Unicode change the glyph associated to the preceding unicode character.
This defeats the procedure FLTK uses to compute text widths (precomputing the width of each used character) because the width of character n is not unique and potentially depends on character n+1. Therefore, we now remove variation selectors from the input string before drawing it. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10791 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
7c0c17a452
commit
db6b98e4f7
@ -492,12 +492,18 @@ static CGColorRef flcolortocgcolor(Fl_Color i)
|
||||
#endif
|
||||
|
||||
static void fl_mac_draw(const char *str, int n, float x, float y, Fl_Graphics_Driver *driver) {
|
||||
// the range [0xFE00-0xFE0F] corresponds to Unicode's 'variation selectors'
|
||||
static CFCharacterSetRef set = CFCharacterSetCreateWithCharactersInRange(NULL, CFRangeMake(0xFE00, 16));
|
||||
CFRange res;
|
||||
// convert to UTF-16 first
|
||||
UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if (fl_mac_os_version >= Fl_X::CoreText_threshold) {
|
||||
CFStringRef str16 = CFStringCreateWithCharactersNoCopy(NULL, uniStr, n, kCFAllocatorNull);
|
||||
CFMutableStringRef str16 = CFStringCreateMutableWithExternalCharactersNoCopy(NULL, uniStr, n, n, kCFAllocatorNull);
|
||||
if (str16 == NULL) return; // shd not happen
|
||||
while (CFStringFindCharacterFromSet(str16, set, CFRangeMake(0, CFStringGetLength(str16)), 0, &res)) {
|
||||
CFStringReplace(str16, res, CFSTR("")); // remove all variation selectors from the input string
|
||||
}
|
||||
CGColorRef color = flcolortocgcolor(driver->color());
|
||||
CFDictionarySetValue (attributes, kCTFontAttributeName, driver->font_descriptor()->fontref);
|
||||
CFDictionarySetValue (attributes, kCTForegroundColorAttributeName, color);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user