2001-09-26 00:16:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#ifndef nsFont_h___
|
|
|
|
#define nsFont_h___
|
|
|
|
|
2004-05-18 18:09:16 +00:00
|
|
|
#include "gfxCore.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsCoord.h"
|
2005-11-17 20:06:22 +00:00
|
|
|
#include "nsStringGlue.h"
|
2009-01-29 20:39:18 +00:00
|
|
|
#include "gfxFontConstants.h"
|
2012-04-26 06:22:24 +00:00
|
|
|
#include "gfxFontFeatures.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// XXX we need a method to enumerate all of the possible fonts on the
|
|
|
|
// system across family, weight, style, size, etc. But not here!
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
// Enumerator callback function. Return false to stop
|
2011-09-29 06:19:26 +00:00
|
|
|
typedef bool (*nsFontFamilyEnumFunc)(const nsString& aFamily, bool aGeneric, void *aData);
|
1998-08-07 02:12:34 +00:00
|
|
|
|
2001-09-27 18:29:17 +00:00
|
|
|
// IDs for generic fonts
|
|
|
|
// NOTE: 0, 1 are reserved for the special IDs of the default variable
|
2004-07-31 23:15:21 +00:00
|
|
|
// and fixed fonts in the presentation context, see nsPresContext.h
|
2001-09-27 18:29:17 +00: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;
|
|
|
|
|
2012-05-04 19:45:03 +00:00
|
|
|
struct gfxFontStyle;
|
2012-04-26 06:22:24 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Font structure.
|
2001-09-24 09:07:53 +00:00
|
|
|
struct NS_GFX nsFont {
|
2001-09-24 15:26:39 +00:00
|
|
|
// The family name of the font
|
1998-04-13 20:24:54 +00:00
|
|
|
nsString name;
|
|
|
|
|
2009-01-29 20:39:18 +00:00
|
|
|
// The style of font (normal, italic, oblique; see gfxFontConstants.h)
|
2008-09-06 13:56:23 +00:00
|
|
|
PRUint8 style;
|
2004-02-20 19:36:53 +00:00
|
|
|
|
|
|
|
// Force this font to not be considered a 'generic' font, even if
|
|
|
|
// the name is the same as a CSS generic font family.
|
2008-09-06 13:56:23 +00:00
|
|
|
PRUint8 systemFont;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// The variant of the font (normal, small-caps)
|
2008-09-06 13:56:23 +00:00
|
|
|
PRUint8 variant;
|
2002-11-12 15:17:07 +00:00
|
|
|
|
2012-04-17 19:22:18 +00:00
|
|
|
// The decorations on the font (underline, overline,
|
|
|
|
// line-through). The decorations can be binary or'd together.
|
|
|
|
PRUint8 decorations;
|
|
|
|
|
2009-01-29 20:39:18 +00:00
|
|
|
// The weight of the font; see gfxFontConstants.h.
|
1998-04-13 20:24:54 +00:00
|
|
|
PRUint16 weight;
|
|
|
|
|
2009-01-29 20:39:18 +00:00
|
|
|
// The stretch of the font (the sum of various NS_FONT_STRETCH_*
|
|
|
|
// constants; see gfxFontConstants.h).
|
|
|
|
PRInt16 stretch;
|
|
|
|
|
2001-09-27 18:29:17 +00:00
|
|
|
// The logical size of the font, in nscoord units
|
1998-04-13 20:24:54 +00:00
|
|
|
nscoord size;
|
|
|
|
|
2001-09-27 18:29:17 +00: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;
|
|
|
|
|
2010-07-13 20:30:42 +00:00
|
|
|
// Font features from CSS font-feature-settings
|
2012-04-26 06:22:24 +00:00
|
|
|
nsTArray<gfxFontFeature> fontFeatureSettings;
|
|
|
|
|
2010-07-13 20:30:42 +00:00
|
|
|
// Language system tag, to override document language;
|
|
|
|
// this is an OpenType "language system" tag represented as a 32-bit integer
|
|
|
|
// (see http://www.microsoft.com/typography/otspec/languagetags.htm).
|
|
|
|
nsString languageOverride;
|
|
|
|
|
2006-06-21 16:35:03 +00:00
|
|
|
// Initialize the font struct with an ASCII name
|
1998-04-13 20:24:54 +00:00
|
|
|
nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
2009-01-29 20:39:18 +00:00
|
|
|
PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
|
2010-07-13 20:30:42 +00:00
|
|
|
nscoord aSize, float aSizeAdjust=0.0f,
|
|
|
|
const nsString* aLanguageOverride = nsnull);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// Initialize the font struct with a (potentially) unicode name
|
|
|
|
nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
2009-01-29 20:39:18 +00:00
|
|
|
PRUint16 aWeight, PRInt16 aStretch, PRUint8 aDecoration,
|
2010-07-13 20:30:42 +00:00
|
|
|
nscoord aSize, float aSizeAdjust=0.0f,
|
|
|
|
const nsString* aLanguageOverride = nsnull);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// Make a copy of the given font
|
|
|
|
nsFont(const nsFont& aFont);
|
|
|
|
|
2001-09-27 18:29:17 +00:00
|
|
|
nsFont();
|
1998-04-13 20:24:54 +00:00
|
|
|
~nsFont();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool operator==(const nsFont& aOther) const {
|
1998-04-13 20:24:54 +00:00
|
|
|
return Equals(aOther);
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool Equals(const nsFont& aOther) const ;
|
2007-01-17 02:16:22 +00:00
|
|
|
// Compare ignoring differences in 'variant' and 'decoration'
|
2011-09-29 06:19:26 +00:00
|
|
|
bool BaseEquals(const nsFont& aOther) const;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
nsFont& operator=(const nsFont& aOther);
|
1998-08-07 02:12:34 +00:00
|
|
|
|
2012-04-26 06:22:24 +00:00
|
|
|
// Add featureSettings into style
|
|
|
|
void AddFontFeaturesToStyle(gfxFontStyle *aStyle) const;
|
|
|
|
|
1998-08-07 02:12:34 +00:00
|
|
|
// Utility method to interpret name string
|
|
|
|
// enumerates all families specified by this font only
|
2011-10-17 14:59:28 +00:00
|
|
|
// returns true if completed, false if stopped
|
1998-08-07 02:12:34 +00:00
|
|
|
// enclosing quotes will be removed, and whitespace compressed (as needed)
|
2011-09-29 06:19:26 +00:00
|
|
|
bool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
|
1998-08-07 02:12:34 +00:00
|
|
|
void GetFirstFamily(nsString& aFamily) const;
|
2001-09-27 18:29:17 +00:00
|
|
|
|
|
|
|
// Utility method to return the ID of a generic font
|
|
|
|
static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_FONT_VARIANT_NORMAL 0
|
|
|
|
#define NS_FONT_VARIANT_SMALL_CAPS 1
|
|
|
|
|
1998-09-17 00:13:15 +00:00
|
|
|
#define NS_FONT_DECORATION_NONE 0x0
|
1998-04-13 20:24:54 +00:00
|
|
|
#define NS_FONT_DECORATION_UNDERLINE 0x1
|
|
|
|
#define NS_FONT_DECORATION_OVERLINE 0x2
|
|
|
|
#define NS_FONT_DECORATION_LINE_THROUGH 0x4
|
|
|
|
|
|
|
|
#endif /* nsFont_h___ */
|