if (face.EqualsIgnoreCase("monospace")) { font->mFont = font->mFixedFont;
if (face.EqualsIgnoreCase("-moz-fixed")) { font->mFlags |= NS_STYLE_FONT_USE_FIXED;
void MapDeclarationFontInto(nsICSSDeclaration* aDeclaration,                             nsIStyleContext* aContext, nsIPresContext* aPresContext){  if (nsnull != aDeclaration) {    nsIStyleContext* parentContext = aContext->GetParent();    nsStyleFont*  font = (nsStyleFont*)aContext->GetMutableStyleData(eStyleStruct_Font);    const nsStyleFont* parentFont = font;    if (nsnull != parentContext) {      parentFont = (const nsStyleFont*)parentContext->GetStyleData(eStyleStruct_Font);    }    nsCSSFont*  ourFont;    if (NS_OK == aDeclaration->GetData(kCSSFontSID, (nsCSSStruct**)&ourFont)) {      if (nsnull != ourFont) {        const nsFont& defaultFont = aPresContext->GetDefaultFontDeprecated();        const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFontDeprecated();        // font-family: string list, enum, inherit        if (eCSSUnit_String == ourFont->mFamily.GetUnit()) {          nsCOMPtr<nsIDeviceContext> dc;          aPresContext->GetDeviceContext(getter_AddRefs(dc));          if (dc) {            nsAutoString  familyList;            ourFont->mFamily.GetStringValue(familyList);            font->mFont.name = familyList;            nsAutoString  face;            if (NS_OK == dc->FirstExistingFont(font->mFont, face)) {              if (face.EqualsIgnoreCase("monospace")) {                font->mFont = font->mFixedFont;              }              else {                font->mFixedFont.name = familyList;              }            }            else {              font->mFont.name = defaultFont.name;              font->mFixedFont.name = defaultFixedFont.name;            }            font->mFlags |= NS_STYLE_FONT_FACE_EXPLICIT;          }        }        else if (eCSSUnit_Enumerated == ourFont->mFamily.GetUnit()) {          NS_NOTYETIMPLEMENTED("system font");        }        else if (eCSSUnit_Inherit == ourFont->mFamily.GetUnit()) {          font->mFont.name = parentFont->mFont.name;          font->mFixedFont.name = parentFont->mFixedFont.name;          font->mFlags &= ~NS_STYLE_FONT_FACE_EXPLICIT;          font->mFlags |= (parentFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT);        }        // font-style: enum, normal, inherit        if (eCSSUnit_Enumerated == ourFont->mStyle.GetUnit()) {          font->mFont.style = ourFont->mStyle.GetIntValue();          font->mFixedFont.style = ourFont->mStyle.GetIntValue();        }        else if (eCSSUnit_Normal == ourFont->mStyle.GetUnit()) {          font->mFont.style = NS_STYLE_FONT_STYLE_NORMAL;          font->mFixedFont.style = NS_STYLE_FONT_STYLE_NORMAL;        }        else if (eCSSUnit_Inherit == ourFont->mStyle.GetUnit()) {          font->mFont.style = parentFont->mFont.style;          font->mFixedFont.style = parentFont->mFixedFont.style;        }        // font-variant: enum, normal, inherit        if (eCSSUnit_Enumerated == ourFont->mVariant.GetUnit()) {          font->mFont.variant = ourFont->mVariant.GetIntValue();          font->mFixedFont.variant = ourFont->mVariant.GetIntValue();        }        else if (eCSSUnit_Normal == ourFont->mVariant.GetUnit()) {          font->mFont.variant = NS_STYLE_FONT_VARIANT_NORMAL;          font->mFixedFont.variant = NS_STYLE_FONT_VARIANT_NORMAL;        }        else if (eCSSUnit_Inherit == ourFont->mVariant.GetUnit()) {          font->mFont.variant = parentFont->mFont.variant;          font->mFixedFont.variant = parentFont->mFixedFont.variant;        }        // font-weight: int, enum, normal, inherit        if (eCSSUnit_Integer == ourFont->mWeight.GetUnit()) {          font->mFont.weight = ourFont->mWeight.GetIntValue();          font->mFixedFont.weight = ourFont->mWeight.GetIntValue();        }        else if (eCSSUnit_Enumerated == ourFont->mWeight.GetUnit()) {          PRInt32 value = ourFont->mWeight.GetIntValue();          switch (value) {            case NS_STYLE_FONT_WEIGHT_NORMAL:            case NS_STYLE_FONT_WEIGHT_BOLD:              font->mFont.weight = value;              font->mFixedFont.weight = value;              break;            case NS_STYLE_FONT_WEIGHT_BOLDER:            case NS_STYLE_FONT_WEIGHT_LIGHTER:              font->mFont.weight = (parentFont->mFont.weight + value);              font->mFixedFont.weight = (parentFont->mFixedFont.weight + value);              break;          }        }        else if (eCSSUnit_Normal == ourFont->mWeight.GetUnit()) {          font->mFont.weight = NS_STYLE_FONT_WEIGHT_NORMAL;          font->mFixedFont.weight = NS_STYLE_FONT_WEIGHT_NORMAL;        }        else if (eCSSUnit_Inherit == ourFont->mWeight.GetUnit()) {          font->mFont.weight = parentFont->mFont.weight;          font->mFixedFont.weight = parentFont->mFixedFont.weight;        }        // font-size: enum, length, percent, inherit        if (eCSSUnit_Enumerated == ourFont->mSize.GetUnit()) {          PRInt32 value = ourFont->mSize.GetIntValue();          PRInt32 scaler;          aPresContext->GetFontScaler(&scaler);          float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);          if ((NS_STYLE_FONT_SIZE_XXSMALL <= value) &&               (value <= NS_STYLE_FONT_SIZE_XXLARGE)) {            font->mFont.size = nsStyleUtil::CalcFontPointSize(value, (PRInt32)defaultFont.size, scaleFactor);            font->mFixedFont.size = nsStyleUtil::CalcFontPointSize(value, (PRInt32)defaultFixedFont.size, scaleFactor);          }          else if (NS_STYLE_FONT_SIZE_LARGER == value) {            PRInt32 index = nsStyleUtil::FindNextLargerFontSize(parentFont->mFont.size, (PRInt32)defaultFont.size, scaleFactor);            font->mFont.size = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFont.size, scaleFactor);            font->mFixedFont.size = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFixedFont.size, scaleFactor);          }          else if (NS_STYLE_FONT_SIZE_SMALLER == value) {            PRInt32 index = nsStyleUtil::FindNextSmallerFontSize(parentFont->mFont.size, (PRInt32)defaultFont.size, scaleFactor);            font->mFont.size = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFont.size, scaleFactor);            font->mFixedFont.size = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFixedFont.size, scaleFactor);          }          // this does NOT explicitly set font size          font->mFlags &= ~NS_STYLE_FONT_SIZE_EXPLICIT;        }        else if (ourFont->mSize.IsLengthUnit()) {          font->mFont.size = CalcLength(ourFont->mSize, parentFont, aPresContext);          font->mFixedFont.size = CalcLength(ourFont->mSize, parentFont, aPresContext);          font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;        }        else if (eCSSUnit_Percent == ourFont->mSize.GetUnit()) {          font->mFont.size = (nscoord)((float)(parentFont->mFont.size) * ourFont->mSize.GetPercentValue());          font->mFixedFont.size = (nscoord)((float)(parentFont->mFixedFont.size) * ourFont->mSize.GetPercentValue());          font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;        }        else if (eCSSUnit_Inherit == ourFont->mSize.GetUnit()) {          font->mFont.size = parentFont->mFont.size;          font->mFixedFont.size = parentFont->mFixedFont.size;          font->mFlags &= ~NS_STYLE_FONT_SIZE_EXPLICIT;          font->mFlags |= (parentFont->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT);        }      }    }    NS_IF_RELEASE(parentContext);  }}