[Webkit-unassigned] [Bug 28131] [Haiku] Adding font-specific files to WebCore.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Aug 14 17:37:08 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=28131


Eric Seidel <eric at webkit.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #34556|review?                     |review-
               Flag|                            |




--- Comment #10 from Eric Seidel <eric at webkit.org>  2009-08-14 17:37:07 PDT ---
(From update of attachment 34556)
I would have put this in a static inline:

+    int32 numStyles = count_font_styles(family);
+    font_style fontStyle;
+    uint32 flags;
+
+    for (int i = 0; i < numStyles; i++) {
+        if (get_font_style(family, i, &fontStyle, &flags) == B_OK) {
+            String style(fontStyle);
+            if ((m_oblique && m_bold) && (style == "BoldItalic" || style ==
"Bold Oblique"))
+                 break;
+            if ((m_oblique && !m_bold) && (style == "Italic" || style ==
"Oblique"))
+                 break;
+            if ((!m_oblique && m_bold) && style == "Bold")
+                 break;
+            if ((!m_oblique && !m_bold) && (style == "Roma" || style == "Book"
+                || style == "Condensed" || style == "Regular" || style ==
"Medium"))
+                 break;
+            }
+        }

Something like findMatchingFontStyle(family, m_bold, m_oblique);


found is not used here:
+    if (BFont().SetFamilyAndStyle(BString(familyName.string()).String(), 0) ==
B_OK) {
+        strcpy(family, BString(familyName.string()).String());
+        found = true;
+    }
+
+    // If no font family is found for the given name, we use a generic font.
+    if (!found) {
+        int type = fontDescription.genericFamily();
+
+        if (BString(familyName.string()).FindFirst("Sans") != B_ERROR)
+            strcpy(family, "DejaVu Sans");
+        else if (BString(familyName.string()).FindFirst("Serif") != B_ERROR)
+            strcpy(family, "DejaVu Serif");
+        else if (BString(familyName.string()).FindFirst("Mono") != B_ERROR)
+            strcpy(family, "DejaVu Mono");
+        else // This is the fallback font.
+            strcpy(family, "DejaVu Sans");
+    }

Seems that should just be an else.

Again, I would have put the family lookup in a separate static inline.

font_family family = findMatchingFontFamily(familyName);

I think this could use on more round of cleanup.  In general, smaller functions
are better. :)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list