294 Commits

Author SHA1 Message Date
Raph Levien
879e8a3a47 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
Raph Levien
9afcc6e2bd 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
f3afe92def 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
16ed4ef07e 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
d8917c69a9 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
cee83d4032 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
450e96c817 Break regional indicators at even numbered code points.
Bug: 23288449
Change-Id: If1419ff9e44e8e640616979bae88311f414b42a1
2016-03-02 17:44:14 -08:00
Raph Levien
1934c2c3cb 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
56840e8006 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
0036da164e 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
94d5525508 Merge "Suppress grapheme cluster breaks in emoji with modifiers" into nyc-dev 2016-02-24 20:58:55 +00:00
Raph Levien
adfa580f1f 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
dbf5c2776b Merge "Support Hanb script." into nyc-dev 2016-02-23 03:57:58 +00:00
Raph Levien
30bf8a7c05 Merge "Suppress linebreaks in emoji ZWJ sequences" into nyc-dev 2016-02-19 17:53:48 +00:00
Raph Levien
d3f45892c7 Suppress linebreaks in emoji ZWJ sequences
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.

This is an adaptation of I225ebebc0f4186e4b8f48fee399c4a62b3f0218a
into the nyc-dev branch.

Bug: 25433289
Change-Id: I84b50b1e6ef13d436965eab389659d02a30d100f
2016-02-18 15:00:24 -08:00
Keisuke Kuroyanagi
ea408fc18e Optimize: Use measureText instead of doLayout.
With this CL, measureText is used for getRunAdvance,
getOffsetForAdvance and line breaking.

Bug: 24505153
Change-Id: Ib699f6b1391b46537736fc274cdb41686586b550
2016-02-18 11:46:48 -08:00
Raph Levien
aa736d0054 Disable hyphenation when word overlaps style boundary
In cases when a word (as defined by the ICU break iterator) overlaps a
style boundary, the returned wordStart can be extend before the range
currently being measured for layout. When we try to hyphenate the
resulting substrings, we get a negative range, which crashes. This
patch disables hyphenation in this case.

Bug: 27237112
Change-Id: I76d04b39dd3b4d6d267aaaf4bebc9ab361891646
2016-02-18 10:33:14 -08:00
Seigo Nonaka
533a01ea84 Support Hanb script.
Hanb is a union of Han and Bopomofo.

Bug: 26687969
Change-Id: Ic696bcbbc9607f3842fd0115668b8e7bd917e62b
2016-02-18 18:28:52 +09:00
Seigo Nonaka
bcb024df56 Merge "Improve Paint.measureText and Paint.hasGlyph for variation sequences." into nyc-dev 2016-02-18 04:33:36 +00:00
Raph Levien
7f9834ae33 Add error logging on invalid cmap - DO NOT MERGE am: 48e5307447 am: d60a48cc7d -s ours am: 4741030f4a am: c279266595 -s ours am: c2f0c7a862 am: cb14adf02d
am: 00e9a7cd08  -s ours

* commit '00e9a7cd08adf53609e1a206a984153aada969b9':
  Add error logging on invalid cmap - DO NOT MERGE
2016-02-18 00:19:02 +00:00
Raph Levien
00e9a7cd08 Add error logging on invalid cmap - DO NOT MERGE am: 48e5307447 am: d60a48cc7d -s ours am: 4741030f4a am: c279266595 -s ours am: c2f0c7a862
am: cb14adf02d

* commit 'cb14adf02d49dc8de66fca882aadcc3682cf6972':
  Add error logging on invalid cmap - DO NOT MERGE
2016-02-18 00:13:35 +00:00
Raph Levien
cb14adf02d Add error logging on invalid cmap - DO NOT MERGE am: 48e5307447 am: d60a48cc7d -s ours am: 4741030f4a am: c279266595 -s ours
am: c2f0c7a862

* commit 'c2f0c7a862e124c4e693040530d0c8a9e1265c57':
  Add error logging on invalid cmap - DO NOT MERGE
2016-02-18 00:04:40 +00:00
Raph Levien
c2f0c7a862 Add error logging on invalid cmap - DO NOT MERGE am: 48e5307447 am: d60a48cc7d -s ours am: 4741030f4a
am: c279266595  -s ours

* commit 'c2792665954d796eb6fc67b5efb1c6bc0809485b':
  Add error logging on invalid cmap - DO NOT MERGE
2016-02-17 23:59:33 +00:00
Raph Levien
2f0604dce2 Add error logging on invalid cmap am: 734f037130 am: c91a77cf22
am: c3433aca7a

* commit 'c3433aca7acac7f642ba0dcc07429027d0453348':
  Add error logging on invalid cmap
2016-02-17 23:55:18 +00:00
Raph Levien
c279266595 Add error logging on invalid cmap - DO NOT MERGE am: 48e5307447 am: d60a48cc7d -s ours
am: 4741030f4a

* commit '4741030f4a416258106f6b489196c2ce632a83e0':
  Add error logging on invalid cmap - DO NOT MERGE
2016-02-17 23:55:07 +00:00
Raph Levien
c3433aca7a Add error logging on invalid cmap am: 734f037130
am: c91a77cf22

* commit 'c91a77cf2236f8806b503a14adbbc19828f7bc89':
  Add error logging on invalid cmap
2016-02-17 23:51:06 +00:00
Raph Levien
4741030f4a Add error logging on invalid cmap - DO NOT MERGE am: 48e5307447
am: d60a48cc7d  -s ours

* commit 'd60a48cc7d8913ab6f05fbc5e5a43b9529df6ade':
  Add error logging on invalid cmap - DO NOT MERGE
2016-02-17 23:47:10 +00:00
Raph Levien
c91a77cf22 Add error logging on invalid cmap
am: 734f037130

* commit '734f037130e14b3d44bc74026d3d065c025a8280':
  Add error logging on invalid cmap
2016-02-17 23:43:34 +00:00
Raph Levien
d60a48cc7d Add error logging on invalid cmap - DO NOT MERGE
am: 48e5307447

* commit '48e5307447bbdeb8c190211ec11801968cb0363e':
  Add error logging on invalid cmap - DO NOT MERGE
2016-02-17 23:43:26 +00:00
Raph Levien
c88ef135fc Add penalty for breaks in URLs and email addresses
Recent changes have added special cases for line breaks within URLs
and email addresses. Such breaks are undesirable when they can be
avoided, but at other times are needed to avoid huge gaps, or indeed
to make the line fit at all.

This patch assigns a penalty for such breaks, equal to the hyphenation
penalty. The mechanism is currently very simple, but would be easy to
fine-tune based on more detailed information about break quality.

Bug: 20126487
Bug: 20566159
Change-Id: I0d3323897737a2850f1e734fa17b96b065eabd9c
2016-02-17 23:13:44 +00:00
Raph Levien
6d15657e4a Add line breaks to email addresses and URLs
This change adds accceptable line breaks according to sections 7.42
(Dividing URLs and e-mail addresses) and 14.12 (URLs or DOIs and line
breaks) of the Chicago Manual of Style (16th ed.). In general, these
place breaks before punctuation symbols, and suppresses them after
hyphens.

Bug: 20126487
Bug: 20566159
Change-Id: I2d07d516b920a506a2f718c38fb435c5eb1ee1f8
2016-02-17 23:12:48 +00:00
Raph Levien
9c4cc648ab Special-case URLs and email addresses for line breaking
Detect URLs and email addresses, and suppress both line breaking and
hyphenation within them.

Bug: 20126487
Bug: 20566159

Change-Id: I43629347a063dcf579e355e5b678d7195f453ad9
2016-02-17 23:11:46 +00:00
Seigo Nonaka
6b1c227da6 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
2016-02-17 16:01:20 +09:00
Raph Levien
57b6dae989 Refine hyphenation around punctuation
Implement a WordBreaker that defines our concept of valid word
boundaries, customizing the ICU behavior. Currently, we suppress line
breaks at soft hyphens (these are handled specially). Also, the
new WordBreaker class has methods that determine the start and end
of the word (punctuation stripped) for the purpose of hyphenation.

This patch, in its current form, doesn't handle email addresses and
URLs specially, but the WordBreaker class is the correct place to do
so. Also, special case handling of hyphens and dashes is still done
in LineBreaker, but all of that should be moved to WordBreaker.

Bug: 20126487
Bug: 20566159
Change-Id: I492cbad963f9b74a2915f010dad46bb91f97b2fe
2016-02-16 22:05:07 -08:00
Raph Levien
48e5307447 Add error logging on invalid cmap - DO NOT MERGE
This patch logs instances of fonts with invalid cmap tables.

Bug: 25645298
Bug: 26413177
Change-Id: I183985e9784a97a2b4307a22e036382b1fc90e5e
2016-02-12 17:09:01 +00:00
Raph Levien
734f037130 Add error logging on invalid cmap
This patch logs instances of fonts with invalid cmap tables.

Bug: 25645298
Bug: 26413177
Change-Id: I183985e9784a97a2b4307a22e036382b1fc90e5e
2016-02-12 17:07:38 +00:00
Aurimas Liutikas
070633ad65 Fix two "unused parameter" warnings in minikin sample.
Removing variables in main function of sample/example.cpp as
they are not used.

Bug: 26936282
Change-Id: I64ae0a455b413df333ddd4810a9e090d52322041
2016-02-12 00:40:29 +00:00
Keisuke Kuroyanagi
9d48271c04 Optimize: Precompute the hash value for LayoutCacheKey.
Bug: 24505153
Change-Id: If61c063c175086dec88cda187eafd9ce923e4cb1
2016-02-08 06:56:56 +00:00
Seigo Nonaka
89e80237bc 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
2016-02-04 12:26:10 +09:00
Stephen Hines
e5f01d0e95 Disable unsigned integer overflow sanitization until libc++ is fixed. am: 4553fa41c3
am: 3d15532afc

* commit '3d15532afc73f2286b83f5c1b027b5d31feb1294':
  Disable unsigned integer overflow sanitization until libc++ is fixed.
2016-01-26 14:35:15 +00:00
Stephen Hines
3d15532afc Disable unsigned integer overflow sanitization until libc++ is fixed.
am: 4553fa41c3

* commit '4553fa41c3f031e0fb3395d57018272d59869afa':
  Disable unsigned integer overflow sanitization until libc++ is fixed.
2016-01-26 14:33:16 +00:00
Stephen Hines
4553fa41c3 Disable unsigned integer overflow sanitization until libc++ is fixed.
Bug: http://b/26781196
Bug: http://b/25884483
Bug: http://b/26432628

Although this issue was first only manifesting on Fugu, it now affects
N9 and N6p as well. This change disables unsigned overflow sanitization
on all platforms. The real fix for libc++ (r257368) can't be committed
until we have updated Clang at least one more time.

Change-Id: I71e9c50d25ae4566d4c06f348183c4b22a4bb60a
2016-01-26 00:49:26 -08:00
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