diff options
| author | Philippe Saint-Pierre <stpere@gmail.com> | 2012-07-21 11:13:41 -0400 |
|---|---|---|
| committer | Philippe Saint-Pierre <stpere@gmail.com> | 2012-07-21 11:17:41 -0400 |
| commit | 6b0362305fa9f8a35ce0f2b7052b4c901d040fe9 (patch) | |
| tree | 97758cb4f19d6047ff3f636d0dcffa1ec712a0e2 | |
| parent | e6e6f56ccf702fe4bc09821b8064861a200122a8 (diff) | |
FontDemo: make it multibyte chars compliant (UTF-8)hrev44373
fixes #8146.
| -rw-r--r-- | src/apps/fontdemo/FontDemoView.cpp | 11 | ||||
| -rw-r--r-- | src/apps/fontdemo/Jamfile | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/apps/fontdemo/FontDemoView.cpp b/src/apps/fontdemo/FontDemoView.cpp index 1dae1a56ed..077ac6e1c1 100644 --- a/src/apps/fontdemo/FontDemoView.cpp +++ b/src/apps/fontdemo/FontDemoView.cpp @@ -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()) { diff --git a/src/apps/fontdemo/Jamfile b/src/apps/fontdemo/Jamfile index 616621f2b0..a02fa1f33f 100644 --- a/src/apps/fontdemo/Jamfile +++ b/src/apps/fontdemo/Jamfile @@ -2,6 +2,8 @@ SubDir HAIKU_TOP src apps fontdemo ; SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateHeaders interface ; + Application FontDemo : ControlView.cpp FontDemo.cpp |
