diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2013-08-22 22:57:54 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2013-08-22 23:00:45 +0200 |
commit | 94a742fbc092eb75dbcffcbce0ac96679c90add4 (patch) | |
tree | 09956c15c50d1a3351e7f5ef6526f603dd43f3aa /vcl | |
parent | cbb3f73adec26896b1e5c371548fa3bd1ae57130 (diff) |
Don't re-create Unicode and font functions for every text run
Change-Id: I35ba21d753adfc619656d4473b214485dc00faba
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/generic/glyphs/gcach_layout.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx index cc22bad9915e..fd3ca3607223 100644 --- a/vcl/generic/glyphs/gcach_layout.cxx +++ b/vcl/generic/glyphs/gcach_layout.cxx @@ -137,6 +137,9 @@ std::ostream &operator <<(std::ostream& s, ServerFont* pFont) return s; } +static hb_font_funcs_t* pHbFontFuncs = NULL; +static hb_unicode_funcs_t* pHbUnicodeFuncs = NULL; + static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pUserData) { char pTagName[5]; @@ -368,8 +371,11 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) SAL_INFO("vcl.harfbuzz", "layout(" << this << ",rArgs=" << rArgs << ")"); + if (pHbFontFuncs == NULL) + pHbFontFuncs = getFontFuncs(); + hb_font_t *pHbFont = hb_font_create(mpHbFace); - hb_font_set_funcs(pHbFont, getFontFuncs(), &rFont, NULL); + hb_font_set_funcs(pHbFont, pHbFontFuncs, &rFont, NULL); hb_font_set_scale(pHbFont, ((uint64_t) aFtFace->size->metrics.x_scale * (uint64_t) fUnitsPerEM) >> 16, ((uint64_t) aFtFace->size->metrics.y_scale * (uint64_t) fUnitsPerEM) >> 16); @@ -414,8 +420,11 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) LanguageTag aLangTag(rArgs.meLanguage); OString sLanguage = OUStringToOString(aLangTag.getLanguage(), RTL_TEXTENCODING_UTF8); + if (pHbUnicodeFuncs == NULL) + pHbUnicodeFuncs = getUnicodeFuncs(); + hb_buffer_t *pHbBuffer = hb_buffer_create(); - hb_buffer_set_unicode_funcs(pHbBuffer, getUnicodeFuncs()); + hb_buffer_set_unicode_funcs(pHbBuffer, pHbUnicodeFuncs); hb_buffer_set_direction(pHbBuffer, bRightToLeft ? HB_DIRECTION_RTL: HB_DIRECTION_LTR); hb_buffer_set_script(pHbBuffer, hb_icu_script_to_script(eScriptCode)); hb_buffer_set_language(pHbBuffer, hb_language_from_string(sLanguage.getStr(), -1)); |