27 Commits

Author SHA1 Message Date
Seigo Nonaka
6f9966ea7c Introduce multiple language based font fallback.
The motivation of this CL is enhance the font fallback score design
to support multiple language font fallback.

This CL contains following changes:
- Break language based font score into two: script-based score and
  primary-language-based score.
- The primary-language-based score is 0 if the script-based score is 0.
  If the script-based score is not 0 and the primary language is the
  as same as the requested one, the font gets an extra score of 1.
- The language score gets a higher multiplier for languages higher in
  the locale list.

Bug: 25122318
Bug: 26168983
Change-Id: Ib999997a88e6977e341f4c325e2a1b41a59db2d5
2016-01-15 14:35:14 +09:00
Raph Levien
6638e05ac2 Tailor grapheme boundaries so sequence emoji are one grapheme
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
2016-01-13 12:52:38 -08:00
Seigo Nonaka
2342e5310f Fix lock assertion failures in unit test.
The assertion for the lock state has now activated by
I9c4b1e1f09c6793e387fbdb8bb654cc0a13c65d5.
This CL fixes the assertion failure in the unit tests by acquiring
lock before calling the functions.

Change-Id: I6a6afefb4de01e8610c2abfe6c779afa9442cc67
2016-01-06 22:49:33 +09:00
Seigo Nonaka
d337652233 Replace Qaae script with Zsye
The emoji variant script "Zsye" is registered in ISO 15924.

Bug: 26226285
Change-Id: Ibc2bc740d57c48f99b6f66b1ad7595bfa8c3cff4
2016-01-05 05:05:57 +00:00
Seigo Nonaka
96233efe4c Merge "Save all kind of script tags into FontLanguage." 2015-12-22 04:01:19 +00:00
Seigo Nonaka
5e995fb850 Save all kind of script tags into FontLanguage.
The main purpose of this CL is expanding FontLanguage to be able to
save full script tag. Previously, FontLangauge kept only limited script
tags. With this CL, FontLanguage keeps all script tags.

This CL contains the following changes:
- FontLanguage changes:
-- Moved to private directory not to be instantiated outside of Minikin.
-- Removed bool(), bits(), FontLanguage(uint32_t) methods which are no
   longer used.
-- Change the FontLanguage internal data structure.
-- Introduces script match logic.

- FontLanguages changes:
-- Moved to private directory not to be instantiated outside of Minikin.
-- This is now std::vector<FontLanguage>

- FontLanguageListCache changes:
-- Now FontLanguageListCache::getId through
   FontStyle::registerLanguageList is the only way to instantiate the
   FontLanguage.
-- Normalize input to be BCP47 compliant identifier by ICU.

Bug: 26168983
Change-Id: I8df992a6851021903478972601a9a5c9424b100c
2015-12-22 09:34:04 +09:00
Seigo Nonaka
c5ec243b3a No op build should not build minikin_tests
Previous CL[1] adds module names into LOCAL_ADDITIONAL_DEPENDENCIES, but
it was wrong. LOCAL_ADDITIONAL_DEPENDENCIES only accepts file path.

However, BUILD_PREBUILT doesn't provide a file path of the installed
font. So use custom tool and LOCAL_GENERATED_SOURCES instead.

Confirmed no-op build doesn't built minikin_tests and
continuous_native_tests.zip contains all necessary files.

[1]: I7d83abc077bce4e38fd93c7d607bc7e1f7871e6b

BUG: 26197092
Change-Id: I90e80036248ae72e0e0f9c6144a259f5f96ec9ce
2015-12-15 16:11:21 -08:00
Seigo Nonaka
43bb9743ca Remove script matching score from the font selection fallback.
Removing the extra score of 2 for the script matching from the font
fallback score calculation.  If the two langauges have different
scripts, we should treat them as different languages.

Change-Id: Ie0d6f27bd1086248895935a7bd01b5d404044ad0
2015-12-10 18:41:03 -08:00
Seigo Nonaka
efaf02ea3a Copy test font files into data directory.
To work native tests with additional font related files, copy
the files into /data/nativetest/minikin_tests/.
This copy only happens when the minikin_tests is built.
It is not an expected to copy the font files into the product image.

Change-Id: I7d83abc077bce4e38fd93c7d607bc7e1f7871e6b
2015-12-09 14:44:12 -08:00
Seigo Nonaka
6d9dcd2cf3 Introduce FontLanguageListCache.
FontLanguageListCache is an intentionally leaky singleton and its
internal cache won't be purged.

BUG: 25122318

Change-Id: I272097e979fe44b83fd86822235350e12eda8f51
2015-12-08 18:49:18 -08:00
Seigo Nonaka
369d2d44cb Select emoji font based on variation selectors.
If U+FE0E is appended to the emoji code point, the glyph should have a
text presentation.
On the other hand, if U+FE0F is appended to the emoji code point, the
glyph should have an emoji presentation.

Bug: 11256006
Change-Id: I5187d44500b13a138e7ffbcf2c72e2da06374c8c
2015-12-07 16:49:16 -08:00
Seigo Nonaka
66a34a04ab Merge "Search all families instead of using mRanges for variation sequence." 2015-11-20 05:46:31 +00:00
Seigo Nonaka
fc119c68f5 Search all families instead of using mRanges for variation sequence.
To optimize the font family search, mRanges is used for narrowing down
the search range. However, mRanges is constructed from format 4 or
format 12 entries. So, if the font supports a variation sequence but doesn't
support the base character of the sequence, the font may not be listed in
mRanges.

The proper way to fix this issue is using format 14 subtable information
for mRanges construction. However, this is not a trivial work since currently
we rely on HarfBuzz for variation sequence lookup and it doesn't provide any
API for retrieving coverage information.

Thus, as the quick fix, iterate all font families in font fallback chain if
the variation sequence is specified.

Change-Id: I278da84be8fb8f553590e2e42ed450b7e4a34eca
2015-11-19 17:14:59 +09:00
Seigo Nonaka
80d113bcd4 Introduce FontCollection::hasVariationSelector method.
To implement Paint.hasGlyph(), we need a new method to ask the
FontCollection if it has a glyph for the code point and variation
selector pair.

Bug: 11256006
Change-Id: Ie4185c91bcaa4d01aee6beb97784b1f9d2a88f12
2015-11-19 17:01:46 +09:00
Seigo Nonaka
3dd8757fcf Fix invalid decrement range of KEYCAP handling in itemize.
This issue was introduced by I22ce0e9eadc941f84e3a9b23462f194e51dd7180.
Need to decrement the two utf16 chars in KEYCAP handling.

To add unit tests, this CL also addresses the Bug: 24184208 by
introducing self built fonts since there is no good example in system
installed fonts.

Bug: 24184208
Change-Id: I23fa008adbaced78a3cb96442a6bc8892ab84ce8
2015-11-13 14:39:06 +09:00
Seigo Nonaka
bae3476829 Add -Werror -Wall -Wextra to compiler option.
This is 2nd trial of I30a0914a4633bd93eb60957cdf378770f04d8428

- To suppress noisy unused parameter warnings, comment out unused
  arguments.
- Add -Werror for suppressing further warning.
- Add -Wall -Wextra for safety.
- Use "z" prefix for format string of size_t.

Verified that compile succeeded on all arm,arm64,mips,x86,x86_64.

Change-Id: I7ad208464486b8a35da53929cb1cfe541ed0052f
2015-10-28 04:52:49 +00:00
Bart Sears
b4c7991804 Revert "Add -Werror -Wall -Wextra to compiler option."
This reverts commit 63635cff5861dcaed963c7332eecf51b9d7d920a.

Change-Id: I2b4b10e8afedc85dbe2d07f3e47315652b65cd14
2015-10-28 03:16:55 +00:00
Seigo Nonaka
63635cff58 Add -Werror -Wall -Wextra to compiler option.
- To suppress noisy unused parameter warnings, comment out unused
  arguments.
- Add -Werror for suppressing further warning.
- Add -Wall -Wextra for safety.

Change-Id: I30a0914a4633bd93eb60957cdf378770f04d8428
2015-10-27 21:18:22 +09:00
Roozbeh Pournader
4b723bf22b Basic scaffolding for handling a language list.
The behavior hasn't changed much yet: all languages are ignored for
rendering text, except the very first supported language.

Change-Id: I1695fb985927ae5e28e4f59c1b531e4993af8688
2015-10-22 14:01:50 -07:00
Seigo Nonaka
16da66db74 Merge "Support Variation Selector in font selection." 2015-10-20 03:47:03 +00:00
Seigo Nonaka
bbdd73ec07 Support Variation Selector in font selection.
This CL contains the following changes:
- Add a variation selector argument into getFamilyForChar to be able to
  select fonts which support variation selector.
- In case no fonts support the codepoint and variation selector pair,
  add a fallback rule which selects font family with ignoring variation
  selector.
- Change FontCollection::itemize to not change the font family
  immediately preceding a variation selector.
- Introduce unit tests for variation selectors.

With this CL, TextView can render the variation selectors correctly.

Bug: 11256006
Change-Id: I22ce0e9eadc941f84e3a9b23462f194e51dd7180
2015-10-20 12:34:40 +09:00
Seigo Nonaka
210dfa01db Remove MinikinFont::GetGlyph interface.
MinikinFont:GetGlyph is no longer used.
No behavior chnages are expected with this CL.

Change-Id: I13398503841ac06f930b04815017d4b33338efa1
2015-10-15 02:54:18 +00:00
Seigo Nonaka
0f2a025d13 Introduce FontFamily::hasVariationSelector
This CL introduces new method hasVariationSelector into FontFamily but it
is not used in production code. So no behavior changes are expected.

This CL contains the following changes:
- Introduce hasVariationSelector which returns true if the corresponding
  font has a glyph for a code point and variation selector pair.
- Introduce purgeHbFontCache since hb_face_t won't be released by
  keeping hb_font_t.
- Introduce unit tests with self-built font.

Change-Id: I659a6d03d9ec446b409e1fba2758452abb9f44fa
2015-10-12 18:53:45 +09:00
Seigo Nonaka
fb0d396929 Extract hb_face_t object cache mechanism from Layout.cpp.
This CL does following things:
- Extract hb_face_t object cache mechanism from Layout.cpp to be able to
  use it from other cpp file, especially from FontFamily.cpp.
  To address Bug 11256006 and Bug 17759267, need to touch
  hb_face_t from FontFamily.
- Make hb_face_t cache mechanism thread-safe.
- Add unit tests for HbFaceCache test cases.

Bug: 11256006
Bug: 17759267
Change-Id: Ic183634ef34326793bd9a32167236611d0af34d6
2015-09-30 17:36:44 +09:00
Seigo Nonaka
1c2bd209d1 Introduce unit tests for FontCollection::itemize.
Introduced tests depend on installed font list in running device.
I verified these test passed  on Nexus 5(hammerhead), Nexus 6(shamu)
and Nexus 9(volantis).

Bug: 11256006
Bug: 17759267
Change-Id: I6f806370e17f6c6d3dad8df0cb70bb475a827873
2015-09-18 15:40:51 +09:00
Seigo Nonaka
4e3adc6fb2 Update word breaker to be aware tone mark and variation selector.
This CL does:
1. Move the getNextWordBreak/getPrevWordBreak function to a separate source file.
2. Adding "ForCache" suffix for function name for making clear these function is
   for layout cache.
3. Introduce unit tests for them.

Bug: 11256006
Change-Id: I4138751a4570915f1a0d6c8921f89700f8ec7f35
2015-08-29 08:02:44 +09:00
Raph Levien
d8dd94b81e Add basic unit tests for Minikin
Initial unit tests for Minikin functionality. Also fixes an incorrect
Hangul case (uncovered in testing), and improves handling of broken
UTF-16.

Change-Id: I69b441d8e3b19ed06abcc56f13271abadf3d1010
2015-08-19 15:00:25 -07:00