2001-09-26 04:16:04 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-26 04:16:04 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 04:16:04 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-26 04:16:04 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-26 04:16:04 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 04:16:04 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 04:16:04 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#ifndef nsFont_h___
|
|
|
|
#define nsFont_h___
|
|
|
|
|
2004-05-18 22:09:16 +04:00
|
|
|
#include "gfxCore.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
// XXX we need a method to enumerate all of the possible fonts on the
|
|
|
|
// system across family, weight, style, size, etc. But not here!
|
|
|
|
|
1998-08-07 06:12:34 +04:00
|
|
|
// Enumerator callback function. Return PR_FALSE to stop
|
|
|
|
typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
|
|
|
|
|
2001-09-27 22:29:17 +04:00
|
|
|
// IDs for generic fonts
|
|
|
|
// NOTE: 0, 1 are reserved for the special IDs of the default variable
|
2004-08-01 03:15:21 +04:00
|
|
|
// and fixed fonts in the presentation context, see nsPresContext.h
|
2001-09-27 22:29:17 +04:00
|
|
|
const PRUint8 kGenericFont_NONE = 0x00;
|
|
|
|
// Special
|
|
|
|
const PRUint8 kGenericFont_moz_variable = 0x00; // for the default variable width font
|
|
|
|
const PRUint8 kGenericFont_moz_fixed = 0x01; // our special "use the user's fixed font"
|
|
|
|
// CSS
|
|
|
|
const PRUint8 kGenericFont_serif = 0x02;
|
|
|
|
const PRUint8 kGenericFont_sans_serif = 0x04;
|
|
|
|
const PRUint8 kGenericFont_monospace = 0x08;
|
|
|
|
const PRUint8 kGenericFont_cursive = 0x10;
|
|
|
|
const PRUint8 kGenericFont_fantasy = 0x20;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Font structure.
|
2001-09-24 13:07:53 +04:00
|
|
|
struct NS_GFX nsFont {
|
2001-09-24 19:26:39 +04:00
|
|
|
// The family name of the font
|
1998-04-14 00:24:54 +04:00
|
|
|
nsString name;
|
|
|
|
|
|
|
|
// The style of font (normal, italic, oblique)
|
2004-02-20 22:36:53 +03:00
|
|
|
unsigned int style : 7;
|
|
|
|
|
|
|
|
// Force this font to not be considered a 'generic' font, even if
|
|
|
|
// the name is the same as a CSS generic font family.
|
|
|
|
unsigned int systemFont : 1;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// The variant of the font (normal, small-caps)
|
2002-11-12 18:17:07 +03:00
|
|
|
PRUint8 variant : 7;
|
|
|
|
|
|
|
|
// True if the character set quirks (for treatment of "Symbol",
|
|
|
|
// "Wingdings", etc.) should be applied.
|
|
|
|
PRPackedBool familyNameQuirks : 1;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// The weight of the font (0-999)
|
|
|
|
PRUint16 weight;
|
|
|
|
|
|
|
|
// The decorations on the font (underline, overline,
|
|
|
|
// line-through). The decorations can be binary or'd together.
|
|
|
|
PRUint8 decorations;
|
|
|
|
|
2001-09-27 22:29:17 +04:00
|
|
|
// The logical size of the font, in nscoord units
|
1998-04-14 00:24:54 +04:00
|
|
|
nscoord size;
|
|
|
|
|
2001-09-27 22:29:17 +04:00
|
|
|
// The aspect-value (ie., the ratio actualsize:actualxheight) that any
|
|
|
|
// actual physical font created from this font structure must have when
|
|
|
|
// rendering or measuring a string. A value of 0 means no adjustment
|
|
|
|
// needs to be done.
|
|
|
|
float sizeAdjust;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Initialize the font struct with an iso-latin1 name
|
|
|
|
nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
2001-09-27 22:29:17 +04:00
|
|
|
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
|
|
|
float aSizeAdjust=0.0f);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Initialize the font struct with a (potentially) unicode name
|
|
|
|
nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
2001-09-27 22:29:17 +04:00
|
|
|
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
|
|
|
float aSizeAdjust=0.0f);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Make a copy of the given font
|
|
|
|
nsFont(const nsFont& aFont);
|
|
|
|
|
2001-09-27 22:29:17 +04:00
|
|
|
nsFont();
|
1998-04-14 00:24:54 +04:00
|
|
|
~nsFont();
|
|
|
|
|
|
|
|
PRBool operator==(const nsFont& aOther) const {
|
|
|
|
return Equals(aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool Equals(const nsFont& aOther) const ;
|
|
|
|
|
|
|
|
nsFont& operator=(const nsFont& aOther);
|
1998-08-07 06:12:34 +04:00
|
|
|
|
|
|
|
// Utility method to interpret name string
|
|
|
|
// enumerates all families specified by this font only
|
2001-09-27 22:29:17 +04:00
|
|
|
// returns PR_TRUE if completed, PR_FALSE if stopped
|
1998-08-07 06:12:34 +04:00
|
|
|
// enclosing quotes will be removed, and whitespace compressed (as needed)
|
|
|
|
PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
|
|
|
|
void GetFirstFamily(nsString& aFamily) const;
|
2001-09-27 22:29:17 +04:00
|
|
|
|
|
|
|
// Utility method to return the ID of a generic font
|
|
|
|
static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_FONT_STYLE_NORMAL 0
|
|
|
|
#define NS_FONT_STYLE_ITALIC 1
|
|
|
|
#define NS_FONT_STYLE_OBLIQUE 2
|
|
|
|
|
|
|
|
#define NS_FONT_VARIANT_NORMAL 0
|
|
|
|
#define NS_FONT_VARIANT_SMALL_CAPS 1
|
|
|
|
|
1998-09-17 04:13:15 +04:00
|
|
|
#define NS_FONT_DECORATION_NONE 0x0
|
1998-04-14 00:24:54 +04:00
|
|
|
#define NS_FONT_DECORATION_UNDERLINE 0x1
|
|
|
|
#define NS_FONT_DECORATION_OVERLINE 0x2
|
|
|
|
#define NS_FONT_DECORATION_LINE_THROUGH 0x4
|
|
|
|
|
|
|
|
#define NS_FONT_WEIGHT_NORMAL 400
|
|
|
|
#define NS_FONT_WEIGHT_BOLD 700
|
|
|
|
|
|
|
|
#endif /* nsFont_h___ */
|