diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h index 19a0e3e4f8..c6d0cc8a13 100644 --- a/headers/os/interface/View.h +++ b/headers/os/interface/View.h @@ -433,8 +433,12 @@ public: void DrawString(const char* string, int32 length, BPoint location, escapement_delta* delta = 0L); + void DrawString(const char* string, + const BPoint* locations, + int32 locationCount); void DrawString(const char* string, int32 length, - const BPoint* locations); + const BPoint* locations, + int32 locationCount); virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL); diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index b051f8704f..ec599c188b 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -45,7 +45,6 @@ #include #include -#include #include #include #include @@ -2571,7 +2570,19 @@ BView::DrawString(const char* string, int32 length, BPoint location, void -BView::DrawString(const char* string, int32 length, const BPoint* locations) +BView::DrawString(const char* string, const BPoint* locations, + int32 locationCount) +{ + if (string == NULL) + return; + + DrawString(string, strlen(string), locations, locationCount); +} + + +void +BView::DrawString(const char* string, int32 length, const BPoint* locations, + int32 locationCount) { if (fOwner == NULL || string == NULL || length < 1 || locations == NULL) return; @@ -2580,11 +2591,10 @@ BView::DrawString(const char* string, int32 length, const BPoint* locations) fOwner->fLink->StartMessage(AS_DRAW_STRING_WITH_OFFSETS); - int32 glyphCount = UTF8CountChars(string, length); fOwner->fLink->Attach(length); - fOwner->fLink->Attach(glyphCount); + fOwner->fLink->Attach(locationCount); fOwner->fLink->Attach(string, length); - fOwner->fLink->Attach(locations, glyphCount * sizeof(BPoint)); + fOwner->fLink->Attach(locations, locationCount * sizeof(BPoint)); _FlushIfNotInTransaction(); diff --git a/src/tests/servers/app/draw_string_offsets/main.cpp b/src/tests/servers/app/draw_string_offsets/main.cpp index 37269a974e..04cdeebd4d 100644 --- a/src/tests/servers/app/draw_string_offsets/main.cpp +++ b/src/tests/servers/app/draw_string_offsets/main.cpp @@ -43,7 +43,7 @@ TestView::Draw(BRect updateRect) offsets[4].x = 30; offsets[4].y = 10; - DrawString("Hello", strlen("Hello"), offsets); + DrawString("Hello", offsets, 5); }