Work around CG assert drawing tiny glyphs.
For some fonts when drawing glyphs at CGFLOAT_MIN size,
CG will assert internally. Instead, request such glyphs at size 1,
and scale them down to 0 with a transform.
This change follows the pattern set by
3490263287e9432119c501884e45840de4d986bc
"Replace use of deprecated CG methods." on master.
BUG=chromium:441538
R=reed@google.com
Review URL: https://codereview.chromium.org/796783003
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 2f991c8..8c1abc9 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -741,9 +741,12 @@
CGFloat textSize = ScalarToCG(fRec.fTextSize);
// If a text size of 0 is requested, CoreGraphics will use 12 instead.
- // If the text size is 0, set it to something tiny.
+ // It would make sense to force the text size to something tiny,
+ // but this causes assertion failures inside CG (drawing glyphs at CGFLOAT_MIN size).
+ // Instead, set such tiny sizes to 1, and transform them down to 0 with a singular transform.
if (textSize < CGFLOAT_MIN) {
- textSize = CGFLOAT_MIN;
+ textSize = 1;
+ transform = CGAffineTransformMakeScale(0, 0);
}
fCTFont.reset(CTFontCreateCopyWithAttributes(ctFont, textSize, &transform, ctFontDesc));