equal
deleted
inserted
replaced
325 } |
325 } |
326 |
326 |
327 |
327 |
328 void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing) |
328 void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing) |
329 { |
329 { |
330 *ysize = fontDef.pixelSize << 6; |
330 *ysize = qRound(fontDef.pixelSize * 64); |
331 *xsize = *ysize * fontDef.stretch / 100; |
331 *xsize = *ysize * fontDef.stretch / 100; |
332 *outline_drawing = false; |
332 *outline_drawing = false; |
333 |
333 |
334 /* |
334 /* |
335 * Bitmap only faces must match exactly, so find the closest |
335 * Bitmap only faces must match exactly, so find the closest |
385 } else { |
385 } else { |
386 p.ascent = QFixed::fromFixed(face->size->metrics.ascender); |
386 p.ascent = QFixed::fromFixed(face->size->metrics.ascender); |
387 p.descent = QFixed::fromFixed(-face->size->metrics.descender); |
387 p.descent = QFixed::fromFixed(-face->size->metrics.descender); |
388 p.leading = QFixed::fromFixed(face->size->metrics.height - face->size->metrics.ascender + face->size->metrics.descender); |
388 p.leading = QFixed::fromFixed(face->size->metrics.height - face->size->metrics.ascender + face->size->metrics.descender); |
389 p.emSquare = face->size->metrics.y_ppem; |
389 p.emSquare = face->size->metrics.y_ppem; |
390 p.boundingBox = QRectF(-p.ascent.toReal(), 0, (p.ascent + p.descent).toReal(), face->size->metrics.max_advance/64.); |
390 // p.boundingBox = QRectF(-p.ascent.toReal(), 0, (p.ascent + p.descent).toReal(), face->size->metrics.max_advance/64.); |
|
391 p.boundingBox = QRectF(0, -p.ascent.toReal(), |
|
392 face->size->metrics.max_advance/64, (p.ascent + p.descent).toReal() ); |
391 } |
393 } |
392 p.italicAngle = 0; |
394 p.italicAngle = 0; |
393 p.capHeight = p.ascent; |
395 p.capHeight = p.ascent; |
394 p.lineWidth = face->underline_thickness; |
396 p.lineWidth = face->underline_thickness; |
395 return p; |
397 return p; |
707 hbFont.y_scale = face->size->metrics.y_scale; |
709 hbFont.y_scale = face->size->metrics.y_scale; |
708 |
710 |
709 hbFace = freetype->hbFace; |
711 hbFace = freetype->hbFace; |
710 |
712 |
711 metrics = face->size->metrics; |
713 metrics = face->size->metrics; |
|
714 |
712 #if defined(Q_WS_QWS) |
715 #if defined(Q_WS_QWS) |
713 /* |
716 /* |
714 TrueType fonts with embedded bitmaps may have a bitmap font specific |
717 TrueType fonts with embedded bitmaps may have a bitmap font specific |
715 ascent/descent in the EBLC table. There is no direct public API |
718 ascent/descent in the EBLC table. There is no direct public API |
716 to extract those values. The only way we've found is to trick freetype |
719 to extract those values. The only way we've found is to trick freetype |
750 int load_flags = FT_LOAD_DEFAULT | default_load_flags; |
753 int load_flags = FT_LOAD_DEFAULT | default_load_flags; |
751 if (set->outline_drawing) |
754 if (set->outline_drawing) |
752 load_flags = FT_LOAD_NO_BITMAP; |
755 load_flags = FT_LOAD_NO_BITMAP; |
753 |
756 |
754 // apply our matrix to this, but note that the metrics will not be affected by this. |
757 // apply our matrix to this, but note that the metrics will not be affected by this. |
755 FT_Matrix matrix = freetype->matrix; |
|
756 FT_Face face = lockFace(); |
758 FT_Face face = lockFace(); |
757 matrix = this->matrix; |
759 FT_Matrix matrix = this->matrix; |
758 FT_Matrix_Multiply(&set->transformationMatrix, &matrix); |
760 FT_Matrix_Multiply(&set->transformationMatrix, &matrix); |
759 FT_Set_Transform(face, &matrix, 0); |
761 FT_Set_Transform(face, &matrix, 0); |
760 freetype->matrix = matrix; |
762 freetype->matrix = matrix; |
761 |
763 |
762 bool transform = matrix.xx != 0x10000 || matrix.yy != 0x10000 || matrix.xy != 0 || matrix.yx != 0; |
764 bool transform = matrix.xx != 0x10000 || matrix.yy != 0x10000 || matrix.xy != 0 || matrix.yx != 0; |
1217 return QFixed::fromFixed(metrics.ascender); |
1219 return QFixed::fromFixed(metrics.ascender); |
1218 } |
1220 } |
1219 |
1221 |
1220 QFixed QFontEngineFT::descent() const |
1222 QFixed QFontEngineFT::descent() const |
1221 { |
1223 { |
1222 return QFixed::fromFixed(-metrics.descender); |
1224 // subtract a pixel to work around QFontMetrics's built-in + 1 |
|
1225 return QFixed::fromFixed(-metrics.descender - 64); |
1223 } |
1226 } |
1224 |
1227 |
1225 QFixed QFontEngineFT::leading() const |
1228 QFixed QFontEngineFT::leading() const |
1226 { |
1229 { |
1227 return QFixed::fromFixed(metrics.height - metrics.ascender + metrics.descender); |
1230 return QFixed::fromFixed(metrics.height - metrics.ascender + metrics.descender); |