[OS/2] Bug 381330: improve handling of system fonts, automatically replace WarpSans by Workplace Sans if available. OK from wuno for code via testing and stevew for the documentation part.
Wed, 28 Nov 2007 13:46:10 -0800
changeset 8413 f7e30dbbb2703a26e93bb76e0886359fc03fba82
parent 8412 66ee2bd5a0a3fb6c0e095c398776045fd8ea6894
child 8414 53e67c46e59dab633a9d140e3dc9071cf1682737
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
[OS/2] Bug 381330: improve handling of system fonts, automatically replace WarpSans by Workplace Sans if available. OK from wuno for code via testing and stevew for the documentation part.
--- a/browser/locales/en-US/os2/README.txt
+++ b/browser/locales/en-US/os2/README.txt
@@ -200,10 +200,18 @@ Known Problems of the OS/2 version
 Cross-platform problems are usually listed in the release notes of each
 milestone release.
 - Firefox will beep when copying more than 64 kB of text to the clipboard.
   This is to alert users that many applications (most notably the system
   editor, EPM, and applications running in VIO windows) cannot paste more
   than this.
+- Firefox cannot make use of OS/2 fonts like WarpSans and others which
+  are not available in Type1 or TrueType format. It is therefore
+  recommended to install the "Workplace Sans" font from
+     http://www.cs-club.org/~alex/creative/fonts/
+  or
+     http://hobbes.nmsu.edu/cgi-bin/h-search?key=wpsu_ttf
+  which Firefox will use as a replacement of WarpSans.
 Other known problems can be found by following the link "Current Open Warpzilla
 Bugs" on the OS/2 Mozilla page <http://www.mozilla.org/ports/os2/>.
--- a/gfx/thebes/src/gfxOS2Fonts.cpp
+++ b/gfx/thebes/src/gfxOS2Fonts.cpp
@@ -307,16 +307,21 @@ cairo_font_face_t *gfxOS2Font::CairoFont
         FcPatternGetInteger(fcMatch, FC_SLANT, 0, &i2);
         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",
                NS_LossyConvertUTF16toASCII(mName).get(), mStyle.weight, mStyle.style, mStyle.size,
                (char *)str1, w1, i1, s1,
                (char *)str2, w2, i2, s2);
+        if (mName == NS_LITERAL_STRING("Workplace Sans") && fcW >= FC_WEIGHT_DEMIBOLD) {
+            // if we are dealing with Workplace Sans and want a bold font, we
+            // need to artificially embolden it (no bold counterpart yet)
+            FcPatternAddBool(fcMatch, FC_EMBOLDEN, FcTrue);
+        }
         // and ask cairo to return a font face for this
         mFontFace = cairo_ft_font_face_create_for_pattern(fcMatch);
     NS_ASSERTION(mFontFace, "Failed to make font face");
     return mFontFace;
@@ -385,35 +390,43 @@ gfxOS2FontGroup::gfxOS2FontGroup(const n
     : gfxFontGroup(aFamilies, aStyle)
 #ifdef DEBUG_thebes_2
     printf("gfxOS2FontGroup[%#x]::gfxOS2FontGroup(\"%s\", %#x)\n",
            (unsigned)this, NS_LossyConvertUTF16toASCII(aFamilies).get(),
+    // check for WarpSans and as we cannot display that (yet), replace
+    // it with Workplace Sans
+    int pos = 0;
+    if ((pos = mFamilies.Find("WarpSans", PR_FALSE, 0, -1)) > -1) {
+        mFamilies.Replace(pos, 8, NS_LITERAL_STRING("Workplace Sans"));
+    }
     nsStringArray familyArray;
     ForEachFont(FontCallback, &familyArray);
     FindGenericFontFromStyle(FontCallback, &familyArray);
     // To be able to easily search for glyphs in other fonts, append a few good
     // replacement candidates to the list. The best ones are the Unicode fonts that
     // are set up, and if the user was so clever to set up the User Defined fonts,
     // then these are probable candidates, too.
     nsString fontString;
     gfxPlatform::GetPlatform()->GetPrefFonts("x-unicode", fontString, PR_FALSE);
     ForEachFont(fontString, NS_LITERAL_CSTRING("x-unicode"), FontCallback, &familyArray);
     gfxPlatform::GetPlatform()->GetPrefFonts("x-user-def", fontString, PR_FALSE);
     ForEachFont(fontString, NS_LITERAL_CSTRING("x-user-def"), FontCallback, &familyArray);
+    // Should append some default font if there are no available fonts.
+    // Let's use Helv which should be available on any OS/2 system; if
+    // it's not there, Fontconfig replaces it with something else...
     if (familyArray.Count() == 0) {
-        // Should append default GUI font if there are no available fonts.
-        // We use WarpSans as in the default case in nsSystemFontsOS2.
-        familyArray.AppendString(NS_LITERAL_STRING("WarpSans"));
+        familyArray.AppendString(NS_LITERAL_STRING("Helv"));
     for (int i = 0; i < familyArray.Count(); i++) {
         mFonts.AppendElement(new gfxOS2Font(*familyArray[i], &mStyle));
     // just continue to append all fonts known to the system