if (!mFont) { nsFont font; mSource->GetFont(&font);  cairo_font_slant_t slant; cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
SelectFont(mCT);
nsSVGCairoGlyphMetrics::Update(PRUint32 updatemask, PRBool *_retval){  *_retval = PR_FALSE;    if (updatemask & nsISVGGlyphMetricsSource::UPDATEMASK_CHARACTER_DATA) {    *_retval = PR_TRUE;  }  if (updatemask & nsISVGGlyphMetricsSource::UPDATEMASK_FONT) {    if (mFont) {      // don't delete mFont because we're just pointing at the ctx copy      mFont = NULL;    }    *_retval = PR_TRUE;  }  if (!mFont) {    nsFont font;    mSource->GetFont(&font);          cairo_font_slant_t slant;    cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;    switch (font.style) {    case NS_FONT_STYLE_NORMAL:      slant = CAIRO_FONT_SLANT_NORMAL;      break;    case NS_FONT_STYLE_ITALIC:      slant = CAIRO_FONT_SLANT_ITALIC;      break;    case NS_FONT_STYLE_OBLIQUE:      slant = CAIRO_FONT_SLANT_OBLIQUE;      break;    }    if (font.weight % 100 == 0) {      if (font.weight >= 600)	      weight = CAIRO_FONT_WEIGHT_BOLD;    } else if (font.weight % 100 < 50) {      weight = CAIRO_FONT_WEIGHT_BOLD;    }    nsString family;    font.GetFirstFamily(family);    char *f = ToNewCString(family);    cairo_select_font(mCT, f, slant, weight);    free(f);    nsCOMPtr<nsPresContext> presContext;    mSource->GetPresContext(getter_AddRefs(presContext));    float pxPerTwips;    pxPerTwips = presContext->TwipsToPixels();    cairo_scale_font(mCT, font.size*pxPerTwips);     mFont = cairo_current_font(mCT);    nsAutoString text;    mSource->GetCharacterData(text);    cairo_text_extents(mCT,                        (unsigned char*)NS_ConvertUCS2toUTF8(text).get(),                       &mExtents);  }    return NS_OK;}