History log of /frameworks/minikin/include/minikin/FontCollection.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d0ca7a21fe1779b16b4752381019c87867f1fb48 20-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Expose supportedAxes to frameworks/base"
f6d1c03ffa329d5d8c9261061f5c13daaa8c3966 10-Mar-2017 Seigo Nonaka <nona@google.com> Expose supportedAxes to frameworks/base

The list of supportedAxes are necessary for returning value of
setFontVariationSettings.

Bug: 35764323
Test: ran TextViewTest and PaintTest in cts
Change-Id: I52f244146ea0ce335df02c841f89285be2ed746e
/frameworks/minikin/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.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
/frameworks/minikin/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.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
/frameworks/minikin/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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
/frameworks/minikin/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h
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/include/minikin/FontCollection.h