OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2008, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2006 Alexey Proskuryakov | 3 * Copyright (C) 2006 Alexey Proskuryakov |
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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 // arbitrary but comes pretty close to the expected value in most cases. | 194 // arbitrary but comes pretty close to the expected value in most cases. |
195 if (m_maxCharWidth < 1) | 195 if (m_maxCharWidth < 1) |
196 m_maxCharWidth = ascent * 2; | 196 m_maxCharWidth = ascent * 2; |
197 #elif OS(MACOSX) | 197 #elif OS(MACOSX) |
198 // FIXME: The current avg/max character width calculation is not ideal, | 198 // FIXME: The current avg/max character width calculation is not ideal, |
199 // it should check either the OS2 table or, better yet, query FontMetrics. | 199 // it should check either the OS2 table or, better yet, query FontMetrics. |
200 // Sadly FontMetrics provides incorrect data on Mac at the moment. | 200 // Sadly FontMetrics provides incorrect data on Mac at the moment. |
201 // https://crbug.com/420901 | 201 // https://crbug.com/420901 |
202 m_maxCharWidth = std::max(m_avgCharWidth, m_fontMetrics.floatAscent()); | 202 m_maxCharWidth = std::max(m_avgCharWidth, m_fontMetrics.floatAscent()); |
203 #else | 203 #else |
204 // FIXME: This seems incorrect and should probably use fMaxCharWidth as | 204 // FIXME: Skia needs to fill in fMaxCharWidth for us. [skbug.com/3087] |
205 // the code path above. | 205 m_maxCharWidth = std::max(m_avgCharWidth, m_fontMetrics.floatAscent()); |
jbroman
2014/10/30 19:55:20
drive-by: this seems to be the same as the previou
| |
206 SkScalar xRange = metrics.fXMax - metrics.fXMin; | |
207 m_maxCharWidth = SkScalarRoundToInt(xRange * SkScalarRoundToInt(m_platformDa ta.size())); | |
208 #endif | 206 #endif |
209 | 207 |
210 #if !OS(MACOSX) | 208 #if !OS(MACOSX) |
211 if (metrics.fAvgCharWidth) { | 209 if (metrics.fAvgCharWidth) { |
212 m_avgCharWidth = SkScalarRoundToInt(metrics.fAvgCharWidth); | 210 m_avgCharWidth = SkScalarRoundToInt(metrics.fAvgCharWidth); |
213 } else { | 211 } else { |
214 #endif | 212 #endif |
215 m_avgCharWidth = xHeight; | 213 m_avgCharWidth = xHeight; |
216 | 214 |
217 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->pag e(); | 215 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->pag e(); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 if (glyphs[i]) { | 482 if (glyphs[i]) { |
485 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); | 483 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); |
486 haveGlyphs = true; | 484 haveGlyphs = true; |
487 } | 485 } |
488 } | 486 } |
489 | 487 |
490 return haveGlyphs; | 488 return haveGlyphs; |
491 } | 489 } |
492 | 490 |
493 } // namespace blink | 491 } // namespace blink |
OLD | NEW |