120 Commits

Author SHA1 Message Date
Raph Levien
c76f4113d7 Revert "Fix build: Revert "Add hyphenation to line breaking""
This reverts commit f8ed26a065cdb58adfa5df940bd2f0f6ae70d236.
2015-03-30 14:20:18 -07:00
Ed Heyl
f8ed26a065 Fix build: Revert "Add hyphenation to line breaking"
This reverts commit b038d920c433d8971b179b888220cc2a197bc227.

Change-Id: I3fed65046274d3aeb748f0730585ab89927f5741
2015-03-30 20:40:33 +00:00
Raph Levien
b038d920c4 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
e65751d728 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
aa1337a41a 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
4c4af7f4dc 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
9b92cfc0ec am fa7d7235: am 65866430: Remove hardcoded ICU include paths.
* commit 'fa7d72355bb5d870797aa6df3c31e9c5d5d10edf':
  Remove hardcoded ICU include paths.
2015-01-05 16:38:00 +00:00
Narayan Kamath
fa7d72355b am 65866430: Remove hardcoded ICU include paths.
* commit '65866430cf310c8711d77b2feff70a25006cb948':
  Remove hardcoded ICU include paths.
2015-01-05 16:31:53 +00:00
Narayan Kamath
65866430cf 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
e91f4fd54e am 1503e1ff: am faf26d17: Minikin: Remove unused variables, fix init order
* commit '1503e1ff93656759019987cc51dd7cdab7b16c01':
  Minikin: Remove unused variables, fix init order
2014-12-04 20:44:11 +00:00
Andreas Gampe
1503e1ff93 am faf26d17: Minikin: Remove unused variables, fix init order
* commit 'faf26d176f220c5fa00c20085b764346c998405e':
  Minikin: Remove unused variables, fix init order
2014-12-04 19:52:12 +00:00
Raph Levien
c6b912e71c am def32a19: am 477b5d2c: Move coverage bitmap from FontCollection to FontFamily
* commit 'def32a19f92e966bbca35f5f05b6dabea8b1b4f3':
  Move coverage bitmap from FontCollection to FontFamily
2014-12-04 16:17:39 +00:00
Raph Levien
def32a19f9 am 477b5d2c: Move coverage bitmap from FontCollection to FontFamily
* commit '477b5d2cdbbc7c8115d5fcf441ea25cedc48d08c':
  Move coverage bitmap from FontCollection to FontFamily
2014-12-04 09:22:21 +00:00
Andreas Gampe
faf26d176f 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
477b5d2cdb 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
46e3118bfd am 8bbd29fc: am a4e238f7: Move frameworks/minikin over to libc++.
* commit '8bbd29fce5fb17fb86d9fd2f79028c949c66d20a':
  Move frameworks/minikin over to libc++.
2014-11-12 21:31:35 +00:00
Dan Albert
8bbd29fce5 am a4e238f7: Move frameworks/minikin over to libc++.
* commit 'a4e238f757417c13e688f69f49eed4db168dc6c9':
  Move frameworks/minikin over to libc++.
2014-11-12 21:28:22 +00:00
Dan Albert
a4e238f757 Move frameworks/minikin over to libc++.
Bug: 15193147
Change-Id: I5e15c95415c39515340e2663acd5fd26666db720
2014-11-11 19:32:48 -08:00
Raph Levien
bb55fc47a5 am 474b009e: Move coverage bitmap from FontCollection to FontFamily
* commit '474b009ef443dbb82c1f93688613b9853ab1b396':
  Move coverage bitmap from FontCollection to FontFamily
2014-10-31 00:37:02 +00:00
Raph Levien
474b009ef4 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
c74b7505c1 am 92e8cc70: Silently ignore invalid rangeOffset values
* commit '92e8cc7071364e58b3d5642649f7032a63f389f7':
  Silently ignore invalid rangeOffset values
2014-10-24 06:31:13 +00:00
Raph Levien
92e8cc7071 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
5f94c59c2e am 6cba4a1d: Fine-tune fake-bolding condition
* commit '6cba4a1dcae7ce1a359638405c3703b3cbb91277':
  Fine-tune fake-bolding condition
2014-09-23 16:17:41 +00:00
Raph Levien
6cba4a1dca 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
5a3a896405 am ff55a581: Snap advance widths to integers
* commit 'ff55a581fa07b52f3cffcf3fc825d297cf955ffe':
  Snap advance widths to integers
2014-09-04 00:16:27 +00:00
Raph Levien
ff55a581fa 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
604053e564 am 543c65c8: Try Unicode decomposition for selecting fallback font
* commit '543c65c80b71e3111314bf429004a10d004e861b':
  Try Unicode decomposition for selecting fallback font
2014-08-27 17:07:48 +00:00
Raph Levien
543c65c80b 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
ddd99662c1 am 11c8920a: Allocate font vector on stack
* commit '11c8920a3fc1c5895e777f71c822501367eef69c':
  Allocate font vector on stack
2014-08-22 18:36:40 +00:00
Behdad Esfahbod
11c8920a3f 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
55f6f0cd86 am df03550a: Fix Layout initialization in the skipCache path
* commit 'df03550a40706a55ca1bfcb67da62765194cf98f':
  Fix Layout initialization in the skipCache path
2014-08-21 22:09:56 +00:00
Behdad Esfahbod
df03550a40 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
2f65c78209 am a33151e9: Speed up cache lookup
* commit 'a33151e9c78c5547eeadbaaa9168dad361df05e4':
  Speed up cache lookup
2014-08-21 20:39:33 +00:00
Behdad Esfahbod
a33151e9c7 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
a50cc8616c am 2f24599f: Choose same font for Emoji keycap and its base character
* commit '2f24599f4a258160854d18096b302ec2c3aa66c9':
  Choose same font for Emoji keycap and its base character
2014-08-08 19:56:55 +00:00
Behdad Esfahbod
2f24599f4a 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
f7a71d4b4e am a944efa7: Support fontFeatureSettings
* commit 'a944efa7a0e61169f56c0002b95e9d6951b1e86e':
  Support fontFeatureSettings
2014-07-30 21:42:58 +00:00
Behdad Esfahbod
a944efa7a0 Support fontFeatureSettings
Bug: 15246510
Change-Id: I544915d29b2be4fb9f82f1989188a3a918c50fbc
2014-07-30 17:29:00 -04:00
Behdad Esfahbod
947aaacee5 am 8bee8f92: Fix examples build
* commit '8bee8f92e045f5e709dbcbedd9d486b55e73f54e':
  Fix examples build
2014-07-29 21:17:20 +00:00
Behdad Esfahbod
6abdc7368f am 2d51f518: Merge "Remove CSS string doLayout entrypoint and supporting code" into lmp-dev
* commit '2d51f518d22eb897603c80f4df5149c711f705b2':
  Remove CSS string doLayout entrypoint and supporting code
2014-07-29 21:01:36 +00:00
Behdad Esfahbod
997dacbde1 am f3879f9b: Initialize MinikinPaint members
* commit 'f3879f9b1f5593552e96cd0f3c2cf755c376fb85':
  Initialize MinikinPaint members
2014-07-29 21:01:36 +00:00
Behdad Esfahbod
8bee8f92e0 Fix examples build
Was broken after recent CSS removal.

Change-Id: I160fbc73286b21336d6f3943ff92d7d150dff74b
2014-07-29 16:57:00 -04:00
Behdad Esfahbod
f3879f9b1f 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
b501846d80 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
2d51f518d2 Merge "Remove CSS string doLayout entrypoint and supporting code" into lmp-dev 2014-07-27 22:35:46 +00:00
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