LCOV - code coverage report
Current view: top level - gfx/src - nsFont.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 5 60.0 %
Date: 2017-07-14 16:53:18 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef nsFont_h___
       7             : #define nsFont_h___
       8             : 
       9             : #include <stdint.h>                     // for uint8_t, uint16_t
      10             : #include <sys/types.h>                  // for int16_t
      11             : #include "gfxFontFamilyList.h"
      12             : #include "gfxFontConstants.h"           // for NS_FONT_KERNING_AUTO, etc
      13             : #include "gfxFontFeatures.h"
      14             : #include "gfxFontVariations.h"
      15             : #include "mozilla/RefPtr.h"             // for RefPtr
      16             : #include "nsCoord.h"                    // for nscoord
      17             : #include "nsStringFwd.h"                // for nsAString
      18             : #include "nsString.h"               // for nsString
      19             : #include "nsTArray.h"                   // for nsTArray
      20             : 
      21             : struct gfxFontStyle;
      22             : 
      23             : // XXX we need a method to enumerate all of the possible fonts on the
      24             : // system across family, weight, style, size, etc. But not here!
      25             : 
      26             : // Enumerator callback function. Return false to stop
      27             : typedef bool (*nsFontFamilyEnumFunc)(const nsString& aFamily, bool aGeneric, void *aData);
      28             : 
      29             : // IDs for generic fonts
      30             : // NOTE: 0, 1 are reserved for the special IDs of the default variable
      31             : // and fixed fonts in the presentation context, see nsPresContext.h
      32             : const uint8_t kGenericFont_NONE         = 0x00;
      33             : // Special
      34             : const uint8_t kGenericFont_moz_variable = 0x00; // for the default variable width font
      35             : const uint8_t kGenericFont_moz_fixed    = 0x01; // our special "use the user's fixed font"
      36             : // CSS
      37             : const uint8_t kGenericFont_serif        = 0x02;
      38             : const uint8_t kGenericFont_sans_serif   = 0x04;
      39             : const uint8_t kGenericFont_monospace    = 0x08;
      40             : const uint8_t kGenericFont_cursive      = 0x10;
      41             : const uint8_t kGenericFont_fantasy      = 0x20;
      42             : 
      43             : // Font structure.
      44         111 : struct nsFont {
      45             : 
      46             :   // list of font families, either named or generic
      47             :   mozilla::FontFamilyList fontlist;
      48             : 
      49             :   // The style of font (normal, italic, oblique; see gfxFontConstants.h)
      50             :   uint8_t style = NS_FONT_STYLE_NORMAL;
      51             : 
      52             :   // Force this font to not be considered a 'generic' font, even if
      53             :   // the name is the same as a CSS generic font family.
      54             :   bool systemFont = false;
      55             : 
      56             :   // Variant subproperties
      57             :   uint8_t variantCaps = NS_FONT_VARIANT_CAPS_NORMAL;
      58             :   uint8_t variantNumeric = NS_FONT_VARIANT_NUMERIC_NORMAL;
      59             :   uint8_t variantPosition = NS_FONT_VARIANT_POSITION_NORMAL;
      60             :   uint8_t variantWidth = NS_FONT_VARIANT_WIDTH_NORMAL;
      61             : 
      62             :   uint16_t variantLigatures = NS_FONT_VARIANT_LIGATURES_NORMAL;
      63             :   uint16_t variantEastAsian = NS_FONT_VARIANT_EAST_ASIAN_NORMAL;
      64             : 
      65             :   // Some font-variant-alternates property values require
      66             :   // font-specific settings defined via @font-feature-values rules.
      67             :   // These are resolved *after* font matching occurs.
      68             : 
      69             :   // -- bitmask for both enumerated and functional propvals
      70             :   uint16_t variantAlternates = NS_FONT_VARIANT_ALTERNATES_NORMAL;
      71             : 
      72             :   // Smoothing - controls subpixel-antialiasing (currently OSX only)
      73             :   uint8_t smoothing = NS_FONT_SMOOTHING_AUTO;
      74             : 
      75             :   // The weight of the font; see gfxFontConstants.h.
      76             :   uint16_t weight = NS_FONT_WEIGHT_NORMAL;
      77             : 
      78             :   // The stretch of the font (the sum of various NS_FONT_STRETCH_*
      79             :   // constants; see gfxFontConstants.h).
      80             :   int16_t stretch = NS_FONT_STRETCH_NORMAL;
      81             : 
      82             :   // Kerning
      83             :   uint8_t kerning = NS_FONT_KERNING_AUTO;
      84             : 
      85             :   // Synthesis setting, controls use of fake bolding/italics
      86             :   uint8_t synthesis = NS_FONT_SYNTHESIS_WEIGHT | NS_FONT_SYNTHESIS_STYLE;
      87             : 
      88             :   // The logical size of the font, in nscoord units
      89             :   nscoord size = 0;
      90             : 
      91             :   // The aspect-value (ie., the ratio actualsize:actualxheight) that any
      92             :   // actual physical font created from this font structure must have when
      93             :   // rendering or measuring a string. A value of -1.0 means no adjustment
      94             :   // needs to be done; otherwise the value must be nonnegative.
      95             :   float sizeAdjust = -1.0f;
      96             : 
      97             :   // -- list of value tags for font-specific alternate features
      98             :   nsTArray<gfxAlternateValue> alternateValues;
      99             : 
     100             :   // -- object used to look these up once the font is matched
     101             :   RefPtr<gfxFontFeatureValueSet> featureValueLookup;
     102             : 
     103             :   // Font features from CSS font-feature-settings
     104             :   nsTArray<gfxFontFeature> fontFeatureSettings;
     105             : 
     106             :   // Font variations from CSS font-variation-settings
     107             :   nsTArray<gfxFontVariation> fontVariationSettings;
     108             : 
     109             :   // Language system tag, to override document language;
     110             :   // this is an OpenType "language system" tag represented as a 32-bit integer
     111             :   // (see http://www.microsoft.com/typography/otspec/languagetags.htm).
     112             :   uint32_t languageOverride = 0;
     113             : 
     114             :   // initialize the font with a fontlist
     115             :   nsFont(const mozilla::FontFamilyList& aFontlist, nscoord aSize);
     116             : 
     117             :   // initialize the font with a single generic
     118             :   nsFont(mozilla::FontFamilyType aGenericType, nscoord aSize);
     119             : 
     120             :   // Make a copy of the given font
     121             :   nsFont(const nsFont& aFont);
     122             : 
     123             :   // leave members uninitialized
     124             :   nsFont();
     125             : 
     126             :   ~nsFont();
     127             : 
     128           0 :   bool operator==(const nsFont& aOther) const {
     129           0 :     return Equals(aOther);
     130             :   }
     131             : 
     132          36 :   bool operator!=(const nsFont& aOther) const {
     133          36 :     return !Equals(aOther);
     134             :   }
     135             : 
     136             :   bool Equals(const nsFont& aOther) const;
     137             : 
     138             :   nsFont& operator=(const nsFont& aOther);
     139             : 
     140             :   void CopyAlternates(const nsFont& aOther);
     141             : 
     142             :   // Add featureSettings into style
     143             :   void AddFontFeaturesToStyle(gfxFontStyle *aStyle) const;
     144             : 
     145             :   void AddFontVariationsToStyle(gfxFontStyle *aStyle) const;
     146             : };
     147             : 
     148             : #define NS_FONT_VARIANT_NORMAL            0
     149             : #define NS_FONT_VARIANT_SMALL_CAPS        1
     150             : 
     151             : #endif /* nsFont_h___ */

Generated by: LCOV version 1.13