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

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

Issue 2735233004: Remove HarfBuzz version specific compile conditional (Closed)
Patch Set: Created 3 years, 9 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 | no next file » | 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 hb_ot_font_set_funcs(otFont.get()); 373 hb_ot_font_set_funcs(otFont.get());
374 // Creating a sub font means that non-available functions 374 // Creating a sub font means that non-available functions
375 // are found from the parent. 375 // are found from the parent.
376 hb_font_t* unscaledFont = hb_font_create_sub_font(otFont.get()); 376 hb_font_t* unscaledFont = hb_font_create_sub_font(otFont.get());
377 RefPtr<HbFontCacheEntry> cacheEntry = HbFontCacheEntry::create(unscaledFont); 377 RefPtr<HbFontCacheEntry> cacheEntry = HbFontCacheEntry::create(unscaledFont);
378 hb_font_set_funcs(unscaledFont, harfBuzzSkiaGetFontFuncs(), 378 hb_font_set_funcs(unscaledFont, harfBuzzSkiaGetFontFuncs(),
379 cacheEntry->hbFontData(), nullptr); 379 cacheEntry->hbFontData(), nullptr);
380 return cacheEntry; 380 return cacheEntry;
381 } 381 }
382 382
383 // TODO: crbug.com/696570 Remove this conditional
384 // once HarfBuzz on CrOS is updated.
385 #if HB_VERSION_ATLEAST(1, 4, 2)
386 static_assert( 383 static_assert(
387 std::is_same<decltype(SkFontArguments::VariationPosition::Coordinate::axis), 384 std::is_same<decltype(SkFontArguments::VariationPosition::Coordinate::axis),
388 decltype(hb_variation_t::tag)>::value && 385 decltype(hb_variation_t::tag)>::value &&
389 std::is_same< 386 std::is_same<
390 decltype(SkFontArguments::VariationPosition::Coordinate::value), 387 decltype(SkFontArguments::VariationPosition::Coordinate::value),
391 decltype(hb_variation_t::value)>::value && 388 decltype(hb_variation_t::value)>::value &&
392 sizeof(SkFontArguments::VariationPosition::Coordinate) == 389 sizeof(SkFontArguments::VariationPosition::Coordinate) ==
393 sizeof(hb_variation_t), 390 sizeof(hb_variation_t),
394 "Skia and HarfBuzz Variation parameter types must match in structure and " 391 "Skia and HarfBuzz Variation parameter types must match in structure and "
395 "size."); 392 "size.");
396 #endif
397 393
398 hb_font_t* HarfBuzzFace::getScaledFont( 394 hb_font_t* HarfBuzzFace::getScaledFont(
399 PassRefPtr<UnicodeRangeSet> rangeSet) const { 395 PassRefPtr<UnicodeRangeSet> rangeSet) const {
400 m_platformData->setupPaint(&m_harfBuzzFontData->m_paint); 396 m_platformData->setupPaint(&m_harfBuzzFontData->m_paint);
401 m_harfBuzzFontData->m_paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 397 m_harfBuzzFontData->m_paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
402 m_harfBuzzFontData->m_rangeSet = rangeSet; 398 m_harfBuzzFontData->m_rangeSet = rangeSet;
403 m_harfBuzzFontData->updateSimpleFontData(m_platformData); 399 m_harfBuzzFontData->updateSimpleFontData(m_platformData);
404 400
405 ASSERT(m_harfBuzzFontData->m_simpleFontData); 401 ASSERT(m_harfBuzzFontData->m_simpleFontData);
406 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size()); 402 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size());
407 hb_font_set_scale(m_unscaledFont, scale, scale); 403 hb_font_set_scale(m_unscaledFont, scale, scale);
408 404
409 // TODO: crbug.com/696570 Remove this conditional
410 // once HarfBuzz on CrOS is updated.
411 #if HB_VERSION_ATLEAST(1, 4, 2)
412 SkTypeface* typeface = m_harfBuzzFontData->m_paint.getTypeface(); 405 SkTypeface* typeface = m_harfBuzzFontData->m_paint.getTypeface();
413 int axisCount = typeface->getVariationDesignPosition(nullptr, 0); 406 int axisCount = typeface->getVariationDesignPosition(nullptr, 0);
414 if (axisCount > 0) { 407 if (axisCount > 0) {
415 Vector<SkFontArguments::VariationPosition::Coordinate> axisValues; 408 Vector<SkFontArguments::VariationPosition::Coordinate> axisValues;
416 axisValues.resize(axisCount); 409 axisValues.resize(axisCount);
417 if (typeface->getVariationDesignPosition(axisValues.data(), 410 if (typeface->getVariationDesignPosition(axisValues.data(),
418 axisValues.size()) > 0) { 411 axisValues.size()) > 0) {
419 hb_font_set_variations( 412 hb_font_set_variations(
420 m_unscaledFont, reinterpret_cast<hb_variation_t*>(axisValues.data()), 413 m_unscaledFont, reinterpret_cast<hb_variation_t*>(axisValues.data()),
421 axisValues.size()); 414 axisValues.size());
422 } 415 }
423 } 416 }
424 #endif
425 417
426 return m_unscaledFont; 418 return m_unscaledFont;
427 } 419 }
428 420
429 } // namespace blink 421 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698