Bumping manifests a=b2g-bump
[gecko.git] / gfx / thebes / gfxPangoFonts.h
blob8aacdbd1ac4f49ca97932305ca9b2733f97f4b79
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_PANGOFONTS_H
7 #define GFX_PANGOFONTS_H
9 #include "cairo.h"
10 #include "gfxTypes.h"
11 #include "gfxFont.h"
13 #include "nsAutoRef.h"
14 #include "nsTArray.h"
16 #include <pango/pango.h>
18 class gfxFcFontSet;
19 class gfxFcFont;
20 class gfxProxyFontEntry;
21 typedef struct _FcPattern FcPattern;
22 typedef struct FT_FaceRec_* FT_Face;
23 typedef struct FT_LibraryRec_ *FT_Library;
25 class gfxPangoFontGroup : public gfxFontGroup {
26 public:
27 gfxPangoFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
28 const gfxFontStyle *aStyle,
29 gfxUserFontSet *aUserFontSet);
30 virtual ~gfxPangoFontGroup();
32 virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
34 virtual gfxFont *GetFontAt(int32_t i);
36 virtual void UpdateFontList();
38 virtual already_AddRefed<gfxFont>
39 FindFontForChar(uint32_t aCh, uint32_t aPrevCh, int32_t aRunScript,
40 gfxFont *aPrevMatchedFont,
41 uint8_t *aMatchType);
43 static void Shutdown();
45 // Used for @font-face { src: local(); }
46 static gfxFontEntry *NewFontEntry(const gfxProxyFontEntry &aProxyEntry,
47 const nsAString &aFullname);
48 // Used for @font-face { src: url(); }
49 static gfxFontEntry *NewFontEntry(const gfxProxyFontEntry &aProxyEntry,
50 const uint8_t *aFontData,
51 uint32_t aLength);
53 private:
54 // @param aLang [in] language to use for pref fonts and system default font
55 // selection, or nullptr for the language guessed from the
56 // gfxFontStyle.
57 // The FontGroup holds a reference to this set.
58 gfxFcFontSet *GetFontSet(PangoLanguage *aLang = nullptr);
60 class FontSetByLangEntry {
61 public:
62 FontSetByLangEntry(PangoLanguage *aLang, gfxFcFontSet *aFontSet);
63 PangoLanguage *mLang;
64 nsRefPtr<gfxFcFontSet> mFontSet;
66 // There is only one of entry in this array unless characters from scripts
67 // of other languages are measured.
68 nsAutoTArray<FontSetByLangEntry,1> mFontSets;
70 gfxFloat mSizeAdjustFactor;
71 PangoLanguage *mPangoLanguage;
73 // @param aLang [in] language to use for pref fonts and system font
74 // resolution, or nullptr to guess a language from the gfxFontStyle.
75 // @param aMatchPattern [out] if non-nullptr, will return the pattern used.
76 already_AddRefed<gfxFcFontSet>
77 MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor,
78 nsAutoRef<FcPattern> *aMatchPattern = nullptr);
80 gfxFcFontSet *GetBaseFontSet();
81 gfxFcFont *GetBaseFont();
83 gfxFloat GetSizeAdjustFactor()
85 if (mFontSets.Length() == 0)
86 GetBaseFontSet();
87 return mSizeAdjustFactor;
90 virtual void FindPlatformFont(const nsAString& aName,
91 bool aUseFontSet,
92 void *aClosure);
94 friend class gfxSystemFcFontEntry;
95 static FT_Library GetFTLibrary();
98 #endif /* GFX_PANGOFONTS_H */