Commit Graph

275 Commits

Author SHA1 Message Date
Raph Levien
0f7db07b2d Add error logging on invalid cmap am: 9e8fd1dff7 am: 78bf54cc23 am: 83f28ad6b6
am: 960c6bd18b

* commit '960c6bd18b30accc4c18a468d42e31edcfde3da6':
  Add error logging on invalid cmap
2016-02-18 00:17:26 +00:00
Raph Levien
88645a5b0f Add penalty for breaks in URLs and email addresses
am: 76772e8ad4

* commit '76772e8ad4a88cbe87edc873dd66af7d0baf6a25':
  Add penalty for breaks in URLs and email addresses
2016-02-18 00:17:18 +00:00
Raph Levien
960c6bd18b Add error logging on invalid cmap am: 9e8fd1dff7 am: 78bf54cc23
am: 83f28ad6b6

* commit '83f28ad6b687d09fb14c5f76673376962cd563cd':
  Add error logging on invalid cmap
2016-02-17 23:55:18 +00:00
Raph Levien
83f28ad6b6 Add error logging on invalid cmap am: 9e8fd1dff7
am: 78bf54cc23

* commit '78bf54cc23fd7752302e9e39cc6fbc7346f6f939':
  Add error logging on invalid cmap
2016-02-17 23:51:06 +00:00
Raph Levien
78bf54cc23 Add error logging on invalid cmap
am: 9e8fd1dff7

* commit '9e8fd1dff74e2c696d3fd7a2873d982bcb0b06cd':
  Add error logging on invalid cmap
2016-02-17 23:43:34 +00:00
Raph Levien
90118a90f5 Add line breaks to email addresses and URLs
am: 5102c20dd5

* commit '5102c20dd50fde7ab9cdcdce173f53a6cacbd9e0':
  Add line breaks to email addresses and URLs
2016-02-17 23:42:21 +00:00
Raph Levien
084923f611 Special-case URLs and email addresses for line breaking
am: 76022a08e3

* commit '76022a08e3f01db804d97c10277ee2704ef68f45':
  Special-case URLs and email addresses for line breaking
2016-02-17 23:42:08 +00:00
Raph Levien
806dd8f792 Refine hyphenation around punctuation
am: c3b16d8894

* commit 'c3b16d88941b337c2b0b861daf610bf9ca80f908':
  Refine hyphenation around punctuation
2016-02-17 23:41:55 +00:00
Raph Levien
76772e8ad4 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
5102c20dd5 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
76022a08e3 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
Bill Yi
7e4f21a4e3 Merge commit \'408d44a0834d88a9ed4060dbeb8223fcd321f5d0\' into HEAD
am: d166b937e4

* commit 'd166b937e4aafc61e00a59101e38f628d19e1505':
2016-02-17 20:47:59 +00:00
Bill Yi
d166b937e4 Merge commit '408d44a0834d88a9ed4060dbeb8223fcd321f5d0' into HEAD 2016-02-17 09:50:45 -08:00
Raph Levien
c3b16d8894 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
Dan Albert
24e3abaf1e Fix warnings.
am: 09481597e4  -s ours

* commit '09481597e453ab3ce4fd4a1b4533ff2a2c5dd23a':
  Fix warnings.
2016-02-12 20:40:00 +00:00
Raph Levien
9e8fd1dff7 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
Dan Albert
09481597e4 Fix warnings.
Bug: http://b/26936282
Change-Id: I91b3bc246a4a8c45bde223cfc25df18ae9af8c5b
2016-02-11 20:40:58 -08:00
Aurimas Liutikas
aa48a65766 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
380658778e Optimize: Precompute the hash value for LayoutCacheKey.
Bug: 24505153
Change-Id: If61c063c175086dec88cda187eafd9ce923e4cb1
2016-02-08 06:56:56 +00:00
Seigo Nonaka
109b667554 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
e7f39cb730 Disable unsigned integer overflow sanitization until libc++ is fixed. am: 900a7c36fb
am: 711e2e5d39

* commit '711e2e5d39e4db68803407262b4af6ad3e104c9d':
  Disable unsigned integer overflow sanitization until libc++ is fixed.
2016-01-26 14:35:15 +00:00
Stephen Hines
711e2e5d39 Disable unsigned integer overflow sanitization until libc++ is fixed.
am: 900a7c36fb

* commit '900a7c36fb2953605bae61a70fb508d0f8fe515c':
  Disable unsigned integer overflow sanitization until libc++ is fixed.
2016-01-26 14:33:16 +00:00
Stephen Hines
900a7c36fb 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
84b080abc5 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
d34c46ee7d Reject fonts with invalid ranges in cmap am: f5d2fa97bb am: 8d10d3a0f9 am: 97ef1a4890 am: 0d004fc9b6 am: 5936f34f86 am: f76c8acaf6 am: 95a63d665b -s ours
am: 408d44a083  -s ours

* commit '408d44a0834d88a9ed4060dbeb8223fcd321f5d0':
  Reject fonts with invalid ranges in cmap
2016-01-15 22:22:10 +00:00
Raph Levien
408d44a083 Reject fonts with invalid ranges in cmap am: f5d2fa97bb am: 8d10d3a0f9 am: 97ef1a4890 am: 0d004fc9b6 am: 5936f34f86 am: f76c8acaf6
am: 95a63d665b  -s ours

* commit '95a63d665b622d4e7002b1c09603a0d50f0b8947':
  Reject fonts with invalid ranges in cmap
2016-01-15 22:11:58 +00:00
Raph Levien
95a63d665b Reject fonts with invalid ranges in cmap am: f5d2fa97bb am: 8d10d3a0f9 am: 97ef1a4890 am: 0d004fc9b6 am: 5936f34f86
am: f76c8acaf6

* commit 'f76c8acaf67dc263dddc9f9691f6e87d2450c013':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:50:24 +00:00
Raph Levien
f76c8acaf6 Reject fonts with invalid ranges in cmap am: f5d2fa97bb am: 8d10d3a0f9 am: 97ef1a4890 am: 0d004fc9b6
am: 5936f34f86

* commit '5936f34f8604542b6ab2714195c69456974e2590':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:45:37 +00:00
Raph Levien
5936f34f86 Reject fonts with invalid ranges in cmap am: f5d2fa97bb am: 8d10d3a0f9 am: 97ef1a4890
am: 0d004fc9b6

* commit '0d004fc9b6e9f438ba67a0188e1072247a7618a9':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:43:03 +00:00
Raph Levien
0d004fc9b6 Reject fonts with invalid ranges in cmap am: f5d2fa97bb am: 8d10d3a0f9
am: 97ef1a4890

* commit '97ef1a4890fddf0945f06c644a8a27bf834df3f1':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:40:23 +00:00
Raph Levien
97ef1a4890 Reject fonts with invalid ranges in cmap am: f5d2fa97bb
am: 8d10d3a0f9

* commit '8d10d3a0f9d87d90839da17e20a1812aaaa1e754':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:36:37 +00:00
Raph Levien
8d10d3a0f9 Reject fonts with invalid ranges in cmap
am: f5d2fa97bb

* commit 'f5d2fa97bbdbf5075e293fb641cd2e5dbaa29cfa':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:28:10 +00:00
Seigo Nonaka
6cefe2eab1 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
416a652c93 Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE am: c4e24421ec
am: 2dd7d8f92e  -s ours

* commit '2dd7d8f92e6e40abbc2ed643adce0fba15d9d584':
  Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE
2016-01-13 23:52:06 +00:00
Raph Levien
2dd7d8f92e Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE
am: c4e24421ec

* commit 'c4e24421ecb8b4532bde4e759625107367cd60e3':
  Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGE
2016-01-13 23:17:11 +00:00
Raph Levien
c4e24421ec 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
4760a9f190 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
f5d2fa97bb 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
116708d9a3 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
4bb53ef025 Minikin: Disable sanitizer on x86 am: 251f4772fb
am: 473628753d

* commit '473628753d2187af012f7486723ab9b8ccbbc2b3':
  Minikin: Disable sanitizer on x86
2016-01-07 04:47:52 +00:00
Andreas Gampe
473628753d Minikin: Disable sanitizer on x86
am: 251f4772fb

* commit '251f4772fb6996b5b8555fa94dd67f97a0377650':
  Minikin: Disable sanitizer on x86
2016-01-07 04:45:20 +00:00
Andreas Gampe
251f4772fb 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
410f1e69a7 Merge "Fix lock assertion failures in unit test." 2016-01-07 03:14:25 +00:00
Dan Austin
c3a7ec8af1 Enable integer sanitization in libminikin am: da13d5e835
am: 7521326d4f

* commit '7521326d4fcd3bfda5aaa02a2b54122cce6fcadd':
  Enable integer sanitization in libminikin
2016-01-06 20:44:58 +00:00
Dan Austin
7521326d4f Enable integer sanitization in libminikin
am: da13d5e835

* commit 'da13d5e835bf4657246e2410dcf29c0b4a61887b':
  Enable integer sanitization in libminikin
2016-01-06 20:42:47 +00:00
Dan Austin
da13d5e835 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
1854e6c2df Revert "Enable integer sanitization in libminikin." am: 2ffc286102
am: 8c5fc9931f

* commit '8c5fc9931fec0ccaff1181ff82f4965236f17036':
  Revert "Enable integer sanitization in libminikin."
2016-01-06 18:38:18 +00:00
Dan Austin
8c5fc9931f Revert "Enable integer sanitization in libminikin."
am: 2ffc286102

* commit '2ffc28610290d221109105ba17969db83b317ca1':
  Revert "Enable integer sanitization in libminikin."
2016-01-06 18:36:33 +00:00
Dan Austin
2ffc286102 Revert "Enable integer sanitization in libminikin."
This reverts commit 147ce0acb9.

Change-Id: Iecd1f61a5fdf5955d871a920cb243553857d46ff
2016-01-06 18:31:38 +00:00
Dan Austin
1d362de4cc Enable integer sanitization in libminikin. am: 147ce0acb9
am: ea647a237d

* commit 'ea647a237d8ded834b585f5556b98509e2221ca1':
  Enable integer sanitization in libminikin.
2016-01-06 17:08:33 +00:00