Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: Source/platform/fonts/SimpleFontData.cpp

Issue 691133002: use better heuristic for maxcharwidth (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: set flag in gypi Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | public/blink_skia_config.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Better would be to rely on either fMaxCharWidth or fAveCharWidth.
205 // the code path above. 205 // skbug.com/3087
206 SkScalar xRange = metrics.fXMax - metrics.fXMin; 206 m_maxCharWidth = SkScalarRoundToInt(metrics.fXMax - metrics.fXMin);
207 m_maxCharWidth = SkScalarRoundToInt(xRange * SkScalarRoundToInt(m_platformDa ta.size())); 207
208 #endif 208 #endif
209 209
210 #if !OS(MACOSX) 210 #if !OS(MACOSX)
211 if (metrics.fAvgCharWidth) { 211 if (metrics.fAvgCharWidth) {
212 m_avgCharWidth = SkScalarRoundToInt(metrics.fAvgCharWidth); 212 m_avgCharWidth = SkScalarRoundToInt(metrics.fAvgCharWidth);
213 } else { 213 } else {
214 #endif 214 #endif
215 m_avgCharWidth = xHeight; 215 m_avgCharWidth = xHeight;
216 216
217 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->pag e(); 217 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->pag e();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (glyphs[i]) { 484 if (glyphs[i]) {
485 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); 485 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this);
486 haveGlyphs = true; 486 haveGlyphs = true;
487 } 487 }
488 } 488 }
489 489
490 return haveGlyphs; 490 return haveGlyphs;
491 } 491 }
492 492
493 } // namespace blink 493 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/blink_skia_config.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698