Author: spouliot
Date: 2006-09-18 13:29:47 -0400 (Mon, 18 Sep 2006)
New Revision: 65588
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/graphics.c
Log:
2006-09-18 Sebastien Pouliot <[EMAIL PROTECTED]>
* graphics.c: Avoid unit conversions, when possible, when measuring
or drawing strings. Fix both charactersFitted (not total string
length, see bug #76664) and linesFitted (floor) in MeasureOrDrawString
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2006-09-18 16:14:19 UTC (rev 65587)
+++ trunk/libgdiplus/src/ChangeLog 2006-09-18 17:29:47 UTC (rev 65588)
@@ -1,3 +1,9 @@
+2006-09-18 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * graphics.c: Avoid unit conversions, when possible, when measuring
+ or drawing strings. Fix both charactersFitted (not total string
+ length, see bug #76664) and linesFitted (floor) in MeasureOrDrawString
+
2006-09-16 Sebastien Pouliot <[EMAIL PROTECTED]>
* pngcodec.c: Fix 24bbp saving for big endian architectures.
Modified: trunk/libgdiplus/src/graphics.c
===================================================================
--- trunk/libgdiplus/src/graphics.c 2006-09-18 16:14:19 UTC (rev 65587)
+++ trunk/libgdiplus/src/graphics.c 2006-09-18 17:29:47 UTC (rev 65588)
@@ -2327,7 +2327,7 @@
GdipDeleteStringFormat(fmt);
}
- return 0;
+ return Ok;
}
/* Convert string from Gdiplus format to UTF8, suitable for cairo */
@@ -2718,29 +2718,46 @@
are to be displayed and where every character goes
*/
if (boundingBox) {
- boundingBox->X=gdip_convgr_unitx (graphics, rc->X);
- boundingBox->Y=gdip_convgr_unity (graphics, rc->Y);
+ boundingBox->X = rc->X;
+ boundingBox->Y = rc->Y;
if (fmt->formatFlags & StringFormatFlagsDirectionVertical) {
- boundingBox->Width=gdip_convgr_unitx (graphics, MaxY);
- boundingBox->Height=gdip_convgr_unity (graphics, MaxX);
+ boundingBox->Width = MaxY;
+ boundingBox->Height = MaxX;
} else {
- boundingBox->Width=gdip_convgr_unitx (graphics, MaxX);
- boundingBox->Height=gdip_convgr_unity (graphics, MaxY);
+ boundingBox->Width = MaxX;
+ boundingBox->Height = MaxY;
}
- if (rc->Width>0 && boundingBox->Width>rc->Width) {
- boundingBox->Width=gdip_convgr_unitx (graphics,
rc->Width);
+ if ((rc->Width > 0) && (boundingBox->Width > rc->Width)) {
+ boundingBox->Width = rc->Width;
}
- if (rc->Height>0 && boundingBox->Height>rc->Height) {
- boundingBox->Height=gdip_convgr_unity (graphics,
rc->Height);
+ if ((rc->Height > 0) && (boundingBox->Height > rc->Height)) {
+ boundingBox->Height = rc->Height;
}
+
+ /* avoid conversion computations if possible */
+ if (!OPTIMIZE_CONVERSION (graphics)) {
+ boundingBox->X = gdip_convgr_unitx (graphics,
boundingBox->X);
+ boundingBox->Y = gdip_convgr_unity (graphics,
boundingBox->Y);
+ boundingBox->Width = gdip_convgr_unitx (graphics,
boundingBox->Width);
+ boundingBox->Height = gdip_convgr_unity (graphics,
boundingBox->Height);
+ }
}
if (codepointsFitted) {
- *codepointsFitted=StringLen;
+ /* how many characters from the string can be drawn in the
boundingBox (#76664) */
+ double max_width = boundingBox ? (boundingBox->X +
boundingBox->Width) : rc->X + min (MaxX, rc->Width);
+ int charactersFitted;
+ for (charactersFitted = 0; charactersFitted < StringLen;
charactersFitted++) {
+ if ((StringDetails[charactersFitted].PosX +
StringDetails[charactersFitted].Width) > max_width)
+ break;
+ }
+ *codepointsFitted = charactersFitted;
}
if (linesFilled) {
- *linesFilled=MaxY / LineHeight;
+ /* how many *complete* lines fits in our calculated boundingBox
*/
+ double height = (boundingBox) ? boundingBox->Height : min
(MaxY, rc->Height);
+ *linesFilled = floor (height / LineHeight);
}
if (draw) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches