本文整理汇总了C++中nsRenderingContext::FontMetrics方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRenderingContext::FontMetrics方法的具体用法?C++ nsRenderingContext::FontMetrics怎么用?C++ nsRenderingContext::FontMetrics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsRenderingContext
的用法示例。
在下文中一共展示了nsRenderingContext::FontMetrics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Equals
/* static */ void
nsMathMLFrame::GetRuleThickness(nsRenderingContext& aRenderingContext,
nsFontMetrics* aFontMetrics,
nscoord& aRuleThickness)
{
// get the bounding metrics of the overbar char, the rendering context
// is assumed to have been set with the font of the current style context
NS_ASSERTION(aRenderingContext.FontMetrics()->Font().
Equals(aFontMetrics->Font()),
"unexpected state");
nscoord xHeight = aFontMetrics->XHeight();
PRUnichar overBar = 0x00AF;
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&overBar, 1);
aRuleThickness = bm.ascent + bm.descent;
if (aRuleThickness <= 0 || aRuleThickness >= xHeight) {
// fall-back to the other version
GetRuleThickness(aFontMetrics, aRuleThickness);
}
}
示例2: ReflowError
nsresult
nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
PRBool 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);
aRenderingContext.SetFont(GetStyleFont()->mFont,
presContext->GetUserFontSet());
nsFontMetrics* fm = aRenderingContext.FontMetrics();
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);
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;
}
}
else {
// Rule 15d, App. G, TeXbook
// min clearance between numerator or denominator and middle of bar
//.........这里部分代码省略.........