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/. */
9 #include "mozilla/MemoryReporting.h"
13 #include "gfxFT2FontBase.h"
14 #include "gfxContext.h"
15 #include "gfxFontUtils.h"
16 #include "gfxUserFontSet.h"
20 class gfxFT2Font
: public gfxFT2FontBase
{
21 public: // new functions
22 gfxFT2Font(cairo_scaled_font_t
*aCairoFont
,
23 FT2FontEntry
*aFontEntry
,
24 const gfxFontStyle
*aFontStyle
,
26 virtual ~gfxFT2Font ();
28 FT2FontEntry
*GetFontEntry();
30 static already_AddRefed
<gfxFT2Font
>
31 GetOrMakeFont(const nsAString
& aName
, const gfxFontStyle
*aStyle
,
32 bool aNeedsBold
= false);
34 static already_AddRefed
<gfxFT2Font
>
35 GetOrMakeFont(FT2FontEntry
*aFontEntry
, const gfxFontStyle
*aStyle
,
36 bool aNeedsBold
= false);
38 struct CachedGlyphData
{
40 : glyphIndex(0xffffffffU
) { }
42 CachedGlyphData(uint32_t gid
)
51 const CachedGlyphData
* GetGlyphDataForChar(uint32_t ch
) {
52 CharGlyphMapEntryType
*entry
= mCharGlyphCache
.PutEntry(ch
);
57 if (entry
->mData
.glyphIndex
== 0xffffffffU
) {
58 // this is a new entry, fill it
59 FillGlyphDataForChar(ch
, &entry
->mData
);
65 virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf
,
66 FontCacheSizes
* aSizes
) const;
67 virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
,
68 FontCacheSizes
* aSizes
) const;
71 virtual mozilla::TemporaryRef
<mozilla::gfx::GlyphRenderingOptions
> GetGlyphRenderingOptions();
75 virtual bool ShapeText(gfxContext
*aContext
,
76 const char16_t
*aText
,
80 gfxShapedText
*aShapedText
);
82 void FillGlyphDataForChar(uint32_t ch
, CachedGlyphData
*gd
);
84 void AddRange(const char16_t
*aText
,
87 gfxShapedText
*aShapedText
);
89 typedef nsBaseHashtableET
<nsUint32HashKey
, CachedGlyphData
> CharGlyphMapEntryType
;
90 typedef nsTHashtable
<CharGlyphMapEntryType
> CharGlyphMap
;
91 CharGlyphMap mCharGlyphCache
;
94 #endif /* GFX_FT2FONTS_H */