| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 float ascent; | 83 float ascent; |
| 84 float descent; | 84 float descent; |
| 85 | 85 |
| 86 // Beware those who step here: This code is designed to match Win32 font | 86 // Beware those who step here: This code is designed to match Win32 font |
| 87 // metrics *exactly* (except the adjustment of ascent/descent on Linux/Andro
id). | 87 // metrics *exactly* (except the adjustment of ascent/descent on Linux/Andro
id). |
| 88 if (isVDMXValid) { | 88 if (isVDMXValid) { |
| 89 ascent = vdmxAscent; | 89 ascent = vdmxAscent; |
| 90 descent = -vdmxDescent; | 90 descent = -vdmxDescent; |
| 91 } else { | 91 } else { |
| 92 SkScalar height = -metrics.fAscent + metrics.fDescent + metrics.fLeading
; | |
| 93 ascent = SkScalarRound(-metrics.fAscent); | 92 ascent = SkScalarRound(-metrics.fAscent); |
| 94 descent = SkScalarRound(height) - ascent; | 93 descent = SkScalarRound(metrics.fDescent); |
| 95 #if OS(LINUX) || OS(ANDROID) | 94 #if OS(LINUX) || OS(ANDROID) |
| 96 // When subpixel positioning is enabled, if the descent is rounded down,
the descent part | 95 // When subpixel positioning is enabled, if the descent is rounded down,
the descent part |
| 97 // of the glyph may be truncated when displayed in a 'overflow: hidden'
container. | 96 // of the glyph may be truncated when displayed in a 'overflow: hidden'
container. |
| 98 // To avoid that, borrow 1 unit from the ascent when possible. | 97 // To avoid that, borrow 1 unit from the ascent when possible. |
| 99 // FIXME: This can be removed if sub-pixel ascent/descent is supported. | 98 // FIXME: This can be removed if sub-pixel ascent/descent is supported. |
| 100 if (platformData().fontRenderStyle().useSubpixelPositioning && descent <
SkScalarToFloat(metrics.fDescent) && ascent >= 1) { | 99 if (platformData().fontRenderStyle().useSubpixelPositioning && descent <
SkScalarToFloat(metrics.fDescent) && ascent >= 1) { |
| 101 ++descent; | 100 ++descent; |
| 102 --ascent; | 101 --ascent; |
| 103 } | 102 } |
| 104 #endif | 103 #endif |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | 275 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); |
| 277 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { | 276 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { |
| 278 addResult.iterator->value = true; | 277 addResult.iterator->value = true; |
| 279 return true; | 278 return true; |
| 280 } | 279 } |
| 281 return false; | 280 return false; |
| 282 } | 281 } |
| 283 #endif | 282 #endif |
| 284 | 283 |
| 285 } // namespace WebCore | 284 } // namespace WebCore |
| OLD | NEW |