summaryrefslogtreecommitdiffstats
path: root/libs/minikin/Layout.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix logspam and incorrect cluster offsetRaph Levien2015-06-291-1/+1
| | | | | | | | | An incorrect cluster offset calculation was causing a lot of log messages to appear. Separately, a confusion between #if and #ifdef was causing unintended logging of line breaks. This patch fixes both. Bug: 22178333 Change-Id: I2b3673ed66c784f5082fd127a8dc10bd3df6ed79
* Disable letterspacing for connected scriptsRaph Levien2015-06-261-9/+38
| | | | | | | | | | | The appearance of letterspacing with scripts with cursive connections is poor, so we simply disable letterspacing for those scripts. There may be some cases where some form of letterspacing is desirable, but this gives the highest likelihood that the final result will be good without requiring additional work from clients. Bug: 21935803 Change-Id: Ie25266249ac3a2605aa89ef5132e8edbe3a06d35
* Use ASCII HYPHEN-MINUS when there's no HYPHEN in the font.Roozbeh Pournader2015-06-121-1/+11
| | | | | | | | | | | | | | | | | | Previously, we just assumed the font in use had a U+2010 HYPHEN character, resulting in a tofu (or an empty space) being shown when U+2010 was not supported in the font used to render the hyphenated word. Now we try to fallback to U+002D HYPHEN-MINUS, which has a very good chance of being available in at least any Latin font. We still show a tofu when neither character is supported, to intentionally alert that something is missing. Bug: 20497913 Bug: 21088552 Bug: 21570828 Change-Id: Iff69bbc38836c03495e9124502b5207c39270da2
* Move Bitmap to a different namespaceJohn Reck2015-04-271-39/+43
| | | | | | | namespace naming collision. Move minikin's Bitmap out of android:: and into minikin:: Change-Id: I5ae3925f81b848dc79576429ab55243b96f7fed2
* Add LineBreaker to MinikinRaph Levien2015-03-261-13/+0
| | | | | | | | | | | | | 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
* HyphenEdit in support of hyphenationRaph Levien2015-03-121-1/+17
| | | | | | | | 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
* Disable HarfBuzz's fallback to compatibility decompositionsRoozbeh Pournader2015-02-251-2/+13
| | | | | | | | | | | | | 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
* am 919fbb99: am cb20a2f0: Minikin: Remove unused variables, fix init orderAndreas Gampe2014-12-041-3/+3
|\ | | | | | | | | * commit '919fbb99f1d5d0c95bf165cec9b7b178b42908ec': Minikin: Remove unused variables, fix init order
| * Minikin: Remove unused variables, fix init orderAndreas Gampe2014-12-031-3/+3
| | | | | | | | | | | | | | | | | | For build-system CFLAGS clean-up, fix unused variables. Reorder initializer list to initialize in the order of member declarations. Change-Id: I64358b2dcf0e39d0f4e18fdc3473de867f84fcba
* | am dc81fbad: am 69d4fba2: Move frameworks/minikin over to libc++.Dan Albert2014-11-121-3/+5
|\| | | | | | | | | * commit 'dc81fbad809f08564199c8f08df7e7f72310961a': Move frameworks/minikin over to libc++.
| * Move frameworks/minikin over to libc++.Dan Albert2014-11-111-3/+5
| | | | | | | | | | Bug: 15193147 Change-Id: I5e15c95415c39515340e2663acd5fd26666db720
* | am 6740536e: Snap advance widths to integersRaph Levien2014-09-041-8/+18
|\| | | | | | | | | * commit '6740536e3927d25bf5c2567e5f6e8c175973cbb7': Snap advance widths to integers
| * Snap advance widths to integersRaph Levien2014-09-031-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | am 56c7fb8c: Allocate font vector on stackBehdad Esfahbod2014-08-221-3/+12
|\| | | | | | | | | * commit '56c7fb8c0633f1b02115bb4370854016f8c84fb4': Allocate font vector on stack
| * Allocate font vector on stackBehdad Esfahbod2014-08-211-3/+12
| | | | | | | | | | | | | | | | This reduces another allocation (last one?) we were doing when fulfilling shaping requests from the cache. Bug: 17111260 Change-Id: Ieb8ae1ccfcaacedb257e1e9263777f10623aaf98
* | am 6da7796c: Fix Layout initialization in the skipCache pathBehdad Esfahbod2014-08-211-6/+11
|\| | | | | | | | | * commit '6da7796cbe8a17efd61a3302369e69bb222fdb4f': Fix Layout initialization in the skipCache path
| * Fix Layout initialization in the skipCache pathBehdad Esfahbod2014-08-211-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | am 288c9159: Speed up cache lookupBehdad Esfahbod2014-08-211-35/+64
|\| | | | | | | | | * commit '288c915963b3500c7efb958ba613650e2ecdfdfa': Speed up cache lookup
| * Speed up cache lookupBehdad Esfahbod2014-08-211-35/+64
| | | | | | | | | | | | | | Avoid copying the string for cache lookup. Bug: 17111260 Change-Id: Ic220bfc991fc6b3dada197304aabdf72a8941bd7
* | am 5986f604: Support fontFeatureSettingsBehdad Esfahbod2014-07-301-12/+23
|\| | | | | | | | | * commit '5986f6048ae21e0ec094c1f2ca0169d0ca6ec6b5': Support fontFeatureSettings
| * Support fontFeatureSettingsBehdad Esfahbod2014-07-301-12/+23
| | | | | | | | | | Bug: 15246510 Change-Id: I544915d29b2be4fb9f82f1989188a3a918c50fbc
* | am d50c99df: Merge "Remove CSS string doLayout entrypoint and supporting ↵Behdad Esfahbod2014-07-291-45/+0
|\| | | | | | | | | | | | | code" into lmp-dev * commit 'd50c99df4efbc57eb4419bd7944a979b9a1d53cc': Remove CSS string doLayout entrypoint and supporting code
| * Remove CSS string doLayout entrypoint and supporting codeBehdad Esfahbod2014-07-291-45/+0
| | | | | | | | | | | | | | All usage is ported to the new doLayout() API now. Bug: 16651112 Change-Id: I2c959138a69853b5e30098889d771fe5f4cfaa66
* | Merge "Revert "Don't pass invalid Unicode codepoint to Skia""Behdad Esfahbod2014-07-241-6/+0
|\ \ | |/ |/|
| * Revert "Don't pass invalid Unicode codepoint to Skia"Behdad Esfahbod2014-07-251-6/+0
| | | | | | | | | | | | | | | | 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 4422f4dd941628ad289bcabc75fbd788d37415f6. Change-Id: Icfd0dc836a8d684fb1723fc215aa01f99639ff59
* | Add doLayout variant that does NOT take css stringBehdad Esfahbod2014-07-291-8/+20
| | | | | | | | | | | | | | New API removes CSS string and directly takes needed objects. Bug: 16651112 Change-Id: Ie5f7c2ab05be6cbd77cae0a5fd6bb453771ada59
* | Merge "Don't get stuck on invalid UTF-16" into lmp-devBehdad Esfahbod2014-07-241-4/+3
|\ \
| * | Don't get stuck on invalid UTF-16Behdad Esfahbod2014-07-251-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | Replaces invalid unicode with replacement character U+FFFD and always makes forward progress. Bug: 15849380 Change-Id: Ic59ef6c64b0f5c4450bcae61597adcc269d6e7c5
* | | Towards CSS removalBehdad Esfahbod2014-07-241-16/+18
|/ / | | | | | | | | | | | | Extract language from FontStyle during shaping. Don't attach CSS to LayoutContext. Change-Id: Ie621d3415410178d0d15fa7b810eb8e412342ab6
* | Remove deprecated APIBehdad Esfahbod2014-07-241-9/+0
| | | | | | | | | | | | It has been unused outside minikin. Change-Id: Iaa2237767d81c77f90d0264e633375e601dd72f1
* | Add letter-spacing supportBehdad Esfahbod2014-07-221-4/+41
|/ | | | | Bug: 15594400 Change-Id: Ied94d7674be4097b0f44c9b0770d3294dc6433c1
* Don't pass invalid Unicode codepoint to SkiaBehdad Esfahbod2014-07-111-0/+6
| | | | | Bug: 15849380 Change-Id: Ib5285e57c5806bd399600fadd56e8bc809da323f
* Disable "palt" OpenType featureRaph Levien2014-06-261-0/+6
| | | | | | | | 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
* Add purgeCaches() methodRaph Levien2014-06-251-0/+8
| | | | | | | Expose a method to purge caches used for TextLayout, useful for low memory conditions. Change-Id: I92f41afe987b7be4af5ca0a0c50fb51be35a2758
* Merge "Provisionally enable "palt" OpenType feature"Raph Levien2014-06-101-1/+10
|\
| * Provisionally enable "palt" OpenType featureRaph Levien2014-06-071-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Support for fake bold and italicsRaph Levien2014-06-101-8/+14
|/ | | | | | | | | | 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
* Support for context in APIRaph Levien2014-06-051-21/+14
| | | | | | | | | | 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
* Make paint flags consistently uint32_tRaph Levien2014-06-051-4/+4
| | | | | | | | | 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
* Fix unmatching typeRaph Levien2014-06-041-1/+1
| | | | | | | Missed a slightly mismatched type (int vs int32_t) from a previous code review. Change-Id: Ib56775a3a1a6ec3763da7f7432186954251cc048
* Support for scaleX and skewXRaph Levien2014-06-031-13/+30
| | | | | | | | | | | 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
* Language and variant selectionRaph Levien2014-05-291-3/+15
| | | | | | | | | | | | | | 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
* Fix for Minikin native crashRaph Levien2014-05-291-1/+1
| | | | | | | | | | | 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
* Fix for bug 15252902 native crash in MinikinRaph Levien2014-05-271-4/+4
| | | | | | | | | | 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
* Caching for layouts and harfbuzz facesRaph Levien2014-05-271-64/+322
| | | | | | | | | | | | | | | | | 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
* Do BiDi algorithm for text layoutRaph Levien2014-05-271-9/+79
| | | | | | | | | | | | | 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)
* Fix incomplete refcounting and lockingRaph Levien2014-05-191-0/+7
| | | | | | | | 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
* Initial BiDi supportRaph Levien2014-05-141-2/+11
| | | | | | | | | | | | | | 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
* Fix 64-bit cleanliness problemRaph Levien2014-05-141-2/+2
| | | | | | This patch fixes a problem where int and ssize_t were being conflated. Change-Id: I642a4ee1d59d81723034fdfe33bd8ca29a5dc322
* Better refcounting and lockingRaph Levien2014-05-121-5/+2
| | | | | | | | | | | All major externally accessible objects (especially FontFamily and FontCollection) are now reference counted. In addition, there is a global lock intended to make operations thread-safe. WIP notice: in this version of the patch, not all external API entry points are protected by the lock. That should be fixed. Change-Id: I14106196e99eb101e8bf1bcb4b81359759d2086c