252 Commits

Author SHA1 Message Date
Keisuke Kuroyanagi
6344de60fa 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
2016-01-21 18:23:25 +09:00
Raph Levien
f3b1a821f5 Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: a3df6da30b am: e82552ae00 am: 545b36d667 am: 98dd15e2cd am: 97d7265862 -s ours
am: f5dc6044c6  -s ours

* commit 'f5dc6044c679eb80c28900d755a42cc5730447a1':
  Reject fonts with invalid ranges in cmap
2016-01-15 22:22:10 +00:00
Raph Levien
f5dc6044c6 Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: a3df6da30b am: e82552ae00 am: 545b36d667 am: 98dd15e2cd
am: 97d7265862  -s ours

* commit '97d7265862a9df05b3521ac4954de9cc82ec989d':
  Reject fonts with invalid ranges in cmap
2016-01-15 22:11:58 +00:00
Raph Levien
97d7265862 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
2016-01-15 21:50:24 +00:00
Raph Levien
98dd15e2cd 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
2016-01-15 21:45:37 +00:00
Raph Levien
545b36d667 Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: a3df6da30b
am: e82552ae00

* commit 'e82552ae0094efdb1b1b40ebfc832540eeb1234b':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:43:03 +00:00
Raph Levien
e82552ae00 Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab
am: a3df6da30b

* commit 'a3df6da30bdfda0b5b188e6511deeffddeeb9409':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:40:23 +00:00
Raph Levien
a3df6da30b Reject fonts with invalid ranges in cmap am: ca8ac8acda
am: 3034e8b4ab

* commit '3034e8b4ab627278b88faae2f4813562f31a7c2b':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:36:37 +00:00
Raph Levien
3034e8b4ab Reject fonts with invalid ranges in cmap
am: ca8ac8acda

* commit 'ca8ac8acdad662230ae37998c6c4091bb39402b6':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:28:10 +00:00
Seigo Nonaka
6f9966ea7c 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
2016-01-15 14:35:14 +09:00
Raph Levien
a69ca2e172 Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE am: 2e98eb6be1
am: 850fcc0b6f  -s ours

* commit '850fcc0b6fb848b383ab3123d243faf9c73efda0':
  Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE
2016-01-13 23:52:06 +00:00
Raph Levien
850fcc0b6f 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
2016-01-13 23:17:11 +00:00
Raph Levien
2e98eb6be1 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
2016-01-13 14:12:56 -08:00
Raph Levien
6638e05ac2 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
2016-01-13 12:52:38 -08:00
Raph Levien
ca8ac8acda 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
2016-01-07 21:39:25 +00:00
Raph Levien
73abbd5934 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
2016-01-07 13:38:42 -08:00
Andreas Gampe
a5706e4ef9 Minikin: Disable sanitizer on x86 am: 72c026822d
am: 0497c013f6

* commit '0497c013f640324550ff731bc088bb62fbb6882a':
  Minikin: Disable sanitizer on x86
2016-01-07 04:47:52 +00:00
Andreas Gampe
0497c013f6 Minikin: Disable sanitizer on x86
am: 72c026822d

* commit '72c026822d32550b10bb62949644c10826d7658e':
  Minikin: Disable sanitizer on x86
2016-01-07 04:45:20 +00:00
Andreas Gampe
72c026822d Minikin: Disable sanitizer on x86
Disable unsigned-integer-overflow sanitizer on x86, as it crashes.

Bug: 25884483
Bug: 26432628
Change-Id: Ia658ed56a6c81660a36edf71f7116118056aa917
2016-01-06 20:28:52 -08:00
Seigo Nonaka
f9af6786dc Merge "Fix lock assertion failures in unit test." 2016-01-07 03:14:25 +00:00
Dan Austin
97944f2856 Enable integer sanitization in libminikin am: 7087da2519
am: cf6ebc1ebc

* commit 'cf6ebc1ebcc9137c12e221799f3b20436d2984c1':
  Enable integer sanitization in libminikin
2016-01-06 20:44:58 +00:00
Dan Austin
cf6ebc1ebc Enable integer sanitization in libminikin
am: 7087da2519

* commit '7087da2519f0aa303e5941e7d8cfbe2a73e696a2':
  Enable integer sanitization in libminikin
2016-01-06 20:42:47 +00:00
Dan Austin
7087da2519 Enable integer sanitization in libminikin
Enable signed and unsigned integer sanitization in libminikin.

Bug: 25884483
Change-Id: I98905827174d16138d20bb443fe2e1d7228ea1a3
2016-01-06 12:30:12 -08:00
Dan Austin
728ae8d629 Revert "Enable integer sanitization in libminikin." am: 342cd45a5e
am: 5255614d23

* commit '5255614d230d241432c7f86c4ce3582a8cb71545':
  Revert "Enable integer sanitization in libminikin."
2016-01-06 18:38:18 +00:00
Dan Austin
5255614d23 Revert "Enable integer sanitization in libminikin."
am: 342cd45a5e

* commit '342cd45a5e5779e81155515d36cd500bfd975fdf':
  Revert "Enable integer sanitization in libminikin."
2016-01-06 18:36:33 +00:00
Dan Austin
342cd45a5e Revert "Enable integer sanitization in libminikin."
This reverts commit 9c13a3dc96d16976c45417bdc34e0fc5670815b9.

Change-Id: Iecd1f61a5fdf5955d871a920cb243553857d46ff
2016-01-06 18:31:38 +00:00
Dan Austin
679f147eda Enable integer sanitization in libminikin. am: 9c13a3dc96
am: ebe371670e

* commit 'ebe371670e760b5318db6a02e10775e4a4ed7b96':
  Enable integer sanitization in libminikin.
2016-01-06 17:08:33 +00:00
Dan Austin
ebe371670e Enable integer sanitization in libminikin.
am: 9c13a3dc96

* commit '9c13a3dc96d16976c45417bdc34e0fc5670815b9':
  Enable integer sanitization in libminikin.
2016-01-06 17:06:22 +00:00
Seigo Nonaka
2342e5310f Fix lock assertion failures in unit test.
The assertion for the lock state has now activated by
I9c4b1e1f09c6793e387fbdb8bb654cc0a13c65d5.
This CL fixes the assertion failure in the unit tests by acquiring
lock before calling the functions.

Change-Id: I6a6afefb4de01e8610c2abfe6c779afa9442cc67
2016-01-06 22:49:33 +09:00
Seigo Nonaka
7564b7fd5b Merge "Fix race condition in Paint.hasGlyph()" 2016-01-06 06:00:38 +00:00
Seigo Nonaka
a6f5c46836 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
2016-01-06 03:21:37 +00:00
Dan Austin
9c13a3dc96 Enable integer sanitization in libminikin.
Enable signed and unsigned integer sanitization in libminikin.

Bug: 25884483
Change-Id: I53abf6affea8e2bb3a5abd381a9f19003a306b36
2016-01-05 17:36:31 -08:00
Roozbeh Pournader
b5aba20c13 Merge "Replace Qaae script with Zsye" 2016-01-05 21:54:29 +00:00
Seigo Nonaka
d337652233 Replace Qaae script with Zsye
The emoji variant script "Zsye" is registered in ISO 15924.

Bug: 26226285
Change-Id: Ibc2bc740d57c48f99b6f66b1ad7595bfa8c3cff4
2016-01-05 05:05:57 +00:00
Seigo Nonaka
198b46f1fe 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
2016-01-05 14:00:32 +09:00
Raph Levien
3d629534d7 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE am: 30fca219e0 -s ours am: 43772d6ef2 -s ours
am: 2cc5a22011  -s ours

* commit '2cc5a220117d1afeae62eda02d839b58a0f0391b':
2015-12-23 18:11:56 -08:00
Bart Sears
bba7b1b425 Merge "Revert "Save all kind of script tags into FontLanguage."" 2015-12-22 09:07:09 +00:00
Bart Sears
6c4c098cbd Revert "Save all kind of script tags into FontLanguage."
This reverts commit 5e995fb850c2b32631914c3815dfb421855fba9b.

Change-Id: I761e0e41906742fbe3d3ac34170af3101e18042a
2015-12-22 09:06:03 +00:00
Seigo Nonaka
96233efe4c Merge "Save all kind of script tags into FontLanguage." 2015-12-22 04:01:19 +00:00
Seigo Nonaka
5e995fb850 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
2015-12-22 09:34:04 +09:00
Seigo Nonaka
c5ec243b3a No op build should not build minikin_tests
Previous CL[1] adds module names into LOCAL_ADDITIONAL_DEPENDENCIES, but
it was wrong. LOCAL_ADDITIONAL_DEPENDENCIES only accepts file path.

However, BUILD_PREBUILT doesn't provide a file path of the installed
font. So use custom tool and LOCAL_GENERATED_SOURCES instead.

Confirmed no-op build doesn't built minikin_tests and
continuous_native_tests.zip contains all necessary files.

[1]: I7d83abc077bce4e38fd93c7d607bc7e1f7871e6b

BUG: 26197092
Change-Id: I90e80036248ae72e0e0f9c6144a259f5f96ec9ce
2015-12-15 16:11:21 -08:00
Dan Austin
1f0d794737 Refactored unsigned long negations am: 1bbe03d215
am: b9f27a2509

* commit 'b9f27a2509241a0f2dfcf6921958dab4b14fbc42':
  Refactored unsigned long negations
2015-12-14 09:30:20 -08:00
Dan Austin
b9f27a2509 Refactored unsigned long negations
am: 1bbe03d215

* commit '1bbe03d215c9452bc9917111e63f19160cc5f56a':
  Refactored unsigned long negations
2015-12-14 09:12:42 -08:00
Dan Austin
1bbe03d215 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
2015-12-11 16:33:23 -08:00
Seigo Nonaka
43bb9743ca 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
2015-12-10 18:41:03 -08:00
Seigo Nonaka
efaf02ea3a Copy test font files into data directory.
To work native tests with additional font related files, copy
the files into /data/nativetest/minikin_tests/.
This copy only happens when the minikin_tests is built.
It is not an expected to copy the font files into the product image.

Change-Id: I7d83abc077bce4e38fd93c7d607bc7e1f7871e6b
2015-12-09 14:44:12 -08:00
Seigo Nonaka
6d9dcd2cf3 Introduce FontLanguageListCache.
FontLanguageListCache is an intentionally leaky singleton and its
internal cache won't be purged.

BUG: 25122318

Change-Id: I272097e979fe44b83fd86822235350e12eda8f51
2015-12-08 18:49:18 -08:00
Seigo Nonaka
a47969c90a Merge "Select emoji font based on variation selectors." 2015-12-08 21:29:42 +00:00
Raph Levien
a1d81a1797 Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ffadd191a0 am: d56908571d am: 7aec64b909 am: 8921cfe226
am: 868eaf86be

* commit '868eaf86be0ba319653a3fabc8893d7d6eaedb21':
  Avoid integer overflows in parsing fonts
2015-12-08 19:58:04 +00:00
Raph Levien
868eaf86be Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ffadd191a0 am: d56908571d am: 7aec64b909
am: 8921cfe226

* commit '8921cfe226e9b7774810c9711579586b5b227b82':
  Avoid integer overflows in parsing fonts
2015-12-08 19:54:42 +00:00