@@ -831,7 +831,13 @@ static void convertCGPathToQPainterPath(void *info, const CGPathElement *element
831
831
832
832
QFontEngine::FaceId QCoreTextFontEngine::faceId () const
833
833
{
834
- return QFontEngine::FaceId ();
834
+ FaceId result;
835
+ result.index = 0 ;
836
+
837
+ QCFString name = CTFontCopyName (ctfont, kCTFontUniqueNameKey );
838
+ result.filename = QCFString::toQString (name).toUtf8 ();
839
+
840
+ return result;
835
841
}
836
842
837
843
bool QCoreTextFontEngine::canRender (const QChar *string, int len)
@@ -856,9 +862,26 @@ static void convertCGPathToQPainterPath(void *info, const CGPathElement *element
856
862
return true ;
857
863
}
858
864
859
- void QCoreTextFontEngine::getUnscaledGlyph (glyph_t , QPainterPath *, glyph_metrics_t *)
865
+ void QCoreTextFontEngine::getUnscaledGlyph (glyph_t glyph , QPainterPath *path , glyph_metrics_t *metric )
860
866
{
861
- // ###
867
+ CGAffineTransform cgMatrix = CGAffineTransformIdentity;
868
+
869
+ qreal emSquare = CTFontGetUnitsPerEm (ctfont);
870
+ qreal scale = emSquare / CTFontGetSize (ctfont);
871
+ cgMatrix = CGAffineTransformScale (cgMatrix, scale, -scale);
872
+
873
+ QCFType<CGPathRef> cgpath = CTFontCreatePathForGlyph (ctfont, (CGGlyph) glyph, &cgMatrix);
874
+ ConvertPathInfo info (path, QPointF (0 ,0 ));
875
+ CGPathApply (cgpath, &info, convertCGPathToQPainterPath);
876
+
877
+ *metric = boundingBox (glyph);
878
+ // scale the metrics too
879
+ metric->width = QFixed::fromReal (metric->width .toReal () * scale);
880
+ metric->height = QFixed::fromReal (metric->height .toReal () * scale);
881
+ metric->x = QFixed::fromReal (metric->x .toReal () * scale);
882
+ metric->y = QFixed::fromReal (metric->y .toReal () * scale);
883
+ metric->xoff = QFixed::fromReal (metric->xoff .toReal () * scale);
884
+ metric->yoff = QFixed::fromReal (metric->yoff .toReal () * scale);
862
885
}
863
886
864
887
QFixed QCoreTextFontEngine::emSquareSize () const
@@ -875,6 +898,45 @@ static void convertCGPathToQPainterPath(void *info, const CGPathElement *element
875
898
return new QCoreTextFontEngine (cgFont, newFontDef);
876
899
}
877
900
901
+ QFontEngine::Properties QCoreTextFontEngine::properties () const
902
+ {
903
+ Properties result;
904
+
905
+ QCFString psName, copyright;
906
+ psName = CTFontCopyPostScriptName (ctfont);
907
+ copyright = CTFontCopyName (ctfont, kCTFontCopyrightNameKey );
908
+ result.postscriptName = QCFString::toQString (psName).toUtf8 ();
909
+ result.copyright = QCFString::toQString (copyright).toUtf8 ();
910
+
911
+ qreal emSquare = CTFontGetUnitsPerEm (ctfont);
912
+ qreal scale = emSquare / CTFontGetSize (ctfont);
913
+
914
+ CGRect cgRect = CTFontGetBoundingBox (ctfont);
915
+ result.boundingBox = QRectF (cgRect.origin .x * scale,
916
+ -CTFontGetAscent (ctfont) * scale,
917
+ cgRect.size .width * scale,
918
+ cgRect.size .height * scale);
919
+
920
+ result.emSquare = emSquareSize ();
921
+ result.ascent = QFixed::fromReal (CTFontGetAscent (ctfont) * scale);
922
+ result.descent = QFixed::fromReal (CTFontGetDescent (ctfont) * scale);
923
+ result.leading = QFixed::fromReal (CTFontGetLeading (ctfont) * scale);
924
+ result.italicAngle = QFixed::fromReal (CTFontGetSlantAngle (ctfont));
925
+ result.capHeight = QFixed::fromReal (CTFontGetCapHeight (ctfont) * scale);
926
+ result.lineWidth = QFixed::fromReal (CTFontGetUnderlineThickness (ctfont) * scale);
927
+
928
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
929
+ result.ascent = result.ascent .round ();
930
+ result.descent = result.descent .round ();
931
+ result.leading = result.leading .round ();
932
+ result.italicAngle = result.italicAngle .round ();
933
+ result.capHeight = result.capHeight .round ();
934
+ result.lineWidth = result.lineWidth .round ();
935
+ }
936
+
937
+ return result;
938
+ }
939
+
878
940
QT_END_NAMESPACE
879
941
880
942
#endif // !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
0 commit comments