From 277bea40a31cd83625afee0d5586d6ac5783ad4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 7 Aug 2007 01:24:09 +0000 Subject: [PATCH] rectArray can only be NULL in case fAsString is true, not the other way around; this fixes ServerFont::GetBoundingBoxesForStrings() (ScreenSaver no longer crashes as reported by Brian Verre on the mailing list). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21846 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerFont.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index 116b93f7a0..db1915f2ca 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -592,6 +592,7 @@ class BoundingBoxConsumer { , fTransform(transform) { } + void Start() {} void Finish(double x, double y) {} void ConsumeEmptyGlyph(int32 index, uint32 charCode, double x, double y) {} @@ -601,21 +602,21 @@ class BoundingBoxConsumer { if (glyph->data_type != glyph_data_outline) { const agg::rect_i& r = glyph->bounds; if (fAsString) { - rectArray[index].left = r.x1 + x; - rectArray[index].top = r.y1 + y; - rectArray[index].right = r.x2 + x + 1; - rectArray[index].bottom = r.y2 + y + 1; - } else { if (rectArray) { - rectArray[index].left = r.x1; - rectArray[index].top = r.y1; - rectArray[index].right = r.x2 + 1; - rectArray[index].bottom = r.y2 + 1; + rectArray[index].left = r.x1 + x; + rectArray[index].top = r.y1 + y; + rectArray[index].right = r.x2 + x + 1; + rectArray[index].bottom = r.y2 + y + 1; } else { stringBoundingBox = stringBoundingBox | BRect(r.x1 + x, r.y1 + y, r.x2 + x + 1, r.y2 + y + 1); } + } else { + rectArray[index].left = r.x1; + rectArray[index].top = r.y1; + rectArray[index].right = r.x2 + 1; + rectArray[index].bottom = r.y2 + 1; } } else { if (fAsString) { @@ -686,8 +687,9 @@ ServerFont::GetBoundingBoxes(const char* string, int32 numChars, status_t -ServerFont::GetBoundingBoxesForStrings(char *charArray[], int32 lengthArray[], - int32 numStrings, BRect rectArray[], font_metric_mode mode, escapement_delta deltaArray[]) +ServerFont::GetBoundingBoxesForStrings(char *charArray[], int32 lengthArray[], + int32 numStrings, BRect rectArray[], font_metric_mode mode, + escapement_delta deltaArray[]) { // TODO: The font_metric_mode is never used if (!charArray || !lengthArray|| numStrings <= 0 || !rectArray || !deltaArray)