/dist/include/gfx/nsFont.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Netscape Public License
00006  * Version 1.1 (the "License"); you may not use this file except in
00007  * compliance with the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/NPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is 
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the NPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the NPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsFont_h___
00040 #define nsFont_h___
00041 
00042 #include "nscore.h"
00043 #include "nsComObsolete.h"
00044 #include "nsCoord.h"
00045 #include "nsString.h"
00046 
00047 // XXX we need a method to enumerate all of the possible fonts on the
00048 // system across family, weight, style, size, etc. But not here!
00049 
00050 // Enumerator callback function. Return PR_FALSE to stop
00051 typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
00052 
00053 // IDs for generic fonts
00054 // NOTE: 0, 1 are reserved for the special IDs of the default variable
00055 // and fixed fonts in the presentation context, see nsIPresContext.h
00056 const PRUint8 kGenericFont_NONE         = 0x00;
00057 // Special
00058 const PRUint8 kGenericFont_moz_variable = 0x00; // for the default variable width font
00059 const PRUint8 kGenericFont_moz_fixed    = 0x01; // our special "use the user's fixed font"
00060 // CSS
00061 const PRUint8 kGenericFont_serif        = 0x02;
00062 const PRUint8 kGenericFont_sans_serif   = 0x04;
00063 const PRUint8 kGenericFont_monospace    = 0x08;
00064 const PRUint8 kGenericFont_cursive      = 0x10;
00065 const PRUint8 kGenericFont_fantasy      = 0x20;
00066 
00067 // Font structure.
00068 struct NS_GFX nsFont {
00069   // The family name of the font
00070   nsString name;
00071 
00072   // The style of font (normal, italic, oblique)
00073   PRUint8 style;
00074 
00075   // The variant of the font (normal, small-caps)
00076   PRUint8 variant : 7;
00077 
00078   // True if the character set quirks (for treatment of "Symbol",
00079   // "Wingdings", etc.) should be applied.
00080   PRPackedBool familyNameQuirks : 1;
00081 
00082   // The weight of the font (0-999)
00083   PRUint16 weight;
00084 
00085   // The decorations on the font (underline, overline,
00086   // line-through). The decorations can be binary or'd together.
00087   PRUint8 decorations;
00088 
00089   // The logical size of the font, in nscoord units
00090   nscoord size;
00091 
00092   // The aspect-value (ie., the ratio actualsize:actualxheight) that any
00093   // actual physical font created from this font structure must have when
00094   // rendering or measuring a string. A value of 0 means no adjustment
00095   // needs to be done.
00096   float sizeAdjust;
00097 
00098   // Initialize the font struct with an iso-latin1 name
00099   nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
00100          PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
00101          float aSizeAdjust=0.0f);
00102 
00103   // Initialize the font struct with a (potentially) unicode name
00104   nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
00105          PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
00106          float aSizeAdjust=0.0f);
00107 
00108   // Make a copy of the given font
00109   nsFont(const nsFont& aFont);
00110 
00111   nsFont();
00112   ~nsFont();
00113 
00114   PRBool operator==(const nsFont& aOther) const {
00115     return Equals(aOther);
00116   }
00117 
00118   PRBool Equals(const nsFont& aOther) const ;
00119 
00120   nsFont& operator=(const nsFont& aOther);
00121 
00122   // Utility method to interpret name string
00123   // enumerates all families specified by this font only
00124   // returns PR_TRUE if completed, PR_FALSE if stopped
00125   // enclosing quotes will be removed, and whitespace compressed (as needed)
00126   PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
00127   void GetFirstFamily(nsString& aFamily) const;
00128 
00129   // Utility method to return the ID of a generic font
00130   static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
00131 };
00132 
00133 #define NS_FONT_STYLE_NORMAL              0
00134 #define NS_FONT_STYLE_ITALIC              1
00135 #define NS_FONT_STYLE_OBLIQUE             2
00136 
00137 #define NS_FONT_VARIANT_NORMAL            0
00138 #define NS_FONT_VARIANT_SMALL_CAPS        1
00139 
00140 #define NS_FONT_DECORATION_NONE           0x0
00141 #define NS_FONT_DECORATION_UNDERLINE      0x1
00142 #define NS_FONT_DECORATION_OVERLINE       0x2
00143 #define NS_FONT_DECORATION_LINE_THROUGH   0x4
00144 
00145 #define NS_FONT_WEIGHT_NORMAL             400
00146 #define NS_FONT_WEIGHT_BOLD               700
00147 
00148 #endif /* nsFont_h___ */

Generated on Wed Sep 10 22:25:23 2003 for Mozilla SVG Project Rendering Backend by doxygen1.3