summaryrefslogtreecommitdiffstats
path: root/libs
Commit message (Collapse)AuthorAgeFilesLines
* Add error logging on invalid cmapRaph Levien2016-03-011-0/+3
| | | | | | | | This patch logs instances of fonts with invalid cmap tables. Bug: 25645298 Bug: 26413177 Change-Id: I183985e9784a97a2b4307a22e036382b1fc90e5e
* Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: ↵Raph Levien2016-01-152-16/+27
|\ | | | | | | | | | | | | | | | | a3df6da30b am: e82552ae00 am: 545b36d667 am: 98dd15e2cd * commit '98dd15e2cde1eb1835753c9af66d630779c18bc0': Reject fonts with invalid ranges in cmap
| * Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: ↵Raph Levien2016-01-152-16/+27
| |\ | | | | | | | | | | | | | | | | | | | | | | | | a3df6da30b am: e82552ae00 am: 545b36d667 * commit '545b36d667c5b13c1b397b4c5ece20f097bf1f8b': Reject fonts with invalid ranges in cmap
| | * Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4ab am: ↵Raph Levien2016-01-152-16/+27
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a3df6da30b am: e82552ae00 * commit 'e82552ae0094efdb1b1b40ebfc832540eeb1234b': Reject fonts with invalid ranges in cmap
| | | * Reject fonts with invalid ranges in cmap am: ca8ac8acda am: 3034e8b4abRaph Levien2016-01-152-16/+27
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: a3df6da30b * commit 'a3df6da30bdfda0b5b188e6511deeffddeeb9409': Reject fonts with invalid ranges in cmap
| | | | * Reject fonts with invalid ranges in cmap am: ca8ac8acdaRaph Levien2016-01-152-16/+27
| | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: 3034e8b4ab * commit '3034e8b4ab627278b88faae2f4813562f31a7c2b': Reject fonts with invalid ranges in cmap
| | | | | * Reject fonts with invalid ranges in cmapRaph Levien2016-01-152-16/+27
| | | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: ca8ac8acda * commit 'ca8ac8acdad662230ae37998c6c4091bb39402b6': Reject fonts with invalid ranges in cmap
| | | | | | * Reject fonts with invalid ranges in cmapRaph Levien2016-01-072-16/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A corrupt or malicious font may have a negative size in its cmap range, which in turn could lead to memory corruption. This patch detects the case and rejects the font, and also includes an assertion in the sparse bit set implementation if we missed any such case. External issue: https://code.google.com/p/android/issues/detail?id=192618 Bug: 26413177 Change-Id: Icc0c80e4ef389abba0964495b89aa0fae3e9f4b2
* | | | | | | Tailor grapheme boundaries so sequence emoji are one grapheme - DO NOT MERGERaph Levien2016-01-131-0/+26
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make it so it's not possible to position the cursor inside an emoji formed by a sequence including zero-width joiners. Bug: 25368653 Change-Id: I67ec0874cd1505f3c82ab91492ffc3d39a52fae6
* | | | | | Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ↵Raph Levien2015-12-081-3/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ffadd191a0 am: d56908571d am: 7aec64b909 * commit '7aec64b9099d0b5bbbe766a2c29b9f09f0939a4c': Avoid integer overflows in parsing fonts
| * | | | | Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985 am: ↵Raph Levien2015-12-081-3/+6
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ffadd191a0 am: d56908571d * commit 'd56908571d3dc28686a198484d1cc8a399276d86': Avoid integer overflows in parsing fonts
| | * | | | Avoid integer overflows in parsing fonts am: 6299a6ba13 am: 998293f985Raph Levien2015-12-081-3/+6
| | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: ffadd191a0 * commit 'ffadd191a041f16c52b693d8dc0c42b3b9f01b2b': Avoid integer overflows in parsing fonts
| | | * | | Avoid integer overflows in parsing fonts am: 6299a6ba13Raph Levien2015-12-081-3/+6
| | | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: 998293f985 * commit '998293f985dc6c23f90b160f3bc647807c76d3fe': Avoid integer overflows in parsing fonts
| | | | * | Avoid integer overflows in parsing fontsRaph Levien2015-12-081-3/+6
| | | | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | am: 6299a6ba13 * commit '6299a6ba13906c695f7a4f6748f7bc5856a110e5': Avoid integer overflows in parsing fonts
| | | | | * Avoid integer overflows in parsing fontsRaph Levien2015-12-071-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A malformed TTF can cause size calculations to overflow. This patch checks the maximum reasonable value so that the total size fits in 32 bits. It also adds some explicit casting to avoid possible technical undefined behavior when parsing sized unsigned values. Bug: 25645298 Change-Id: Id4716132041a6f4f1fbb73ec4e445391cf7d9616 (cherry picked from commit 183c9ec2800baa2ce099ee260c6cbc6121cf1274)
* | | | | | Suppress linebreaks in emoji ZWJ sequences - DO NOT MERGERaph Levien2015-11-031-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the way emoji ZWJ sequences are defined, the ICU line breaking algorithm determines that there are valid line breaks inside the sequence. This patch suppresses these line breaks. Bug: 25433289 Change-Id: I225ebebc0f4186e4b8f48fee399c4a62b3f0218a
* | | | | | Accept variation selector in emoji sequences - DO NOT MERGERaph Levien2015-10-291-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch basically ignores variation selectors for the purpose of itemization into font runs. This allows GSUB to be applied when input sequences contain variation selectors. Bug: 25368653 Change-Id: I9c1d325ae0cd322c21b7e850d0ec4d73551b2372
* | | | | | Complete half-done cherry-picking of Android.mk. DO NOT MERGERoozbeh Pournader2015-10-141-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous commit, 6e2cccdc518f8d3424c84ae6fbe0e87ae3c3f66a, was incompletely cherry-picked. This adds the missing parts. Bug: 24570591 Change-Id: I1097c60587fb8a88cfe6b8ffed5b1689d9bdd429
* | | | | | Binary format for hyphenation patternsRaph Levien2015-10-142-100/+197
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the current state, hyphenation in all languages than Sanskrit seems to work (case-folding edge cases). Thus, we just disable Sanskrit. Packed tries are implemented, but not the finite state machine (space/speed tradeoff). This commit contains a throw-away test app, which runs on the host. I think I want to replace it with unit tests, but I'm including it in the CL because it's useful during development. Bug: 21562869 Bug: 21826930 Bug: 23317038 Bug: 23317904 Bug: 24570591 Change-Id: I7479a565a4a062fa319651c2c14c0fa18c5ceaea (cherry picked from commit f0be43de02a1e07308d3d95408349c3c7f973430)
* | | | | Improve fallback where explicit variant is not givenRaph Levien2015-07-291-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In computing scores for which fallback font to choose, a match of a variant given explicitly in the xml config file scores higher than a family with no explicit variant. One consequence is that U+2010 HYPHEN is chosen from the Naskh Arabic font in the fallback case. This patch scores families with no variants as a match (effectively the same as if the xml file specified both variants). Thus, it will choose the first matching font (Roboto), which is a better choice. This patch also revises the list of "sticky" characters to include various hyphens, so Arabic (and potentially other scripts) text that includes hyphens can access the script-specific variants matched to the underlying text. Bug: 22824219 Change-Id: I6ec1043037f89cad50ca99ac24c473395546bcdf
* | | | | Merge "Revert "Allow clusters to start with zero-width characters"" into mnc-devRaph Levien2015-07-211-2/+1
|\ \ \ \ \
| * | | | | Revert "Allow clusters to start with zero-width characters"Raph Levien2015-07-211-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 3e0fc64da064b8c4156daf53242b8eeb47830f64. Bug: 22589743 Bug: 22121742 Change-Id: I7b482ffb8a0ee174ddc804aa890de45bdbd758e3
* | | | | | Consistently apply break opportunities in text spansRaph Levien2015-07-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's essential not to apply a break opportunity within a replacement span, otherwise things can happen such as displaying the span twice. The old code tested this case based on zero-width characters. However, this test was both imprecise, and also in some cases read uninitialized values from the mCharWidths array, which in turn led to inconsistent line breaking of the same text. This patch applies all line break opportunities (as identified by ICU) within text (as opposed to replacement spans), and also applies break opportunities at the beginning and end of replacement spans, but avoids breaks within a replacement span. Bug: 20138621 Change-Id: I36baeb44d6808356649e1bb69ca57f093fc8c723
* | | | | | Use ICU to lowercase words to hyphenate.Roozbeh Pournader2015-07-151-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the standard C tolower() function was used, which didn't support any characters beyond the basic ASCII letters. Bug: 22506121 Change-Id: Ibb81121caa29be44fbb59aa98891e9faafc57592
* | | | | | Add missing hyphen-like characters.Roozbeh Pournader2015-07-151-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds various hyphen-like characters missed in the previous patch, that should disallow automatic hyphenation of words containing them. Bug: 22484266 Change-Id: Ie972cb50384dbe0aa1ab5ec50286b75f9877953a
* | | | | | Avoid re-hyphenating already-hyphenated phrases.Roozbeh Pournader2015-07-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, automatic hyphenation blindly took almost every line breaking opportunity as a word break, so words like "low-budget" were treated as two separate words, "low-", and "budget", each automatically hyphenated. This patch makes sure the subwords in already-hyphenated phrases are not passed to the automatic hyphenator, while keeping the possibility of a potential line break where a hyphen already exists. Bug: 22484266 Bug: 22287425 Change-Id: Ie46dbdd70e993d64a9b9cf44b4ae93b21459dbc2
* | | | | | Add HyphenEdit to layout cacheRaph Levien2015-07-091-1/+4
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We bypass the word layout cache for "complex" cases, which includes things like OpenType features. We were counting a hyphen edit as such a case, but the problem is that we measure a _lot_ of these when doing layout with hyphenation. This patch adds plumbing for hyphen edits to the layout cache, so that word fragments with hyphens can be cached as well. Bug: 22378829 Change-Id: Idba4df4faa14f48a5faccc8a7a7955a36c19ef27
* | | | | Allow clusters to start with zero-width charactersRaph Levien2015-06-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic in getRunAdvance() assumed that any zero-width character was part of the preceding cluster, which is valid most of the time. However, characters such as ZWNBSP (U+FEFF) renders as a zero width glyph and is also a grapheme cluster boundary. This patch adds a clause to handle that case. Bug: 22121742 Change-Id: Iad79a7d988bded1ef05f0fd7905d20669ea22051
* | | | | Fix logspam and incorrect cluster offsetRaph Levien2015-06-292-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Separate additional penalty for last line with hyphenRaph Levien2015-06-241-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent change added a penalty for a hyphen at the last line break, which is visually undesirable. However, the penalty was assessed to "widthScore", which broke the assumption (used for another optimization) that widthScore increases monotonically. This patch separates the penalty into a different parameter, restoring the validity of the monotonicity assumption. Bug: 22066119 Change-Id: I6a47a350ef3ceee2f00ee430d6954d0c307227f0
* | | | | Merge "Use ASCII HYPHEN-MINUS when there's no HYPHEN in the font." into mnc-devRoozbeh Pournader2015-06-121-1/+11
|\ \ \ \ \
| * | | | | 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
* | | | | | Merge "Increase hyphenation penalty for short last line" into mnc-devRaph Levien2015-06-121-63/+37
|\ \ \ \ \ \
| * | | | | | Increase hyphenation penalty for short last lineRaph Levien2015-06-081-63/+37
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tuning for hyphenation parameters. We discourage hyphenation on the last line, but offset this penalty by also applying a penalty for each line, which optimizes for minimizing the number of lines. Thus, when hyphenation can reduce the number of lines, it increases the chance they're used. There's probably more tuning and refinement that can be done, but testing suggests that the tunable parameters are appropriate. Bug: 20883322 Change-Id: Ida7eaf8aced109e426694f5a386924a842d29c4b
* / / / / / Fix: getOffsetForAdvance can return worng offset.Keisuke Kuroyanagi2015-06-101-8/+14
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | searchStart was passed to getRunAdvance, but it can be different from the start that has been used to initialize Layout object. As a result, wrong index could be used in getRunAdvance. Bug: 21744454 Change-Id: Ibe83cc50ed6f0da2a1532318bc224502be350699
* | | | | Merge "Use context start correctly in getRunAdvance" into mnc-devRaph Levien2015-06-011-1/+1
|\ \ \ \ \
| * | | | | Use context start correctly in getRunAdvanceRaph Levien2015-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were not taking context start into account when deciding whether to split a ligature, which was causing inconsistent behavior. This patch consistently references the widths array relative to the start of the context. Bug: 21549197 Change-Id: I7c71e10c1af84354fefe782fc0b87120016e6555
* | | | | | Disable hyphenation for unreasonably long wordsRaph Levien2015-06-011-1/+7
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Very long words cause O(n^2) behavior. These are unlikely to happen in real text, but do happen with synthetic strings, so in those cases we just disable hyphenation. Bug: 20790394 Change-Id: Idf957dd40b24efe1476f619f17093a48b5bc56f7
* | | | | Support hyphenation frequency in Minikin.Roozbeh Pournader2015-05-121-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Three hyphenation frequencies are now supported: kHyphenationFrequency_None, which turns off both automatic hyphenation and soft hyphens. kHyphenationFrequency_Normal, which has aconservative amount of hyphenation useful as a conservative default. kHyphenationFrequency_Full, which has a typographic-quality amount of hyphenation useful for running text and tight screens. Bug: 21038249 Change-Id: I2800f718c887c9389a1a059d7ec07d7fa2ca1dee
* | | | | 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
* | | | | Don't include trailing newline in width for line breakingRaph Levien2015-04-221-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a paragraph with a trailing newline, the width of the newline character was included in the line width for breaking purposes, basically as if it were a non-breaking space. This caused a discrepancy, where Layout.getDesiredWidth() suggested that the text would fit in a single line, but StaticLayout would break it because of the added width of the newline character. The proposed fix is simply to consider newline to be a space that disappears at the end of a line. Bug: 20152308 Change-Id: I539574c5b8ea892c8ed6aca6c59e90ccdf74a680
* | | | | Add functions for measuring cursor positioningRaph Levien2015-04-153-4/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New functions for computing the correspondence between cursor position and advance, respecting grapheme boundaries. Change-Id: I620378d5f64cd74300cd43db522adeb555825dff
* | | | | Rename "margins" to "indents"Raph Levien2015-04-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Add margins array to line widths objectRaph Levien2015-04-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Revert "Fix build: Revert "Add hyphenation to line breaking""Raph Levien2015-03-303-36/+313
| | | | | | | | | | | | | | | | | | | | This reverts commit 0b25d5ac85533f64764a0d53d5e5d33b46b715fa.
* | | | | Fix build: Revert "Add hyphenation to line breaking"Ed Heyl2015-03-303-313/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit daf6a6bdbf2ff1f66496d6200cb253e2f50759d5. Change-Id: I3fed65046274d3aeb748f0730585ab89927f5741
* | | | | Add hyphenation to line breakingRaph Levien2015-03-303-36/+313
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Add LineBreaker to MinikinRaph Levien2015-03-263-13/+302
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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