本文整理汇总了C++中nsRenderingContext::SetFont方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRenderingContext::SetFont方法的具体用法?C++ nsRenderingContext::SetFont怎么用?C++ nsRenderingContext::SetFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsRenderingContext
的用法示例。
在下文中一共展示了nsRenderingContext::SetFont方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rect
void
nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
nsPoint aPt)
{
nsPresContext* pc = PresContext();
if (!mPD->mPrintSettings) {
if (pc->Type() == nsPresContext::eContext_PrintPreview || pc->IsDynamic())
mPD->mPrintSettings = pc->GetPrintSettings();
if (!mPD->mPrintSettings)
return;
}
nsRect rect(aPt, mRect.Size());
aRenderingContext.SetColor(NS_RGB(0,0,0));
// Get the FontMetrics to determine width.height of strings
nsRefPtr<nsFontMetrics> fontMet;
pc->DeviceContext()->GetMetricsFor(*mPD->mHeadFootFont, nullptr,
pc->GetUserFontSet(),
*getter_AddRefs(fontMet));
aRenderingContext.SetFont(fontMet);
nscoord ascent = 0;
nscoord visibleHeight = 0;
if (fontMet) {
visibleHeight = fontMet->MaxHeight();
ascent = fontMet->MaxAscent();
}
// print document headers and footers
nsXPIDLString headerLeft, headerCenter, headerRight;
mPD->mPrintSettings->GetHeaderStrLeft(getter_Copies(headerLeft));
mPD->mPrintSettings->GetHeaderStrCenter(getter_Copies(headerCenter));
mPD->mPrintSettings->GetHeaderStrRight(getter_Copies(headerRight));
DrawHeaderFooter(aRenderingContext, eHeader,
headerLeft, headerCenter, headerRight,
rect, ascent, visibleHeight);
nsXPIDLString footerLeft, footerCenter, footerRight;
mPD->mPrintSettings->GetFooterStrLeft(getter_Copies(footerLeft));
mPD->mPrintSettings->GetFooterStrCenter(getter_Copies(footerCenter));
mPD->mPrintSettings->GetFooterStrRight(getter_Copies(footerRight));
DrawHeaderFooter(aRenderingContext, eFooter,
footerLeft, footerCenter, footerRight,
rect, ascent, visibleHeight);
}
示例2: if
// exported routine that both munderover and msubsup share.
// munderover uses this when movablelimits is set.
nsresult
nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
nscoord aScriptSpace)
{
// force the scriptSpace to be atleast 1 pixel
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aScriptSpace = NS_MAX(onePixel, aScriptSpace);
////////////////////////////////////
// Get the children's desired sizes
nsHTMLReflowMetrics baseSize;
nsHTMLReflowMetrics subScriptSize;
nsHTMLReflowMetrics supScriptSize;
nsBoundingMetrics bmBase, bmSubScript, bmSupScript;
nsIFrame* subScriptFrame = nsnull;
nsIFrame* supScriptFrame = nsnull;
nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild();
if (baseFrame)
subScriptFrame = baseFrame->GetNextSibling();
if (subScriptFrame)
supScriptFrame = subScriptFrame->GetNextSibling();
if (!baseFrame || !subScriptFrame || !supScriptFrame ||
supScriptFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript);
GetReflowAndBoundingMetricsFor(supScriptFrame, supScriptSize, bmSupScript);
// get the subdrop from the subscript font
nscoord subDrop;
GetSubDropFromChild(subScriptFrame, subDrop);
// parameter v, Rule 18a, App. G, TeXbook
nscoord minSubScriptShift = bmBase.descent + subDrop;
// get the supdrop from the supscript font
nscoord supDrop;
GetSupDropFromChild(supScriptFrame, supDrop);
// parameter u, Rule 18a, App. G, TeXbook
nscoord minSupScriptShift = bmBase.ascent - supDrop;
//////////////////
// Place Children
//////////////////
//////////////////////////////////////////////////
// Get subscript shift
// slightly different from nsMathMLmsubFrame.cpp
//////////////////////////////////////////////////
// subScriptShift{1,2}
// = minimum amount to shift the subscript down
// = sub{1,2} in TeXbook
// subScriptShift1 = subscriptshift attribute * x-height
nscoord subScriptShift1, subScriptShift2;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
// get x-height (an ex)
nscoord xHeight = fm->XHeight();
nscoord ruleSize;
GetRuleThickness (aRenderingContext, fm, ruleSize);
// Get subScriptShift{1,2} default from font
GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
if (0 < aUserSubScriptShift) {
// the user has set the subscriptshift attribute
float scaler = ((float) subScriptShift2) / subScriptShift1;
subScriptShift1 = NS_MAX(subScriptShift1, aUserSubScriptShift);
subScriptShift2 = NSToCoordRound(scaler * subScriptShift1);
}
// get a tentative value for subscriptshift
// Rule 18d, App. G, TeXbook
nscoord subScriptShift =
NS_MAX(minSubScriptShift,NS_MAX(subScriptShift1,subScriptShift2));
//////////////////////////////////////////////////
// Get supscript shift
// same code from nsMathMLmsupFrame.cpp
//////////////////////////////////////////////////
// get min supscript shift limit from x-height
// = d(x) + 1/4 * sigma_5, Rule 18c, App. G, TeXbook
nscoord minShiftFromXHeight = (nscoord)
(bmSupScript.descent + (1.0f/4.0f) * xHeight);
//.........这里部分代码省略.........
示例3: if
// NOTE: aDesiredStretchSize is an IN/OUT parameter
// On input - it contains our current size
// On output - the same size or the new size that we want
NS_IMETHODIMP
nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize)
{
if (NS_MATHML_STRETCH_WAS_DONE(mPresentationData.flags)) {
NS_WARNING("it is wrong to fire stretch more than once on a frame");
return NS_OK;
}
mPresentationData.flags |= NS_MATHML_STRETCH_DONE;
nsIFrame* firstChild = mFrames.FirstChild();
// get the axis height;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
nscoord axisHeight, height;
GetAxisHeight(aRenderingContext, fm, axisHeight);
// get the leading to be left at the top and the bottom of the stretched char
// this seems more reliable than using fm->GetLeading() on suspicious fonts
nscoord em;
GetEmHeight(fm, em);
nscoord leading = NSToCoordRound(0.2f * em);
// Operators that are stretchy, or those that are to be centered
// to cater for fonts that are not math-aware, are handled by the MathMLChar
// ('form' is reset if stretch fails -- i.e., we don't bother to stretch next time)
bool useMathMLChar = UseMathMLChar();
nsBoundingMetrics charSize;
nsBoundingMetrics container = aDesiredStretchSize.mBoundingMetrics;
bool isVertical = false;
if (((aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL) ||
(aStretchDirection == NS_STRETCH_DIRECTION_DEFAULT)) &&
(mEmbellishData.direction == NS_STRETCH_DIRECTION_VERTICAL)) {
isVertical = true;
}
uint32_t stretchHint =
GetStretchHint(mFlags, mPresentationData, isVertical);
if (useMathMLChar) {
nsBoundingMetrics initialSize = aDesiredStretchSize.mBoundingMetrics;
if (stretchHint != NS_STRETCH_NONE) {
container = aContainerSize;
// some adjustments if the operator is symmetric and vertical
if (isVertical && NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
// we need to center about the axis
nscoord delta = std::max(container.ascent - axisHeight,
container.descent + axisHeight);
container.ascent = delta + axisHeight;
container.descent = delta - axisHeight;
// get ready in case we encounter user-desired min-max size
delta = std::max(initialSize.ascent - axisHeight,
initialSize.descent + axisHeight);
initialSize.ascent = delta + axisHeight;
initialSize.descent = delta - axisHeight;
}
// check for user-desired min-max size
if (mMaxSize != NS_MATHML_OPERATOR_SIZE_INFINITY && mMaxSize > 0.0f) {
// if we are here, there is a user defined maxsize ...
//XXX Set stretchHint = NS_STRETCH_NORMAL? to honor the maxsize as close as possible?
if (NS_MATHML_OPERATOR_MAXSIZE_IS_ABSOLUTE(mFlags)) {
// there is an explicit value like maxsize="20pt"
// try to maintain the aspect ratio of the char
float aspect = mMaxSize / float(initialSize.ascent + initialSize.descent);
container.ascent =
std::min(container.ascent, nscoord(initialSize.ascent * aspect));
container.descent =
std::min(container.descent, nscoord(initialSize.descent * aspect));
// below we use a type cast instead of a conversion to avoid a VC++ bug
// see http://support.microsoft.com/support/kb/articles/Q115/7/05.ASP
container.width =
std::min(container.width, (nscoord)mMaxSize);
}
else { // multiplicative value
container.ascent =
std::min(container.ascent, nscoord(initialSize.ascent * mMaxSize));
container.descent =
std::min(container.descent, nscoord(initialSize.descent * mMaxSize));
container.width =
std::min(container.width, nscoord(initialSize.width * mMaxSize));
}
if (isVertical && !NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
// re-adjust to align the char with the bottom of the initial container
//.........这里部分代码省略.........
示例4: if
/* virtual */ nsresult
nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
////////////////////////////////////
// Get the children's desired sizes
nscoord minShiftFromXHeight, subDrop, supDrop;
////////////////////////////////////////
// Initialize super/sub shifts that
// depend only on the current font
////////////////////////////////////////
ProcessAttributes();
// get x-height (an ex)
const nsStyleFont* font = GetStyleFont();
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
nscoord xHeight = fm->XHeight();
nscoord ruleSize;
GetRuleThickness (aRenderingContext, fm, ruleSize);
// scriptspace from TeX for extra spacing after sup/subscript (0.5pt in plain TeX)
// forced to be at least 1 pixel here
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord scriptSpace = NS_MAX(nsPresContext::CSSPointsToAppUnits(0.5f), onePixel);
/////////////////////////////////////
// first the shift for the subscript
// subScriptShift{1,2}
// = minimum amount to shift the subscript down
// = sub{1,2} in TeXbook
// subScriptShift1 = subscriptshift attribute * x-height
nscoord subScriptShift1, subScriptShift2;
// Get subScriptShift{1,2} default from font
GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
if (0 < mSubScriptShift) {
// the user has set the subscriptshift attribute
float scaler = ((float) subScriptShift2) / subScriptShift1;
subScriptShift1 = NS_MAX(subScriptShift1, mSubScriptShift);
subScriptShift2 = NSToCoordRound(scaler * subScriptShift1);
}
// the font dependent shift
nscoord subScriptShift = NS_MAX(subScriptShift1,subScriptShift2);
/////////////////////////////////////
// next the shift for the superscript
// supScriptShift{1,2,3}
// = minimum amount to shift the supscript up
// = sup{1,2,3} in TeX
// supScriptShift1 = superscriptshift attribute * x-height
// Note that there are THREE values for supscript shifts depending
// on the current style
nscoord supScriptShift1, supScriptShift2, supScriptShift3;
// Set supScriptShift{1,2,3} default from font
GetSupScriptShifts (fm, supScriptShift1, supScriptShift2, supScriptShift3);
if (0 < mSupScriptShift) {
// the user has set the superscriptshift attribute
float scaler2 = ((float) supScriptShift2) / supScriptShift1;
float scaler3 = ((float) supScriptShift3) / supScriptShift1;
supScriptShift1 = NS_MAX(supScriptShift1, mSupScriptShift);
supScriptShift2 = NSToCoordRound(scaler2 * supScriptShift1);
supScriptShift3 = NSToCoordRound(scaler3 * supScriptShift1);
}
// get sup script shift depending on current script level and display style
// Rule 18c, App. G, TeXbook
nscoord supScriptShift;
if ( font->mScriptLevel == 0 &&
NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags) &&
!NS_MATHML_IS_COMPRESSED(mPresentationData.flags)) {
// Style D in TeXbook
supScriptShift = supScriptShift1;
}
else if (NS_MATHML_IS_COMPRESSED(mPresentationData.flags)) {
// Style C' in TeXbook = D',T',S',SS'
supScriptShift = supScriptShift3;
}
else {
// everything else = T,S,SS
supScriptShift = supScriptShift2;
}
////////////////////////////////////
// Get the children's sizes
////////////////////////////////////
nscoord width = 0, prescriptsWidth = 0, rightBearing = 0;
nsIFrame* mprescriptsFrame = nsnull; // frame of <mprescripts/>, if there.
bool isSubScript = false;
nscoord minSubScriptShift = 0, minSupScriptShift = 0;
//.........这里部分代码省略.........
示例5: ReflowError
nsresult
nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
bool aWidthOnly)
{
////////////////////////////////////
// Get the children's desired sizes
nsBoundingMetrics bmNum, bmDen;
nsHTMLReflowMetrics sizeNum;
nsHTMLReflowMetrics sizeDen;
nsIFrame* frameDen = nsnull;
nsIFrame* frameNum = mFrames.FirstChild();
if (frameNum)
frameDen = frameNum->GetNextSibling();
if (!frameNum || !frameDen || frameDen->GetNextSibling()) {
// report an error, encourage people to get their markups in order
return ReflowError(aRenderingContext, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(frameNum, sizeNum, bmNum);
GetReflowAndBoundingMetricsFor(frameDen, sizeDen, bmDen);
nsPresContext* presContext = PresContext();
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
nscoord defaultRuleThickness, axisHeight;
GetRuleThickness(aRenderingContext, fm, defaultRuleThickness);
GetAxisHeight(aRenderingContext, fm, axisHeight);
nsEmbellishData coreData;
GetEmbellishDataFrom(mEmbellishData.coreFrame, coreData);
// see if the linethickness attribute is there
nsAutoString value;
GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::linethickness_,
value);
mLineThickness = CalcLineThickness(presContext, mStyleContext, value,
onePixel, defaultRuleThickness);
// bevelled attribute
GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::bevelled_,
value);
mIsBevelled = value.EqualsLiteral("true");
if (!mIsBevelled) {
mLineRect.height = mLineThickness;
// by default, leave at least one-pixel padding at either end, or use
// lspace & rspace that may come from <mo> if we are an embellished
// container (we fetch values from the core since they may use units that
// depend on style data, and style changes could have occurred in the
// core since our last visit there)
nscoord leftSpace = NS_MAX(onePixel, coreData.leftSpace);
nscoord rightSpace = NS_MAX(onePixel, coreData.rightSpace);
//////////////////
// Get shifts
nscoord numShift = 0;
nscoord denShift = 0;
// Rule 15b, App. G, TeXbook
nscoord numShift1, numShift2, numShift3;
nscoord denShift1, denShift2;
GetNumeratorShifts(fm, numShift1, numShift2, numShift3);
GetDenominatorShifts(fm, denShift1, denShift2);
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
// C > T
numShift = numShift1;
denShift = denShift1;
}
else {
numShift = (0 < mLineRect.height) ? numShift2 : numShift3;
denShift = denShift2;
}
nscoord minClearance = 0;
nscoord actualClearance = 0;
nscoord actualRuleThickness = mLineThickness;
if (0 == actualRuleThickness) {
// Rule 15c, App. G, TeXbook
// min clearance between numerator and denominator
minClearance = (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) ?
7 * defaultRuleThickness : 3 * defaultRuleThickness;
actualClearance =
(numShift - bmNum.descent) - (bmDen.ascent - denShift);
// actualClearance should be >= minClearance
if (actualClearance < minClearance) {
nscoord halfGap = (minClearance - actualClearance)/2;
numShift += halfGap;
denShift += halfGap;
}
//.........这里部分代码省略.........
示例6: DidReflowChildren
/* virtual */ nsresult
nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
bool aWidthOnly)
{
///////////////
// Measure the size of our content using the base class to format like an
// inferred mrow.
nsHTMLReflowMetrics baseSize;
nsresult rv =
nsMathMLContainerFrame::Place(aRenderingContext, false, baseSize);
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
DidReflowChildren(GetFirstPrincipalChild());
return rv;
}
nsBoundingMetrics bmBase = baseSize.mBoundingMetrics;
nscoord dx_left = 0, dx_right = 0;
nsBoundingMetrics bmLongdivChar, bmRadicalChar;
nscoord radicalAscent = 0, radicalDescent = 0;
nscoord longdivAscent = 0, longdivDescent = 0;
nscoord psi = 0;
///////////////
// Thickness of bars and font metrics
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord mEmHeight;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
GetRuleThickness(aRenderingContext, fm, mRuleThickness);
GetEmHeight(fm, mEmHeight);
PRUnichar one = '1';
nsBoundingMetrics bmOne = aRenderingContext.GetBoundingMetrics(&one, 1);
///////////////
// General rules: the menclose element takes the size of the enclosed content.
// We add a padding when needed.
// determine padding & psi
nscoord padding = 3 * mRuleThickness;
nscoord delta = padding % onePixel;
if (delta)
padding += onePixel - delta; // round up
if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) {
nscoord phi;
// Rule 11, App. G, TeXbook
// psi = clearance between rule and content
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
phi = fm->XHeight();
else
phi = mRuleThickness;
psi = mRuleThickness + phi / 4;
delta = psi % onePixel;
if (delta)
psi += onePixel - delta; // round up
}
if (mRuleThickness < onePixel)
mRuleThickness = onePixel;
// Set horizontal parameters
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
IsToDraw(NOTATION_TOP) ||
IsToDraw(NOTATION_LEFT) ||
IsToDraw(NOTATION_BOTTOM) ||
IsToDraw(NOTATION_CIRCLE))
dx_left = padding;
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
IsToDraw(NOTATION_TOP) ||
IsToDraw(NOTATION_RIGHT) ||
IsToDraw(NOTATION_BOTTOM) ||
IsToDraw(NOTATION_CIRCLE))
dx_right = padding;
// Set vertical parameters
if (IsToDraw(NOTATION_RIGHT) ||
IsToDraw(NOTATION_LEFT) ||
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
IsToDraw(NOTATION_VERTICALSTRIKE) ||
IsToDraw(NOTATION_CIRCLE) ||
IsToDraw(NOTATION_ROUNDEDBOX) ||
IsToDraw(NOTATION_RADICAL) ||
IsToDraw(NOTATION_LONGDIV)) {
// set a minimal value for the base height
bmBase.ascent = NS_MAX(bmOne.ascent, bmBase.ascent);
bmBase.descent = NS_MAX(0, bmBase.descent);
}
mBoundingMetrics.ascent = bmBase.ascent;
mBoundingMetrics.descent = bmBase.descent;
//.........这里部分代码省略.........
示例7: if
// exported routine that both munderover and mmultiscripts share.
// munderover uses this when movablelimits is set.
nsresult
nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
nscoord aScriptSpace)
{
nsIAtom* tag = aFrame->GetContent()->Tag();
// This function deals with both munderover etc. as well as msubsup etc.
// As the former behaves identically to the later, we treat it as such
// to avoid additional checks later.
if (tag == nsGkAtoms::mover_)
tag = nsGkAtoms::msup_;
else if (tag == nsGkAtoms::munder_)
tag = nsGkAtoms::msub_;
else if (tag == nsGkAtoms::munderover_)
tag = nsGkAtoms::msubsup_;
nsBoundingMetrics bmFrame;
nscoord minShiftFromXHeight, subDrop, supDrop;
////////////////////////////////////////
// Initialize super/sub shifts that
// depend only on the current font
////////////////////////////////////////
nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild();
if (!baseFrame) {
if (tag == nsGkAtoms::mmultiscripts_)
aFrame->ReportErrorToConsole("NoBase");
else
aFrame->ReportChildCountError();
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
}
// get x-height (an ex)
const nsStyleFont* font = aFrame->StyleFont();
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
nscoord xHeight = fm->XHeight();
nscoord ruleSize;
GetRuleThickness (aRenderingContext, fm, ruleSize);
// force the scriptSpace to be at least 1 pixel
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aScriptSpace = std::max(onePixel, aScriptSpace);
/////////////////////////////////////
// first the shift for the subscript
// subScriptShift{1,2}
// = minimum amount to shift the subscript down
// = sub{1,2} in TeXbook
// subScriptShift1 = subscriptshift attribute * x-height
nscoord subScriptShift1, subScriptShift2;
// Get subScriptShift{1,2} default from font
GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
nscoord subScriptShift;
if (tag == nsGkAtoms::msub_) {
subScriptShift = subScriptShift1;
} else {
subScriptShift = std::max(subScriptShift1, subScriptShift2);
}
if (0 < aUserSubScriptShift) {
// the user has set the subscriptshift attribute
subScriptShift = std::max(subScriptShift, aUserSubScriptShift);
}
/////////////////////////////////////
// next the shift for the superscript
// supScriptShift{1,2,3}
// = minimum amount to shift the supscript up
// = sup{1,2,3} in TeX
// supScriptShift1 = superscriptshift attribute * x-height
// Note that there are THREE values for supscript shifts depending
// on the current style
nscoord supScriptShift1, supScriptShift2, supScriptShift3;
// Set supScriptShift{1,2,3} default from font
GetSupScriptShifts (fm, supScriptShift1, supScriptShift2, supScriptShift3);
// get sup script shift depending on current script level and display style
// Rule 18c, App. G, TeXbook
nsPresentationData presentationData;
aFrame->GetPresentationData(presentationData);
nscoord supScriptShift;
if (font->mScriptLevel == 0 &&
//.........这里部分代码省略.........