|
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/. */ |
|
5 |
|
6 #ifndef GFX_PANGOFONTS_H |
|
7 #define GFX_PANGOFONTS_H |
|
8 |
|
9 #include "cairo.h" |
|
10 #include "gfxTypes.h" |
|
11 #include "gfxFont.h" |
|
12 |
|
13 #include "nsAutoRef.h" |
|
14 #include "nsTArray.h" |
|
15 |
|
16 #include <pango/pango.h> |
|
17 |
|
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; |
|
24 |
|
25 class gfxPangoFontGroup : public gfxFontGroup { |
|
26 public: |
|
27 gfxPangoFontGroup (const nsAString& families, |
|
28 const gfxFontStyle *aStyle, |
|
29 gfxUserFontSet *aUserFontSet); |
|
30 virtual ~gfxPangoFontGroup (); |
|
31 |
|
32 virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle); |
|
33 |
|
34 virtual gfxFont *GetFontAt(int32_t i); |
|
35 |
|
36 virtual void UpdateFontList(); |
|
37 |
|
38 virtual already_AddRefed<gfxFont> |
|
39 FindFontForChar(uint32_t aCh, uint32_t aPrevCh, int32_t aRunScript, |
|
40 gfxFont *aPrevMatchedFont, |
|
41 uint8_t *aMatchType); |
|
42 |
|
43 static void Shutdown(); |
|
44 |
|
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); |
|
52 |
|
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); |
|
59 |
|
60 class FontSetByLangEntry { |
|
61 public: |
|
62 FontSetByLangEntry(PangoLanguage *aLang, gfxFcFontSet *aFontSet); |
|
63 PangoLanguage *mLang; |
|
64 nsRefPtr<gfxFcFontSet> mFontSet; |
|
65 }; |
|
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; |
|
69 |
|
70 gfxFloat mSizeAdjustFactor; |
|
71 PangoLanguage *mPangoLanguage; |
|
72 |
|
73 void GetFcFamilies(nsTArray<nsString> *aFcFamilyList, |
|
74 nsIAtom *aLanguage); |
|
75 |
|
76 // @param aLang [in] language to use for pref fonts and system font |
|
77 // resolution, or nullptr to guess a language from the gfxFontStyle. |
|
78 // @param aMatchPattern [out] if non-nullptr, will return the pattern used. |
|
79 already_AddRefed<gfxFcFontSet> |
|
80 MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor, |
|
81 nsAutoRef<FcPattern> *aMatchPattern = nullptr); |
|
82 |
|
83 gfxFcFontSet *GetBaseFontSet(); |
|
84 gfxFcFont *GetBaseFont(); |
|
85 |
|
86 gfxFloat GetSizeAdjustFactor() |
|
87 { |
|
88 if (mFontSets.Length() == 0) |
|
89 GetBaseFontSet(); |
|
90 return mSizeAdjustFactor; |
|
91 } |
|
92 |
|
93 friend class gfxSystemFcFontEntry; |
|
94 static FT_Library GetFTLibrary(); |
|
95 }; |
|
96 |
|
97 #endif /* GFX_PANGOFONTS_H */ |