1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxFT2Fonts.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,134 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_FT2FONTS_H 1.10 +#define GFX_FT2FONTS_H 1.11 + 1.12 +#include "mozilla/MemoryReporting.h" 1.13 +#include "cairo.h" 1.14 +#include "gfxTypes.h" 1.15 +#include "gfxFont.h" 1.16 +#include "gfxFT2FontBase.h" 1.17 +#include "gfxContext.h" 1.18 +#include "gfxFontUtils.h" 1.19 +#include "gfxUserFontSet.h" 1.20 + 1.21 +class FT2FontEntry; 1.22 + 1.23 +class gfxFT2Font : public gfxFT2FontBase { 1.24 +public: // new functions 1.25 + gfxFT2Font(cairo_scaled_font_t *aCairoFont, 1.26 + FT2FontEntry *aFontEntry, 1.27 + const gfxFontStyle *aFontStyle, 1.28 + bool aNeedsBold); 1.29 + virtual ~gfxFT2Font (); 1.30 + 1.31 + FT2FontEntry *GetFontEntry(); 1.32 + 1.33 + static already_AddRefed<gfxFT2Font> 1.34 + GetOrMakeFont(const nsAString& aName, const gfxFontStyle *aStyle, 1.35 + bool aNeedsBold = false); 1.36 + 1.37 + static already_AddRefed<gfxFT2Font> 1.38 + GetOrMakeFont(FT2FontEntry *aFontEntry, const gfxFontStyle *aStyle, 1.39 + bool aNeedsBold = false); 1.40 + 1.41 + struct CachedGlyphData { 1.42 + CachedGlyphData() 1.43 + : glyphIndex(0xffffffffU) { } 1.44 + 1.45 + CachedGlyphData(uint32_t gid) 1.46 + : glyphIndex(gid) { } 1.47 + 1.48 + uint32_t glyphIndex; 1.49 + int32_t lsbDelta; 1.50 + int32_t rsbDelta; 1.51 + int32_t xAdvance; 1.52 + }; 1.53 + 1.54 + const CachedGlyphData* GetGlyphDataForChar(uint32_t ch) { 1.55 + CharGlyphMapEntryType *entry = mCharGlyphCache.PutEntry(ch); 1.56 + 1.57 + if (!entry) 1.58 + return nullptr; 1.59 + 1.60 + if (entry->mData.glyphIndex == 0xffffffffU) { 1.61 + // this is a new entry, fill it 1.62 + FillGlyphDataForChar(ch, &entry->mData); 1.63 + } 1.64 + 1.65 + return &entry->mData; 1.66 + } 1.67 + 1.68 + virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.69 + FontCacheSizes* aSizes) const; 1.70 + virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, 1.71 + FontCacheSizes* aSizes) const; 1.72 + 1.73 +#ifdef USE_SKIA 1.74 + virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions(); 1.75 +#endif 1.76 + 1.77 +protected: 1.78 + virtual bool ShapeText(gfxContext *aContext, 1.79 + const char16_t *aText, 1.80 + uint32_t aOffset, 1.81 + uint32_t aLength, 1.82 + int32_t aScript, 1.83 + gfxShapedText *aShapedText, 1.84 + bool aPreferPlatformShaping); 1.85 + 1.86 + void FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd); 1.87 + 1.88 + void AddRange(const char16_t *aText, 1.89 + uint32_t aOffset, 1.90 + uint32_t aLength, 1.91 + gfxShapedText *aShapedText); 1.92 + 1.93 + typedef nsBaseHashtableET<nsUint32HashKey, CachedGlyphData> CharGlyphMapEntryType; 1.94 + typedef nsTHashtable<CharGlyphMapEntryType> CharGlyphMap; 1.95 + CharGlyphMap mCharGlyphCache; 1.96 +}; 1.97 + 1.98 +#ifndef ANDROID // not needed on Android, uses the standard gfxFontGroup directly 1.99 +class gfxFT2FontGroup : public gfxFontGroup { 1.100 +public: // new functions 1.101 + gfxFT2FontGroup (const nsAString& families, 1.102 + const gfxFontStyle *aStyle, 1.103 + gfxUserFontSet *aUserFontSet); 1.104 + virtual ~gfxFT2FontGroup (); 1.105 + 1.106 +protected: // from gfxFontGroup 1.107 + 1.108 + virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle); 1.109 + 1.110 + 1.111 +protected: // new functions 1.112 + 1.113 + static bool FontCallback (const nsAString & fontName, 1.114 + const nsACString & genericName, 1.115 + bool aUseFontSet, 1.116 + void *closure); 1.117 + bool mEnableKerning; 1.118 + 1.119 + void GetPrefFonts(nsIAtom *aLangGroup, 1.120 + nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList); 1.121 + void GetCJKPrefFonts(nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList); 1.122 + void FamilyListToArrayList(const nsString& aFamilies, 1.123 + nsIAtom *aLangGroup, 1.124 + nsTArray<nsRefPtr<gfxFontEntry> > *aFontEntryList); 1.125 + already_AddRefed<gfxFT2Font> WhichFontSupportsChar(const nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList, 1.126 + uint32_t aCh); 1.127 + already_AddRefed<gfxFont> WhichPrefFontSupportsChar(uint32_t aCh); 1.128 + already_AddRefed<gfxFont> 1.129 + WhichSystemFontSupportsChar(uint32_t aCh, int32_t aRunScript); 1.130 + 1.131 + nsTArray<gfxTextRange> mRanges; 1.132 + nsString mString; 1.133 +}; 1.134 +#endif // !ANDROID 1.135 + 1.136 +#endif /* GFX_FT2FONTS_H */ 1.137 +