diff options
author | Tor Lillqvist <tml@iki.fi> | 2003-08-07 02:56:36 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2003-08-07 02:56:36 +0000 |
commit | e2f4d1dc15dc6664246780e51eb7664d023c0a07 (patch) | |
tree | 311532c3423d713a2b100c0d370c64631f7dc15b /modules | |
parent | e5661fe5f8cc2c7ecb992e16f6d69445e3365d4f (diff) | |
download | pango-e2f4d1dc15dc6664246780e51eb7664d023c0a07.tar.gz |
New function. Uses the Uniscribe ScriptIsSimple() function to check if
2003-08-05 Tor Lillqvist <tml@iki.fi>
* modules/basic/basic-win32.c (text_is_simple): New function. Uses
the Uniscribe ScriptIsSimple() function to check if Uniscribe
shaping is needed for a piece of text.
(basic_engine_shape): Use it, to avoid calling Uniscribe to shape
non-complex text. Produces dramatic speedup according to tests by
Hans Breuer.
(init_uniscribe): No need for the PANGO_WIN32_NO_UNISCRIBE
environment variable any longer.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/basic/basic-win32.c | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index 9e00139c..82c8b88c 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -107,14 +107,21 @@ typedef HRESULT (WINAPI *pScriptPlace) (HDC, typedef HRESULT (WINAPI *pScriptFreeCache) (SCRIPT_CACHE *); +typedef HRESULT (WINAPI *pScriptIsComplex) (WCHAR *, + int, + DWORD); + static pScriptGetProperties script_get_properties; static pScriptItemize script_itemize; static pScriptShape script_shape; static pScriptPlace script_place; static pScriptFreeCache script_free_cache; +static pScriptIsComplex script_is_complex; +#ifdef BASIC_WIN32_DEBUGGING static const SCRIPT_PROPERTIES **scripts; static int nscripts; +#endif #endif @@ -264,6 +271,8 @@ swap_range (PangoGlyphString *glyphs, #ifdef BASIC_WIN32_DEBUGGING +#if 0 + static char * charset_name (int charset) { @@ -298,6 +307,8 @@ charset_name (int charset) } } +#endif + static char * lang_name (int lang) { @@ -904,14 +915,13 @@ uniscribe_shape (PangoFont *font, wchar_t *wtext; int wlen, i; gboolean retval = TRUE; - GError *error; HGDIOBJ old_font = NULL; HFONT hfont = NULL; LOGFONT *lf; SCRIPT_CACHE script_cache[100]; wtext = (wchar_t *) g_convert (text, length, "UTF-16LE", "UTF-8", - NULL, &wlen, &error); + NULL, &wlen, NULL); if (wtext == NULL) return FALSE; @@ -972,6 +982,35 @@ uniscribe_shape (PangoFont *font, return retval; } +static gboolean +text_is_simple (const char *text, + gint length) +{ + gboolean retval; + wchar_t *wtext; + int wlen; + + wtext = (wchar_t *) g_convert (text, length, "UTF-16LE", "UTF-8", + NULL, &wlen, NULL); + + if (wtext == NULL) + return TRUE; + + wlen /= 2; + + retval = ((*script_is_complex) (wtext, wlen, SIC_COMPLEX) == S_FALSE); + + g_free (wtext); + +#ifdef BASIC_WIN32_DEBUGGING + if (pango_win32_debug) + printf ("text_is_simple: %.*s (%d chars): %s\n", + MIN (length, 10), text, wlen, retval ? "YES" : "NO"); +#endif + + return retval; +} + #endif /* HAVE_USP10_H */ static void @@ -993,7 +1032,9 @@ basic_engine_shape (PangoEngineShape *engine, #ifdef HAVE_USP10_H - if (have_uniscribe && uniscribe_shape (font, text, length, analysis, glyphs)) + if (have_uniscribe && + !text_is_simple (text, length) && + uniscribe_shape (font, text, length, analysis, glyphs)) return; #endif @@ -1088,8 +1129,7 @@ init_uniscribe (void) have_uniscribe = FALSE; - if (getenv ("PANGO_WIN32_NO_UNISCRIBE") == NULL && - (usp10_dll = LoadLibrary ("usp10.dll")) != NULL) + if ((usp10_dll = LoadLibrary ("usp10.dll")) != NULL) { (script_get_properties = (pScriptGetProperties) GetProcAddress (usp10_dll, "ScriptGetProperties")) && @@ -1101,12 +1141,15 @@ init_uniscribe (void) GetProcAddress (usp10_dll, "ScriptPlace")) && (script_free_cache = (pScriptFreeCache) GetProcAddress (usp10_dll, "ScriptFreeCache")) && - (have_uniscribe = TRUE); + (script_is_complex = (pScriptIsComplex) + GetProcAddress (usp10_dll, "ScriptIsComplex")) && + (have_uniscribe = TRUE); } if (have_uniscribe) { +#ifdef BASIC_WIN32_DEBUGGING (*script_get_properties) (&scripts, &nscripts); - +#endif font_cache = pango_win32_font_map_get_font_cache (pango_win32_font_map_for_display ()); |