Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / gfx / public / nsFont.h
blobc5c5e87366cd8228574505b82e042733946df9b3
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
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 of the GNU General Public License Version 2 or later (the "GPL"),
26 * or 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 nsFont_h___
39 #define nsFont_h___
41 #include "gfxCore.h"
42 #include "nsCoord.h"
43 #include "nsStringGlue.h"
45 // XXX we need a method to enumerate all of the possible fonts on the
46 // system across family, weight, style, size, etc. But not here!
48 // Enumerator callback function. Return PR_FALSE to stop
49 typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
51 // IDs for generic fonts
52 // NOTE: 0, 1 are reserved for the special IDs of the default variable
53 // and fixed fonts in the presentation context, see nsPresContext.h
54 const PRUint8 kGenericFont_NONE = 0x00;
55 // Special
56 const PRUint8 kGenericFont_moz_variable = 0x00; // for the default variable width font
57 const PRUint8 kGenericFont_moz_fixed = 0x01; // our special "use the user's fixed font"
58 // CSS
59 const PRUint8 kGenericFont_serif = 0x02;
60 const PRUint8 kGenericFont_sans_serif = 0x04;
61 const PRUint8 kGenericFont_monospace = 0x08;
62 const PRUint8 kGenericFont_cursive = 0x10;
63 const PRUint8 kGenericFont_fantasy = 0x20;
65 // Font structure.
66 struct NS_GFX nsFont {
67 // The family name of the font
68 nsString name;
70 // The style of font (normal, italic, oblique)
71 PRUint8 style;
73 // Force this font to not be considered a 'generic' font, even if
74 // the name is the same as a CSS generic font family.
75 PRUint8 systemFont;
77 // The variant of the font (normal, small-caps)
78 PRUint8 variant;
80 // True if the character set quirks (for treatment of "Symbol",
81 // "Wingdings", etc.) should be applied.
82 PRUint8 familyNameQuirks;
84 // The weight of the font (0-999)
85 PRUint16 weight;
87 // The decorations on the font (underline, overline,
88 // line-through). The decorations can be binary or'd together.
89 PRUint8 decorations;
91 // The logical size of the font, in nscoord units
92 nscoord size;
94 // The aspect-value (ie., the ratio actualsize:actualxheight) that any
95 // actual physical font created from this font structure must have when
96 // rendering or measuring a string. A value of 0 means no adjustment
97 // needs to be done.
98 float sizeAdjust;
100 // Initialize the font struct with an ASCII name
101 nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
102 PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
103 float aSizeAdjust=0.0f);
105 // Initialize the font struct with a (potentially) unicode name
106 nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
107 PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
108 float aSizeAdjust=0.0f);
110 // Make a copy of the given font
111 nsFont(const nsFont& aFont);
113 nsFont();
114 ~nsFont();
116 PRBool operator==(const nsFont& aOther) const {
117 return Equals(aOther);
120 PRBool Equals(const nsFont& aOther) const ;
121 // Compare ignoring differences in 'variant' and 'decoration'
122 PRBool BaseEquals(const nsFont& aOther) const;
124 nsFont& operator=(const nsFont& aOther);
126 // Utility method to interpret name string
127 // enumerates all families specified by this font only
128 // returns PR_TRUE if completed, PR_FALSE if stopped
129 // enclosing quotes will be removed, and whitespace compressed (as needed)
130 PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
131 void GetFirstFamily(nsString& aFamily) const;
133 // Utility method to return the ID of a generic font
134 static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
137 #define NS_FONT_STYLE_NORMAL 0
138 #define NS_FONT_STYLE_ITALIC 1
139 #define NS_FONT_STYLE_OBLIQUE 2
141 #define NS_FONT_VARIANT_NORMAL 0
142 #define NS_FONT_VARIANT_SMALL_CAPS 1
144 #define NS_FONT_DECORATION_NONE 0x0
145 #define NS_FONT_DECORATION_UNDERLINE 0x1
146 #define NS_FONT_DECORATION_OVERLINE 0x2
147 #define NS_FONT_DECORATION_LINE_THROUGH 0x4
149 #define NS_FONT_WEIGHT_NORMAL 400
150 #define NS_FONT_WEIGHT_BOLD 700
152 #endif /* nsFont_h___ */