| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
| 14 * its contributors may be used to endorse or promote products derived | |
| 15 * from this software without specific prior written permission. | |
| 16 * | |
| 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
| 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
| 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 27 */ | |
| 28 | |
| 29 #ifndef FontCache_h | |
| 30 #define FontCache_h | |
| 31 | |
| 32 #include <limits.h> | |
| 33 #include <wtf/Vector.h> | |
| 34 #include <unicode/uscript.h> | |
| 35 #include <wtf/unicode/Unicode.h> | |
| 36 | |
| 37 #if PLATFORM(WIN) | |
| 38 #include <objidl.h> | |
| 39 #include <mlang.h> | |
| 40 #endif | |
| 41 | |
| 42 namespace WebCore | |
| 43 { | |
| 44 | |
| 45 class AtomicString; | |
| 46 class Font; | |
| 47 class FontPlatformData; | |
| 48 class FontData; | |
| 49 class FontDescription; | |
| 50 class FontSelector; | |
| 51 class SimpleFontData; | |
| 52 | |
| 53 class FontCache { | |
| 54 public: | |
| 55 static const FontData* getFontData(const Font&, int& familyIndex, FontSelect
or*); | |
| 56 static void releaseFontData(const SimpleFontData*); | |
| 57 | |
| 58 // This method is implemented by the platform. | |
| 59 // FIXME: Font data returned by this method never go inactive because caller
s don't track and release them. | |
| 60 static const SimpleFontData* getFontDataForCharacters(const Font&, const UCh
ar* characters, int length); | |
| 61 | |
| 62 // Also implemented by the platform. | |
| 63 static void platformInit(); | |
| 64 | |
| 65 #if PLATFORM(WIN) | |
| 66 static IMLangFontLink2* getFontLinkInterface(); | |
| 67 #endif | |
| 68 | |
| 69 static void getTraitsInFamily(const AtomicString&, Vector<unsigned>&); | |
| 70 | |
| 71 static FontPlatformData* getCachedFontPlatformData(const FontDescription&, c
onst AtomicString& family, bool checkingAlternateName = false); | |
| 72 static SimpleFontData* getCachedFontData(const FontPlatformData*); | |
| 73 static FontPlatformData* getLastResortFallbackFont(const FontDescription&); | |
| 74 | |
| 75 bool fontExists(const FontDescription&, const AtomicString& family); | |
| 76 | |
| 77 // TODO(jungshik): Is this the best place to put this function? It may | |
| 78 // or may not be. Font.h is another place we can cosider. | |
| 79 // Return a font family for |script| and |FontDescription.genericFamily()|. | |
| 80 // It will return an empty atom if we can't find a font matching | |
| 81 // script and genericFamily in FontDescription. A caller should check | |
| 82 // the emptyness before using it. | |
| 83 static AtomicString getGenericFontForScript(UScriptCode script, const FontDe
scription&); | |
| 84 static void addClient(FontSelector*); | |
| 85 static void removeClient(FontSelector*); | |
| 86 | |
| 87 static unsigned generation(); | |
| 88 static void invalidate(); | |
| 89 | |
| 90 static size_t fontDataCount(); | |
| 91 static size_t inactiveFontDataCount(); | |
| 92 static void purgeInactiveFontData(int count = INT_MAX); | |
| 93 | |
| 94 private: | |
| 95 // These methods are implemented by each platform. | |
| 96 static FontPlatformData* getSimilarFontPlatformData(const Font&); | |
| 97 static FontPlatformData* createFontPlatformData(const FontDescription&, cons
t AtomicString& family); | |
| 98 static const AtomicString& alternateFamilyName(const AtomicString& family); | |
| 99 | |
| 100 friend class SimpleFontData; | |
| 101 friend class FontFallbackList; | |
| 102 }; | |
| 103 | |
| 104 } | |
| 105 | |
| 106 #endif | |
| OLD | NEW |