--- mozilla/gfx/src/gtk/nsFontMetricsPango.h.foo 2004-12-10 18:18:18.000000000 -0500 +++ mozilla/gfx/src/gtk/nsFontMetricsPango.h 2004-12-10 18:19:16.000000000 -0500 @@ -256,6 +256,7 @@ nscoord mMaxDescent; nscoord mMaxAdvance; nscoord mSpaceWidth; + nscoord mPangoSpaceWidth; nscoord mAveCharWidth; // Private methods @@ -282,6 +283,8 @@ PRInt32& aNumCharsFit, nsTextDimensions& aLastWordDimensions, nsRenderingContextGTK *aContext); + + void FixupSpaceWidths (PangoLayout *aLayout, const char *aString); }; class nsFontEnumeratorPango : public nsIFontEnumerator --- mozilla/gfx/src/gtk/nsFontMetricsPango.cpp.foo 2004-12-10 18:18:18.000000000 -0500 +++ mozilla/gfx/src/gtk/nsFontMetricsPango.cpp 2004-12-10 18:19:16.000000000 -0500 @@ -145,6 +145,7 @@ mRTLPangoContext = nsnull; mPangoAttrList = nsnull; mIsRTL = PR_FALSE; + mPangoSpaceWidth = 0; static PRBool initialized = PR_FALSE; if (initialized) @@ -345,6 +346,14 @@ // mMaxAdvance mMaxAdvance = nscoord(xftFont->max_advance_width * f); + // mPangoSpaceWidth + PangoLayout *layout = pango_layout_new(mPangoContext); + pango_layout_set_text(layout, " ", 1); + int pswidth, psheight; + pango_layout_get_size(layout, &pswidth, &psheight); + mPangoSpaceWidth = pswidth; + g_object_unref(layout); + // mSpaceWidth (width of a space) nscoord tmpWidth; GetWidth(" ", 1, tmpWidth, NULL); @@ -485,6 +494,9 @@ pango_layout_set_text(layout, aString, aLength); + if (mPangoSpaceWidth) + FixupSpaceWidths(layout, aString); + int width, height; pango_layout_get_size(layout, &width, &height); @@ -526,6 +538,7 @@ gint width, height; pango_layout_set_text(layout, text, strlen(text)); + FixupSpaceWidths(layout, text); pango_layout_get_size(layout, &width, &height); width /= PANGO_SCALE; @@ -573,6 +586,7 @@ pango_layout_set_text(layout, text, strlen(text)); + FixupSpaceWidths(layout, text); // Get the logical extents PangoLayoutLine *line; @@ -715,6 +729,7 @@ PangoLayout *layout = pango_layout_new(mPangoContext); pango_layout_set_text(layout, aString, aLength); + FixupSpaceWidths(layout, aString); int x = aX; int y = aY; @@ -778,6 +793,7 @@ } pango_layout_set_text(layout, text, strlen(text)); + FixupSpaceWidths(layout, text); aContext->GetTranMatrix()->TransformCoord(&x, &y); @@ -847,6 +863,7 @@ } pango_layout_set_text(layout, text, strlen(text)); + FixupSpaceWidths(layout, text); // Get the logical extents PangoLayoutLine *line; @@ -931,6 +948,7 @@ // Set up the pango layout pango_layout_set_text(layout, text, strlen(text)); + FixupSpaceWidths(layout, text); // Convert back to UTF-16 while filling in the cluster info // structure. @@ -986,6 +1004,7 @@ // Set up the pango layout pango_layout_set_text(layout, text, strlen(text)); + FixupSpaceWidths(layout, text); found = pango_layout_xy_to_index(layout, localCoord, 0, &inx, &trailing); @@ -1087,6 +1106,7 @@ utf8End = strlen(text); pango_layout_set_text(layout, text, strlen(text)); + FixupSpaceWidths(layout, text); PangoLayoutLine *line; if (pango_layout_get_line_count(layout) != 1) { @@ -1502,6 +1522,26 @@ return NS_OK; } +void +nsFontMetricsPango::FixupSpaceWidths (PangoLayout *aLayout, + const char *aString) +{ + PangoLayoutLine *line = pango_layout_get_line(aLayout, 0); + + gint curRun = 0; + + for (GSList *tmpList = line->runs; tmpList && tmpList->data; + tmpList = tmpList->next, curRun++) { + PangoLayoutRun *layoutRun = (PangoLayoutRun *)tmpList->data; + + for (gint i=0; i < layoutRun->glyphs->num_glyphs; i++) { + gint thisOffset = (gint)layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset; + if (aString[thisOffset] == ' ') + layoutRun->glyphs->glyphs[i].geometry.width = mPangoSpaceWidth; + } + } +} + /* static */ PRBool IsASCIIFontName(const nsString& aName) @@ -1790,7 +1830,6 @@ return nsCRT::strcmp(str1, str2); } - // nsFontEnumeratorPango class nsFontEnumeratorPango::nsFontEnumeratorPango()