2008-08-07 00:48:55 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2009-10-31 02:13:41 +03:00
|
|
|
#ifndef GFX_FT2FONTS_H
|
|
|
|
#define GFX_FT2FONTS_H
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2008-08-07 00:48:55 +04:00
|
|
|
#include "cairo.h"
|
|
|
|
#include "gfxTypes.h"
|
|
|
|
#include "gfxFont.h"
|
2009-10-31 02:13:41 +03:00
|
|
|
#include "gfxFT2FontBase.h"
|
2008-08-07 00:48:55 +04:00
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxFontUtils.h"
|
2009-01-23 09:24:29 +03:00
|
|
|
#include "gfxUserFontSet.h"
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2011-09-23 15:16:13 +04:00
|
|
|
class FT2FontEntry;
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2009-10-31 02:13:41 +03:00
|
|
|
class gfxFT2Font : public gfxFT2FontBase {
|
2008-08-07 00:48:55 +04:00
|
|
|
public: // new functions
|
2009-10-31 02:13:41 +03:00
|
|
|
gfxFT2Font(cairo_scaled_font_t *aCairoFont,
|
2011-09-23 15:16:13 +04:00
|
|
|
FT2FontEntry *aFontEntry,
|
2011-07-26 18:04:55 +04:00
|
|
|
const gfxFontStyle *aFontStyle,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNeedsBold);
|
2008-08-07 00:48:55 +04:00
|
|
|
virtual ~gfxFT2Font ();
|
|
|
|
|
2011-09-23 15:16:13 +04:00
|
|
|
FT2FontEntry *GetFontEntry();
|
2009-01-23 09:24:29 +03:00
|
|
|
|
|
|
|
static already_AddRefed<gfxFT2Font>
|
2011-09-23 15:15:36 +04:00
|
|
|
GetOrMakeFont(const nsAString& aName, const gfxFontStyle *aStyle,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNeedsBold = false);
|
2011-09-23 15:15:36 +04:00
|
|
|
|
2009-09-09 19:35:08 +04:00
|
|
|
static already_AddRefed<gfxFT2Font>
|
2011-09-23 15:16:13 +04:00
|
|
|
GetOrMakeFont(FT2FontEntry *aFontEntry, const gfxFontStyle *aStyle,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNeedsBold = false);
|
2009-01-23 09:24:29 +03:00
|
|
|
|
2009-09-11 00:52:40 +04:00
|
|
|
struct CachedGlyphData {
|
|
|
|
CachedGlyphData()
|
|
|
|
: glyphIndex(0xffffffffU) { }
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
CachedGlyphData(uint32_t gid)
|
2009-09-11 00:52:40 +04:00
|
|
|
: glyphIndex(gid) { }
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t glyphIndex;
|
|
|
|
int32_t lsbDelta;
|
|
|
|
int32_t rsbDelta;
|
|
|
|
int32_t xAdvance;
|
2009-09-11 00:52:40 +04:00
|
|
|
};
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
const CachedGlyphData* GetGlyphDataForChar(uint32_t ch) {
|
2009-09-11 00:52:40 +04:00
|
|
|
CharGlyphMapEntryType *entry = mCharGlyphCache.PutEntry(ch);
|
|
|
|
|
|
|
|
if (!entry)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-09-11 00:52:40 +04:00
|
|
|
|
|
|
|
if (entry->mData.glyphIndex == 0xffffffffU) {
|
|
|
|
// this is a new entry, fill it
|
|
|
|
FillGlyphDataForChar(ch, &entry->mData);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &entry->mData;
|
|
|
|
}
|
|
|
|
|
2013-10-15 06:19:47 +04:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
2012-03-23 16:14:16 +04:00
|
|
|
|
2013-06-05 21:48:59 +04:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
|
|
|
#endif
|
|
|
|
|
2011-01-07 15:38:28 +03:00
|
|
|
protected:
|
2013-01-04 22:35:37 +04:00
|
|
|
virtual bool ShapeText(gfxContext *aContext,
|
|
|
|
const PRUnichar *aText,
|
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
int32_t aScript,
|
|
|
|
gfxShapedText *aShapedText,
|
|
|
|
bool aPreferPlatformShaping);
|
2010-12-09 14:57:23 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd);
|
2009-09-11 00:52:40 +04:00
|
|
|
|
2013-01-04 22:35:37 +04:00
|
|
|
void AddRange(const PRUnichar *aText,
|
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
gfxShapedText *aShapedText);
|
2010-12-09 14:57:23 +03:00
|
|
|
|
2009-09-11 00:52:40 +04:00
|
|
|
typedef nsBaseHashtableET<nsUint32HashKey, CachedGlyphData> CharGlyphMapEntryType;
|
|
|
|
typedef nsTHashtable<CharGlyphMapEntryType> CharGlyphMap;
|
|
|
|
CharGlyphMap mCharGlyphCache;
|
2008-08-07 00:48:55 +04:00
|
|
|
};
|
|
|
|
|
2011-09-23 15:15:36 +04:00
|
|
|
#ifndef ANDROID // not needed on Android, uses the standard gfxFontGroup directly
|
2013-05-30 01:59:24 +04:00
|
|
|
class gfxFT2FontGroup : public gfxFontGroup {
|
2008-08-07 00:48:55 +04:00
|
|
|
public: // new functions
|
|
|
|
gfxFT2FontGroup (const nsAString& families,
|
2010-07-16 10:03:45 +04:00
|
|
|
const gfxFontStyle *aStyle,
|
|
|
|
gfxUserFontSet *aUserFontSet);
|
2008-08-07 00:48:55 +04:00
|
|
|
virtual ~gfxFT2FontGroup ();
|
|
|
|
|
|
|
|
protected: // from gfxFontGroup
|
|
|
|
|
|
|
|
virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
|
|
|
|
|
|
|
|
|
|
|
|
protected: // new functions
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool FontCallback (const nsAString & fontName,
|
2008-08-07 00:48:55 +04:00
|
|
|
const nsACString & genericName,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aUseFontSet,
|
2008-08-07 00:48:55 +04:00
|
|
|
void *closure);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mEnableKerning;
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2010-02-24 20:57:57 +03:00
|
|
|
void GetPrefFonts(nsIAtom *aLangGroup,
|
2009-10-07 18:13:40 +04:00
|
|
|
nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList);
|
|
|
|
void GetCJKPrefFonts(nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList);
|
2009-09-09 19:35:08 +04:00
|
|
|
void FamilyListToArrayList(const nsString& aFamilies,
|
2010-02-24 20:57:57 +03:00
|
|
|
nsIAtom *aLangGroup,
|
2009-10-07 18:13:40 +04:00
|
|
|
nsTArray<nsRefPtr<gfxFontEntry> > *aFontEntryList);
|
|
|
|
already_AddRefed<gfxFT2Font> WhichFontSupportsChar(const nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aCh);
|
|
|
|
already_AddRefed<gfxFont> WhichPrefFontSupportsChar(uint32_t aCh);
|
2012-03-09 06:05:24 +04:00
|
|
|
already_AddRefed<gfxFont>
|
2012-08-22 19:56:38 +04:00
|
|
|
WhichSystemFontSupportsChar(uint32_t aCh, int32_t aRunScript);
|
2009-09-09 19:35:08 +04:00
|
|
|
|
|
|
|
nsTArray<gfxTextRange> mRanges;
|
2008-08-07 00:48:55 +04:00
|
|
|
nsString mString;
|
|
|
|
};
|
2011-09-23 15:15:36 +04:00
|
|
|
#endif // !ANDROID
|
2008-08-07 00:48:55 +04:00
|
|
|
|
2009-10-31 02:13:41 +03:00
|
|
|
#endif /* GFX_FT2FONTS_H */
|
2008-08-07 00:48:55 +04:00
|
|
|
|