• Home
  • History
  • Annotate
  • only in /frameworks/minikin/libs/minikin/
History log of /frameworks/minikin/libs/minikin/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9196194d76e4325c5bb0c23f22a5787a717067ed 18-Mar-2017 Seigo Nonaka <nona@google.com> Compute SparseBitSet for cmap format 14 subtables.

By computing cmap format 14 subtables similar to cmap format 4 or 12,
there are following benefits:
- FontCollection::hasVariationSelector becomes 70x faster for the worst
case, 10x faster for the normal case.
- FontFamily::hasGlyph becomes lock-free.
- FontCollection::itemize becomes 2x faster than before for some cases.

On the other hand, following negative things happen:
- Initial FontFamily construction takes 2.5x longer than before, but this
only happens in Zygote and should not happen at application launch time.
- FontFamily construction from buffer takes longer time than before but
it is still around 800µs.
- Consumes additionally memory (about 30kB for NotoSansCJK-Regular.ttc
of ttc index 0, 2.5kB for NotoColorEmoji.ttf), but this is shared across
all applications. No additional memory is necessary if the font doesn't
support variation sequences.

Bug: 36401726
Test: minikin_tests passed
Test: minikin_stress_tests passed
Test: android.graphics.cts.PaintTest passed
Merged-In: I3ebc9ad5050fb9ab6283810d31ae8d13af168ec5
Change-Id: Ia84c4b56aed35a899223e33c1a4a15734de58c33
mapCoverage.cpp
ontCollection.cpp
ontFamily.cpp
inikinInternal.cpp
inikinInternal.h
818fbee83a72ca86f64527eb90b2f15ec9b28504 14-Apr-2017 Seigo Nonaka <nona@google.com> Reduce heap memory in minikin.

This patch reduces about 73 kB memory.
The original SparseBitSet could contain full 32bit integers, but all of
that is not necessary for Unicode code points. By reducing the supported
range to up to Unicode maximum, U+10FFFF, we can save extra memory.

SparseBitSet holds 256-bit sliced pages and indices of them.
Previously, we needed to hold up to 2^24-1 pages for keeping 32-bit
integers.

This CL limits the number of pages to 2^16-1 (65535), so that
SparseBitSet only supports 24-bit integers now, but this is sufficient
for keeping all Unicode code points. With this change, we can change the
index integer type from uint32_t to uint16_t.

Bug: 37357593
Test: minikin_tests passes
Change-Id: I462cc27927752c942ac5da0bf303a5afb81b87a3
mapCoverage.cpp
inikinInternal.h
parseBitSet.cpp
db1b6cb7765091453d9b4dc7f6c2fb4d7123ab11 25-Mar-2017 Seigo Nonaka <nona@google.com> Support cmap tables with platform ID == 0

Some fonts don't have cmap subtables of Microsoft Platform ID (3) and
only have cmap subtables of Unicode Platform ID (0).

Bug: 32505843
Test: minikin_unittest passed
Test: android.graphics.cts.TypefaceTest passed
Change-Id: I24aa49860790c0ae8d8e578efd728b95ec0f93ae
mapCoverage.cpp
ontFamily.cpp
parseBitSet.cpp
bab3b98ceb29fa3fc5d8832284312859d7f32cc7 31-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Override the bidi properties of new emojis

Test: new Minikin tests are added, and pass
Bug: 32952475
Change-Id: Ibcae60d18d0cd5efd7556aaf58a716b6b59c8ee0
ndroid.mk
moji.cpp
ontCollection.cpp
raphemeBreak.cpp
ayout.cpp
inikinInternal.cpp
inikinInternal.h
ordBreaker.cpp
55e37071ab06ae46a87add9d54fe2b371b720241 31-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Remove unused classes and methods

Removed Bitmap and MinikinFontFreeType classes, as well
as the Layout::draw() method.

The code was there for debugging purposes and for potential
third-party users. We no longer support third-party uses of
Minikin, since we don't know of any.

Test: mmma -j frameworks/minikin builds with no errors
Change-Id: Iddc9e8d35334053bd5255bccf3dbe5ba1eecf814
ndroid.mk
ayout.cpp
inikinFontFreeType.cpp
dff5e5d5a1d0f17a1b5d2fd197b5a6389bc41e28 22-Mar-2017 Seigo Nonaka <nona@google.com> Remove unused functions.

This CL is essentially reverting following changes:
- "Serialize and deserialize supported axes."
I4086fb887e13f872390b533584bce6f1d5598ea0
- "Make SparseBitSet serializable."
I0463138adcf234739bb3ce1cdadf382021921f3e

Bug: 36232655
Test: N/A
Change-Id: I25c701e1805e92b01034142147a9925f86533819
ontFamily.cpp
parseBitSet.cpp
d8983d43240b28677767c487b48e8ca972cb53dd 18-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Relax requirement for text variation sequences

Previously, we insisted that in order for us to claim that a text variation
sequence is supported or to display it, it needs to be standardized already.
Now we accept any character as the base of a text variation sequence and
support it as far the font used to display it is not an emoji font.

Also fix a typo in a font name.

Test: Unit tests are updated and pass.

Bug: 30874706
Change-Id: I9660ec43aeee84303cfb825352a7f5029d036dd6
ontCollection.cpp
c97689439cb98ddf46fa279d8088b8c4a5f7b2f4 17-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Remove workaround for line breaks around currency symbols

This is now done properly in ICU so we no longer need to do it ourselves.

Also updated some comments about emoji line-breaking.

Test: Existings tests for this in Minikin continue to pass.
Bug: 24959657
Bug: 27365282
Change-Id: I865ea9ba1e79a64409d84d2d30c121f740e35ad6
ordBreaker.cpp
754913bd274b32ad66c1dfcf3bd592bb6c8c01bd 17-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Update Minikin to use ICU's emoji data

Certain differences are still needed, since ICU appears to support
Emoji 4.0 only, while we need Emoji 5.0. But the bulk of the data is
now carried by ICU.

We no longer need the script that generates the tables, so that's
also removed.

Test: Comprehensive unit tests added.
Bug: 27365282
Bug: 30874706
Change-Id: I011443fbca9bb202deff7fffb40043f89e1f1fb1
ndroid.mk
inikinInternal.cpp
nicode_emoji_h_gen.py
eb5a72899b657e61aaecb5a8a4b27cf8e9fe9b81 17-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Update emoji character data in Minikin"
0480d6daa40ecd83d8d23443fe794d699505fb0e 16-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Update emoji character data in Minikin

Update emoji character data to Unicode 10.0 / Emoji 5.0 (which also
removes U+1F93B MODERN PENATHLON from the emoji base letters).

Also add unit tests for line breaking for new characters (based on
earlier work by Seigo Nonaka).

Test: All new and existing unit tests pass;
Test: Manually tested line breaking of new emojis in TextView.

Bug: 28364892
Bug: 28678294
Bug: 30874706
Change-Id: I367cdab09187dc08a66a3112a5181a2b7fb338a5
inikinInternal.cpp
760508d856393432f5a38a767020fbd286ae5420 16-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Update emoji grapheme breaking rules"
34048ff4c46f142d64019cd7b0e97d5380e5611b 16-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Refactor WordBreaker"
93e9c9f71e7cb418287a0acc8d188e385ba11e43 16-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Update emoji grapheme breaking rules

The rules are updated to the latest UAX #29, with tailorings based on
the font in use: we can now use the clustering information
calculated by Layout, so we will only disallow a grapheme break if an
emoji ligature is actually formed.

Test: Unit tests have been updated and pass.
Bug: 30917298
Bug: 34211654
Change-Id: Idc0ef9f1f4f45dc45a50ed69e45c43ebfaea0306
raphemeBreak.cpp
8bdd9b948fc8a55ade32c2d84ff1a6b5be5659e1 16-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Refactor WordBreaker

Refactor WordBreaker to make it ready for more complex behavior.

Test: existing unit tests continue to pass
Change-Id: Ife758f3e2cf48922ab56109e6c5d3cffa3673feb
ordBreaker.cpp
919a48923ad3ad8407022735d075589a8017af43 16-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Serialize and deserialize supported axes."
92d8235c751947cb37a363da8f8227aced1da88d 15-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fallback from script-specific hyphens to normal hyphen first"
186f11581d9b4af4265dbd151b4dd7b77267c284 15-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "In greedy line breaking, repeat breaks until the line fits"
1adbccfd0f40ef416e4f76ea16cbc0bae549d669 15-Mar-2017 Seigo Nonaka <nona@google.com> Serialize and deserialize supported axes.

To avoid reading font files during FontFamily construction, serialize
and deserialize supported axes and cmap coverage at the same time.

Bug: 36232655
Test: ran minikin_tests
Change-Id: I4086fb887e13f872390b533584bce6f1d5598ea0
ontFamily.cpp
829f28371c4c4926965a5dbaec256f7e76e415f8 15-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Fallback from script-specific hyphens to normal hyphen first

The previous code fell back directly from a script-specific hyphen to
the ASCII hyphen-minus if the font didn't support the script-specific
hyphen. Now we try the Unicode hyphen (U+2010) first before trying
the ASCII hyphen-minus.

Bug: 36201363
Test: Not needed
Change-Id: I374234fd73fab7edd990ea86f8937c38761c90bf
ayout.cpp
67d1601c603970aecd737cf8b82f6a13648e0820 14-Mar-2017 Roozbeh Pournader <roozbeh@google.com> In greedy line breaking, repeat breaks until the line fits

Previously, in greedy line breaking, when a line overflowed, we found
the best line breaking candidate before it and broke the line there.
But we didn't check to see if the remaining part now fits in a line.

With this change, we now repeat checking for overflows, and break
again until we have no breaking opportunity or the remaining text now
fits in a line.

Also found an issue with greedy line breaking and keeping the
hyphenation edit for the next line which is now fixed.

Test: Manual. The issue reported in the bug is now fixed.
Bug: 34185255
Bug: https://code.google.com/p/android/issues/detail?id=231437
Bug: 33560754
Change-Id: I93bdd341e4f8e1257710e453e4938f224cb2a1ff
ineBreaker.cpp
f698f16c1e55f45e9dec650fe6d85b101b7b6b22 15-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Break grapheme clusters after viramas if they end a cluster"
99ef32cef014231c0d544e8d4f97449695d429c0 14-Mar-2017 Seigo Nonaka <nona@google.com> Do not keep FontCollection reference in Layout.

LayoutCache only keeps result of layout and can live after
FontCollection is destructed by GC.

This kind of failure will be captured by minikin_stress_tests in the
subsequent CL (I1bf4ba43e6e97cd04e7d6dd42d388dd17ce64c7b)

Test: ran minikin_tests
Bug: 36223724
Change-Id: I639b73c0f1041549158c43212a901c82df4b02db
ayout.cpp
b01028d1d7bc3906ef71c72ad985919f79304b5e 14-Mar-2017 Roozbeh Pournader <roozbeh@google.com> Break grapheme clusters after viramas if they end a cluster

Previously, we stayed on the conservative side and disallowed any
grapheme breaks (and thus cursoring) where a virama was followed by a
letter, since we did not know if the virama would be forming a
cluster with the letter or not. This created problems with Indic
languages with infrequent conjuncts, such as Tamil.

Now we use the information in calculated advances to find if a
cluster is formed. If there is no cluster, we break the grapheme and
allow cursoring after the virama.

Test: Unit tests added to GraphemeBreakTests and MeasurementTests.
Test: Also manually tested Tamil sequences.
Bug: 35721792
Change-Id: Ib159edb94b3ad6f693f0d3dad016b332b2cef447
raphemeBreak.cpp
easurement.cpp
fd4124c53399581dd94eac5a9749bc07b474a294 14-Mar-2017 Seigo Nonaka <nona@google.com> Revert "Use std::mutex instead of android::Mutex"

This reverts commit 62ad565335d4774bc5b31ced462e92566b48d197.

Bug: 36208043
Test: N/A

Change-Id: I165ab7a0718ea50a8034adb6277809e271fd762c
ontCollection.cpp
ontFamily.cpp
ontLanguageListCache.cpp
ontLanguageListCache.h
bFontCache.cpp
ayout.cpp
inikinFont.cpp
inikinInternal.cpp
inikinInternal.h
2cb3214e55f360fc76bc2ef1fe34359847c9d03f 14-Mar-2017 Seigo Nonaka <nona@google.com> Fix build failure due to unexpected merge.

FontLanguageListCache::kEmptyListId is gone, use kEmptyLanguageListId
instead.

Test: N/A
Change-Id: I96075849c53f23fbce8dbc180a51d8f97e45f316
ontFamily.cpp
44075ee9fa0e1c64defe1c2534d6ce1ff0f775a2 14-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Make SparseBitSet serializable."
fbbc5a6b361c623e47a433f83e7200b4e2ba3501 05-Jan-2017 Seigo Nonaka <nona@google.com> Make SparseBitSet serializable.

To share the calculated coverage information across the processes, make
SparseBitSet serializable.

Bug: 34042446
Test: minikin_tests passes
Change-Id: I0463138adcf234739bb3ce1cdadf382021921f3e
ontFamily.cpp
parseBitSet.cpp
62ad565335d4774bc5b31ced462e92566b48d197 21-Feb-2017 Seigo Nonaka <nona@google.com> Use std::mutex instead of android::Mutex

This CL includes:
- Stop using utils/Mutex and use std::mutex instead.
- Stop using utils/Singleton.

Test: minikin_tests passed
Change-Id: Ib3f75b83397a546472bb5f91e066e44506e78263
ontCollection.cpp
ontFamily.cpp
ontLanguageListCache.cpp
ontLanguageListCache.h
bFontCache.cpp
ayout.cpp
inikinFont.cpp
inikinInternal.cpp
inikinInternal.h
c436e925b4f1c42b7bcd61d6f2d7d8cbe6418348 17-Jan-2017 Seigo Nonaka <nona@google.com> Reduce memory usage of FontCollection.

This is 2nd attempt at I9e01d237c9adcb05e200932401cb1a4780049f86.

The previous CL was reverted because 8-bit integers were too small to
store the indices of mFamilyVec. This CL changes it to 16-bit integers
since size_t is still unnecessary large.

Theoretically, 32-bit integers are necessary for the indices of
mFamilyVec since the size of mFamilyVec can be 0x10EE01. However, in
practice, 16-bit integers are enough for the indices of mFamilyVec.
The length of mFamilyVec for the system fonts is 2084. Even if the
developers load their own very large fonts, it can only increase the
number of elements in mFamilyVec to at most 0x10FF.

As the result, memory usage of the FontCollections for the system fonts
decreases as follows.
64-bit process: before: 398,264 bytes, after: 282,568 bytes (-115,696 bytes)
32-bit process: before: 199,132 bytes, after: 149,548 bytes (-49,584 bytes)

Bug: 33562608
Test: Verified Emoji and CJK characters are present.
Test: android.text.cts.EmojiTest passed
Test: Minikin unit tests passed
Change-Id: I6796fd55ac30fe30528a212ebf6097b1d672e2f8
ontCollection.cpp
d78f260a988024b878909555edbfcd7159e7ad2f 28-Feb-2017 Roozbeh Pournader <roozbeh@google.com> Customizable min suffix/prefix length for hyphenation in Minikin

With this change, different languages can have a different minimum
length for suffix and prefixes when hyphenating. Previously, the
defaults used for English, 2 and 3, were used for every language.

Bug: 35712376
Test: Minikin unit tests were updated and the pass
Change-Id: Iffaf11c6b208c57d28d45b17246e177572dc1210
yphenator.cpp
c7ef4000c1e840c3d3b66e85a40ebd34a5a2a8ee 18-Feb-2017 Roozbeh Pournader <roozbeh@google.com> Correct hyphenation for various complex cases

This adds better support for Arabic script languages, Armenian,
Catalan, Hebrew, Kannada, Malayalam, Polish, Tamil, and Telugu by
adding various hyphenation types and edits appropriate for the
locales.

For Arabic script languages, soft hyphens act transparently with
regard to joining: If a line is broken at a soft hyphen where the two
characters around the soft hyphen were joining each other before,
they will continue to appear joining if the line is broken at the
soft hyphen and a hyphen glyph is inserted. This is needed for
Central Asian languages such as Uighur.

For Armenian, U+058A ARMENIAN HYPHEN is used for line breaks caused
by either automatic hyphenation or soft hyphens.

For Catalan, nonstandard line breaks are implemented for "l·l", which
hyphenates as "l-/l".

For Polish, when there is a line break at a hyphen, the hyphen is
repeated at the next line.

For the South Indic languages, when breaks happen due to soft breaks
or automatic hyphenation, no visible hyphen is inserted, although a
penalty is added.

For Hebrew, support for using U+05BE HEBREW PUNCTUATION MAQAF has
been implemented, but it's turned off pending confirmation of
desirability.

Also, hard hyphens, which previously had no penalty added for
breaking the line after them, now have the same penalty as an
automatic or soft break, with the difference that no hyphen is
inserted when they break.

Finally, some bugs have been fixed with hyphenating multiscript and
multi-font words.

Bug: 19950445
Bug: 19955011
Bug: 25623243
Bug: 26154469
Bug: 26154471
Bug: 33387871
Bug: 33560754
Bug: 33752592
Bug: 33754204
Test: Unit tests added, plus thorough manual testing
Change-Id: Iaccf776ce8d1d434ee8b1c534ff3659d80fdc338
ontCollection.cpp
yphenator.cpp
ayout.cpp
ineBreaker.cpp
ordBreaker.cpp
dfbc6e374259f9d81940b5195ac013b02429af27 10-Feb-2017 Seigo Nonaka <nona@google.com> Remove MinikinRefCounted and use shared_ptr instead

Let's use shared_ptr since manual ref counting can be a bug-prone and
using the global mutex inside destructor is not useful for some time.

To remove raw pointer manipulation, needed to change Layout
constructors. Layout is no longer copyable and need to pass
FontCollection to constructor.

Bug: 28119474
Test: minikin_tests passed
Test: hwui_unit_tests passed
Test: No performance regression in minikin_perftest.
Change-Id: I8824593206ecba74cbc9731e298f045e1ae442a3
ndroid.mk
ontCollection.cpp
ontFamily.cpp
bFontCache.cpp
bFontCache.h
ayout.cpp
ineBreaker.cpp
inikinFont.cpp
inikinInternal.cpp
inikinInternal.h
inikinRefCounted.cpp
39654bb6441b55f99341b613fc1194121b1e740b 13-Feb-2017 Seigo Nonaka <nona@google.com> Call hb_font_set_variation if font variations are provided.

Test: None
Change-Id: I203d9ba7e1a1fcfdb10cd6a711d9a35136cbddd6
bFontCache.cpp
22462be7358f1facbe0c0074f8e58a41c2314b6e 07-Feb-2017 Seigo Nonaka <nona@google.com> Pass region code to HarfBuzz.

Keep the region code and pass it to HarfBuzz during doing layout.

Test: minikin_tests
Bug: 30746293
Change-Id: I7c908701ca677238f663c82c597f8615d190e055
ontLanguage.cpp
ontLanguage.h
ayout.cpp
90d8b567ef79da279c677a7b8a57f3ebede3fbe5 14-Feb-2017 Roozbeh Pournader <roozbeh@google.com> Add U+202F NARROW NO-BREAK SPACE to the sticky white list

Mongolian fonts need to shape across U+202F NARROW NO-BREAK SPACE
(NNBSP). But if the first font in the fallback chain supports NNBSP,
it would break Mongolian shaping since the text would be broken into
three font runs. By making NNBSP sticky, we make sure Mongolian text
is kept in one font run and is shaped properly.

See http://www.unicode.org/L2/L2017/17036-mongolian-suffix.pdf for
background. The proposed character in the proposal was not accepted
for encoding by the Unicode Techincal Committee, but the document
explains in more detail why this change in needed.

Bug: 34344220
Test: manual
Change-Id: I344a63f383fa5485875603570025eac3c4eb2574
ontCollection.cpp
065c46a665d562c93ffa82fda10dee52a16ac23b 22-Nov-2016 Seigo Nonaka <nona@google.com> Introduce createCollectionWithVariation.

This is 2nd attempt of I08e9b74192f8af1d045f1276498fa4e60d73863e.
The original CL was reverted due to conflicting with another CL submitted
before.

Here is the original commit message of reverted change.

This lays the groundwork for variation settings support.
Since we should regard different variations of a font as different fonts, we
need to create new typefaces. To reuse the same instance of MinikinFont, as
much as possible, FontFamily::createFamilyWithVariation now reuses an
existence instance, while incrementing the reference count.

Test: minikin_tests
Bug: 33062398
Change-Id: Ib25bf1bb5a5191e15a6523954146521464c91906
nalyzeStyle.cpp
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ontUtils.cpp
ontUtils.h
41718c770d0ae12133270a4ee4a8dbd27851480d 28-Dec-2016 Seigo Nonaka <nona@google.com> Remove FontFamily.addFont and make FontFamily immutable.

This is 2nd attempt of 41e02e96131c1ec66d013e4615348be013518dc4
The difference is adding clearElementsEithLock to Font class which
is necessary to delete Fonts object outside of minikin. This method
should be removed once http://b/28119474 is fixed.

Here is original commit message of reverted change.

This lays the groundwork for making SparseBitSet serializable.
FontFamily.addFont is only used when the FontFamily is constructed.
Thus, instead of calling FontFamily.addFont multiple time, passes
Font list to the constructor. By this change, FontFamily can be
immutable now.

By making FontFamily immutable, We can create FontFamily with
pre-calculated SparseBitSet.

Bug: 34042446
Bug: 28119474
Bug: 34378805
Test: minikin_tests has passed
Change-Id: Ice433931196f5ae79a1a7ee0c98020f914aeb5f2
ontCollection.cpp
ontFamily.cpp
cc0352cc677e4ecea6ae12f734a010d290734e86 20-Jan-2017 Siyamed Sinir <siyamed@google.com> Revert "Remove FontFamily.addFont and make FontFamily immutable."

This reverts commit 41e02e96131c1ec66d013e4615348be013518dc4.

Bug: 34378805
Change-Id: I8f1ee00b365c8b17c6140e9e286fbea082e31364
ontCollection.cpp
ontFamily.cpp
e1d0fe1e93a1bcb674424f44e3e101544a33617b 20-Jan-2017 Siyamed Sinir <siyamed@google.com> Merge "Revert "Introduce createCollectionWithVariation.""
1c7b0261542f8a54e7b3e52236070f62d073e17f 20-Jan-2017 Siyamed Sinir <siyamed@google.com> Revert "Introduce createCollectionWithVariation."

This reverts commit 90e6b1885d44c33b1da9477a85dc7dd066acd33f.

Bug: 34378805
Change-Id: I22b683f774813724f220b1b8584ab188f3cf4fa7
nalyzeStyle.cpp
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ontUtils.cpp
ontUtils.h
22e7e464af843e340b0458004914144dbd6cd498 12-Jan-2017 Siyamed Sinir <siyamed@google.com> Merge "Revert "Reduce memory usage of FontCollection.""
1d753f6fe91ff47e5a76fa1707da91cfe90c200e 12-Jan-2017 Siyamed Sinir <siyamed@google.com> Revert "Reduce memory usage of FontCollection."

This reverts commit c4b989fc812af6c94018bad2e30ed6a006e2f8f5.

Test: Manually tested
Bug: 34247671
Change-Id: I0510009b2deac784770f26059681b1980800abc8
ontCollection.cpp
646a6f8035ba3917d187c79206443197c03535a5 12-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Introduce createCollectionWithVariation."
0decbb3686f9fe929bed1664b11366a00520e86a 12-Jan-2017 Seigo Nonaka <nona@google.com> Fix inverse condition of forColorEmoji.

We should override the advance function only when the glyph is came
from color bitmap. This was introduced by
Ia88cb670ca9e0bb352bccef22c5ea3a789bcc1da.

Bug: 21705974
Test: ran minikin_tests
Change-Id: I3489d75ace8bffdd9035a5986a2641313feef04d
ayout.cpp
90e6b1885d44c33b1da9477a85dc7dd066acd33f 22-Nov-2016 Seigo Nonaka <nona@google.com> Introduce createCollectionWithVariation.

This lays the groundwork for variation settings support.
Since we should regard different variations of a font as different fonts, we
need to create new typefaces. To reuse the same instance of MinikinFont, as
much as possible, FontFamily::createFamilyWithVariation now reuses an
existence instance, while incrementing the reference count.

Test: minikin_tests
Bug: 33062398
Change-Id: I08e9b74192f8af1d045f1276498fa4e60d73863e
nalyzeStyle.cpp
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ontUtils.cpp
ontUtils.h
dfab450f815bc7f93f4760041078724d2aa19eca 12-Jan-2017 Seigo Nonaka <nona@google.com> Merge "Use HarfBuzz metric implementation for emoji font."
a559cfd5df6a2ed740c2d680485160774764cc6e 12-Jan-2017 Seigo Nonaka <nona@google.com> Merge "Fix GraphemeBreak test failures."
bdb50a7cc54fc2edd8e8ed0f2923d6400e476ba8 12-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Remove FontFamily.addFont and make FontFamily immutable."
212f327e3dad3c16a5a2e05dc9b74a14b610c050 12-Jan-2017 Seigo Nonaka <nona@google.com> Merge "Reduce memory usage of FontCollection."
41e02e96131c1ec66d013e4615348be013518dc4 28-Dec-2016 Seigo Nonaka <nona@google.com> Remove FontFamily.addFont and make FontFamily immutable.

This lays the groundwork for making SparseBitSet serializable.
FontFamily.addFont is only used when the FontFamily is constructed.
Thus, instead of calling FontFamily.addFont multiple time, passes
Font list to the constructor. By this change, FontFamily can be
immutable now.

By making FontFamily immutable, We can create FontFamily with
pre-calculated SparseBitSet.

Bug: 34042446
Test: minikin_tests has passed
Change-Id: I2576789fba6cb27687e920e2488e8bedbcf7d36f
ontCollection.cpp
ontFamily.cpp
8a805cd2651b5d1b55d6af036a40c9b9c63c9d74 06-Jan-2017 Seigo Nonaka <nona@google.com> Fix GraphemeBreak test failures.

GraphemeBreak.tailoring/GraphemeBreak.genderBalancedEmoji start failing
after ICU update to 58. The failure is around Rule GB9 in Unicode Standard
Annex #29. GB9 forbids breaks before extending characters and before ZWJ.
However the implementation in minikin only checks for extending characters.
It used to work with Unicode 8.0 since ZWJ had the Grapheme_Cluster_Break
property of Extend in Unicode 8.0 but it no longer has that property in
Uniocde 9.0.
Thus, we need to check for ZWJ explicitly.

At the same time, this removes manually added PREPEND characters case from
tailoredGraphemeClusterBreak which is already supported in ICU 58.

Test: minikin_tests passes
Bug: 34117643
Change-Id: Ib46d48bebe4a866208e050d7defc715c61fcbeb1
raphemeBreak.cpp
afc31403d5c6322cd67e38439f41c1466c699b5b 11-Jan-2017 Seigo Nonaka <nona@google.com> Merge "Tune line breaking for justification"
58ee6af0c3f5ccef659119c8ffbeb8536fbb59e0 04-Dec-2016 Seigo Nonaka <nona@google.com> Use HarfBuzz metric implementation for emoji font.

To avoid lock contention in Skia, use HarfBuzz implementation
for retrieving boundary box and advance information from font.

Bug: 21705974
Test: Manually done

Change-Id: Ia88cb670ca9e0bb352bccef22c5ea3a789bcc1da
ayout.cpp
inikinInternal.h
77baca2bda0f8d313f48af2df0b397d5de94a132 10-Jan-2017 Mark Salyzyn <salyzyn@google.com> resolve merge conflicts of dff2a9d to master

Test: compile
Bug: 30465923
Change-Id: I9bcbf910e90a9160ed2fd2f75c5d72dba6ad6fcf
39ab40115fae6d0c948e435233b3dd997ee7d8e5 09-Jan-2017 Mark Salyzyn <salyzyn@google.com> minikin: use log/log.h when utilizing ALOG macros

Use log/log.h to harden code against liblog changes.

Test: compile
Bug: 30465923
Change-Id: I3dea82e76d28d9ef52d7c0f11e038c4298863eb9
ontCollection.cpp
ontFamily.cpp
ontLanguageListCache.cpp
bFontCache.cpp
ayout.cpp
ineBreaker.cpp
inikinInternal.cpp
parseBitSet.cpp
c4b989fc812af6c94018bad2e30ed6a006e2f8f5 13-Dec-2016 Seigo Nonaka <nona@google.com> Reduce memory usage of FontCollection.

Since switching to 64-bit devices, size_t is now a 64-bit integer.
FontCollection::Range uses two size_t integers but they just point to an index
in mFamilies. To reduce the memory usage, this CL changes the size_t integers to
uint8_t.

The maximum size of each integer in Range is the size of FontCollection::mFamilies.
The largest this can go is the system font list plus a user defined family, which
has 91 families. So an 8-bit integer should be enough.

With this change, about 84 KiB of memory will be saved per font collection. Since
eight font collections are created during bootstrap, about 670 KiB of memory will
be saved with this CL.

Bug: 33562608
Test: Ran FontCollection.collectionAllocationSizeTest on a 64-bit device.
On my Nexus 5X, it changed from 327358 to 241342.

Change-Id: I9e01d237c9adcb05e200932401cb1a4780049f86
ontCollection.cpp
3a74bcd0b4c4150cd524a37cdfa4e0ffe490cca6 24-Nov-2016 Seigo Nonaka <nona@google.com> Tune line breaking for justification

Add an "mJustified" for justification, and tune the line breaking to
produce good results. Major differences for fully justified text include:
- Space can be shrunk in justified text.
- Hyphenation should be more aggressive in justified text.

Also adds a penalty for the last line being very short. This is tuned
to be more aggressive for ragged right than for justified text.

This is based on a patch by Raph Levien (raph@google.com).

Bug: 31707212
Test: Manually tested with Icbfab2faa11a6a0b52e6f0a77a9c9b5ef6e191da
Change-Id: If366f82800831ccc247ec07b7bc28ca4c6ae0ed6
ineBreaker.cpp
32c12c0ac825453f4c3bba07718cfe684ec90bec 28-Dec-2016 Mark Salyzyn <salyzyn@google.com> resolve merge conflicts of 2377a00 to master

Test: build
Bug: 26552300
Bug: 31289077
Change-Id: I6181ae7e84f9bdcbed50841c70d07f6906a10eb7
555d84c6f98eafcbe677cdcb8e9605760acd8ce5 29-Sep-2016 Mark Salyzyn <salyzyn@google.com> minikin: Replace cutils/log.h with android/log.h or log/log.h

- replace cutils/log.h with android/log.h (main buffer logging)
- replace cutils/log.h with log.log.h (+SafetyNet logging)
- define LOG_TAG before use.

Test: compile
Bug: 26552300
Bug: 31289077
Change-Id: I7a4803dd66f31b7103e09e5ff5b8fa523fa0fd60
mapCoverage.cpp
ontCollection.cpp
ontFamily.cpp
ontLanguageListCache.cpp
bFontCache.cpp
ayout.cpp
ineBreaker.cpp
easurement.cpp
inikinInternal.cpp
parseBitSet.cpp
ordBreaker.cpp
d478da324d3b98e736b6c42415c02d506cfb653f 15-Sep-2016 Yirui Huang <yirui@google.com> Change language score calculation

Change language score calculation in the calculation of the font family.
Instead of language and script matching, a match in subtag is added.
In addition, a match in subtag has a higher priority than a match in
script. The score levels are divided into 5 score levels and the limit
of the number of font languages is changed to 12 from 17. Multiple
languages selection rule could to be added in the future.

Bug: 31608997
Test: Done by unittests.
Change-Id: I1e7177095f604fd1794bc99ca36c705dcb4c56e7
ontCollection.cpp
ontLanguage.cpp
ontLanguage.h
e1d7f6168a0a485ecac75cfc9ae3bdc5143d0fb1 12-Sep-2016 yirui <yirui@google.com> Parse Emoji subtag and store it to FontLanguage

Parse Emoji subtag and store into 4 different styles: default, text,
color and empty. Replace hasEmojiFlag function with getEmojiStyle to
get effective status according to script and subtag. However, score
calculation for the font selection needs to be completed in the next
stage. No performance regression is observed with this CL.

Bug: 31608997
Test: Done by unittests.
Change-Id: I923243641c946248dd5a0aa9fb9c940515310d34
ontCollection.cpp
ontFamily.cpp
ontLanguage.cpp
ontLanguage.h
fd77b01ff2cb5c55f02929b5821ddc41aee0cd05 18-Oct-2016 Seigo Nonaka <nona@google.com> Clean Up: Removing unused interface GetTable from MinikinFont.

This is 2nd attempt of Ifcd7a348d7fb5af081192899dbcdfc7fb4eebbf9

After Id766ab16a8d342bf7322a90e076e801271d527d4, GetTable is no longer
used in production due to poor performance and it is now only used in
tests. This CL removes GetTable interface from MinikinFont and update
tests code to use new interfaces, GetFontData, GetFontSize and
GetFontIndex.

Bug: 27860101
Test: Manually done
Change-Id: Ib48973ff25cdc61a4c666d28128266df0aaea83e
bFontCache.cpp
acd401d02981af51419f4b740abb2c41e4980fdb 15-Nov-2016 Seigo Nonaka <nona@google.com> Implement word spacing

Add a wordSpacing paint parameter, which will be used for
justification.

Bug: 31707212
Test: ran minikin_tests
Change-Id: I91224ab8ef882ac0c87425c28ab731fead283612
ayout.cpp
ayoutUtils.cpp
ayoutUtils.h
160fdd1f16fe2b83d30bb0f666cb4e5a2f14b95f 07-Nov-2016 Seigo Nonaka <nona@google.com> Merge "Fix lookup order for VS in itemization."
8d7ed7374b67fe16e8ce0815ec6f8d12c5126c9e 25-Oct-2016 Seigo Nonaka <nona@google.com> Revert "Clean Up: Removing unused interface GetTable from MinikinFont."

This reverts commit 1d525df4f0849a980c3204d5e4d41cbcc42f4ad6.

This causes a crash on Android Auto.

Bug: 32374752
Change-Id: Ia2ff77bf9a12351c6949f79ef6fa2d8016e3022d
bFontCache.cpp
1d525df4f0849a980c3204d5e4d41cbcc42f4ad6 18-Oct-2016 Seigo Nonaka <nona@google.com> Clean Up: Removing unused interface GetTable from MinikinFont.

After Id766ab16a8d342bf7322a90e076e801271d527d4, GetTable is no longer
used in production due to poor performance and it is now only used in
tests. This CL removes GetTable interface from MinikinFont and update
tests code to use new interfaces, GetFontData, GetFontSize and
GetFontIndex.

Bug: 27860101
Test: Manually done

Change-Id: Ifcd7a348d7fb5af081192899dbcdfc7fb4eebbf9
bFontCache.cpp
4a4e6574c02774c758974c1fadf161f829baaaa3 23-Jun-2016 Seigo Nonaka <nona@google.com> Fix lookup order for VS in itemization.

This is partial revert of Iced1349e3ca750821d8882c551551f65bb569794.

Due to sorting of target family vectors, the font family order from XML
settings file is broken. Making unique operation stable doesn't fix the
issue completely since some font families are appended for the fallback
which also breaks the original order.

By this change, itemization becomes 3x slower than before if variation
selector is appended.

Bug: 29585939
Change-Id: I7c1a8a57f04111a30cd41a5cd5bec25fcfb3972e
ontCollection.cpp
d7f177ca30cef185e78cef27461ce3ecd7d95b2f 13-Sep-2016 Dan Willemsen <dwillemsen@google.com> Merge "Rename libicuuc-host/libicui18n-host to libicuuc/libicui18n" am: 00b9a21209 am: acad3df882 am: f58fc7b5ff
am: 229f35a43a

Change-Id: I85ee278323a578fcf941651161b46ef0559098cc
229f35a43a86134d977fad0770d83d4c0482192e 13-Sep-2016 Dan Willemsen <dwillemsen@google.com> Merge "Rename libicuuc-host/libicui18n-host to libicuuc/libicui18n" am: 00b9a21209 am: acad3df882
am: f58fc7b5ff

Change-Id: I346fddaa5822eee2371d877a8bdeb055b6244c0d
00b9a21209f6a9117f4915eb3fc074564e21aadd 13-Sep-2016 Dan Willemsen <dwillemsen@google.com> Merge "Rename libicuuc-host/libicui18n-host to libicuuc/libicui18n"
57e469e6f8616c4de758441547a97c9ed4dbfcdf 13-Sep-2016 Elliott Hughes <enh@google.com> Switch minikin to std::unique_ptr. am: 6261d82459 am: e716bdbd48 am: 2583c5c86b
am: bb3df55710

Change-Id: I56cce90607bce82d337d4da3b4ac5f167c7cc1b4
bb3df55710fa8a6eaf4382271895f2bb45efb648 13-Sep-2016 Elliott Hughes <enh@google.com> Switch minikin to std::unique_ptr. am: 6261d82459 am: e716bdbd48
am: 2583c5c86b

Change-Id: I9c0b81d55e01b08b053a7031a214626351244607
6261d824595d3590b5355d8dea80949769d8e38e 11-Sep-2016 Elliott Hughes <enh@google.com> Switch minikin to std::unique_ptr.

Bug: http://b/22403888
Change-Id: I9e18496fcc38ad2e6b922455daa9f2a46778ec55
ontFamily.cpp
ayout.cpp
ccfc696dfc91d045271e0b2f92da90d2579a65df 12-Sep-2016 Dan Willemsen <dwillemsen@google.com> Rename libicuuc-host/libicui18n-host to libicuuc/libicui18n

These modules can be named the same between the target and host
libraries, which simplifies references to them, particularly in
Soong.

To prevent accidentally loading the system copy of the library,
we still rename the installed name to be libicu*-host.so. But
modules do not need to know that in order to build against them.

Change-Id: Ic38499bb236ace75333a84f23798af023e14cf5f
ndroid.mk
47b905f6840ea6776d6f6778915e7408a1ff8be4 15-Aug-2016 Chih-Hung Hsieh <chh@google.com> Fix google-explicit-constructor warnings in minikin

* Add explicit keyword to conversion constructors,
or add NOLINT(implicit) for implicit converters.
Bug: 28341362
Test: build with WITH_TIDY=1

Change-Id: I0c7b90f9bb953a9f2e4f0fb2032fa65ac604b9ca
ontLanguage.h
inikinInternal.h
b830102259584c873413d369659480188cb16641 12-Aug-2016 Roozbeh Pournader <roozbeh@google.com> Revert "Lookup glyph from color emoji font before and after ZWJ." am: 1aa0c40db9 am: de728a34c9
am: f83d57f7e5

Change-Id: Iebf945839891cc1ab561cf424ef917ac15e08842
1aa0c40db9d3d308758fc836ac117a9b4e3723a5 11-Aug-2016 Roozbeh Pournader <roozbeh@google.com> Revert "Lookup glyph from color emoji font before and after ZWJ."

This reverts commit 9431bb96406121d2eb3fda8ca8209edc434f96a0.

Bug: 30815709
Change-Id: I057d9bcd05246e58894abb4e9633bd10f6fab211
ontCollection.cpp
9431bb96406121d2eb3fda8ca8209edc434f96a0 11-Jul-2016 Seigo Nonaka <nona@google.com> Lookup glyph from color emoji font before and after ZWJ.

Unicode recommends that the zwj sequences should be emoji presentation
even if they don't have the proper U+FE0F. Thus always lookup the glyph
for the code point before and after zwj as if they have a U+FE0F
variation selector.

Bug: 30056627
Change-Id: I03958a92337eaba4a8dd9c5be824b2665aa4a103
ontCollection.cpp
c2642f9a33b640e0ad25b17dc6f9d0734297166a 30-Jun-2016 Seigo Nonaka <nona@google.com> Treat U+2695, U+2640, U+2642 as emoji characters.

Bug: 29885295
Change-Id: I1bf191a46d05e7099265d863bae0523c50817d0b
ontCollection.cpp
inikinInternal.cpp
fab99dde4be50b6377ecc0873ac33f3f4cacf36a 08-Jul-2016 Seigo Nonaka <nona@google.com> Add some gender balanced components in to the sticky whitelist.

FEMALE SIGN(U+2640), MALE SIGN(U+2642), StAFF OF AESCULAPIUS(U+2695)
will be used as the ZWJ sequenced in gender balanced emoji sequence.
To be in the same run with ZWJ, mark these emoji as sticky chracters.

With this fix, Female police officer sequence will be shown correctly
regardless of VS16.

Bug: 30026374
Change-Id: I503fc061eaa943d45208bb69e885151610c430ce
ontCollection.cpp
98487de54771df7bd1bb2a6d0ad5fbc736832f95 11-Jul-2016 Seigo Nonaka <nona@google.com> Lookup glyph from color emoji font before and after ZWJ.

Unicode recommends that the zwj sequences should be emoji presentation
even if they don't have the proper U+FE0F. Thus always lookup the glyph
for the code point before and after zwj as if they have a U+FE0F
variation selector.

Bug: 30056627
Change-Id: I03958a92337eaba4a8dd9c5be824b2665aa4a103
ontCollection.cpp
1946f48e84fd67943dd2d09b3fee94028fbfe762 30-Jun-2016 Seigo Nonaka <nona@google.com> Treat U+2695, U+2640, U+2642 as emoji characters.

Bug: 29885295
Change-Id: I1bf191a46d05e7099265d863bae0523c50817d0b
ontCollection.cpp
inikinInternal.cpp
435076ff2e3cae9e06f4d6069b0352a030787bde 08-Jul-2016 Seigo Nonaka <nona@google.com> Add some gender balanced components in to the sticky whitelist.

FEMALE SIGN(U+2640), MALE SIGN(U+2642), StAFF OF AESCULAPIUS(U+2695)
will be used as the ZWJ sequenced in gender balanced emoji sequence.
To be in the same run with ZWJ, mark these emoji as sticky chracters.

With this fix, Female police officer sequence will be shown correctly
regardless of VS16.

Bug: 30026374
Change-Id: I503fc061eaa943d45208bb69e885151610c430ce
ontCollection.cpp
14e2d136aaef271ba131f917cf5f27baa31ae5ad 09-Jun-2016 Seigo Nonaka <nona@google.com> Always use minikin namespace.

Here is a new policy of the namespace of minikin.
- All components should be in minikin namespace.
- All tests are also in minikin namespace and no anonymous namespace.

Bug: 29233740
Change-Id: I71a8a35049bb8d624f7a78797231e90fed1e2b8c
nalyzeStyle.cpp
mapCoverage.cpp
ontCollection.cpp
ontFamily.cpp
ontLanguage.cpp
ontLanguage.h
ontLanguageListCache.cpp
ontLanguageListCache.h
raphemeBreak.cpp
bFontCache.cpp
bFontCache.h
yphenator.cpp
ayout.cpp
ayoutUtils.cpp
ayoutUtils.h
ineBreaker.cpp
easurement.cpp
inikinFont.cpp
inikinFontFreeType.cpp
inikinInternal.cpp
inikinInternal.h
inikinRefCounted.cpp
parseBitSet.cpp
ordBreaker.cpp
nicode_emoji_h_gen.py
74b56175e5d41c1c1dc992208842b5576973d452 26-May-2016 Roozbeh Pournader <roozbeh@google.com> Do not break after Myanmar viramas

This is to work around a bug in ICU's line breaker, which thinks
there is a valid line break between a Myanmar kinzi and a consonant.
See http://bugs.icu-project.org/trac/ticket/12561 for the ICU bug.

Bug: 28964845
Change-Id: I076ac15077e5627cbccf6732900bcc60d8596dda
ordBreaker.cpp
77f488345316fba46c271fc04bea470819ae1712 19-Apr-2016 Seigo Nonaka <nona@google.com> Do not break before and after ZWJ.

The emoji list is generated from external/unicode/emoji-data.txt

Bug: 28248662
Change-Id: Ie49b3782505665d62c24371ca23d317ae5e9c5f7
ndroid.mk
raphemeBreak.cpp
inikinInternal.cpp
inikinInternal.h
ordBreaker.cpp
nicode_emoji_h_gen.py
994aa84f7b18466806fe552ea57da1852b909f24 08-Mar-2016 Seigo Nonaka <nona@google.com> Returns hasVariationSelector true for VS15/VS16

Minikin has a special font fallback for VS15/VS16, so
hasVariationSelector for emojis with VS15/VS16 should always return
true.

Bug: 27531970
Change-Id: Ieebd58f48b135b6ec50d999df68dcc09b1284606
ontCollection.cpp
ontFamily.cpp
b1203b648acb109fddd537f8d76d168b7f70103e 13-Apr-2016 Raph Levien <raph@google.com> Merge "Clear mLineWidths in LineBreaker::finish()" into nyc-dev
879e8a3a479b2cedd05e652f082683a02aa57dcf 13-Apr-2016 Raph Levien <raph@google.com> Clear mLineWidths in LineBreaker::finish()

There was the possibility of stale indents from previous invocations
persisting in the mLineWidths across multiple invocations. This patch
clears them.

Bug: 28090810
Change-Id: I3621dfbe983512046289373711709aeade52eab4
ineBreaker.cpp
6c60831cfce24b0749f50f37231e0a56d8fd4b85 11-Apr-2016 Seigo Nonaka <nona@google.com> Fix minikin_unittests

This CL fixes following test cases in minikin_tests
- FontFamilyTest.hasVariationSelectorTest
- HbFontCacheTest.getHbFontLockedTest
- HbFontCacheTest.purgeCacheTest

For the fix of FontFamilyTest.hasVariationSelectorTest, removing virtual
from GetUniqueId() in MinikinFont. After [1], MinikinFont's destructor
started calling purgeHbCache() which calls virtual method,
MinikinFont::GetUniqueId(). Fortunately, the SkTypeface::uniqueID()
returns just internal value, so we can store it at the construction time
and use it instead of calling SkTypeface::uniqueID() every time.

This patch also changes purgeHbFont to purgeHbFontLocked, as all uses of
it were already under global mutex. This change avoids deadlock on
explicit unref, as when invoked by a Java finalizer from the Java object
that holds a reference to the font.

Some of the tests needed to change to using the ref counting protocol
rather than explicitly destructing font objects, as well.

[1] 9afcc6e2bd4d89e4e1deb6e18c3c4daca4e114fd

Bug: 28105730
Bug: 28105688
Change-Id: Ie5983c4869147dacabdca81af1605066cd680b3f
bFontCache.cpp
bFontCache.h
inikinFont.cpp
inikinFontFreeType.cpp
aaa4e3470270496e6eb80704eadecb2cb7c56bf0 07-Apr-2016 Raph Levien <raph@google.com> Avoid copying of font table data

The hb_font_t object holds on to tables of font data, acquired through
the MinikinFont::GetTable interface, which is based on copying data
into caller-owned buffers. Now that we're caching lots of hb_font_t's,
the cost of these buffers is significant.

This patch moves to a different interface, inspired by HarfBuzz's
hb_reference_table API, where the font can provide a pointer to the
actual font data (which will often be mmap'ed, so it doesn't even
consume physical RAM).

Bug: 27860101
Change-Id: Id766ab16a8d342bf7322a90e076e801271d527d4
ontFamily.cpp
bFontCache.cpp
ayout.cpp
inikinFontFreeType.cpp
inikinInternal.cpp
inikinInternal.h
9afcc6e2bd4d89e4e1deb6e18c3c4daca4e114fd 07-Apr-2016 Raph Levien <raph@google.com> Purge hb font on Minikin font destruction

This patch eagerly purges the corresponding hb_font_t object from
the HbFontCache when the underlying MinikinFont is destroyed. After
that, the key will no longer be accessed, so having the entry is
wastes memory.

Bug: 27251075
Bug: 27860101
Change-Id: I1b98016133fe3baf6525ac37d970a65ddccadb4f
ndroid.mk
bFontCache.cpp
bFontCache.h
inikinFont.cpp
f3afe92def0fff022889fd036d68451223aac146 25-Jan-2016 Seigo Nonaka <nona@google.com> Support multiple locales for font language settings.

Some fonts support multiple scripts, for example, some fonts for
Korean supports not only "Kore" but also "Jamo".

To select fonts based on their multiple languages, this CL introduces
the following changes:
- Compares all languages of the font family and use the maximum score
for font selection.
- Even if each language of the font family doesn't support the requested
language, the font get score of 2 if the requested font is covered by
all of the languages of the font family. For example, the font for
"ko-Hang,ko-Hani" gets score of 2 for the requested language "ko-Kore".

Bug: 26687969

Change-Id: I7f13b51464c9b01982bb573251d77052b9ddbd70
ontCollection.cpp
ontLanguage.cpp
ontLanguage.h
ontLanguageListCache.cpp
16ed4ef07ed8fb2333447b48055633bf8d4f38e4 31-Mar-2016 Roozbeh Pournader <roozbeh@google.com> Try putting combining marks in the same font run

Indic combining marks, when combined with a common character such as
a hyphen or a dotted circle, used to get rendered in a different font
due to the greedy algorithm used in determining runs, which resulted
in the base character and the combining mark getting rendered in
separate font runs, resulting in a dotted circle appearing in phrases
such as "100-ാം" (0031 0030 0030 002D 0D3E 0D02).

This change makes combining marks change the font run of the base
character if the base character is supported in the same font as the
combining mark, similar to the support for emoji modifiers and the
combining keycap.

Bug: 25036888
Bug: 24535344
Change-Id: I8e2798e8ecb8efaf723a0fd02c05c6fbdef8b365
ontCollection.cpp
d8917c69a9f7b7ca52f7ac850922dab4322113f5 16-Mar-2016 Roozbeh Pournader <roozbeh@google.com> Do not allow line breaks before currency symbols

Implement the change proposed in UTC document L2/16-043R
(http://www.unicode.org/L2/L2016/16043r-line-break-pr-po.txt) to make
sure we do not break between letters and currency symbols.

Bug: 24959657
Change-Id: Ia29d0e5625f84870bd910d0c6e19036d17206704
ordBreaker.cpp
cee83d40324b1f3b8e113eb8c9eda8e12ef36923 04-Mar-2016 Seigo Nonaka <nona@google.com> Suppress log span due to returning null for itemize result.

Bug: 26808815
Change-Id: I2a5a52f2c441d27c7ef270342b4ef93c3de9e56e
ontCollection.cpp
450e96c8170c3d59a5896e734c90d3f9def505f8 02-Mar-2016 Seigo Nonaka <nona@google.com> Break regional indicators at even numbered code points.

Bug: 23288449
Change-Id: If1419ff9e44e8e640616979bae88311f414b42a1
raphemeBreak.cpp
1934c2c3cb2c93aa12f852f95915190f8ac81fac 27-Feb-2016 Raph Levien <raph@google.com> Fix wrong conditions in isEmojiBase

I computed ranges using low <= c || c <= high, should be &&.

Bug: 26829153
Change-Id: Ic1002d90b6a408a0b415f2d117d0e57adcbc2fa9
inikinInternal.cpp
56840e8006ca2b822adb401fc8a65f3c075cde10 25-Feb-2016 Raph Levien <raph@google.com> Suppress line breaks in emoji + modifier

An emoji base with an emoji modifier renders as a single glyph and
thus should not be a line break. Current (Unicode 8) logic does
indicate a line break, so we override the results of the ICU line
break iterator. The code references a proposal to improve Unicode
behavior; when that is adopted and we upgrade ICU accordingly, the
special-case code should be deleted, but the tests can remain.

Bug: 27343378
Change-Id: I5de9c53e9a34c503816f9131e3d894e6f7a57d13
ordBreaker.cpp
0036da164e3b25f1ac29c840c1fe15b03dc6677f 25-Feb-2016 Seigo Nonaka <nona@google.com> Use color font if skin tone is specified.

If skin tone is specified, the base emoji should be emoji style even
if it is text presentation default emoji.

This patch also removes wrong test case which expects default emoji
presentation but it is controlled by family order in /etc/fonts.xml
and there is no special logic for default presentation in minikin.
Thus the default presentation unit test should not be in minikin.

Bug: 27342346

Change-Id: I74a2b2feab4d559535049e368cfd833063cce81c
ontCollection.cpp
raphemeBreak.cpp
inikinInternal.cpp
inikinInternal.h
94d5525508b60407c9224fbd279a9f6932d5fb6c 24-Feb-2016 Raph Levien <raph@google.com> Merge "Suppress grapheme cluster breaks in emoji with modifiers" into nyc-dev
adfa580f1f067c846509b4346e5be2cb19177c1b 22-Feb-2016 Raph Levien <raph@google.com> Suppress grapheme cluster breaks in emoji with modifiers

An emoji with a modifier should be treated as a single grapheme, i.e.
it should not be possible to place the cursor between the base and
modifier. This patch implements the proposed Rule GB9c from Mark
Davis's proposal entitled "Fixing breaking properties for emoji",
L2/16-011R3.

The patch also skips over variation sequences attached the to the
preceding character, for computing grapheme cluster boundaries.

Bug: 26829153
Change-Id: Iff5bc2bb8e5246223a017c7cf33acfbf63817f16
raphemeBreak.cpp
dbf5c2776bb2de1baf1cd5e53ce21f5bd3226052 23-Feb-2016 Seigo Nonaka <nona@google.com> Merge "Support Hanb script." into nyc-dev
30bf8a7c05925a970f1cab87c38bec8dd97fa82e 19-Feb-2016 Raph Levien <raph@google.com> Merge "Suppress linebreaks in emoji ZWJ sequences" into nyc-dev
d3f45892c721fb1738bf02fe19a5143a320ca4bf 19-Feb-2016 Raph Levien <raph@google.com> Suppress linebreaks in emoji ZWJ sequences

Due to the way emoji ZWJ sequences are defined, the ICU line breaking
algorithm determines that there are valid line breaks inside the
sequence. This patch suppresses these line breaks.

This is an adaptation of I225ebebc0f4186e4b8f48fee399c4a62b3f0218a
into the nyc-dev branch.

Bug: 25433289
Change-Id: I84b50b1e6ef13d436965eab389659d02a30d100f
ordBreaker.cpp
ea408fc18e8e78d984ebdf63703da668a15720de 18-Feb-2016 Keisuke Kuroyanagi <ksk@google.com> Optimize: Use measureText instead of doLayout.

With this CL, measureText is used for getRunAdvance,
getOffsetForAdvance and line breaking.

Bug: 24505153
Change-Id: Ib699f6b1391b46537736fc274cdb41686586b550
ineBreaker.cpp
easurement.cpp
aa736d00548da691e75a09a70deb886e1f68b060 18-Feb-2016 Raph Levien <raph@google.com> Disable hyphenation when word overlaps style boundary

In cases when a word (as defined by the ICU break iterator) overlaps a
style boundary, the returned wordStart can be extend before the range
currently being measured for layout. When we try to hyphenate the
resulting substrings, we get a negative range, which crashes. This
patch disables hyphenation in this case.

Bug: 27237112
Change-Id: I76d04b39dd3b4d6d267aaaf4bebc9ab361891646
ineBreaker.cpp
533a01ea8438bb102b0dbc71f6c4ef356b260ed5 22-Jan-2016 Seigo Nonaka <nona@google.com> Support Hanb script.

Hanb is a union of Han and Bopomofo.

Bug: 26687969
Change-Id: Ic696bcbbc9607f3842fd0115668b8e7bd917e62b
ontLanguage.cpp
ontLanguage.h
bcb024df56c8ae7a5914d6f060ac99a2b5d118d9 18-Feb-2016 Seigo Nonaka <nona@google.com> Merge "Improve Paint.measureText and Paint.hasGlyph for variation sequences." into nyc-dev
2f0604dce2207ba3223cc5f5cdd0642e25c0b6e3 18-Feb-2016 Raph Levien <raph@google.com> Add error logging on invalid cmap am: 734f037130 am: c91a77cf22
am: c3433aca7a

* commit 'c3433aca7acac7f642ba0dcc07429027d0453348':
Add error logging on invalid cmap
c3433aca7acac7f642ba0dcc07429027d0453348 18-Feb-2016 Raph Levien <raph@google.com> Add error logging on invalid cmap am: 734f037130
am: c91a77cf22

* commit 'c91a77cf2236f8806b503a14adbbc19828f7bc89':
Add error logging on invalid cmap
c91a77cf2236f8806b503a14adbbc19828f7bc89 18-Feb-2016 Raph Levien <raph@google.com> Add error logging on invalid cmap
am: 734f037130

* commit '734f037130e14b3d44bc74026d3d065c025a8280':
Add error logging on invalid cmap
c88ef135fcc2661ec7addc171ebc60787df38aff 09-Sep-2015 Raph Levien <raph@google.com> Add penalty for breaks in URLs and email addresses

Recent changes have added special cases for line breaks within URLs
and email addresses. Such breaks are undesirable when they can be
avoided, but at other times are needed to avoid huge gaps, or indeed
to make the line fit at all.

This patch assigns a penalty for such breaks, equal to the hyphenation
penalty. The mechanism is currently very simple, but would be easy to
fine-tune based on more detailed information about break quality.

Bug: 20126487
Bug: 20566159
Change-Id: I0d3323897737a2850f1e734fa17b96b065eabd9c
ineBreaker.cpp
ordBreaker.cpp
6d15657e4a3826d4d47d5358f1dde211484527e9 09-Sep-2015 Raph Levien <raph@google.com> Add line breaks to email addresses and URLs

This change adds accceptable line breaks according to sections 7.42
(Dividing URLs and e-mail addresses) and 14.12 (URLs or DOIs and line
breaks) of the Chicago Manual of Style (16th ed.). In general, these
place breaks before punctuation symbols, and suppresses them after
hyphens.

Bug: 20126487
Bug: 20566159
Change-Id: I2d07d516b920a506a2f718c38fb435c5eb1ee1f8
ordBreaker.cpp
9c4cc648abcae144f3b99d612e58ef01d5e52cce 09-Sep-2015 Raph Levien <raph@google.com> Special-case URLs and email addresses for line breaking

Detect URLs and email addresses, and suppress both line breaking and
hyphenation within them.

Bug: 20126487
Bug: 20566159

Change-Id: I43629347a063dcf579e355e5b678d7195f453ad9
ordBreaker.cpp
6b1c227da6492a435f0341d7fe95d9992669920e 02-Feb-2016 Seigo Nonaka <nona@google.com> Improve Paint.measureText and Paint.hasGlyph for variation sequences.

Before this patch, the font fallback chain iterated all installed font
families if a variation selector was specified.

This CL narrows down the range of iteration.
To decide the font family for the variation sequence, we need to search
for both the variation sequence and its base code point.
The new range of the iteration is a union of them.

With this change, the running time of Paint.hasGlyph for the variation
sequence improves 50% and the running time of Paint.measureText for the
variation sequence improves 40% for the large text case on Nexus 6
userdebug.

Bug: 26784699
Bug: 11750374

Change-Id: Iced1349e3ca750821d8882c551551f65bb569794
mapCoverage.cpp
ontCollection.cpp
ontFamily.cpp
57b6dae9894b9362ef04517ff477fd491f9d433b 05-Sep-2015 Raph Levien <raph@google.com> Refine hyphenation around punctuation

Implement a WordBreaker that defines our concept of valid word
boundaries, customizing the ICU behavior. Currently, we suppress line
breaks at soft hyphens (these are handled specially). Also, the
new WordBreaker class has methods that determine the start and end
of the word (punctuation stripped) for the purpose of hyphenation.

This patch, in its current form, doesn't handle email addresses and
URLs specially, but the WordBreaker class is the correct place to do
so. Also, special case handling of hyphens and dashes is still done
in LineBreaker, but all of that should be moved to WordBreaker.

Bug: 20126487
Bug: 20566159
Change-Id: I492cbad963f9b74a2915f010dad46bb91f97b2fe
ndroid.mk
ineBreaker.cpp
ordBreaker.cpp
734f037130e14b3d44bc74026d3d065c025a8280 11-Feb-2016 Raph Levien <raph@google.com> Add error logging on invalid cmap

This patch logs instances of fonts with invalid cmap tables.

Bug: 25645298
Bug: 26413177
Change-Id: I183985e9784a97a2b4307a22e036382b1fc90e5e
mapCoverage.cpp
9d48271c0480c27402cfba359f45964637927a63 02-Feb-2016 Keisuke Kuroyanagi <ksk@google.com> Optimize: Precompute the hash value for LayoutCacheKey.

Bug: 24505153
Change-Id: If61c063c175086dec88cda187eafd9ce923e4cb1
ayout.cpp
89e80237bc27af084c9ff316d4f47abf426eced8 03-Feb-2016 Seigo Nonaka <nona@google.com> Improve Paint.hasGlyph performance by caching hb_font_t

It turned out that hb_font_t creation is not a lightweight operation.
Especially, Paint.hasGlyph creates hb_font_t for all existing fonts
every time. To improve the performance, cache hb_font_t instead
of hb_face_t.

Note that to calculate horizontal advance, MinikinPaint needs to be
associated with hb_font_t by calling hb_font_set_funcs. With this patch,
hb_font_set_funcs may be called multiple times for the same hb_font_t
object. However this is not an issue since MinikinPaint is unique
during layout.

Bug: 26784699

Change-Id: I516498ae9f0127d700fc9829327e9789845a1416
ndroid.mk
ontCollection.cpp
ontFamily.cpp
bFaceCache.cpp
bFaceCache.h
bFontCache.cpp
bFontCache.h
ayout.cpp
e5f01d0e954b1cace4ff000d63e383f8b1888a1f 26-Jan-2016 Stephen Hines <srhines@google.com> Disable unsigned integer overflow sanitization until libc++ is fixed. am: 4553fa41c3
am: 3d15532afc

* commit '3d15532afc73f2286b83f5c1b027b5d31feb1294':
Disable unsigned integer overflow sanitization until libc++ is fixed.
3d15532afc73f2286b83f5c1b027b5d31feb1294 26-Jan-2016 Stephen Hines <srhines@google.com> Disable unsigned integer overflow sanitization until libc++ is fixed.
am: 4553fa41c3

* commit '4553fa41c3f031e0fb3395d57018272d59869afa':
Disable unsigned integer overflow sanitization until libc++ is fixed.
4553fa41c3f031e0fb3395d57018272d59869afa 26-Jan-2016 Stephen Hines <srhines@google.com> Disable unsigned integer overflow sanitization until libc++ is fixed.

Bug: http://b/26781196
Bug: http://b/25884483
Bug: http://b/26432628

Although this issue was first only manifesting on Fugu, it now affects
N9 and N6p as well. This change disables unsigned overflow sanitization
on all platforms. The real fix for libc++ (r257368) can't be committed
until we have updated Clang at least one more time.

Change-Id: I71e9c50d25ae4566d4c06f348183c4b22a4bb60a
ndroid.mk
6344de60fa37c4e4246cb37d82215564826c2b8b 13-Oct-2015 Keisuke Kuroyanagi <ksk@google.com> Add light weight methods for text measurement.

The intruduced method measureText can be used instead of
doLayout for text measurement purpose.

Bug: 24505153
Change-Id: Ic29bbb347daf18d1f6c13f86970dcdd11dd6a2bd
ayout.cpp
97d7265862a9df05b3521ac4954de9cc82ec989d 15-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: a3df6da30b am: e82552ae00 am: 545b36d667
am: 98dd15e2cd

* commit '98dd15e2cde1eb1835753c9af66d630779c18bc0':
Reject fonts with invalid ranges in cmap
98dd15e2cde1eb1835753c9af66d630779c18bc0 15-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: a3df6da30b am: e82552ae00
am: 545b36d667

* commit '545b36d667c5b13c1b397b4c5ece20f097bf1f8b':
Reject fonts with invalid ranges in cmap
545b36d667c5b13c1b397b4c5ece20f097bf1f8b 15-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: a3df6da30b
am: e82552ae00

* commit 'e82552ae0094efdb1b1b40ebfc832540eeb1234b':
Reject fonts with invalid ranges in cmap
e82552ae0094efdb1b1b40ebfc832540eeb1234b 15-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab
am: a3df6da30b

* commit 'a3df6da30bdfda0b5b188e6511deeffddeeb9409':
Reject fonts with invalid ranges in cmap
a3df6da30bdfda0b5b188e6511deeffddeeb9409 15-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap am: ca8ac8acda
am: 3034e8b4ab

* commit '3034e8b4ab627278b88faae2f4813562f31a7c2b':
Reject fonts with invalid ranges in cmap
3034e8b4ab627278b88faae2f4813562f31a7c2b 15-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap
am: ca8ac8acda

* commit 'ca8ac8acdad662230ae37998c6c4091bb39402b6':
Reject fonts with invalid ranges in cmap
6f9966ea7c1910fd780cf7779cc59701c9b98a2b 12-Dec-2015 Seigo Nonaka <nona@google.com> Introduce multiple language based font fallback.

The motivation of this CL is enhance the font fallback score design
to support multiple language font fallback.

This CL contains following changes:
- Break language based font score into two: script-based score and
primary-language-based score.
- The primary-language-based score is 0 if the script-based score is 0.
If the script-based score is not 0 and the primary language is the
as same as the requested one, the font gets an extra score of 1.
- The language score gets a higher multiplier for languages higher in
the locale list.

Bug: 25122318
Bug: 26168983
Change-Id: Ib999997a88e6977e341f4c325e2a1b41a59db2d5
ontCollection.cpp
ontLanguage.cpp
ontLanguage.h
ontLanguageListCache.cpp
850fcc0b6fb848b383ab3123d243faf9c73efda0 14-Jan-2016 Raph Levien <raph@google.com> Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE
am: 2e98eb6be1

* commit '2e98eb6be123ec64070f7524ff24df538695d7c8':
Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE
2e98eb6be123ec64070f7524ff24df538695d7c8 29-Oct-2015 Raph Levien <raph@google.com> Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE

Make it so it's not possible to position the cursor inside an emoji
formed by a sequence including zero-width joiners.

Bug: 25368653
Change-Id: I67ec0874cd1505f3c82ab91492ffc3d39a52fae6
raphemeBreak.cpp
6638e05ac2de397455c30cae05aca399a567428d 29-Oct-2015 Raph Levien <raph@google.com> Tailor grapheme boundaries so sequence emoji are one grapheme

Make it so it's not possible to position the cursor inside an emoji
formed by a sequence including zero-width joiners.

Bug: 25368653
Change-Id: I67ec0874cd1505f3c82ab91492ffc3d39a52fae6
raphemeBreak.cpp
ca8ac8acdad662230ae37998c6c4091bb39402b6 06-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap

A corrupt or malicious font may have a negative size in its cmap
range, which in turn could lead to memory corruption. This patch
detects the case and rejects the font, and also includes an assertion
in the sparse bit set implementation if we missed any such case.

External issue:
https://code.google.com/p/android/issues/detail?id=192618

Bug: 26413177
Change-Id: Icc0c80e4ef389abba0964495b89aa0fae3e9f4b2
mapCoverage.cpp
parseBitSet.cpp
73abbd59344770601991248cc56846cd199812b8 06-Jan-2016 Raph Levien <raph@google.com> Reject fonts with invalid ranges in cmap

A corrupt or malicious font may have a negative size in its cmap
range, which in turn could lead to memory corruption. This patch
detects the case and rejects the font, and also includes an assertion
in the sparse bit set implementation if we missed any such case.

External issue:
https://code.google.com/p/android/issues/detail?id=192618

Bug: 26413177
Change-Id: Icc0c80e4ef389abba0964495b89aa0fae3e9f4b2
mapCoverage.cpp
parseBitSet.cpp
a5706e4ef922af9a04c03a4768dd3f7186784882 07-Jan-2016 Andreas Gampe <agampe@google.com> Minikin: Disable sanitizer on x86 am: 72c026822d
am: 0497c013f6

* commit '0497c013f640324550ff731bc088bb62fbb6882a':
Minikin: Disable sanitizer on x86
0497c013f640324550ff731bc088bb62fbb6882a 07-Jan-2016 Andreas Gampe <agampe@google.com> Minikin: Disable sanitizer on x86
am: 72c026822d

* commit '72c026822d32550b10bb62949644c10826d7658e':
Minikin: Disable sanitizer on x86
72c026822d32550b10bb62949644c10826d7658e 07-Jan-2016 Andreas Gampe <agampe@google.com> Minikin: Disable sanitizer on x86

Disable unsigned-integer-overflow sanitizer on x86, as it crashes.

Bug: 25884483
Bug: 26432628
Change-Id: Ia658ed56a6c81660a36edf71f7116118056aa917
ndroid.mk
97944f285636b4d9ba277a6e1acfd60d2f22cd7c 06-Jan-2016 Dan Austin <danielaustin@google.com> Enable integer sanitization in libminikin am: 7087da2519
am: cf6ebc1ebc

* commit 'cf6ebc1ebcc9137c12e221799f3b20436d2984c1':
Enable integer sanitization in libminikin
cf6ebc1ebcc9137c12e221799f3b20436d2984c1 06-Jan-2016 Dan Austin <danielaustin@google.com> Enable integer sanitization in libminikin
am: 7087da2519

* commit '7087da2519f0aa303e5941e7d8cfbe2a73e696a2':
Enable integer sanitization in libminikin
7087da2519f0aa303e5941e7d8cfbe2a73e696a2 06-Jan-2016 Dan Austin <danielaustin@google.com> Enable integer sanitization in libminikin

Enable signed and unsigned integer sanitization in libminikin.

Bug: 25884483
Change-Id: I98905827174d16138d20bb443fe2e1d7228ea1a3
ndroid.mk
728ae8d629eaf5e7cedba98866ebcbd96bf204b9 06-Jan-2016 Dan Austin <danielaustin@google.com> Revert "Enable integer sanitization in libminikin." am: 342cd45a5e
am: 5255614d23

* commit '5255614d230d241432c7f86c4ce3582a8cb71545':
Revert "Enable integer sanitization in libminikin."
5255614d230d241432c7f86c4ce3582a8cb71545 06-Jan-2016 Dan Austin <danielaustin@google.com> Revert "Enable integer sanitization in libminikin."
am: 342cd45a5e

* commit '342cd45a5e5779e81155515d36cd500bfd975fdf':
Revert "Enable integer sanitization in libminikin."
342cd45a5e5779e81155515d36cd500bfd975fdf 06-Jan-2016 Dan Austin <danielaustin@google.com> Revert "Enable integer sanitization in libminikin."

This reverts commit 9c13a3dc96d16976c45417bdc34e0fc5670815b9.

Change-Id: Iecd1f61a5fdf5955d871a920cb243553857d46ff
ndroid.mk
679f147edaba19a05a341bc60a99679e6a96cc34 06-Jan-2016 Dan Austin <danielaustin@google.com> Enable integer sanitization in libminikin. am: 9c13a3dc96
am: ebe371670e

* commit 'ebe371670e760b5318db6a02e10775e4a4ed7b96':
Enable integer sanitization in libminikin.
ebe371670e760b5318db6a02e10775e4a4ed7b96 06-Jan-2016 Dan Austin <danielaustin@google.com> Enable integer sanitization in libminikin.
am: 9c13a3dc96

* commit '9c13a3dc96d16976c45417bdc34e0fc5670815b9':
Enable integer sanitization in libminikin.
7564b7fd5b78e3fb985b593545625112a0afbd56 06-Jan-2016 Seigo Nonaka <nona@google.com> Merge "Fix race condition in Paint.hasGlyph()"
a6f5c46836090d1197e453c15c7f04c3c796a7ab 05-Jan-2016 Seigo Nonaka <nona@google.com> Fix race condition in Paint.hasGlyph()

The caller of FontFamily::hasVariationSelector needs to acquire the
lock before calling it, but FontCollection::hasVariationSelector
didn't acquire the lock. This caused a race condition.
This CL fixes this race condition.

Also, it turned out that assertMinikinLocked didn't assert even on
eng or userdebug device. This CL enables assertion on eng and userdebug
device since this assertion must be treated as bug.

BUG: 26323806

Change-Id: I9c4b1e1f09c6793e387fbdb8bb654cc0a13c65d5
ndroid.mk
ontCollection.cpp
inikinInternal.cpp
9c13a3dc96d16976c45417bdc34e0fc5670815b9 06-Jan-2016 Dan Austin <danielaustin@google.com> Enable integer sanitization in libminikin.

Enable signed and unsigned integer sanitization in libminikin.

Bug: 25884483
Change-Id: I53abf6affea8e2bb3a5abd381a9f19003a306b36
ndroid.mk
b5aba20c13e32c90b0396cf75afb19fb40d495f5 05-Jan-2016 Roozbeh Pournader <roozbeh@google.com> Merge "Replace Qaae script with Zsye"
d3376522332e1e016e59fabb22c24025092c724d 22-Dec-2015 Seigo Nonaka <nona@google.com> Replace Qaae script with Zsye

The emoji variant script "Zsye" is registered in ISO 15924.

Bug: 26226285
Change-Id: Ibc2bc740d57c48f99b6f66b1ad7595bfa8c3cff4
ontLanguage.cpp
198b46f1fea3f47ef8eb6317799c0d77aaec52f6 15-Dec-2015 Seigo Nonaka <nona@google.com> Save all kind of script tags into FontLanguage.

This is 2nd attempt of I8df992a6851021903478972601a9a5c9424b100c.

The main purpose of this CL is expanding FontLanguage to be able to
save full script tag. Previously, FontLangauge kept only limited script
tags. With this CL, FontLanguage keeps all script tags.

This CL contains the following changes:
- FontLanguage changes:
-- Moved to private directory not to be instantiated outside of Minikin.
-- Removed bool(), bits(), FontLanguage(uint32_t) methods which are no
longer used.
-- Change the FontLanguage internal data structure.
-- Introduces script match logic.

- FontLanguages changes:
-- Moved to private directory not to be instantiated outside of Minikin.
-- This is now std::vector<FontLanguage>

- FontLanguageListCache changes:
-- Now FontLanguageListCache::getId through
FontStyle::registerLanguageList is the only way to instantiate the
FontLanguage.
-- Normalize input to be BCP47 compliant identifier by ICU.

Bug: 26168983
Change-Id: I431b3f361a7635497c05b85e8ecbeb48d9aef63e
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ontLanguage.cpp
ontLanguage.h
ontLanguageListCache.cpp
ontLanguageListCache.h
ayout.cpp
6c4c098cbd37eccef483ab1986127250b4d2ddf2 22-Dec-2015 Bart Sears <bsears@google.com> Revert "Save all kind of script tags into FontLanguage."

This reverts commit 5e995fb850c2b32631914c3815dfb421855fba9b.

Change-Id: I761e0e41906742fbe3d3ac34170af3101e18042a
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ontLanguage.cpp
ontLanguage.h
ontLanguageListCache.cpp
ontLanguageListCache.h
ayout.cpp
5e995fb850c2b32631914c3815dfb421855fba9b 15-Dec-2015 Seigo Nonaka <nona@google.com> Save all kind of script tags into FontLanguage.

The main purpose of this CL is expanding FontLanguage to be able to
save full script tag. Previously, FontLangauge kept only limited script
tags. With this CL, FontLanguage keeps all script tags.

This CL contains the following changes:
- FontLanguage changes:
-- Moved to private directory not to be instantiated outside of Minikin.
-- Removed bool(), bits(), FontLanguage(uint32_t) methods which are no
longer used.
-- Change the FontLanguage internal data structure.
-- Introduces script match logic.

- FontLanguages changes:
-- Moved to private directory not to be instantiated outside of Minikin.
-- This is now std::vector<FontLanguage>

- FontLanguageListCache changes:
-- Now FontLanguageListCache::getId through
FontStyle::registerLanguageList is the only way to instantiate the
FontLanguage.
-- Normalize input to be BCP47 compliant identifier by ICU.

Bug: 26168983
Change-Id: I8df992a6851021903478972601a9a5c9424b100c
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ontLanguage.cpp
ontLanguage.h
ontLanguageListCache.cpp
ontLanguageListCache.h
ayout.cpp
1f0d7947373882f812a119aedeb1948e12a440a0 14-Dec-2015 Dan Austin <danielaustin@google.com> Refactored unsigned long negations am: 1bbe03d215
am: b9f27a2509

* commit 'b9f27a2509241a0f2dfcf6921958dab4b14fbc42':
Refactored unsigned long negations
b9f27a2509241a0f2dfcf6921958dab4b14fbc42 14-Dec-2015 Dan Austin <danielaustin@google.com> Refactored unsigned long negations
am: 1bbe03d215

* commit '1bbe03d215c9452bc9917111e63f19160cc5f56a':
Refactored unsigned long negations
1bbe03d215c9452bc9917111e63f19160cc5f56a 12-Dec-2015 Dan Austin <danielaustin@google.com> Refactored unsigned long negations

Replaced two instances of negating an unsigned long, which was
resulting in aborts from unsigned integer sanitization with the
equivalent logical not-add 1.

Bug: 25884483
Change-Id: Ic7498e0af638dcd438ce69803021d3cdc3acd4f6
parseBitSet.cpp
43bb9743ca91a761b9723674ac862660dd2be834 10-Dec-2015 Seigo Nonaka <nona@google.com> Remove script matching score from the font selection fallback.

Removing the extra score of 2 for the script matching from the font
fallback score calculation. If the two langauges have different
scripts, we should treat them as different languages.

Change-Id: Ie0d6f27bd1086248895935a7bd01b5d404044ad0
ontCollection.cpp
ontFamily.cpp
6d9dcd2cf3d3ed26a886e02d94c907311e7b1f83 02-Dec-2015 Seigo Nonaka <nona@google.com> Introduce FontLanguageListCache.

FontLanguageListCache is an intentionally leaky singleton and its
internal cache won't be purged.

BUG: 25122318

Change-Id: I272097e979fe44b83fd86822235350e12eda8f51
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ontLanguageListCache.cpp
ontLanguageListCache.h
ayout.cpp
a47969c90ac9ef5d2c7c439030d3cfcabbecc539 08-Dec-2015 Seigo Nonaka <nona@google.com> Merge "Select emoji font based on variation selectors."
8921cfe226e9b7774810c9711579586b5b227b82 08-Dec-2015 Raph Levien <raph@google.com> Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ffadd191a0 am: d56908571d
am: 7aec64b909

* commit '7aec64b9099d0b5bbbe766a2c29b9f09f0939a4c':
Avoid integer overflows in parsing fonts
7aec64b9099d0b5bbbe766a2c29b9f09f0939a4c 08-Dec-2015 Raph Levien <raph@google.com> Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ffadd191a0
am: d56908571d

* commit 'd56908571d3dc28686a198484d1cc8a399276d86':
Avoid integer overflows in parsing fonts
d56908571d3dc28686a198484d1cc8a399276d86 08-Dec-2015 Raph Levien <raph@google.com> Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985
am: ffadd191a0

* commit 'ffadd191a041f16c52b693d8dc0c42b3b9f01b2b':
Avoid integer overflows in parsing fonts
ffadd191a041f16c52b693d8dc0c42b3b9f01b2b 08-Dec-2015 Raph Levien <raph@google.com> Avoid integer overflows in parsing fonts am: 6299a6ba13
am: 998293f985

* commit '998293f985dc6c23f90b160f3bc647807c76d3fe':
Avoid integer overflows in parsing fonts
998293f985dc6c23f90b160f3bc647807c76d3fe 08-Dec-2015 Raph Levien <raph@google.com> Avoid integer overflows in parsing fonts
am: 6299a6ba13

* commit '6299a6ba13906c695f7a4f6748f7bc5856a110e5':
Avoid integer overflows in parsing fonts
369d2d44cb09ac4346cdd9e3b131bb173d764f88 29-Oct-2015 Seigo Nonaka <nona@google.com> Select emoji font based on variation selectors.

If U+FE0E is appended to the emoji code point, the glyph should have a
text presentation.
On the other hand, if U+FE0F is appended to the emoji code point, the
glyph should have an emoji presentation.

Bug: 11256006
Change-Id: I5187d44500b13a138e7ffbcf2c72e2da06374c8c
ontCollection.cpp
ontFamily.cpp
6299a6ba13906c695f7a4f6748f7bc5856a110e5 01-Dec-2015 Raph Levien <raph@google.com> Avoid integer overflows in parsing fonts

A malformed TTF can cause size calculations to overflow. This patch
checks the maximum reasonable value so that the total size fits in 32
bits. It also adds some explicit casting to avoid possible technical
undefined behavior when parsing sized unsigned values.

Bug: 25645298
Change-Id: Id4716132041a6f4f1fbb73ec4e445391cf7d9616
(cherry picked from commit 183c9ec2800baa2ce099ee260c6cbc6121cf1274)
mapCoverage.cpp
183c9ec2800baa2ce099ee260c6cbc6121cf1274 01-Dec-2015 Raph Levien <raph@google.com> Avoid integer overflows in parsing fonts

A malformed TTF can cause size calculations to overflow. This patch
checks the maximum reasonable value so that the total size fits in 32
bits. It also adds some explicit casting to avoid possible technical
undefined behavior when parsing sized unsigned values.

Bug: 25645298
Change-Id: Id4716132041a6f4f1fbb73ec4e445391cf7d9616
mapCoverage.cpp
66a34a04ab34519723f682ef2e71d22405d267c2 20-Nov-2015 Seigo Nonaka <nona@google.com> Merge "Search all families instead of using mRanges for variation sequence."
fc119c68f5def1e44e65ae4cdd147c01d62c9ad2 18-Nov-2015 Seigo Nonaka <nona@google.com> Search all families instead of using mRanges for variation sequence.

To optimize the font family search, mRanges is used for narrowing down
the search range. However, mRanges is constructed from format 4 or
format 12 entries. So, if the font supports a variation sequence but doesn't
support the base character of the sequence, the font may not be listed in
mRanges.

The proper way to fix this issue is using format 14 subtable information
for mRanges construction. However, this is not a trivial work since currently
we rely on HarfBuzz for variation sequence lookup and it doesn't provide any
API for retrieving coverage information.

Thus, as the quick fix, iterate all font families in font fallback chain if
the variation sequence is specified.

Change-Id: I278da84be8fb8f553590e2e42ed450b7e4a34eca
ontCollection.cpp
80d113bcd4bbc395218503354af1a5a6dba59b4b 21-Oct-2015 Seigo Nonaka <nona@google.com> Introduce FontCollection::hasVariationSelector method.

To implement Paint.hasGlyph(), we need a new method to ask the
FontCollection if it has a glyph for the code point and variation
selector pair.

Bug: 11256006
Change-Id: Ie4185c91bcaa4d01aee6beb97784b1f9d2a88f12
ontCollection.cpp
3dd8757fcf48976295bac566277b6da1046e8362 30-Oct-2015 Seigo Nonaka <nona@google.com> Fix invalid decrement range of KEYCAP handling in itemize.

This issue was introduced by I22ce0e9eadc941f84e3a9b23462f194e51dd7180.
Need to decrement the two utf16 chars in KEYCAP handling.

To add unit tests, this CL also addresses the Bug: 24184208 by
introducing self built fonts since there is no good example in system
installed fonts.

Bug: 24184208
Change-Id: I23fa008adbaced78a3cb96442a6bc8892ab84ce8
ontCollection.cpp
c65e6f1ee0b2f32183766726ac459188b1a37b35 03-Nov-2015 Raph Levien <raph@google.com> Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE

Due to the way emoji ZWJ sequences are defined, the ICU line breaking
algorithm determines that there are valid line breaks inside the
sequence. This patch suppresses these line breaks.

Bug: 25433289
Change-Id: I225ebebc0f4186e4b8f48fee399c4a62b3f0218a
ineBreaker.cpp
adaf42f0d3444de2b0bb977ccc94801458497f46 29-Oct-2015 Raph Levien <raph@google.com> Accept variation selector in emoji sequences - DO NOT MERGE

This patch basically ignores variation selectors for the purpose of
itemization into font runs. This allows GSUB to be applied when input
sequences contain variation selectors.

Bug: 25368653
Change-Id: I9c1d325ae0cd322c21b7e850d0ec4d73551b2372
ontCollection.cpp
bae347682989d2627081310129a5b60541ed6ad0 27-Oct-2015 Seigo Nonaka <nona@google.com> Add -Werror -Wall -Wextra to compiler option.

This is 2nd trial of I30a0914a4633bd93eb60957cdf378770f04d8428

- To suppress noisy unused parameter warnings, comment out unused
arguments.
- Add -Werror for suppressing further warning.
- Add -Wall -Wextra for safety.
- Use "z" prefix for format string of size_t.

Verified that compile succeeded on all arm,arm64,mips,x86,x86_64.

Change-Id: I7ad208464486b8a35da53929cb1cfe541ed0052f
ndroid.mk
ontCollection.cpp
ontFamily.cpp
bFaceCache.cpp
ayout.cpp
ineBreaker.cpp
inikinFontFreeType.cpp
b4c799180458fc37b96ee43ef9111f64e0cc99f7 28-Oct-2015 Bart Sears <bsears@google.com> Revert "Add -Werror -Wall -Wextra to compiler option."

This reverts commit 63635cff5861dcaed963c7332eecf51b9d7d920a.

Change-Id: I2b4b10e8afedc85dbe2d07f3e47315652b65cd14
ndroid.mk
bFaceCache.cpp
ayout.cpp
inikinFontFreeType.cpp
63635cff5861dcaed963c7332eecf51b9d7d920a 27-Oct-2015 Seigo Nonaka <nona@google.com> Add -Werror -Wall -Wextra to compiler option.

- To suppress noisy unused parameter warnings, comment out unused
arguments.
- Add -Werror for suppressing further warning.
- Add -Wall -Wextra for safety.

Change-Id: I30a0914a4633bd93eb60957cdf378770f04d8428
ndroid.mk
bFaceCache.cpp
ayout.cpp
inikinFontFreeType.cpp
4b723bf22b1bbc5fcdaa9bd96178c921199905d5 20-Oct-2015 Roozbeh Pournader <roozbeh@google.com> Basic scaffolding for handling a language list.

The behavior hasn't changed much yet: all languages are ignored for
rendering text, except the very first supported language.

Change-Id: I1695fb985927ae5e28e4f59c1b531e4993af8688
ontFamily.cpp
16da66db748ce4877bc1d3e7af783eed8a08c77a 20-Oct-2015 Seigo Nonaka <nona@google.com> Merge "Support Variation Selector in font selection."
bbdd73ec077a1bb6801b25a639834be16dfd78cb 01-Oct-2015 Seigo Nonaka <nona@google.com> Support Variation Selector in font selection.

This CL contains the following changes:
- Add a variation selector argument into getFamilyForChar to be able to
select fonts which support variation selector.
- In case no fonts support the codepoint and variation selector pair,
add a fallback rule which selects font family with ignoring variation
selector.
- Change FontCollection::itemize to not change the font family
immediately preceding a variation selector.
- Introduce unit tests for variation selectors.

With this CL, TextView can render the variation selectors correctly.

Bug: 11256006
Change-Id: I22ce0e9eadc941f84e3a9b23462f194e51dd7180
ontCollection.cpp
210dfa01db0defb3c23b60c446e97b1ee6f1287e 13-Oct-2015 Seigo Nonaka <nona@google.com> Remove MinikinFont::GetGlyph interface.

MinikinFont:GetGlyph is no longer used.
No behavior chnages are expected with this CL.

Change-Id: I13398503841ac06f930b04815017d4b33338efa1
inikinFontFreeType.cpp
e8264e065f0edd58a9fa04bbdd777f2af2794789 15-Oct-2015 Roozbeh Pournader <roozbeh@google.com> Complete half-done cherry-picking of Android.mk. DO NOT MERGE

The previous commit, 6e2cccdc518f8d3424c84ae6fbe0e87ae3c3f66a, was
incompletely cherry-picked. This adds the missing parts.

Bug: 24570591
Change-Id: I1097c60587fb8a88cfe6b8ffed5b1689d9bdd429
ndroid.mk
6e2cccdc518f8d3424c84ae6fbe0e87ae3c3f66a 27-Aug-2015 Raph Levien <raph@google.com> Binary format for hyphenation patterns

In the current state, hyphenation in all languages than Sanskrit seems
to work (case-folding edge cases). Thus, we just disable Sanskrit.
Packed tries are implemented, but not the finite state machine
(space/speed tradeoff).

This commit contains a throw-away test app, which runs on the host.
I think I want to replace it with unit tests, but I'm including it in
the CL because it's useful during development.

Bug: 21562869
Bug: 21826930
Bug: 23317038
Bug: 23317904
Bug: 24570591
Change-Id: I7479a565a4a062fa319651c2c14c0fa18c5ceaea
(cherry picked from commit f0be43de02a1e07308d3d95408349c3c7f973430)
ndroid.mk
yphenator.cpp
0f2a025d135f9ca52cc3cf917fffc29d6c126094 24-Sep-2015 Seigo Nonaka <nona@google.com> Introduce FontFamily::hasVariationSelector

This CL introduces new method hasVariationSelector into FontFamily but it
is not used in production code. So no behavior changes are expected.

This CL contains the following changes:
- Introduce hasVariationSelector which returns true if the corresponding
font has a glyph for a code point and variation selector pair.
- Introduce purgeHbFontCache since hb_face_t won't be released by
keeping hb_font_t.
- Introduce unit tests with self-built font.

Change-Id: I659a6d03d9ec446b409e1fba2758452abb9f44fa
ontCollection.cpp
ontFamily.cpp
ayout.cpp
7c8ac67a9022590d32d25e61094f29f7af42357d 01-Oct-2015 Keisuke Kuroyanagi <ksk@google.com> Merge "Refactoring: Introduce helper class to iterate runs."
6ac8ca4ce7e3da669209aac1572085b49425e3cf 01-Oct-2015 Raph Levien <raph@google.com> Merge "Binary format for hyphenation patterns"
f0be43de02a1e07308d3d95408349c3c7f973430 27-Aug-2015 Raph Levien <raph@google.com> Binary format for hyphenation patterns

In the current state, hyphenation in all languages than Sanskrit seems
to work (case-folding edge cases). Thus, we just disable Sanskrit.
Packed tries are implemented, but not the finite state machine
(space/speed tradeoff).

This commit contains a throw-away test app, which runs on the host.
I think I want to replace it with unit tests, but I'm including it in
the CL because it's useful during development.

Bug: 21562869
Bug: 21826930
Bug: 23317038
Bug: 23317904

Change-Id: I7479a565a4a062fa319651c2c14c0fa18c5ceaea
ndroid.mk
yphenator.cpp
fb0d396929e534a3686469b474d4f670864aa5ac 17-Sep-2015 Seigo Nonaka <nona@google.com> Extract hb_face_t object cache mechanism from Layout.cpp.

This CL does following things:
- Extract hb_face_t object cache mechanism from Layout.cpp to be able to
use it from other cpp file, especially from FontFamily.cpp.
To address Bug 11256006 and Bug 17759267, need to touch
hb_face_t from FontFamily.
- Make hb_face_t cache mechanism thread-safe.
- Add unit tests for HbFaceCache test cases.

Bug: 11256006
Bug: 17759267
Change-Id: Ic183634ef34326793bd9a32167236611d0af34d6
ndroid.mk
bFaceCache.cpp
bFaceCache.h
ayout.cpp
inikinInternal.cpp
inikinInternal.h
6292e1a966da86af7045c356fcad6ab8864089b8 24-Sep-2015 Keisuke Kuroyanagi <ksk@google.com> Refactoring: Introduce helper class to iterate runs.

This doesn't change current behavior. It's a preparation
for the following CLs.

Bug: 22408712
Change-Id: Ic018422254aa3904655f499194caad74f0c0fc5d
ayout.cpp
2a79f59e73294e43f32cc0138e23fcde34eec28a 01-Sep-2015 Seigo Nonaka <nona@google.com> Resolve glyph ID by HarfBuzz function.

Currently codepoint to glyph ID resolution is done through MinikinFont
interface. To support variation selector, use HarfBuzz API instead of
calling this interface since one of its implementation Skia doesn't
support variation selector.

On the other hand, we don't want to get glyph horizontal advance values
by HarfBuzz since HarfBuzz doesn't return correct values when the hinting
is active.

Thus, use ot_font as a parent font and override
glyph_h_advance/glyph_h_origin functions as is.

With this change, MinikinFont::GetGlyph is no longer necessary but not
removing in this CL for easy reverting since removing interface requires
multi-repository commit.

This is a base work of b/11256006 and this patch doesn't provide any
user visible changes.

Bug: 11256006
Change-Id: I061172c0b674bb649ce8bc013ffecf38708bdc41
ayout.cpp
4e3adc6fb2073d5b466b88b8f5329d281038aba1 25-Aug-2015 Seigo Nonaka <nona@google.com> Update word breaker to be aware tone mark and variation selector.

This CL does:
1. Move the getNextWordBreak/getPrevWordBreak function to a separate source file.
2. Adding "ForCache" suffix for function name for making clear these function is
for layout cache.
3. Introduce unit tests for them.

Bug: 11256006
Change-Id: I4138751a4570915f1a0d6c8921f89700f8ec7f35
ndroid.mk
ayout.cpp
ayoutUtils.cpp
ayoutUtils.h
d8dd94b81ea7efd776859fbbdf4a76458e270eab 12-Aug-2015 Raph Levien <raph@google.com> Add basic unit tests for Minikin

Initial unit tests for Minikin functionality. Also fixes an incorrect
Hangul case (uncovered in testing), and improves handling of broken
UTF-16.

Change-Id: I69b441d8e3b19ed06abcc56f13271abadf3d1010
ndroid.mk
raphemeBreak.cpp
2967a13420ffd1d426e6edd1648414910593d179 12-Aug-2015 Roozbeh Pournader <roozbeh@google.com> Clean up use of printf() in Layout.cpp.

Reported externally at https://code.google.com/p/android/issues/detail?id=167715.
Bug: 21498085

Change-Id: I73f22de03b0151ce31a6b3070d051a2a701b33d2
ayout.cpp
71ec97055357b6ccb13a2697a56254bb19f43ae9 08-Aug-2015 Roozbeh Pournader <roozbeh@google.com> Support three-letter language codes in FontLanguage.

Also handle the case of weird language code that we don't understand
properly better, by treating them not equal to each other.

Change-Id: Iaccb251fa38d700932f6eadac254d3d1fa09b3ea
ontFamily.cpp
c02138bf556739fa9c9212da13aee89aa520c8ef 06-Aug-2015 Roozbeh Pournader <roozbeh@google.com> Gold plate grapheme cluster breaks.

This tailors Unicode's Grapheme_Cluster_Break property to better
classify characters currently with the Control property value.

Also adds support for rule GB9b of UAX #29, needed since there are
now characters we are tailoring to be Prepend. The rule was
previously ommited in our implementation because there was no
characters in the Prepend class.

Bug: 15653110
Change-Id: If10da88df0980f7d676c8c0b950eda5fb8dbe741
raphemeBreak.cpp
90a09c3f36d98530822392446884b8af68035908 29-Jul-2015 Raph Levien <raph@google.com> Improve fallback where explicit variant is not given

In computing scores for which fallback font to choose, a match of a
variant given explicitly in the xml config file scores higher than a
family with no explicit variant. One consequence is that U+2010
HYPHEN is chosen from the Naskh Arabic font in the fallback case.

This patch scores families with no variants as a match (effectively
the same as if the xml file specified both variants). Thus, it will
choose the first matching font (Roboto), which is a better choice.

This patch also revises the list of "sticky" characters to include
various hyphens, so Arabic (and potentially other scripts) text that
includes hyphens can access the script-specific variants matched to
the underlying text.

Bug: 22824219
Change-Id: I6ec1043037f89cad50ca99ac24c473395546bcdf
ontCollection.cpp
5ba60b1c255efee72316f002bc850908b7f0fe4e 21-Jul-2015 Raph Levien <raph@google.com> Merge "Revert "Allow clusters to start with zero-width characters"" into mnc-dev
542572394dfb35b6b78b73837ec13c8e3170385a 21-Jul-2015 Raph Levien <raph@google.com> Revert "Allow clusters to start with zero-width characters"

This reverts commit 3e0fc64da064b8c4156daf53242b8eeb47830f64.

Bug: 22589743
Bug: 22121742
Change-Id: I7b482ffb8a0ee174ddc804aa890de45bdbd758e3
easurement.cpp
e9ec9a1d1b9e177659b7cc2cd3a102760fcfec14 21-Jul-2015 Raph Levien <raph@google.com> Consistently apply break opportunities in text spans

It's essential not to apply a break opportunity within a replacement
span, otherwise things can happen such as displaying the span twice.
The old code tested this case based on zero-width characters.
However, this test was both imprecise, and also in some cases read
uninitialized values from the mCharWidths array, which in turn led
to inconsistent line breaking of the same text.

This patch applies all line break opportunities (as identified by
ICU) within text (as opposed to replacement spans), and also applies
break opportunities at the beginning and end of replacement spans,
but avoids breaks within a replacement span.

Bug: 20138621
Change-Id: I36baeb44d6808356649e1bb69ca57f093fc8c723
ineBreaker.cpp
cdd19dadd11a611409c24bb69e6629eab6812d98 15-Jul-2015 Roozbeh Pournader <roozbeh@google.com> Use ICU to lowercase words to hyphenate.

Previously, the standard C tolower() function was used, which
didn't support any characters beyond the basic ASCII letters.

Bug: 22506121
Change-Id: Ibb81121caa29be44fbb59aa98891e9faafc57592
yphenator.cpp
daf62d0eef9e339c9d3269e5eaa2007d25c18194 15-Jul-2015 Roozbeh Pournader <roozbeh@google.com> Add missing hyphen-like characters.

This adds various hyphen-like characters missed in the previous
patch, that should disallow automatic hyphenation of words containing
them.

Bug: 22484266
Change-Id: Ie972cb50384dbe0aa1ab5ec50286b75f9877953a
ineBreaker.cpp
baf6d0a41fdabb0f859bd065f3724921a3e91089 14-Jul-2015 Roozbeh Pournader <roozbeh@google.com> Avoid re-hyphenating already-hyphenated phrases.

Previously, automatic hyphenation blindly took almost every line
breaking opportunity as a word break, so words like "low-budget" were
treated as two separate words, "low-", and "budget", each
automatically hyphenated.

This patch makes sure the subwords in already-hyphenated phrases are
not passed to the automatic hyphenator, while keeping the possibility
of a potential line break where a hyphen already exists.

Bug: 22484266
Bug: 22287425
Change-Id: Ie46dbdd70e993d64a9b9cf44b4ae93b21459dbc2
ineBreaker.cpp
6c4d167bff33c24c239d77ddb1044b18d180766a 10-Jul-2015 Raph Levien <raph@google.com> Add HyphenEdit to layout cache

We bypass the word layout cache for "complex" cases, which includes
things like OpenType features. We were counting a hyphen edit as such
a case, but the problem is that we measure a _lot_ of these when
doing layout with hyphenation.

This patch adds plumbing for hyphen edits to the layout cache, so
that word fragments with hyphens can be cached as well.

Bug: 22378829

Change-Id: Idba4df4faa14f48a5faccc8a7a7955a36c19ef27
ayout.cpp
3e0fc64da064b8c4156daf53242b8eeb47830f64 30-Jun-2015 Raph Levien <raph@google.com> Allow clusters to start with zero-width characters

The logic in getRunAdvance() assumed that any zero-width character was
part of the preceding cluster, which is valid most of the time. However,
characters such as ZWNBSP (U+FEFF) renders as a zero width glyph
and is also a grapheme cluster boundary. This patch adds a clause to
handle that case.

Bug: 22121742
Change-Id: Iad79a7d988bded1ef05f0fd7905d20669ea22051
easurement.cpp
91425f0564581e258d3f9b2f44d13f3b6d7a60ea 29-Jun-2015 Raph Levien <raph@google.com> Fix logspam and incorrect cluster offset

An incorrect cluster offset calculation was causing a lot of log
messages to appear. Separately, a confusion between #if and #ifdef was
causing unintended logging of line breaks. This patch fixes both.

Bug: 22178333
Change-Id: I2b3673ed66c784f5082fd127a8dc10bd3df6ed79
ayout.cpp
ineBreaker.cpp
e8721b2d293ba1a0e5d92a066aa9aa15807357cc 26-Jun-2015 Raph Levien <raph@google.com> Disable letterspacing for connected scripts

The appearance of letterspacing with scripts with cursive connections
is poor, so we simply disable letterspacing for those scripts. There
may be some cases where some form of letterspacing is desirable, but
this gives the highest likelihood that the final result will be good
without requiring additional work from clients.

Bug: 21935803
Change-Id: Ie25266249ac3a2605aa89ef5132e8edbe3a06d35
ayout.cpp
a6f8bf6f530f80b00a7cc64605667dd1d75a971c 24-Jun-2015 Raph Levien <raph@google.com> Separate additional penalty for last line with hyphen

A recent change added a penalty for a hyphen at the last line break,
which is visually undesirable. However, the penalty was assessed to
"widthScore", which broke the assumption (used for another
optimization) that widthScore increases monotonically. This patch
separates the penalty into a different parameter, restoring the
validity of the monotonicity assumption.

Bug: 22066119
Change-Id: I6a47a350ef3ceee2f00ee430d6954d0c307227f0
ineBreaker.cpp
0d2dbb55c90cc540aad264577c756103660ddff5 13-Jun-2015 Roozbeh Pournader <roozbeh@google.com> Merge "Use ASCII HYPHEN-MINUS when there's no HYPHEN in the font." into mnc-dev
f997dd21968bac16966269aede235247fb08a00b 12-Jun-2015 Roozbeh Pournader <roozbeh@google.com> Use ASCII HYPHEN-MINUS when there's no HYPHEN in the font.

Previously, we just assumed the font in use had a U+2010 HYPHEN
character, resulting in a tofu (or an empty space) being shown when
U+2010 was not supported in the font used to render the hyphenated
word.

Now we try to fallback to U+002D HYPHEN-MINUS, which has a very good
chance of being available in at least any Latin font.

We still show a tofu when neither character is supported, to
intentionally alert that something is missing.

Bug: 20497913
Bug: 21088552
Bug: 21570828
Change-Id: Iff69bbc38836c03495e9124502b5207c39270da2
ayout.cpp
17e78fa864df7b1f3ee737db6ad6c193dffc2396 12-Jun-2015 Raph Levien <raph@google.com> Merge "Increase hyphenation penalty for short last line" into mnc-dev
4ea1cc82b0e8170d6ab6a7e9ee274c81315cd59e 10-Jun-2015 Keisuke Kuroyanagi <ksk@google.com> Fix: getOffsetForAdvance can return worng offset.

searchStart was passed to getRunAdvance, but it can be
different from the start that has been used to initialize
Layout object. As a result, wrong index could be used in
getRunAdvance.

Bug: 21744454
Change-Id: Ibe83cc50ed6f0da2a1532318bc224502be350699
easurement.cpp
abae97a39c26e191e350575932611a90e6b04d06 08-Jun-2015 Raph Levien <raph@google.com> Increase hyphenation penalty for short last line

Tuning for hyphenation parameters. We discourage hyphenation on the
last line, but offset this penalty by also applying a penalty for
each line, which optimizes for minimizing the number of lines. Thus,
when hyphenation can reduce the number of lines, it increases the
chance they're used.

There's probably more tuning and refinement that can be done, but
testing suggests that the tunable parameters are appropriate.

Bug: 20883322

Change-Id: Ida7eaf8aced109e426694f5a386924a842d29c4b
ineBreaker.cpp
73fa6dfd6366c6ac04d6a25cdcc0721f5b3e7fbb 01-Jun-2015 Raph Levien <raph@google.com> Merge "Use context start correctly in getRunAdvance" into mnc-dev
95af01c57b60130ba4c098340ba6ea4b4ebfee3f 01-Jun-2015 Raph Levien <raph@google.com> Use context start correctly in getRunAdvance

We were not taking context start into account when deciding whether
to split a ligature, which was causing inconsistent behavior. This
patch consistently references the widths array relative to the start
of the context.

Bug: 21549197
Change-Id: I7c71e10c1af84354fefe782fc0b87120016e6555
easurement.cpp
a019665898d830283a99f505f72d3899ba137b62 01-Jun-2015 Raph Levien <raph@google.com> Disable hyphenation for unreasonably long words

Very long words cause O(n^2) behavior. These are unlikely to happen in
real text, but do happen with synthetic strings, so in those cases we
just disable hyphenation.

Bug: 20790394
Change-Id: Idf957dd40b24efe1476f619f17093a48b5bc56f7
ineBreaker.cpp
0dc07c0be325b7c12c50729e04c4b2785a673fd7 12-May-2015 Roozbeh Pournader <roozbeh@google.com> 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
ineBreaker.cpp
8920e81717c6e51b92ff8f4479a1f959af260556 17-Apr-2015 John Reck <jreck@google.com> Move Bitmap to a different namespace

namespace naming collision. Move minikin's
Bitmap out of android:: and into minikin::

Change-Id: I5ae3925f81b848dc79576429ab55243b96f7fed2
ayout.cpp
68ae337aa05f598af18b09fe4125146d4d67db83 23-Apr-2015 Raph Levien <raph@google.com> Don't include trailing newline in width for line breaking

In a paragraph with a trailing newline, the width of the newline
character was included in the line width for breaking purposes,
basically as if it were a non-breaking space. This caused a
discrepancy, where Layout.getDesiredWidth() suggested that the text
would fit in a single line, but StaticLayout would break it because of
the added width of the newline character.

The proposed fix is simply to consider newline to be a space that
disappears at the end of a line.

Bug: 20152308
Change-Id: I539574c5b8ea892c8ed6aca6c59e90ccdf74a680
ineBreaker.cpp
40beb7744a61248de82a6077996c83c14e0122c2 07-Apr-2015 Raph Levien <raph@google.com> Add functions for measuring cursor positioning

New functions for computing the correspondence between cursor
position and advance, respecting grapheme boundaries.

Change-Id: I620378d5f64cd74300cd43db522adeb555825dff
ndroid.mk
raphemeBreak.cpp
easurement.cpp
bb86b433f97a301c11800806b1ce5331fa227d4a 16-Apr-2015 Raph Levien <raph@google.com> Rename "margins" to "indents"

The name "margin" conflicts with another meaning, so we're making the
name in the public api "idents" and the code consistent in naming.

Change-Id: I9170116b4d972e4b25f0f319e78376310288eb41
ineBreaker.cpp
dc7bc6e39e1ef6b713b927baf24db8b4f02f1a3f 15-Apr-2015 Raph Levien <raph@google.com> Add margins array to line widths object

In order to support layout in non-rectangular regions, the LineWidths
object needs to accept an arbitrary array of margins. This is
implemented in addition to the existing firstWidthLineCount/restWidth
mechanism for convenience, though using only arrays would have the
same expressive power.

Bug: 20182243
Change-Id: Iea96bca1a92012314ac27e617c67f306c1f1b2f2
ineBreaker.cpp
5cdad92c300a65cab89b172e952186f0c5870657 30-Mar-2015 Raph Levien <raph@google.com> Revert "Fix build: Revert "Add hyphenation to line breaking""

This reverts commit 0b25d5ac85533f64764a0d53d5e5d33b46b715fa.
ndroid.mk
yphenator.cpp
ineBreaker.cpp
0b25d5ac85533f64764a0d53d5e5d33b46b715fa 30-Mar-2015 Ed Heyl <edheyl@google.com> Fix build: Revert "Add hyphenation to line breaking"

This reverts commit daf6a6bdbf2ff1f66496d6200cb253e2f50759d5.

Change-Id: I3fed65046274d3aeb748f0730585ab89927f5741
ndroid.mk
yphenator.cpp
ineBreaker.cpp
daf6a6bdbf2ff1f66496d6200cb253e2f50759d5 19-Mar-2015 Raph Levien <raph@google.com> Add hyphenation to line breaking

This patch adds hyphenation using the Liang hyphenation algorithm,
similar to TeX. It also improves the optimized line breaker so that
it works correctly and efficiently even when the line width is not
constant (there is a specialization for constant width, which is
probably worthwhile, but performance TODOs remain).

Still to be done:

* hyphenator has many shortcuts, only tested with English

* interaction between punctuation and hyphenation is problematic

Change-Id: I2d94a1668ebc536398b7c43fcf486333eeb7c6aa
ndroid.mk
yphenator.cpp
ineBreaker.cpp
01f526614431e3a0a6e1a48039e00b8a9b7d6fbf 14-Mar-2015 Raph Levien <raph@google.com> Add LineBreaker to Minikin

This patch adds a LineBreaker class to Minikin, which will be used for
computing line breaks in StaticLayout. The version in this patch
contains basically the same functionality that existed before, but
hopefully better performance and an interface that's suitable for more
sophisticated paragraph layout.

Note that this version contains a high quality strategy, which mostly
works but doesn't respect varying line width.

Change-Id: I02485d58b1e52856296a72cdd4efd963bc572933
ndroid.mk
ayout.cpp
ineBreaker.cpp
d692d6a9791145d41d7778cdf6b40b20c2be8cb4 30-Jan-2015 Raph Levien <raph@google.com> HyphenEdit in support of hyphenation

Adds a "HyphenEdit" field to the Minikin Paint object, which represents
an edit to the text to add a hyphen (and, in the future, other edits to
support nonstandard hyphenation).

Change-Id: Ib4ee690b0fe2137e1d1e2c9251e5526b274ec3a7
ayout.cpp
0bbff3a96d3836079371cdd4398c21afad3c5234 25-Feb-2015 Roozbeh Pournader <roozbeh@google.com> Disable HarfBuzz's fallback to compatibility decompositions

Previously, HarfBuzz's default fallback to compatibility
decompositions resulted in Mathematical Alphanumeric Symbols getting
rendered as normal letters and digits when there was no font
available to render them. This patch disables that fallback, to
ensure they are displayed as tofus.

Based on a patch by Behdad Esfahbod.

Bug: 19202569
Change-Id: I357f172302448d4ab0b24efc86119f1977b5996b
ayout.cpp
30c70ff7142e9cf3cd795a7afdf2b5afe8bc4564 05-Jan-2015 Narayan Kamath <narayan@google.com> am 79298c34: am 5870d4f0: Remove hardcoded ICU include paths.

* commit '79298c346088e13a0ddc93d49f4bb100afdbd14b':
Remove hardcoded ICU include paths.
79298c346088e13a0ddc93d49f4bb100afdbd14b 05-Jan-2015 Narayan Kamath <narayan@google.com> am 5870d4f0: Remove hardcoded ICU include paths.

* commit '5870d4f0d46f185568a2d2ea45afe48ae999b223':
Remove hardcoded ICU include paths.
5870d4f0d46f185568a2d2ea45afe48ae999b223 05-Jan-2015 Narayan Kamath <narayan@google.com> Remove hardcoded ICU include paths.

ICU exports them using LOCAL_EXPORT_C_INCLUDE_DIRS.

bug: 18581021
Change-Id: Ia57b3b4d231966203274b0e7e7b850beb1bd11c0
ndroid.mk
da09490825ce49e103d511ec1b92c79df0923ada 04-Dec-2014 Andreas Gampe <agampe@google.com> am 919fbb99: am cb20a2f0: Minikin: Remove unused variables, fix init order

* commit '919fbb99f1d5d0c95bf165cec9b7b178b42908ec':
Minikin: Remove unused variables, fix init order
919fbb99f1d5d0c95bf165cec9b7b178b42908ec 04-Dec-2014 Andreas Gampe <agampe@google.com> am cb20a2f0: Minikin: Remove unused variables, fix init order

* commit 'cb20a2f0b366bfc16db3a489a60156dec7a9fe21':
Minikin: Remove unused variables, fix init order
cb20a2f0b366bfc16db3a489a60156dec7a9fe21 25-Nov-2014 Andreas Gampe <agampe@google.com> Minikin: Remove unused variables, fix init order

For build-system CFLAGS clean-up, fix unused variables.

Reorder initializer list to initialize in the order of member
declarations.

Change-Id: I64358b2dcf0e39d0f4e18fdc3473de867f84fcba
ontCollection.cpp
ontFamily.cpp
ayout.cpp
inikinFontFreeType.cpp
13f1aae02bacd475722bc8ea3fc2cf6abc1a82e3 29-Oct-2014 Raph Levien <raph@google.com> Move coverage bitmap from FontCollection to FontFamily

This will significantly reduce memory usage and also speed the creation
of new font families. In particular, the coverage bitmaps for the fonts
in the fallback stack will be computed once in the Zygote, rather than
separately in each app process.

Bug: 17756900
Change-Id: I66f5706bddd4658d78fe5b709f7251ca9d2ff4f8
ontCollection.cpp
ontFamily.cpp
e8b4a1b78a29878c89659860a7b7fa5605b3be0e 12-Nov-2014 Dan Albert <danalbert@google.com> am dc81fbad: am 69d4fba2: Move frameworks/minikin over to libc++.

* commit 'dc81fbad809f08564199c8f08df7e7f72310961a':
Move frameworks/minikin over to libc++.
dc81fbad809f08564199c8f08df7e7f72310961a 12-Nov-2014 Dan Albert <danalbert@google.com> am 69d4fba2: Move frameworks/minikin over to libc++.

* commit '69d4fba2f2b7bb2c248cc0e78cf277a6e44665f8':
Move frameworks/minikin over to libc++.
69d4fba2f2b7bb2c248cc0e78cf277a6e44665f8 12-Nov-2014 Dan Albert <danalbert@google.com> Move frameworks/minikin over to libc++.

Bug: 15193147
Change-Id: I5e15c95415c39515340e2663acd5fd26666db720
ndroid.mk
ayout.cpp
92065a6f3f8bf1a97c57f2f7c22aee750c0ce3b8 31-Oct-2014 Raph Levien <raph@google.com> am 253320d2: Move coverage bitmap from FontCollection to FontFamily

* commit '253320d25fccbb49621926d49dcf5ef64cf529c6':
Move coverage bitmap from FontCollection to FontFamily
253320d25fccbb49621926d49dcf5ef64cf529c6 29-Oct-2014 Raph Levien <raph@google.com> Move coverage bitmap from FontCollection to FontFamily

This will significantly reduce memory usage and also speed the creation
of new font families. In particular, the coverage bitmaps for the fonts
in the fallback stack will be computed once in the Zygote, rather than
separately in each app process.

Bug: 17756900
Change-Id: I66f5706bddd4658d78fe5b709f7251ca9d2ff4f8
ontCollection.cpp
ontFamily.cpp
168d3ef0e086a98f4c344f233863b6751a00583a 24-Oct-2014 Raph Levien <raph@google.com> am 5f11abd3: Silently ignore invalid rangeOffset values

* commit '5f11abd31fa8cfa723f54bd1c98ce4e27e7d3c77':
Silently ignore invalid rangeOffset values
5f11abd31fa8cfa723f54bd1c98ce4e27e7d3c77 23-Oct-2014 Raph Levien <raph@google.com> Silently ignore invalid rangeOffset values

Some fonts contain a cmap segment for char 0xffff that contains an
invalid rangeOffset. This was rejected by the existing code, which
means the font is considered to have empty Unicode coverage. This patch
just discards the invalid segment (consistent with OpenType Sanitizer),
making the custom font display.

Bug: 18106256
Change-Id: Icc8616a3030f80e62db906332be64d434ae72ea2
mapCoverage.cpp
60cc2ccf68058f3d3ff1c0a863ef796ad388eed5 23-Sep-2014 Raph Levien <raph@google.com> am d5804e39: Fine-tune fake-bolding condition

* commit 'd5804e3937a961736e5cef0e8a70eacf91ee00bb':
Fine-tune fake-bolding condition
d5804e3937a961736e5cef0e8a70eacf91ee00bb 22-Sep-2014 Raph Levien <raph@google.com> Fine-tune fake-bolding condition

The old logic for fake bolding results in no fake bolding for a bold
span on a light weight (300) because the target weight (600 in this
case) didn't meet the condition. This patch fine-tunes the threshold
to enable fake bolding for this.

Bug: 17587185

Change-Id: I04abd00a74240cbed79c417f81486aa2158b2806
ontFamily.cpp
9f00aaec705f667fc62710c5b1cd2cb8d005e1d5 04-Sep-2014 Raph Levien <raph@google.com> am 6740536e: Snap advance widths to integers

* commit '6740536e3927d25bf5c2567e5f6e8c175973cbb7':
Snap advance widths to integers
6740536e3927d25bf5c2567e5f6e8c175973cbb7 03-Sep-2014 Raph Levien <raph@google.com> Snap advance widths to integers

Fractional advance widths were causing subtle problems with text
positioning when the same text was drawn with different spans in the
hwui renderer. Quantizing the coordinates on layout (as opposed to
waiting until the renderer draws the glyphs) solves the problem.

This patch also fixes a discrepancy between x position and advance
widths when letterspacing.

Bug: 17347779
Change-Id: Ia705944047408c2839d5ad078eefd6bbec446872
ayout.cpp
df0178d7d22efabe922f5c1f90a100d2b740ebf4 27-Aug-2014 Raph Levien <raph@google.com> am 997c799e: Try Unicode decomposition for selecting fallback font

* commit '997c799e3ec6bf8adf687e29670d23d91e0f5fee':
Try Unicode decomposition for selecting fallback font
997c799e3ec6bf8adf687e29670d23d91e0f5fee 27-Aug-2014 Raph Levien <raph@google.com> Try Unicode decomposition for selecting fallback font

This patch finds an appropriate fallback font in the case where no font
directly maps the requested character, but a font does exist for the
character's canonical decomposition. This yields correct rendering of
compatibility characters such as U+FA70.

Bug: 15816880
Bug: 16856221
Change-Id: Idff8ed6b942fec992a0815a32028b95af091d0ee
ontCollection.cpp
10d07727cf81c86352493e2241e17a0008c04bb5 22-Aug-2014 Behdad Esfahbod <behdad@google.com> am 56c7fb8c: Allocate font vector on stack

* commit '56c7fb8c0633f1b02115bb4370854016f8c84fb4':
Allocate font vector on stack
56c7fb8c0633f1b02115bb4370854016f8c84fb4 22-Aug-2014 Behdad Esfahbod <behdad@google.com> Allocate font vector on stack

This reduces another allocation (last one?) we were doing when
fulfilling shaping requests from the cache.

Bug: 17111260
Change-Id: Ieb8ae1ccfcaacedb257e1e9263777f10623aaf98
ayout.cpp
c01aa1e323e078a3103219f3646b369c73126f2b 22-Aug-2014 Behdad Esfahbod <behdad@google.com> am 6da7796c: Fix Layout initialization in the skipCache path

* commit '6da7796cbe8a17efd61a3302369e69bb222fdb4f':
Fix Layout initialization in the skipCache path
6da7796cbe8a17efd61a3302369e69bb222fdb4f 21-Aug-2014 Behdad Esfahbod <behdad@google.com> Fix Layout initialization in the skipCache path

C++ local var initialization always tricks me. Previously, Layout
didn't have a constructor, which meant that defining it on the stack
left mAdvance uninitialized. This was not an issue when we were doing
"new Layout()", since that invokes zero-initialization, but was an
issue for the skipCache path that was allocating layout on stack by
just "Layout l" instead of "Layout l = Layout()". To avoid surprises,
add a constructors that clears everything.

Also adds reset() method to reset the layout for reuse.

Change-Id: I3e02f00da9dd7d360abe13f63c310f6882292d0a
ayout.cpp
338de7c42303c9710d37242fac8727c36caee174 21-Aug-2014 Behdad Esfahbod <behdad@google.com> am 288c9159: Speed up cache lookup

* commit '288c915963b3500c7efb958ba613650e2ecdfdfa':
Speed up cache lookup
288c915963b3500c7efb958ba613650e2ecdfdfa 20-Aug-2014 Behdad Esfahbod <behdad@google.com> Speed up cache lookup

Avoid copying the string for cache lookup.

Bug: 17111260
Change-Id: Ic220bfc991fc6b3dada197304aabdf72a8941bd7
ayout.cpp
8e865a08c03bae9bbdae69c5ad1a79b47adb047f 08-Aug-2014 Behdad Esfahbod <behdad@google.com> am f952161b: Choose same font for Emoji keycap and its base character

* commit 'f952161b874fd2e9af474b9fd2ebcca1f3bb4555':
Choose same font for Emoji keycap and its base character
f952161b874fd2e9af474b9fd2ebcca1f3bb4555 08-Aug-2014 Behdad Esfahbod <behdad@google.com> Choose same font for Emoji keycap and its base character

The U+20E3 COMBINING KEYCAP is used in our fonts to generate an emoji
rendering of ASCII numbers and letters through GSUB. For that to work
we need to choose the same (Emoji) font for the character coming
*before* the COMBINING KEYCAP character.

This is a special-case of a broader need to choose fonts per grapheme
cluster as opposed to per character, but for now, special-case U+20E3.

Bug: 7557244
Change-Id: I958e5a01068df8495bbb9bc3b9ed871cea1838b6
ontCollection.cpp
143a999611a780f2549887b60702eee1f8c33bdc 30-Jul-2014 Behdad Esfahbod <behdad@google.com> am 5986f604: Support fontFeatureSettings

* commit '5986f6048ae21e0ec094c1f2ca0169d0ca6ec6b5':
Support fontFeatureSettings
5986f6048ae21e0ec094c1f2ca0169d0ca6ec6b5 29-Jul-2014 Behdad Esfahbod <behdad@google.com> Support fontFeatureSettings

Bug: 15246510
Change-Id: I544915d29b2be4fb9f82f1989188a3a918c50fbc
ayout.cpp
11b08d8be3e2487488608173693180d6044f67bb 29-Jul-2014 Behdad Esfahbod <behdad@google.com> am d50c99df: Merge "Remove CSS string doLayout entrypoint and supporting code" into lmp-dev

* commit 'd50c99df4efbc57eb4419bd7944a979b9a1d53cc':
Remove CSS string doLayout entrypoint and supporting code
c924dd126db5d029af407ae6dd1a41c3652a6a64 29-Jul-2014 Behdad Esfahbod <behdad@google.com> Remove CSS string doLayout entrypoint and supporting code

All usage is ported to the new doLayout() API now.

Bug: 16651112
Change-Id: I2c959138a69853b5e30098889d771fe5f4cfaa66
ndroid.mk
ssParse.cpp
ayout.cpp
09f1901d6befcab49ed46cb77151a5d4af14a3b9 29-Jul-2014 Behdad Esfahbod <behdad@google.com> Add doLayout variant that does NOT take css string

New API removes CSS string and directly takes needed objects.

Bug: 16651112
Change-Id: Ie5f7c2ab05be6cbd77cae0a5fd6bb453771ada59
ayout.cpp
41b1aa18d7c32b4383993cd1b0a7e2e6648be14e 25-Jul-2014 Behdad Esfahbod <behdad@google.com> Merge "Don't get stuck on invalid UTF-16" into lmp-dev
b8208bc19c178b73175f76323381a1eeb8059807 25-Jul-2014 Behdad Esfahbod <behdad@google.com> Don't get stuck on invalid UTF-16

Replaces invalid unicode with replacement character U+FFFD and always
makes forward progress.

Bug: 15849380

Change-Id: Ic59ef6c64b0f5c4450bcae61597adcc269d6e7c5
ayout.cpp
a5bb91190edbea0be0e78a8511b3c920b6e99c4e 25-Jul-2014 Behdad Esfahbod <behdad@google.com> Towards CSS removal

Extract language from FontStyle during shaping. Don't attach CSS
to LayoutContext.

Change-Id: Ie621d3415410178d0d15fa7b810eb8e412342ab6
ontFamily.cpp
ayout.cpp
f0a1e5b2da5aaccbc1c010413365cd8c304cf5d9 25-Jul-2014 Behdad Esfahbod <behdad@google.com> Remove deprecated API

It has been unused outside minikin.

Change-Id: Iaa2237767d81c77f90d0264e633375e601dd72f1
ayout.cpp
a3aa943b865077123352a9309c9af28af8bb0347 29-Jul-2014 Behdad Esfahbod <behdad@google.com> Merge "Revert "Don't pass invalid Unicode codepoint to Skia""
75d33a31f661d9eb98f3d1b4ac180ed5a9dec014 25-Jul-2014 Behdad Esfahbod <behdad@google.com> Revert "Don't pass invalid Unicode codepoint to Skia"

After update to HarfBuzz 0.9.33 we don't need this anymore. HarfBuzz takes care of invalid input and passes U+FFFD to us.

This reverts commit 4422f4dd941628ad289bcabc75fbd788d37415f6.

Change-Id: Icfd0dc836a8d684fb1723fc215aa01f99639ff59
ayout.cpp
8e7a3dae37e9a22b2c054aec852615843d71caf6 18-Jul-2014 Behdad Esfahbod <behdad@google.com> Add letter-spacing support

Bug: 15594400
Change-Id: Ied94d7674be4097b0f44c9b0770d3294dc6433c1
ssParse.cpp
ayout.cpp
4422f4dd941628ad289bcabc75fbd788d37415f6 11-Jul-2014 Behdad Esfahbod <behdad@google.com> Don't pass invalid Unicode codepoint to Skia

Bug: 15849380
Change-Id: Ib5285e57c5806bd399600fadd56e8bc809da323f
ayout.cpp
a8e7eb6316e7d5169f0800e8f6e5af6508d97b72 11-Jul-2014 Behdad Esfahbod <behdad@google.com> Merge "Use __builtin_clzl if element is long"
329ae0639e332fa0ca85049f738776083b6dbafc 10-Jul-2014 Behdad Esfahbod <behdad@google.com> Use __builtin_clzl if element is long

Change-Id: I50a112739847fa826088854f6d172a188ff4cfb3
parseBitSet.cpp
fbe7ebf529b3d429ae9f153b7df3529554bfc64d 10-Jul-2014 Elliott Hughes <enh@google.com> Switch minikin to the new icu.

Change-Id: I29a59edfe6102257c9f308aac1b4348ef7a18db7
ndroid.mk
156acb18f53b32655abb34166ea737e4320ca366 07-Jul-2014 Raph Levien <raph@google.com> Assign non-coverage font runs to base font

When a run has no cmap coverage in any font, use the base font. Most of
the time, this will cause rendering of the .notdef glyph, which is
preferable to displaying nothing. In some cases, Harfbuzz may be able to
decompose the characters (not in the cmap) to ones that are, in which
case we'll render those, as long as they're in the base font.

Bug: 6629748
Bug: 15816880
Change-Id: Ibb1b9242c83626e0c7db363ad65ce44a967a005e
ontCollection.cpp
67ea671fe421d0e4642caef619ec39ec86bdcaef 26-Jun-2014 Raph Levien <raph@google.com> Disable "palt" OpenType feature

Proper Japanese layout requires sophisticated rules for spacing
punctuation, not just turning on the "palt" (proportional alternate)
feature. Until we can support the whole set, roll back palt.

Change-Id: If2359c529b70b1dd45dddc00e5f4aa1c91f8b0e9
ayout.cpp
22e41754f6470ff1f4c0e0a56d01f7f555b59e21 26-Jun-2014 Raph Levien <raph@google.com> Add purgeCaches() method

Expose a method to purge caches used for TextLayout, useful for low
memory conditions.

Change-Id: I92f41afe987b7be4af5ca0a0c50fb51be35a2758
ayout.cpp
3d28a3fcebfed4744d1ef0307a8bdc8fc01e364c 16-Jun-2014 Raph Levien <raph@google.com> Implement grapheme cluster breaking

This patch includes an implementation of grapheme cluster breaking,
which is especially useful for repositioning the cursor for left and
right arrow key presses. The implementation is closely based on Unicode
TR29, and uses the ICU grapheme cluster break property, but is tailored
to more closely match the existing implementation and expected behavior.

Part of a fix for b/15653110 Improve behavior of arrow keys in EditText

Change-Id: I8eb742f77039c9ab7b2838285018cf8a8fc88343
ndroid.mk
raphemeBreak.cpp
bb601b67dd05947f92cc23092bfb8a059c2e3377 19-Jun-2014 Raph Levien <raph@google.com> Make font runs less sticky

Fixes b/15734816 In the text "Wi-Fi", "-Fi" appears bolder than "Wi"

The problem was caused by "stickiness" in choosing fonts, where layout
would prefer using a font used for preceding characters as long as it
mapped the following characters in a run, in favor of the "best match"
rules. This patch adds a whitelist for making the stickiness more
conservative, only applying it for characters necessary for correct
shaping (ZWJ and ZWNJ in particular) and basic punctuation, where it is
desirable to match the style of the preceding text.

Change-Id: I1cf116879f074a5a71c351846707bfdd07b0d320
ontCollection.cpp
92207c3e831ce4214f60137da9430a1ce65351c0 12-Jun-2014 Raph Levien <raph@google.com> Merge "Fix missing text on nonexistent font file"
9f9f3b1ef40f7358dca6acd9dfef686cedefb6aa 12-Jun-2014 Raph Levien <raph@google.com> Tighten requirements for fake bold

The simple predicate for fake bold (2 or more grades darker than
requested) was applying it to thin (100 weight) when normal was
requested. This patch tightens the predicate to also require that
the requested weight be in the bold range.

Fix for bug 15588352 "sans-serif-thin doesn't work on lockscreen"

Change-Id: Id9988bd149a9c8a7c943e3b221f7fb4b37fb6ddb
ontFamily.cpp
bd36ec766a451c62ffdd407d5ce1a355e8f7dfd8 12-Jun-2014 Raph Levien <raph@google.com> Fix missing text on nonexistent font file

Fix for bug 15570313 "Missing text on nonexistent font file"

This patch makes sure that the lastChar and mInstances arrays are in
sync with each other even when a FontFamily being added has no valid
fonts in it. Previously, when they got out of sync, unicode coverage
calculation would be wrong, resulting in missing text.

Change-Id: I69c727ef69e2c61e2b2d6b81d5a28c806327f865
ontCollection.cpp
1c7b403ad8026fdebd0185319183d0a7a2c377bd 10-Jun-2014 Raph Levien <raph@google.com> Merge "Provisionally enable "palt" OpenType feature"
9a5f713add8cfb91ac2c9ed5c917309053201ab6 07-Jun-2014 Raph Levien <raph@google.com> Support for fake bold and italics

This patch adds support for computing when fake bold and fake italics
are needed (because the styles are requested but not provided by the
matching FontFamily), and providing them as part of the layout result.

Part of the fix for bug 15436379 Fake bold doesn't fully work (Minikin)

Change-Id: I180c034b559837943673b5c272c8e890178dff0d
ontCollection.cpp
ontFamily.cpp
ayout.cpp
4043f6f6d9c584bc61bc3d81d1680bf1b558330e 07-Jun-2014 Raph Levien <raph@google.com> Provisionally enable "palt" OpenType feature

We want to test configurations where the Noto Japanese font will have
its "palt" feature (to select tighter spacing in kana) will be enabled
for framework but not WebView or Chrome rendering of Japanese text. This
patch simply hardcodes this feature on.

This is also a first step towards more general setting of OpenType
features. The hardcoded feature list will grow into one set by
parameters which will eventually be plumbed up to Java.

Change-Id: Ie284e0487a1434155c8ac1cb68ddc4fc4b3c018a
ayout.cpp
89566f0ada1cafe673efa064cde38467990235d4 06-Jun-2014 Raph Levien <raph@google.com> Add baseFont method to FontCollection

This patch adds a method to retrieve the base font from a
FontCollection, which is useful when querying global font metrics.

Part of the fix for bug 15467288 "Inconsistent line heights on
Minikin builds"

Change-Id: I268ae5128d0852a020d746bc22af81fc1a623228
ontCollection.cpp
3f1ea5da2ee12b0d95c17c56928c3e553d4eeda0 05-Jun-2014 Raph Levien <raph@google.com> Support for context in API

This patch completes support for adding context for complex script
layout, for example when a string with joins straddles two spans.

Part of the fix for 15431028: "Properly support context for joining
scripts (Minikin)"

Change-Id: I65b0833be92eb477aa531bbef0ac6eddeb3a962a
ayout.cpp
3164d1a77eecf3185347a44342131f4275de824f 05-Jun-2014 Raph Levien <raph@google.com> Make paint flags consistently uint32_t

Change internal plumbing of paint flags (including CssParse) to uint32_t
consistently, to match the type used in the client. This will probably
prevent compiler warnings. Also renames "float" to "double" to avoid
confusion about precision.

Change-Id: I80374712c4067ca9e7711cc2d4ec33c440ab9c7c
ssParse.cpp
ayout.cpp
893399732b64203133c22ad3c1f3535e46bf35a7 04-Jun-2014 Raph Levien <raph@google.com> Fix unmatching type

Missed a slightly mismatched type (int vs int32_t) from a previous code
review.

Change-Id: Ib56775a3a1a6ec3763da7f7432186954251cc048
ayout.cpp
448b0fd720d7ba902b9be224a287d08abe3ebea8 31-May-2014 Raph Levien <raph@google.com> Support for scaleX and skewX

Adds pseudo-css properties for scaleX and skewX, as well as paint flags,
and plumb them through to the MinikinPaint abstraction and to Harfbuzz,
to support nontrivial scale and stretch of text.

This is the Minikin part of the fix for bug 15186705 "Usability of the
suggestion strip in recent OTA's is severely reduced"

Change-Id: Ifa60355e086e4691ff92c5d50d84eb7cea0fea95
ssParse.cpp
ayout.cpp
066e8575af64fb452617ac6005de6ccf6509553b 29-May-2014 Raph Levien <raph@google.com> Fix ZWJ not working for Indic fonts

This is a fix for bug 15185229 ZWJ not working in Sinhala and Kannada.

Indic fonts (unlike Arabic) require the entire string, including ZWJ,
to be passed to Harfbuzz; it's not enough for the ZWJ to be present in
the context. The solution is to be "sticky" in font itemization,
continuing to use the same font as long as it has Unicode coverage.

Change-Id: I7673bc56fbda09f1e1a4582e8d88342343b706f1
ontCollection.cpp
7b221d97b7b64dc5ce457e19666d55d042e22e62 27-May-2014 Raph Levien <raph@google.com> Language and variant selection

This patch adds a "lang" pseudo-CSS property and uses it both to select
an appropriate font and control the "locl" OpenType feature to get the
most appropriate rendering for the langauge and script. In addition,
the "-minikin-variant" property selects between "compact" and "elegant"
variants of a font, as the former is needed for vertically cramped
spaces.

This is part of the fix for bug 15179652 "Japanese font isn't shown on
LMP".

Change-Id: I7fab23c12d4c797a6d339a16e497b79a3afe9df1
ssParse.cpp
ontCollection.cpp
ontFamily.cpp
ayout.cpp
0297ee985c26b49fc2a3b0941db354c27f436bbf 29-May-2014 Raph Levien <raph@google.com> Fix for Minikin native crash

The context start offset wasn't being taken into account for
accumulating the advance values, leading in some cases to array index
overflow.

This is a fix for bug 15327918 "SIGSEGV in
android::MinikinFontSkia::GetSkTypeface()"

Change-Id: I9b646785724c9b72d862b822cd84661c106fbe52
ayout.cpp
7c382381191b2280b53c375fe83dfc6217bbdfa9 26-May-2014 Raph Levien <raph@google.com> Fix for bug 15252902 native crash in Minikin

This is a fix for bug 15252902 "Crash observed on keep launch or
existing youtube app after playing video". It was doing the test for a
null font after trying to resolve the font in a cache, which caused a
crash when there was no font for the run. This patch just tests before
cache lookup.

Change-Id: Iee41f7ce6b69cb09438462b6aaa916f242da7b77
ayout.cpp
4d4e6bc8118d15542f1f2a9218f0f7a91a29474f 21-May-2014 Raph Levien <raph@google.com> Caching for layouts and harfbuzz faces

This patch adds caching for both layouts and for HarfBuzz face objects.
The granularity of the cache for layouts is words, so it splits the
input string at word boundaries (using a heuristic). There are is also
some refactoring to reduce the amount of allocation and copying, and
movement towards properly supporting contexts.

The size of the caches is a fixed number of entries; thus, it is
possible to consume a large amount of memory by filling the cache with
lots of large strings. This should be refined towards a scheme that
bounds the total memory used by the cache.

This patch fixes bug 15237293 "Regression: Measure performance is
significantly slower with minikin".

Change-Id: Ie8176857e2d78656ce5479a7c04969819ef2718d
ndroid.mk
ontCollection.cpp
ayout.cpp
d973b3926b3a34c19d3d6f309fae1138e782e4dc 27-May-2014 Raph Levien <raph@google.com> Merge "Do BiDi algorithm for text layout" into lmp-preview-dev
86fa46c5ebb0d2c3319e08f4fbf487d8c2abbbfc 19-May-2014 Raph Levien <raph@google.com> Do BiDi algorithm for text layout

This is a fix for bug 15130102 "Language name for Hebrew displayed the
wrong way around on keyboard".

This patch extends the previous BiDi support (when the direction for the
entire string was given by the caller) to run the BiDi algorithm
(provided by ICU) over the string to break it into BiDi runs. Thus, it
handles mixed LTR and RTL strings in a single layout, and also respects
heuristics for inferring the paragraph direction from the string.

Change-Id: Ia4b869de3c139c5a7d16b8ce7766870b98a815ea
(cherry picked from commit 4b3a941128454e55893d65433a835e78a9e9781d)
ndroid.mk
ayout.cpp
72fe9422c869b7878240a23e4650d9d90edb1c2a 24-May-2014 Raph Levien <raph@google.com> Fix native crash in Latin-1 typefaces

This is a fix for bug 15171911 Timely crashes (native crash in
libminikin) when I go to add a new alarm

This patch fixes an off-by-one error that caused typefaces with only one
page of Unicode coverage (ASCII or Latin-1) to have nPages = 0 instead
of the correct value of 1 in the corresponding FontCollection.

Change-Id: Id8be0c9e5713b8af22d863992921ee6382416a34
ontCollection.cpp
c31e3883456e018d742e9f29815ba5ff8b315ea1 19-May-2014 Raph Levien <raph@google.com> Fix incomplete refcounting and locking

These changes were supposed to be committed in the previous patch
"Better refcounting and locking" but seem to have gotten lost in a
rebase. It fixes a memory leak and some possible race conditions.

Change-Id: I54ca1e37500ec49756fe317cc6d6d03da9911501
ontCollection.cpp
ontFamily.cpp
ayout.cpp
d231a4b0b1d482c7ae7717b048112e1fe5d0f5a9 13-May-2014 Raph Levien <raph@google.com> Initial BiDi support

This patch contains a very basic implementation of BiDi. It respects the
BiDi flags passed in as an explicit parameter (through the
"-minikin-bidi" pseudo-CSS property), but doesn't yet do its own BiDi
run detection. It also takes some shortcuts (marked as TODO) that are
based on reasonable assumptions of the current font stack, but not
universally valid.

Even with these shortcomings, it seems to display RTL text from TextView
correctly.

Change-Id: I223433923c4eb06f90c0327e86bfbe0aff71d4f5
ssParse.cpp
ayout.cpp
0a689bb956183beebe7d59fccb226a82680f265a 14-May-2014 Raph Levien <raph@google.com> Fix 64-bit cleanliness problem

This patch fixes a problem where int and ssize_t were being conflated.

Change-Id: I642a4ee1d59d81723034fdfe33bd8ca29a5dc322
ayout.cpp
d133eab2a1a59ce4a5b1b3db04ec00dc0dbdf349 14-May-2014 Raph Levien <raph@google.com> Fix build breakage in sample code

This updates the Skia sample implementation to implement GetBounds,
but the FreeType implementation is NYI (to be fixed in future commit).

Change-Id: I24eda14d5fb11c2a1e81394ad8c779de3292dd79
inikinFontFreeType.cpp
b80c1f19c58b927820a8a24bf2218e5645724608 06-May-2014 Raph Levien <raph@google.com> Better refcounting and locking

All major externally accessible objects (especially FontFamily and
FontCollection) are now reference counted. In addition, there is a
global lock intended to make operations thread-safe.

WIP notice: in this version of the patch, not all external API entry
points are protected by the lock. That should be fixed.

Change-Id: I14106196e99eb101e8bf1bcb4b81359759d2086c
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ayout.cpp
inikinInternal.cpp
inikinInternal.h
inikinRefCounted.cpp
ecc2d34ac23a497988f21e5f415b53c007b9d8c5 15-Jul-2013 Raph Levien <raph@google.com> A basket of features: itemization, bounds, refcount

This patch improves script run itemization and also exposes metrics
and bounds for layouts. In addition, there is a fair amount of internal
cleanup, including ref counting, and making the MinikinFont abstraction
strong enough to support both FreeType and Skia implementations. There
is also a sample implementation using Skia, in the sample directory.

As part of its functionality, his patch measures the bounds of the
layout and gives access through Layout::GetBounds(). The corresponding
method is not implemented in the FreeType-only implementation of
MinikinFont, so that will probably have to be fixed.

Change-Id: Ib1a3fe9d7c90519ac651fb4aa957848e4bb758ec
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ayout.cpp
1279a3bf5ec6131efefbc51d52d24850fd81f676 12-Sep-2013 Kenny Root <kroot@google.com> Use canonical UniquePtr.h header

Change-Id: Id50e9d6fe2f08d3121b168b45791a8e8fb045d7f
ontFamily.cpp
1686c1d7a2562360bfcca52e9c53ebbcd1bed00c 28-Jun-2013 Victoria Lease <violets@google.com> Use shared ft2 lib, deal with libpng/zlib deps

Bug: 9603326
Change-Id: I7df1f68fa3a44b37b1b279387f4ddfe942928bb0
ndroid.mk
bcc3dc5a2591a95a57e379e27cbad69c18e91e67 23-May-2013 Raph Levien <raph@google.com> Introduce MinikinFont abstraction

This commit removes the direct dependency on FreeType and replaces it
with a MinikinFont abstraction, which is designed to support both
FreeType and Skia fonts (and possibly others in the future).

Also adds a "total advance" to the Layout, with an API for retrieving
it.

Change-Id: If20f92db9a43fd15b0fe9794b761ba00fb21338c
ndroid.mk
ontCollection.cpp
ontFamily.cpp
ayout.cpp
inikinFontFreeType.cpp
9cc9bbe1461f359f0b27c5e7645c17dda001ab1d 24-Apr-2013 Raph Levien <raph@google.com> Initial commit of Minikin library

This is the initial draft of Minikin, a library intended to perform text
layout functions. This version does basic weight selection and font runs
for scripts, and also has a simple renderer for drawing into bitmaps,
but is lacking measurement, line breaking, and a number of other
important features. It also lacks caching and other performance
refinements.

Change-Id: I789a2e47d11d71202dc84b4751b51a5e2cd9c451
nalyzeStyle.cpp
ndroid.mk
mapCoverage.cpp
ssParse.cpp
ontCollection.cpp
ontFamily.cpp
ayout.cpp
parseBitSet.cpp