Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Computer, Inc. | 2 * Copyright (C) 2006, 2007 Apple Computer, Inc. |
| 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. | 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 uint32_t textFlags = paintTextFlags(); | 54 uint32_t textFlags = paintTextFlags(); |
| 55 uint32_t flags = paint->getFlags(); | 55 uint32_t flags = paint->getFlags(); |
| 56 static const uint32_t textFlagsMask = | 56 static const uint32_t textFlagsMask = |
| 57 SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag | | 57 SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag | |
| 58 SkPaint::kEmbeddedBitmapText_Flag | SkPaint::kSubpixelText_Flag; | 58 SkPaint::kEmbeddedBitmapText_Flag | SkPaint::kSubpixelText_Flag; |
| 59 flags &= ~textFlagsMask; | 59 flags &= ~textFlagsMask; |
| 60 | 60 |
| 61 if (ts <= kMaxSizeForEmbeddedBitmap) | 61 if (ts <= kMaxSizeForEmbeddedBitmap) |
| 62 flags |= SkPaint::kEmbeddedBitmapText_Flag; | 62 flags |= SkPaint::kEmbeddedBitmapText_Flag; |
| 63 | 63 |
| 64 if (ts >= m_minSizeForAntiAlias) { | 64 // Subpixel text positioning leads to uneven spacing without font |
|
eae
2017/03/17 16:53:16
This explanation is a little confusing at first as
| |
| 65 // Disable subpixel text for certain older fonts at smaller sizes as | 65 // smoothing. Subpixel test placement coordinates would be passed to Skia, |
| 66 // they tend to get quite blurry at non-integer sizes and positions. | 66 // which only has non-antialiased glyphs to draw, so they necessarily get |
| 67 // For high-DPI this workaround isn't required. | 67 // clamped at pixel positions, which leads to uneven spacing, either too close |
| 68 if ((ts >= m_minSizeForSubpixel || | 68 // or too far away from adjacent glyphs. |
| 69 FontCache::fontCache()->deviceScaleFactor() >= 1.5) | 69 if (textFlags & SkPaint::kAntiAlias_Flag) |
| 70 flags |= SkPaint::kSubpixelText_Flag; | |
| 70 | 71 |
| 71 // Subpixel text positioning looks pretty bad without font | 72 SkASSERT(!(textFlags & ~textFlagsMask)); |
| 72 // smoothing. Disable it unless some type of font smoothing is used. | 73 flags |= textFlags; |
| 73 // As most tests run without font smoothing we enable it for tests | |
| 74 // to ensure we get good test coverage matching the more common | |
| 75 // smoothing enabled behavior. | |
| 76 && ((textFlags & SkPaint::kAntiAlias_Flag) || | |
| 77 LayoutTestSupport::isRunningLayoutTest())) | |
| 78 flags |= SkPaint::kSubpixelText_Flag; | |
| 79 | |
| 80 SkASSERT(!(textFlags & ~textFlagsMask)); | |
| 81 flags |= textFlags; | |
| 82 } | |
| 83 | 74 |
| 84 paint->setFlags(flags); | 75 paint->setFlags(flags); |
| 85 } | 76 } |
| 86 | 77 |
| 87 static bool isWebFont(const String& familyName) { | 78 static bool isWebFont(const String& familyName) { |
| 88 // Web-fonts have artifical names constructed to always be: | 79 // Web-fonts have artifical names constructed to always be: |
| 89 // 1. 24 characters, followed by a '\0' | 80 // 1. 24 characters, followed by a '\0' |
| 90 // 2. the last two characters are '==' | 81 // 2. the last two characters are '==' |
| 91 return familyName.length() == 24 && '=' == familyName[22] && | 82 return familyName.length() == 24 && '=' == familyName[22] && |
| 92 '=' == familyName[23]; | 83 '=' == familyName[23]; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 114 textFlags |= SkPaint::kAntiAlias_Flag; | 105 textFlags |= SkPaint::kAntiAlias_Flag; |
| 115 | 106 |
| 116 return textFlags; | 107 return textFlags; |
| 117 } | 108 } |
| 118 | 109 |
| 119 void FontPlatformData::querySystemForRenderStyle() { | 110 void FontPlatformData::querySystemForRenderStyle() { |
| 120 m_paintTextFlags = computePaintTextFlags(fontFamilyName()); | 111 m_paintTextFlags = computePaintTextFlags(fontFamilyName()); |
| 121 } | 112 } |
| 122 | 113 |
| 123 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |