Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 73255
Collapse All | Expand All

(-)gfx/idl/nsIFreeType2.idl.agriffis (-12 / +1 lines)
Lines 98-105 Link Here
98
{
98
{
99
99
100
    readonly attribute FT_Library library;
100
    readonly attribute FT_Library library;
101
    readonly attribute FTC_Manager FTCacheManager;
102
    readonly attribute FTC_Image_Cache ImageCache;
103
101
104
    void    doneFace(in FT_Face face);
102
    void    doneFace(in FT_Face face);
105
    void    doneFreeType(in FT_Library lib);
103
    void    doneFreeType(in FT_Library lib);
Lines 114-130 Link Here
114
                    in FT_Long face_num, out FT_Face face);
112
                    in FT_Long face_num, out FT_Face face);
115
    void    outlineDecompose(in FT_Outline_p outline,
113
    void    outlineDecompose(in FT_Outline_p outline,
116
                             in const_FT_Outline_Funcs_p funcs, in voidPtr p);
114
                             in const_FT_Outline_Funcs_p funcs, in voidPtr p);
115
    void    setPixelSizes(in FT_Face face, in FT_UInt width, in FT_UInt height); 
117
    void    setCharmap(in FT_Face face, in FT_CharMap charmap);
116
    void    setCharmap(in FT_Face face, in FT_CharMap charmap);
118
    void    imageCacheLookup(in FTC_Image_Cache cache, in FTC_Image_Desc_p desc,
119
                             in FT_UInt gindex, out FT_Glyph glyph);
120
    void    managerLookupSize(in FTC_Manager manager, in FTC_Font font,
121
                              out FT_Face face, out FT_Size size);
122
    void    managerDone(in FTC_Manager manager);
123
    void    managerNew(in FT_Library lib, in FT_UInt max_faces,
124
                       in FT_UInt max_sizes, in FT_ULong max_bytes,
125
                       in FTC_Face_Requester requester, in FT_Pointer req_data,
126
                       out FTC_Manager manager);
127
    void    imageCacheNew(in FTC_Manager manager, out FTC_Image_Cache cache);
128
/* #ifdef MOZ_SVG */
117
/* #ifdef MOZ_SVG */
129
    void glyphTransform(in FT_Glyph glyph, in FT_Matrix_p matrix,
118
    void glyphTransform(in FT_Glyph glyph, in FT_Matrix_p matrix,
130
                        in FT_Vector_p delta);
119
                        in FT_Vector_p delta);
(-)gfx/src/ps/nsFontMetricsPS.h.agriffis (-2 / +4 lines)
Lines 320-326 Link Here
320
  nsCOMPtr<nsITrueTypeFontCatalogEntry> mFaceID;
320
  nsCOMPtr<nsITrueTypeFontCatalogEntry> mFaceID;
321
  nsCOMPtr<nsIFreeType2> mFt2;
321
  nsCOMPtr<nsIFreeType2> mFt2;
322
  PRUint16        mPixelSize;
322
  PRUint16        mPixelSize;
323
  FTC_Image_Desc  mImageDesc;
323
  FT_Face         mFace; 
324
  FT_Library      mFreeTypeLibrary;
324
325
325
326
326
  static PRBool AddUserPref(nsIAtom *aLang, const nsFont& aFont,
327
  static PRBool AddUserPref(nsIAtom *aLang, const nsFont& aFont,
Lines 363-369 Link Here
363
protected:
364
protected:
364
  nsCOMPtr<nsITrueTypeFontCatalogEntry> mEntry;
365
  nsCOMPtr<nsITrueTypeFontCatalogEntry> mEntry;
365
  nsCOMPtr<nsIFreeType2> mFt2;
366
  nsCOMPtr<nsIFreeType2> mFt2;
366
  FTC_Image_Desc  mImageDesc;
367
  FT_Face         mFace; 
368
  FT_Library      mFreeTypeLibrary;
367
};
369
};
368
#endif
370
#endif
369
371
(-)gfx/src/ps/nsFontMetricsPS.cpp.agriffis (-45 / +51 lines)
Lines 1141-1161 Link Here
1141
  
1141
  
1142
  mPixelSize = NSToIntRound(app2dev * mFont->size);
1142
  mPixelSize = NSToIntRound(app2dev * mFont->size);
1143
1143
1144
  mImageDesc.font.face_id    = (void*)mEntry;
1145
  mImageDesc.font.pix_width  = mPixelSize;
1146
  mImageDesc.font.pix_height = mPixelSize;
1147
  mImageDesc.image_type = 0;
1148
1149
  nsresult rv;
1144
  nsresult rv;
1150
  mFt2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv);
1145
  mFt2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv);
1151
  if (NS_FAILED(rv)) {
1146
  if (NS_FAILED(rv)) {
1147
    NS_ERROR("failed to get ft2 service");
1148
    return NS_ERROR_FAILURE;
1149
  }
1150
1151
  if (NS_FAILED(mFt2->GetLibrary(&mFreeTypeLibrary))) {
1152
    NS_ERROR("failed to get ft2 library");
1152
    return NS_ERROR_FAILURE;
1153
    return NS_ERROR_FAILURE;
1153
  }
1154
  }
1155
1156
  mFace = nsnull; 
1154
  return NS_OK;
1157
  return NS_OK;
1155
}
1158
}
1156
1159
1157
nsFontPSFreeType::~nsFontPSFreeType()
1160
nsFontPSFreeType::~nsFontPSFreeType()
1158
{
1161
{
1162
  if (mFace) 
1163
    mFt2->DoneFace(mFace);
1159
  mEntry = nsnull;
1164
  mEntry = nsnull;
1160
}
1165
}
1161
1166
Lines 1180-1211 Link Here
1180
nscoord
1185
nscoord
1181
nsFontPSFreeType::GetWidth(const PRUnichar* aString, PRUint32 aLength)
1186
nsFontPSFreeType::GetWidth(const PRUnichar* aString, PRUint32 aLength)
1182
{
1187
{
1183
  FT_UInt glyph_index;
1184
  FT_Glyph glyph;
1185
  double origin_x = 0;
1186
1187
  // get the face/size from the FreeType cache
1188
  // get the face/size from the FreeType cache
1188
  FT_Face face = getFTFace();
1189
  FT_Face face = getFTFace();
1189
  NS_ASSERTION(face, "failed to get face/size");
1190
  NS_ASSERTION(face, "failed to get face/size");
1190
  if (!face)
1191
  if (!face)
1191
    return 0;
1192
    return 0;
1192
1193
1193
  FTC_Image_Cache iCache;
1194
  FT_UInt glyph_index;
1194
  nsresult rv = mFt2->GetImageCache(&iCache);
1195
  FT_Glyph glyph;
1195
  if (NS_FAILED(rv)) {
1196
  double origin_x = 0;
1196
    NS_ERROR("Failed to get Image Cache");
1197
    return 0;
1198
  }
1199
1197
1198
  // XXX : we might need some caching here
1200
  for (PRUint32 i=0; i<aLength; i++) {
1199
  for (PRUint32 i=0; i<aLength; i++) {
1201
    mFt2->GetCharIndex((FT_Face)face, aString[i], &glyph_index);
1200
    mFt2->GetCharIndex(face, aString[i], &glyph_index);
1202
    nsresult rv = mFt2->ImageCacheLookup(iCache, &mImageDesc,
1201
    if (NS_FAILED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) ||
1203
                                         glyph_index, &glyph);
1202
        NS_FAILED(mFt2->GetGlyph(face->glyph, &glyph))) {     
1204
    if (NS_FAILED(rv)) {
1205
      origin_x += FT_REG_TO_16_16(face->size->metrics.x_ppem/2 + 2);
1203
      origin_x += FT_REG_TO_16_16(face->size->metrics.x_ppem/2 + 2);
1206
      continue;
1204
      continue;
1207
    }
1205
    }
1208
    origin_x += glyph->advance.x;
1206
    origin_x += glyph->advance.x;
1207
    mFt2->DoneGlyph(glyph);
1209
  }
1208
  }
1210
1209
1211
  NS_ENSURE_TRUE(mFontMetrics, 0);
1210
  NS_ENSURE_TRUE(mFontMetrics, 0);
Lines 1224-1239 Link Here
1224
FT_Face
1223
FT_Face
1225
nsFontPSFreeType::getFTFace()
1224
nsFontPSFreeType::getFTFace()
1226
{
1225
{
1227
  FT_Face face = nsnull;
1226
  if (mFace) return mFace;
1228
  
1227
1229
  FTC_Manager cManager;
1228
  nsCAutoString fileName;
1230
  mFt2->GetFTCacheManager(&cManager);
1229
  PRInt16       faceIndex; 
1231
  nsresult rv = mFt2->ManagerLookupSize(cManager, &mImageDesc.font,
1230
  mEntry->GetFileName(fileName);
1232
                                        &face, nsnull);
1231
  mEntry->GetFaceIndex(&faceIndex);
1232
1233
  nsresult rv = 
1234
    mFt2->NewFace(mFreeTypeLibrary, fileName.get(), faceIndex, &mFace);
1235
1233
  NS_ASSERTION(rv==0, "failed to get face/size");
1236
  NS_ASSERTION(rv==0, "failed to get face/size");
1234
  if (rv)
1237
  if (NS_FAILED(rv)) {
1235
    return nsnull;
1238
    return nsnull; 
1236
  return face;
1239
  }
1240
1241
  if (NS_FAILED(mFt2->SetPixelSizes(mFace, mPixelSize, 0))) {
1242
    return nsnull; 
1243
  }
1244
1245
  return mFace; 
1237
}
1246
}
1238
1247
1239
nscoord
1248
nscoord
Lines 1618-1643 Link Here
1618
1627
1619
void nsFT2Type8Generator::GeneratePSFont(FILE* aFile)
1628
void nsFT2Type8Generator::GeneratePSFont(FILE* aFile)
1620
{
1629
{
1621
  nsCAutoString fontName, styleName;
1630
  if (mFace == nsnull) {
1622
  mEntry->GetFamilyName(fontName);
1631
    nsCAutoString fileName;
1623
  mEntry->GetStyleName(styleName);
1632
    PRInt16       faceIndex; 
1624
  
1633
1625
  mImageDesc.font.face_id    = (void*)mEntry;
1634
    mEntry->GetFileName(fileName);
1626
  // TT glyph has no relation to size
1635
    mEntry->GetFaceIndex(&faceIndex);
1627
  mImageDesc.font.pix_width  = 16;
1636
    if (NS_FAILED(mFt2->
1628
  mImageDesc.font.pix_height = 16;
1637
          NewFace(mFreeTypeLibrary, fileName.get(), faceIndex, &mFace))) {
1629
  mImageDesc.image_type = 0;
1638
      return;
1630
  FT_Face face = nsnull;
1639
    }
1631
  FTC_Manager cManager;
1640
    NS_ASSERTION(mFace != nsnull, "mFace is null");
1632
  mFt2->GetFTCacheManager(&cManager);
1641
  }
1633
  nsresult rv = mFt2->ManagerLookupSize(cManager, &mImageDesc.font,
1642
1634
                                        &face, nsnull);
1635
  if (NS_FAILED(rv))
1636
    return;
1637
 
1643
 
1638
  int wmode = 0;
1644
  int wmode = 0;
1639
  if (!mSubset.IsEmpty())
1645
  if (!mSubset.IsEmpty())
1640
    FT2SubsetToType8(face, mSubset.get(), mSubset.Length(), wmode, aFile);
1646
    FT2SubsetToType8(mFace, mSubset.get(), mSubset.Length(), wmode, aFile);
1641
}
1647
}
1642
#endif //MOZ_ENABLE_FREETYPE2
1648
#endif //MOZ_ENABLE_FREETYPE2
1643
1649
(-)gfx/src/x11shared/nsFontFreeType.cpp.agriffis (-46 / +58 lines)
Lines 173-187 Link Here
173
FT_Face
173
FT_Face
174
nsFreeTypeFont::getFTFace()
174
nsFreeTypeFont::getFTFace()
175
{
175
{
176
  FT_Face face = nsnull;
176
  if (mFace) return mFace;
177
  FTC_Manager mgr;
177
178
  nsCAutoString fileName;
179
  PRInt16       faceIndex; 
180
  mFaceID->GetFileName(fileName);
181
  mFaceID->GetFaceIndex(&faceIndex);
182
178
  nsresult rv;
183
  nsresult rv;
179
  mFt2->GetFTCacheManager(&mgr);
184
  rv = mFt2->NewFace(mFreeTypeLibrary, fileName.get(), faceIndex, &mFace);
180
  rv = mFt2->ManagerLookupSize(mgr, &mImageDesc.font, &face, nsnull);
181
  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get face/size");
185
  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get face/size");
182
  if (NS_FAILED(rv))
186
  if (NS_FAILED(rv))
183
    return nsnull;
187
    return nsnull;
184
  return face;
188
  rv = mFt2->SetPixelSizes(mFace, mPixelSize, 0);
189
  if (NS_FAILED(rv))
190
    return nsnull;
191
  return mFace;
185
}
192
}
186
193
187
nsFreeTypeFont::nsFreeTypeFont(nsITrueTypeFontCatalogEntry *aFaceID,
194
nsFreeTypeFont::nsFreeTypeFont(nsITrueTypeFontCatalogEntry *aFaceID,
Lines 191-211 Link Here
191
  PRBool embedded_bimap = PR_FALSE;
198
  PRBool embedded_bimap = PR_FALSE;
192
  mFaceID = aFaceID;
199
  mFaceID = aFaceID;
193
  mPixelSize = aPixelSize;
200
  mPixelSize = aPixelSize;
194
  mImageDesc.font.face_id    = (void*)mFaceID;
201
//mLoadFlag = FT_LOAD_RENDER;
195
  mImageDesc.font.pix_width  = aPixelSize;
202
  mLoadFlag = 0;
196
  mImageDesc.font.pix_height = aPixelSize;
203
  mFace = nsnull;
197
  mImageDesc.image_type = 0;
198
204
199
  if (aPixelSize < nsFreeType2::gAntiAliasMinimum) {
205
  if (aPixelSize < nsFreeType2::gAntiAliasMinimum) {
200
    mImageDesc.image_type |= ftc_image_mono;
206
    mLoadFlag |= FT_LOAD_MONOCHROME; 
201
    anti_alias = PR_FALSE;
207
    anti_alias = PR_FALSE;
202
  }
208
  }
203
209
204
  if (nsFreeType2::gFreeType2Autohinted)
210
  if (nsFreeType2::gFreeType2Autohinted)
205
    mImageDesc.image_type |= ftc_image_flag_autohinted;
211
    mLoadFlag |= FT_LOAD_FORCE_AUTOHINT;
206
212
207
  if (nsFreeType2::gFreeType2Unhinted)
213
  if (nsFreeType2::gFreeType2Unhinted)
208
    mImageDesc.image_type |= ftc_image_flag_unhinted;
214
    mLoadFlag |= FT_LOAD_NO_HINTING;
209
215
210
  PRUint32  num_embedded_bitmaps, i;
216
  PRUint32  num_embedded_bitmaps, i;
211
  PRInt32*  embedded_bitmapheights;
217
  PRInt32*  embedded_bitmapheights;
Lines 218-224 Link Here
218
        if (embedded_bitmapheights[i] == aPixelSize) {
224
        if (embedded_bitmapheights[i] == aPixelSize) {
219
          embedded_bimap = PR_TRUE;
225
          embedded_bimap = PR_TRUE;
220
          // unhinted must be set for embedded bitmaps to be used
226
          // unhinted must be set for embedded bitmaps to be used
221
          mImageDesc.image_type |= ftc_image_flag_unhinted;
227
          mLoadFlag |= FT_LOAD_NO_HINTING;
222
          break;
228
          break;
223
        }
229
        }
224
      }
230
      }
Lines 230-235 Link Here
230
  mFt2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv);
236
  mFt2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv);
231
  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to find FreeType routines");
237
  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to find FreeType routines");
232
238
239
  if (mFt2) {
240
    rv = mFt2->GetLibrary(&mFreeTypeLibrary); 
241
    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to find FreeType library");
242
  }
243
233
  FREETYPE_FONT_PRINTF(("anti_alias=%d, embedded_bitmap=%d, "
244
  FREETYPE_FONT_PRINTF(("anti_alias=%d, embedded_bitmap=%d, "
234
                        "AutoHinted=%d, gFreeType2Unhinted = %d, "
245
                        "AutoHinted=%d, gFreeType2Unhinted = %d, "
235
                        "size=%dpx, \"%s\"",
246
                        "size=%dpx, \"%s\"",
Lines 288-295 Link Here
288
                                     PRInt32* aDescent,
299
                                     PRInt32* aDescent,
289
                                     PRInt32* aWidth)
300
                                     PRInt32* aWidth)
290
{
301
{
291
  nsresult rv;
292
293
  *aLeftBearing = 0;
302
  *aLeftBearing = 0;
294
  *aRightBearing = 0;
303
  *aRightBearing = 0;
295
  *aAscent = 0;
304
  *aAscent = 0;
Lines 312-322 Link Here
312
  if (!face)
321
  if (!face)
313
    return NS_ERROR_FAILURE;
322
    return NS_ERROR_FAILURE;
314
323
315
  FTC_Image_Cache icache;
316
  mFt2->GetImageCache(&icache);
317
  if (!icache)
318
    return NS_ERROR_FAILURE;
319
320
  // get the text size
324
  // get the text size
321
  PRUint32 i, extraSurrogateLength;
325
  PRUint32 i, extraSurrogateLength;
322
  for (i=0; i<aLength; i+=1+extraSurrogateLength) {
326
  for (i=0; i<aLength; i+=1+extraSurrogateLength) {
Lines 337-352 Link Here
337
    }
341
    }
338
    mFt2->GetCharIndex(face, code_point, &glyph_index);
342
    mFt2->GetCharIndex(face, code_point, &glyph_index);
339
343
340
    //NS_ASSERTION(glyph_index,"failed to get glyph");
344
    // XXX : we need some caching here
341
    if (glyph_index) {
345
    if (glyph_index && 
342
      rv = mFt2->ImageCacheLookup(icache, &mImageDesc, glyph_index, &glyph);
346
        NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, mLoadFlag)) &&
343
      NS_ASSERTION(NS_SUCCEEDED(rv),"error loading glyph");
347
//      NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) &&
344
    }
348
        NS_SUCCEEDED(mFt2->GetGlyph(face->glyph, &glyph))) {
345
    if ((glyph_index) && (NS_SUCCEEDED(rv))) {
346
      mFt2->GlyphGetCBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox);
349
      mFt2->GlyphGetCBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox);
347
      advance = FT_16_16_TO_REG(glyph->advance.x);
350
      advance = FT_16_16_TO_REG(glyph->advance.x);
351
      mFt2->DoneGlyph(glyph);
348
    }
352
    }
349
    else {
353
    else {
354
      NS_ERROR("failed to get or load glyph");
350
      // allocate space to draw an empty box in
355
      // allocate space to draw an empty box in
351
      GetFallbackGlyphMetrics(&glyph_bbox, face);
356
      GetFallbackGlyphMetrics(&glyph_bbox, face);
352
      advance = glyph_bbox.xMax + 1;
357
      advance = glyph_bbox.xMax + 1;
Lines 401-411 Link Here
401
  if (!face)
406
  if (!face)
402
    return 0;
407
    return 0;
403
408
404
  FTC_Image_Cache icache;
405
  mFt2->GetImageCache(&icache);
406
  if (!icache)
407
    return 0;
408
409
  PRUint32 i, extraSurrogateLength;
409
  PRUint32 i, extraSurrogateLength;
410
  for (i=0; i<aLength; i+=1+extraSurrogateLength) {
410
  for (i=0; i<aLength; i+=1+extraSurrogateLength) {
411
    extraSurrogateLength=0;
411
    extraSurrogateLength=0;
Lines 418-432 Link Here
418
      // skip aString[i+1], it is already used as low surrogate
418
      // skip aString[i+1], it is already used as low surrogate
419
      extraSurrogateLength = 1;
419
      extraSurrogateLength = 1;
420
    }
420
    }
421
422
    // XXX : we need some caching here
421
    mFt2->GetCharIndex((FT_Face)face, code_point, &glyph_index);
423
    mFt2->GetCharIndex((FT_Face)face, code_point, &glyph_index);
422
    nsresult rv;
424
    if (NS_FAILED(mFt2->LoadGlyph(face, glyph_index, mLoadFlag)) ||
423
    rv = mFt2->ImageCacheLookup(icache, &mImageDesc, glyph_index, &glyph);
425
//  if (NS_FAILED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) ||
424
    NS_ASSERTION(NS_SUCCEEDED(rv),"error loading glyph");
426
          NS_FAILED(mFt2->GetGlyph(face->glyph, &glyph))) {
425
    if (NS_FAILED(rv)) {
427
      NS_ERROR("error loading glyph");
426
      origin_x += face->size->metrics.x_ppem/2 + 2;
428
      origin_x += face->size->metrics.x_ppem/2 + 2;
427
      continue;
429
      continue;
428
    }
430
    }
429
    origin_x += FT_16_16_TO_REG(glyph->advance.x);
431
    origin_x += FT_16_16_TO_REG(glyph->advance.x);
432
    mFt2->DoneGlyph(glyph);
430
  }
433
  }
431
434
432
  return origin_x;
435
  return origin_x;
Lines 723-733 Link Here
723
    if (y%4==0) (*blendPixelFunc)(sub_image, y, ascent-1, black, 255/2);
726
    if (y%4==0) (*blendPixelFunc)(sub_image, y, ascent-1, black, 255/2);
724
#endif
727
#endif
725
728
726
  FTC_Image_Cache icache;
727
  mFt2->GetImageCache(&icache);
728
  if (!icache)
729
    return 0;
730
731
  //
729
  //
732
  // Get aa glyphs and blend with background
730
  // Get aa glyphs and blend with background
733
  //
731
  //
Lines 736-742 Link Here
736
  for (i=0; i<aLength; i+=1+extraSurrogateLength) {
734
  for (i=0; i<aLength; i+=1+extraSurrogateLength) {
737
    FT_UInt glyph_index;
735
    FT_UInt glyph_index;
738
    FT_Glyph glyph;
736
    FT_Glyph glyph;
739
    nsresult rv;
740
    FT_BBox glyph_bbox;
737
    FT_BBox glyph_bbox;
741
    FT_ULong code_point = aString[i];
738
    FT_ULong code_point = aString[i];
742
    extraSurrogateLength = 0;
739
    extraSurrogateLength = 0;
Lines 750-760 Link Here
750
      extraSurrogateLength = 1;
747
      extraSurrogateLength = 1;
751
    }
748
    }
752
749
750
    // XXX : we need some caching here
753
    mFt2->GetCharIndex(face, code_point, &glyph_index);
751
    mFt2->GetCharIndex(face, code_point, &glyph_index);
754
    if (glyph_index) {
752
    if (glyph_index && 
755
      rv = mFt2->ImageCacheLookup(icache, &mImageDesc, glyph_index, &glyph);
753
        NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, mLoadFlag)) &&
756
    }
754
//      NS_SUCCEEDED(mFt2->LoadGlyph(face, glyph_index, FT_LOAD_DEFAULT)) &&
757
    if ((glyph_index) && (NS_SUCCEEDED(rv))) {
755
        NS_SUCCEEDED(mFt2->GetGlyph(face->glyph, &glyph))) {
758
      mFt2->GlyphGetCBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox);
756
      mFt2->GlyphGetCBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox);
759
    }
757
    }
760
    else {
758
    else {
Lines 775-787 Link Here
775
      continue;
773
      continue;
776
    }
774
    }
777
775
778
    FT_BitmapGlyph slot = (FT_BitmapGlyph)glyph;
776
    FT_BitmapGlyph slot;
777
778
    if (glyph->format != FT_GLYPH_FORMAT_BITMAP) 
779
    {
780
      if (mFt2->GlyphToBitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
781
        NS_ERROR("failed to convert outline to bitmap ");
782
        XDestroyImage(sub_image);
783
        mFt2->DoneGlyph(glyph);
784
        return 0;
785
      }
786
    }
787
788
    slot = (FT_BitmapGlyph)glyph;
779
    nsAntiAliasedGlyph aaglyph(glyph_bbox.xMax-glyph_bbox.xMin,
789
    nsAntiAliasedGlyph aaglyph(glyph_bbox.xMax-glyph_bbox.xMin,
780
                               glyph_bbox.yMax-glyph_bbox.yMin, 0);
790
                               glyph_bbox.yMax-glyph_bbox.yMin, 0);
781
    PRUint8 buf[IMAGE_BUFFER_SIZE]; // try to use the stack for data
791
    PRUint8 buf[IMAGE_BUFFER_SIZE]; // try to use the stack for data
782
    if (!aaglyph.WrapFreeType(&glyph_bbox, slot, buf, IMAGE_BUFFER_SIZE)) {
792
    if (!aaglyph.WrapFreeType(&glyph_bbox, slot, buf, IMAGE_BUFFER_SIZE)) {
783
      NS_ERROR("failed to wrap freetype image");
793
      NS_ERROR("failed to wrap freetype image");
784
      XDestroyImage(sub_image);
794
      XDestroyImage(sub_image);
795
      mFt2->DoneGlyph(glyph);
785
      return 0;
796
      return 0;
786
    }
797
    }
787
798
Lines 815-820 Link Here
815
                  x_pos + aaglyph.GetLBearing(), ascent-glyph_bbox.yMax);
826
                  x_pos + aaglyph.GetLBearing(), ascent-glyph_bbox.yMax);
816
827
817
    x_pos += aaglyph.GetAdvance();
828
    x_pos += aaglyph.GetAdvance();
829
    mFt2->DoneGlyph(glyph);
818
  }
830
  }
819
831
820
  //
832
  //
(-)gfx/src/x11shared/nsFontFreeType.h.agriffis (-1 / +3 lines)
Lines 110-117 Link Here
110
  XImage *GetXImage(PRUint32 width, PRUint32 height);
110
  XImage *GetXImage(PRUint32 width, PRUint32 height);
111
  nsITrueTypeFontCatalogEntry *mFaceID;
111
  nsITrueTypeFontCatalogEntry *mFaceID;
112
  PRUint16        mPixelSize;
112
  PRUint16        mPixelSize;
113
  FTC_Image_Desc  mImageDesc;
114
  nsCOMPtr<nsIFreeType2> mFt2;
113
  nsCOMPtr<nsIFreeType2> mFt2;
114
  FT_Face         mFace;
115
  FT_Int32        mLoadFlag;
116
  FT_Library      mFreeTypeLibrary;
115
};
117
};
116
118
117
void WeightTableInitCorrection(PRUint8*, PRUint8, double);
119
void WeightTableInitCorrection(PRUint8*, PRUint8, double);
(-)gfx/src/freetype/nsFreeType.cpp.agriffis (-81 / +6 lines)
Lines 109-120 Link Here
109
  {"FT_Load_Glyph",           NS_FT2_OFFSET(nsFT_Load_Glyph),           PR_TRUE},
109
  {"FT_Load_Glyph",           NS_FT2_OFFSET(nsFT_Load_Glyph),           PR_TRUE},
110
  {"FT_New_Face",             NS_FT2_OFFSET(nsFT_New_Face),             PR_TRUE},
110
  {"FT_New_Face",             NS_FT2_OFFSET(nsFT_New_Face),             PR_TRUE},
111
  {"FT_Outline_Decompose",    NS_FT2_OFFSET(nsFT_Outline_Decompose),    PR_TRUE},
111
  {"FT_Outline_Decompose",    NS_FT2_OFFSET(nsFT_Outline_Decompose),    PR_TRUE},
112
  {"FT_Set_Pixel_Sizes",      NS_FT2_OFFSET(nsFT_Set_Pixel_Sizes),      PR_TRUE},
112
  {"FT_Set_Charmap",          NS_FT2_OFFSET(nsFT_Set_Charmap),          PR_TRUE},
113
  {"FT_Set_Charmap",          NS_FT2_OFFSET(nsFT_Set_Charmap),          PR_TRUE},
113
  {"FTC_Image_Cache_Lookup",  NS_FT2_OFFSET(nsFTC_Image_Cache_Lookup),  PR_TRUE},
114
  {"FTC_Manager_Lookup_Size", NS_FT2_OFFSET(nsFTC_Manager_Lookup_Size), PR_TRUE},
115
  {"FTC_Manager_Done",        NS_FT2_OFFSET(nsFTC_Manager_Done),        PR_TRUE},
116
  {"FTC_Manager_New",         NS_FT2_OFFSET(nsFTC_Manager_New),         PR_TRUE},
117
  {"FTC_Image_Cache_New",     NS_FT2_OFFSET(nsFTC_Image_Cache_New),     PR_TRUE},
118
// #ifdef MOZ_SVG
114
// #ifdef MOZ_SVG
119
  {"FT_Glyph_Transform",      NS_FT2_OFFSET(nsFT_Glyph_Transform),      PR_TRUE},
115
  {"FT_Glyph_Transform",      NS_FT2_OFFSET(nsFT_Glyph_Transform),      PR_TRUE},
120
  {"FT_Get_Kerning",          NS_FT2_OFFSET(nsFT_Get_Kerning),          PR_TRUE},
116
  {"FT_Get_Kerning",          NS_FT2_OFFSET(nsFT_Get_Kerning),          PR_TRUE},
Lines 274-332 Link Here
274
} 
270
} 
275
 
271
 
276
NS_IMETHODIMP
272
NS_IMETHODIMP
277
nsFreeType2::SetCharmap(FT_Face face, FT_CharMap  charmap)
273
nsFreeType2::SetPixelSizes(FT_Face face, FT_UInt width, FT_UInt height)
278
{ 
279
  // call the FreeType2 function via the function pointer
280
  FT_Error error = nsFT_Set_Charmap(face, charmap);
281
  return error ? NS_ERROR_FAILURE : NS_OK;
282
} 
283
 
284
NS_IMETHODIMP
285
nsFreeType2::ImageCacheLookup(FTC_Image_Cache cache, FTC_Image_Desc *desc,
286
                              FT_UInt glyphID, FT_Glyph *glyph)
287
{ 
288
  // call the FreeType2 function via the function pointer
289
  FT_Error error = nsFTC_Image_Cache_Lookup(cache, desc, glyphID, glyph);
290
  return error ? NS_ERROR_FAILURE : NS_OK;
291
} 
292
 
293
NS_IMETHODIMP
294
nsFreeType2::ManagerLookupSize(FTC_Manager manager, FTC_Font font,
295
                               FT_Face *face, FT_Size *size)
296
{ 
274
{ 
297
  // call the FreeType2 function via the function pointer
275
  // call the FreeType2 function via the function pointer
298
  FT_Error error = nsFTC_Manager_Lookup_Size(manager, font, face, size);
276
  FT_Error error = nsFT_Set_Pixel_Sizes(face, width, height); 
299
  return error ? NS_ERROR_FAILURE : NS_OK;
277
  return error ? NS_ERROR_FAILURE : NS_OK;
300
} 
278
} 
301
 
279
302
NS_IMETHODIMP
303
nsFreeType2::ManagerDone(FTC_Manager manager)
304
{ 
305
  // call the FreeType2 function via the function pointer
306
  nsFTC_Manager_Done(manager);
307
  return NS_OK;
308
} 
309
 
310
NS_IMETHODIMP
280
NS_IMETHODIMP
311
nsFreeType2::ManagerNew(FT_Library library, FT_UInt max_faces,
281
nsFreeType2::SetCharmap(FT_Face face, FT_CharMap  charmap)
312
                        FT_UInt max_sizes, FT_ULong max_bytes,
313
                        FTC_Face_Requester requester, FT_Pointer req_data,
314
                        FTC_Manager *manager)
315
{ 
282
{ 
316
  // call the FreeType2 function via the function pointer
283
  // call the FreeType2 function via the function pointer
317
  FT_Error error = nsFTC_Manager_New(library, max_faces, max_sizes, max_bytes,
284
  FT_Error error = nsFT_Set_Charmap(face, charmap);
318
                                     requester, req_data, manager);
319
  return error ? NS_ERROR_FAILURE : NS_OK;
285
  return error ? NS_ERROR_FAILURE : NS_OK;
320
} 
286
} 
321
 
287
 
322
NS_IMETHODIMP
323
nsFreeType2::ImageCacheNew(FTC_Manager manager, FTC_Image_Cache *cache)
324
{ 
325
  // call the FreeType2 function via the function pointer
326
  FT_Error error = nsFTC_Image_Cache_New(manager, cache);
327
  return error ? NS_ERROR_FAILURE : NS_OK;
328
} 
329
330
// #ifdef MOZ_SVG
288
// #ifdef MOZ_SVG
331
NS_IMETHODIMP
289
NS_IMETHODIMP
332
nsFreeType2::GlyphTransform(FT_Glyph glyph, FT_Matrix * matrix, FT_Vector * delta)
290
nsFreeType2::GlyphTransform(FT_Glyph glyph, FT_Matrix * matrix, FT_Vector * delta)
Lines 389-408 Link Here
389
} 
347
} 
390
 
348
 
391
NS_IMETHODIMP
349
NS_IMETHODIMP
392
nsFreeType2::GetImageCache(FTC_Image_Cache *aCache)
393
{
394
  *aCache = mImageCache;
395
  return NS_OK;
396
}
397
398
NS_IMETHODIMP
399
nsFreeType2::GetFTCacheManager(FTC_Manager *aManager)
400
{ 
401
  *aManager = mFTCacheManager;
402
  return NS_OK;
403
} 
404
 
405
NS_IMETHODIMP
406
nsFreeType2::GetLibrary(FT_Library *aLibrary)
350
nsFreeType2::GetLibrary(FT_Library *aLibrary)
407
{ 
351
{ 
408
  *aLibrary = mFreeTypeLibrary;
352
  *aLibrary = mFreeTypeLibrary;
Lines 425-432 Link Here
425
{
369
{
426
  mSharedLib = nsnull;
370
  mSharedLib = nsnull;
427
  mFreeTypeLibrary = nsnull;
371
  mFreeTypeLibrary = nsnull;
428
  mFTCacheManager  = nsnull;
429
  mImageCache      = nsnull;
430
}
372
}
431
373
432
// I would like to make this a static member function but the compilier 
374
// I would like to make this a static member function but the compilier 
Lines 456-467 Link Here
456
    delete gFreeTypeFaces;
398
    delete gFreeTypeFaces;
457
    gFreeTypeFaces = nsnull;
399
    gFreeTypeFaces = nsnull;
458
  }
400
  }
459
  // mImageCache released by cache manager
460
  if (mFTCacheManager) {
461
    // use "this->" to make sure it is obivious we are calling the member func
462
    this->ManagerDone(mFTCacheManager);
463
    mFTCacheManager = nsnull;
464
  }
465
  if (mFreeTypeLibrary) {
401
  if (mFreeTypeLibrary) {
466
    // use "this->" to make sure it is obivious we are calling the member func
402
    // use "this->" to make sure it is obivious we are calling the member func
467
    this->DoneFreeType(mFreeTypeLibrary);
403
    this->DoneFreeType(mFreeTypeLibrary);
Lines 658-674 Link Here
658
    mFreeTypeLibrary = nsnull;
594
    mFreeTypeLibrary = nsnull;
659
    goto cleanup_and_return;
595
    goto cleanup_and_return;
660
  }
596
  }
661
  // use "this->" to make sure it is obivious we are calling the member func
662
  rv = this->ManagerNew(mFreeTypeLibrary, 0, 0, 0, nsFreeTypeFaceRequester,
663
                         this, &mFTCacheManager);
664
  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create FreeType Cache manager");
665
  if (NS_FAILED(rv))
666
    goto cleanup_and_return;
667
  // use "this->" to make sure it is obivious we are calling the member func
668
  rv = this->ImageCacheNew(mFTCacheManager, &mImageCache);
669
  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create FreeType image cache");
670
  if (NS_FAILED(rv))
671
    goto cleanup_and_return;
672
  return PR_TRUE;
597
  return PR_TRUE;
673
598
674
cleanup_and_return:
599
cleanup_and_return:
(-)gfx/src/freetype/nsFreeType.h.agriffis (-17 / +4 lines)
Lines 102-116 Link Here
102
typedef FT_Error (*FT_Outline_Decompose_t)
102
typedef FT_Error (*FT_Outline_Decompose_t)
103
                      (FT_Outline*, const FT_Outline_Funcs*, void*);
103
                      (FT_Outline*, const FT_Outline_Funcs*, void*);
104
typedef FT_Error (*FT_New_Face_t)(FT_Library, const char*, FT_Long, FT_Face*);
104
typedef FT_Error (*FT_New_Face_t)(FT_Library, const char*, FT_Long, FT_Face*);
105
typedef FT_Error (*FT_Set_Pixel_Sizes_t)(FT_Face face, FT_UInt, FT_UInt);
105
typedef FT_Error (*FT_Set_Charmap_t)(FT_Face face, FT_CharMap  charmap);
106
typedef FT_Error (*FT_Set_Charmap_t)(FT_Face face, FT_CharMap  charmap);
106
typedef FT_Error (*FTC_Image_Cache_Lookup_t)
107
                      (FTC_Image_Cache, FTC_Image_Desc*, FT_UInt, FT_Glyph*);
108
typedef FT_Error (*FTC_Manager_Lookup_Size_t)
109
                      (FTC_Manager, FTC_Font, FT_Face*, FT_Size*);
110
typedef FT_Error (*FTC_Manager_Done_t)(FTC_Manager);
111
typedef FT_Error (*FTC_Manager_New_t)(FT_Library, FT_UInt, FT_UInt, FT_ULong,
112
                       FTC_Face_Requester, FT_Pointer, FTC_Manager*);
113
typedef FT_Error (*FTC_Image_Cache_New_t)(FTC_Manager, FTC_Image_Cache*);
114
// #ifdef MOZ_SVG
107
// #ifdef MOZ_SVG
115
typedef FT_Error (*FT_Glyph_Transform_t)(FT_Glyph, FT_Matrix*, FT_Vector*);
108
typedef FT_Error (*FT_Glyph_Transform_t)(FT_Glyph, FT_Matrix*, FT_Vector*);
116
typedef FT_Error (*FT_Get_Kerning_t)
109
typedef FT_Error (*FT_Get_Kerning_t)
Lines 163-174 Link Here
163
  FT_Load_Glyph_t           nsFT_Load_Glyph;
156
  FT_Load_Glyph_t           nsFT_Load_Glyph;
164
  FT_New_Face_t             nsFT_New_Face;
157
  FT_New_Face_t             nsFT_New_Face;
165
  FT_Outline_Decompose_t    nsFT_Outline_Decompose;
158
  FT_Outline_Decompose_t    nsFT_Outline_Decompose;
159
  FT_Set_Pixel_Sizes_t      nsFT_Set_Pixel_Sizes;
166
  FT_Set_Charmap_t          nsFT_Set_Charmap;
160
  FT_Set_Charmap_t          nsFT_Set_Charmap;
167
  FTC_Image_Cache_Lookup_t  nsFTC_Image_Cache_Lookup;
168
  FTC_Manager_Lookup_Size_t nsFTC_Manager_Lookup_Size;
169
  FTC_Manager_Done_t        nsFTC_Manager_Done;
170
  FTC_Manager_New_t         nsFTC_Manager_New;
171
  FTC_Image_Cache_New_t     nsFTC_Image_Cache_New;
172
// #ifdef MOZ_SVG
161
// #ifdef MOZ_SVG
173
  FT_Glyph_Transform_t      nsFT_Glyph_Transform;
162
  FT_Glyph_Transform_t      nsFT_Glyph_Transform;
174
  FT_Get_Kerning_t          nsFT_Get_Kerning;
163
  FT_Get_Kerning_t          nsFT_Get_Kerning;
Lines 181-189 Link Here
181
  // this array needs to be big enough to hold all the function pointers
170
  // this array needs to be big enough to hold all the function pointers
182
  // plus one extra for the null at the end
171
  // plus one extra for the null at the end
183
// #ifdef MOZ_SVG
172
// #ifdef MOZ_SVG
184
  static FtFuncList FtFuncs[24];
173
  static FtFuncList FtFuncs[20];
185
// #else
174
// #else
186
//  static FtFuncList FtFuncs[20];
175
//  static FtFuncList FtFuncs[17];
187
// #endif
176
// #endif
188
  
177
  
189
protected:
178
protected:
Lines 212-219 Link Here
212
201
213
  PRLibrary      *mSharedLib;
202
  PRLibrary      *mSharedLib;
214
  FT_Library      mFreeTypeLibrary;
203
  FT_Library      mFreeTypeLibrary;
215
  FTC_Manager     mFTCacheManager;
216
  FTC_Image_Cache mImageCache;
217
204
218
  static nsHashtable   *sFontFamilies;
205
  static nsHashtable   *sFontFamilies;
219
  static nsHashtable   *sRange1CharSetNames;
206
  static nsHashtable   *sRange1CharSetNames;

Return to bug 73255