Commit Graph

600 Commits

Author SHA1 Message Date
Raph Levien
e275a0a2bd Avoid integer overflows in parsing fonts am: 1fd1c39021 am: fa84e49423
am: 47e7a9b486

* commit '47e7a9b48626fcc5d15f18994f0382c7b490fd9b':
  Avoid integer overflows in parsing fonts
2015-12-08 11:29:31 -08:00
Raph Levien
47e7a9b486 Avoid integer overflows in parsing fonts am: 1fd1c39021
am: fa84e49423

* commit 'fa84e494232565cf5141bfb6736652fca6c710c2':
  Avoid integer overflows in parsing fonts
2015-12-08 19:22:49 +00:00
Raph Levien
fa84e49423 Avoid integer overflows in parsing fonts
am: 1fd1c39021

* commit '1fd1c390217da22a54b49e9a91bc79b0323e6a73':
  Avoid integer overflows in parsing fonts
2015-12-08 19:17:40 +00:00
Seigo Nonaka
c047506ec2 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
1fd1c39021 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 371e5dbb3f)
2015-12-07 17:58:12 +00:00
Raph Levien
371e5dbb3f 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
ff9d1a5484 Merge "Search all families instead of using mRanges for variation sequence." 2015-11-20 05:46:31 +00:00
Seigo Nonaka
abdea9d96d Merge "Introduce FontCollection::hasVariationSelector method." 2015-11-20 05:45:27 +00:00
Seigo Nonaka
3700f23508 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
77476fc5b9 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
abbb307682 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE am: d40c0c59e4 -s ours am: 3871933e15 -s ours
am: 7aee6297e4  -s ours

* commit '7aee6297e42d6da44babd3c78f41247f54e117f3':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-19 05:46:01 +00:00
Raph Levien
41fc0db12e Accept variation selector in emoji sequences - DO NOT MERGE am: 6e98debfaf -s ours am: 29af616a2b -s ours
am: 16698c880e  -s ours

* commit '16698c880e3edebb58deaefe05ee536607256e77':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-11-19 05:45:59 +00:00
Raph Levien
7aee6297e4 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE am: d40c0c59e4 -s ours
am: 3871933e15  -s ours

* commit '3871933e1542292598e2ffdb88ac770342093d63':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-18 19:59:22 +00:00
Raph Levien
d86eba7db1 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE am: d40c0c59e4 -s ours
am: 3871933e15  -s ours

* commit '3871933e1542292598e2ffdb88ac770342093d63':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-18 19:59:21 +00:00
Raph Levien
16698c880e Accept variation selector in emoji sequences - DO NOT MERGE am: 6e98debfaf -s ours
am: 29af616a2b  -s ours

* commit '29af616a2b4b07cfd2cb6b02c9d887b665a82a3f':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-11-18 19:59:17 +00:00
Raph Levien
3871933e15 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
am: d40c0c59e4  -s ours

* commit 'd40c0c59e446196c0beff54968913205f7f6fe28':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-18 19:52:27 +00:00
Raph Levien
29af616a2b Accept variation selector in emoji sequences - DO NOT MERGE
am: 6e98debfaf  -s ours

* commit '6e98debfaf50ad0d301fef2d2b656ba175b2e02c':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-11-18 19:52:21 +00:00
Raph Levien
d40c0c59e4 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
6e98debfaf 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
40ffbdf94c 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
0f4a9f1687 Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
am: 5001f2ae48  -s ours

* commit '5001f2ae481c3b77ffcb2b64803cc9e96e5cfeb9':
  Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGE
2015-11-04 00:34:13 +00:00
Raph Levien
5001f2ae48 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
03cf082e80 Accept variation selector in emoji sequences - DO NOT MERGE
am: 34c39bcde6  -s ours

* commit '34c39bcde69c8505fd72c460ee601dff1ad4c8c9':
  Accept variation selector in emoji sequences - DO NOT MERGE
2015-10-29 21:42:01 +00:00
Raph Levien
34c39bcde6 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
ac88812115 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
07c8ad2b85 Revert "Add -Werror -Wall -Wextra to compiler option."
This reverts commit a816dfb3fa.

Change-Id: I2b4b10e8afedc85dbe2d07f3e47315652b65cd14
2015-10-28 03:16:55 +00:00
Seigo Nonaka
a816dfb3fa 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
9a4c3535be 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
0eb96541f6 Merge "Support Variation Selector in font selection." 2015-10-20 03:47:03 +00:00
Seigo Nonaka
2a099196e6 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
1bbd2a00f7 Merge "Remove MinikinFont::GetGlyph interface." 2015-10-19 04:07:45 +00:00
Roozbeh Pournader
471f461e48 am 4f26d114: (-s ours) Complete half-done cherry-picking of Android.mk. DO NOT MERGE
* commit '4f26d114368939d06989de1e54c65227fdbfa843':
  Complete half-done cherry-picking of Android.mk. DO NOT MERGE
2015-10-15 03:21:50 +00:00
Seigo Nonaka
aaec3837bf 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
4f26d11436 Complete half-done cherry-picking of Android.mk. DO NOT MERGE
The previous commit, 9036c194b0, was
incompletely cherry-picked. This adds the missing parts.

Bug: 24570591
Change-Id: I1097c60587fb8a88cfe6b8ffed5b1689d9bdd429
2015-10-14 19:37:47 -07:00
Raph Levien
c850371b5c am 7635ac13: Explicitly set utf-8 encoding for hyb file verification
* commit '7635ac1324ebe58f21adc904185f446cec11a97d':
  Explicitly set utf-8 encoding for hyb file verification
2015-10-15 01:56:15 +00:00
Raph Levien
c44bae6483 am 9036c194: (-s ours) Binary format for hyphenation patterns
* commit '9036c194b04f921f35a7b7c064f88bba565c63b3':
  Binary format for hyphenation patterns
2015-10-15 01:56:14 +00:00
Raph Levien
7635ac1324 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 179d763488)
2015-10-14 16:32:17 -07:00
Raph Levien
9036c194b0 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 96df754284)
2015-10-14 16:26:37 -07:00
Seigo Nonaka
ad9cb5909a 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
89e185c3a8 Merge "Refactoring: Introduce helper class to iterate runs." 2015-10-01 20:11:50 +00:00
Raph Levien
af68d9ae49 Merge "Explicitly set utf-8 encoding for hyb file verification" 2015-10-01 06:36:47 +00:00
Raph Levien
179d763488 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
d277bd3287 Merge "Binary format for hyphenation patterns" 2015-10-01 04:53:44 +00:00
Raph Levien
96df754284 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
Seigo Nonaka
52dfb07bde Extract hb_face_t object cache mechanism from Layout.cpp.
This CL does following things:
- Extract hb_face_t object cache mechanism from Layout.cpp to be able to
  use it from other cpp file, especially from FontFamily.cpp.
  To address Bug 11256006 and Bug 17759267, need to touch
  hb_face_t from FontFamily.
- Make hb_face_t cache mechanism thread-safe.
- Add unit tests for HbFaceCache test cases.

Bug: 11256006
Bug: 17759267
Change-Id: Ic183634ef34326793bd9a32167236611d0af34d6
2015-09-30 17:36:44 +09:00
Seigo Nonaka
0bf06e0c74 Merge "Introduce unit tests for FontCollection::itemize." 2015-09-30 03:33:13 +00:00
Keisuke Kuroyanagi
f6aa09df27 Refactoring: Introduce helper class to iterate runs.
This doesn't change current behavior. It's a preparation
for the following CLs.

Bug: 22408712
Change-Id: Ic018422254aa3904655f499194caad74f0c0fc5d
2015-09-29 16:05:15 -07:00
Seigo Nonaka
5debe07231 Introduce unit tests for FontCollection::itemize.
Introduced tests depend on installed font list in running device.
I verified these test passed  on Nexus 5(hammerhead), Nexus 6(shamu)
and Nexus 9(volantis).

Bug: 11256006
Bug: 17759267
Change-Id: I6f806370e17f6c6d3dad8df0cb70bb475a827873
2015-09-18 15:40:51 +09:00
Seigo Nonaka
0345da636e Resolve glyph ID by HarfBuzz function.
Currently codepoint to glyph ID resolution is done through MinikinFont
interface. To support variation selector, use HarfBuzz API instead of
calling this interface since one of its implementation Skia doesn't
support variation selector.

On the other hand, we don't want to get glyph horizontal advance values
by HarfBuzz since HarfBuzz doesn't return correct values when the hinting
is active.

Thus, use ot_font as a parent font and override
glyph_h_advance/glyph_h_origin functions as is.

With this change, MinikinFont::GetGlyph is no longer necessary but not
removing in this CL for easy reverting since removing interface requires
multi-repository commit.

This is a base work of b/11256006 and this patch doesn't provide any
user visible changes.

Bug: 11256006
Change-Id: I061172c0b674bb649ce8bc013ffecf38708bdc41
2015-09-11 16:44:37 +09:00
Seigo Nonaka
f09cf789ef Update word breaker to be aware tone mark and variation selector.
This CL does:
1. Move the getNextWordBreak/getPrevWordBreak function to a separate source file.
2. Adding "ForCache" suffix for function name for making clear these function is
   for layout cache.
3. Introduce unit tests for them.

Bug: 11256006
Change-Id: I4138751a4570915f1a0d6c8921f89700f8ec7f35
2015-08-29 08:02:44 +09:00