Changeset 100601 in webkit
- Timestamp:
- Nov 17, 2011 4:16:57 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r100597 r100601 1 2011-11-17 Kenichi Ishibashi <bashi@chromium.org> 2 3 [chromium] don't call fontconfig twice in complex text path 4 https://bugs.webkit.org/show_bug.cgi?id=38701 5 6 Adds a new API for getting font family. For now, FontCacheLinux calls the new API, but don't use additional properties for compatibility. The old API will be removed when Chromium is ready to use new API. 7 8 Reviewed by Tony Chang. 9 10 No new tests. No behavior changes for now. 11 12 * platform/chromium/PlatformSupport.h: Added FontFamily struct and changed the declaration of getFontFamilyForCharacters(). 13 * platform/graphics/chromium/FontCacheLinux.cpp: 14 (WebCore::FontCache::getFontDataForCharacters): Uses new PlatformSupport::getFontFamilyForCharacters(). 15 * platform/graphics/chromium/FontPlatformDataLinux.h: 16 (WebCore::FontPlatformData::setFakeBold): Added. 17 (WebCore::FontPlatformData::setFakeItalic): Added. 18 1 19 2011-11-17 Mario Sanchez Prada <msanchez@igalia.com> 2 20 -
trunk/Source/WebCore/platform/chromium/PlatformSupport.h
r100495 r100601 153 153 #elif OS(UNIX) 154 154 static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result); 155 static String getFontFamilyForCharacters(const UChar*, size_t numCharacters, const char* preferredLocale); 155 struct FontFamily { 156 String name; 157 bool isBold; 158 bool isItalic; 159 }; 160 static void getFontFamilyForCharacters(const UChar*, size_t numCharacters, const char* preferredLocale, FontFamily*); 156 161 #endif 157 162 -
trunk/Source/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
r100070 r100601 60 60 { 61 61 icu::Locale locale = icu::Locale::getDefault(); 62 String family = PlatformSupport::getFontFamilyForCharacters(characters, length, locale.getLanguage()); 63 if (family.isEmpty()) 62 PlatformSupport::FontFamily family; 63 PlatformSupport::getFontFamilyForCharacters(characters, length, locale.getLanguage(), &family); 64 if (family.name.isEmpty()) 64 65 return 0; 65 66 66 AtomicString atomicFamily(family); 67 AtomicString atomicFamily(family.name); 68 // FIXME: Remove this #if after API transition complete. 69 #if 0 70 // Changes weight and/or italic of given FontDescription depends on 71 // the result of fontconfig so that keeping the correct font mapping 72 // of the given characters. See http://crbug.com/32109 for details. 73 bool shouldSetFakeBold = false; 74 bool shouldSetFakeItalic = false; 75 FontDescription description(font.fontDescription()); 76 if (family.isBold && description.weight() < FontWeightBold) 77 description.setWeight(FontWeightBold); 78 if (!family.isBold && description.weight() >= FontWeightBold) { 79 shouldSetFakeBold = true; 80 description.setWeight(FontWeightNormal); 81 } 82 if (family.isItalic && description.italic() == FontItalicOff) 83 description.setItalic(FontItalicOn); 84 if (!family.isItalic && description.italic() == FontItalicOn) { 85 shouldSetFakeItalic = true; 86 description.setItalic(FontItalicOff); 87 } 88 89 FontPlatformData platformData = FontPlatformData(*getCachedFontPlatformData(description, atomicFamily, DoNotRetain)); 90 platformData.setFakeBold(shouldSetFakeBold); 91 platformData.setFakeItalic(shouldSetFakeItalic); 92 return getCachedFontData(&platformData, DoNotRetain); 93 #else 67 94 return getCachedFontData(getCachedFontPlatformData(font.fontDescription(), atomicFamily, DoNotRetain), DoNotRetain); 95 #endif 68 96 } 69 97 -
trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
r95901 r100601 119 119 FontOrientation orientation() const { return m_orientation; } 120 120 void setOrientation(FontOrientation orientation) { m_orientation = orientation; } 121 121 void setFakeBold(bool fakeBold) { m_fakeBold = fakeBold; } 122 void setFakeItalic(bool fakeItalic) { m_fakeItalic = fakeItalic; } 122 123 bool operator==(const FontPlatformData&) const; 123 124 FontPlatformData& operator=(const FontPlatformData&); -
trunk/Source/WebKit/chromium/ChangeLog
r100582 r100601 1 2011-11-17 Kenichi Ishibashi <bashi@chromium.org> 2 3 [chromium] don't call fontconfig twice in complex text path 4 https://bugs.webkit.org/show_bug.cgi?id=38701 5 6 Reviewed by Tony Chang. 7 8 Add new API for getFamilyForChars() so that keeping correct font mapping of the given characters. 9 10 * public/linux/WebFontFamily.h: Added. 11 * public/linux/WebFontInfo.h: Add a new API. 12 * public/linux/WebSandboxSupport.h: 13 (WebKit::WebSandboxSupport::getFontFamilyForCharacters): Ditto. 14 * src/PlatformSupport.cpp: 15 (WebCore::PlatformSupport::getFontFamilyForCharacters): Ditto. 16 * src/linux/WebFontInfo.cpp: 17 (WebKit::WebFontInfo::familyForChars): Modified to get weight and italic properties of the font. Old API uses new API internally. 18 1 19 2011-11-17 Adam Barth <abarth@webkit.org> 2 20 -
trunk/Source/WebKit/chromium/public/linux/WebFontFamily.h
r100600 r100601 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 */ 30 30 31 #ifndef Web SandboxSupport_h32 #define Web SandboxSupport_h31 #ifndef WebFontFamily_h 32 #define WebFontFamily_h 33 33 34 #include "../WebCString.h" 34 35 #include "../WebCommon.h" 35 #include "../WebString.h"36 36 37 37 namespace WebKit { 38 38 39 struct WebFontRenderStyle; 40 41 // Put methods here that are required due to sandbox restrictions. 42 class WebSandboxSupport { 43 public: 44 // Fonts --------------------------------------------------------------- 45 46 // Get a font family which contains glyphs for the given Unicode 47 // code-points. 48 // characters: a UTF-16 encoded string 49 // numCharacters: the number of 16-bit words in |characters| 50 // preferredLocale: preferred locale identifier for the |characters| 51 // (e.g. "en", "ja", "zh-CN") 52 // 53 // Returns a string with the font family on an empty string if the 54 // request cannot be satisfied. 55 virtual WebString getFontFamilyForCharacters(const WebUChar* characters, size_t numCharacters, const char* preferredLocale) = 0; 56 virtual void getRenderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* style) = 0; 39 struct WebFontFamily { 40 WebCString name; 41 bool isBold; 42 bool isItalic; 57 43 }; 58 44 59 45 } // namespace WebKit 60 46 61 #endif 47 #endif // WebFontFamily_h -
trunk/Source/WebKit/chromium/public/linux/WebFontInfo.h
r96233 r100601 33 33 34 34 #include "../WebCString.h" 35 #include "../linux/WebFontFamily.h" 35 36 #include "../linux/WebFontRenderStyle.h" 36 37 … … 51 52 // Returns: the font family or an empty string if the request could not be 52 53 // satisfied. 54 // FIXME: Depreciated API. Remove later. 53 55 WEBKIT_EXPORT static WebCString familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale); 56 // Returns: the font family instance. The instance has an empty font name if the request could not be satisfied. 57 WEBKIT_EXPORT static void familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale, WebFontFamily*); 54 58 55 59 // Fill out the given WebFontRenderStyle with the user's preferences for -
trunk/Source/WebKit/chromium/public/linux/WebSandboxSupport.h
r95901 r100601 34 34 #include "../WebCommon.h" 35 35 #include "../WebString.h" 36 #include "WebFontFamily.h" 36 37 37 38 namespace WebKit { … … 53 54 // Returns a string with the font family on an empty string if the 54 55 // request cannot be satisfied. 55 virtual WebString getFontFamilyForCharacters(const WebUChar* characters, size_t numCharacters, const char* preferredLocale) = 0; 56 // FIXME: Depreciated API. Remove later. 57 virtual WebString getFontFamilyForCharacters(const WebUChar* characters, size_t numCharacters, const char* preferredLocale) { return WebString(); } 58 // Returns a WebFontFamily instance with the font name. The instance has empty font name if the request cannot be satisfied. 59 // FIXME: Make this to be a pure virtual function after transition. 60 virtual void getFontFamilyForCharacters(const WebUChar* characters, size_t numCharacters, const char* preferredLocale, WebFontFamily* family) 61 { 62 family->name = getFontFamilyForCharacters(characters, numCharacters, preferredLocale).utf8(); 63 } 64 56 65 virtual void getRenderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* style) = 0; 57 66 }; -
trunk/Source/WebKit/chromium/src/PlatformSupport.cpp
r100495 r100601 438 438 } 439 439 #elif OS(UNIX) 440 String PlatformSupport::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale)440 void PlatformSupport::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, FontFamily* family) 441 441 { 442 442 #if OS(ANDROID) 443 443 // FIXME: We do not use fontconfig on Android, so use simple logic for now. 444 444 // https://bugs.webkit.org/show_bug.cgi?id=67587 445 return WebString("Arial"); 445 family->name = "Arial"; 446 family->isBold = false; 447 family->isItalic = false; 446 448 #else 449 WebFontFamily webFamily; 447 450 if (webKitPlatformSupport()->sandboxSupport()) 448 return webKitPlatformSupport()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters, preferredLocale); 449 450 WebCString family = WebFontInfo::familyForChars(characters, numCharacters, preferredLocale); 451 if (family.data()) 452 return WebString::fromUTF8(family.data()); 453 454 return WebString(); 451 webKitPlatformSupport()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters, preferredLocale, &webFamily); 452 else 453 WebFontInfo::familyForChars(characters, numCharacters, preferredLocale, &webFamily); 454 family->name = String::fromUTF8(webFamily.name.data(), webFamily.name.length()); 455 family->isBold = webFamily.isBold; 456 family->isItalic = webFamily.isItalic; 455 457 #endif 456 458 } -
trunk/Source/WebKit/chromium/src/linux/WebFontInfo.cpp
r96660 r100601 32 32 #include "WebFontInfo.h" 33 33 34 #include "WebFontFamily.h" 34 35 #include "WebFontRenderStyle.h" 35 36 … … 40 41 namespace WebKit { 41 42 43 // FIXME: Depreciated API. Remove later. 42 44 WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale) 45 { 46 WebFontFamily family; 47 familyForChars(characters, numCharacters, preferredLocale, &family); 48 return family.name; 49 } 50 51 void WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale, WebFontFamily* family) 43 52 { 44 53 FcCharSet* cset = FcCharSetCreate(); … … 79 88 FcCharSetDestroy(cset); 80 89 81 if (!fontSet) 82 return WebCString(); 83 90 if (!fontSet) { 91 family->name = WebCString(); 92 family->isBold = false; 93 family->isItalic = false; 94 return; 95 } 84 96 // Older versions of fontconfig have a bug where they cannot select 85 97 // only scalable fonts so we have to manually filter the results. … … 100 112 continue; 101 113 102 FcChar8* family; 103 WebCString result; 104 if (FcPatternGetString(current, FC_FAMILY, 0, &family) == FcResultMatch) { 105 const char* charFamily = reinterpret_cast<char*>(family); 106 result = WebCString(charFamily, strlen(charFamily)); 114 FcChar8* familyName; 115 if (FcPatternGetString(current, FC_FAMILY, 0, &familyName) == FcResultMatch) { 116 const char* charFamily = reinterpret_cast<char*>(familyName); 117 family->name = WebCString(charFamily, strlen(charFamily)); 107 118 } 119 int weight; 120 if (FcPatternGetInteger(current, FC_WEIGHT, 0, &weight) == FcResultMatch) 121 family->isBold = weight >= FC_WEIGHT_BOLD; 122 else 123 family->isBold = false; 124 int slant; 125 if (FcPatternGetInteger(current, FC_SLANT, 0, &slant) == FcResultMatch) 126 family->isItalic = slant != FC_SLANT_ROMAN; 127 else 128 family->isItalic = false; 108 129 FcFontSetDestroy(fontSet); 109 return result;130 return; 110 131 } 111 132 112 133 FcFontSetDestroy(fontSet); 113 return WebCString();114 134 } 115 135
Note: See TracChangeset
for help on using the changeset viewer.