1. 16 3月, 2017 1 次提交
    • R
      In greedy line breaking, repeat breaks until the line fits · 67d1601c
      Roozbeh Pournader 提交于
      Previously, in greedy line breaking, when a line overflowed, we found
      the best line breaking candidate before it and broke the line there.
      But we didn't check to see if the remaining part now fits in a line.
      
      With this change, we now repeat checking for overflows, and break
      again until we have no breaking opportunity or the remaining text now
      fits in a line.
      
      Also found an issue with greedy line breaking and keeping the
      hyphenation edit for the next line which is now fixed.
      
      Test: Manual. The issue reported in the bug is now fixed.
      Bug: 34185255
      Bug: https://code.google.com/p/android/issues/detail?id=231437
      Bug: 33560754
      Change-Id: I93bdd341e4f8e1257710e453e4938f224cb2a1ff
      67d1601c
  2. 15 3月, 2017 3 次提交
    • S
      Do not keep FontCollection reference in Layout. · 99ef32ce
      Seigo Nonaka 提交于
      LayoutCache only keeps result of layout and can live after
      FontCollection is destructed by GC.
      
      This kind of failure will be captured by minikin_stress_tests in the
      subsequent CL (I1bf4ba43e6e97cd04e7d6dd42d388dd17ce64c7b)
      
      Test: ran minikin_tests
      Bug: 36223724
      Change-Id: I639b73c0f1041549158c43212a901c82df4b02db
      99ef32ce
    • R
      Break grapheme clusters after viramas if they end a cluster · b01028d1
      Roozbeh Pournader 提交于
      Previously, we stayed on the conservative side and disallowed any
      grapheme breaks (and thus cursoring) where a virama was followed by a
      letter, since we did not know if the virama would be forming a
      cluster with the letter or not. This created problems with Indic
      languages with infrequent conjuncts, such as Tamil.
      
      Now we use the information in calculated advances to find if a
      cluster is formed. If there is no cluster, we break the grapheme and
      allow cursoring after the virama.
      
      Test: Unit tests added to GraphemeBreakTests and MeasurementTests.
      Test: Also manually tested Tamil sequences.
      Bug: 35721792
      Change-Id: Ib159edb94b3ad6f693f0d3dad016b332b2cef447
      b01028d1
    • S
      Revert "Use std::mutex instead of android::Mutex" · fd4124c5
      Seigo Nonaka 提交于
      This reverts commit 62ad5653.
      
      Bug: 36208043
      Test: N/A
      
      Change-Id: I165ab7a0718ea50a8034adb6277809e271fd762c
      fd4124c5
  3. 14 3月, 2017 2 次提交
    • S
      Make SparseBitSet serializable. · fbbc5a6b
      Seigo Nonaka 提交于
      To share the calculated coverage information across the processes, make
      SparseBitSet serializable.
      
      Bug: 34042446
      Test: minikin_tests passes
      Change-Id: I0463138adcf234739bb3ce1cdadf382021921f3e
      fbbc5a6b
    • S
      Use std::mutex instead of android::Mutex · 62ad5653
      Seigo Nonaka 提交于
      This CL includes:
      - Stop using utils/Mutex and use std::mutex instead.
      - Stop using utils/Singleton.
      
      Test: minikin_tests passed
      Change-Id: Ib3f75b83397a546472bb5f91e066e44506e78263
      62ad5653
  4. 13 3月, 2017 1 次提交
    • S
      Reduce memory usage of FontCollection. · c436e925
      Seigo Nonaka 提交于
      This is 2nd attempt at I9e01d237c9adcb05e200932401cb1a4780049f86.
      
      The previous CL was reverted because 8-bit integers were too small to
      store the indices of mFamilyVec. This CL changes it to 16-bit integers
      since size_t is still unnecessary large.
      
      Theoretically, 32-bit integers are necessary for the indices of
      mFamilyVec since the size of mFamilyVec can be 0x10EE01. However, in
      practice, 16-bit integers are enough for the indices of mFamilyVec.
      The length of mFamilyVec for the system fonts is 2084. Even if the
      developers load their own very large fonts, it can only increase the
      number of elements in mFamilyVec to at most 0x10FF.
      
      As the result, memory usage of the FontCollections for the system fonts
      decreases as follows.
      64-bit process: before: 398,264 bytes, after: 282,568 bytes (-115,696 bytes)
      32-bit process: before: 199,132 bytes, after: 149,548 bytes (-49,584 bytes)
      
      Bug: 33562608
      Test: Verified Emoji and CJK characters are present.
      Test: android.text.cts.EmojiTest passed
      Test: Minikin unit tests passed
      Change-Id: I6796fd55ac30fe30528a212ebf6097b1d672e2f8
      c436e925
  5. 07 3月, 2017 1 次提交
    • R
      Customizable min suffix/prefix length for hyphenation in Minikin · d78f260a
      Roozbeh Pournader 提交于
      With this change, different languages can have a different minimum
      length for suffix and prefixes when hyphenating. Previously, the
      defaults used for English, 2 and 3, were used for every language.
      
      Bug: 35712376
      Test: Minikin unit tests were updated and the pass
      Change-Id: Iffaf11c6b208c57d28d45b17246e177572dc1210
      d78f260a
  6. 03 3月, 2017 1 次提交
    • R
      Correct hyphenation for various complex cases · c7ef4000
      Roozbeh Pournader 提交于
      This adds better support for Arabic script languages, Armenian,
      Catalan, Hebrew, Kannada, Malayalam, Polish, Tamil, and Telugu by
      adding various hyphenation types and edits appropriate for the
      locales.
      
      For Arabic script languages, soft hyphens act transparently with
      regard to joining: If a line is broken at a soft hyphen where the two
      characters around the soft hyphen were joining each other before,
      they will continue to appear joining if the line is broken at the
      soft hyphen and a hyphen glyph is inserted.  This is needed for
      Central Asian languages such as Uighur.
      
      For Armenian, U+058A ARMENIAN HYPHEN is used for line breaks caused
      by either automatic hyphenation or soft hyphens.
      
      For Catalan, nonstandard line breaks are implemented for "l·l", which
      hyphenates as "l-/l".
      
      For Polish, when there is a line break at a hyphen, the hyphen is
      repeated at the next line.
      
      For the South Indic languages, when breaks happen due to soft breaks
      or automatic hyphenation, no visible hyphen is inserted, although a
      penalty is added.
      
      For Hebrew, support for using U+05BE HEBREW PUNCTUATION MAQAF has
      been implemented, but it's turned off pending confirmation of
      desirability.
      
      Also, hard hyphens, which previously had no penalty added for
      breaking the line after them, now have the same penalty as an
      automatic or soft break, with the difference that no hyphen is
      inserted when they break.
      
      Finally, some bugs have been fixed with hyphenating multiscript and
      multi-font words.
      
      Bug: 19950445
      Bug: 19955011
      Bug: 25623243
      Bug: 26154469
      Bug: 26154471
      Bug: 33387871
      Bug: 33560754
      Bug: 33752592
      Bug: 33754204
      Test: Unit tests added, plus thorough manual testing
      Change-Id: Iaccf776ce8d1d434ee8b1c534ff3659d80fdc338
      c7ef4000
  7. 24 2月, 2017 1 次提交
    • S
      Remove MinikinRefCounted and use shared_ptr instead · dfbc6e37
      Seigo Nonaka 提交于
      Let's use shared_ptr since manual ref counting can be a bug-prone and
      using the global mutex inside destructor is not useful for some time.
      
      To remove raw pointer manipulation, needed to change Layout
      constructors. Layout is no longer copyable and need to pass
      FontCollection to constructor.
      
      Bug: 28119474
      Test: minikin_tests passed
      Test: hwui_unit_tests passed
      Test: No performance regression in minikin_perftest.
      Change-Id: I8824593206ecba74cbc9731e298f045e1ae442a3
      dfbc6e37
  8. 22 2月, 2017 1 次提交
  9. 31 1月, 2017 1 次提交
    • S
      Introduce createCollectionWithVariation. · 065c46a6
      Seigo Nonaka 提交于
      This is 2nd attempt of I08e9b74192f8af1d045f1276498fa4e60d73863e.
      The original CL was reverted due to conflicting with another CL submitted
      before.
      
      Here is the original commit message of reverted change.
      
      This lays the groundwork for variation settings support.
      Since we should regard different variations of a font as different fonts, we
      need to create new typefaces. To reuse the same instance of MinikinFont, as
      much as possible, FontFamily::createFamilyWithVariation now reuses an
      existence instance, while incrementing the reference count.
      
      Test: minikin_tests
      Bug: 33062398
      Change-Id: Ib25bf1bb5a5191e15a6523954146521464c91906
      065c46a6
  10. 20 1月, 2017 3 次提交
    • S
      Remove FontFamily.addFont and make FontFamily immutable. · 41718c77
      Seigo Nonaka 提交于
      This is 2nd attempt of 41e02e96
      The difference is adding clearElementsEithLock to Font class which
      is necessary to delete Fonts object outside of minikin. This method
      should be removed once http://b/28119474 is fixed.
      
      Here is original commit message of reverted change.
      
      This lays the groundwork for making SparseBitSet serializable.
      FontFamily.addFont is only used when the FontFamily is constructed.
      Thus, instead of calling FontFamily.addFont multiple time, passes
      Font list to the constructor. By this change, FontFamily can be
      immutable now.
      
      By making FontFamily immutable, We can create FontFamily with
      pre-calculated SparseBitSet.
      
      Bug: 34042446
      Bug: 28119474
      Bug: 34378805
      Test: minikin_tests has passed
      Change-Id: Ice433931196f5ae79a1a7ee0c98020f914aeb5f2
      41718c77
    • S
      Revert "Remove FontFamily.addFont and make FontFamily immutable." · cc0352cc
      Siyamed Sinir 提交于
      This reverts commit 41e02e96.
      
      Bug: 34378805
      Change-Id: I8f1ee00b365c8b17c6140e9e286fbea082e31364
      cc0352cc
    • S
      Revert "Introduce createCollectionWithVariation." · 1c7b0261
      Siyamed Sinir 提交于
      This reverts commit 90e6b188.
      
      Bug: 34378805
      Change-Id: I22b683f774813724f220b1b8584ab188f3cf4fa7
      1c7b0261
  11. 13 1月, 2017 1 次提交
  12. 12 1月, 2017 2 次提交
    • S
      Introduce createCollectionWithVariation. · 90e6b188
      Seigo Nonaka 提交于
      This lays the groundwork for variation settings support.
      Since we should regard different variations of a font as different fonts, we
      need to create new typefaces. To reuse the same instance of MinikinFont, as
      much as possible, FontFamily::createFamilyWithVariation now reuses an
      existence instance, while incrementing the reference count.
      
      Test: minikin_tests
      Bug: 33062398
      Change-Id: I08e9b74192f8af1d045f1276498fa4e60d73863e
      90e6b188
    • S
      Remove FontFamily.addFont and make FontFamily immutable. · 41e02e96
      Seigo Nonaka 提交于
      This lays the groundwork for making SparseBitSet serializable.
      FontFamily.addFont is only used when the FontFamily is constructed.
      Thus, instead of calling FontFamily.addFont multiple time, passes
      Font list to the constructor. By this change, FontFamily can be
      immutable now.
      
      By making FontFamily immutable, We can create FontFamily with
      pre-calculated SparseBitSet.
      
      Bug: 34042446
      Test: minikin_tests has passed
      Change-Id: I2576789fba6cb27687e920e2488e8bedbcf7d36f
      41e02e96
  13. 06 1月, 2017 1 次提交
    • S
      Reduce memory usage of FontCollection. · c4b989fc
      Seigo Nonaka 提交于
      Since switching to 64-bit devices, size_t is now a 64-bit integer.
      FontCollection::Range uses two size_t integers but they just point to an index
      in mFamilies. To reduce the memory usage, this CL changes the size_t integers to
      uint8_t.
      
      The maximum size of each integer in Range is the size of FontCollection::mFamilies.
      The largest this can go is the system font list plus a user defined family, which
      has 91 families. So an 8-bit integer should be enough.
      
      With this change, about 84 KiB of memory will be saved per font collection. Since
      eight font collections are created during bootstrap, about 670 KiB of memory will
      be saved with this CL.
      
      Bug: 33562608
      Test: Ran FontCollection.collectionAllocationSizeTest on a 64-bit device.
            On my Nexus 5X, it changed from 327358 to 241342.
      
      Change-Id: I9e01d237c9adcb05e200932401cb1a4780049f86
      c4b989fc
  14. 02 1月, 2017 1 次提交
    • S
      Tune line breaking for justification · 3a74bcd0
      Seigo Nonaka 提交于
      Add an "mJustified" for justification, and tune the line breaking to
      produce good results. Major differences for fully justified text include:
      - Space can be shrunk in justified text.
      - Hyphenation should be more aggressive in justified text.
      
      Also adds a penalty for the last line being very short. This is tuned
      to be more aggressive for ragged right than for justified text.
      
      This is based on a patch by Raph Levien (raph@google.com).
      
      Bug: 31707212
      Test: Manually tested with Icbfab2faa11a6a0b52e6f0a77a9c9b5ef6e191da
      Change-Id: If366f82800831ccc247ec07b7bc28ca4c6ae0ed6
      3a74bcd0
  15. 17 11月, 2016 1 次提交
    • S
      Clean Up: Removing unused interface GetTable from MinikinFont. · fd77b01f
      Seigo Nonaka 提交于
      This is 2nd attempt of Ifcd7a348d7fb5af081192899dbcdfc7fb4eebbf9
      
      After Id766ab16a8d342bf7322a90e076e801271d527d4, GetTable is no longer
      used in production due to poor performance and it is now only used in
      tests. This CL removes GetTable interface from MinikinFont and update
      tests code to use new interfaces, GetFontData, GetFontSize and
      GetFontIndex.
      
      Bug: 27860101
      Test: Manually done
      Change-Id: Ib48973ff25cdc61a4c666d28128266df0aaea83e
      fd77b01f
  16. 16 11月, 2016 1 次提交
    • S
      Implement word spacing · acd401d0
      Seigo Nonaka 提交于
      Add a wordSpacing paint parameter, which will be used for
      justification.
      
      Bug: 31707212
      Test: ran minikin_tests
      Change-Id: I91224ab8ef882ac0c87425c28ab731fead283612
      acd401d0
  17. 25 10月, 2016 1 次提交
  18. 18 10月, 2016 1 次提交
    • S
      Clean Up: Removing unused interface GetTable from MinikinFont. · 1d525df4
      Seigo Nonaka 提交于
      After Id766ab16a8d342bf7322a90e076e801271d527d4, GetTable is no longer
      used in production due to poor performance and it is now only used in
      tests. This CL removes GetTable interface from MinikinFont and update
      tests code to use new interfaces, GetFontData, GetFontSize and
      GetFontIndex.
      
      Bug: 27860101
      Test: Manually done
      
      Change-Id: Ifcd7a348d7fb5af081192899dbcdfc7fb4eebbf9
      1d525df4
  19. 13 9月, 2016 1 次提交
  20. 16 8月, 2016 2 次提交
    • C
      Fix google-explicit-constructor warnings in minikin · 0114c6a1
      Chih-Hung Hsieh 提交于
      * Add explicit keyword to conversion constructors,
        or add NOLINT(implicit) for implicit converters.
      Bug: 28341362
      Test: build with WITH_TIDY=1
      
      Change-Id: I0c7b90f9bb953a9f2e4f0fb2032fa65ac604b9ca
      Merged-In: I0c7b90f9bb953a9f2e4f0fb2032fa65ac604b9ca
      0114c6a1
    • C
      Fix google-explicit-constructor warnings in minikin · 47b905f6
      Chih-Hung Hsieh 提交于
      * Add explicit keyword to conversion constructors,
        or add NOLINT(implicit) for implicit converters.
      Bug: 28341362
      Test: build with WITH_TIDY=1
      
      Change-Id: I0c7b90f9bb953a9f2e4f0fb2032fa65ac604b9ca
      47b905f6
  21. 10 6月, 2016 1 次提交
    • S
      Always use minikin namespace. · 14e2d136
      Seigo Nonaka 提交于
      Here is a new policy of the namespace of minikin.
      - All components should be in minikin namespace.
      - All tests are also in minikin namespace and no anonymous namespace.
      
      Bug: 29233740
      Change-Id: I71a8a35049bb8d624f7a78797231e90fed1e2b8c
      14e2d136
  22. 15 4月, 2016 1 次提交
    • S
      Returns hasVariationSelector true for VS15/VS16 · 994aa84f
      Seigo Nonaka 提交于
      Minikin has a special font fallback for VS15/VS16, so
      hasVariationSelector for emojis with VS15/VS16 should always return
      true.
      
      Bug: 27531970
      Change-Id: Ieebd58f48b135b6ec50d999df68dcc09b1284606
      994aa84f
  23. 13 4月, 2016 1 次提交
    • R
      Clear mLineWidths in LineBreaker::finish() · 879e8a3a
      Raph Levien 提交于
      There was the possibility of stale indents from previous invocations
      persisting in the mLineWidths across multiple invocations. This patch
      clears them.
      
      Bug: 28090810
      Change-Id: I3621dfbe983512046289373711709aeade52eab4
      879e8a3a
  24. 12 4月, 2016 1 次提交
    • S
      Fix minikin_unittests · 6c60831c
      Seigo Nonaka 提交于
      This CL fixes following test cases in minikin_tests
      - FontFamilyTest.hasVariationSelectorTest
      - HbFontCacheTest.getHbFontLockedTest
      - HbFontCacheTest.purgeCacheTest
      
      For the fix of FontFamilyTest.hasVariationSelectorTest, removing virtual
      from GetUniqueId() in MinikinFont.  After [1], MinikinFont's destructor
      started calling purgeHbCache() which calls virtual method,
      MinikinFont::GetUniqueId().  Fortunately, the SkTypeface::uniqueID()
      returns just internal value, so we can store it at the construction time
      and use it instead of calling SkTypeface::uniqueID() every time.
      
      This patch also changes purgeHbFont to purgeHbFontLocked, as all uses of
      it were already under global mutex. This change avoids deadlock on
      explicit unref, as when invoked by a Java finalizer from the Java object
      that holds a reference to the font.
      
      Some of the tests needed to change to using the ref counting protocol
      rather than explicitly destructing font objects, as well.
      
      [1] 9afcc6e2
      
      Bug: 28105730
      Bug: 28105688
      Change-Id: Ie5983c4869147dacabdca81af1605066cd680b3f
      6c60831c
  25. 08 4月, 2016 2 次提交
    • R
      Avoid copying of font table data · aaa4e347
      Raph Levien 提交于
      The hb_font_t object holds on to tables of font data, acquired through
      the MinikinFont::GetTable interface, which is based on copying data
      into caller-owned buffers. Now that we're caching lots of hb_font_t's,
      the cost of these buffers is significant.
      
      This patch moves to a different interface, inspired by HarfBuzz's
      hb_reference_table API, where the font can provide a pointer to the
      actual font data (which will often be mmap'ed, so it doesn't even
      consume physical RAM).
      
      Bug: 27860101
      Change-Id: Id766ab16a8d342bf7322a90e076e801271d527d4
      aaa4e347
    • R
      Purge hb font on Minikin font destruction · 9afcc6e2
      Raph Levien 提交于
      This patch eagerly purges the corresponding hb_font_t object from
      the HbFontCache when the underlying MinikinFont is destroyed. After
      that, the key will no longer be accessed, so having the entry is
      wastes memory.
      
      Bug: 27251075
      Bug: 27860101
      Change-Id: I1b98016133fe3baf6525ac37d970a65ddccadb4f
      9afcc6e2
  26. 04 3月, 2016 1 次提交
  27. 19 2月, 2016 1 次提交
  28. 18 2月, 2016 3 次提交
    • R
      Add penalty for breaks in URLs and email addresses · c88ef135
      Raph Levien 提交于
      Recent changes have added special cases for line breaks within URLs
      and email addresses. Such breaks are undesirable when they can be
      avoided, but at other times are needed to avoid huge gaps, or indeed
      to make the line fit at all.
      
      This patch assigns a penalty for such breaks, equal to the hyphenation
      penalty. The mechanism is currently very simple, but would be easy to
      fine-tune based on more detailed information about break quality.
      
      Bug: 20126487
      Bug: 20566159
      Change-Id: I0d3323897737a2850f1e734fa17b96b065eabd9c
      c88ef135
    • R
      Add line breaks to email addresses and URLs · 6d15657e
      Raph Levien 提交于
      This change adds accceptable line breaks according to sections 7.42
      (Dividing URLs and e-mail addresses) and 14.12 (URLs or DOIs and line
      breaks) of the Chicago Manual of Style (16th ed.). In general, these
      place breaks before punctuation symbols, and suppresses them after
      hyphens.
      
      Bug: 20126487
      Bug: 20566159
      Change-Id: I2d07d516b920a506a2f718c38fb435c5eb1ee1f8
      6d15657e
    • R
      Special-case URLs and email addresses for line breaking · 9c4cc648
      Raph Levien 提交于
      Detect URLs and email addresses, and suppress both line breaking and
      hyphenation within them.
      
      Bug: 20126487
      Bug: 20566159
      
      Change-Id: I43629347a063dcf579e355e5b678d7195f453ad9
      9c4cc648
  29. 17 2月, 2016 2 次提交
    • S
      Improve Paint.measureText and Paint.hasGlyph for variation sequences. · 6b1c227d
      Seigo Nonaka 提交于
      Before this patch, the font fallback chain iterated all installed font
      families if a variation selector was specified.
      
      This CL narrows down the range of iteration.
      To decide the font family for the variation sequence, we need to search
      for both the variation sequence and its base code point.
      The new range of the iteration is a union of them.
      
      With this change, the running time of Paint.hasGlyph for the variation
      sequence improves 50% and the running time of Paint.measureText for the
      variation sequence improves 40% for the large text case on Nexus 6
      userdebug.
      
      Bug: 26784699
      Bug: 11750374
      
      Change-Id: Iced1349e3ca750821d8882c551551f65bb569794
      6b1c227d
    • R
      Refine hyphenation around punctuation · 57b6dae9
      Raph Levien 提交于
      Implement a WordBreaker that defines our concept of valid word
      boundaries, customizing the ICU behavior. Currently, we suppress line
      breaks at soft hyphens (these are handled specially). Also, the
      new WordBreaker class has methods that determine the start and end
      of the word (punctuation stripped) for the purpose of hyphenation.
      
      This patch, in its current form, doesn't handle email addresses and
      URLs specially, but the WordBreaker class is the correct place to do
      so. Also, special case handling of hyphens and dashes is still done
      in LineBreaker, but all of that should be moved to WordBreaker.
      
      Bug: 20126487
      Bug: 20566159
      Change-Id: I492cbad963f9b74a2915f010dad46bb91f97b2fe
      57b6dae9