summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-08-22 22:57:54 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-08-24 04:33:57 +0000
commit93e590627587f4023e03338696e35751b5a6ce52 (patch)
treecee2fc2984b82b678a731bfc12e9bbbd78a77e02 /vcl
parentfbaedf8bd45d3cc4409c92a4b798d9d9788567ed (diff)
Don't re-create Unicode and font functions for every text run
Change-Id: I35ba21d753adfc619656d4473b214485dc00faba Reviewed-on: https://gerrit.libreoffice.org/5599 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/generic/glyphs/gcach_layout.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index 9031ab76e4cd..833cf4f9a383 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -122,6 +122,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];
@@ -353,8 +356,11 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
SAL_INFO("vcl.harfbuzz.layout", "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);
@@ -399,8 +405,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));