113 Commits

Author SHA1 Message Date
Jason Simmons
6961f993c7
libtxt: use a fixed set of font manager roles instead of a list of font managers (#4756)
Prior to this, the engine was adding font managers to the list every time the
app restarts (e.g. after a suspend-and-resume cycle), causing a leak.
2018-03-08 12:40:08 -08:00
Alexander Aprelev
54cda7b27a
Revert "Migrate all uses of gtest to googletest (#4728)" (#4750)
* Merge

* Update license hash
2018-03-06 09:46:24 -08:00
Petr Hosek
15bb1e9cb9
Migrate all uses of gtest to googletest (#4728)
gtest is an old version that predates the googletest and googlemock
merger, all tests should be using the newer googletest that's being
kept in sync with the upstream version.
2018-03-06 01:06:32 -08:00
Jason Simmons
9c6e29c470
libtxt: lazily populate the fallback font cache (#4720) 2018-02-27 17:09:56 -08:00
Jason Simmons
1cab96c6eb
libtxt: miscellaneous cleanup (#4679)
* use TextDecoration enums
* replace GetBlobLength with a function that returns runs based on typeface
* a few other minor style fixes
2018-02-15 09:54:54 -08:00
Jason Simmons
468935eb85
libtxt: specifically request the Roboto font in tests and benchmarks (#4675) 2018-02-14 10:01:01 -08:00
Jason Simmons
a301ff86d1
Restore minikin code that had been disabled due to older versions of ICU and HarfBuzz (#4671) 2018-02-13 15:47:36 -08:00
Jason Simmons
50f375c359
libtxt: disable font fallback when test font mode is enabled (#4661) 2018-02-13 09:37:48 -08:00
Jason Simmons
b971e6e2a9
libtxt: change the host default font family to something more widely available (#4631) 2018-02-07 14:10:07 -08:00
Jason Simmons
de34a3e272
libtxt: extend Minikin to find a fallback font if its font collection can not match a given character (#4623)
Minikin layout uses a FontCollection containing a list of pre-selected fonts
for a particular font family.  This patch extends the FontCollection to invoke
a hook provided by libtxt if layout sees a character that can not be rendered
by any font in the collection.

* Change the Minikin lock to a recursive mutex.  This is required because the
  fallback font provider may create new fonts during a layout operation that
  already holds the lock.
* Implement a fallback font provider hook that queries Skia for fonts matching
  an unrecognized character.
* Maintain a cache of fallback fonts.  Prepopulate the cache with fonts
  covering some commonly used character classes.
* Add a last resort font list for cases where Skia's font manager can not
  find any font for a character (similar to Blink's FontCache::getLastResortFallbackFont)
2018-01-31 13:56:44 -08:00
Jason Simmons
8f120531f8
libtxt: update some unit tests (#4603)
* GetGlyphPositionAtCoordinate maps points within the right half of a
  glyph to the next position
* The second pass in RepeatLayoutParagraph was at the borderline between 5
  and 6 lines in the Minikin line breaker.  Add text to ensure that the text
  fills 12 lines at half width and 6 lines at full width.
2018-01-30 13:30:47 -08:00
Jason Simmons
6dccf26354
libtxt: track the range of code units represented by the current glyph (#4598)
This simplifies iteration over graphemes and fixes an off-by-one error seen
when handling RTL runs.
2018-01-30 13:30:06 -08:00
Chris Bracken
f557f476c8
Revert "libtxt: extend Minikin to find a fallback font if its font collection can not match a given character (#4595)" (#4609)
This reverts commit 9a402241e9d679ff9dcd96712693b9df38cdc414.
2018-01-29 15:23:24 -08:00
Jason Simmons
9a402241e9
libtxt: extend Minikin to find a fallback font if its font collection can not match a given character (#4595)
Minikin layout uses a FontCollection containing a list of pre-selected fonts
for a particular font family.  This patch extends the FontCollection to invoke
a hook provided by libtxt if layout sees a character that can not be rendered
by any font in the collection.

* Change the Minikin lock to a recursive mutex.  This is required because the
  fallback font provider may create new fonts during a layout operation that
  already holds the lock.
* Implement a fallback font provider hook that queries Skia for fonts matching
  an unrecognized character.
* Maintain a cache of fallback fonts.  Prepopulate the cache with fonts
  covering some commonly used character classes.
* Add a last resort font list for cases where Skia's font manager can not
  find any font for a character (similar to Blink's FontCache::getLastResortFallbackFont)
2018-01-29 12:06:48 -08:00
Jason Simmons
c9b1e0394b
libtxt: be more resilient if the minikin glyphs and the grapheme breaker get out of sync (#4590) 2018-01-26 13:35:53 -08:00
Jason Simmons
3f41726860
Implement more SkFontMgr APIs in AssetFontManager (#4591) 2018-01-26 11:55:16 -08:00
Jason Simmons
53a9540751
libtxt: insert styled runs in reverse order if a bidi run is RTL (#4573) 2018-01-19 13:49:14 -08:00
Jason Simmons
a1328e7730
libtxt: use an ICU character iterator that can handle complex grapheme clusters (#4548) 2018-01-16 10:43:00 -08:00
Jason Simmons
a394ee04aa
libtxt: skip redundant bidi processing performed by minikin (#4539)
The libtxt Paragraph class now runs the bidi algorithm itself, and each text
run passed to doLayout will be entirely LTR or RTL
2018-01-16 10:39:31 -08:00
Jason Simmons
e8bfd4d025
libtxt: map pixel coordinates above the text to glyph positions on the first line of text (#4533)
This matches Blink's behavior
2018-01-10 10:32:24 -08:00
Jason Simmons
5bcbd1c2f3
libtxt: ensure that decoration underline thickness is not zero (#4477) 2017-12-19 14:28:56 -08:00
Jason Simmons
1c6eef1b0d
libtxt: make minIntrinsicWidth match maxIntrinsicWidth if constraints prevent line wrapping (#4468) 2017-12-18 16:06:19 -08:00
Jason Simmons
1cc9abb259
Revert "libtxt: Restore code that had been disabled due to older versions of ICU and HarfBuzz (#4456)" (#4474)
This reverts commit 503999ff4dd63b0dcebd889fd895375925bfdd58.

Fuchsia is still pinned to ICU version 57, which doesn't have these APIs
2017-12-18 15:02:16 -08:00
Jason Simmons
0182ed9832
libtxt: fixes to text style inheritance (#4466)
* newly pushed styles should inherit from the top of the paragraph's style
  stack, not the most recently added style in StyledRuns
* make the paragraph-level style a default that is not pushed onto the stack
  and can not be popped
2017-12-15 16:21:40 -08:00
Jason Simmons
2b2e21ae0b
libtxt: If no glyphs were rendered, then compute baseline metrics using the paragraph style's font (#4462)
Fixes the "empty text baseline" case in text_painter_rtl_test
2017-12-15 10:07:11 -08:00
Jason Simmons
503999ff4d
libtxt: Restore code that had been disabled due to older versions of ICU and HarfBuzz (#4456) 2017-12-14 09:43:59 -08:00
Jason Simmons
1e669f080b
libtxt: fix the paragraph level text direction passed to the ICU bidi API (#4455)
Also includes some cleanup of the BidiRun struct
2017-12-14 09:43:49 -08:00
Jason Simmons
28bc7b1248
libtxt: improvements to GetWordBoundary (#4446)
* fix an off-by-one when the offset itself is a word boundary
* lazily create the word break iterator
2017-12-12 17:44:34 -08:00
Jason Simmons
9f8cf7eb97
libtxt: track the font metrics of each run in order to calculate heights in GetRectsForRange (#4442)
Previously GetRectsForRange was assigning each rectangle a height matching the
height of the entire line.  If the line includes multiple text styles, callers
will expect each span's rectangle to reflect the height of that span.
(see text_painter_rtl_test.dart)
2017-12-11 14:38:17 -08:00
Ben Konyi
a817ee14cb
Fixed failure on Windows in paragraph.cc which was surfaced by enabling (#4434)
Fixed failure on Windows in paragraph.cc which was surfaced by enabling flutter_tester.exe build on bots.
2017-12-08 16:27:47 -08:00
Brian Osman
5309ac6c19
Remove SkToBool usage (#4429) 2017-12-08 13:28:06 -05:00
Jason Simmons
e79dc185f0
libtxt: implement GetWordBoundary using the ICU word breaker (#4421) 2017-12-06 15:23:40 -08:00
Jason Simmons
affa4e7c46
libtxt: handle lines containing both LTR and RTL text runs (#4416)
* Call the ICU bidi API to divide the text into LTR/RTL runs and merge
  them with the styled runs defined by the application
* Maintain a list of glyph positions sorted by the order of the corresponding
  code units in the text, as well as a list of glyphs sorted by x/y coordinates
  in the layout
2017-12-06 14:46:03 -08:00
Ben Konyi
da43e7c62e
Added Windows support for libtxt in order to build flutter_tester.exe (#4395)
* Added Windows support for libtxt in order to build flutter_tester.exe.

Relatively minor changes were needed to get libtxt building on Windows
(missing/incompatiable headers, the odd syscall, path separators, etc.).
Windows doesn't render text in the same way as other platforms, so some tests
that checked for specific pixel offsets are disabled.
2017-11-30 16:35:32 -05:00
Jason Simmons
d6dd5b10d9
Request slight hinting when rendering glyphs with Skia (#4307)
Fixes https://github.com/flutter/flutter/issues/12820
2017-11-01 11:47:09 -07:00
Jason Simmons
e1f08d998a libtxt: insert a placeholder paint record representing the font metrics of an empty run (#4272) 2017-10-24 14:35:02 -07:00
Jason Simmons
054a2cca35 libtxt: some cleanup (#4268)
* rename glyph_position_x to glyph_lines
* use round instead of roundf
* return a range start/end struct in Paragraph::GetWordBoundary
2017-10-23 17:18:00 -07:00
Jason Simmons
b942027083 libtxt: record metrics for each font used within a run (#4259) 2017-10-20 14:45:52 -07:00
Jason Simmons
c39124d07c libtxt: better accuracy for text justification (#4255)
* do not reset the justify offset after each run within a line
* track word start/end ranges relative to the start of the text instead of the line
2017-10-20 11:50:21 -07:00
P.Y. Laligand
6fcb45991d Move //dart to //third_party/dart. (#4245) 2017-10-19 01:20:38 -07:00
Jason Simmons
8a9034c0fd libtxt: handle newlines during invocation of the minikin line breaker (#4237)
minikin::LineBreaker does not convert newline characters into line breaks
in its output.  Previously libtxt's version of LineBreaker container a patch
that added a large width offset for a newline in order to force wrapping to
the next line.  This works if the offset exceeds the paragraph's width
constraint.  But if the paragraph is laid out with infinite width, then the
text after the newline will continue on the current output line.

This change separates the paragraph's text into newline delimited blocks and
feeds each block separately to the minikin LineBreaker.

Also, libtxt was breaking the input styled text runs at newline boundaries.
This is no longer necessary.
2017-10-18 14:14:02 -07:00
Jason Simmons
4ab4ace867 libtxt: make the min/max intrinsic width calculations match expectations of the framework (#4220)
maxIntrinsicWidth is the sum of the width of all lines in the input
(if the width were any smaller, the renderer might have to wrap a line)

minIntrinsicWidth is the maximum width of a word (if the paragraph were
any narrower, the renderer would have to truncate a word)
2017-10-16 15:31:15 -07:00
P.Y. Laligand
5fae5d52cf Allow the project to be mapped to a location other than //flutter. (#4203)
This is for Fuchsia where we would like it to be located at //third_party/flutter.
2017-10-13 17:00:58 -07:00
Jason Simmons
6f4eb92020 libtxt: support the use_test_font flag required by framework tests (#4216)
This registers a test font manager that maps all fonts to the Ahem font
2017-10-13 11:31:35 -07:00
Jason Simmons
248af2d5b6 Remove obsolete text_align header from the libtxt benchmarks (#4211) 2017-10-12 13:50:27 -07:00
Jason Simmons
b84e114b8b libtxt: fix some typos (#4206) 2017-10-12 11:51:50 -07:00
Jason Simmons
199620a57b libtxt: support right-to-left text (#4198) 2017-10-11 16:15:57 -07:00
Jason Simmons
f24987571a libtxt: refactoring of paragraph layout to improve text justification (#4178)
This changes Paragraph::Layout to iterate line-by-line through the text.
For each line, Layout scans for word boundaries and adds extra space between
words if the line is justified.
2017-10-06 15:46:27 -07:00
Brian Osman
6388e92880 Change to new SkFontMgr API (#4173)
* Change to new SkFontMgr API

These changes clarify ownership rules and work today. They will be
necessary once SK_SUPPORT_LEGACY_FONTMGR_API goes away.

* Fix spacing

* Formatting
2017-10-04 14:22:57 -04:00
Jason Simmons
414c3fe3df libtxt: handle characters encoded as multiple UTF-16 code units (#4165) 2017-10-02 17:11:38 -07:00