]> git.pld-linux.org Git - packages/firefox.git/blame - mozilla-firefox-xft-randewidth.patch
- updated to 3.5rc3
[packages/firefox.git] / mozilla-firefox-xft-randewidth.patch
CommitLineData
e36ee87a 1diff -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
5
6 static void ConvertCharToUCS4 (const char *aString,
7 PRUint32 aLength,
8+ PRUint32 aStart,
9+ PRUint32 aEnd,
10 nsAutoFcChar32Buffer &aOutBuffer,
11 PRUint32 *aOutLen);
12 static void ConvertUnicharToUCS4 (const PRUnichar *aString,
13 PRUint32 aLength,
14+ PRUint32 aStart,
15+ PRUint32 aEnd,
16 nsAutoFcChar32Buffer &aOutBuffer,
17 PRUint32 *aOutLen);
18 static nsresult ConvertUCS4ToCustom (FcChar32 *aSrc, PRUint32 aSrcLen,
19@@ -507,7 +511,7 @@ nsFontMetricsXft::GetWidth(const PRUnich
20 return NS_OK;
21 }
22
23- gint rawWidth = RawGetWidth(aString, aLength);
24+ gint rawWidth = RawGetWidth(aString, aLength, 0, aLength);
25
26 float f;
27 f = mDeviceContext->DevUnitsToAppUnits();
28@@ -533,7 +537,7 @@ nsFontMetricsXft::GetTextDimensions(cons
29 return NS_OK;
30
31 nsresult rv;
32- rv = EnumerateGlyphs(aString, aLength,
33+ rv = EnumerateGlyphs(aString, aLength, 0, aLength,
34 &nsFontMetricsXft::TextDimensionsCallback,
35 &aDimensions);
36
37@@ -608,7 +612,7 @@ nsFontMetricsXft::DrawString(const char
38 nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
39 data.drawBuffer = &drawBuffer;
40
41- return EnumerateGlyphs(aString, aLength,
42+ return EnumerateGlyphs(aString, aLength, 0, aLength,
43 &nsFontMetricsXft::DrawStringCallback, &data);
44 }
45
46@@ -638,7 +642,7 @@ nsFontMetricsXft::DrawString(const PRUni
47 nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
48 data.drawBuffer = &drawBuffer;
49
50- return EnumerateGlyphs(aString, aLength,
51+ return EnumerateGlyphs(aString, aLength, 0, aLength,
52 &nsFontMetricsXft::DrawStringCallback, &data);
53 }
54
55@@ -662,7 +666,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
56 data.firstTime = PR_TRUE;
57
58 nsresult rv;
59- rv = EnumerateGlyphs(aString, aLength,
60+ rv = EnumerateGlyphs(aString, aLength, 0, aLength,
61 &nsFontMetricsXft::BoundingMetricsCallback, &data);
62 NS_ENSURE_SUCCESS(rv, rv);
63
64@@ -700,7 +704,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
65 data.firstTime = PR_TRUE;
66
67 nsresult rv;
68- rv = EnumerateGlyphs(aString, aLength,
69+ rv = EnumerateGlyphs(aString, aLength, 0, aLength,
70 &nsFontMetricsXft::BoundingMetricsCallback, &data);
71 NS_ENSURE_SUCCESS(rv, rv);
72
73@@ -758,7 +762,17 @@ nsFontMetricsXft::GetRangeWidth(const PR
74 PRUint32 aEnd,
75 PRUint32 &aWidth)
76 {
77- return NS_ERROR_NOT_IMPLEMENTED;
78+ if (!aLength) {
79+ aWidth = 0;
80+ return NS_OK;
81+ }
82+
83+ gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
84+ float f = mDeviceContext->DevUnitsToAppUnits();
85+
86+ aWidth = NSToCoordRound(rawWidth * f);
87+
88+ return NS_OK;
89 }
90
91 nsresult
92@@ -768,7 +782,17 @@ nsFontMetricsXft::GetRangeWidth(const ch
93 PRUint32 aEnd,
94 PRUint32 &aWidth)
95 {
96- return NS_ERROR_NOT_IMPLEMENTED;
97+ if (!aLength) {
98+ aWidth = 0;
99+ return NS_OK;
100+ }
101+
102+ gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
103+ float f = mDeviceContext->DevUnitsToAppUnits();
104+
105+ aWidth = NSToCoordRound(rawWidth * f);
106+
107+ return NS_OK;
108 }
109
110 PRUint32
111@@ -850,12 +874,12 @@ nsFontMetricsXft::CacheFontMetrics(void)
112 // mSpaceWidth (width of a space)
113 gint rawWidth;
114 PRUnichar unispace(' ');
115- rawWidth = RawGetWidth(&unispace, 1);
116+ rawWidth = RawGetWidth(&unispace, 1, 0, 1);
117 mSpaceWidth = NSToCoordRound(rawWidth * f);
118
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);
124
125 // mXHeight (height of an 'x' character)
126@@ -1226,12 +1250,27 @@ nsFontMetricsXft::DoMatch(PRBool aMatchA
127 }
128
129 gint
130-nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength)
131+nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
132+{
133+ nscoord width = 0;
134+ nsresult rv;
135+
136+ rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
137+ &nsFontMetricsXft::GetWidthCallback, &width);
138+
139+ if (NS_FAILED(rv))
140+ width = 0;
141+
142+ return width;
143+}
144+
145+gint
146+nsFontMetricsXft::RawGetWidth(const char* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
147 {
148 nscoord width = 0;
149 nsresult rv;
150
151- rv = EnumerateGlyphs(aString, aLength,
152+ rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
153 &nsFontMetricsXft::GetWidthCallback, &width);
154
155 if (NS_FAILED(rv))
156@@ -1457,6 +1496,8 @@ nsFontMetricsXft::EnumerateXftGlyphs(con
157 nsresult
158 nsFontMetricsXft::EnumerateGlyphs(const PRUnichar *aString,
159 PRUint32 aLen,
160+ PRUint32 aStart,
161+ PRUint32 aEnd,
162 GlyphEnumeratorCallback aCallback,
163 void *aCallbackData)
164 {
165@@ -1465,7 +1506,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
166
167 NS_ENSURE_TRUE(aLen, NS_OK);
168
169- ConvertUnicharToUCS4(aString, aLen, charBuffer, &len);
170+ ConvertUnicharToUCS4(aString, aLen, aStart, aEnd, charBuffer, &len);
171 if (!len)
172 return NS_ERROR_OUT_OF_MEMORY;
173
174@@ -1475,6 +1516,8 @@ nsFontMetricsXft::EnumerateGlyphs(const
175 nsresult
176 nsFontMetricsXft::EnumerateGlyphs(const char *aString,
177 PRUint32 aLen,
178+ PRUint32 aStart,
179+ PRUint32 aEnd,
180 GlyphEnumeratorCallback aCallback,
181 void *aCallbackData)
182 {
183@@ -1484,7 +1527,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
184 NS_ENSURE_TRUE(aLen, NS_OK);
185
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);
189 if (!len)
190 return NS_ERROR_OUT_OF_MEMORY;
191
192@@ -2343,7 +2386,7 @@ EnumFontsXft(nsIAtom* aLangGroup, const
193
194 /* static */
195 void
196-ConvertCharToUCS4(const char *aString, PRUint32 aLength,
197+ConvertCharToUCS4(const char *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
198 nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
199 {
200 *aOutLen = 0;
201@@ -2352,19 +2395,21 @@ ConvertCharToUCS4(const char *aString, P
202 if (!aOutBuffer.EnsureElemCapacity(aLength))
203 return;
204 outBuffer = aOutBuffer.get();
205+ if (aEnd > aLength)
206+ aEnd = aLength;
207
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
212 }
213
214- *aOutLen = aLength;
215+ *aOutLen = aEnd - aStart;
216 }
217
218 // Convert the incoming string into an array of UCS4 chars
219
220 /* static */
221 void
222-ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength,
223+ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
224 nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
225 {
226 *aOutLen = 0;
227@@ -2378,7 +2423,7 @@ ConvertUnicharToUCS4(const PRUnichar *aS
228
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];
234
235 // Optimized for the non-surrogate case
236@@ -2693,12 +2738,12 @@ ConvertUCS4ToCustom(FcChar32 *aSrc, PRU
237 #endif
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;
243 }
244 else {
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;
249 }
250
251diff -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);
256
257 gint RawGetWidth (const PRUnichar* aString,
258- PRUint32 aLength);
259+ PRUint32 aLength,
260+ PRUint32 aStart,
261+ PRUint32 aEnd);
262+ gint RawGetWidth (const char* aString,
263+ PRUint32 aLength,
264+ PRUint32 aStart,
265+ PRUint32 aEnd);
266 nsresult SetupMiniFont (void);
267 nsresult DrawUnknownGlyph (FcChar32 aChar,
268 nscoord aX,
269@@ -272,10 +278,14 @@ private:
270 void *aCallbackData);
271 nsresult EnumerateGlyphs (const char *aString,
272 PRUint32 aLen,
273+ PRUint32 aStart,
274+ PRUint32 aEnd,
275 GlyphEnumeratorCallback aCallback,
276 void *aCallbackData);
277 nsresult EnumerateGlyphs (const PRUnichar *aString,
278 PRUint32 aLen,
279+ PRUint32 aStart,
280+ PRUint32 aEnd,
281 GlyphEnumeratorCallback aCallback,
282 void *aCallbackData);
283 void PrepareToDraw (nsRenderingContextGTK *aContext,
This page took 0.109781 seconds and 4 git commands to generate.