Calculate the size of an ATSUI font by finding the magnitude of a unit vector scaled using the current ctm. This calculation is only correct for isotropic scaling and translation, but correctly implements the intent of the old code. --- commit e26db8db0d0e6a475589308419f869d3e1ef46ad tree 28f0d9079824a25e254106901581b2a84d12a99c parent 15e8486ef1558b8049a4c7a5c2f50a7e4a2599da author Brian Ewins Fri, 15 Dec 2006 03:08:26 +0000 committer Brian Ewins Fri, 15 Dec 2006 03:08:26 +0000 src/cairo-atsui-font.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c index 2927caa..74498c1 100644 --- a/src/cairo-atsui-font.c +++ b/src/cairo-atsui-font.c @@ -152,11 +152,12 @@ CreateSizedCopyOfStyle(ATSUStyle inStyle OSStatus err; /* Set the style's size */ - CGAffineTransform theTransform = - CGAffineTransformMakeWithCairoFontScale(scale); - Fixed theSize = - FloatToFixed(CGSizeApplyAffineTransform - (CGSizeMake(1.0, 1.0), theTransform).height); + /* XXX The size calculated here is only correct for transposition and isotropic + * scaling. Cairo does not yet have tests for anisotropic scaling or shear. + * However, it would be faster and more correct to set a size here and + * use the ctm to transform the font later, instead of using sqrt. + */ + Fixed theSize = FloatToFixed(sqrt(scale->xx * scale->xx + scale->xy * scale->xy)); const ATSUAttributeTag theFontStyleTags[] = { kATSUSizeTag }; const ByteCount theFontStyleSizes[] = { sizeof(Fixed) }; ATSUAttributeValuePtr theFontStyleValues[] = { &theSize };