206 Commits

Author SHA1 Message Date
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
Raph Levien
8921cfe226 Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ffadd191a0 am: d56908571d
am: 7aec64b909

* commit '7aec64b9099d0b5bbbe766a2c29b9f09f0939a4c':
  Avoid integer overflows in parsing fonts
2015-12-08 11:36:58 -08:00
Raph Levien
7aec64b909 Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ffadd191a0
am: d56908571d

* commit 'd56908571d3dc28686a198484d1cc8a399276d86':
  Avoid integer overflows in parsing fonts
2015-12-08 19:33:14 +00:00
Raph Levien
d56908571d Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985
am: ffadd191a0

* commit 'ffadd191a041f16c52b693d8dc0c42b3b9f01b2b':
  Avoid integer overflows in parsing fonts
2015-12-08 11:29:31 -08:00
Raph Levien
ffadd191a0 Avoid integer overflows in parsing fonts am: 6299a6ba13
am: 998293f985

* commit '998293f985dc6c23f90b160f3bc647807c76d3fe':
  Avoid integer overflows in parsing fonts
2015-12-08 19:22:49 +00:00
Raph Levien
998293f985 Avoid integer overflows in parsing fonts
am: 6299a6ba13

* commit '6299a6ba13906c695f7a4f6748f7bc5856a110e5':
  Avoid integer overflows in parsing fonts
2015-12-08 19:17:40 +00:00
Seigo Nonaka
369d2d44cb 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
2015-12-07 16:49:16 -08:00
Raph Levien
6299a6ba13 Avoid integer overflows in parsing fonts
A malformed TTF can cause size calculations to overflow. This patch
checks the maximum reasonable value so that the total size fits in 32
bits. It also adds some explicit casting to avoid possible technical
undefined behavior when parsing sized unsigned values.

Bug: 25645298
Change-Id: Id4716132041a6f4f1fbb73ec4e445391cf7d9616
(cherry picked from commit 183c9ec2800baa2ce099ee260c6cbc6121cf1274)
2015-12-07 17:58:12 +00:00
Raph Levien
183c9ec280 Avoid integer overflows in parsing fonts
A malformed TTF can cause size calculations to overflow. This patch
checks the maximum reasonable value so that the total size fits in 32
bits. It also adds some explicit casting to avoid possible technical
undefined behavior when parsing sized unsigned values.

Bug: 25645298
Change-Id: Id4716132041a6f4f1fbb73ec4e445391cf7d9616
2015-11-30 15:08:41 -08:00
Seigo Nonaka
66a34a04ab Merge "Search all families instead of using mRanges for variation sequence." 2015-11-20 05:46:31 +00:00
Seigo Nonaka
41054af158 Merge "Introduce FontCollection::hasVariationSelector method." 2015-11-20 05:45:27 +00:00
Seigo Nonaka
fc119c68f5 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
2015-11-19 17:14:59 +09:00
Seigo Nonaka
80d113bcd4 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
2015-11-19 17:01:46 +09:00
Raph Levien
3578ca0ccf Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE am: 30fca219e0 -s ours am: 43772d6ef2 -s ours
am: 13c1203c9d  -s ours

* commit '13c1203c9dc7ba3c8b3e6b43f816dd65be8d5355':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-19 05:46:01 +00:00
Raph Levien
0b5eefc1a0 Accept variation selector in emoji sequences - DO NOT MERGE am: 35e4ebec36 -s ours am: 562d243a71 -s ours
am: 805f849a35  -s ours

* commit '805f849a35eb82f83e2e31ee778fab5af9ec761c':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-11-19 05:45:59 +00:00
Raph Levien
13c1203c9d Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE am: 30fca219e0 -s ours
am: 43772d6ef2  -s ours

* commit '43772d6ef2e41cdd46a53a035dfab0407788c031':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-18 19:59:22 +00:00
Raph Levien
805f849a35 Accept variation selector in emoji sequences - DO NOT MERGE am: 35e4ebec36 -s ours
am: 562d243a71  -s ours

* commit '562d243a7149591f59e3b9306dafccd1cbe5dda4':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-11-18 19:59:17 +00:00
Raph Levien
43772d6ef2 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
am: 30fca219e0  -s ours

* commit '30fca219e07ba1059c5a782781c9c5f73e126bb6':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-18 19:52:27 +00:00
Raph Levien
562d243a71 Accept variation selector in emoji sequences - DO NOT MERGE
am: 35e4ebec36  -s ours

* commit '35e4ebec362b159b39dea1537c545418d57ea43c':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-11-18 19:52:21 +00:00
Raph Levien
30fca219e0 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
Due to the way emoji ZWJ sequences are defined, the ICU line breaking
algorithm determines that there are valid line breaks inside the
sequence. This patch suppresses these line breaks.

Bug: 25433289
Change-Id: I225ebebc0f4186e4b8f48fee399c4a62b3f0218a
2015-11-18 10:41:09 -08:00
Raph Levien
35e4ebec36 Accept variation selector in emoji sequences - DO NOT MERGE
This patch basically ignores variation selectors for the purpose of
itemization into font runs. This allows GSUB to be applied when input
sequences contain variation selectors.

Bug: 25368653
Change-Id: I9c1d325ae0cd322c21b7e850d0ec4d73551b2372
2015-11-18 10:41:03 -08:00
Seigo Nonaka
3dd8757fcf 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
2015-11-13 14:39:06 +09:00
Raph Levien
bdd5ccf0e8 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
am: c65e6f1ee0  -s ours

* commit 'c65e6f1ee0b2f32183766726ac459188b1a37b35':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-04 00:34:13 +00:00
Raph Levien
c65e6f1ee0 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
Due to the way emoji ZWJ sequences are defined, the ICU line breaking
algorithm determines that there are valid line breaks inside the
sequence. This patch suppresses these line breaks.

Bug: 25433289
Change-Id: I225ebebc0f4186e4b8f48fee399c4a62b3f0218a
2015-11-03 05:16:31 +00:00
Raph Levien
39b51624ae Accept variation selector in emoji sequences - DO NOT MERGE
am: adaf42f0d3  -s ours

* commit 'adaf42f0d3444de2b0bb977ccc94801458497f46':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-10-29 21:42:01 +00:00
Raph Levien
adaf42f0d3 Accept variation selector in emoji sequences - DO NOT MERGE
This patch basically ignores variation selectors for the purpose of
itemization into font runs. This allows GSUB to be applied when input
sequences contain variation selectors.

Bug: 25368653
Change-Id: I9c1d325ae0cd322c21b7e850d0ec4d73551b2372
2015-10-29 12:30:57 -07:00
Seigo Nonaka
bae3476829 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
2015-10-28 04:52:49 +00:00
Bart Sears
b4c7991804 Revert "Add -Werror -Wall -Wextra to compiler option."
This reverts commit 63635cff5861dcaed963c7332eecf51b9d7d920a.

Change-Id: I2b4b10e8afedc85dbe2d07f3e47315652b65cd14
2015-10-28 03:16:55 +00:00
Seigo Nonaka
63635cff58 Add -Werror -Wall -Wextra to compiler option.
- To suppress noisy unused parameter warnings, comment out unused
  arguments.
- Add -Werror for suppressing further warning.
- Add -Wall -Wextra for safety.

Change-Id: I30a0914a4633bd93eb60957cdf378770f04d8428
2015-10-27 21:18:22 +09:00
Roozbeh Pournader
4b723bf22b Basic scaffolding for handling a language list.
The behavior hasn't changed much yet: all languages are ignored for
rendering text, except the very first supported language.

Change-Id: I1695fb985927ae5e28e4f59c1b531e4993af8688
2015-10-22 14:01:50 -07:00
Seigo Nonaka
16da66db74 Merge "Support Variation Selector in font selection." 2015-10-20 03:47:03 +00:00
Seigo Nonaka
bbdd73ec07 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
2015-10-20 12:34:40 +09:00
Seigo Nonaka
82ceb82fe1 Merge "Remove MinikinFont::GetGlyph interface." 2015-10-19 04:07:45 +00:00
Roozbeh Pournader
786eac9c7f am e8264e06: (-s ours) Complete half-done cherry-picking of Android.mk. DO NOT MERGE
* commit 'e8264e065f0edd58a9fa04bbdd777f2af2794789':
  Complete half-done cherry-picking of Android.mk. DO NOT MERGE
2015-10-15 03:21:50 +00:00
Seigo Nonaka
210dfa01db Remove MinikinFont::GetGlyph interface.
MinikinFont:GetGlyph is no longer used.
No behavior chnages are expected with this CL.

Change-Id: I13398503841ac06f930b04815017d4b33338efa1
2015-10-15 02:54:18 +00:00
Roozbeh Pournader
e8264e065f Complete half-done cherry-picking of Android.mk. DO NOT MERGE
The previous commit, 6e2cccdc518f8d3424c84ae6fbe0e87ae3c3f66a, was
incompletely cherry-picked. This adds the missing parts.

Bug: 24570591
Change-Id: I1097c60587fb8a88cfe6b8ffed5b1689d9bdd429
2015-10-14 19:37:47 -07:00
Raph Levien
8925a8c30a am e5e7aa0e: Explicitly set utf-8 encoding for hyb file verification
* commit 'e5e7aa0e8031f6f1c0ed370f70e49778f3570527':
  Explicitly set utf-8 encoding for hyb file verification
2015-10-15 01:56:15 +00:00
Raph Levien
ed833cff3b am 6e2cccdc: (-s ours) Binary format for hyphenation patterns
* commit '6e2cccdc518f8d3424c84ae6fbe0e87ae3c3f66a':
  Binary format for hyphenation patterns
2015-10-15 01:56:14 +00:00
Raph Levien
e5e7aa0e80 Explicitly set utf-8 encoding for hyb file verification
Not all platforms default to UTF-8 encoding, so we set it explicitly.
This patch should fix build breakages resulting from failed verification
of binary hyb files for hyphenation patterns.

Bug: 24570591
Change-Id: I65ac4536d3436586c2633e2b57554fc6ff16d3a8
(cherry picked from commit 138b93f094584212dd6978a1822d078f93574022)
2015-10-14 16:32:17 -07:00
Raph Levien
6e2cccdc51 Binary format for hyphenation patterns
In the current state, hyphenation in all languages than Sanskrit seems
to work (case-folding edge cases). Thus, we just disable Sanskrit.
Packed tries are implemented, but not the finite state machine
(space/speed tradeoff).

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

Bug: 21562869
Bug: 21826930
Bug: 23317038
Bug: 23317904
Bug: 24570591
Change-Id: I7479a565a4a062fa319651c2c14c0fa18c5ceaea
(cherry picked from commit f0be43de02a1e07308d3d95408349c3c7f973430)
2015-10-14 16:26:37 -07:00
Seigo Nonaka
0f2a025d13 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
2015-10-12 18:53:45 +09:00
Keisuke Kuroyanagi
7c8ac67a90 Merge "Refactoring: Introduce helper class to iterate runs." 2015-10-01 20:11:50 +00:00
Raph Levien
741694870a Merge "Explicitly set utf-8 encoding for hyb file verification" 2015-10-01 06:36:47 +00:00
Raph Levien
138b93f094 Explicitly set utf-8 encoding for hyb file verification
Not all platforms default to UTF-8 encoding, so we set it explicitly.
This patch should fix build breakages resulting from failed verification
of binary hyb files for hyphenation patterns.

Change-Id: I65ac4536d3436586c2633e2b57554fc6ff16d3a8
2015-09-30 23:26:54 -07:00
Raph Levien
6ac8ca4ce7 Merge "Binary format for hyphenation patterns" 2015-10-01 04:53:44 +00:00
Raph Levien
f0be43de02 Binary format for hyphenation patterns
In the current state, hyphenation in all languages than Sanskrit seems
to work (case-folding edge cases). Thus, we just disable Sanskrit.
Packed tries are implemented, but not the finite state machine
(space/speed tradeoff).

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

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

Change-Id: I7479a565a4a062fa319651c2c14c0fa18c5ceaea
2015-09-30 21:37:31 -07:00