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

Side by Side Diff: sky/engine/platform/fonts/skia/SimpleFontDataSkia.cpp

Issue 1163323003: sky/engine updates for iOS targets (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months 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
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 SkPaint::FontMetrics metrics; 61 SkPaint::FontMetrics metrics;
62 62
63 m_platformData.setupPaint(&paint); 63 m_platformData.setupPaint(&paint);
64 paint.getFontMetrics(&metrics); 64 paint.getFontMetrics(&metrics);
65 SkTypeface* face = paint.getTypeface(); 65 SkTypeface* face = paint.getTypeface();
66 ASSERT(face); 66 ASSERT(face);
67 67
68 int vdmxAscent = 0, vdmxDescent = 0; 68 int vdmxAscent = 0, vdmxDescent = 0;
69 bool isVDMXValid = false; 69 bool isVDMXValid = false;
70 70
71 #if OS(LINUX) || OS(ANDROID) 71 #if OS(LINUX) || OS(ANDROID) || OS(IOS)
72 // Manually digging up VDMX metrics is only applicable when bytecode hinting using FreeType. 72 // Manually digging up VDMX metrics is only applicable when bytecode hinting using FreeType.
73 // With GDI, the metrics will already have taken this into account (as neede d). 73 // With GDI, the metrics will already have taken this into account (as neede d).
74 // With DirectWrite or CoreText, no bytecode hinting is ever done. 74 // With DirectWrite or CoreText, no bytecode hinting is ever done.
75 // This code should be pushed into FreeType (hinted font metrics). 75 // This code should be pushed into FreeType (hinted font metrics).
76 static const uint32_t vdmxTag = SkSetFourByteTag('V', 'D', 'M', 'X'); 76 static const uint32_t vdmxTag = SkSetFourByteTag('V', 'D', 'M', 'X');
77 int pixelSize = m_platformData.size() + 0.5; 77 int pixelSize = m_platformData.size() + 0.5;
78 if (!paint.isAutohinted() 78 if (!paint.isAutohinted()
79 && (paint.getHinting() == SkPaint::kFull_Hinting 79 && (paint.getHinting() == SkPaint::kFull_Hinting
80 || paint.getHinting() == SkPaint::kNormal_Hinting)) 80 || paint.getHinting() == SkPaint::kNormal_Hinting))
81 { 81 {
(...skipping 13 matching lines...) Expand all
95 float descent; 95 float descent;
96 96
97 // Beware those who step here: This code is designed to match Win32 font 97 // Beware those who step here: This code is designed to match Win32 font
98 // metrics *exactly* (except the adjustment of ascent/descent on Linux/Andro id). 98 // metrics *exactly* (except the adjustment of ascent/descent on Linux/Andro id).
99 if (isVDMXValid) { 99 if (isVDMXValid) {
100 ascent = vdmxAscent; 100 ascent = vdmxAscent;
101 descent = -vdmxDescent; 101 descent = -vdmxDescent;
102 } else { 102 } else {
103 ascent = SkScalarRoundToInt(-metrics.fAscent); 103 ascent = SkScalarRoundToInt(-metrics.fAscent);
104 descent = SkScalarRoundToInt(metrics.fDescent); 104 descent = SkScalarRoundToInt(metrics.fDescent);
105 #if OS(LINUX) || OS(ANDROID) 105 #if OS(LINUX) || OS(ANDROID) || OS(IOS)
106 // When subpixel positioning is enabled, if the descent is rounded down, the descent part 106 // When subpixel positioning is enabled, if the descent is rounded down, the descent part
107 // of the glyph may be truncated when displayed in a 'overflow: hidden' container. 107 // of the glyph may be truncated when displayed in a 'overflow: hidden' container.
108 // To avoid that, borrow 1 unit from the ascent when possible. 108 // To avoid that, borrow 1 unit from the ascent when possible.
109 // FIXME: This can be removed if sub-pixel ascent/descent is supported. 109 // FIXME: This can be removed if sub-pixel ascent/descent is supported.
110 if (platformData().fontRenderStyle().useSubpixelPositioning && descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) { 110 if (platformData().fontRenderStyle().useSubpixelPositioning && descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) {
111 ++descent; 111 ++descent;
112 --ascent; 112 --ascent;
113 } 113 }
114 #endif 114 #endif
115 } 115 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if (glyphs[i]) { 293 if (glyphs[i]) {
294 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); 294 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this);
295 haveGlyphs = true; 295 haveGlyphs = true;
296 } 296 }
297 } 297 }
298 298
299 return haveGlyphs; 299 return haveGlyphs;
300 } 300 }
301 301
302 } // namespace blink 302 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698