diff --git a/gfx/thebes/public/gfxFontUtils.h b/gfx/thebes/public/gfxFontUtils.h index 26af7b1f7dd..a742bfabc4a 100644 --- a/gfx/thebes/public/gfxFontUtils.h +++ b/gfx/thebes/public/gfxFontUtils.h @@ -368,9 +368,6 @@ public: static void GetPrefsFontList(const char *aPrefName, nsTArray& aFontList); - // generate a unique font name - static nsresult MakeUniqueUserFontName(nsAString& aName); - }; // helper class for loading in font info spaced out at regular intervals diff --git a/gfx/thebes/src/gfxFontUtils.cpp b/gfx/thebes/src/gfxFontUtils.cpp index 6c61529a887..3c4dafbf6f6 100644 --- a/gfx/thebes/src/gfxFontUtils.cpp +++ b/gfx/thebes/src/gfxFontUtils.cpp @@ -46,12 +46,8 @@ #include "nsIPrefLocalizedString.h" #include "nsISupportsPrimitives.h" #include "nsIStreamBufferAccess.h" -#include "nsIUUIDGenerator.h" #include "nsMemory.h" -#include "plbase64.h" - - #define NO_RANGE_FOUND 126 // bit 126 in the font unicode ranges is required to be 0 /* Unicode subrange table @@ -475,43 +471,6 @@ void gfxFontUtils::GetPrefsFontList(const char *aPrefName, nsTArray& a } -// produce a unique font name that is (1) a valid Postscript name and (2) less -// than 31 characters in length. Using AddFontMemResourceEx on Windows fails -// for names longer than 30 characters in length. - -#define MAX_B64_LEN 32 - -nsresult gfxFontUtils::MakeUniqueUserFontName(nsAString& aName) -{ - nsCOMPtr uuidgen = - do_GetService("@mozilla.org/uuid-generator;1"); - NS_ENSURE_TRUE(uuidgen, NS_ERROR_OUT_OF_MEMORY); - - nsID guid; - - NS_ASSERTION(sizeof(guid) * 2 <= MAX_B64_LEN, "size of nsID has changed!"); - - nsresult rv = uuidgen->GenerateUUIDInPlace(&guid); - NS_ENSURE_SUCCESS(rv, rv); - - char guidB64[MAX_B64_LEN] = {0}; - - if (!PL_Base64Encode((char *)(&guid), sizeof(guid), guidB64)) - return NS_ERROR_FAILURE; - - // all b64 characters except for '/' are allowed in Postscript names, so convert / ==> - - char *p; - for (p = guidB64; *p; p++) { - if (*p == '/') - *p = '-'; - } - - aName.Assign(NS_LITERAL_STRING("uf")); - aName.AppendASCII(guidB64); - return NS_OK; -} - - // TrueType/OpenType table handling code // need byte aligned structs diff --git a/gfx/thebes/src/gfxQuartzFontCache.mm b/gfx/thebes/src/gfxQuartzFontCache.mm index c228913d6fa..7f28742501c 100644 --- a/gfx/thebes/src/gfxQuartzFontCache.mm +++ b/gfx/thebes/src/gfxQuartzFontCache.mm @@ -1429,8 +1429,10 @@ gfxQuartzFontCache::MakePlatformFont(const gfxFontEntry *aProxyEntry, // now lookup the Postscript name; this may fail if the font cache is bad OSStatus err; NSString *psname = NULL; + nsAutoString postscriptName; err = ATSFontGetPostScriptName(fontRef, kATSOptionFlagsDefault, (CFStringRef*) (&psname)); if (err == noErr) { + GetStringForNSString(psname, postscriptName); [psname release]; } else { #ifdef DEBUG @@ -1459,16 +1461,8 @@ gfxQuartzFontCache::MakePlatformFont(const gfxFontEntry *aProxyEntry, NS_ASSERTION(w >= 100 && w <= 900, "bogus font weight value!"); // create the font entry - nsAutoString uniqueName; - - nsresult rv = gfxFontUtils::MakeUniqueUserFontName(uniqueName); - if (NS_FAILED(rv)) { - delete userFontData; - return nsnull; - } - MacOSFontEntry *newFontEntry = - new MacOSFontEntry(uniqueName, + new MacOSFontEntry(postscriptName, FMGetFontFromATSFontRef(fontRef), w, aProxyEntry->mStretch, (PRUint32(aProxyEntry->mItalic) ? diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp index 290862340f5..bc405e37428 100644 --- a/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/gfx/thebes/src/gfxWindowsFonts.cpp @@ -492,6 +492,17 @@ public: }; +static void MakeUniqueFontName(nsAString& aName) +{ + char buf[50]; + + static PRUint32 fontCount = 0; + ++fontCount; + + sprintf(buf, "mozfont%8.8x%8.8x", ::GetTickCount(), fontCount); // slightly retarded, figure something better later... + aName.AssignASCII(buf); +} + /* static */ FontEntry* FontEntry::CreateFontEntry(const gfxProxyFontEntry &aProxyEntry, @@ -509,9 +520,7 @@ FontEntry::CreateFontEntry(const gfxProxyFontEntry &aProxyEntry, HANDLE fontRef; nsAutoString uniqueName; - rv = gfxFontUtils::MakeUniqueUserFontName(uniqueName); - if (NS_FAILED(rv)) - return nsnull; + MakeUniqueFontName(uniqueName); if (isCFF) { // Postscript-style glyphs, swizzle name table, load directly diff --git a/layout/reftests/font-face/reftest.list b/layout/reftests/font-face/reftest.list index c79a41d6969..5066e243c6a 100644 --- a/layout/reftests/font-face/reftest.list +++ b/layout/reftests/font-face/reftest.list @@ -77,4 +77,3 @@ HTTP(..) == ex-unit-1.html ex-unit-1-ref.html HTTP(..) == ex-unit-1-dynamic.html ex-unit-1-ref.html fails-if(MOZ_WIDGET_TOOLKIT=="windows") == local-1.html local-1-ref.html # bug 468387 -fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == synthetic-weight-style.html synthetic-weight-style-ref.html # bug 468387, 480098 diff --git a/layout/reftests/font-face/synthetic-weight-style-ref.html b/layout/reftests/font-face/synthetic-weight-style-ref.html deleted file mode 100644 index af44b593f25..00000000000 --- a/layout/reftests/font-face/synthetic-weight-style-ref.html +++ /dev/null @@ -1,120 +0,0 @@ - - - -@font-face and synthetic rendering - - - - - - - - - -

Text below should appear in normal face with no synthetic bolding/italics

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100RegularItalicObliqueRegularItalicOblique
200RegularItalicObliqueRegularItalicOblique
300RegularItalicObliqueRegularItalicOblique
400RegularItalicObliqueRegularItalicOblique
500RegularItalicObliqueRegularItalicOblique
600RegularItalicObliqueRegularItalicOblique
700RegularItalicObliqueRegularItalicOblique
800RegularItalicObliqueRegularItalicOblique
900RegularItalicObliqueRegularItalicOblique
- - - \ No newline at end of file diff --git a/layout/reftests/font-face/synthetic-weight-style.html b/layout/reftests/font-face/synthetic-weight-style.html deleted file mode 100644 index 332e62eae3e..00000000000 --- a/layout/reftests/font-face/synthetic-weight-style.html +++ /dev/null @@ -1,165 +0,0 @@ - - - -@font-face and synthetic rendering - - - - - - - - - -

Text below should appear in normal face with no synthetic bolding/italics

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100RegularItalicObliqueRegularItalicOblique
200RegularItalicObliqueRegularItalicOblique
300RegularItalicObliqueRegularItalicOblique
400RegularItalicObliqueRegularItalicOblique
500RegularItalicObliqueRegularItalicOblique
600RegularItalicObliqueRegularItalicOblique
700RegularItalicObliqueRegularItalicOblique
800RegularItalicObliqueRegularItalicOblique
900RegularItalicObliqueRegularItalicOblique
- - - \ No newline at end of file