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
13 #include "nsAutoRef.h"
16 #include <pango/pango.h>
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
{
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
,
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
,
54 // @param aLang [in] language to use for pref fonts and system default font
55 // selection, or nullptr for the language guessed from the
57 // The FontGroup holds a reference to this set.
58 gfxFcFontSet
*GetFontSet(PangoLanguage
*aLang
= nullptr);
60 class FontSetByLangEntry
{
62 FontSetByLangEntry(PangoLanguage
*aLang
, gfxFcFontSet
*aFontSet
);
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)
87 return mSizeAdjustFactor
;
90 virtual void FindPlatformFont(const nsAString
& aName
,
94 friend class gfxSystemFcFontEntry
;
95 static FT_Library
GetFTLibrary();
98 #endif /* GFX_PANGOFONTS_H */