Annotation of /trunk/mozilla/patches/mozilla-1.7.3-4ft2.patch
Parent Directory | Revision Log
Revision 153 -
(hide annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 22360 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 22360 byte(s)
-import
1 | niro | 153 | This patch is from |
2 | https://bugzilla.mozilla.org/show_bug.cgi?id=234035#c65 to enable | ||
3 | linking against freetype-2.1.8+. It disables the experimental | ||
4 | freetype caching. I modified this patch slightly to apply to 1.7.3; | ||
5 | some things had moved around in the files since the original patch. | ||
6 | |||
7 | Note this is the same patch as we apply to mozilla-firefox-1.0 | ||
8 | |||
9 | 15 Nov 2004 agriffis | ||
10 | |||
11 | --- gfx/idl/nsIFreeType2.idl.agriffis 2004-04-15 21:09:33.000000000 -0400 | ||
12 | +++ gfx/idl/nsIFreeType2.idl 2004-11-15 13:29:05.120343408 -0500 | ||
13 | @@ -98,8 +98,6 @@ | ||
14 | { | ||
15 | |||
16 | readonly attribute FT_Library library; | ||
17 | - readonly attribute FTC_Manager FTCacheManager; | ||
18 | - readonly attribute FTC_Image_Cache ImageCache; | ||
19 | |||
20 | void doneFace(in FT_Face face); | ||
21 | void doneFreeType(in FT_Library lib); | ||
22 | @@ -114,17 +112,8 @@ | ||
23 | in FT_Long face_num, out FT_Face face); | ||
24 | void outlineDecompose(in FT_Outline_p outline, | ||
25 | in const_FT_Outline_Funcs_p funcs, in voidPtr p); | ||
26 | + void setPixelSizes(in FT_Face face, in FT_UInt width, in FT_UInt height); | ||
27 | void setCharmap(in FT_Face face, in FT_CharMap charmap); | ||
28 | - void imageCacheLookup(in FTC_Image_Cache cache, in FTC_Image_Desc_p desc, | ||
29 | - in FT_UInt gindex, out FT_Glyph glyph); | ||
30 | - void managerLookupSize(in FTC_Manager manager, in FTC_Font font, | ||
31 | - out FT_Face face, out FT_Size size); | ||
32 | - void managerDone(in FTC_Manager manager); | ||
33 | - void managerNew(in FT_Library lib, in FT_UInt max_faces, | ||
34 | - in FT_UInt max_sizes, in FT_ULong max_bytes, | ||
35 | - in FTC_Face_Requester requester, in FT_Pointer req_data, | ||
36 | - out FTC_Manager manager); | ||
37 | - void imageCacheNew(in FTC_Manager manager, out FTC_Image_Cache cache); | ||
38 | /* #ifdef MOZ_SVG */ | ||
39 | void glyphTransform(in FT_Glyph glyph, in FT_Matrix_p matrix, | ||
40 | in FT_Vector_p delta); | ||
41 | --- gfx/src/ps/nsFontMetricsPS.h.agriffis 2003-04-22 12:25:09.000000000 -0400 | ||
42 | +++ gfx/src/ps/nsFontMetricsPS.h 2004-11-15 13:37:58.431267824 -0500 | ||
43 | @@ -320,7 +320,8 @@ | ||
44 | nsCOMPtr<nsITrueTypeFontCatalogEntry> mFaceID; | ||
45 | nsCOMPtr<nsIFreeType2> mFt2; | ||
46 | PRUint16 mPixelSize; | ||
47 | - FTC_Image_Desc mImageDesc; | ||
48 | + FT_Face mFace; | ||
49 | + FT_Library mFreeTypeLibrary; | ||
50 | |||
51 | |||
52 | static PRBool AddUserPref(nsIAtom *aLang, const nsFont& aFont, | ||
53 | @@ -363,7 +364,8 @@ | ||
54 | protected: | ||
55 | nsCOMPtr<nsITrueTypeFontCatalogEntry> mEntry; | ||
56 | nsCOMPtr<nsIFreeType2> mFt2; | ||
57 | - FTC_Image_Desc mImageDesc; | ||
58 | + FT_Face mFace; | ||
59 | + FT_Library mFreeTypeLibrary; | ||
60 | }; | ||
61 | #endif | ||
62 | |||
63 | --- gfx/src/ps/nsFontMetricsPS.cpp.agriffis 2004-02-04 20:57:05.000000000 -0500 | ||
64 | +++ gfx/src/ps/nsFontMetricsPS.cpp 2004-11-15 13:29:05.123342952 -0500 | ||
65 | @@ -1141,21 +1141,26 @@ | ||
66 | |||
67 | mPixelSize = NSToIntRound(app2dev * mFont->size); | ||
68 | |||
69 | - mImageDesc.font.face_id = (void*)mEntry; | ||
70 | - mImageDesc.font.pix_width = mPixelSize; | ||
71 | - mImageDesc.font.pix_height = mPixelSize; | ||
72 | - mImageDesc.image_type = 0; | ||
73 | - | ||
74 | nsresult rv; | ||
75 | mFt2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv); | ||
76 | if (NS_FAILED(rv)) { | ||
77 | + NS_ERROR("failed to get ft2 service"); | ||
78 | + return NS_ERROR_FAILURE; | ||
79 | + } | ||
80 | + | ||
81 | + if (NS_FAILED(mFt2->GetLibrary(&mFreeTypeLibrary))) { | ||
82 | + NS_ERROR("failed to get ft2 library"); | ||
83 | return NS_ERROR_FAILURE; | ||
84 | } | ||
85 | + | ||
86 | + mFace = nsnull; | ||
87 | return NS_OK; | ||
88 | } | ||
89 | |||
90 | nsFontPSFreeType::~nsFontPSFreeType() | ||
91 | { | ||
92 | + if (mFace) | ||
93 | + mFt2->DoneFace(mFace); | ||
94 | mEntry = nsnull; | ||
95 | } | ||
96 | |||
97 | @@ -1180,32 +1185,26 @@ | ||
98 | nscoord | ||
99 | nsFontPSFreeType::GetWidth(const PRUnichar* aString, PRUint32 aLength) | ||
100 | { | ||
101 | - FT_UInt glyph_index; | ||
102 | - FT_Glyph glyph; | ||
103 | - double origin_x = 0; | ||
104 | - | ||
105 | // get the face/size from the FreeType cache | ||
106 | FT_Face face = getFTFace(); | ||
107 | NS_ASSERTION(face, "failed to get face/size"); | ||
108 | if (!face) | ||
109 | return 0; | ||
110 | |||
111 | - FTC_Image_Cache iCache; | ||
112 | - nsresult rv = mFt2->GetImageCache(&iCache); | ||
113 | - if (NS_FAILED(rv)) { | ||
114 | - NS_ERROR("Failed to get Image Cache"); | ||
115 | - return 0; | ||
116 | - } | ||
117 | + FT_UInt glyph_index; | ||
118 | + FT_Glyph glyph; | ||
119 | + double origin_x = 0; | ||
120 | |||
121 | + // XXX : we might need some caching here | ||
122 | for (PRUint32 i=0; i<aLength; i++) { | ||
123 | - mFt2->GetCharIndex((FT_Face)face, aString[i], &glyph_index); | ||
124 | - nsresult rv = mFt2->ImageCacheLookup(iCache, &mImageDesc, | ||
125 | - glyph_index, &glyph); | ||
126 | - if (NS_FAILED(rv)) { | ||
127 | + mFt2->GetCharIndex(face, aString[i], &glyph_index); | ||
128 | + if (NS_FAILED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) || | ||
129 | + NS_FAILED(mFt2->GetGlyph(face->glyph, &glyph))) { | ||
130 | origin_x += FT_REG_TO_16_16(face->size->metrics.x_ppem/2 + 2); | ||
131 | continue; | ||
132 | } | ||
133 | origin_x += glyph->advance.x; | ||
134 | + mFt2->DoneGlyph(glyph); | ||
135 | } | ||
136 | |||
137 | NS_ENSURE_TRUE(mFontMetrics, 0); | ||
138 | @@ -1224,16 +1223,26 @@ | ||
139 | FT_Face | ||
140 | nsFontPSFreeType::getFTFace() | ||
141 | { | ||
142 | - FT_Face face = nsnull; | ||
143 | - | ||
144 | - FTC_Manager cManager; | ||
145 | - mFt2->GetFTCacheManager(&cManager); | ||
146 | - nsresult rv = mFt2->ManagerLookupSize(cManager, &mImageDesc.font, | ||
147 | - &face, nsnull); | ||
148 | + if (mFace) return mFace; | ||
149 | + | ||
150 | + nsCAutoString fileName; | ||
151 | + PRInt16 faceIndex; | ||
152 | + mEntry->GetFileName(fileName); | ||
153 | + mEntry->GetFaceIndex(&faceIndex); | ||
154 | + | ||
155 | + nsresult rv = | ||
156 | + mFt2->NewFace(mFreeTypeLibrary, fileName.get(), faceIndex, &mFace); | ||
157 | + | ||
158 | NS_ASSERTION(rv==0, "failed to get face/size"); | ||
159 | - if (rv) | ||
160 | - return nsnull; | ||
161 | - return face; | ||
162 | + if (NS_FAILED(rv)) { | ||
163 | + return nsnull; | ||
164 | + } | ||
165 | + | ||
166 | + if (NS_FAILED(mFt2->SetPixelSizes(mFace, mPixelSize, 0))) { | ||
167 | + return nsnull; | ||
168 | + } | ||
169 | + | ||
170 | + return mFace; | ||
171 | } | ||
172 | |||
173 | nscoord | ||
174 | @@ -1618,26 +1627,23 @@ | ||
175 | |||
176 | void nsFT2Type8Generator::GeneratePSFont(FILE* aFile) | ||
177 | { | ||
178 | - nsCAutoString fontName, styleName; | ||
179 | - mEntry->GetFamilyName(fontName); | ||
180 | - mEntry->GetStyleName(styleName); | ||
181 | - | ||
182 | - mImageDesc.font.face_id = (void*)mEntry; | ||
183 | - // TT glyph has no relation to size | ||
184 | - mImageDesc.font.pix_width = 16; | ||
185 | - mImageDesc.font.pix_height = 16; | ||
186 | - mImageDesc.image_type = 0; | ||
187 | - FT_Face face = nsnull; | ||
188 | - FTC_Manager cManager; | ||
189 | - mFt2->GetFTCacheManager(&cManager); | ||
190 | - nsresult rv = mFt2->ManagerLookupSize(cManager, &mImageDesc.font, | ||
191 | - &face, nsnull); | ||
192 | - if (NS_FAILED(rv)) | ||
193 | - return; | ||
194 | + if (mFace == nsnull) { | ||
195 | + nsCAutoString fileName; | ||
196 | + PRInt16 faceIndex; | ||
197 | + | ||
198 | + mEntry->GetFileName(fileName); | ||
199 | + mEntry->GetFaceIndex(&faceIndex); | ||
200 | + if (NS_FAILED(mFt2-> | ||
201 | + NewFace(mFreeTypeLibrary, fileName.get(), faceIndex, &mFace))) { | ||
202 | + return; | ||
203 | + } | ||
204 | + NS_ASSERTION(mFace != nsnull, "mFace is null"); | ||
205 | + } | ||
206 | + | ||
207 | |||
208 | int wmode = 0; | ||
209 | if (!mSubset.IsEmpty()) | ||
210 | - FT2SubsetToType8(face, mSubset.get(), mSubset.Length(), wmode, aFile); | ||
211 | + FT2SubsetToType8(mFace, mSubset.get(), mSubset.Length(), wmode, aFile); | ||
212 | } | ||
213 | #endif //MOZ_ENABLE_FREETYPE2 | ||
214 | |||
215 | --- gfx/src/x11shared/nsFontFreeType.cpp.agriffis 2003-12-25 03:24:52.000000000 -0500 | ||
216 | +++ gfx/src/x11shared/nsFontFreeType.cpp 2004-11-15 13:29:05.125342648 -0500 | ||
217 | @@ -173,15 +173,22 @@ | ||
218 | FT_Face | ||
219 | nsFreeTypeFont::getFTFace() | ||
220 | { | ||
221 | - FT_Face face = nsnull; | ||
222 | - FTC_Manager mgr; | ||
223 | + if (mFace) return mFace; | ||
224 | + | ||
225 | + nsCAutoString fileName; | ||
226 | + PRInt16 faceIndex; | ||
227 | + mFaceID->GetFileName(fileName); | ||
228 | + mFaceID->GetFaceIndex(&faceIndex); | ||
229 | + | ||
230 | nsresult rv; | ||
231 | - mFt2->GetFTCacheManager(&mgr); | ||
232 | - rv = mFt2->ManagerLookupSize(mgr, &mImageDesc.font, &face, nsnull); | ||
233 | + rv = mFt2->NewFace(mFreeTypeLibrary, fileName.get(), faceIndex, &mFace); | ||
234 | NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get face/size"); | ||
235 | if (NS_FAILED(rv)) | ||
236 | return nsnull; | ||
237 | - return face; | ||
238 | + rv = mFt2->SetPixelSizes(mFace, mPixelSize, 0); | ||
239 | + if (NS_FAILED(rv)) | ||
240 | + return nsnull; | ||
241 | + return mFace; | ||
242 | } | ||
243 | |||
244 | nsFreeTypeFont::nsFreeTypeFont(nsITrueTypeFontCatalogEntry *aFaceID, | ||
245 | @@ -191,21 +198,20 @@ | ||
246 | PRBool embedded_bimap = PR_FALSE; | ||
247 | mFaceID = aFaceID; | ||
248 | mPixelSize = aPixelSize; | ||
249 | - mImageDesc.font.face_id = (void*)mFaceID; | ||
250 | - mImageDesc.font.pix_width = aPixelSize; | ||
251 | - mImageDesc.font.pix_height = aPixelSize; | ||
252 | - mImageDesc.image_type = 0; | ||
253 | +//mLoadFlag = FT_LOAD_RENDER; | ||
254 | + mLoadFlag = 0; | ||
255 | + mFace = nsnull; | ||
256 | |||
257 | if (aPixelSize < nsFreeType2::gAntiAliasMinimum) { | ||
258 | - mImageDesc.image_type |= ftc_image_mono; | ||
259 | + mLoadFlag |= FT_LOAD_MONOCHROME; | ||
260 | anti_alias = PR_FALSE; | ||
261 | } | ||
262 | |||
263 | if (nsFreeType2::gFreeType2Autohinted) | ||
264 | - mImageDesc.image_type |= ftc_image_flag_autohinted; | ||
265 | + mLoadFlag |= FT_LOAD_FORCE_AUTOHINT; | ||
266 | |||
267 | if (nsFreeType2::gFreeType2Unhinted) | ||
268 | - mImageDesc.image_type |= ftc_image_flag_unhinted; | ||
269 | + mLoadFlag |= FT_LOAD_NO_HINTING; | ||
270 | |||
271 | PRUint32 num_embedded_bitmaps, i; | ||
272 | PRInt32* embedded_bitmapheights; | ||
273 | @@ -218,7 +224,7 @@ | ||
274 | if (embedded_bitmapheights[i] == aPixelSize) { | ||
275 | embedded_bimap = PR_TRUE; | ||
276 | // unhinted must be set for embedded bitmaps to be used | ||
277 | - mImageDesc.image_type |= ftc_image_flag_unhinted; | ||
278 | + mLoadFlag |= FT_LOAD_NO_HINTING; | ||
279 | break; | ||
280 | } | ||
281 | } | ||
282 | @@ -230,6 +236,11 @@ | ||
283 | mFt2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv); | ||
284 | NS_ASSERTION(NS_SUCCEEDED(rv), "failed to find FreeType routines"); | ||
285 | |||
286 | + if (mFt2) { | ||
287 | + rv = mFt2->GetLibrary(&mFreeTypeLibrary); | ||
288 | + NS_ASSERTION(NS_SUCCEEDED(rv), "failed to find FreeType library"); | ||
289 | + } | ||
290 | + | ||
291 | FREETYPE_FONT_PRINTF(("anti_alias=%d, embedded_bitmap=%d, " | ||
292 | "AutoHinted=%d, gFreeType2Unhinted = %d, " | ||
293 | "size=%dpx, \"%s\"", | ||
294 | @@ -288,8 +299,6 @@ | ||
295 | PRInt32* aDescent, | ||
296 | PRInt32* aWidth) | ||
297 | { | ||
298 | - nsresult rv; | ||
299 | - | ||
300 | *aLeftBearing = 0; | ||
301 | *aRightBearing = 0; | ||
302 | *aAscent = 0; | ||
303 | @@ -312,11 +321,6 @@ | ||
304 | if (!face) | ||
305 | return NS_ERROR_FAILURE; | ||
306 | |||
307 | - FTC_Image_Cache icache; | ||
308 | - mFt2->GetImageCache(&icache); | ||
309 | - if (!icache) | ||
310 | - return NS_ERROR_FAILURE; | ||
311 | - | ||
312 | // get the text size | ||
313 | PRUint32 i, extraSurrogateLength; | ||
314 | for (i=0; i<aLength; i+=1+extraSurrogateLength) { | ||
315 | @@ -337,16 +341,17 @@ | ||
316 | } | ||
317 | mFt2->GetCharIndex(face, code_point, &glyph_index); | ||
318 | |||
319 | - //NS_ASSERTION(glyph_index,"failed to get glyph"); | ||
320 | - if (glyph_index) { | ||
321 | - rv = mFt2->ImageCacheLookup(icache, &mImageDesc, glyph_index, &glyph); | ||
322 | - NS_ASSERTION(NS_SUCCEEDED(rv),"error loading glyph"); | ||
323 | - } | ||
324 | - if ((glyph_index) && (NS_SUCCEEDED(rv))) { | ||
325 | + // XXX : we need some caching here | ||
326 | + if (glyph_index && | ||
327 | + NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, mLoadFlag)) && | ||
328 | +// NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) && | ||
329 | + NS_SUCCEEDED(mFt2->GetGlyph(face->glyph, &glyph))) { | ||
330 | mFt2->GlyphGetCBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox); | ||
331 | advance = FT_16_16_TO_REG(glyph->advance.x); | ||
332 | + mFt2->DoneGlyph(glyph); | ||
333 | } | ||
334 | else { | ||
335 | + NS_ERROR("failed to get or load glyph"); | ||
336 | // allocate space to draw an empty box in | ||
337 | GetFallbackGlyphMetrics(&glyph_bbox, face); | ||
338 | advance = glyph_bbox.xMax + 1; | ||
339 | @@ -401,11 +406,6 @@ | ||
340 | if (!face) | ||
341 | return 0; | ||
342 | |||
343 | - FTC_Image_Cache icache; | ||
344 | - mFt2->GetImageCache(&icache); | ||
345 | - if (!icache) | ||
346 | - return 0; | ||
347 | - | ||
348 | PRUint32 i, extraSurrogateLength; | ||
349 | for (i=0; i<aLength; i+=1+extraSurrogateLength) { | ||
350 | extraSurrogateLength=0; | ||
351 | @@ -418,15 +418,18 @@ | ||
352 | // skip aString[i+1], it is already used as low surrogate | ||
353 | extraSurrogateLength = 1; | ||
354 | } | ||
355 | + | ||
356 | + // XXX : we need some caching here | ||
357 | mFt2->GetCharIndex((FT_Face)face, code_point, &glyph_index); | ||
358 | - nsresult rv; | ||
359 | - rv = mFt2->ImageCacheLookup(icache, &mImageDesc, glyph_index, &glyph); | ||
360 | - NS_ASSERTION(NS_SUCCEEDED(rv),"error loading glyph"); | ||
361 | - if (NS_FAILED(rv)) { | ||
362 | + if (NS_FAILED(mFt2->LoadGlyph(face, glyph_index, mLoadFlag)) || | ||
363 | +// if (NS_FAILED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) || | ||
364 | + NS_FAILED(mFt2->GetGlyph(face->glyph, &glyph))) { | ||
365 | + NS_ERROR("error loading glyph"); | ||
366 | origin_x += face->size->metrics.x_ppem/2 + 2; | ||
367 | continue; | ||
368 | } | ||
369 | origin_x += FT_16_16_TO_REG(glyph->advance.x); | ||
370 | + mFt2->DoneGlyph(glyph); | ||
371 | } | ||
372 | |||
373 | return origin_x; | ||
374 | @@ -723,11 +726,6 @@ | ||
375 | if (y%4==0) (*blendPixelFunc)(sub_image, y, ascent-1, black, 255/2); | ||
376 | #endif | ||
377 | |||
378 | - FTC_Image_Cache icache; | ||
379 | - mFt2->GetImageCache(&icache); | ||
380 | - if (!icache) | ||
381 | - return 0; | ||
382 | - | ||
383 | // | ||
384 | // Get aa glyphs and blend with background | ||
385 | // | ||
386 | @@ -736,7 +734,6 @@ | ||
387 | for (i=0; i<aLength; i+=1+extraSurrogateLength) { | ||
388 | FT_UInt glyph_index; | ||
389 | FT_Glyph glyph; | ||
390 | - nsresult rv; | ||
391 | FT_BBox glyph_bbox; | ||
392 | FT_ULong code_point = aString[i]; | ||
393 | extraSurrogateLength = 0; | ||
394 | @@ -750,11 +747,12 @@ | ||
395 | extraSurrogateLength = 1; | ||
396 | } | ||
397 | |||
398 | + // XXX : we need some caching here | ||
399 | mFt2->GetCharIndex(face, code_point, &glyph_index); | ||
400 | - if (glyph_index) { | ||
401 | - rv = mFt2->ImageCacheLookup(icache, &mImageDesc, glyph_index, &glyph); | ||
402 | - } | ||
403 | - if ((glyph_index) && (NS_SUCCEEDED(rv))) { | ||
404 | + if (glyph_index && | ||
405 | + NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, mLoadFlag)) && | ||
406 | +// NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) && | ||
407 | + NS_SUCCEEDED(mFt2->GetGlyph(face->glyph, &glyph))) { | ||
408 | mFt2->GlyphGetCBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox); | ||
409 | } | ||
410 | else { | ||
411 | @@ -775,13 +773,26 @@ | ||
412 | continue; | ||
413 | } | ||
414 | |||
415 | - FT_BitmapGlyph slot = (FT_BitmapGlyph)glyph; | ||
416 | + FT_BitmapGlyph slot; | ||
417 | + | ||
418 | + if (glyph->format != FT_GLYPH_FORMAT_BITMAP) | ||
419 | + { | ||
420 | + if (mFt2->GlyphToBitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1)) { | ||
421 | + NS_ERROR("failed to convert outline to bitmap "); | ||
422 | + XDestroyImage(sub_image); | ||
423 | + mFt2->DoneGlyph(glyph); | ||
424 | + return 0; | ||
425 | + } | ||
426 | + } | ||
427 | + | ||
428 | + slot = (FT_BitmapGlyph)glyph; | ||
429 | nsAntiAliasedGlyph aaglyph(glyph_bbox.xMax-glyph_bbox.xMin, | ||
430 | glyph_bbox.yMax-glyph_bbox.yMin, 0); | ||
431 | PRUint8 buf[IMAGE_BUFFER_SIZE]; // try to use the stack for data | ||
432 | if (!aaglyph.WrapFreeType(&glyph_bbox, slot, buf, IMAGE_BUFFER_SIZE)) { | ||
433 | NS_ERROR("failed to wrap freetype image"); | ||
434 | XDestroyImage(sub_image); | ||
435 | + mFt2->DoneGlyph(glyph); | ||
436 | return 0; | ||
437 | } | ||
438 | |||
439 | @@ -815,6 +826,7 @@ | ||
440 | x_pos + aaglyph.GetLBearing(), ascent-glyph_bbox.yMax); | ||
441 | |||
442 | x_pos += aaglyph.GetAdvance(); | ||
443 | + mFt2->DoneGlyph(glyph); | ||
444 | } | ||
445 | |||
446 | // | ||
447 | --- gfx/src/x11shared/nsFontFreeType.h.agriffis 2003-04-22 12:25:13.000000000 -0400 | ||
448 | +++ gfx/src/x11shared/nsFontFreeType.h 2004-11-15 13:29:05.125342648 -0500 | ||
449 | @@ -110,8 +110,10 @@ | ||
450 | XImage *GetXImage(PRUint32 width, PRUint32 height); | ||
451 | nsITrueTypeFontCatalogEntry *mFaceID; | ||
452 | PRUint16 mPixelSize; | ||
453 | - FTC_Image_Desc mImageDesc; | ||
454 | nsCOMPtr<nsIFreeType2> mFt2; | ||
455 | + FT_Face mFace; | ||
456 | + FT_Int32 mLoadFlag; | ||
457 | + FT_Library mFreeTypeLibrary; | ||
458 | }; | ||
459 | |||
460 | void WeightTableInitCorrection(PRUint8*, PRUint8, double); | ||
461 | --- gfx/src/freetype/nsFreeType.cpp.agriffis 2004-02-07 10:22:30.000000000 -0500 | ||
462 | +++ gfx/src/freetype/nsFreeType.cpp 2004-11-15 13:29:05.121343256 -0500 | ||
463 | @@ -109,12 +109,8 @@ | ||
464 | {"FT_Load_Glyph", NS_FT2_OFFSET(nsFT_Load_Glyph), PR_TRUE}, | ||
465 | {"FT_New_Face", NS_FT2_OFFSET(nsFT_New_Face), PR_TRUE}, | ||
466 | {"FT_Outline_Decompose", NS_FT2_OFFSET(nsFT_Outline_Decompose), PR_TRUE}, | ||
467 | + {"FT_Set_Pixel_Sizes", NS_FT2_OFFSET(nsFT_Set_Pixel_Sizes), PR_TRUE}, | ||
468 | {"FT_Set_Charmap", NS_FT2_OFFSET(nsFT_Set_Charmap), PR_TRUE}, | ||
469 | - {"FTC_Image_Cache_Lookup", NS_FT2_OFFSET(nsFTC_Image_Cache_Lookup), PR_TRUE}, | ||
470 | - {"FTC_Manager_Lookup_Size", NS_FT2_OFFSET(nsFTC_Manager_Lookup_Size), PR_TRUE}, | ||
471 | - {"FTC_Manager_Done", NS_FT2_OFFSET(nsFTC_Manager_Done), PR_TRUE}, | ||
472 | - {"FTC_Manager_New", NS_FT2_OFFSET(nsFTC_Manager_New), PR_TRUE}, | ||
473 | - {"FTC_Image_Cache_New", NS_FT2_OFFSET(nsFTC_Image_Cache_New), PR_TRUE}, | ||
474 | // #ifdef MOZ_SVG | ||
475 | {"FT_Glyph_Transform", NS_FT2_OFFSET(nsFT_Glyph_Transform), PR_TRUE}, | ||
476 | {"FT_Get_Kerning", NS_FT2_OFFSET(nsFT_Get_Kerning), PR_TRUE}, | ||
477 | @@ -274,59 +270,21 @@ | ||
478 | } | ||
479 | |||
480 | NS_IMETHODIMP | ||
481 | -nsFreeType2::SetCharmap(FT_Face face, FT_CharMap charmap) | ||
482 | -{ | ||
483 | - // call the FreeType2 function via the function pointer | ||
484 | - FT_Error error = nsFT_Set_Charmap(face, charmap); | ||
485 | - return error ? NS_ERROR_FAILURE : NS_OK; | ||
486 | -} | ||
487 | - | ||
488 | -NS_IMETHODIMP | ||
489 | -nsFreeType2::ImageCacheLookup(FTC_Image_Cache cache, FTC_Image_Desc *desc, | ||
490 | - FT_UInt glyphID, FT_Glyph *glyph) | ||
491 | -{ | ||
492 | - // call the FreeType2 function via the function pointer | ||
493 | - FT_Error error = nsFTC_Image_Cache_Lookup(cache, desc, glyphID, glyph); | ||
494 | - return error ? NS_ERROR_FAILURE : NS_OK; | ||
495 | -} | ||
496 | - | ||
497 | -NS_IMETHODIMP | ||
498 | -nsFreeType2::ManagerLookupSize(FTC_Manager manager, FTC_Font font, | ||
499 | - FT_Face *face, FT_Size *size) | ||
500 | +nsFreeType2::SetPixelSizes(FT_Face face, FT_UInt width, FT_UInt height) | ||
501 | { | ||
502 | // call the FreeType2 function via the function pointer | ||
503 | - FT_Error error = nsFTC_Manager_Lookup_Size(manager, font, face, size); | ||
504 | + FT_Error error = nsFT_Set_Pixel_Sizes(face, width, height); | ||
505 | return error ? NS_ERROR_FAILURE : NS_OK; | ||
506 | } | ||
507 | - | ||
508 | -NS_IMETHODIMP | ||
509 | -nsFreeType2::ManagerDone(FTC_Manager manager) | ||
510 | -{ | ||
511 | - // call the FreeType2 function via the function pointer | ||
512 | - nsFTC_Manager_Done(manager); | ||
513 | - return NS_OK; | ||
514 | -} | ||
515 | - | ||
516 | + | ||
517 | NS_IMETHODIMP | ||
518 | -nsFreeType2::ManagerNew(FT_Library library, FT_UInt max_faces, | ||
519 | - FT_UInt max_sizes, FT_ULong max_bytes, | ||
520 | - FTC_Face_Requester requester, FT_Pointer req_data, | ||
521 | - FTC_Manager *manager) | ||
522 | +nsFreeType2::SetCharmap(FT_Face face, FT_CharMap charmap) | ||
523 | { | ||
524 | // call the FreeType2 function via the function pointer | ||
525 | - FT_Error error = nsFTC_Manager_New(library, max_faces, max_sizes, max_bytes, | ||
526 | - requester, req_data, manager); | ||
527 | + FT_Error error = nsFT_Set_Charmap(face, charmap); | ||
528 | return error ? NS_ERROR_FAILURE : NS_OK; | ||
529 | } | ||
530 | |||
531 | -NS_IMETHODIMP | ||
532 | -nsFreeType2::ImageCacheNew(FTC_Manager manager, FTC_Image_Cache *cache) | ||
533 | -{ | ||
534 | - // call the FreeType2 function via the function pointer | ||
535 | - FT_Error error = nsFTC_Image_Cache_New(manager, cache); | ||
536 | - return error ? NS_ERROR_FAILURE : NS_OK; | ||
537 | -} | ||
538 | - | ||
539 | // #ifdef MOZ_SVG | ||
540 | NS_IMETHODIMP | ||
541 | nsFreeType2::GlyphTransform(FT_Glyph glyph, FT_Matrix * matrix, FT_Vector * delta) | ||
542 | @@ -389,20 +347,6 @@ | ||
543 | } | ||
544 | |||
545 | NS_IMETHODIMP | ||
546 | -nsFreeType2::GetImageCache(FTC_Image_Cache *aCache) | ||
547 | -{ | ||
548 | - *aCache = mImageCache; | ||
549 | - return NS_OK; | ||
550 | -} | ||
551 | - | ||
552 | -NS_IMETHODIMP | ||
553 | -nsFreeType2::GetFTCacheManager(FTC_Manager *aManager) | ||
554 | -{ | ||
555 | - *aManager = mFTCacheManager; | ||
556 | - return NS_OK; | ||
557 | -} | ||
558 | - | ||
559 | -NS_IMETHODIMP | ||
560 | nsFreeType2::GetLibrary(FT_Library *aLibrary) | ||
561 | { | ||
562 | *aLibrary = mFreeTypeLibrary; | ||
563 | @@ -425,8 +369,6 @@ | ||
564 | { | ||
565 | mSharedLib = nsnull; | ||
566 | mFreeTypeLibrary = nsnull; | ||
567 | - mFTCacheManager = nsnull; | ||
568 | - mImageCache = nsnull; | ||
569 | } | ||
570 | |||
571 | // I would like to make this a static member function but the compilier | ||
572 | @@ -456,12 +398,6 @@ | ||
573 | delete gFreeTypeFaces; | ||
574 | gFreeTypeFaces = nsnull; | ||
575 | } | ||
576 | - // mImageCache released by cache manager | ||
577 | - if (mFTCacheManager) { | ||
578 | - // use "this->" to make sure it is obivious we are calling the member func | ||
579 | - this->ManagerDone(mFTCacheManager); | ||
580 | - mFTCacheManager = nsnull; | ||
581 | - } | ||
582 | if (mFreeTypeLibrary) { | ||
583 | // use "this->" to make sure it is obivious we are calling the member func | ||
584 | this->DoneFreeType(mFreeTypeLibrary); | ||
585 | @@ -658,17 +594,6 @@ | ||
586 | mFreeTypeLibrary = nsnull; | ||
587 | goto cleanup_and_return; | ||
588 | } | ||
589 | - // use "this->" to make sure it is obivious we are calling the member func | ||
590 | - rv = this->ManagerNew(mFreeTypeLibrary, 0, 0, 0, nsFreeTypeFaceRequester, | ||
591 | - this, &mFTCacheManager); | ||
592 | - NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create FreeType Cache manager"); | ||
593 | - if (NS_FAILED(rv)) | ||
594 | - goto cleanup_and_return; | ||
595 | - // use "this->" to make sure it is obivious we are calling the member func | ||
596 | - rv = this->ImageCacheNew(mFTCacheManager, &mImageCache); | ||
597 | - NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create FreeType image cache"); | ||
598 | - if (NS_FAILED(rv)) | ||
599 | - goto cleanup_and_return; | ||
600 | return PR_TRUE; | ||
601 | |||
602 | cleanup_and_return: | ||
603 | --- gfx/src/freetype/nsFreeType.h.agriffis 2004-04-16 17:31:42.000000000 -0400 | ||
604 | +++ gfx/src/freetype/nsFreeType.h 2004-11-15 13:29:05.122343104 -0500 | ||
605 | @@ -102,15 +102,8 @@ | ||
606 | typedef FT_Error (*FT_Outline_Decompose_t) | ||
607 | (FT_Outline*, const FT_Outline_Funcs*, void*); | ||
608 | typedef FT_Error (*FT_New_Face_t)(FT_Library, const char*, FT_Long, FT_Face*); | ||
609 | +typedef FT_Error (*FT_Set_Pixel_Sizes_t)(FT_Face face, FT_UInt, FT_UInt); | ||
610 | typedef FT_Error (*FT_Set_Charmap_t)(FT_Face face, FT_CharMap charmap); | ||
611 | -typedef FT_Error (*FTC_Image_Cache_Lookup_t) | ||
612 | - (FTC_Image_Cache, FTC_Image_Desc*, FT_UInt, FT_Glyph*); | ||
613 | -typedef FT_Error (*FTC_Manager_Lookup_Size_t) | ||
614 | - (FTC_Manager, FTC_Font, FT_Face*, FT_Size*); | ||
615 | -typedef FT_Error (*FTC_Manager_Done_t)(FTC_Manager); | ||
616 | -typedef FT_Error (*FTC_Manager_New_t)(FT_Library, FT_UInt, FT_UInt, FT_ULong, | ||
617 | - FTC_Face_Requester, FT_Pointer, FTC_Manager*); | ||
618 | -typedef FT_Error (*FTC_Image_Cache_New_t)(FTC_Manager, FTC_Image_Cache*); | ||
619 | // #ifdef MOZ_SVG | ||
620 | typedef FT_Error (*FT_Glyph_Transform_t)(FT_Glyph, FT_Matrix*, FT_Vector*); | ||
621 | typedef FT_Error (*FT_Get_Kerning_t) | ||
622 | @@ -163,12 +156,8 @@ | ||
623 | FT_Load_Glyph_t nsFT_Load_Glyph; | ||
624 | FT_New_Face_t nsFT_New_Face; | ||
625 | FT_Outline_Decompose_t nsFT_Outline_Decompose; | ||
626 | + FT_Set_Pixel_Sizes_t nsFT_Set_Pixel_Sizes; | ||
627 | FT_Set_Charmap_t nsFT_Set_Charmap; | ||
628 | - FTC_Image_Cache_Lookup_t nsFTC_Image_Cache_Lookup; | ||
629 | - FTC_Manager_Lookup_Size_t nsFTC_Manager_Lookup_Size; | ||
630 | - FTC_Manager_Done_t nsFTC_Manager_Done; | ||
631 | - FTC_Manager_New_t nsFTC_Manager_New; | ||
632 | - FTC_Image_Cache_New_t nsFTC_Image_Cache_New; | ||
633 | // #ifdef MOZ_SVG | ||
634 | FT_Glyph_Transform_t nsFT_Glyph_Transform; | ||
635 | FT_Get_Kerning_t nsFT_Get_Kerning; | ||
636 | @@ -181,9 +170,9 @@ | ||
637 | // this array needs to be big enough to hold all the function pointers | ||
638 | // plus one extra for the null at the end | ||
639 | // #ifdef MOZ_SVG | ||
640 | - static FtFuncList FtFuncs[24]; | ||
641 | + static FtFuncList FtFuncs[20]; | ||
642 | // #else | ||
643 | -// static FtFuncList FtFuncs[20]; | ||
644 | +// static FtFuncList FtFuncs[17]; | ||
645 | // #endif | ||
646 | |||
647 | protected: | ||
648 | @@ -212,8 +201,6 @@ | ||
649 | |||
650 | PRLibrary *mSharedLib; | ||
651 | FT_Library mFreeTypeLibrary; | ||
652 | - FTC_Manager mFTCacheManager; | ||
653 | - FTC_Image_Cache mImageCache; | ||
654 | |||
655 | static nsHashtable *sFontFamilies; | ||
656 | static nsHashtable *sRange1CharSetNames; |