| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the internal font implementation. | 2 * This file is part of the internal font implementation. |
| 3 * | 3 * |
| 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 5 * Copyright (c) 2010 Google Inc. All rights reserved. | 5 * Copyright (c) 2010 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 ASSERT(m_font || !m_cgFont); | 43 ASSERT(m_font || !m_cgFont); |
| 44 uintptr_t hashCodes[2] = { (uintptr_t)m_font, static_cast<uintptr_t>(m_isHas
hTableDeletedValue << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheti
cItalic) }; | 44 uintptr_t hashCodes[2] = { (uintptr_t)m_font, static_cast<uintptr_t>(m_isHas
hTableDeletedValue << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheti
cItalic) }; |
| 45 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); | 45 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext*, const Font*
font) const | 48 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext*, const Font*
font) const |
| 49 { | 49 { |
| 50 bool shouldSmoothFonts = true; | 50 bool shouldSmoothFonts = true; |
| 51 bool shouldAntialias = true; | 51 bool shouldAntialias = true; |
| 52 | 52 |
| 53 shouldAntialias = shouldAntialias && (!LayoutTestSupport::isRunningLayoutTes
t() | 53 if (font) { |
| 54 || LayoutTestSupport::isFontAntialiasingEnabledForTest()); | 54 switch (font->fontDescription().fontSmoothing()) { |
| 55 case Antialiased: |
| 56 shouldSmoothFonts = false; |
| 57 break; |
| 58 case SubpixelAntialiased: |
| 59 break; |
| 60 case NoSmoothing: |
| 61 shouldAntialias = false; |
| 62 shouldSmoothFonts = false; |
| 63 break; |
| 64 case AutoSmoothing: |
| 65 // For the AutoSmooth case, don't do anything! Keep the default sett
ings. |
| 66 break; |
| 67 } |
| 68 } |
| 69 |
| 70 if (LayoutTestSupport::isRunningLayoutTest()) { |
| 71 shouldSmoothFonts = false; |
| 72 shouldAntialias = shouldAntialias && LayoutTestSupport::isFontAntialiasi
ngEnabledForTest(); |
| 73 } |
| 74 |
| 55 bool useSubpixelText = RuntimeEnabledFeatures::subpixelFontScalingEnabled(); | 75 bool useSubpixelText = RuntimeEnabledFeatures::subpixelFontScalingEnabled(); |
| 56 shouldSmoothFonts = shouldSmoothFonts && !LayoutTestSupport::isRunningLayout
Test(); | |
| 57 | 76 |
| 58 paint->setAntiAlias(shouldAntialias); | 77 paint->setAntiAlias(shouldAntialias); |
| 59 paint->setEmbeddedBitmapText(false); | 78 paint->setEmbeddedBitmapText(false); |
| 60 const float ts = m_textSize >= 0 ? m_textSize : 12; | 79 const float ts = m_textSize >= 0 ? m_textSize : 12; |
| 61 paint->setTextSize(SkFloatToScalar(ts)); | 80 paint->setTextSize(SkFloatToScalar(ts)); |
| 62 paint->setTypeface(typeface()); | 81 paint->setTypeface(typeface()); |
| 63 paint->setFakeBoldText(m_syntheticBold); | 82 paint->setFakeBoldText(m_syntheticBold); |
| 64 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0); | 83 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0); |
| 65 paint->setLCDRenderText(shouldSmoothFonts); | 84 paint->setLCDRenderText(shouldSmoothFonts); |
| 66 paint->setSubpixelText(useSubpixelText); | 85 paint->setSubpixelText(useSubpixelText); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 else | 272 else |
| 254 fontDescriptor = cascadeToLastResortFontDescriptor(); | 273 fontDescriptor = cascadeToLastResortFontDescriptor(); |
| 255 m_CTFont.adoptCF(CTFontCreateCopyWithAttributes(m_CTFont.get(), m_textSi
ze, 0, fontDescriptor)); | 274 m_CTFont.adoptCF(CTFontCreateCopyWithAttributes(m_CTFont.get(), m_textSi
ze, 0, fontDescriptor)); |
| 256 } else | 275 } else |
| 257 m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_textSize
, 0, cascadeToLastResortFontDescriptor())); | 276 m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_textSize
, 0, cascadeToLastResortFontDescriptor())); |
| 258 | 277 |
| 259 return m_CTFont.get(); | 278 return m_CTFont.get(); |
| 260 } | 279 } |
| 261 | 280 |
| 262 } // namespace blink | 281 } // namespace blink |
| OLD | NEW |