2008-08-06 20:48:55 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 11:12:37 +00: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 20:48:55 +00:00
|
|
|
|
2009-10-30 23:13:41 +00:00
|
|
|
#ifndef GFX_FT2FONTS_H
|
|
|
|
#define GFX_FT2FONTS_H
|
2008-08-06 20:48:55 +00:00
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2008-08-06 20:48:55 +00:00
|
|
|
#include "cairo.h"
|
|
|
|
#include "gfxTypes.h"
|
|
|
|
#include "gfxFont.h"
|
2009-10-30 23:13:41 +00:00
|
|
|
#include "gfxFT2FontBase.h"
|
2008-08-06 20:48:55 +00:00
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxFontUtils.h"
|
2009-01-23 06:24:29 +00:00
|
|
|
#include "gfxUserFontSet.h"
|
2008-08-06 20:48:55 +00:00
|
|
|
|
2011-09-23 11:16:13 +00:00
|
|
|
class FT2FontEntry;
|
2008-08-06 20:48:55 +00:00
|
|
|
|
2009-10-30 23:13:41 +00:00
|
|
|
class gfxFT2Font : public gfxFT2FontBase {
|
2008-08-06 20:48:55 +00:00
|
|
|
public: // new functions
|
2009-10-30 23:13:41 +00:00
|
|
|
gfxFT2Font(cairo_scaled_font_t *aCairoFont,
|
2011-09-23 11:16:13 +00:00
|
|
|
FT2FontEntry *aFontEntry,
|
2011-07-26 14:04:55 +00:00
|
|
|
const gfxFontStyle *aFontStyle,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aNeedsBold);
|
2008-08-06 20:48:55 +00:00
|
|
|
virtual ~gfxFT2Font ();
|
|
|
|
|
2011-09-23 11:16:13 +00:00
|
|
|
FT2FontEntry *GetFontEntry();
|
2009-01-23 06:24:29 +00:00
|
|
|
|
|
|
|
static already_AddRefed<gfxFT2Font>
|
2011-09-23 11:15:36 +00:00
|
|
|
GetOrMakeFont(const nsAString& aName, const gfxFontStyle *aStyle,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aNeedsBold = false);
|
2011-09-23 11:15:36 +00:00
|
|
|
|
2009-09-09 15:35:08 +00:00
|
|
|
static already_AddRefed<gfxFT2Font>
|
2011-09-23 11:16:13 +00:00
|
|
|
GetOrMakeFont(FT2FontEntry *aFontEntry, const gfxFontStyle *aStyle,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aNeedsBold = false);
|
2009-01-23 06:24:29 +00:00
|
|
|
|
2009-09-10 20:52:40 +00:00
|
|
|
struct CachedGlyphData {
|
|
|
|
CachedGlyphData()
|
|
|
|
: glyphIndex(0xffffffffU) { }
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
CachedGlyphData(uint32_t gid)
|
2009-09-10 20:52:40 +00:00
|
|
|
: glyphIndex(gid) { }
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t glyphIndex;
|
|
|
|
int32_t lsbDelta;
|
|
|
|
int32_t rsbDelta;
|
|
|
|
int32_t xAdvance;
|
2009-09-10 20:52:40 +00:00
|
|
|
};
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
const CachedGlyphData* GetGlyphDataForChar(uint32_t ch) {
|
2009-09-10 20:52:40 +00:00
|
|
|
CharGlyphMapEntryType *entry = mCharGlyphCache.PutEntry(ch);
|
|
|
|
|
|
|
|
if (!entry)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-09-10 20:52:40 +00:00
|
|
|
|
|
|
|
if (entry->mData.glyphIndex == 0xffffffffU) {
|
|
|
|
// this is a new entry, fill it
|
|
|
|
FillGlyphDataForChar(ch, &entry->mData);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &entry->mData;
|
|
|
|
}
|
|
|
|
|
2013-10-15 02:19:47 +00:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
2012-03-23 12:14:16 +00:00
|
|
|
|
2013-06-05 17:48:59 +00:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
|
|
|
|
#endif
|
|
|
|
|
2011-01-07 12:38:28 +00:00
|
|
|
protected:
|
2013-01-04 18:35:37 +00:00
|
|
|
virtual bool ShapeText(gfxContext *aContext,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t *aText,
|
2013-01-04 18:35:37 +00:00
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
int32_t aScript,
|
2014-10-01 19:25:48 +00:00
|
|
|
bool aVertical,
|
2014-05-31 07:12:40 +00:00
|
|
|
gfxShapedText *aShapedText);
|
2010-12-09 11:57:23 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd);
|
2009-09-10 20:52:40 +00:00
|
|
|
|
2014-01-04 15:02:17 +00:00
|
|
|
void AddRange(const char16_t *aText,
|
2013-01-04 18:35:37 +00:00
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
gfxShapedText *aShapedText);
|
2010-12-09 11:57:23 +00:00
|
|
|
|
2009-09-10 20:52:40 +00:00
|
|
|
typedef nsBaseHashtableET<nsUint32HashKey, CachedGlyphData> CharGlyphMapEntryType;
|
|
|
|
typedef nsTHashtable<CharGlyphMapEntryType> CharGlyphMap;
|
|
|
|
CharGlyphMap mCharGlyphCache;
|
2008-08-06 20:48:55 +00:00
|
|
|
};
|
|
|
|
|
2009-10-30 23:13:41 +00:00
|
|
|
#endif /* GFX_FT2FONTS_H */
|
2008-08-06 20:48:55 +00:00
|
|
|
|