26175 Commits

Author SHA1 Message Date
Behdad Esfahbod
bff381b1be Remove CSS string doLayout entrypoint and supporting code
All usage is ported to the new doLayout() API now.

Bug: 16651112
Change-Id: I2c959138a69853b5e30098889d771fe5f4cfaa66
2014-07-29 15:51:12 -04:00
Behdad Esfahbod
94300c2146 Merge "Don't get stuck on invalid UTF-16" into lmp-dev 2014-07-24 15:37:54 +00:00
Behdad Esfahbod
abf2e7d050 Don't get stuck on invalid UTF-16
Replaces invalid unicode with replacement character U+FFFD and always
makes forward progress.

Bug: 15849380

Change-Id: Ic59ef6c64b0f5c4450bcae61597adcc269d6e7c5
2014-07-25 19:13:10 +00:00
Behdad Esfahbod
675a078bdf Towards CSS removal
Extract language from FontStyle during shaping.  Don't attach CSS
to LayoutContext.

Change-Id: Ie621d3415410178d0d15fa7b810eb8e412342ab6
2014-07-24 20:26:03 -04:00
Behdad Esfahbod
ded72d1e4a Remove deprecated API
It has been unused outside minikin.

Change-Id: Iaa2237767d81c77f90d0264e633375e601dd72f1
2014-07-24 19:18:14 -04:00
Behdad Esfahbod
801eb4ebad Merge "Revert "Don't pass invalid Unicode codepoint to Skia"" 2014-07-24 15:36:21 +00:00
Behdad Esfahbod
ca5b3e1676 Revert "Don't pass invalid Unicode codepoint to Skia"
After update to HarfBuzz 0.9.33 we don't need this anymore.  HarfBuzz takes care of invalid input and passes U+FFFD to us.

This reverts commit 29eb45e667be81d37f29fcce2adccb8c5e6d5ada.

Change-Id: Icfd0dc836a8d684fb1723fc215aa01f99639ff59
2014-07-25 17:31:46 +00:00
Behdad Esfahbod
7043f8f1fc Add letter-spacing support
Bug: 15594400
Change-Id: Ied94d7674be4097b0f44c9b0770d3294dc6433c1
2014-07-22 16:37:53 -04:00
Behdad Esfahbod
29eb45e667 Don't pass invalid Unicode codepoint to Skia
Bug: 15849380
Change-Id: Ib5285e57c5806bd399600fadd56e8bc809da323f
2014-07-11 11:30:06 -04:00
Behdad Esfahbod
264f497c91 Merge "Use __builtin_clzl if element is long" 2014-07-10 21:09:47 +00:00
Behdad Esfahbod
da0c3511e3 Use __builtin_clzl if element is long
Change-Id: I50a112739847fa826088854f6d172a188ff4cfb3
2014-07-10 17:48:37 -04:00
Elliott Hughes
b6138e6653 Switch minikin to the new icu.
Change-Id: I29a59edfe6102257c9f308aac1b4348ef7a18db7
2014-07-10 10:39:07 -07:00
Raph Levien
293208bda8 Assign non-coverage font runs to base font
When a run has no cmap coverage in any font, use the base font. Most of
the time, this will cause rendering of the .notdef glyph, which is
preferable to displaying nothing. In some cases, Harfbuzz may be able to
decompose the characters (not in the cmap) to ones that are, in which
case we'll render those, as long as they're in the base font.

Bug: 6629748
Bug: 15816880
Change-Id: Ibb1b9242c83626e0c7db363ad65ce44a967a005e
2014-07-09 09:18:15 -07:00
Mike Reed
f9490880cc setConfig is deprecated
Change-Id: Iffad3ef724b565d5d8fed17722630fd74cda9234
2014-07-07 10:59:40 -04:00
Raph Levien
05d59ee462 Disable "palt" OpenType feature
Proper Japanese layout requires sophisticated rules for spacing
punctuation, not just turning on the "palt" (proportional alternate)
feature. Until we can support the whole set, roll back palt.

Change-Id: If2359c529b70b1dd45dddc00e5f4aa1c91f8b0e9
2014-06-26 14:34:27 -07:00
Raph Levien
69f3585cf6 Add purgeCaches() method
Expose a method to purge caches used for TextLayout, useful for low
memory conditions.

Change-Id: I92f41afe987b7be4af5ca0a0c50fb51be35a2758
2014-06-25 23:02:52 +00:00
Raph Levien
e8bed5d3cc Implement grapheme cluster breaking
This patch includes an implementation of grapheme cluster breaking,
which is especially useful for repositioning the cursor for left and
right arrow key presses. The implementation is closely based on Unicode
TR29, and uses the ICU grapheme cluster break property, but is tailored
to more closely match the existing implementation and expected behavior.

Part of a fix for b/15653110 Improve behavior of arrow keys in EditText

Change-Id: I8eb742f77039c9ab7b2838285018cf8a8fc88343
2014-06-19 09:49:50 -07:00
Raph Levien
ba5dbb6f24 Make font runs less sticky
Fixes b/15734816 In the text "Wi-Fi", "-Fi" appears bolder than "Wi"

The problem was caused by "stickiness" in choosing fonts, where layout
would prefer using a font used for preceding characters as long as it
mapped the following characters in a run, in favor of the "best match"
rules. This patch adds a whitelist for making the stickiness more
conservative, only applying it for characters necessary for correct
shaping (ZWJ and ZWNJ in particular) and basic punctuation, where it is
desirable to match the style of the preceding text.

Change-Id: I1cf116879f074a5a71c351846707bfdd07b0d320
2014-06-19 09:03:01 -07:00
Raph Levien
01d64756a7 am e88f8c37: Tighten requirements for fake bold
* commit 'e88f8c37c740a317f11d407d48aaacdfdad56395':
  Tighten requirements for fake bold
2014-06-12 22:31:15 +00:00
Raph Levien
1e81203f00 am 1f8de301: (-s ours) Support for fake bold and italics
* commit '1f8de3019ded454358e56a9f0f9b233e372acba8':
  Support for fake bold and italics
2014-06-12 18:07:59 +00:00
Raph Levien
c1b20c0a0c am 1e35d09d: (-s ours) Add baseFont method to FontCollection
* commit '1e35d09df19bbb9bef5c29673106975d96aeb74d':
  Add baseFont method to FontCollection
2014-06-12 18:02:23 +00:00
Raph Levien
e88f8c37c7 Tighten requirements for fake bold
The simple predicate for fake bold (2 or more grades darker than
requested) was applying it to thin (100 weight) when normal was
requested. This patch tightens the predicate to also require that
the requested weight be in the bold range.

Fix for bug 15588352 "sans-serif-thin doesn't work on lockscreen"

Change-Id: Id9988bd149a9c8a7c943e3b221f7fb4b37fb6ddb
(cherry picked from commit 0f8e4702a5aa8c43f3efa3643680dca9f45a1edd)
2014-06-12 16:29:24 +00:00
Raph Levien
3ec74f54ba Merge "Fix missing text on nonexistent font file" 2014-06-11 21:23:31 +00:00
Raph Levien
0f8e4702a5 Tighten requirements for fake bold
The simple predicate for fake bold (2 or more grades darker than
requested) was applying it to thin (100 weight) when normal was
requested. This patch tightens the predicate to also require that
the requested weight be in the bold range.

Fix for bug 15588352 "sans-serif-thin doesn't work on lockscreen"

Change-Id: Id9988bd149a9c8a7c943e3b221f7fb4b37fb6ddb
2014-06-12 09:23:21 -07:00
Raph Levien
43e8943dfd Fix missing text on nonexistent font file
Fix for bug 15570313 "Missing text on nonexistent font file"

This patch makes sure that the lastChar and mInstances arrays are in
sync with each other even when a FontFamily being added has no valid
fonts in it. Previously, when they got out of sync, unicode coverage
calculation would be wrong, resulting in missing text.

Change-Id: I69c727ef69e2c61e2b2d6b81d5a28c806327f865
2014-06-11 16:03:49 -07:00
Raph Levien
1f8de3019d Support for fake bold and italics
This patch adds support for computing when fake bold and fake italics
are needed (because the styles are requested but not provided by the
matching FontFamily), and providing them as part of the layout result.

Part of the fix for bug 15436379 Fake bold doesn't fully work (Minikin)

Change-Id: I180c034b559837943673b5c272c8e890178dff0d
2014-06-11 12:42:44 -07:00
Raph Levien
1e35d09df1 Add baseFont method to FontCollection
This patch adds a method to retrieve the base font from a
FontCollection, which is useful when querying global font metrics.

Part of the fix for bug 15467288 "Inconsistent line heights on
Minikin builds"

Change-Id: I268ae5128d0852a020d746bc22af81fc1a623228
2014-06-11 12:42:32 -07:00
Raph Levien
9c9cab6487 Merge "Provisionally enable "palt" OpenType feature" 2014-06-10 19:09:51 +00:00
Raph Levien
2b7da7bc2b Support for fake bold and italics
This patch adds support for computing when fake bold and fake italics
are needed (because the styles are requested but not provided by the
matching FontFamily), and providing them as part of the layout result.

Part of the fix for bug 15436379 Fake bold doesn't fully work (Minikin)

Change-Id: I180c034b559837943673b5c272c8e890178dff0d
2014-06-10 11:59:29 -07:00
Raph Levien
faadb4243e Provisionally enable "palt" OpenType feature
We want to test configurations where the Noto Japanese font will have
its "palt" feature (to select tighter spacing in kana) will be enabled
for framework but not WebView or Chrome rendering of Japanese text. This
patch simply hardcodes this feature on.

This is also a first step towards more general setting of OpenType
features. The hardcoded feature list will grow into one set by
parameters which will eventually be plumbed up to Java.

Change-Id: Ie284e0487a1434155c8ac1cb68ddc4fc4b3c018a
2014-06-07 08:23:25 -07:00
Raph Levien
13b22fd243 Add baseFont method to FontCollection
This patch adds a method to retrieve the base font from a
FontCollection, which is useful when querying global font metrics.

Part of the fix for bug 15467288 "Inconsistent line heights on
Minikin builds"

Change-Id: I268ae5128d0852a020d746bc22af81fc1a623228
2014-06-06 17:03:33 +00:00
Qiwen Zhao
8305dbe5d9 reset sha1 06dec08 with history 2014-06-05 21:44:58 -07:00
Raph Levien
dab4f5f793 am 014498ae: Fix unmatching type
* commit '014498ae2ab29399a632c548b8dc94cbf215b861':
  Fix unmatching type
2014-06-05 20:04:26 +00:00
Raph Levien
a367eb1998 am 23801bf4: Support for scaleX and skewX
* commit '23801bf449e5bfa467729b1a61af324a7afbee19':
  Support for scaleX and skewX
2014-06-05 20:04:26 +00:00
Raph Levien
06dec08ca2 Support for context in API
This patch completes support for adding context for complex script
layout, for example when a string with joins straddles two spans.

Part of the fix for 15431028: "Properly support context for joining
scripts (Minikin)"

Change-Id: I65b0833be92eb477aa531bbef0ac6eddeb3a962a
2014-06-05 12:23:21 -07:00
Raph Levien
ddcdc08c7c Make paint flags consistently uint32_t
Change internal plumbing of paint flags (including CssParse) to uint32_t
consistently, to match the type used in the client. This will probably
prevent compiler warnings. Also renames "float" to "double" to avoid
confusion about precision.

Change-Id: I80374712c4067ca9e7711cc2d4ec33c440ab9c7c
2014-06-05 09:26:43 -07:00
Raph Levien
014498ae2a Fix unmatching type
Missed a slightly mismatched type (int vs int32_t) from a previous code
review.

Change-Id: Ib56775a3a1a6ec3763da7f7432186954251cc048
2014-06-04 11:16:15 -07:00
Raph Levien
23801bf449 Support for scaleX and skewX
Adds pseudo-css properties for scaleX and skewX, as well as paint flags,
and plumb them through to the MinikinPaint abstraction and to Harfbuzz,
to support nontrivial scale and stretch of text.

This is the Minikin part of the fix for bug 15186705 "Usability of the
suggestion strip in recent OTA's is severely reduced"

Change-Id: Ifa60355e086e4691ff92c5d50d84eb7cea0fea95
2014-06-03 17:05:51 -07:00
Raph Levien
6100fa5441 am 1391c37e: Fix ZWJ not working for Indic fonts
* commit '1391c37ea908bff79222109f4351d361c2910372':
  Fix ZWJ not working for Indic fonts
2014-05-29 22:38:30 +00:00
Raph Levien
bef68b94ed am 7d4090fb: Language and variant selection
* commit '7d4090fbe937014d79bb996c03e763d2557d238d':
  Language and variant selection
2014-05-29 22:38:29 +00:00
Raph Levien
1391c37ea9 Fix ZWJ not working for Indic fonts
This is a fix for bug 15185229 ZWJ not working in Sinhala and Kannada.

Indic fonts (unlike Arabic) require the entire string, including ZWJ,
to be passed to Harfbuzz; it's not enough for the ZWJ to be present in
the context. The solution is to be "sticky" in font itemization,
continuing to use the same font as long as it has Unicode coverage.

Change-Id: I7673bc56fbda09f1e1a4582e8d88342343b706f1
2014-05-29 15:16:32 -07:00
Raph Levien
7d4090fbe9 Language and variant selection
This patch adds a "lang" pseudo-CSS property and uses it both to select
an appropriate font and control the "locl" OpenType feature to get the
most appropriate rendering for the langauge and script.  In addition,
the "-minikin-variant" property selects between "compact" and "elegant"
variants of a font, as the former is needed for vertically cramped
spaces.

This is part of the fix for bug 15179652 "Japanese font isn't shown on
LMP".

Change-Id: I7fab23c12d4c797a6d339a16e497b79a3afe9df1
2014-05-29 15:16:32 -07:00
Raph Levien
ac1f6e260c am e1a0422a: Fix for Minikin native crash
* commit 'e1a0422aae785f6ed213ba0bb0139edc30502d7a':
  Fix for Minikin native crash
2014-05-29 21:27:39 +00:00
Raph Levien
e1a0422aae Fix for Minikin native crash
The context start offset wasn't being taken into account for
accumulating the advance values, leading in some cases to array index
overflow.

This is a fix for bug 15327918 "SIGSEGV in
android::MinikinFontSkia::GetSkTypeface()"

Change-Id: I9b646785724c9b72d862b822cd84661c106fbe52
2014-05-29 14:06:53 -07:00
Raph Levien
1c75d0afe7 am 9c5d659d: Fix for bug 15252902 native crash in Minikin
* commit '9c5d659d5fdfb149f786335f39b20e55c71d949b':
  Fix for bug 15252902 native crash in Minikin
2014-05-27 15:51:43 +00:00
Raph Levien
4d33c6c9ca am ddfa014d: Caching for layouts and harfbuzz faces
* commit 'ddfa014d55c11da8e73580b639917f2e2a441add':
  Caching for layouts and harfbuzz faces
2014-05-27 15:51:42 +00:00
Raph Levien
f043d36367 am 2d546464: (-s ours) Merge "Do BiDi algorithm for text layout" into lmp-preview-dev
* commit '2d546464055f7a6964ca87ca7c7b4f175ea4101b':
  Do BiDi algorithm for text layout
2014-05-27 15:51:42 +00:00
Raph Levien
9c5d659d5f Fix for bug 15252902 native crash in Minikin
This is a fix for bug 15252902 "Crash observed on keep launch or
existing youtube app after playing video". It was doing the test for a
null font after trying to resolve the font in a cache, which caused a
crash when there was no font for the run. This patch just tests before
cache lookup.

Change-Id: Iee41f7ce6b69cb09438462b6aaa916f242da7b77
2014-05-27 15:40:17 +00:00
Raph Levien
ddfa014d55 Caching for layouts and harfbuzz faces
This patch adds caching for both layouts and for HarfBuzz face objects.
The granularity of the cache for layouts is words, so it splits the
input string at word boundaries (using a heuristic). There are is also
some refactoring to reduce the amount of allocation and copying, and
movement towards properly supporting contexts.

The size of the caches is a fixed number of entries; thus, it is
possible to consume a large amount of memory by filling the cache with
lots of large strings. This should be refined towards a scheme that
bounds the total memory used by the cache.

This patch fixes bug 15237293 "Regression: Measure performance is
significantly slower with minikin".

Change-Id: Ie8176857e2d78656ce5479a7c04969819ef2718d
2014-05-27 15:39:33 +00:00
Raph Levien
2d54646405 Merge "Do BiDi algorithm for text layout" into lmp-preview-dev 2014-05-27 15:36:36 +00:00