61 Commits

Author SHA1 Message Date
Raph Levien
67ea671fe4 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
22e41754f6 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
3d28a3fceb 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
bb601b67dd 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
3276dee361 am e68467e9: Tighten requirements for fake bold
* commit 'e68467e971390f0c79992cd938a870093a3d6412':
  Tighten requirements for fake bold
2014-06-12 22:31:15 +00:00
Raph Levien
cca62d1a8b am 15651697: (-s ours) Support for fake bold and italics
* commit '1565169734dbed6d59cc10f2a7de01f8601533e0':
  Support for fake bold and italics
2014-06-12 18:07:59 +00:00
Raph Levien
fc118a91b4 am b1eae5ea: (-s ours) Add baseFont method to FontCollection
* commit 'b1eae5ea1f0f1303d155ee550f9aa94acd0127c5':
  Add baseFont method to FontCollection
2014-06-12 18:02:23 +00:00
Raph Levien
e68467e971 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 9f9f3b1ef40f7358dca6acd9dfef686cedefb6aa)
2014-06-12 16:29:24 +00:00
Raph Levien
92207c3e83 Merge "Fix missing text on nonexistent font file" 2014-06-11 21:23:31 +00:00
Raph Levien
9f9f3b1ef4 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
bd36ec766a 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
1565169734 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
b1eae5ea1f 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
1c7b403ad8 Merge "Provisionally enable "palt" OpenType feature" 2014-06-10 19:09:51 +00:00
Raph Levien
9a5f713add 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
4043f6f6d9 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
89566f0ada 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
621d437b92 reset sha1 3f1ea5d with history 2014-06-05 21:44:58 -07:00
Raph Levien
80556a83ad am 89339973: Fix unmatching type
* commit '893399732b64203133c22ad3c1f3535e46bf35a7':
  Fix unmatching type
2014-06-05 20:04:26 +00:00
Raph Levien
d963b2d5e6 am 448b0fd7: Support for scaleX and skewX
* commit '448b0fd720d7ba902b9be224a287d08abe3ebea8':
  Support for scaleX and skewX
2014-06-05 20:04:26 +00:00
Raph Levien
3f1ea5da2e 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
3164d1a77e 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
893399732b 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
448b0fd720 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
67841bf03b am 066e8575: Fix ZWJ not working for Indic fonts
* commit '066e8575af64fb452617ac6005de6ccf6509553b':
  Fix ZWJ not working for Indic fonts
2014-05-29 22:38:30 +00:00
Raph Levien
b4a2754557 am 7b221d97: Language and variant selection
* commit '7b221d97b7b64dc5ce457e19666d55d042e22e62':
  Language and variant selection
2014-05-29 22:38:29 +00:00
Raph Levien
066e8575af 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
7b221d97b7 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
7d190a2b77 am 0297ee98: Fix for Minikin native crash
* commit '0297ee985c26b49fc2a3b0941db354c27f436bbf':
  Fix for Minikin native crash
2014-05-29 21:27:39 +00:00
Raph Levien
0297ee985c 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
fb9c6e2e4e am 7c382381: Fix for bug 15252902 native crash in Minikin
* commit '7c382381191b2280b53c375fe83dfc6217bbdfa9':
  Fix for bug 15252902 native crash in Minikin
2014-05-27 15:51:43 +00:00
Raph Levien
8eef0a2ebf am 4d4e6bc8: Caching for layouts and harfbuzz faces
* commit '4d4e6bc8118d15542f1f2a9218f0f7a91a29474f':
  Caching for layouts and harfbuzz faces
2014-05-27 15:51:42 +00:00
Raph Levien
4af2976a62 am d973b392: (-s ours) Merge "Do BiDi algorithm for text layout" into lmp-preview-dev
* commit 'd973b3926b3a34c19d3d6f309fae1138e782e4dc':
  Do BiDi algorithm for text layout
2014-05-27 15:51:42 +00:00
Raph Levien
7c38238119 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
4d4e6bc811 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
d973b3926b Merge "Do BiDi algorithm for text layout" into lmp-preview-dev 2014-05-27 15:36:36 +00:00
Raph Levien
86fa46c5eb Do BiDi algorithm for text layout
This is a fix for bug 15130102 "Language name for Hebrew displayed the
wrong way around on keyboard".

This patch extends the previous BiDi support (when the direction for the
entire string was given by the caller) to run the BiDi algorithm
(provided by ICU) over the string to break it into BiDi runs. Thus, it
handles mixed LTR and RTL strings in a single layout, and also respects
heuristics for inferring the paragraph direction from the string.

Change-Id: Ia4b869de3c139c5a7d16b8ce7766870b98a815ea
(cherry picked from commit 4b3a941128454e55893d65433a835e78a9e9781d)
2014-05-27 14:44:32 +00:00
Raph Levien
9d44749a5d am 72fe9422: Fix native crash in Latin-1 typefaces
* commit '72fe9422c869b7878240a23e4650d9d90edb1c2a':
  Fix native crash in Latin-1 typefaces
2014-05-24 14:52:56 +00:00
The Android Automerger
0980c41b38 am b43357ad: merge in master-release history after reset to c31e3883456e018d742e9f29815ba5ff8b315ea1
* commit 'b43357ad71782b4d1df03ee7e89b30705fcc6a93':
  Fix incomplete refcounting and locking
2014-05-24 14:52:56 +00:00
Raph Levien
72fe9422c8 Fix native crash in Latin-1 typefaces
This is a fix for bug 15171911 Timely crashes (native crash in
libminikin) when I go to add a new alarm

This patch fixes an off-by-one error that caused typefaces with only one
page of Unicode coverage (ASCII or Latin-1) to have nPages = 0 instead
of the correct value of 1 in the corresponding FontCollection.

Change-Id: Id8be0c9e5713b8af22d863992921ee6382416a34
2014-05-23 22:44:35 -07:00
Raph Levien
cf6d68c32c 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.

Change-Id: Ie8176857e2d78656ce5479a7c04969819ef2718d
2014-05-22 16:30:33 -07:00
The Android Automerger
b43357ad71 merge in master-release history after reset to c31e3883456e018d742e9f29815ba5ff8b315ea1 2014-05-22 07:22:04 -07:00
The Android Automerger
0beda2b994 merge in master-release history after reset to c31e3883456e018d742e9f29815ba5ff8b315ea1 2014-05-22 05:50:25 -07:00
The Android Automerger
24971ebb2e merge in master-release history after reset to c31e3883456e018d742e9f29815ba5ff8b315ea1 2014-05-21 05:50:20 -07:00
The Android Automerger
edb291fbf2 merge in master-release history after reset to c31e3883456e018d742e9f29815ba5ff8b315ea1 2014-05-20 05:50:09 -07:00
Raph Levien
55f3653aae Fix incomplete refcounting and locking
These changes were supposed to be committed in the previous patch
"Better refcounting and locking" but seem to have gotten lost in a
rebase. It fixes a memory leak and some possible race conditions.

Change-Id: I54ca1e37500ec49756fe317cc6d6d03da9911501
2014-05-19 16:24:51 -07:00
Raph Levien
4b3a941128 Do BiDi algorithm for text layout
This patch extends the previous BiDi support (when the direction for the
entire string was given by the caller) to run the BiDi algorithm
(provided by ICU) over the string to break it into BiDi runs. Thus, it
handles mixed LTR and RTL strings in a single layout, and also respects
heuristics for inferring the paragraph direction from the string.

Change-Id: Ia4b869de3c139c5a7d16b8ce7766870b98a815ea
2014-05-19 14:53:57 -07:00
Raph Levien
c31e388345 Fix incomplete refcounting and locking
These changes were supposed to be committed in the previous patch
"Better refcounting and locking" but seem to have gotten lost in a
rebase. It fixes a memory leak and some possible race conditions.

Change-Id: I54ca1e37500ec49756fe317cc6d6d03da9911501
2014-05-19 14:01:37 -07:00
Leon Scroggins III
a3998d4f51 Remove references to SkFloatToScalar.
The macro has been deprecated, now that SkScalar is never fixed point.

Fixes minikin build.

Change-Id: I02838a7fa167c5cf58ad225f3f2f52659495492c
2014-05-15 10:52:56 -04:00
Raph Levien
d231a4b0b1 Initial BiDi support
This patch contains a very basic implementation of BiDi. It respects the
BiDi flags passed in as an explicit parameter (through the
"-minikin-bidi" pseudo-CSS property), but doesn't yet do its own BiDi
run detection. It also takes some shortcuts (marked as TODO) that are
based on reasonable assumptions of the current font stack, but not
universally valid.

Even with these shortcomings, it seems to display RTL text from TextView
correctly.

Change-Id: I223433923c4eb06f90c0327e86bfbe0aff71d4f5
2014-05-14 15:56:05 -07:00