FontDemo: make it multibyte chars compliant (UTF-8)

fixes #8146.
This commit is contained in:
Philippe Saint-Pierre 2012-07-21 11:13:41 -04:00
parent e6e6f56ccf
commit 6b0362305f
2 changed files with 11 additions and 2 deletions

View File

@ -20,6 +20,8 @@
#include <Message.h>
#include <Shape.h>
#include <utf8_functions.h>
#include "messages.h"
#undef B_TRANSLATION_CONTEXT
@ -99,7 +101,7 @@ FontDemoView::_DrawView(BView* view)
view->SetFont(&fFont, B_FONT_ALL);
const size_t size = strlen(fString);
const size_t size = UTF8CountChars(fString, -1);
BRect boundBoxes[size];
if (OutLineLevel())
@ -137,6 +139,8 @@ FontDemoView::_DrawView(BView* view)
fBoxRegion.MakeEmpty();
char *tmpString = fString;
for (size_t i = 0; i < size; i++) {
xCoordArray[i] = 0.0f;
yCoordArray[i] = 0.0f;
@ -159,7 +163,10 @@ FontDemoView::_DrawView(BView* view)
} else {
view->SetHighColor(0, 0, 0);
view->SetDrawingMode(fDrawingMode);
view->DrawChar(fString[i], BPoint(xCoordArray[i], yCoordArray[i]));
int32 length = UTF8NextCharLen(tmpString);
view->DrawString(tmpString, length,
BPoint(xCoordArray[i], yCoordArray[i]));
tmpString += length;
}
if (BoundingBoxes() && !OutLineLevel()) {

View File

@ -2,6 +2,8 @@ SubDir HAIKU_TOP src apps fontdemo ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders interface ;
Application FontDemo :
ControlView.cpp
FontDemo.cpp