1 diff -pruN -x '.moz*' -x .libs -x .deps -x dist -x 'config*' -x 'firefox*' -x '*a' -x '*so' -x '*o' -x build -x '*html' mozilla.orig/gfx/src/gtk/nsFontMetricsXft.cpp mozilla/gfx/src/gtk/nsFontMetricsXft.cpp
2 --- mozilla.orig/gfx/src/gtk/nsFontMetricsXft.cpp 2006-04-25 08:58:36.000000000 +0900
3 +++ mozilla/gfx/src/gtk/nsFontMetricsXft.cpp 2007-02-08 01:50:05.000000000 +0900
4 @@ -227,10 +227,14 @@ static nsresult EnumFontsXft (nsIAto
6 static void ConvertCharToUCS4 (const char *aString,
10 nsAutoFcChar32Buffer &aOutBuffer,
12 static void ConvertUnicharToUCS4 (const PRUnichar *aString,
16 nsAutoFcChar32Buffer &aOutBuffer,
18 static nsresult ConvertUCS4ToCustom (FcChar32 *aSrc, PRUint32 aSrcLen,
19 @@ -507,7 +511,7 @@ nsFontMetricsXft::GetWidth(const PRUnich
23 - gint rawWidth = RawGetWidth(aString, aLength);
24 + gint rawWidth = RawGetWidth(aString, aLength, 0, aLength);
27 f = mDeviceContext->DevUnitsToAppUnits();
28 @@ -533,7 +537,7 @@ nsFontMetricsXft::GetTextDimensions(cons
32 - rv = EnumerateGlyphs(aString, aLength,
33 + rv = EnumerateGlyphs(aString, aLength, 0, aLength,
34 &nsFontMetricsXft::TextDimensionsCallback,
37 @@ -608,7 +612,7 @@ nsFontMetricsXft::DrawString(const char
38 nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
39 data.drawBuffer = &drawBuffer;
41 - return EnumerateGlyphs(aString, aLength,
42 + return EnumerateGlyphs(aString, aLength, 0, aLength,
43 &nsFontMetricsXft::DrawStringCallback, &data);
46 @@ -638,7 +642,7 @@ nsFontMetricsXft::DrawString(const PRUni
47 nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
48 data.drawBuffer = &drawBuffer;
50 - return EnumerateGlyphs(aString, aLength,
51 + return EnumerateGlyphs(aString, aLength, 0, aLength,
52 &nsFontMetricsXft::DrawStringCallback, &data);
55 @@ -662,7 +666,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
56 data.firstTime = PR_TRUE;
59 - rv = EnumerateGlyphs(aString, aLength,
60 + rv = EnumerateGlyphs(aString, aLength, 0, aLength,
61 &nsFontMetricsXft::BoundingMetricsCallback, &data);
62 NS_ENSURE_SUCCESS(rv, rv);
64 @@ -700,7 +704,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
65 data.firstTime = PR_TRUE;
68 - rv = EnumerateGlyphs(aString, aLength,
69 + rv = EnumerateGlyphs(aString, aLength, 0, aLength,
70 &nsFontMetricsXft::BoundingMetricsCallback, &data);
71 NS_ENSURE_SUCCESS(rv, rv);
73 @@ -758,7 +762,17 @@ nsFontMetricsXft::GetRangeWidth(const PR
77 - return NS_ERROR_NOT_IMPLEMENTED;
83 + gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
84 + float f = mDeviceContext->DevUnitsToAppUnits();
86 + aWidth = NSToCoordRound(rawWidth * f);
92 @@ -768,7 +782,17 @@ nsFontMetricsXft::GetRangeWidth(const ch
96 - return NS_ERROR_NOT_IMPLEMENTED;
102 + gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
103 + float f = mDeviceContext->DevUnitsToAppUnits();
105 + aWidth = NSToCoordRound(rawWidth * f);
111 @@ -850,12 +874,12 @@ nsFontMetricsXft::CacheFontMetrics(void)
112 // mSpaceWidth (width of a space)
114 PRUnichar unispace(' ');
115 - rawWidth = RawGetWidth(&unispace, 1);
116 + rawWidth = RawGetWidth(&unispace, 1, 0, 1);
117 mSpaceWidth = NSToCoordRound(rawWidth * f);
119 // mAveCharWidth (width of an 'average' char)
120 PRUnichar xUnichar('x');
121 - rawWidth = RawGetWidth(&xUnichar, 1);
122 + rawWidth = RawGetWidth(&xUnichar, 1, 0, 1);
123 mAveCharWidth = NSToCoordRound(rawWidth * f);
125 // mXHeight (height of an 'x' character)
126 @@ -1226,12 +1250,27 @@ nsFontMetricsXft::DoMatch(PRBool aMatchA
130 -nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength)
131 +nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
136 + rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
137 + &nsFontMetricsXft::GetWidthCallback, &width);
146 +nsFontMetricsXft::RawGetWidth(const char* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
151 - rv = EnumerateGlyphs(aString, aLength,
152 + rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
153 &nsFontMetricsXft::GetWidthCallback, &width);
156 @@ -1457,6 +1496,8 @@ nsFontMetricsXft::EnumerateXftGlyphs(con
158 nsFontMetricsXft::EnumerateGlyphs(const PRUnichar *aString,
162 GlyphEnumeratorCallback aCallback,
165 @@ -1465,7 +1506,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
167 NS_ENSURE_TRUE(aLen, NS_OK);
169 - ConvertUnicharToUCS4(aString, aLen, charBuffer, &len);
170 + ConvertUnicharToUCS4(aString, aLen, aStart, aEnd, charBuffer, &len);
172 return NS_ERROR_OUT_OF_MEMORY;
174 @@ -1475,6 +1516,8 @@ nsFontMetricsXft::EnumerateGlyphs(const
176 nsFontMetricsXft::EnumerateGlyphs(const char *aString,
180 GlyphEnumeratorCallback aCallback,
183 @@ -1484,7 +1527,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
184 NS_ENSURE_TRUE(aLen, NS_OK);
186 // Convert the incoming string into an array of UCS4 chars
187 - ConvertCharToUCS4(aString, aLen, charBuffer, &len);
188 + ConvertCharToUCS4(aString, aLen, aStart, aEnd, charBuffer, &len);
190 return NS_ERROR_OUT_OF_MEMORY;
192 @@ -2343,7 +2386,7 @@ EnumFontsXft(nsIAtom* aLangGroup, const
196 -ConvertCharToUCS4(const char *aString, PRUint32 aLength,
197 +ConvertCharToUCS4(const char *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
198 nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
201 @@ -2352,19 +2395,21 @@ ConvertCharToUCS4(const char *aString, P
202 if (!aOutBuffer.EnsureElemCapacity(aLength))
204 outBuffer = aOutBuffer.get();
205 + if (aEnd > aLength)
208 - for (PRUint32 i = 0; i < aLength; ++i) {
209 - outBuffer[i] = PRUint8(aString[i]); // to convert char >= 0x80 correctly
210 + for (PRUint32 i = aStart; i < aLength && i < aEnd; ++i) {
211 + outBuffer[i - aStart] = PRUint8(aString[i]); // to convert char >= 0x80 correctly
214 - *aOutLen = aLength;
215 + *aOutLen = aEnd - aStart;
218 // Convert the incoming string into an array of UCS4 chars
222 -ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength,
223 +ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
224 nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
227 @@ -2378,7 +2423,7 @@ ConvertUnicharToUCS4(const PRUnichar *aS
229 // Walk the passed in string looking for surrogates to convert to
230 // their full ucs4 representation.
231 - for (PRUint32 i = 0; i < aLength; ++i) {
232 + for (PRUint32 i = aStart; i < aLength && i < aEnd; ++i) {
233 PRUnichar c = aString[i];
235 // Optimized for the non-surrogate case
236 @@ -2693,12 +2738,12 @@ ConvertUCS4ToCustom(FcChar32 *aSrc, PRU
238 // Convert 16bit custom font codes to UCS4
239 ConvertUnicharToUCS4(NS_REINTERPRET_CAST(PRUnichar *, med),
240 - medLen >> 1, aResult, &aDestLen);
241 + medLen >> 1, 0, medLen >> 1, aResult, &aDestLen);
242 rv = aDestLen ? rv : NS_ERROR_OUT_OF_MEMORY;
245 // Convert 8bit custom font codes to UCS4
246 - ConvertCharToUCS4(med, medLen, aResult, &aDestLen);
247 + ConvertCharToUCS4(med, medLen, 0, medLen, aResult, &aDestLen);
248 rv = aDestLen ? rv : NS_ERROR_OUT_OF_MEMORY;
251 diff -pruN -x '.moz*' -x .libs -x .deps -x dist -x 'config*' -x 'firefox*' -x '*a' -x '*so' -x '*o' -x build -x '*html' mozilla.orig/gfx/src/gtk/nsFontMetricsXft.h mozilla/gfx/src/gtk/nsFontMetricsXft.h
252 --- mozilla.orig/gfx/src/gtk/nsFontMetricsXft.h 2005-05-03 05:48:30.000000000 +0900
253 +++ mozilla/gfx/src/gtk/nsFontMetricsXft.h 2007-02-08 01:38:27.000000000 +0900
254 @@ -259,7 +259,13 @@ private:
255 void DoMatch (PRBool aMatchAll);
257 gint RawGetWidth (const PRUnichar* aString,
262 + gint RawGetWidth (const char* aString,
266 nsresult SetupMiniFont (void);
267 nsresult DrawUnknownGlyph (FcChar32 aChar,
269 @@ -272,10 +278,14 @@ private:
270 void *aCallbackData);
271 nsresult EnumerateGlyphs (const char *aString,
275 GlyphEnumeratorCallback aCallback,
276 void *aCallbackData);
277 nsresult EnumerateGlyphs (const PRUnichar *aString,
281 GlyphEnumeratorCallback aCallback,
282 void *aCallbackData);
283 void PrepareToDraw (nsRenderingContextGTK *aContext,