Exemplo n.º 1
0
WFontMetrics WRasterImage::fontMetrics()
{
  struct SkPaint::FontMetrics metrics;
  impl_->textPaint_.getFontMetrics(&metrics);
  // assumed all are to be positive - ascent of skia is negative
  double ascent = -SkScalarToFloat(metrics.fAscent);
  double descent = SkScalarToFloat(metrics.fDescent);
  double leading = SkScalarToFloat(metrics.fLeading);

  return WFontMetrics(painter_->font(), leading, ascent, descent);
}
Exemplo n.º 2
0
WFontMetrics WPdfImage::fontMetrics()
{
  HPDF_Box bbox = HPDF_Font_GetBBox(font_);

  int ascent = HPDF_Font_GetAscent(font_);
  int descent = -HPDF_Font_GetDescent(font_);

  if (ascent == 0 && descent == 0) {
    ascent = bbox.top;
    descent = -bbox.bottom;
  }

  int leading = bbox.top - ascent;

  return WFontMetrics(painter()->font(),
		      fontSize_ * leading / 1000.0,
		      fontSize_ * ascent / 1000.0,
		      fontSize_ * descent / 1000.0);
}