1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef GFX_MATH_TABLE_H
6 #define GFX_MATH_TABLE_H
11 * Used by |gfxFont| to represent the MATH table of an OpenType font.
12 * Each |gfxFont| owns at most one |gfxMathTable| instance.
18 * @param aFace The HarfBuzz face containing the math table.
19 * @param aSize The font size to pass to HarfBuzz.
21 gfxMathTable(hb_face_t
*aFace
, gfxFloat aSize
);
24 * Releases our reference to the MATH table and cleans up everything else.
29 // The order of the constants must match the order of the fields
30 // defined in the MATH table.
31 ScriptPercentScaleDown
,
32 ScriptScriptPercentScaleDown
,
33 DelimitedSubFormulaMinHeight
,
34 DisplayOperatorMinHeight
,
38 FlattenedAccentBaseHeight
,
41 SubscriptBaselineDropMin
,
43 SuperscriptShiftUpCramped
,
45 SuperscriptBaselineDropMax
,
47 SuperscriptBottomMaxWithSubscript
,
50 UpperLimitBaselineRiseMin
,
52 LowerLimitBaselineDropMin
,
54 StackTopDisplayStyleShiftUp
,
56 StackBottomDisplayStyleShiftDown
,
58 StackDisplayStyleGapMin
,
59 StretchStackTopShiftUp
,
60 StretchStackBottomShiftDown
,
61 StretchStackGapAboveMin
,
62 StretchStackGapBelowMin
,
63 FractionNumeratorShiftUp
,
64 FractionNumeratorDisplayStyleShiftUp
,
65 FractionDenominatorShiftDown
,
66 FractionDenominatorDisplayStyleShiftDown
,
67 FractionNumeratorGapMin
,
68 FractionNumDisplayStyleGapMin
,
69 FractionRuleThickness
,
70 FractionDenominatorGapMin
,
71 FractionDenomDisplayStyleGapMin
,
72 SkewedFractionHorizontalGap
,
73 SkewedFractionVerticalGap
,
78 UnderbarRuleThickness
,
79 UnderbarExtraDescender
,
81 RadicalDisplayStyleVerticalGap
,
84 RadicalKernBeforeDegree
,
85 RadicalKernAfterDegree
,
86 RadicalDegreeBottomRaisePercent
90 * Returns the value of the specified constant from the MATH table.
92 gfxFloat
Constant(MathConstant aConstant
) const;
95 * Returns the value of the specified constant in app units.
97 nscoord
Constant(MathConstant aConstant
,
98 uint32_t aAppUnitsPerDevPixel
) const
100 return NSToCoordRound(Constant(aConstant
) * aAppUnitsPerDevPixel
);
104 * If the MATH table contains an italic correction for that glyph, this
105 * function returns the corresponding value. Otherwise it returns 0.
108 ItalicsCorrection(uint32_t aGlyphID
) const;
111 * @param aGlyphID glyph index of the character we want to stretch
112 * @param aVertical direction of the stretching (vertical/horizontal)
113 * @param aSize the desired size variant
115 * Returns the glyph index of the desired size variant or 0 if there is not
116 * any such size variant.
118 uint32_t VariantsSize(uint32_t aGlyphID
, bool aVertical
,
119 uint16_t aSize
) const;
122 * @param aGlyphID glyph index of the character we want to stretch
123 * @param aVertical direction of the stretching (vertical/horizontal)
124 * @param aGlyphs pre-allocated buffer of 4 elements where the glyph
125 * indexes (or 0 for absent parts) will be stored. The parts are stored in
126 * the order expected by the nsMathMLChar: Top (or Left), Middle, Bottom
129 * Tries to fill-in aGlyphs with the relevant glyph indexes and returns
130 * whether the operation was successful. The function returns false if
131 * there is not any assembly for the character we want to stretch or if
132 * the format is not supported by the nsMathMLChar code.
135 bool VariantsParts(uint32_t aGlyphID
, bool aVertical
,
136 uint32_t aGlyphs
[4]) const;
139 // size-specific font object, owned by the gfxMathTable
142 static const unsigned int kMaxCachedSizeCount
= 10;
143 struct MathVariantCacheEntry
{
146 uint32_t sizes
[kMaxCachedSizeCount
];
150 mutable MathVariantCacheEntry mMathVariantCache
;
151 void ClearCache() const;
152 void UpdateMathVariantCache(uint32_t aGlyphID
, bool aVertical
) const;