Bug 574778 - Fix win widget's ConstrainPosition so that it supports full screen windo...
[mozilla-central.git] / gfx / src / nsFont.h
blob0bddb98ad7d8e6642d8400a3e923655812a5e59f
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"
44 #include "gfxFontConstants.h"
46 // XXX we need a method to enumerate all of the possible fonts on the
47 // system across family, weight, style, size, etc. But not here!
49 // Enumerator callback function. Return PR_FALSE to stop
50 typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
52 // IDs for generic fonts
53 // NOTE: 0, 1 are reserved for the special IDs of the default variable
54 // and fixed fonts in the presentation context, see nsPresContext.h
55 const PRUint8 kGenericFont_NONE = 0x00;
56 // Special
57 const PRUint8 kGenericFont_moz_variable = 0x00; // for the default variable width font
58 const PRUint8 kGenericFont_moz_fixed = 0x01; // our special "use the user's fixed font"
59 // CSS
60 const PRUint8 kGenericFont_serif = 0x02;
61 const PRUint8 kGenericFont_sans_serif = 0x04;
62 const PRUint8 kGenericFont_monospace = 0x08;
63 const PRUint8 kGenericFont_cursive = 0x10;
64 const PRUint8 kGenericFont_fantasy = 0x20;
66 // Font structure.
67 struct NS_GFX nsFont {
68 // The family name of the font
69 nsString name;
71 // The style of font (normal, italic, oblique; see gfxFontConstants.h)
72 PRUint8 style;
74 // Force this font to not be considered a 'generic' font, even if
75 // the name is the same as a CSS generic font family.
76 PRUint8 systemFont;
78 // The variant of the font (normal, small-caps)
79 PRUint8 variant;
81 // True if the character set quirks (for treatment of "Symbol",
82 // "Wingdings", etc.) should be applied.
83 PRUint8 familyNameQuirks;
85 // The weight of the font; see gfxFontConstants.h.
86 PRUint16 weight;
88 // The stretch of the font (the sum of various NS_FONT_STRETCH_*
89 // constants; see gfxFontConstants.h).
90 PRInt16 stretch;
92 // The decorations on the font (underline, overline,
93 // line-through). The decorations can be binary or'd together.
94 PRUint8 decorations;
96 // The logical size of the font, in nscoord units
97 nscoord size;
99 // The aspect-value (ie., the ratio actualsize:actualxheight) that any
100 // actual physical font created from this font structure must have when
101 // rendering or measuring a string. A value of 0 means no adjustment
102 // needs to be done.
103 float sizeAdjust;
105 // Font features from CSS font-feature-settings
106 nsString featureSettings;
108 // Language system tag, to override document language;
109 // this is an OpenType "language system" tag represented as a 32-bit integer
110 // (see http://www.microsoft.com/typography/otspec/languagetags.htm).
111 nsString languageOverride;
113 // Initialize the font struct with an ASCII name
114 nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
115 PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
116 nscoord aSize, float aSizeAdjust=0.0f,
117 const nsString* aFeatureSettings = nsnull,
118 const nsString* aLanguageOverride = nsnull);
120 // Initialize the font struct with a (potentially) unicode name
121 nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
122 PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
123 nscoord aSize, float aSizeAdjust=0.0f,
124 const nsString* aFeatureSettings = nsnull,
125 const nsString* aLanguageOverride = nsnull);
127 // Make a copy of the given font
128 nsFont(const nsFont& aFont);
130 nsFont();
131 ~nsFont();
133 PRBool operator==(const nsFont& aOther) const {
134 return Equals(aOther);
137 PRBool Equals(const nsFont& aOther) const ;
138 // Compare ignoring differences in 'variant' and 'decoration'
139 PRBool BaseEquals(const nsFont& aOther) const;
141 nsFont& operator=(const nsFont& aOther);
143 // Utility method to interpret name string
144 // enumerates all families specified by this font only
145 // returns PR_TRUE if completed, PR_FALSE if stopped
146 // enclosing quotes will be removed, and whitespace compressed (as needed)
147 PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
148 void GetFirstFamily(nsString& aFamily) const;
150 // Utility method to return the ID of a generic font
151 static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
154 #define NS_FONT_VARIANT_NORMAL 0
155 #define NS_FONT_VARIANT_SMALL_CAPS 1
157 #define NS_FONT_DECORATION_NONE 0x0
158 #define NS_FONT_DECORATION_UNDERLINE 0x1
159 #define NS_FONT_DECORATION_OVERLINE 0x2
160 #define NS_FONT_DECORATION_LINE_THROUGH 0x4
162 #endif /* nsFont_h___ */