2008-08-06 13:48:55 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07: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-06 13:48:55 -07:00
|
|
|
|
2009-10-30 16:13:41 -07:00
|
|
|
#ifndef GFX_FT2FONTS_H
|
|
|
|
#define GFX_FT2FONTS_H
|
2008-08-06 13:48:55 -07:00
|
|
|
|
|
|
|
#include "cairo.h"
|
|
|
|
#include "gfxTypes.h"
|
|
|
|
#include "gfxFont.h"
|
2009-10-30 16:13:41 -07:00
|
|
|
#include "gfxFT2FontBase.h"
|
2008-08-06 13:48:55 -07:00
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxFontUtils.h"
|
2009-01-22 22:24:29 -08:00
|
|
|
#include "gfxUserFontSet.h"
|
2008-08-06 13:48:55 -07:00
|
|
|
|
2011-09-23 04:16:13 -07:00
|
|
|
class FT2FontEntry;
|
2008-08-06 13:48:55 -07:00
|
|
|
|
2009-10-30 16:13:41 -07:00
|
|
|
class gfxFT2Font : public gfxFT2FontBase {
|
2008-08-06 13:48:55 -07:00
|
|
|
public: // new functions
|
2009-10-30 16:13:41 -07:00
|
|
|
gfxFT2Font(cairo_scaled_font_t *aCairoFont,
|
2011-09-23 04:16:13 -07:00
|
|
|
FT2FontEntry *aFontEntry,
|
2011-07-26 07:04:55 -07:00
|
|
|
const gfxFontStyle *aFontStyle,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNeedsBold);
|
2008-08-06 13:48:55 -07:00
|
|
|
virtual ~gfxFT2Font ();
|
|
|
|
|
|
|
|
cairo_font_face_t *CairoFontFace();
|
|
|
|
|
2011-09-23 04:16:13 -07:00
|
|
|
FT2FontEntry *GetFontEntry();
|
2009-01-22 22:24:29 -08:00
|
|
|
|
|
|
|
static already_AddRefed<gfxFT2Font>
|
2011-09-23 04:15:36 -07:00
|
|
|
GetOrMakeFont(const nsAString& aName, const gfxFontStyle *aStyle,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNeedsBold = false);
|
2011-09-23 04:15:36 -07:00
|
|
|
|
2009-09-09 08:35:08 -07:00
|
|
|
static already_AddRefed<gfxFT2Font>
|
2011-09-23 04:16:13 -07:00
|
|
|
GetOrMakeFont(FT2FontEntry *aFontEntry, const gfxFontStyle *aStyle,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNeedsBold = false);
|
2009-01-22 22:24:29 -08:00
|
|
|
|
2009-09-10 13:52:40 -07:00
|
|
|
struct CachedGlyphData {
|
|
|
|
CachedGlyphData()
|
|
|
|
: glyphIndex(0xffffffffU) { }
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
CachedGlyphData(uint32_t gid)
|
2009-09-10 13:52:40 -07:00
|
|
|
: glyphIndex(gid) { }
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t glyphIndex;
|
|
|
|
int32_t lsbDelta;
|
|
|
|
int32_t rsbDelta;
|
|
|
|
int32_t xAdvance;
|
2009-09-10 13:52:40 -07:00
|
|
|
};
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
const CachedGlyphData* GetGlyphDataForChar(uint32_t ch) {
|
2009-09-10 13:52:40 -07:00
|
|
|
CharGlyphMapEntryType *entry = mCharGlyphCache.PutEntry(ch);
|
|
|
|
|
|
|
|
if (!entry)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2009-09-10 13:52:40 -07:00
|
|
|
|
|
|
|
if (entry->mData.glyphIndex == 0xffffffffU) {
|
|
|
|
// this is a new entry, fill it
|
|
|
|
FillGlyphDataForChar(ch, &entry->mData);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &entry->mData;
|
|
|
|
}
|
|
|
|
|
2012-03-23 05:14:16 -07:00
|
|
|
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
|
2011-01-07 04:38:28 -08:00
|
|
|
protected:
|
2011-12-06 04:39:19 -08:00
|
|
|
virtual bool ShapeWord(gfxContext *aContext,
|
|
|
|
gfxShapedWord *aShapedWord,
|
|
|
|
const PRUnichar *aString,
|
|
|
|
bool aPreferPlatformShaping = false);
|
2010-12-09 03:57:23 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd);
|
2009-09-10 13:52:40 -07:00
|
|
|
|
2011-12-06 04:39:19 -08:00
|
|
|
void AddRange(gfxShapedWord *aShapedWord, const PRUnichar *str);
|
2010-12-09 03:57:23 -08:00
|
|
|
|
2009-09-10 13:52:40 -07:00
|
|
|
typedef nsBaseHashtableET<nsUint32HashKey, CachedGlyphData> CharGlyphMapEntryType;
|
|
|
|
typedef nsTHashtable<CharGlyphMapEntryType> CharGlyphMap;
|
|
|
|
CharGlyphMap mCharGlyphCache;
|
2008-08-06 13:48:55 -07:00
|
|
|
};
|
|
|
|
|
2011-09-23 04:15:36 -07:00
|
|
|
#ifndef ANDROID // not needed on Android, uses the standard gfxFontGroup directly
|
2008-08-06 13:48:55 -07:00
|
|
|
class THEBES_API gfxFT2FontGroup : public gfxFontGroup {
|
|
|
|
public: // new functions
|
|
|
|
gfxFT2FontGroup (const nsAString& families,
|
2010-07-15 23:03:45 -07:00
|
|
|
const gfxFontStyle *aStyle,
|
|
|
|
gfxUserFontSet *aUserFontSet);
|
2008-08-06 13:48:55 -07:00
|
|
|
virtual ~gfxFT2FontGroup ();
|
|
|
|
|
|
|
|
protected: // from gfxFontGroup
|
|
|
|
|
|
|
|
virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
|
|
|
|
|
|
|
|
|
|
|
|
protected: // new functions
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool FontCallback (const nsAString & fontName,
|
2008-08-06 13:48:55 -07:00
|
|
|
const nsACString & genericName,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseFontSet,
|
2008-08-06 13:48:55 -07:00
|
|
|
void *closure);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mEnableKerning;
|
2008-08-06 13:48:55 -07:00
|
|
|
|
2010-02-24 09:57:57 -08:00
|
|
|
void GetPrefFonts(nsIAtom *aLangGroup,
|
2009-10-07 07:13:40 -07:00
|
|
|
nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList);
|
|
|
|
void GetCJKPrefFonts(nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList);
|
2009-09-09 08:35:08 -07:00
|
|
|
void FamilyListToArrayList(const nsString& aFamilies,
|
2010-02-24 09:57:57 -08:00
|
|
|
nsIAtom *aLangGroup,
|
2009-10-07 07:13:40 -07:00
|
|
|
nsTArray<nsRefPtr<gfxFontEntry> > *aFontEntryList);
|
|
|
|
already_AddRefed<gfxFT2Font> WhichFontSupportsChar(const nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aCh);
|
|
|
|
already_AddRefed<gfxFont> WhichPrefFontSupportsChar(uint32_t aCh);
|
2012-03-08 18:05:24 -08:00
|
|
|
already_AddRefed<gfxFont>
|
2012-08-22 08:56:38 -07:00
|
|
|
WhichSystemFontSupportsChar(uint32_t aCh, int32_t aRunScript);
|
2009-09-09 08:35:08 -07:00
|
|
|
|
|
|
|
nsTArray<gfxTextRange> mRanges;
|
2008-08-06 13:48:55 -07:00
|
|
|
nsString mString;
|
|
|
|
};
|
2011-09-23 04:15:36 -07:00
|
|
|
#endif // !ANDROID
|
2008-08-06 13:48:55 -07:00
|
|
|
|
2009-10-30 16:13:41 -07:00
|
|
|
#endif /* GFX_FT2FONTS_H */
|
2008-08-06 13:48:55 -07:00
|
|
|
|