Commit Graph

273 Commits

Author SHA1 Message Date
Seigo Nonaka
dc8de001df Revert "Clean Up: Removing unused interface GetTable from MinikinFont."
This reverts commit 7b02f5e95c.

This causes a crash on Android Auto.

Bug: 32374752
Change-Id: Ia2ff77bf9a12351c6949f79ef6fa2d8016e3022d
2016-10-25 00:49:52 +00:00
Seigo Nonaka
7b02f5e95c 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
2016-10-18 08:16:18 +00:00
Dan Willemsen
4d688b0172 Merge "Rename libicuuc-host/libicui18n-host to libicuuc/libicui18n" am: f8ca78ffa4 am: 90f9f8d7a2 am: e2217d5b85
am: b4c239f555

Change-Id: I85ee278323a578fcf941651161b46ef0559098cc
2016-09-13 04:32:28 +00:00
Dan Willemsen
b4c239f555 Merge "Rename libicuuc-host/libicui18n-host to libicuuc/libicui18n" am: f8ca78ffa4 am: 90f9f8d7a2
am: e2217d5b85

Change-Id: I346fddaa5822eee2371d877a8bdeb055b6244c0d
2016-09-13 03:58:51 +00:00
Dan Willemsen
f8ca78ffa4 Merge "Rename libicuuc-host/libicui18n-host to libicuuc/libicui18n" 2016-09-13 03:47:02 +00:00
Elliott Hughes
88ca7498cc Switch minikin to std::unique_ptr. am: fba88d3b3c am: c5e0585ac7 am: 83bdd0ae73
am: b150a633ba

Change-Id: I56cce90607bce82d337d4da3b4ac5f167c7cc1b4
2016-09-13 01:50:14 +00:00
Elliott Hughes
b150a633ba Switch minikin to std::unique_ptr. am: fba88d3b3c am: c5e0585ac7
am: 83bdd0ae73

Change-Id: I9c0b81d55e01b08b053a7031a214626351244607
2016-09-13 01:29:45 +00:00
Elliott Hughes
fba88d3b3c Switch minikin to std::unique_ptr.
Bug: http://b/22403888
Change-Id: I9e18496fcc38ad2e6b922455daa9f2a46778ec55
2016-09-12 15:29:35 -07:00
Dan Willemsen
b4f4c16d32 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
2016-09-12 14:37:02 -07:00
Chih-Hung Hsieh
85c660fa98 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
2016-08-15 13:58:52 -07:00
Roozbeh Pournader
8bbb3224cf Revert "Lookup glyph from color emoji font before and after ZWJ." am: 96fa633577 am: 01be577f0e
am: 777a92cefa

Change-Id: Iebf945839891cc1ab561cf424ef917ac15e08842
2016-08-11 23:40:20 +00:00
Roozbeh Pournader
96fa633577 Revert "Lookup glyph from color emoji font before and after ZWJ."
This reverts commit 56bda7e82a.

Bug: 30815709
Change-Id: I057d9bcd05246e58894abb4e9633bd10f6fab211
2016-08-11 21:03:00 +00:00
Ben Wagner
3ebdaaae86 Move SkTypeface::CreateXXX to SkTypeface::MakeXXX.
Skia is moving to returning smart pointers from its factory methods.
This updates uses of SkTypeface::CreateXXX to SkTypeface::MakeXXX and
generally updates use of SkTypeface to sk_sp. This will allow for the
removal of the SK_SUPPORT_LEGACY_TYPEFACE_PTR define.

Change-Id: If3e600c6cb86080576667bc77d427da4f6560afa
2016-08-05 13:57:22 -04:00
Seigo Nonaka
56bda7e82a 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
2016-07-13 14:12:06 -07:00
Seigo Nonaka
c5d673d423 Treat U+2695, U+2640, U+2642 as emoji characters.
Bug: 29885295
Change-Id: I1bf191a46d05e7099265d863bae0523c50817d0b
2016-07-13 14:05:02 -07:00
Seigo Nonaka
2fd057eb70 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
2016-07-13 14:01:41 -07:00
Seigo Nonaka
3d665c82d4 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
2016-07-12 10:07:19 +09:00
Seigo Nonaka
9c9fda459e Treat U+2695, U+2640, U+2642 as emoji characters.
Bug: 29885295
Change-Id: I1bf191a46d05e7099265d863bae0523c50817d0b
2016-07-11 15:27:05 +09:00
Seigo Nonaka
dc6138ffeb 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
2016-07-08 15:49:50 +09:00
Adam Buchbinder
a39c200b81 Merge "Fix a leaked file in HyphTool.cpp." 2016-07-07 20:51:08 +00:00
Seigo Nonaka
cd8eea6205 Fix build failure of minikin_perftest
stat.st_size is off_t not size_t, so need to cast to size_t before
compare it.

Change-Id: I6b742746fbb9f254701fc91e515c293f93f912c5
2016-06-28 09:37:17 +00:00
Seigo Nonaka
a89c08ae49 Introduce FontCollection perftest
This CL introduces performance tests for FontCollection.

To support TTC file in /system/fonts, this CL also extends FontTestUtils

Bug:29142734
Change-Id: I9d8ad24ca55f61031b85623ab7c26234239e4f41
2016-06-28 08:52:35 +00:00
Seigo Nonaka
df66baa6fa Add more native perf tests to minikin.
This CL introduces performance tests for following three modules:
- Hyphenator
- WordBreaker
- GraphemeBreak

During using UnicodeUtils, need to decouple it from gtest since
perftest doesn't have gtest dependencies.

Bug:29142734
Change-Id: I700c662fa7d0a52f19d8e93150ad1a85dc28769f
2016-06-28 16:55:42 +09:00
Seigo Nonaka
c3b9f7dadd Fix test utilities
This fixes following three memory leaks in test utilities.
There is no problem in production code and this CL doesn't affect
any production behaviors.

- SkTypeface leaks due to forget calling SkSafeUnref in dtor.
- MinikinFontForTest leaks during constructing FontCollection.
- FontCollection leaks due to unnecessary AddRef.

Change-Id: I22e1e0307f1b2499296acb1aacc3ef66076a36e9
2016-06-21 16:47:25 +09:00
Seigo Nonaka
2fdcf62495 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
2016-06-11 00:11:17 +09:00
Seigo Nonaka
b344fd499c Merge "Introduce initial minikin perftest" 2016-06-09 03:31:45 +00:00
Seigo Nonaka
2eef839c8e Reconstruct the directory structure of minikin tests.
To add perftests and reuse some utility classes, reconstruct
test directory structure.

- Move unit tests from minikin/tests to minikin/tests/unittests
- Extract utilitiy classes to minikin/tests/utils which will be
  used by perftests eventually.

Change-Id: I5026b177934e72ae67d362ee888302037da2f808
2016-06-09 03:25:03 +00:00
Seigo Nonaka
96c4e39716 Introduce initial minikin perftest
Bug: 28992567
Change-Id: Id14cc86761d6c5b408262fe8684e2b293a420a4f
2016-06-08 13:01:55 +09:00
Roozbeh Pournader
acaf5cc08d 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
2016-05-25 16:46:56 -07:00
Adam Buchbinder
1cec37d918 Fix a leaked file in HyphTool.cpp.
This addresses the following cppcheck reports:
[frameworks/minikin/app/HyphTool.cpp:30]: (error) Resource leak: f
[frameworks/minikin/app/HyphTool.cpp:32]: (error) Resource leak: f

Change-Id: I5113e0a7268bd3a45bf1498fd023042d9dfe2b87
2016-05-23 13:16:13 -07:00
Seigo Nonaka
47932fa53b Do not break before and after ZWJ.
The emoji list is generated from external/unicode/emoji-data.txt

Bug: 28248662
Change-Id: Ie49b3782505665d62c24371ca23d317ae5e9c5f7
2016-04-19 14:09:38 +00:00
Seigo Nonaka
0f5d87990b 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
2016-04-15 12:45:04 +09:00
Raph Levien
1aa246aa80 Merge "Clear mLineWidths in LineBreaker::finish()" into nyc-dev 2016-04-13 16:11:56 +00:00
Raph Levien
0ae37ab603 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
2016-04-12 15:27:17 -07:00
Seigo Nonaka
bb8b7fd32f 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] 1ea4165cef

Bug: 28105730
Bug: 28105688
Change-Id: Ie5983c4869147dacabdca81af1605066cd680b3f
2016-04-11 13:33:35 -07:00
Raph Levien
d2161cf80f Update minikin/sample code to use new GetTable
We changed the signature of the MinikinFont::GetTable method. This
patch updates the sample code, and fixes the build.

Change-Id: I1977be868bf7636986fc802915f3dd54c418a73a
2016-04-08 10:28:47 -07:00
Raph Levien
a8e8948bd7 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
2016-04-08 08:26:38 -07:00
Raph Levien
1ea4165cef 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
2016-04-07 13:43:15 -07:00
Seigo Nonaka
dbcbe1f426 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
2016-04-04 22:31:16 +09:00
Roozbeh Pournader
c9c0359b1d 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
2016-03-30 17:48:34 -07:00
Roozbeh Pournader
0eaf80b016 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
2016-03-16 16:21:09 -07:00
Seigo Nonaka
5ccdf654f5 Suppress log span due to returning null for itemize result.
Bug: 26808815
Change-Id: I2a5a52f2c441d27c7ef270342b4ef93c3de9e56e
2016-03-03 15:51:55 -08:00
Seigo Nonaka
f4c679ca68 Break regional indicators at even numbered code points.
Bug: 23288449
Change-Id: If1419ff9e44e8e640616979bae88311f414b42a1
2016-03-02 17:44:14 -08:00
Raph Levien
a58530bccc Fix wrong conditions in isEmojiBase
I computed ranges using low <= c || c <= high, should be &&.

Bug: 26829153
Change-Id: Ic1002d90b6a408a0b415f2d117d0e57adcbc2fa9
2016-02-27 07:43:56 -08:00
Raph Levien
7f9de429d4 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
2016-02-26 19:05:34 +00:00
Seigo Nonaka
b7d66e3db0 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
2016-02-26 11:26:30 +09:00
Raph Levien
336d826c44 Merge "Suppress grapheme cluster breaks in emoji with modifiers" into nyc-dev 2016-02-24 20:58:55 +00:00
Raph Levien
675933f271 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
2016-02-24 12:43:36 -08:00
Seigo Nonaka
9b2942bfe6 Merge "Support Hanb script." into nyc-dev 2016-02-23 03:57:58 +00:00
Raph Levien
e87aac42d0 Merge "Suppress linebreaks in emoji ZWJ sequences" into nyc-dev 2016-02-19 17:53:48 +00:00