OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
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 are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 for (auto it = holesQueue.begin(); it != holesQueue.end(); ++it) { | 301 for (auto it = holesQueue.begin(); it != holesQueue.end(); ++it) { |
302 if (it->m_action == HolesQueueNextFont) | 302 if (it->m_action == HolesQueueNextFont) |
303 break; | 303 break; |
304 | 304 |
305 UChar32 hintChar; | 305 UChar32 hintChar; |
306 RELEASE_ASSERT(it->m_startIndex + it->m_numCharacters <= | 306 RELEASE_ASSERT(it->m_startIndex + it->m_numCharacters <= |
307 m_normalizedBufferLength); | 307 m_normalizedBufferLength); |
308 UTF16TextIterator iterator(m_normalizedBuffer + it->m_startIndex, | 308 UTF16TextIterator iterator(m_normalizedBuffer + it->m_startIndex, |
309 it->m_numCharacters); | 309 it->m_numCharacters); |
310 while (iterator.consume(hintChar)) { | 310 while (iterator.consume(hintChar)) { |
311 hint.append(hintChar); | 311 hint.push_back(hintChar); |
312 numCharsAdded++; | 312 numCharsAdded++; |
313 iterator.advance(); | 313 iterator.advance(); |
314 } | 314 } |
315 } | 315 } |
316 return numCharsAdded > 0; | 316 return numCharsAdded > 0; |
317 } | 317 } |
318 | 318 |
319 namespace { | 319 namespace { |
320 using HolesQueueItem = HarfBuzzShaper::HolesQueueItem; | 320 using HolesQueueItem = HarfBuzzShaper::HolesQueueItem; |
321 using HolesQueueItemAction = HarfBuzzShaper::HolesQueueItemAction; | 321 using HolesQueueItemAction = HarfBuzzShaper::HolesQueueItemAction; |
(...skipping 25 matching lines...) Expand all Loading... |
347 void setFontFeatures(const Font* font, FeaturesVector* features) { | 347 void setFontFeatures(const Font* font, FeaturesVector* features) { |
348 const FontDescription& description = font->getFontDescription(); | 348 const FontDescription& description = font->getFontDescription(); |
349 | 349 |
350 static hb_feature_t noKern = createFeature(HB_TAG('k', 'e', 'r', 'n')); | 350 static hb_feature_t noKern = createFeature(HB_TAG('k', 'e', 'r', 'n')); |
351 static hb_feature_t noVkrn = createFeature(HB_TAG('v', 'k', 'r', 'n')); | 351 static hb_feature_t noVkrn = createFeature(HB_TAG('v', 'k', 'r', 'n')); |
352 switch (description.getKerning()) { | 352 switch (description.getKerning()) { |
353 case FontDescription::NormalKerning: | 353 case FontDescription::NormalKerning: |
354 // kern/vkrn are enabled by default | 354 // kern/vkrn are enabled by default |
355 break; | 355 break; |
356 case FontDescription::NoneKerning: | 356 case FontDescription::NoneKerning: |
357 features->append(description.isVerticalAnyUpright() ? noVkrn : noKern); | 357 features->push_back(description.isVerticalAnyUpright() ? noVkrn : noKern); |
358 break; | 358 break; |
359 case FontDescription::AutoKerning: | 359 case FontDescription::AutoKerning: |
360 break; | 360 break; |
361 } | 361 } |
362 | 362 |
363 static hb_feature_t noClig = createFeature(HB_TAG('c', 'l', 'i', 'g')); | 363 static hb_feature_t noClig = createFeature(HB_TAG('c', 'l', 'i', 'g')); |
364 static hb_feature_t noLiga = createFeature(HB_TAG('l', 'i', 'g', 'a')); | 364 static hb_feature_t noLiga = createFeature(HB_TAG('l', 'i', 'g', 'a')); |
365 switch (description.commonLigaturesState()) { | 365 switch (description.commonLigaturesState()) { |
366 case FontDescription::DisabledLigaturesState: | 366 case FontDescription::DisabledLigaturesState: |
367 features->append(noLiga); | 367 features->push_back(noLiga); |
368 features->append(noClig); | 368 features->push_back(noClig); |
369 break; | 369 break; |
370 case FontDescription::EnabledLigaturesState: | 370 case FontDescription::EnabledLigaturesState: |
371 // liga and clig are on by default | 371 // liga and clig are on by default |
372 break; | 372 break; |
373 case FontDescription::NormalLigaturesState: | 373 case FontDescription::NormalLigaturesState: |
374 break; | 374 break; |
375 } | 375 } |
376 static hb_feature_t dlig = createFeature(HB_TAG('d', 'l', 'i', 'g'), 1); | 376 static hb_feature_t dlig = createFeature(HB_TAG('d', 'l', 'i', 'g'), 1); |
377 switch (description.discretionaryLigaturesState()) { | 377 switch (description.discretionaryLigaturesState()) { |
378 case FontDescription::DisabledLigaturesState: | 378 case FontDescription::DisabledLigaturesState: |
379 // dlig is off by default | 379 // dlig is off by default |
380 break; | 380 break; |
381 case FontDescription::EnabledLigaturesState: | 381 case FontDescription::EnabledLigaturesState: |
382 features->append(dlig); | 382 features->push_back(dlig); |
383 break; | 383 break; |
384 case FontDescription::NormalLigaturesState: | 384 case FontDescription::NormalLigaturesState: |
385 break; | 385 break; |
386 } | 386 } |
387 static hb_feature_t hlig = createFeature(HB_TAG('h', 'l', 'i', 'g'), 1); | 387 static hb_feature_t hlig = createFeature(HB_TAG('h', 'l', 'i', 'g'), 1); |
388 switch (description.historicalLigaturesState()) { | 388 switch (description.historicalLigaturesState()) { |
389 case FontDescription::DisabledLigaturesState: | 389 case FontDescription::DisabledLigaturesState: |
390 // hlig is off by default | 390 // hlig is off by default |
391 break; | 391 break; |
392 case FontDescription::EnabledLigaturesState: | 392 case FontDescription::EnabledLigaturesState: |
393 features->append(hlig); | 393 features->push_back(hlig); |
394 break; | 394 break; |
395 case FontDescription::NormalLigaturesState: | 395 case FontDescription::NormalLigaturesState: |
396 break; | 396 break; |
397 } | 397 } |
398 static hb_feature_t noCalt = createFeature(HB_TAG('c', 'a', 'l', 't')); | 398 static hb_feature_t noCalt = createFeature(HB_TAG('c', 'a', 'l', 't')); |
399 switch (description.contextualLigaturesState()) { | 399 switch (description.contextualLigaturesState()) { |
400 case FontDescription::DisabledLigaturesState: | 400 case FontDescription::DisabledLigaturesState: |
401 features->append(noCalt); | 401 features->push_back(noCalt); |
402 break; | 402 break; |
403 case FontDescription::EnabledLigaturesState: | 403 case FontDescription::EnabledLigaturesState: |
404 // calt is on by default | 404 // calt is on by default |
405 break; | 405 break; |
406 case FontDescription::NormalLigaturesState: | 406 case FontDescription::NormalLigaturesState: |
407 break; | 407 break; |
408 } | 408 } |
409 | 409 |
410 static hb_feature_t hwid = createFeature(HB_TAG('h', 'w', 'i', 'd'), 1); | 410 static hb_feature_t hwid = createFeature(HB_TAG('h', 'w', 'i', 'd'), 1); |
411 static hb_feature_t twid = createFeature(HB_TAG('t', 'w', 'i', 'd'), 1); | 411 static hb_feature_t twid = createFeature(HB_TAG('t', 'w', 'i', 'd'), 1); |
412 static hb_feature_t qwid = createFeature(HB_TAG('q', 'w', 'i', 'd'), 1); | 412 static hb_feature_t qwid = createFeature(HB_TAG('q', 'w', 'i', 'd'), 1); |
413 switch (description.widthVariant()) { | 413 switch (description.widthVariant()) { |
414 case HalfWidth: | 414 case HalfWidth: |
415 features->append(hwid); | 415 features->push_back(hwid); |
416 break; | 416 break; |
417 case ThirdWidth: | 417 case ThirdWidth: |
418 features->append(twid); | 418 features->push_back(twid); |
419 break; | 419 break; |
420 case QuarterWidth: | 420 case QuarterWidth: |
421 features->append(qwid); | 421 features->push_back(qwid); |
422 break; | 422 break; |
423 case RegularWidth: | 423 case RegularWidth: |
424 break; | 424 break; |
425 } | 425 } |
426 | 426 |
427 // font-variant-numeric: | 427 // font-variant-numeric: |
428 static hb_feature_t lnum = createFeature(HB_TAG('l', 'n', 'u', 'm'), 1); | 428 static hb_feature_t lnum = createFeature(HB_TAG('l', 'n', 'u', 'm'), 1); |
429 if (description.variantNumeric().numericFigureValue() == | 429 if (description.variantNumeric().numericFigureValue() == |
430 FontVariantNumeric::LiningNums) | 430 FontVariantNumeric::LiningNums) |
431 features->append(lnum); | 431 features->push_back(lnum); |
432 | 432 |
433 static hb_feature_t onum = createFeature(HB_TAG('o', 'n', 'u', 'm'), 1); | 433 static hb_feature_t onum = createFeature(HB_TAG('o', 'n', 'u', 'm'), 1); |
434 if (description.variantNumeric().numericFigureValue() == | 434 if (description.variantNumeric().numericFigureValue() == |
435 FontVariantNumeric::OldstyleNums) | 435 FontVariantNumeric::OldstyleNums) |
436 features->append(onum); | 436 features->push_back(onum); |
437 | 437 |
438 static hb_feature_t pnum = createFeature(HB_TAG('p', 'n', 'u', 'm'), 1); | 438 static hb_feature_t pnum = createFeature(HB_TAG('p', 'n', 'u', 'm'), 1); |
439 if (description.variantNumeric().numericSpacingValue() == | 439 if (description.variantNumeric().numericSpacingValue() == |
440 FontVariantNumeric::ProportionalNums) | 440 FontVariantNumeric::ProportionalNums) |
441 features->append(pnum); | 441 features->push_back(pnum); |
442 static hb_feature_t tnum = createFeature(HB_TAG('t', 'n', 'u', 'm'), 1); | 442 static hb_feature_t tnum = createFeature(HB_TAG('t', 'n', 'u', 'm'), 1); |
443 if (description.variantNumeric().numericSpacingValue() == | 443 if (description.variantNumeric().numericSpacingValue() == |
444 FontVariantNumeric::TabularNums) | 444 FontVariantNumeric::TabularNums) |
445 features->append(tnum); | 445 features->push_back(tnum); |
446 | 446 |
447 static hb_feature_t afrc = createFeature(HB_TAG('a', 'f', 'r', 'c'), 1); | 447 static hb_feature_t afrc = createFeature(HB_TAG('a', 'f', 'r', 'c'), 1); |
448 if (description.variantNumeric().numericFractionValue() == | 448 if (description.variantNumeric().numericFractionValue() == |
449 FontVariantNumeric::StackedFractions) | 449 FontVariantNumeric::StackedFractions) |
450 features->append(afrc); | 450 features->push_back(afrc); |
451 static hb_feature_t frac = createFeature(HB_TAG('f', 'r', 'a', 'c'), 1); | 451 static hb_feature_t frac = createFeature(HB_TAG('f', 'r', 'a', 'c'), 1); |
452 if (description.variantNumeric().numericFractionValue() == | 452 if (description.variantNumeric().numericFractionValue() == |
453 FontVariantNumeric::DiagonalFractions) | 453 FontVariantNumeric::DiagonalFractions) |
454 features->append(frac); | 454 features->push_back(frac); |
455 | 455 |
456 static hb_feature_t ordn = createFeature(HB_TAG('o', 'r', 'd', 'n'), 1); | 456 static hb_feature_t ordn = createFeature(HB_TAG('o', 'r', 'd', 'n'), 1); |
457 if (description.variantNumeric().ordinalValue() == | 457 if (description.variantNumeric().ordinalValue() == |
458 FontVariantNumeric::OrdinalOn) | 458 FontVariantNumeric::OrdinalOn) |
459 features->append(ordn); | 459 features->push_back(ordn); |
460 | 460 |
461 static hb_feature_t zero = createFeature(HB_TAG('z', 'e', 'r', 'o'), 1); | 461 static hb_feature_t zero = createFeature(HB_TAG('z', 'e', 'r', 'o'), 1); |
462 if (description.variantNumeric().slashedZeroValue() == | 462 if (description.variantNumeric().slashedZeroValue() == |
463 FontVariantNumeric::SlashedZeroOn) | 463 FontVariantNumeric::SlashedZeroOn) |
464 features->append(zero); | 464 features->push_back(zero); |
465 | 465 |
466 FontFeatureSettings* settings = description.featureSettings(); | 466 FontFeatureSettings* settings = description.featureSettings(); |
467 if (!settings) | 467 if (!settings) |
468 return; | 468 return; |
469 | 469 |
470 // TODO(drott): crbug.com/450619 Implement feature resolution instead of | 470 // TODO(drott): crbug.com/450619 Implement feature resolution instead of |
471 // just appending the font-feature-settings. | 471 // just appending the font-feature-settings. |
472 unsigned numFeatures = settings->size(); | 472 unsigned numFeatures = settings->size(); |
473 for (unsigned i = 0; i < numFeatures; ++i) { | 473 for (unsigned i = 0; i < numFeatures; ++i) { |
474 hb_feature_t feature; | 474 hb_feature_t feature; |
475 const AtomicString& tag = settings->at(i).tag(); | 475 const AtomicString& tag = settings->at(i).tag(); |
476 feature.tag = HB_TAG(tag[0], tag[1], tag[2], tag[3]); | 476 feature.tag = HB_TAG(tag[0], tag[1], tag[2], tag[3]); |
477 feature.value = settings->at(i).value(); | 477 feature.value = settings->at(i).value(); |
478 feature.start = 0; | 478 feature.start = 0; |
479 feature.end = static_cast<unsigned>(-1); | 479 feature.end = static_cast<unsigned>(-1); |
480 features->append(feature); | 480 features->push_back(feature); |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 class CapsFeatureSettingsScopedOverlay final { | 484 class CapsFeatureSettingsScopedOverlay final { |
485 STACK_ALLOCATED() | 485 STACK_ALLOCATED() |
486 | 486 |
487 public: | 487 public: |
488 CapsFeatureSettingsScopedOverlay(FeaturesVector*, | 488 CapsFeatureSettingsScopedOverlay(FeaturesVector*, |
489 FontDescription::FontVariantCaps); | 489 FontDescription::FontVariantCaps); |
490 CapsFeatureSettingsScopedOverlay() = delete; | 490 CapsFeatureSettingsScopedOverlay() = delete; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 segmentRange.script, !fallbackIterator->hasNext())) | 668 segmentRange.script, !fallbackIterator->hasNext())) |
669 DLOG(ERROR) << "Shape result extraction failed."; | 669 DLOG(ERROR) << "Shape result extraction failed."; |
670 | 670 |
671 hb_buffer_reset(harfBuzzBuffer.get()); | 671 hb_buffer_reset(harfBuzzBuffer.get()); |
672 } | 672 } |
673 } | 673 } |
674 return result.release(); | 674 return result.release(); |
675 } | 675 } |
676 | 676 |
677 } // namespace blink | 677 } // namespace blink |
OLD | NEW |