[OS/2] follow-up for bug 437356 to unbreak the OS/2 build.

This just copies the font entry stub of gfxPangoFonts, we are going to make real use of the fontentry stuff for OS/2 hopefully soon.
This commit is contained in:
Peter Weilbacher 2008-08-07 10:12:45 +02:00
parent ea5746602f
commit 1ec3d5e1f0
2 changed files with 20 additions and 13 deletions

View File

@ -51,9 +51,15 @@
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
class gfxOS2FontEntry : public gfxFontEntry {
public:
gfxOS2FontEntry(const nsAString& aName) : gfxFontEntry(aName) {}
~gfxOS2FontEntry() {}
};
class gfxOS2Font : public gfxFont { class gfxOS2Font : public gfxFont {
public: public:
gfxOS2Font(const nsAString &aName, const gfxFontStyle *aFontStyle); gfxOS2Font(gfxOS2FontEntry *aFontEntry, const gfxFontStyle *aFontStyle);
virtual ~gfxOS2Font(); virtual ~gfxOS2Font();
virtual const gfxFont::Metrics& GetMetrics(); virtual const gfxFont::Metrics& GetMetrics();

View File

@ -54,8 +54,8 @@
* class gfxOS2Font * class gfxOS2Font
**********************************************************************/ **********************************************************************/
gfxOS2Font::gfxOS2Font(const nsAString &aName, const gfxFontStyle *aFontStyle) gfxOS2Font::gfxOS2Font(gfxOS2FontEntry *aFontEntry, const gfxFontStyle *aFontStyle)
: gfxFont(aName, aFontStyle), : gfxFont(aFontEntry, aFontStyle),
mFontFace(nsnull), mScaledFont(nsnull), mFontFace(nsnull), mScaledFont(nsnull),
mMetrics(nsnull), mAdjustedSize(0), mMetrics(nsnull), mAdjustedSize(0),
mHinting(FC_HINT_MEDIUM), mAntialias(FcTrue) mHinting(FC_HINT_MEDIUM), mAntialias(FcTrue)
@ -231,7 +231,7 @@ const gfxFont::Metrics& gfxOS2Font::GetMetrics()
" emAsc=%f emDesc=%f maxH=%f\n" " emAsc=%f emDesc=%f maxH=%f\n"
" maxAsc=%f maxDes=%f maxAdv=%f\n", " maxAsc=%f maxDes=%f maxAdv=%f\n",
(unsigned)this, (unsigned)this,
NS_LossyConvertUTF16toASCII(mName).get(), NS_LossyConvertUTF16toASCII(GetName()).get(),
os2 && os2->version != 0xFFFF ? "has OS/2 table" : "no OS/2 table!", os2 && os2->version != 0xFFFF ? "has OS/2 table" : "no OS/2 table!",
mMetrics->emHeight, GetStyle()->size, mAdjustedSize, mMetrics->emHeight, GetStyle()->size, mAdjustedSize,
mMetrics->maxHeight, mMetrics->xHeight, mMetrics->maxHeight, mMetrics->xHeight,
@ -277,14 +277,14 @@ cairo_font_face_t *gfxOS2Font::CairoFontFace()
if (!mFontFace) { if (!mFontFace) {
#ifdef DEBUG_thebes #ifdef DEBUG_thebes
printf("gfxOS2Font[%#x]::CairoFontFace(): create it for %s, %f\n", printf("gfxOS2Font[%#x]::CairoFontFace(): create it for %s, %f\n",
(unsigned)this, NS_LossyConvertUTF16toASCII(mName).get(), GetStyle()->size); (unsigned)this, NS_LossyConvertUTF16toASCII(GetName()).get(), GetStyle()->size);
#endif #endif
FcPattern *fcPattern = FcPatternCreate(); FcPattern *fcPattern = FcPatternCreate();
// add (family) name to pattern // add (family) name to pattern
// (the conversion should work, font names don't contain high bit chars) // (the conversion should work, font names don't contain high bit chars)
FcPatternAddString(fcPattern, FC_FAMILY, FcPatternAddString(fcPattern, FC_FAMILY,
(FcChar8 *)NS_LossyConvertUTF16toASCII(mName).get()); (FcChar8 *)NS_LossyConvertUTF16toASCII(GetName()).get());
// adjust font weight using the offset // adjust font weight using the offset
// The requirements outlined in gfxFont.h are difficult to meet without // The requirements outlined in gfxFont.h are difficult to meet without
@ -348,14 +348,14 @@ cairo_font_face_t *gfxOS2Font::CairoFontFace()
FcPatternGetInteger(fcMatch, FC_SLANT, 0, &i2); FcPatternGetInteger(fcMatch, FC_SLANT, 0, &i2);
FcPatternGetDouble(fcMatch, FC_PIXEL_SIZE, 0, &s2); FcPatternGetDouble(fcMatch, FC_PIXEL_SIZE, 0, &s2);
printf(" input=%s,%d,%d,%f\n fcPattern=%s,%d,%d,%f\n fcMatch=%s,%d,%d,%f\n", printf(" input=%s,%d,%d,%f\n fcPattern=%s,%d,%d,%f\n fcMatch=%s,%d,%d,%f\n",
NS_LossyConvertUTF16toASCII(mName).get(), NS_LossyConvertUTF16toASCII(GetName()).get(),
GetStyle()->weight, GetStyle()->style, GetStyle()->size, GetStyle()->weight, GetStyle()->style, GetStyle()->size,
(char *)str1, w1, i1, s1, (char *)str1, w1, i1, s1,
(char *)str2, w2, i2, s2); (char *)str2, w2, i2, s2);
#endif #endif
FcPatternDestroy(fcPattern); FcPatternDestroy(fcPattern);
if (mName == NS_LITERAL_STRING("Workplace Sans") && fcW >= FC_WEIGHT_DEMIBOLD) { if (GetName() == NS_LITERAL_STRING("Workplace Sans") && fcW >= FC_WEIGHT_DEMIBOLD) {
// if we are dealing with Workplace Sans and want a bold font, we // if we are dealing with Workplace Sans and want a bold font, we
// need to artificially embolden it (no bold counterpart yet) // need to artificially embolden it (no bold counterpart yet)
FcPatternAddBool(fcMatch, FC_EMBOLDEN, FcTrue); FcPatternAddBool(fcMatch, FC_EMBOLDEN, FcTrue);
@ -383,7 +383,7 @@ cairo_scaled_font_t *gfxOS2Font::CairoScaledFont()
if (!mScaledFont) { if (!mScaledFont) {
#ifdef DEBUG_thebes_2 #ifdef DEBUG_thebes_2
printf("gfxOS2Font[%#x]::CairoScaledFont(): create it for %s, %f\n", printf("gfxOS2Font[%#x]::CairoScaledFont(): create it for %s, %f\n",
(unsigned)this, NS_LossyConvertUTF16toASCII(mName).get(), GetStyle()->size); (unsigned)this, NS_LossyConvertUTF16toASCII(GetName()).get(), GetStyle()->size);
#endif #endif
double size = mAdjustedSize ? mAdjustedSize : GetStyle()->size; double size = mAdjustedSize ? mAdjustedSize : GetStyle()->size;
@ -404,12 +404,12 @@ cairo_scaled_font_t *gfxOS2Font::CairoScaledFont()
nsString gfxOS2Font::GetUniqueName() nsString gfxOS2Font::GetUniqueName()
{ {
#ifdef DEBUG_thebes #ifdef DEBUG_thebes
printf("gfxOS2Font::GetUniqueName()=%s\n", (char *)mName.get()); printf("gfxOS2Font::GetUniqueName()=%s\n", (char *)GetName().get());
#endif #endif
// gfxFont::mName should already be unique enough // gfxFont::GetName() should already be unique enough
// Atsui uses that, too, while Win appends size, and properties... // Atsui uses that, too, while Win appends size, and properties...
// doesn't seem to get called at all anyway // doesn't seem to get called at all anyway
return mName; return GetName();
} }
PRBool gfxOS2Font::SetupCairoFont(gfxContext *aContext) PRBool gfxOS2Font::SetupCairoFont(gfxContext *aContext)
@ -441,7 +441,8 @@ already_AddRefed<gfxOS2Font> gfxOS2Font::GetOrMakeFont(const nsAString& aName,
{ {
nsRefPtr<gfxFont> font = gfxFontCache::GetCache()->Lookup(aName, aStyle); nsRefPtr<gfxFont> font = gfxFontCache::GetCache()->Lookup(aName, aStyle);
if (!font) { if (!font) {
font = new gfxOS2Font(aName, aStyle); nsRefPtr<gfxOS2FontEntry> fe = new gfxOS2FontEntry(aName);
font = new gfxOS2Font(fe, aStyle);
if (!font) if (!font)
return nsnull; return nsnull;
gfxFontCache::GetCache()->AddNew(font); gfxFontCache::GetCache()->AddNew(font);