OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifdef SK_BUILD_FOR_MAC | 9 #ifdef SK_BUILD_FOR_MAC |
10 #import <ApplicationServices/ApplicationServices.h> | 10 #import <ApplicationServices/ApplicationServices.h> |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 CFDictionaryAddValue(cfAttributes, kCTFontOrientationAttribute, cfVe
rtical); | 734 CFDictionaryAddValue(cfAttributes, kCTFontOrientationAttribute, cfVe
rtical); |
735 ctFontDesc.reset(CTFontDescriptorCreateWithAttributes(cfAttributes))
; | 735 ctFontDesc.reset(CTFontDescriptorCreateWithAttributes(cfAttributes))
; |
736 } | 736 } |
737 } | 737 } |
738 | 738 |
739 // The transform contains everything except the requested text size. | 739 // The transform contains everything except the requested text size. |
740 // Some properties, like 'trak', are based on the text size (before applying
the matrix). | 740 // Some properties, like 'trak', are based on the text size (before applying
the matrix). |
741 CGFloat textSize = ScalarToCG(fRec.fTextSize); | 741 CGFloat textSize = ScalarToCG(fRec.fTextSize); |
742 | 742 |
743 // If a text size of 0 is requested, CoreGraphics will use 12 instead. | 743 // If a text size of 0 is requested, CoreGraphics will use 12 instead. |
744 // If the text size is 0, set it to something tiny. | 744 // It would make sense to force the text size to something tiny, |
| 745 // but this causes assertion failures inside CG (drawing glyphs at CGFLOAT_M
IN size). |
| 746 // Instead, set such tiny sizes to 1, and transform them down to 0 with a si
ngular transform. |
745 if (textSize < CGFLOAT_MIN) { | 747 if (textSize < CGFLOAT_MIN) { |
746 textSize = CGFLOAT_MIN; | 748 textSize = 1; |
| 749 transform = CGAffineTransformMakeScale(0, 0); |
747 } | 750 } |
748 | 751 |
749 fCTFont.reset(CTFontCreateCopyWithAttributes(ctFont, textSize, &transform, c
tFontDesc)); | 752 fCTFont.reset(CTFontCreateCopyWithAttributes(ctFont, textSize, &transform, c
tFontDesc)); |
750 fCGFont.reset(CTFontCopyGraphicsFont(fCTFont, NULL)); | 753 fCGFont.reset(CTFontCopyGraphicsFont(fCTFont, NULL)); |
751 if (fVertical) { | 754 if (fVertical) { |
752 CGAffineTransform rotateLeft = CGAffineTransformMake(0, -1, 1, 0, 0, 0); | 755 CGAffineTransform rotateLeft = CGAffineTransformMake(0, -1, 1, 0, 0, 0); |
753 transform = CGAffineTransformConcat(rotateLeft, transform); | 756 transform = CGAffineTransformConcat(rotateLeft, transform); |
754 fCTVerticalFont.reset(CTFontCreateCopyWithAttributes(ctFont, textSize, &
transform, NULL)); | 757 fCTVerticalFont.reset(CTFontCreateCopyWithAttributes(ctFont, textSize, &
transform, NULL)); |
755 } | 758 } |
756 | 759 |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 } | 2257 } |
2255 return face; | 2258 return face; |
2256 } | 2259 } |
2257 }; | 2260 }; |
2258 | 2261 |
2259 /////////////////////////////////////////////////////////////////////////////// | 2262 /////////////////////////////////////////////////////////////////////////////// |
2260 | 2263 |
2261 SkFontMgr* SkFontMgr::Factory() { | 2264 SkFontMgr* SkFontMgr::Factory() { |
2262 return SkNEW(SkFontMgr_Mac); | 2265 return SkNEW(SkFontMgr_Mac); |
2263 } | 2266 } |
OLD | NEW |