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
|
|
|
|
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
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<mozilla::gfx::GlyphRenderingOptions>
|
2015-03-21 19:28:04 +03:00
|
|
|
GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams = nullptr) override;
|
2013-06-05 21:48:59 +04:00
|
|
|
#endif
|
|
|
|
|
2011-01-07 15:38:28 +03:00
|
|
|
protected:
|
2013-01-04 22:35:37 +04:00
|
|
|
virtual bool ShapeText(gfxContext *aContext,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aText,
|
2013-01-04 22:35:37 +04:00
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aLength,
|
|
|
|
int32_t aScript,
|
2014-10-01 23:25:48 +04:00
|
|
|
bool aVertical,
|
2014-05-31 11:12:40 +04:00
|
|
|
gfxShapedText *aShapedText);
|
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
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
void AddRange(const char16_t *aText,
|
2013-01-04 22:35:37 +04:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2009-10-31 02:13:41 +03:00
|
|
|
#endif /* GFX_FT2FONTS_H */
|
2008-08-07 00:48:55 +04:00
|
|
|
|