Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 nsAString& families,
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;
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;
70 gfxFloat mSizeAdjustFactor;
71 PangoLanguage *mPangoLanguage;
73 void GetFcFamilies(nsTArray<nsString> *aFcFamilyList,
74 nsIAtom *aLanguage);
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);
83 gfxFcFontSet *GetBaseFontSet();
84 gfxFcFont *GetBaseFont();
86 gfxFloat GetSizeAdjustFactor()
87 {
88 if (mFontSets.Length() == 0)
89 GetBaseFontSet();
90 return mSizeAdjustFactor;
91 }
93 friend class gfxSystemFcFontEntry;
94 static FT_Library GetFTLibrary();
95 };
97 #endif /* GFX_PANGOFONTS_H */