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
|
|
|
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.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 ();
|
|
|
|
|
2011-09-23 04:16:13 -07:00
|
|
|
FT2FontEntry *GetFontEntry();
|
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;
|
|
|
|
}
|
|
|
|
|
2013-10-14 19:19:47 -07:00
|
|
|
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
|
|
|
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
|
|
|
FontCacheSizes* aSizes) const;
|
2012-03-23 05:14:16 -07:00
|
|
|
|
2013-06-05 10:48:59 -07:00
|
|
|
#ifdef USE_SKIA
|
2015-06-17 07:00:52 -07:00
|
|
|
virtual already_AddRefed<mozilla::gfx::GlyphRenderingOptions>
|
2015-03-21 09:28:04 -07:00
|
|
|
GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams = nullptr) override;
|
2013-06-05 10:48:59 -07:00
|
|
|
#endif
|
|
|
|
|
2011-01-07 04:38:28 -08:00
|
|
|
protected:
|
2013-01-04 10:35:37 -08:00
|
|
|
virtual bool ShapeText(gfxContext *aContext,
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t *aText,
|
2013-01-04 10:35:37 -08:00
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
int32_t aScript,
|
2014-10-01 12:25:48 -07:00
|
|
|
bool aVertical,
|
2014-05-31 00:12:40 -07:00
|
|
|
gfxShapedText *aShapedText);
|
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
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
void AddRange(const char16_t *aText,
|
2013-01-04 10:35:37 -08:00
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
gfxShapedText *aShapedText);
|
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
|
|
|
};
|
|
|
|
|
2009-10-30 16:13:41 -07:00
|
|
|
#endif /* GFX_FT2FONTS_H */
|
2008-08-06 13:48:55 -07:00
|
|
|
|