Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / gfx / thebes / public / gfxOS2Fonts.h
blob1ca25949a27e5f663f9d9f76ca57f3638753ecff
1 /* vim: set sw=4 sts=4 et cin: */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is OS/2 code in Thebes.
17 * The Initial Developer of the Original Code is
18 * Peter Weilbacher <mozilla@Weilbacher.org>.
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef GFX_OS2_FONTS_H
39 #define GFX_OS2_FONTS_H
41 #include "gfxTypes.h"
42 #include "gfxFont.h"
43 #include "gfxMatrix.h"
44 #include "nsDataHashtable.h"
46 #define INCL_GPI
47 #include <os2.h>
48 #include <cairo-os2.h>
49 #include "cairo-ft.h" // includes fontconfig.h, too
50 #include <freetype/tttables.h>
52 #include "nsICharsetConverterManager.h"
54 class gfxOS2FontEntry : public gfxFontEntry {
55 public:
56 gfxOS2FontEntry(const nsAString& aName) : gfxFontEntry(aName) {}
57 ~gfxOS2FontEntry() {}
60 class gfxOS2Font : public gfxFont {
61 public:
62 gfxOS2Font(gfxOS2FontEntry *aFontEntry, const gfxFontStyle *aFontStyle);
63 virtual ~gfxOS2Font();
65 virtual const gfxFont::Metrics& GetMetrics();
66 cairo_font_face_t *CairoFontFace();
67 cairo_scaled_font_t *CairoScaledFont();
69 virtual nsString GetUniqueName();
71 // Get the glyphID of a space
72 virtual PRUint32 GetSpaceGlyph() {
73 if (!mMetrics)
74 GetMetrics();
75 return mSpaceGlyph;
78 static already_AddRefed<gfxOS2Font> GetOrMakeFont(const nsAString& aName,
79 const gfxFontStyle *aStyle);
81 protected:
82 virtual PRBool SetupCairoFont(gfxContext *aContext);
84 private:
85 cairo_font_face_t *mFontFace;
86 cairo_scaled_font_t *mScaledFont;
87 Metrics *mMetrics;
88 gfxFloat mAdjustedSize;
89 PRUint32 mSpaceGlyph;
90 int mHinting;
91 PRBool mAntialias;
95 class THEBES_API gfxOS2FontGroup : public gfxFontGroup {
96 public:
97 gfxOS2FontGroup(const nsAString& aFamilies, const gfxFontStyle* aStyle, gfxUserFontSet *aUserFontSet);
98 virtual ~gfxOS2FontGroup();
100 virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
102 // create and initialize the textRun using FreeType font
103 virtual gfxTextRun *MakeTextRun(const PRUnichar* aString, PRUint32 aLength,
104 const Parameters* aParams, PRUint32 aFlags);
105 virtual gfxTextRun *MakeTextRun(const PRUint8* aString, PRUint32 aLength,
106 const Parameters* aParams, PRUint32 aFlags);
108 gfxOS2Font *GetFontAt(PRInt32 i) {
109 // If it turns out to be hard for all clients that cache font
110 // groups to call UpdateFontList at appropriate times, we could
111 // instead consider just calling UpdateFontList from someplace
112 // more central (such as here).
113 NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
114 "Whoever was caching this font group should have "
115 "called UpdateFontList on it");
117 #ifdef DEBUG_thebes_2
118 printf("gfxOS2FontGroup[%#x]::GetFontAt(%d), %#x, %#x\n",
119 (unsigned)this, i, (unsigned)&mFonts, (unsigned)&mFonts[i]);
120 #endif
121 return static_cast<gfxOS2Font*>(static_cast<gfxFont*>(mFonts[i]));
124 protected:
125 void InitTextRun(gfxTextRun *aTextRun, const PRUint8 *aUTF8Text,
126 PRUint32 aUTF8Length, PRUint32 aUTF8HeaderLength);
127 void CreateGlyphRunsFT(gfxTextRun *aTextRun, const PRUint8 *aUTF8,
128 PRUint32 aUTF8Length);
129 static PRBool FontCallback(const nsAString& aFontName,
130 const nsACString& aGenericName, void *aClosure);
132 private:
133 PRBool mEnableKerning;
136 #endif /* GFX_OS2_FONTS_H */