122 Commits

Author SHA1 Message Date
Raph Levien
bb86b433f9 Rename "margins" to "indents"
The name "margin" conflicts with another meaning, so we're making the
name in the public api "idents" and the code consistent in naming.

Change-Id: I9170116b4d972e4b25f0f319e78376310288eb41
2015-04-15 19:12:48 -07:00
Raph Levien
dc7bc6e39e Add margins array to line widths object
In order to support layout in non-rectangular regions, the LineWidths
object needs to accept an arbitrary array of margins. This is
implemented in addition to the existing firstWidthLineCount/restWidth
mechanism for convenience, though using only arrays would have the
same expressive power.

Bug: 20182243
Change-Id: Iea96bca1a92012314ac27e617c67f306c1f1b2f2
2015-04-15 19:12:41 -07:00
Raph Levien
5cdad92c30 Revert "Fix build: Revert "Add hyphenation to line breaking""
This reverts commit 0b25d5ac85533f64764a0d53d5e5d33b46b715fa.
2015-03-30 14:20:18 -07:00
Ed Heyl
0b25d5ac85 Fix build: Revert "Add hyphenation to line breaking"
This reverts commit daf6a6bdbf2ff1f66496d6200cb253e2f50759d5.

Change-Id: I3fed65046274d3aeb748f0730585ab89927f5741
2015-03-30 20:40:33 +00:00
Raph Levien
daf6a6bdbf Add hyphenation to line breaking
This patch adds hyphenation using the Liang hyphenation algorithm,
similar to TeX. It also improves the optimized line breaker so that
it works correctly and efficiently even when the line width is not
constant (there is a specialization for constant width, which is
probably worthwhile, but performance TODOs remain).

Still to be done:

* hyphenator has many shortcuts, only tested with English

* interaction between punctuation and hyphenation is problematic

Change-Id: I2d94a1668ebc536398b7c43fcf486333eeb7c6aa
2015-03-30 09:15:53 -07:00
Raph Levien
01f5266144 Add LineBreaker to Minikin
This patch adds a LineBreaker class to Minikin, which will be used for
computing line breaks in StaticLayout. The version in this patch
contains basically the same functionality that existed before, but
hopefully better performance and an interface that's suitable for more
sophisticated paragraph layout.

Note that this version contains a high quality strategy, which mostly
works but doesn't respect varying line width.

Change-Id: I02485d58b1e52856296a72cdd4efd963bc572933
2015-03-26 16:00:04 -07:00
Raph Levien
d692d6a979 HyphenEdit in support of hyphenation
Adds a "HyphenEdit" field to the Minikin Paint object, which represents
an edit to the text to add a hyphen (and, in the future, other edits to
support nonstandard hyphenation).

Change-Id: Ib4ee690b0fe2137e1d1e2c9251e5526b274ec3a7
2015-03-12 14:37:55 -07:00
Roozbeh Pournader
0bbff3a96d Disable HarfBuzz's fallback to compatibility decompositions
Previously, HarfBuzz's default fallback to compatibility
decompositions resulted in Mathematical Alphanumeric Symbols getting
rendered as normal letters and digits when there was no font
available to render them. This patch disables that fallback, to
ensure they are displayed as tofus.

Based on a patch by Behdad Esfahbod.

Bug: 19202569
Change-Id: I357f172302448d4ab0b24efc86119f1977b5996b
2015-02-25 13:30:08 -08:00
Narayan Kamath
30c70ff714 am 79298c34: am 5870d4f0: Remove hardcoded ICU include paths.
* commit '79298c346088e13a0ddc93d49f4bb100afdbd14b':
  Remove hardcoded ICU include paths.
2015-01-05 16:38:00 +00:00
Narayan Kamath
79298c3460 am 5870d4f0: Remove hardcoded ICU include paths.
* commit '5870d4f0d46f185568a2d2ea45afe48ae999b223':
  Remove hardcoded ICU include paths.
2015-01-05 16:31:53 +00:00
Narayan Kamath
5870d4f0d4 Remove hardcoded ICU include paths.
ICU exports them using LOCAL_EXPORT_C_INCLUDE_DIRS.

bug: 18581021
Change-Id: Ia57b3b4d231966203274b0e7e7b850beb1bd11c0
2015-01-05 11:44:09 +00:00
Andreas Gampe
da09490825 am 919fbb99: am cb20a2f0: Minikin: Remove unused variables, fix init order
* commit '919fbb99f1d5d0c95bf165cec9b7b178b42908ec':
  Minikin: Remove unused variables, fix init order
2014-12-04 20:44:11 +00:00
Andreas Gampe
919fbb99f1 am cb20a2f0: Minikin: Remove unused variables, fix init order
* commit 'cb20a2f0b366bfc16db3a489a60156dec7a9fe21':
  Minikin: Remove unused variables, fix init order
2014-12-04 19:52:12 +00:00
Raph Levien
2d7821158c am 58b25145: am 13f1aae0: Move coverage bitmap from FontCollection to FontFamily
* commit '58b25145c1a14dd2e45d2b995d4b07d8fe70510c':
  Move coverage bitmap from FontCollection to FontFamily
2014-12-04 16:17:39 +00:00
Raph Levien
58b25145c1 am 13f1aae0: Move coverage bitmap from FontCollection to FontFamily
* commit '13f1aae02bacd475722bc8ea3fc2cf6abc1a82e3':
  Move coverage bitmap from FontCollection to FontFamily
2014-12-04 09:22:21 +00:00
Andreas Gampe
cb20a2f0b3 Minikin: Remove unused variables, fix init order
For build-system CFLAGS clean-up, fix unused variables.

Reorder initializer list to initialize in the order of member
declarations.

Change-Id: I64358b2dcf0e39d0f4e18fdc3473de867f84fcba
2014-12-03 14:20:11 -08:00
Raph Levien
13f1aae02b Move coverage bitmap from FontCollection to FontFamily
This will significantly reduce memory usage and also speed the creation
of new font families. In particular, the coverage bitmaps for the fonts
in the fallback stack will be computed once in the Zygote, rather than
separately in each app process.

Bug: 17756900
Change-Id: I66f5706bddd4658d78fe5b709f7251ca9d2ff4f8
2014-12-03 12:48:20 -08:00
Dan Albert
e8b4a1b78a am dc81fbad: am 69d4fba2: Move frameworks/minikin over to libc++.
* commit 'dc81fbad809f08564199c8f08df7e7f72310961a':
  Move frameworks/minikin over to libc++.
2014-11-12 21:31:35 +00:00
Dan Albert
dc81fbad80 am 69d4fba2: Move frameworks/minikin over to libc++.
* commit '69d4fba2f2b7bb2c248cc0e78cf277a6e44665f8':
  Move frameworks/minikin over to libc++.
2014-11-12 21:28:22 +00:00
Dan Albert
69d4fba2f2 Move frameworks/minikin over to libc++.
Bug: 15193147
Change-Id: I5e15c95415c39515340e2663acd5fd26666db720
2014-11-11 19:32:48 -08:00
Raph Levien
92065a6f3f am 253320d2: Move coverage bitmap from FontCollection to FontFamily
* commit '253320d25fccbb49621926d49dcf5ef64cf529c6':
  Move coverage bitmap from FontCollection to FontFamily
2014-10-31 00:37:02 +00:00
Raph Levien
253320d25f Move coverage bitmap from FontCollection to FontFamily
This will significantly reduce memory usage and also speed the creation
of new font families. In particular, the coverage bitmaps for the fonts
in the fallback stack will be computed once in the Zygote, rather than
separately in each app process.

Bug: 17756900
Change-Id: I66f5706bddd4658d78fe5b709f7251ca9d2ff4f8
2014-10-29 12:34:50 -07:00
Raph Levien
168d3ef0e0 am 5f11abd3: Silently ignore invalid rangeOffset values
* commit '5f11abd31fa8cfa723f54bd1c98ce4e27e7d3c77':
  Silently ignore invalid rangeOffset values
2014-10-24 06:31:13 +00:00
Raph Levien
5f11abd31f Silently ignore invalid rangeOffset values
Some fonts contain a cmap segment for char 0xffff that contains an
invalid rangeOffset. This was rejected by the existing code, which
means the font is considered to have empty Unicode coverage. This patch
just discards the invalid segment (consistent with OpenType Sanitizer),
making the custom font display.

Bug: 18106256
Change-Id: Icc8616a3030f80e62db906332be64d434ae72ea2
2014-10-23 23:31:42 +00:00
Raph Levien
60cc2ccf68 am d5804e39: Fine-tune fake-bolding condition
* commit 'd5804e3937a961736e5cef0e8a70eacf91ee00bb':
  Fine-tune fake-bolding condition
2014-09-23 16:17:41 +00:00
Raph Levien
d5804e3937 Fine-tune fake-bolding condition
The old logic for fake bolding results in no fake bolding for a bold
span on a light weight (300) because the target weight (600 in this
case) didn't meet the condition. This patch fine-tunes the threshold
to enable fake bolding for this.

Bug: 17587185

Change-Id: I04abd00a74240cbed79c417f81486aa2158b2806
2014-09-22 18:21:34 +00:00
Raph Levien
9f00aaec70 am 6740536e: Snap advance widths to integers
* commit '6740536e3927d25bf5c2567e5f6e8c175973cbb7':
  Snap advance widths to integers
2014-09-04 00:16:27 +00:00
Raph Levien
6740536e39 Snap advance widths to integers
Fractional advance widths were causing subtle problems with text
positioning when the same text was drawn with different spans in the
hwui renderer. Quantizing the coordinates on layout (as opposed to
waiting until the renderer draws the glyphs) solves the problem.

This patch also fixes a discrepancy between x position and advance
widths when letterspacing.

Bug: 17347779
Change-Id: Ia705944047408c2839d5ad078eefd6bbec446872
2014-09-03 10:42:52 -07:00
Raph Levien
df0178d7d2 am 997c799e: Try Unicode decomposition for selecting fallback font
* commit '997c799e3ec6bf8adf687e29670d23d91e0f5fee':
  Try Unicode decomposition for selecting fallback font
2014-08-27 17:07:48 +00:00
Raph Levien
997c799e3e Try Unicode decomposition for selecting fallback font
This patch finds an appropriate fallback font in the case where no font
directly maps the requested character, but a font does exist for the
character's canonical decomposition. This yields correct rendering of
compatibility characters such as U+FA70.

Bug: 15816880
Bug: 16856221
Change-Id: Idff8ed6b942fec992a0815a32028b95af091d0ee
2014-08-26 22:20:16 -07:00
Behdad Esfahbod
10d07727cf am 56c7fb8c: Allocate font vector on stack
* commit '56c7fb8c0633f1b02115bb4370854016f8c84fb4':
  Allocate font vector on stack
2014-08-22 18:36:40 +00:00
Behdad Esfahbod
56c7fb8c06 Allocate font vector on stack
This reduces another allocation (last one?) we were doing when
fulfilling shaping requests from the cache.

Bug: 17111260
Change-Id: Ieb8ae1ccfcaacedb257e1e9263777f10623aaf98
2014-08-21 19:25:06 -04:00
Behdad Esfahbod
c01aa1e323 am 6da7796c: Fix Layout initialization in the skipCache path
* commit '6da7796cbe8a17efd61a3302369e69bb222fdb4f':
  Fix Layout initialization in the skipCache path
2014-08-21 22:09:56 +00:00
Behdad Esfahbod
6da7796cbe Fix Layout initialization in the skipCache path
C++ local var initialization always tricks me.  Previously, Layout
didn't have a constructor, which meant that defining it on the stack
left mAdvance uninitialized.  This was not an issue when we were doing
"new Layout()", since that invokes zero-initialization, but was an
issue for the skipCache path that was allocating layout on stack by
just "Layout l" instead of "Layout l = Layout()".  To avoid surprises,
add a constructors that clears everything.

Also adds reset() method to reset the layout for reuse.

Change-Id: I3e02f00da9dd7d360abe13f63c310f6882292d0a
2014-08-21 17:26:04 -04:00
Behdad Esfahbod
338de7c423 am 288c9159: Speed up cache lookup
* commit '288c915963b3500c7efb958ba613650e2ecdfdfa':
  Speed up cache lookup
2014-08-21 20:39:33 +00:00
Behdad Esfahbod
288c915963 Speed up cache lookup
Avoid copying the string for cache lookup.

Bug: 17111260
Change-Id: Ic220bfc991fc6b3dada197304aabdf72a8941bd7
2014-08-21 14:00:25 -04:00
Behdad Esfahbod
8e865a08c0 am f952161b: Choose same font for Emoji keycap and its base character
* commit 'f952161b874fd2e9af474b9fd2ebcca1f3bb4555':
  Choose same font for Emoji keycap and its base character
2014-08-08 19:56:55 +00:00
Behdad Esfahbod
f952161b87 Choose same font for Emoji keycap and its base character
The U+20E3 COMBINING KEYCAP is used in our fonts to generate an emoji
rendering of ASCII numbers and letters through GSUB.  For that to work
we need to choose the same (Emoji) font for the character coming
*before* the COMBINING KEYCAP character.

This is a special-case of a broader need to choose fonts per grapheme
cluster as opposed to per character, but for now, special-case U+20E3.

Bug: 7557244
Change-Id: I958e5a01068df8495bbb9bc3b9ed871cea1838b6
2014-08-08 15:37:28 -04:00
Behdad Esfahbod
143a999611 am 5986f604: Support fontFeatureSettings
* commit '5986f6048ae21e0ec094c1f2ca0169d0ca6ec6b5':
  Support fontFeatureSettings
2014-07-30 21:42:58 +00:00
Behdad Esfahbod
5986f6048a Support fontFeatureSettings
Bug: 15246510
Change-Id: I544915d29b2be4fb9f82f1989188a3a918c50fbc
2014-07-30 17:29:00 -04:00
Behdad Esfahbod
0713ade318 am 9802b0dc: Fix examples build
* commit '9802b0dc8e648117ab917e716e81e8a0da909cb3':
  Fix examples build
2014-07-29 21:17:20 +00:00
Behdad Esfahbod
11b08d8be3 am d50c99df: Merge "Remove CSS string doLayout entrypoint and supporting code" into lmp-dev
* commit 'd50c99df4efbc57eb4419bd7944a979b9a1d53cc':
  Remove CSS string doLayout entrypoint and supporting code
2014-07-29 21:01:36 +00:00
Behdad Esfahbod
4dcf029f1d am 83d5a3c5: Initialize MinikinPaint members
* commit '83d5a3c53d77c34fbeac7012ab3612933982d494':
  Initialize MinikinPaint members
2014-07-29 21:01:36 +00:00
Behdad Esfahbod
9802b0dc8e Fix examples build
Was broken after recent CSS removal.

Change-Id: I160fbc73286b21336d6f3943ff92d7d150dff74b
2014-07-29 16:57:00 -04:00
Behdad Esfahbod
83d5a3c53d Initialize MinikinPaint members
We are stack-allocating MinikinPaint objects in Minikin clients, and
without a constructor adding new members to the struct cannot be done
without updating all clients (only one right now!).

Change-Id: I4170f16498bb6b07cb795495011aca58087ed0bd
2014-07-29 16:26:49 -04:00
Behdad Esfahbod
09f1901d6b Add doLayout variant that does NOT take css string
New API removes CSS string and directly takes needed objects.

Bug: 16651112
Change-Id: Ie5f7c2ab05be6cbd77cae0a5fd6bb453771ada59
2014-07-29 12:46:07 -04:00
Behdad Esfahbod
d50c99df4e Merge "Remove CSS string doLayout entrypoint and supporting code" into lmp-dev 2014-07-27 22:35:46 +00:00
Behdad Esfahbod
c924dd126d 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
41b1aa18d7 Merge "Don't get stuck on invalid UTF-16" into lmp-dev 2014-07-24 15:37:54 +00:00
Behdad Esfahbod
b8208bc19c 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