gfx/thebes/gfxPangoFonts.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/thebes/gfxPangoFonts.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef GFX_PANGOFONTS_H
    1.10 +#define GFX_PANGOFONTS_H
    1.11 +
    1.12 +#include "cairo.h"
    1.13 +#include "gfxTypes.h"
    1.14 +#include "gfxFont.h"
    1.15 +
    1.16 +#include "nsAutoRef.h"
    1.17 +#include "nsTArray.h"
    1.18 +
    1.19 +#include <pango/pango.h>
    1.20 +
    1.21 +class gfxFcFontSet;
    1.22 +class gfxFcFont;
    1.23 +class gfxProxyFontEntry;
    1.24 +typedef struct _FcPattern FcPattern;
    1.25 +typedef struct FT_FaceRec_* FT_Face;
    1.26 +typedef struct FT_LibraryRec_  *FT_Library;
    1.27 +
    1.28 +class gfxPangoFontGroup : public gfxFontGroup {
    1.29 +public:
    1.30 +    gfxPangoFontGroup (const nsAString& families,
    1.31 +                       const gfxFontStyle *aStyle,
    1.32 +                       gfxUserFontSet *aUserFontSet);
    1.33 +    virtual ~gfxPangoFontGroup ();
    1.34 +
    1.35 +    virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
    1.36 +
    1.37 +    virtual gfxFont *GetFontAt(int32_t i);
    1.38 +
    1.39 +    virtual void UpdateFontList();
    1.40 +
    1.41 +    virtual already_AddRefed<gfxFont>
    1.42 +        FindFontForChar(uint32_t aCh, uint32_t aPrevCh, int32_t aRunScript,
    1.43 +                        gfxFont *aPrevMatchedFont,
    1.44 +                        uint8_t *aMatchType);
    1.45 +
    1.46 +    static void Shutdown();
    1.47 +
    1.48 +    // Used for @font-face { src: local(); }
    1.49 +    static gfxFontEntry *NewFontEntry(const gfxProxyFontEntry &aProxyEntry,
    1.50 +                                      const nsAString &aFullname);
    1.51 +    // Used for @font-face { src: url(); }
    1.52 +    static gfxFontEntry *NewFontEntry(const gfxProxyFontEntry &aProxyEntry,
    1.53 +                                      const uint8_t *aFontData,
    1.54 +                                      uint32_t aLength);
    1.55 +
    1.56 +private:
    1.57 +    // @param aLang [in] language to use for pref fonts and system default font
    1.58 +    //        selection, or nullptr for the language guessed from the
    1.59 +    //        gfxFontStyle.
    1.60 +    // The FontGroup holds a reference to this set.
    1.61 +    gfxFcFontSet *GetFontSet(PangoLanguage *aLang = nullptr);
    1.62 +
    1.63 +    class FontSetByLangEntry {
    1.64 +    public:
    1.65 +        FontSetByLangEntry(PangoLanguage *aLang, gfxFcFontSet *aFontSet);
    1.66 +        PangoLanguage *mLang;
    1.67 +        nsRefPtr<gfxFcFontSet> mFontSet;
    1.68 +    };
    1.69 +    // There is only one of entry in this array unless characters from scripts
    1.70 +    // of other languages are measured.
    1.71 +    nsAutoTArray<FontSetByLangEntry,1> mFontSets;
    1.72 +
    1.73 +    gfxFloat mSizeAdjustFactor;
    1.74 +    PangoLanguage *mPangoLanguage;
    1.75 +
    1.76 +    void GetFcFamilies(nsTArray<nsString> *aFcFamilyList,
    1.77 +                       nsIAtom *aLanguage);
    1.78 +
    1.79 +    // @param aLang [in] language to use for pref fonts and system font
    1.80 +    //        resolution, or nullptr to guess a language from the gfxFontStyle.
    1.81 +    // @param aMatchPattern [out] if non-nullptr, will return the pattern used.
    1.82 +    already_AddRefed<gfxFcFontSet>
    1.83 +    MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor,
    1.84 +                nsAutoRef<FcPattern> *aMatchPattern = nullptr);
    1.85 +
    1.86 +    gfxFcFontSet *GetBaseFontSet();
    1.87 +    gfxFcFont *GetBaseFont();
    1.88 +
    1.89 +    gfxFloat GetSizeAdjustFactor()
    1.90 +    {
    1.91 +        if (mFontSets.Length() == 0)
    1.92 +            GetBaseFontSet();
    1.93 +        return mSizeAdjustFactor;
    1.94 +    }
    1.95 +
    1.96 +    friend class gfxSystemFcFontEntry;
    1.97 +    static FT_Library GetFTLibrary();
    1.98 +};
    1.99 +
   1.100 +#endif /* GFX_PANGOFONTS_H */

mercurial