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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp

Issue 2204923002: Untangle HarfBuzz callbacks for glyph width and extents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Untangle HarfBuzz callbacks for glyph width and extents Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.h » ('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) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return false; 174 return false;
175 175
176 return hb_font_get_glyph(hb_font_get_parent(hbFont), unicode, variationSelec tor, glyph); 176 return hb_font_get_glyph(hb_font_get_parent(hbFont), unicode, variationSelec tor, glyph);
177 } 177 }
178 178
179 static hb_position_t harfBuzzGetGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData) 179 static hb_position_t harfBuzzGetGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData)
180 { 180 {
181 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData) ; 181 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData) ;
182 hb_position_t advance = 0; 182 hb_position_t advance = 0;
183 183
184 SkiaTextMetrics(&hbFontData->m_paint).getGlyphWidthAndExtentsForHarfBuzz(gly ph, &advance, 0); 184 SkiaTextMetrics(&hbFontData->m_paint).getGlyphWidthForHarfBuzz(glyph, &advan ce);
185 return advance; 185 return advance;
186 } 186 }
187 187
188 static hb_bool_t harfBuzzGetGlyphVerticalOrigin(hb_font_t* hbFont, void* fontDat a, hb_codepoint_t glyph, hb_position_t* x, hb_position_t* y, void* userData) 188 static hb_bool_t harfBuzzGetGlyphVerticalOrigin(hb_font_t* hbFont, void* fontDat a, hb_codepoint_t glyph, hb_position_t* x, hb_position_t* y, void* userData)
189 { 189 {
190 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData) ; 190 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData) ;
191 const OpenTypeVerticalData* verticalData = hbFontData->m_simpleFontData->ver ticalData(); 191 const OpenTypeVerticalData* verticalData = hbFontData->m_simpleFontData->ver ticalData();
192 if (!verticalData) 192 if (!verticalData)
193 return false; 193 return false;
194 194
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return SkiaScalarToHarfBuzzPosition(SkScalarMulDiv(SkIntToScalar(kerning Adjustments[0]), size, upm)); 231 return SkiaScalarToHarfBuzzPosition(SkScalarMulDiv(SkIntToScalar(kerning Adjustments[0]), size, upm));
232 } 232 }
233 233
234 return 0; 234 return 0;
235 } 235 }
236 236
237 static hb_bool_t harfBuzzGetGlyphExtents(hb_font_t* hbFont, void* fontData, hb_c odepoint_t glyph, hb_glyph_extents_t* extents, void* userData) 237 static hb_bool_t harfBuzzGetGlyphExtents(hb_font_t* hbFont, void* fontData, hb_c odepoint_t glyph, hb_glyph_extents_t* extents, void* userData)
238 { 238 {
239 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData) ; 239 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData) ;
240 240
241 SkiaTextMetrics(&hbFontData->m_paint).getGlyphWidthAndExtentsForHarfBuzz(gly ph, 0, extents); 241 SkiaTextMetrics(&hbFontData->m_paint).getGlyphExtentsForHarfBuzz(glyph, exte nts);
242 return true; 242 return true;
243 } 243 }
244 244
245 static hb_font_funcs_t* harfBuzzSkiaGetFontFuncs() 245 static hb_font_funcs_t* harfBuzzSkiaGetFontFuncs()
246 { 246 {
247 static hb_font_funcs_t* harfBuzzSkiaFontFuncs = 0; 247 static hb_font_funcs_t* harfBuzzSkiaFontFuncs = 0;
248 248
249 // We don't set callback functions which we can't support. 249 // We don't set callback functions which we can't support.
250 // HarfBuzz will use the fallback implementation if they aren't set. 250 // HarfBuzz will use the fallback implementation if they aren't set.
251 if (!harfBuzzSkiaFontFuncs) { 251 if (!harfBuzzSkiaFontFuncs) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 m_harfBuzzFontData->m_paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 346 m_harfBuzzFontData->m_paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
347 m_harfBuzzFontData->m_rangeSet = rangeSet; 347 m_harfBuzzFontData->m_rangeSet = rangeSet;
348 m_harfBuzzFontData->m_simpleFontData = FontCache::fontCache()->fontDataFromF ontPlatformData(m_platformData).get(); 348 m_harfBuzzFontData->m_simpleFontData = FontCache::fontCache()->fontDataFromF ontPlatformData(m_platformData).get();
349 ASSERT(m_harfBuzzFontData->m_simpleFontData); 349 ASSERT(m_harfBuzzFontData->m_simpleFontData);
350 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size()); 350 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size());
351 hb_font_set_scale(m_unscaledFont, scale, scale); 351 hb_font_set_scale(m_unscaledFont, scale, scale);
352 return m_unscaledFont; 352 return m_unscaledFont;
353 } 353 }
354 354
355 } // namespace blink 355 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698