|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef GFX_GRAPHITESHAPER_H |
|
7 #define GFX_GRAPHITESHAPER_H |
|
8 |
|
9 #include "gfxFont.h" |
|
10 |
|
11 struct gr_face; |
|
12 struct gr_font; |
|
13 struct gr_segment; |
|
14 |
|
15 class gfxGraphiteShaper : public gfxFontShaper { |
|
16 public: |
|
17 gfxGraphiteShaper(gfxFont *aFont); |
|
18 virtual ~gfxGraphiteShaper(); |
|
19 |
|
20 virtual bool ShapeText(gfxContext *aContext, |
|
21 const char16_t *aText, |
|
22 uint32_t aOffset, |
|
23 uint32_t aLength, |
|
24 int32_t aScript, |
|
25 gfxShapedText *aShapedText); |
|
26 |
|
27 static void Shutdown(); |
|
28 |
|
29 protected: |
|
30 nsresult SetGlyphsFromSegment(gfxContext *aContext, |
|
31 gfxShapedText *aShapedText, |
|
32 uint32_t aOffset, |
|
33 uint32_t aLength, |
|
34 const char16_t *aText, |
|
35 gr_segment *aSegment); |
|
36 |
|
37 static float GrGetAdvance(const void* appFontHandle, uint16_t glyphid); |
|
38 |
|
39 gr_face *mGrFace; // owned by the font entry; shaper must call |
|
40 // gfxFontEntry::ReleaseGrFace when finished with it |
|
41 gr_font *mGrFont; // owned by the shaper itself |
|
42 |
|
43 struct CallbackData { |
|
44 gfxFont *mFont; |
|
45 gfxGraphiteShaper *mShaper; |
|
46 gfxContext *mContext; |
|
47 }; |
|
48 |
|
49 CallbackData mCallbackData; |
|
50 |
|
51 // Convert HTML 'lang' (BCP47) to Graphite language code |
|
52 static uint32_t GetGraphiteTagForLang(const nsCString& aLang); |
|
53 static nsTHashtable<nsUint32HashKey> *sLanguageTags; |
|
54 }; |
|
55 |
|
56 #endif /* GFX_GRAPHITESHAPER_H */ |