nsMathMLFrame::GetRuleThickness(nsIRenderingContext& aRenderingContext, nsIFontMetrics*      aFontMetrics, nscoord&             aRuleThickness) {   #ifdef NS_DEBUG nsCOMPtr<nsIFontMetrics> currFontMetrics; aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics)); NS_ASSERTION(currFontMetrics->Font().Equals(aFontMetrics->Font()), "unexpected state"); #endif nscoord xHeight; aFontMetrics->GetXHeight(xHeight); PRUnichar overBar = 0x00AF; nsBoundingMetrics bm; nsresult rv = aRenderingContext.GetBoundingMetrics(&overBar, PRUint32(1), bm); if (NS_SUCCEEDED(rv)) { aRuleThickness = bm.ascent + bm.descent;
GetRuleThickness(nsIFontMetrics* fm, nscoord&        ruleThickness) { nscoord xHeight; fm->GetXHeight(xHeight); ruleThickness = NSToCoordRound(40.000f/430.556f * xHeight);
nsMathMLFrame::GetRuleThickness(nsIRenderingContext& aRenderingContext,                                nsIFontMetrics*      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#ifdef NS_DEBUG  nsCOMPtr<nsIFontMetrics> currFontMetrics;  aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics));  NS_ASSERTION(currFontMetrics->Font().Equals(aFontMetrics->Font()),      "unexpected state");#endif  nscoord xHeight;  aFontMetrics->GetXHeight(xHeight);  PRUnichar overBar = 0x00AF;  nsBoundingMetrics bm;  nsresult rv = aRenderingContext.GetBoundingMetrics(&overBar, PRUint32(1), bm);  if (NS_SUCCEEDED(rv)) {    aRuleThickness = bm.ascent + bm.descent;  }  if (NS_FAILED(rv) || aRuleThickness <= 0 || aRuleThickness >= xHeight) {    // fall-back to the other version    GetRuleThickness(aFontMetrics, aRuleThickness);  }#if 0  nscoord oldRuleThickness;  GetRuleThickness(aFontMetrics, oldRuleThickness);  PRUnichar sqrt = 0xE063; // a sqrt glyph from TeX's CMEX font  rv = aRenderingContext.GetBoundingMetrics(&sqrt, PRUint32(1), bm);  nscoord sqrtrule = bm.ascent; // according to TeX, the ascent should be the rule  printf("xheight:%4d rule:%4d oldrule:%4d  sqrtrule:%4d\n",          xHeight, aRuleThickness, oldRuleThickness, sqrtrule);#endif}