michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_PANGOFONTS_H michael@0: #define GFX_PANGOFONTS_H michael@0: michael@0: #include "cairo.h" michael@0: #include "gfxTypes.h" michael@0: #include "gfxFont.h" michael@0: michael@0: #include "nsAutoRef.h" michael@0: #include "nsTArray.h" michael@0: michael@0: #include michael@0: michael@0: class gfxFcFontSet; michael@0: class gfxFcFont; michael@0: class gfxProxyFontEntry; michael@0: typedef struct _FcPattern FcPattern; michael@0: typedef struct FT_FaceRec_* FT_Face; michael@0: typedef struct FT_LibraryRec_ *FT_Library; michael@0: michael@0: class gfxPangoFontGroup : public gfxFontGroup { michael@0: public: michael@0: gfxPangoFontGroup (const nsAString& families, michael@0: const gfxFontStyle *aStyle, michael@0: gfxUserFontSet *aUserFontSet); michael@0: virtual ~gfxPangoFontGroup (); michael@0: michael@0: virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle); michael@0: michael@0: virtual gfxFont *GetFontAt(int32_t i); michael@0: michael@0: virtual void UpdateFontList(); michael@0: michael@0: virtual already_AddRefed michael@0: FindFontForChar(uint32_t aCh, uint32_t aPrevCh, int32_t aRunScript, michael@0: gfxFont *aPrevMatchedFont, michael@0: uint8_t *aMatchType); michael@0: michael@0: static void Shutdown(); michael@0: michael@0: // Used for @font-face { src: local(); } michael@0: static gfxFontEntry *NewFontEntry(const gfxProxyFontEntry &aProxyEntry, michael@0: const nsAString &aFullname); michael@0: // Used for @font-face { src: url(); } michael@0: static gfxFontEntry *NewFontEntry(const gfxProxyFontEntry &aProxyEntry, michael@0: const uint8_t *aFontData, michael@0: uint32_t aLength); michael@0: michael@0: private: michael@0: // @param aLang [in] language to use for pref fonts and system default font michael@0: // selection, or nullptr for the language guessed from the michael@0: // gfxFontStyle. michael@0: // The FontGroup holds a reference to this set. michael@0: gfxFcFontSet *GetFontSet(PangoLanguage *aLang = nullptr); michael@0: michael@0: class FontSetByLangEntry { michael@0: public: michael@0: FontSetByLangEntry(PangoLanguage *aLang, gfxFcFontSet *aFontSet); michael@0: PangoLanguage *mLang; michael@0: nsRefPtr mFontSet; michael@0: }; michael@0: // There is only one of entry in this array unless characters from scripts michael@0: // of other languages are measured. michael@0: nsAutoTArray mFontSets; michael@0: michael@0: gfxFloat mSizeAdjustFactor; michael@0: PangoLanguage *mPangoLanguage; michael@0: michael@0: void GetFcFamilies(nsTArray *aFcFamilyList, michael@0: nsIAtom *aLanguage); michael@0: michael@0: // @param aLang [in] language to use for pref fonts and system font michael@0: // resolution, or nullptr to guess a language from the gfxFontStyle. michael@0: // @param aMatchPattern [out] if non-nullptr, will return the pattern used. michael@0: already_AddRefed michael@0: MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor, michael@0: nsAutoRef *aMatchPattern = nullptr); michael@0: michael@0: gfxFcFontSet *GetBaseFontSet(); michael@0: gfxFcFont *GetBaseFont(); michael@0: michael@0: gfxFloat GetSizeAdjustFactor() michael@0: { michael@0: if (mFontSets.Length() == 0) michael@0: GetBaseFontSet(); michael@0: return mSizeAdjustFactor; michael@0: } michael@0: michael@0: friend class gfxSystemFcFontEntry; michael@0: static FT_Library GetFTLibrary(); michael@0: }; michael@0: michael@0: #endif /* GFX_PANGOFONTS_H */