diff options
author | Roozbeh Pournader <roozbeh@google.com> | 2015-05-12 14:35:24 -0700 |
---|---|---|
committer | Roozbeh Pournader <roozbeh@google.com> | 2015-05-12 14:51:36 -0700 |
commit | 0dc07c0be325b7c12c50729e04c4b2785a673fd7 (patch) | |
tree | ff001ac27969fe02a6474fd53ba7b3332c7776ce /libs | |
parent | 8920e81717c6e51b92ff8f4479a1f959af260556 (diff) | |
download | android_frameworks_minikin-0dc07c0be325b7c12c50729e04c4b2785a673fd7.tar.gz android_frameworks_minikin-0dc07c0be325b7c12c50729e04c4b2785a673fd7.tar.bz2 android_frameworks_minikin-0dc07c0be325b7c12c50729e04c4b2785a673fd7.zip |
Support hyphenation frequency in Minikin.
Three hyphenation frequencies are now supported:
kHyphenationFrequency_None, which turns off both automatic
hyphenation and soft hyphens.
kHyphenationFrequency_Normal, which has aconservative amount of
hyphenation useful as a conservative default.
kHyphenationFrequency_Full, which has a typographic-quality amount of
hyphenation useful for running text and tight screens.
Bug: 21038249
Change-Id: I2800f718c887c9389a1a059d7ec07d7fa2ca1dee
Diffstat (limited to 'libs')
-rw-r--r-- | libs/minikin/LineBreaker.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/minikin/LineBreaker.cpp b/libs/minikin/LineBreaker.cpp index 88190ff..5eb077c 100644 --- a/libs/minikin/LineBreaker.cpp +++ b/libs/minikin/LineBreaker.cpp @@ -113,6 +113,9 @@ float LineBreaker::addStyleRun(MinikinPaint* paint, const FontCollection* typefa // a heuristic that seems to perform well hyphenPenalty = 0.5 * paint->size * paint->scaleX * mLineWidths.getLineWidth(0); + if (mHyphenationFrequency == kHyphenationFrequency_Normal) { + hyphenPenalty *= 4.0; // TODO: Replace with a better value after some testing + } } size_t current = (size_t)mBreakIterator->current(); @@ -140,7 +143,9 @@ float LineBreaker::addStyleRun(MinikinPaint* paint, const FontCollection* typefa // Override ICU's treatment of soft hyphen as a break opportunity, because we want it // to be a hyphen break, with penalty and drawing behavior. if (c != CHAR_SOFT_HYPHEN) { - if (paint != nullptr && mHyphenator != nullptr && wordEnd > lastBreak) { + if (paint != nullptr && mHyphenator != nullptr && + mHyphenationFrequency != kHyphenationFrequency_None && + wordEnd > lastBreak) { mHyphenator->hyphenate(&mHyphBuf, &mTextBuf[lastBreak], wordEnd - lastBreak); #if VERBOSE_DEBUG std::string hyphenatedString; @@ -426,6 +431,7 @@ void LineBreaker::finish() { mFlags.shrink_to_fit(); } mStrategy = kBreakStrategy_Greedy; + mHyphenationFrequency = kHyphenationFrequency_Normal; } } // namespace android |