diff options
author | Roozbeh Pournader <roozbeh@google.com> | 2015-02-25 11:56:34 -0800 |
---|---|---|
committer | Roozbeh Pournader <roozbeh@google.com> | 2015-02-25 13:30:08 -0800 |
commit | 0bbff3a96d3836079371cdd4398c21afad3c5234 (patch) | |
tree | 5549dd28346f84152e447a168fc8f7e73e45aa3e | |
parent | 30c70ff7142e9cf3cd795a7afdf2b5afe8bc4564 (diff) | |
download | android_frameworks_minikin-0bbff3a96d3836079371cdd4398c21afad3c5234.tar.gz android_frameworks_minikin-0bbff3a96d3836079371cdd4398c21afad3c5234.tar.bz2 android_frameworks_minikin-0bbff3a96d3836079371cdd4398c21afad3c5234.zip |
Disable HarfBuzz's fallback to compatibility decompositions
Previously, HarfBuzz's default fallback to compatibility
decompositions resulted in Mathematical Alphanumeric Symbols getting
rendered as normal letters and digits when there was no font
available to render them. This patch disables that fallback, to
ensure they are displayed as tofus.
Based on a patch by Behdad Esfahbod.
Bug: 19202569
Change-Id: I357f172302448d4ab0b24efc86119f1977b5996b
-rw-r--r-- | libs/minikin/Layout.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libs/minikin/Layout.cpp b/libs/minikin/Layout.cpp index 344766a..375f61d 100644 --- a/libs/minikin/Layout.cpp +++ b/libs/minikin/Layout.cpp @@ -173,13 +173,24 @@ private: static const size_t kMaxEntries = 100; }; +static unsigned int disabledDecomposeCompatibility(hb_unicode_funcs_t*, hb_codepoint_t, + hb_codepoint_t*, void*) { + return 0; +} + class LayoutEngine : public Singleton<LayoutEngine> { public: LayoutEngine() { + unicodeFunctions = hb_unicode_funcs_create(hb_icu_get_unicode_funcs()); + /* Disable the function used for compatibility decomposition */ + hb_unicode_funcs_set_decompose_compatibility_func( + unicodeFunctions, disabledDecomposeCompatibility, NULL, NULL); hbBuffer = hb_buffer_create(); + hb_buffer_set_unicode_funcs(hbBuffer, unicodeFunctions); } hb_buffer_t* hbBuffer; + hb_unicode_funcs_t* unicodeFunctions; LayoutCache layoutCache; HbFaceCache hbFaceCache; }; @@ -402,7 +413,7 @@ int Layout::findFace(FakedFont face, LayoutContext* ctx) { static hb_script_t codePointToScript(hb_codepoint_t codepoint) { static hb_unicode_funcs_t* u = 0; if (!u) { - u = hb_icu_get_unicode_funcs(); + u = LayoutEngine::getInstance().unicodeFunctions; } return hb_unicode_script(u, codepoint); } @@ -709,7 +720,7 @@ void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t srunend = srunstart; hb_script_t script = getScriptRun(buf + start, run.end, &srunend); - hb_buffer_reset(buffer); + hb_buffer_clear_contents(buffer); hb_buffer_set_script(buffer, script); hb_buffer_set_direction(buffer, isRtl? HB_DIRECTION_RTL : HB_DIRECTION_LTR); FontLanguage language = ctx->style.getLanguage(); |