History log of /frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp
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
/frameworks/minikin/libs/minikin/FontCollection.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
/frameworks/minikin/libs/minikin/FontCollection.cpp