michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_GRAPHITESHAPER_H michael@0: #define GFX_GRAPHITESHAPER_H michael@0: michael@0: #include "gfxFont.h" michael@0: michael@0: struct gr_face; michael@0: struct gr_font; michael@0: struct gr_segment; michael@0: michael@0: class gfxGraphiteShaper : public gfxFontShaper { michael@0: public: michael@0: gfxGraphiteShaper(gfxFont *aFont); michael@0: virtual ~gfxGraphiteShaper(); michael@0: michael@0: virtual bool ShapeText(gfxContext *aContext, michael@0: const char16_t *aText, michael@0: uint32_t aOffset, michael@0: uint32_t aLength, michael@0: int32_t aScript, michael@0: gfxShapedText *aShapedText); michael@0: michael@0: static void Shutdown(); michael@0: michael@0: protected: michael@0: nsresult SetGlyphsFromSegment(gfxContext *aContext, michael@0: gfxShapedText *aShapedText, michael@0: uint32_t aOffset, michael@0: uint32_t aLength, michael@0: const char16_t *aText, michael@0: gr_segment *aSegment); michael@0: michael@0: static float GrGetAdvance(const void* appFontHandle, uint16_t glyphid); michael@0: michael@0: gr_face *mGrFace; // owned by the font entry; shaper must call michael@0: // gfxFontEntry::ReleaseGrFace when finished with it michael@0: gr_font *mGrFont; // owned by the shaper itself michael@0: michael@0: struct CallbackData { michael@0: gfxFont *mFont; michael@0: gfxGraphiteShaper *mShaper; michael@0: gfxContext *mContext; michael@0: }; michael@0: michael@0: CallbackData mCallbackData; michael@0: michael@0: // Convert HTML 'lang' (BCP47) to Graphite language code michael@0: static uint32_t GetGraphiteTagForLang(const nsCString& aLang); michael@0: static nsTHashtable *sLanguageTags; michael@0: }; michael@0: michael@0: #endif /* GFX_GRAPHITESHAPER_H */