| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 Deque<HolesQueueItem>* queue, | 372 Deque<HolesQueueItem>* queue, |
| 373 HolesQueueItem& currentQueueItem, | 373 HolesQueueItem& currentQueueItem, |
| 374 SmallCapsIterator::SmallCapsBehavior& smallCapsBehavior) { | 374 SmallCapsIterator::SmallCapsBehavior& smallCapsBehavior) { |
| 375 unsigned numCharactersUntilCaseChange = 0; | 375 unsigned numCharactersUntilCaseChange = 0; |
| 376 SmallCapsIterator smallCapsIterator( | 376 SmallCapsIterator smallCapsIterator( |
| 377 normalizedBuffer + currentQueueItem.m_startIndex, | 377 normalizedBuffer + currentQueueItem.m_startIndex, |
| 378 currentQueueItem.m_numCharacters); | 378 currentQueueItem.m_numCharacters); |
| 379 smallCapsIterator.consume(&numCharactersUntilCaseChange, &smallCapsBehavior); | 379 smallCapsIterator.consume(&numCharactersUntilCaseChange, &smallCapsBehavior); |
| 380 if (numCharactersUntilCaseChange > 0 && | 380 if (numCharactersUntilCaseChange > 0 && |
| 381 numCharactersUntilCaseChange < currentQueueItem.m_numCharacters) { | 381 numCharactersUntilCaseChange < currentQueueItem.m_numCharacters) { |
| 382 unsigned startIndex = | 382 queue->prepend(HolesQueueItem( |
| 383 currentQueueItem.m_startIndex + numCharactersUntilCaseChange; | 383 HolesQueueItemAction::HolesQueueRange, |
| 384 unsigned numCharacters = | 384 currentQueueItem.m_startIndex + numCharactersUntilCaseChange, |
| 385 currentQueueItem.m_numCharacters - numCharactersUntilCaseChange; | 385 currentQueueItem.m_numCharacters - numCharactersUntilCaseChange)); |
| 386 queue->prepend(HolesQueueItem(HolesQueueItemAction::HolesQueueRange, | |
| 387 startIndex, numCharacters)); | |
| 388 currentQueueItem.m_numCharacters = numCharactersUntilCaseChange; | 386 currentQueueItem.m_numCharacters = numCharactersUntilCaseChange; |
| 389 } | 387 } |
| 390 } | 388 } |
| 391 | 389 |
| 392 hb_feature_t createFeature(uint8_t c1, | 390 hb_feature_t createFeature(hb_tag_t tag, uint32_t value = 0) { |
| 393 uint8_t c2, | 391 return {tag, value, 0 /* start */, static_cast<unsigned>(-1) /* end */}; |
| 394 uint8_t c3, | |
| 395 uint8_t c4, | |
| 396 uint32_t value = 0) { | |
| 397 return {HB_TAG(c1, c2, c3, c4), value, 0 /* start */, | |
| 398 static_cast<unsigned>(-1) /* end */}; | |
| 399 } | 392 } |
| 400 | 393 |
| 401 void setFontFeatures(const Font* font, | 394 void setFontFeatures(const Font* font, |
| 402 HarfBuzzShaper::FeaturesVector* features) { | 395 HarfBuzzShaper::FeaturesVector* features) { |
| 403 const FontDescription& description = font->getFontDescription(); | 396 const FontDescription& description = font->getFontDescription(); |
| 404 | 397 |
| 405 static hb_feature_t noKern = createFeature('k', 'e', 'r', 'n'); | 398 static hb_feature_t noKern = createFeature(HB_TAG('k', 'e', 'r', 'n')); |
| 406 static hb_feature_t noVkrn = createFeature('v', 'k', 'r', 'n'); | 399 static hb_feature_t noVkrn = createFeature(HB_TAG('v', 'k', 'r', 'n')); |
| 407 switch (description.getKerning()) { | 400 switch (description.getKerning()) { |
| 408 case FontDescription::NormalKerning: | 401 case FontDescription::NormalKerning: |
| 409 // kern/vkrn are enabled by default | 402 // kern/vkrn are enabled by default |
| 410 break; | 403 break; |
| 411 case FontDescription::NoneKerning: | 404 case FontDescription::NoneKerning: |
| 412 features->append(description.isVerticalAnyUpright() ? noVkrn : noKern); | 405 features->append(description.isVerticalAnyUpright() ? noVkrn : noKern); |
| 413 break; | 406 break; |
| 414 case FontDescription::AutoKerning: | 407 case FontDescription::AutoKerning: |
| 415 break; | 408 break; |
| 416 } | 409 } |
| 417 | 410 |
| 418 static hb_feature_t noClig = createFeature('c', 'l', 'i', 'g'); | 411 static hb_feature_t noClig = createFeature(HB_TAG('c', 'l', 'i', 'g')); |
| 419 static hb_feature_t noLiga = createFeature('l', 'i', 'g', 'a'); | 412 static hb_feature_t noLiga = createFeature(HB_TAG('l', 'i', 'g', 'a')); |
| 420 switch (description.commonLigaturesState()) { | 413 switch (description.commonLigaturesState()) { |
| 421 case FontDescription::DisabledLigaturesState: | 414 case FontDescription::DisabledLigaturesState: |
| 422 features->append(noLiga); | 415 features->append(noLiga); |
| 423 features->append(noClig); | 416 features->append(noClig); |
| 424 break; | 417 break; |
| 425 case FontDescription::EnabledLigaturesState: | 418 case FontDescription::EnabledLigaturesState: |
| 426 // liga and clig are on by default | 419 // liga and clig are on by default |
| 427 break; | 420 break; |
| 428 case FontDescription::NormalLigaturesState: | 421 case FontDescription::NormalLigaturesState: |
| 429 break; | 422 break; |
| 430 } | 423 } |
| 431 static hb_feature_t dlig = createFeature('d', 'l', 'i', 'g', 1); | 424 static hb_feature_t dlig = createFeature(HB_TAG('d', 'l', 'i', 'g'), 1); |
| 432 switch (description.discretionaryLigaturesState()) { | 425 switch (description.discretionaryLigaturesState()) { |
| 433 case FontDescription::DisabledLigaturesState: | 426 case FontDescription::DisabledLigaturesState: |
| 434 // dlig is off by default | 427 // dlig is off by default |
| 435 break; | 428 break; |
| 436 case FontDescription::EnabledLigaturesState: | 429 case FontDescription::EnabledLigaturesState: |
| 437 features->append(dlig); | 430 features->append(dlig); |
| 438 break; | 431 break; |
| 439 case FontDescription::NormalLigaturesState: | 432 case FontDescription::NormalLigaturesState: |
| 440 break; | 433 break; |
| 441 } | 434 } |
| 442 static hb_feature_t hlig = createFeature('h', 'l', 'i', 'g', 1); | 435 static hb_feature_t hlig = createFeature(HB_TAG('h', 'l', 'i', 'g'), 1); |
| 443 switch (description.historicalLigaturesState()) { | 436 switch (description.historicalLigaturesState()) { |
| 444 case FontDescription::DisabledLigaturesState: | 437 case FontDescription::DisabledLigaturesState: |
| 445 // hlig is off by default | 438 // hlig is off by default |
| 446 break; | 439 break; |
| 447 case FontDescription::EnabledLigaturesState: | 440 case FontDescription::EnabledLigaturesState: |
| 448 features->append(hlig); | 441 features->append(hlig); |
| 449 break; | 442 break; |
| 450 case FontDescription::NormalLigaturesState: | 443 case FontDescription::NormalLigaturesState: |
| 451 break; | 444 break; |
| 452 } | 445 } |
| 453 static hb_feature_t noCalt = createFeature('c', 'a', 'l', 't'); | 446 static hb_feature_t noCalt = createFeature(HB_TAG('c', 'a', 'l', 't')); |
| 454 switch (description.contextualLigaturesState()) { | 447 switch (description.contextualLigaturesState()) { |
| 455 case FontDescription::DisabledLigaturesState: | 448 case FontDescription::DisabledLigaturesState: |
| 456 features->append(noCalt); | 449 features->append(noCalt); |
| 457 break; | 450 break; |
| 458 case FontDescription::EnabledLigaturesState: | 451 case FontDescription::EnabledLigaturesState: |
| 459 // calt is on by default | 452 // calt is on by default |
| 460 break; | 453 break; |
| 461 case FontDescription::NormalLigaturesState: | 454 case FontDescription::NormalLigaturesState: |
| 462 break; | 455 break; |
| 463 } | 456 } |
| 464 | 457 |
| 465 static hb_feature_t hwid = createFeature('h', 'w', 'i', 'd', 1); | 458 static hb_feature_t hwid = createFeature(HB_TAG('h', 'w', 'i', 'd'), 1); |
| 466 static hb_feature_t twid = createFeature('t', 'w', 'i', 'd', 1); | 459 static hb_feature_t twid = createFeature(HB_TAG('t', 'w', 'i', 'd'), 1); |
| 467 static hb_feature_t qwid = createFeature('q', 'w', 'i', 'd', 1); | 460 static hb_feature_t qwid = createFeature(HB_TAG('q', 'w', 'i', 'd'), 1); |
| 468 switch (description.widthVariant()) { | 461 switch (description.widthVariant()) { |
| 469 case HalfWidth: | 462 case HalfWidth: |
| 470 features->append(hwid); | 463 features->append(hwid); |
| 471 break; | 464 break; |
| 472 case ThirdWidth: | 465 case ThirdWidth: |
| 473 features->append(twid); | 466 features->append(twid); |
| 474 break; | 467 break; |
| 475 case QuarterWidth: | 468 case QuarterWidth: |
| 476 features->append(qwid); | 469 features->append(qwid); |
| 477 break; | 470 break; |
| 478 case RegularWidth: | 471 case RegularWidth: |
| 479 break; | 472 break; |
| 480 } | 473 } |
| 481 | 474 |
| 482 // font-variant-numeric: | 475 // font-variant-numeric: |
| 483 static hb_feature_t lnum = createFeature('l', 'n', 'u', 'm', 1); | 476 static hb_feature_t lnum = createFeature(HB_TAG('l', 'n', 'u', 'm'), 1); |
| 484 if (description.variantNumeric().numericFigureValue() == | 477 if (description.variantNumeric().numericFigureValue() == |
| 485 FontVariantNumeric::LiningNums) | 478 FontVariantNumeric::LiningNums) |
| 486 features->append(lnum); | 479 features->append(lnum); |
| 487 | 480 |
| 488 static hb_feature_t onum = createFeature('o', 'n', 'u', 'm', 1); | 481 static hb_feature_t onum = createFeature(HB_TAG('o', 'n', 'u', 'm'), 1); |
| 489 if (description.variantNumeric().numericFigureValue() == | 482 if (description.variantNumeric().numericFigureValue() == |
| 490 FontVariantNumeric::OldstyleNums) | 483 FontVariantNumeric::OldstyleNums) |
| 491 features->append(onum); | 484 features->append(onum); |
| 492 | 485 |
| 493 static hb_feature_t pnum = createFeature('p', 'n', 'u', 'm', 1); | 486 static hb_feature_t pnum = createFeature(HB_TAG('p', 'n', 'u', 'm'), 1); |
| 494 if (description.variantNumeric().numericSpacingValue() == | 487 if (description.variantNumeric().numericSpacingValue() == |
| 495 FontVariantNumeric::ProportionalNums) | 488 FontVariantNumeric::ProportionalNums) |
| 496 features->append(pnum); | 489 features->append(pnum); |
| 497 static hb_feature_t tnum = createFeature('t', 'n', 'u', 'm', 1); | 490 static hb_feature_t tnum = createFeature(HB_TAG('t', 'n', 'u', 'm'), 1); |
| 498 if (description.variantNumeric().numericSpacingValue() == | 491 if (description.variantNumeric().numericSpacingValue() == |
| 499 FontVariantNumeric::TabularNums) | 492 FontVariantNumeric::TabularNums) |
| 500 features->append(tnum); | 493 features->append(tnum); |
| 501 | 494 |
| 502 static hb_feature_t afrc = createFeature('a', 'f', 'r', 'c', 1); | 495 static hb_feature_t afrc = createFeature(HB_TAG('a', 'f', 'r', 'c'), 1); |
| 503 if (description.variantNumeric().numericFractionValue() == | 496 if (description.variantNumeric().numericFractionValue() == |
| 504 FontVariantNumeric::StackedFractions) | 497 FontVariantNumeric::StackedFractions) |
| 505 features->append(afrc); | 498 features->append(afrc); |
| 506 static hb_feature_t frac = createFeature('f', 'r', 'a', 'c', 1); | 499 static hb_feature_t frac = createFeature(HB_TAG('f', 'r', 'a', 'c'), 1); |
| 507 if (description.variantNumeric().numericFractionValue() == | 500 if (description.variantNumeric().numericFractionValue() == |
| 508 FontVariantNumeric::DiagonalFractions) | 501 FontVariantNumeric::DiagonalFractions) |
| 509 features->append(frac); | 502 features->append(frac); |
| 510 | 503 |
| 511 static hb_feature_t ordn = createFeature('o', 'r', 'd', 'n', 1); | 504 static hb_feature_t ordn = createFeature(HB_TAG('o', 'r', 'd', 'n'), 1); |
| 512 if (description.variantNumeric().ordinalValue() == | 505 if (description.variantNumeric().ordinalValue() == |
| 513 FontVariantNumeric::OrdinalOn) | 506 FontVariantNumeric::OrdinalOn) |
| 514 features->append(ordn); | 507 features->append(ordn); |
| 515 | 508 |
| 516 static hb_feature_t zero = createFeature('z', 'e', 'r', 'o', 1); | 509 static hb_feature_t zero = createFeature(HB_TAG('z', 'e', 'r', 'o'), 1); |
| 517 if (description.variantNumeric().slashedZeroValue() == | 510 if (description.variantNumeric().slashedZeroValue() == |
| 518 FontVariantNumeric::SlashedZeroOn) | 511 FontVariantNumeric::SlashedZeroOn) |
| 519 features->append(zero); | 512 features->append(zero); |
| 520 | 513 |
| 521 FontFeatureSettings* settings = description.featureSettings(); | 514 FontFeatureSettings* settings = description.featureSettings(); |
| 522 if (!settings) | 515 if (!settings) |
| 523 return; | 516 return; |
| 524 | 517 |
| 525 // TODO(drott): crbug.com/450619 Implement feature resolution instead of | 518 // TODO(drott): crbug.com/450619 Implement feature resolution instead of |
| 526 // just appending the font-feature-settings. | 519 // just appending the font-feature-settings. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 554 | 547 |
| 555 CapsFeatureSettingsScopedOverlay::CapsFeatureSettingsScopedOverlay( | 548 CapsFeatureSettingsScopedOverlay::CapsFeatureSettingsScopedOverlay( |
| 556 HarfBuzzShaper::FeaturesVector* features, | 549 HarfBuzzShaper::FeaturesVector* features, |
| 557 FontDescription::FontVariantCaps variantCaps) | 550 FontDescription::FontVariantCaps variantCaps) |
| 558 : m_features(features), m_countFeatures(0) { | 551 : m_features(features), m_countFeatures(0) { |
| 559 overlayCapsFeatures(variantCaps); | 552 overlayCapsFeatures(variantCaps); |
| 560 } | 553 } |
| 561 | 554 |
| 562 void CapsFeatureSettingsScopedOverlay::overlayCapsFeatures( | 555 void CapsFeatureSettingsScopedOverlay::overlayCapsFeatures( |
| 563 FontDescription::FontVariantCaps variantCaps) { | 556 FontDescription::FontVariantCaps variantCaps) { |
| 564 static hb_feature_t smcp = createFeature('s', 'm', 'c', 'p', 1); | 557 static hb_feature_t smcp = createFeature(HB_TAG('s', 'm', 'c', 'p'), 1); |
| 565 static hb_feature_t pcap = createFeature('p', 'c', 'a', 'p', 1); | 558 static hb_feature_t pcap = createFeature(HB_TAG('p', 'c', 'a', 'p'), 1); |
| 566 static hb_feature_t c2sc = createFeature('c', '2', 's', 'c', 1); | 559 static hb_feature_t c2sc = createFeature(HB_TAG('c', '2', 's', 'c'), 1); |
| 567 static hb_feature_t c2pc = createFeature('c', '2', 'p', 'c', 1); | 560 static hb_feature_t c2pc = createFeature(HB_TAG('c', '2', 'p', 'c'), 1); |
| 568 static hb_feature_t unic = createFeature('u', 'n', 'i', 'c', 1); | 561 static hb_feature_t unic = createFeature(HB_TAG('u', 'n', 'i', 'c'), 1); |
| 569 static hb_feature_t titl = createFeature('t', 'i', 't', 'l', 1); | 562 static hb_feature_t titl = createFeature(HB_TAG('t', 'i', 't', 'l'), 1); |
| 570 if (variantCaps == FontDescription::SmallCaps || | 563 if (variantCaps == FontDescription::SmallCaps || |
| 571 variantCaps == FontDescription::AllSmallCaps) { | 564 variantCaps == FontDescription::AllSmallCaps) { |
| 572 prependCounting(smcp); | 565 prependCounting(smcp); |
| 573 if (variantCaps == FontDescription::AllSmallCaps) { | 566 if (variantCaps == FontDescription::AllSmallCaps) { |
| 574 prependCounting(c2sc); | 567 prependCounting(c2sc); |
| 575 } | 568 } |
| 576 } | 569 } |
| 577 if (variantCaps == FontDescription::PetiteCaps || | 570 if (variantCaps == FontDescription::PetiteCaps || |
| 578 variantCaps == FontDescription::AllPetiteCaps) { | 571 variantCaps == FontDescription::AllPetiteCaps) { |
| 579 prependCounting(pcap); | 572 prependCounting(pcap); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 segmentRange.script, !fallbackIterator->hasNext())) | 718 segmentRange.script, !fallbackIterator->hasNext())) |
| 726 DLOG(ERROR) << "Shape result extraction failed."; | 719 DLOG(ERROR) << "Shape result extraction failed."; |
| 727 | 720 |
| 728 hb_buffer_reset(harfBuzzBuffer.get()); | 721 hb_buffer_reset(harfBuzzBuffer.get()); |
| 729 } | 722 } |
| 730 } | 723 } |
| 731 return result.release(); | 724 return result.release(); |
| 732 } | 725 } |
| 733 | 726 |
| 734 } // namespace blink | 727 } // namespace blink |
| OLD | NEW |