summaryrefslogtreecommitdiff
path: root/core/java/android/text/TextLine.java
Commit message (Collapse)AuthorAgeFilesLines
* Improve BoringLayout#isBoring for PrecomputedTextSeigo Nonaka2022-02-031-2/+6
| | | | | | | Bug: 216736786 Test: atest PrecomputedTextTest Test: perf score becomes 758,071 -> 110,755 Change-Id: I57d3eb9d1e896ed1c847733c4e96ac52dd97d2c4
* Implement fallback line spacing for BoringLayoutSeigo Nonaka2022-01-121-1/+35
| | | | | | | | | | | | | | | | | | | | | | The fallback line spacing is a feature of extending the line height when the fallback font has taller glyph. This was implemented to StaticLayout in Android P but not yet implemented in BoringLayout. This CL enables this feature to the BoringLayout as well. Not to break existing apps, change this behavior only if the targetSdk version is T or later. This is a 2nd attempt of Ia6d6f9f44e73ddaf5e8fe9a8aead7a53efbddd44 The root cause of SystemUI crash was wrong API usage. (start, end) was passed instead of (start, count). Bug: 210923482 Test: atest FallbackLineSpacingTest BoringLayoutFallbackLineSpacingTest Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Test: atest SystemUITests Change-Id: I9137607b0120934f7ad2a12c0f0b8aaa52915831
* Revert "Implement fallback line spacing for BoringLayout"Shubham Dubey2022-01-101-36/+1
| | | | | | | | | | | | | | | | | | | | | Revert "Add font extent calculation" Revert "Add test case for fallback line spacing" Revert submission 16486662-fallback_line_spacing Reason for revert: Investigate test failures on master BUGID: b/213826416 BUGID: b/213829920 Reverted Changes: I06cd7ab71:Add font extent calculation I6214d52cd:Implement fallback line spacing for BoringLayout Ia5825c474:Add test case for fallback line spacing Change-Id: Ia6d6f9f44e73ddaf5e8fe9a8aead7a53efbddd44
* Implement fallback line spacing for BoringLayoutSeigo Nonaka2022-01-061-1/+36
| | | | | | | | | | | | | | | | | The fallback line spacing is a feature of extending the line height when the fallback font has taller glyph. This was implemented to StaticLayout in Android P but not yet implemented in BoringLayout. This CL enables this feature to the BoringLayout as well. Not to break existing apps, change this behavior only if the targetSdk version is T or later. Bug: 210923482 Test: atest FallbackLineSpacingTest BoringLayoutFallbackLineSpacingTest Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Change-Id: I6214d52cde25a044bc6e246d2118e35d3a243c9d
* Early exit if the target region is emptySeigo Nonaka2021-07-231-1/+1
| | | | | | Bug: 193849901 Test: atest StaticLayoutBidiTouchTest Change-Id: I55f04068a6e5b353867d50742356c272d28886b3
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-4/+4
| | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-4/+4
| | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-4/+4
| | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* Fix wrong offset of BiDi text by TextShaperSeigo Nonaka2020-10-191-1/+2
| | | | | | | | | | | | | | This CL includes: - Fix relative offset of BidiRun by reviving width calculation in TextLine. - Fix bidi level buffer offset. It shuold be relative to the substring, but the absolute offset was passed. - Removed paint argument from PositionedGlyph which is not used. Bug: 171275519 Test: atest android.graphics.text.cts.TextRunShaperTest Test: atest android.text.cts.TextShaperTest Change-Id: I36949089d744bdfae61995210b2051866a7510ac
* Update TextShaper APIs to address API council feedbackSeigo Nonaka2020-10-141-25/+25
| | | | | | | | | | | | | | | | This CL contains followings: - Rename TextShaper to TextRunShaper, StyledTextShaper to TextShaper - Renamed getTotalAdvance to getAdvance - Rename getStyle to getGlyphStyle - Rename getOriginX/Y to getOffsetX/Y - Rename getPositionX/Y to getGlyphX/Y - Fixed some documentation errors. - Remvoed GlyphStyle. Added GlyphConsumer instead. Bug: 170255480 Test: atest TextShaperRunTest GlyphStyleTest TextShaperTest Change-Id: I0ffd7a3374e9cd1e04872240c2d0da26bc530244
* Add TextShaper APISeigo Nonaka2020-09-291-18/+122
| | | | | | | | | | | | | | | | | | | | | | | | | TextShaper API provides a primitive text layout result, e.g. what glyph is used etc. Here is the new APIs and its description - PositionedGlyphs This is a native instance backed object that gives layout information to developers. - GlyphStyle The glyph style is an object that holds the parameters that will be used for drawing. This object is a subset of the Paint object for avoiding creating lots of Paint copy. - TextShaper#shapeText This does a text shaping and gives TextShaper.Result. This is a native backed primitive shaping API. - StyledTextShaper This is a text shaper for a styled text. This will be the top-level developer facing API for shaping text. Bug: 168048923 Test: atest FontTest TextShaperTest StyledTextShaperTest Change-Id: I2e91d1ef8503b25b28efc94da7de7cad49c4c1a9
* Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-071-1/+1
| | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I288969b0c22fa3a63bc2e71bb5009fe4a927e154
* Do not compute outside given range in TextLineSeigo Nonaka2019-09-161-0/+3
| | | | | | | | | | | | This is second attempt of I646851973b3816bf9ba32dfe26748c0345a5a081 which breaks various layout test on application. The empty string must be also handled by the TextLine since it retrieves the default line height from the empty string. Bug: 140632678 Test: StaticLayoutTest Test: Manually done Change-Id: I7089ed9b711dddd7de2b27c9c2fa0fb4cb53a735
* Revert "don't compute outside of visible range"Adam Seaton2019-09-131-3/+0
| | | | | | | | | bug:141016653 This reverts commit 0a57fe099a55ab3a7583b229fa7cfb905d6106f3. Reason for revert: CL is implicated in https://b.corp.google.com/issues/141016653 Change-Id: I39954226cb8971ee17e367692b3fd0e29871ad48
* don't compute outside of visible rangeSeigo Nonaka2019-09-111-0/+3
| | | | | | | Bug: 140632678 Test: manually done Test: TreeHugger Change-Id: I646851973b3816bf9ba32dfe26748c0345a5a081
* Hide packing structure from public APISeigo Nonaka2019-03-111-19/+20
| | | | | | | | | | | | | | | | | | | The hyphen edit is packed into 8bit integer in native library, but this should not be exposed to public API as API council suggested. This CL includes: - Removing packing structure from HyphenEdit and move constants from Hyphenator to Paint. - Replace LineBreaker's getLineHyphenEdit with two separate start/end function. - Replace Paint's getHyphenEdit with two separate start/end function. - StaticLayout still relies on this packing mechanism but no longer need to be the same packing structure as in Minikin. Bug: 124794844 Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Change-Id: I8206061f554cf6e119b2b565162f54317eac630a
* Add maxTargetSDK equals P for UnsupportedAppUsage of sCachedHaoyu Zhang2019-02-061-1/+2
| | | | | | | | | | We figured out this non-SDK API is mainly used for a previous memory workaround. Since the bug was fixed, this API is not allowed to access. Bug: 123768439 Test: N/A Change-Id: Ib04bf7e630aee0896c8432aa9c5b794440ea7a2d
* Fix that TextLine overwrites wordSpcing on paintHaoyu Zhang2019-01-081-6/+13
| | | | | | | | | | | TextLine is using wordSpcing for justification. And previously, TextLine will overwrite wordSpcing even justification is not on. This CL make sure that TextLine only changes wordSpcing when justification is on. Bug: 122471618 Test: atest TextLineTest Change-Id: I6f1e2f6c17b65f92d7a5bb064fdafbf5df9ef8f7
* Merge "Revert "Revert "Refactor TextLine class"""TreeHugger Robot2018-11-171-142/+94
|\
| * Revert "Revert "Refactor TextLine class""Siyamed Sinir2018-11-161-142/+94
| | | | | | | | | | | | | | | | This reverts commit 3c097aa45e1fc8c03e09aea09a0dc3596b82c761. Reason for revert: we thought this CL caused b/119659731 but apparently it is not. Change-Id: Id375c4c8f2bffb7c42dc36bc053d536c6ea57a8d
* | Merge "Revert "Revert "Enable PrecomputedText for BiDi text"""TreeHugger Robot2018-11-171-2/+1
|\ \ | |/ |/|
| * Revert "Revert "Enable PrecomputedText for BiDi text""Siyamed Sinir2018-11-161-2/+1
| | | | | | | | | | | | | | | | This reverts commit 321140ad8464dfd22af7ae8d71daa11337680f1d. Reason for revert: we thought this CL caused b/119659731 but apparently it is not. Change-Id: I5b52cc1facec77d6a0d844bcaac53e90c7ecd132
| * Revert "Enable PrecomputedText for BiDi text"Siyamed Sinir2018-11-161-1/+2
| | | | | | | | | | | | | | | | This reverts commit 6224e238d6f0c48b419b99d6889997d83350f4e6. Reason for revert: b/119659731 Change-Id: I33ea82d69d09f113d594446f8979f0df21200662
| * Enable PrecomputedText for BiDi textSeigo Nonaka2018-11-141-2/+1
| | | | | | | | | | | | | | | | Bug: 119312268 Test: atest CtsTextTestCases Test: atest CtsWidgetTestCases Test: atest CtsGraphicsTestCases Change-Id: Ifddf5a35642a22cbb1665fce65c467e6b21bfea6
* | Revert "Refactor TextLine class"Siyamed Sinir2018-11-161-94/+142
|/ | | | | | | | This reverts commit 888dbca2f720ae2ae52dce1d88063e46e3b53c28. Reason for revert: <INSERT REASONING HERE> Change-Id: I259327a6ca507e2614cacdcdabdeca7df48b8ed2
* Refactor TextLine classSeigo Nonaka2018-11-141-142/+94
| | | | | | | | | | | | | | | | Did following refactoring: - The surrogate composition is not necessary since this method is only interested in TAB character. - Move BiDi information interpretation logic to Layout.Directions. - The short circuit for DIRS_ALL_LEFT_TO_RIGHT/DIRS_ALL_RIGHT_TO_LEFT is not necessary. - Renamed the variables. Bug: 119312268 Test: atest TextLineTest Test: TreeHugger Test: Verified locally this doesn't cause performance regression Change-Id: If987387673ec5a22f703952dfbe45b084664ee59
* Merge "Move hasEqualAttribute from Paint with adding some accessors"Seigo Nonaka2018-09-251-1/+39
|\
| * Move hasEqualAttribute from Paint with adding some accessorsSeigo Nonaka2018-09-181-1/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Paint#hasEqualAttributes is not a equal method in Paint. TextLine depends on this method but making this public will make developer confused. So, moving hasEqualAttributes to TextLine and provide some accessors for shadow layer parameters. For the TextPaint, unhide underlineColor and underlineThckness for implementing equalAttributes in TextLine. Bug: 112327179 Test: atest android.graphics.cts.PaintTest Change-Id: I4565e18134856e31d26bd06bcddeb31ddbe7e093
* | Unhide getTextRunCursor APIsSeigo Nonaka2018-09-181-3/+2
|/ | | | | | | | This API is necessary for identifying the cursor locations. Bug: 112327179 Test: atest android.graphics.cts.PaintTest Change-Id: Ief6770bd622a296ae356094fe3ce58e9c4371088
* Move some members to the "Q blacklist".Mathew Inwood2018-09-141-1/+2
| | | | | | | | | | | | | | Based on some analysis, these fields/methods are likely false positives. Set maxTargetSdk=P so that any apps using them are required to migrate off them in future. See the bug for more details. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
* Unhide HyphenEdit related methodsSeigo Nonaka2018-09-101-3/+6
| | | | | | | | These APIs are necessary to implement hyphenation by third party developers. Bug: 112327179 Test: atest android.graphics.cts.PaintTest#testSetGetHyphenEdit Change-Id: I692a56d3d1b15100503eb6d8e0f59d6c5c8af81b
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-151-0/+8
| | | | | | | | | | | | | | | | | | | | For packages: android.text.util android.text.style android.text.method android.text.format android.text This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I9afbd4ca8826c37cb70db43252e39b9a674e5ae0
* Supress text replacement spans for ellipsisMihai Popa2018-05-301-6/+23
| | | | | | | | | | | | | | | | | | | When a sequence of characters belonging to a text is ellipsized, we usually replace the first characters with ... and then all the others with a 0 width character, knowing that they will be drawn, but will be invisible. However, these positions could have had ReplacementSpans attached to them, such as EmojiTypefaceSpan when the EmojiCompat library is used. When this happened, all the ellipsized out characters were invisible, apart from emojis, which were still drawn as usual (as they were replacing sequences of 0 width characters). This CL fixes this behaviour, by skipping those ReplacementSpans that were completely included in ellipsis. Please check the bug for a more detailed explanation. Bug: 69802699 Test: manual testing Test: atest FrameworksCoreTests:android.text.TextLineTest Change-Id: If9758537948abaa0226fe6b551a703110c5457b9
* Optimise the hit test algorithmMihai Popa2018-05-221-0/+93
| | | | | | | | | | | | | | | | | | | | | | | | | Layout#getOffsetForHorizontal was running in O(n^2) time, where n is the length of the current line. The method is used when a touch event happens on a text line, to compute the cursor offset (and the character) where it happened. Although this is not an issue in common usecases, where the number of characters on a line is relatively small, this can be very inefficient as a consequence of Unicode containing 0-width (invisible) characters. Specifically, there are characters defining the text direction (LTR or RTL), which cause our algorithm to touch the worst case quadratic runtime. For example, a person is able to send a message containing a few visible characters, and also a lot of these direction changing invisible ones. When the receiver touches the message (causing the Layout#getOffsetForHorizontal method to be called), the receiver's application would become not responsive. This CL optimizes the method to run in O(n) worst case. This is achieved by computing the measurements of all line prefixes at first, which can be done in a single pass. Then, all the prefix measurement queries will be answered in O(1), rather than O(n) as it was happening before. Bug: 79215201 Test: manual testing Change-Id: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
* Reorder the drawing of underline/stroke and textSeigo Nonaka2018-05-211-2/+3
| | | | | | | | | | | | | | | | | The underline and stroke should be top of the text. This regression happens on O-MR1 and the root cause is still unknown, but the drawning underline/stroke should do before drawing text. Bug: 79906191 Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases FrameworksCoreTests:android.text CtsWidgetTestCases:TextViewPrecomputedTextTest Change-Id: Idc2f99b9c0fa125af331e496da8daa326d14bfac
* Add TextLayout.measure test casesSeigo Nonaka2018-05-161-1/+1
| | | | | | Bug: 78464361 Test: atest android.text.TextLineTest Change-Id: I62e05d4fe18c115060da918a2c9105f0e94fe4b0
* Fix BoringLayout with PrecomputedTextSeigo Nonaka2018-03-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | The special logic for PrecomputedText in BoringLayout has problem. The special logic is no longer necessary since TextLine is now aware of PrecomputedText. So, just removing special logic from BoringLayout. On the other hand, the metrics parameters check in TextLine has removed Ie73bce52c6c673cda58973ddad04627a7cf2e5e9, but that was wrong. TextLine can be used by BoringLayout too. Thus, need to reject PrecomputedText if the given TextPaint is not compatible with given param. Bug: 76227465 Test: atest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest CtsTextTestCases FrameworksCoreTests:android.text CtsWidgetTestCases:TextViewPrecomputedTextTest Change-Id: I172b5f655402e797b53b9667b49cb4ab89ec0dc0
* Reorganize MeasuredText API (2nd)Seigo Nonaka2018-02-161-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | This is 2nd attempt of I7db9e2ca4db68a16648cfb8fcf63555f501304c2 This CL changes the MeasuredText API: - Rename MeasuredText to PrecomputedText. - Introduce PrecomputedText.Param which holds all text layout parameters. - Add API to get PrecomputedText.Param from TextView. - Remove MeasuredText.Builder and add PrecomputedText.create method instead. - Remove setRange from MeasuredText since it is not for normal use case. (It can not be used for TextView) Bug: 67504091 Bug: 72861572 Test: bit FrameworksCoreTests:android.text. Test: atest CtsWidgetTestCases:EditTextTest \ CtsWidgetTestCases:TextViewFadingEdgeTest \ FrameworksCoreTests:TextViewFallbackLineSpacingTest \ FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \ CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \ CtsTextTestCases Change-Id: Ie73bce52c6c673cda58973ddad04627a7cf2e5e9
* Revert "Reorganize MeasuredText API"Seigo Nonaka2018-02-141-28/+14
| | | | | | | | | | The last change needs more discussion and found some edge cases. Revert and make small step-by-step changes. Bug: 73091756 This reverts commit 7fd36d19e309ea515b4048cfaabb8035ceab7baf. Change-Id: I89ff52a70cf6a5d6c553afa20f83719e1f9eb726
* Reorganize MeasuredText APISeigo Nonaka2018-02-121-14/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL changes the MeasuredText API: - Rename MeasuredText to PrecomputedText. - PrecomputedText is no longer a Spanned. - Introduce PrecomputedText.Param which holds all text layout parameters. - Add API to get PrecomputedText.Param from TextView. - Remove MeasuredText.Builder and add PrecomputedText.create method instead. - Remove setRange from MeasuredText since it is not for normal use case. (It can not be used for TextView) Here is a performance scores: (median, walleye-userdebug, N=20) StaticLayout creation time (w/o patch -> w/ patch) PrecomputedText Balanced Hyphenation : 743,615 -> 737,145: (-0.9%) PrecomputedText Balanced NoHyphenation: 551,544 -> 542,715: (-1.6%) PrecomputedText Greedy Hyphenation : 500,343 -> 499,601: (-0.1%) PrecomputedText Greedy NoHyphenation : 497,987 -> 492,587: (-1.1%) RandomText Balanced Hyphenation : 19,100,592 -> 19,135,289: (+0.2%) RandomText Balanced NoHyphenation : 8,015,088 -> 7,954,260: (-0.8%) RandomText Greedy Hyphenation : 7,950,915 -> 7,877,424: (-0.9%) RandomText Greedy NoHyphenation : 7,939,337 -> 7,863,471: (-1.0%) PrecomputedText creation time (w/o patch -> w/ patch) NoStyled Hyphenation : 18,935,638 -> 18,925,422: (-0.1%) NoStyled Hyphenation WidthOnly : 18,469,726 -> 18,978,413: (+2.8%) NoStyled NoHyphenation : 7,940,792 -> 7,919,127: (-0.3%) NoStyled NoHyphenation WidthOnly : 7,463,230 -> 7,922,643: (+6.2%) Styled Hyphenation : 14,822,501 -> 14,809,017: (-0.1%) Styled Hyphenation WidthOnly : 13,891,770 -> 14,656,617: (+5.5%) Styled NoHyphenation : 14,511,134 -> 14,301,503: (-1.4%) Styled NoHyphenation WidthOnly : 13,495,345 -> 14,264,314: (+5.7%) StaticLayout draw time (w/o patch -> w/ patch) PrecomputedText NoStyled : 663,974 -> 661,610: (-0.4%) PrecomputedText NoStyled WithoutCache : 648,294 -> 648,766: (+0.1%) PrecomputedText Styled : 879,322 -> 852,770: (-3.0%) PrecomputedText Styled WithoutCache : 1,084,570 -> 1,110,147: (+2.4%) RandomText NoStyled : 565,682 -> 555,435: (-1.8%) RandomText NoStyled WithoutCache : 9,070,533 -> 9,064,825: (-0.1%) RandomText Styled : 2,955,202 -> 2,962,008: (+0.2%) RandomText Styled WithoutCache : 12,242,325 -> 12,228,573: (-0.1%) Bug: 67504091 Bug: 73091756 Test: bit FrameworksCoreTests:android.text. Test: atest CtsWidgetTestCases:EditTextTest \ CtsWidgetTestCases:TextViewFadingEdgeTest \ FrameworksCoreTests:TextViewFallbackLineSpacingTest \ FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \ CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \ CtsTextTestCases Change-Id: I7db9e2ca4db68a16648cfb8fcf63555f501304c2
* Compute full text layout in MeasuredText and use it for drawingSeigo Nonaka2018-01-231-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The full layout is required for drawing text on UI thread. To save this work, store the full layout result in MeasuredText and compose the final layout from stored full layout if possible. Currently justification/hyphenation is not supported but works normally as before. Nothing changes on existing non measured text. StaticLayout creation time for no style text (w/o patch -> w/ patch, N=30) MeasuredText Balanced Hyphenation : 721,297 -> 720,657: (-0.1%) MeasuredText Balanced NoHyphenation: 550,588 -> 546,069: (-0.8%) MeasuredText Greedy Hyphenation : 503,582 -> 498,009: (-1.1%) MeasuredText Greedy NoHyphenation : 502,344 -> 498,507: (-0.8%) RandomText Balanced Hyphenation : 19,351,802 -> 19,176,024: (-0.9%) RandomText Balanced NoHyphenation : 8,033,830 -> 7,973,336: (-0.8%) RandomText Greedy Hyphenation : 7,957,335 -> 7,927,316: (-0.4%) RandomText Greedy NoHyphenation : 7,988,884 -> 7,929,717: (-0.7%) StaticLayout.draw time for no style text (w/o patch -> w/ patch, N=30) MeasuredText NoStyled : 644,453 -> 660,684: (+2.5%) MeasuredText NoStyled WithoutCache : 9,251,919 -> 648,992: (-93.0%) MeasuredText Styled : 3,092,353 -> 870,702: (-71.8%) MeasuredText Styled WithoutCache : 12,544,014 -> 1,114,557: (-91.1%) RandomText NoStyled : 582,167 -> 572,092: (-1.7%) RandomText NoStyled WithoutCache : 9,167,670 -> 9,056,447: (-1.2%) RandomText Styled : 3,064,490 -> 3,029,028: (-1.2%) RandomText Styled WithoutCache : 12,314,863 -> 12,283,026: (-0.3%) Test: minikin_test Test: bit CtsTextTestCases:* Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest Test: bit FrameworksCoreTests:android.text.MeasuredParagraphTest Bug: 63897135 Change-Id: I7e6ec5c953d7d0f767aba4f61f94e62b6f3a3a2b
* Fix space counting for justified textRoozbeh Pournader2017-10-241-18/+20
| | | | | | | | | | | | | | | | Previously, the number of stretchable spaces in a line were miscounted, always returning one more than the actual number. We now count them correctly. Also, disable NBSP as an stretchable space, since in some use cases it should not stretch and the implementation in Minikin was broken anyway. Test: Manual (justified text is now properly aligned on right side) Test: bit FrameworksCoreTests:android.text.TextLineTest Fixes: 68009059 Bug: 68204709 Change-Id: I473415a2a51eec75377d6ffc4a9adddc2033d360
* Removed unused variables from text layout codeSiyamed Sinir2017-10-101-5/+5
| | | | Test: None Change-Id: I890c3d260edd0570259db5089dcb37f79c2e56e9
* Make strike-through respect kerning at boundariesRoozbeh Pournader2017-07-131-45/+58
| | | | | | | | | | | | | | Also clean up lower-level drawing of strike-through in Cavas.cpp. We still cannot use the strike-through information from the font since Skia doesn't provide it, so we are going with the default values. Test: Manual Test: bit CtsTextTestCases:* Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner Bug: 32907446 Change-Id: Iee6f8102a35eba0ff4127dbbef189529ab573e6d
* Merge "Get underline position and thickness from the font"Roozbeh Pournader2017-06-091-1/+3
|\
| * Get underline position and thickness from the fontRoozbeh Pournader2017-06-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, font underline position and thickness were fixed in Android. Although a custom font may have specified a different value, such a value would never be used. Now we use the values from the font if they are provided and fall back to the old default values only if needed. Bug: 62353930 Test: adb shell am instrument -w -e package android.graphics com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner Test: cts-tradefed run cts-dev --module CtsTextTestCases Test: Manual Change-Id: I6bf21000dd69a2780c894b231638bc0c122e41f4
* | Merge "Early exit if there are no spans affecting display"TreeHugger Robot2017-06-071-3/+10
|\ \ | |/ |/|
| * Early exit if there are no spans affecting displayRoozbeh Pournader2017-06-071-3/+10
| | | | | | | | | | | | | | | | | | | | | | In TextLine#handleRun(), exit early and shape the text as one whole if there were spans, but none of them were a subclass of MetricAffectingSpan or CharacterStyle. Change-Id: I859c896ddb9c4828bfddf200e913e98262da6ea3 Fixes: 30985144 Test: cts-tradefed run cts-dev --module CtsTextTestCases Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
* | Move underline thickness and position computation to PaintRoozbeh Pournader2017-06-051-7/+4
|/ | | | | | | | | | | | Also, in TextLine, fix underline color and thickness to come from the underline info rather than the TextPaint object. Bug: 32907446 Bug: 62353930 Test: Manual Test: cts-tradefed run cts-dev --module CtsTextTestCases Test: cts-tradefed run cts-dev --module CtsWidgetTestCases Change-Id: I259e9cf635a7056ccd367baa77c03100c69e3b98
* Make underlining spans independent of actual classRoozbeh Pournader2017-06-011-43/+172
| | | | | | | | | | | | | | | | | | Previously, we had singled out UnderlineSpan for special treatment for proper kerning at span boundaries. That had the limitation that any other span that used underlining, or even subclasses of UnderlineSpan were not getting the fix. With this CL, we actually look at all the effects of applying a span's updateDrawState() and if the changes were only in underlining, we merge the pieces and call handleText() on the merged chunk of text. Change-Id: I829162c758192b80594f164d1105699224b627ba Bug: 32907446 Test: cts-tradefed run cts-dev --module CtsTextTestCases Test: cts-tradefed run cts-dev --module CtsWidgetTestCases Test: manual