From 6d421e9349e6f50cdd06a02d341af87f05d8f4f8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 22 May 2016 17:01:18 -0400 Subject: [PATCH] Implemented a test of non-BMP characters that need surrogate pairs on UTF-16-based systems on test page 10. --- test/page10.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/page10.c b/test/page10.c index 0262c815..dc312ab8 100644 --- a/test/page10.c +++ b/test/page10.c @@ -1,9 +1,6 @@ // 22 december 2015 #include "test.h" -// TODO figure out how the various backends handle non-BMP characters/surrogate pairs -// use: F0 90 8C 88 (surrogates D800 DF08) - static uiEntry *textString; static uiFontButton *textFontButton; static uiColorButton *textColorButton; @@ -29,6 +26,8 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp) uiDrawTextFont *font; uiDrawTextLayout *layout; double r, g, b, al; + char surrogates[1 + 4 + 1 + 1]; + double width, height; font = uiFontButtonFont(textFontButton); @@ -44,6 +43,22 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp) 14, 18, r, g, b, al); uiDrawText(dp->Context, 10, 10, layout); + uiDrawTextLayoutExtents(layout, &width, &height); + uiDrawFreeTextLayout(layout); + + surrogates[0] = 'x'; + surrogates[1] = 0xF0; // surrogates D800 DF08 + surrogates[2] = 0x90; + surrogates[3] = 0x8C; + surrogates[4] = 0x88; + surrogates[5] = 'y'; + surrogates[6] = '\0'; + + layout = uiDrawNewTextLayout(surrogates, font, -1); + uiDrawTextLayoutSetColor(layout, + 1, 2, + 1, 0, 0.5, 0.5); + uiDrawText(dp->Context, 10, 10 + height, layout); uiDrawFreeTextLayout(layout); uiDrawFreeTextFont(font);