aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbungeman <bungeman@google.com>2014-12-12 14:59:53 -0500
committerbungeman <bungeman@google.com>2014-12-12 14:59:53 -0500
commitf4153260844a88d208c30bac5cc6902e716289c9 (patch)
tree85e39f798500b6bfcab21a9d3a684ae2a73171a3
parentb83253202f87a021efbef27ffeb316335d39a5ac (diff)
downloadskia-f4153260844a88d208c30bac5cc6902e716289c9.tar.gz
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
-rwxr-xr-xsrc/ports/SkFontHost_mac.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 2f991c861..8c1abc91c 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -741,9 +741,12 @@ SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface,
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));