diff options
author | Alexander Larsson <alexl@redhat.com> | 2000-12-21 09:54:01 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2000-12-21 09:54:01 +0000 |
commit | e763eba74d05d9b8948cd5bfa05ab7056f4c52e8 (patch) | |
tree | ea783760274470968a6be3d27e3ef740c635bc44 | |
parent | b00ec4cbd9b6f08884d5ae01099be5f4dc854693 (diff) | |
download | pango-e763eba74d05d9b8948cd5bfa05ab7056f4c52e8.tar.gz |
Change usage to say pango-config instead of glib-config. Add support for
2000-12-21 Alexander Larsson <alexl@redhat.com>
* pango-config.in:
Change usage to say pango-config instead of glib-config.
Add support for pangoft2.
* modules/basic/Makefile.am:
Compile and install pango-basic-ft2 if freetype was found.
* modules/basic/basic-ft2.c:
Remove lang engine. Make the glyph from the glyph index instead
of the unicode index. The id is really BasicScriptEngineFT2.
* pango/Makefile.am:
Compile and install pangoft2 if freetype was found.
* pango/pangoft2-fontcache.c (pango_ft2_font_cache_load):
Init face->generic.data to 0, since this field will be used
to cache the current size of the face.
* pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display):
Use g_object_new instead of g_type_create_instance.
(pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S
instead of \\. (pango_ft2_font_entry_get_coverage): Init result
to NULL. Don't write to file if open failed.
* pango/pangoft2-private.h:
Add PangoFT2GlyphInfo.
* pango/pangoft2.c (pango_ft2_get_face): Export function, and make
sure it sets the correct face size. (pango_ft2_load_font,
pango_ft2_get_per_char, pango_ft2_font_get_kerning):
PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value.
(pango_ft2_font_get_glyph_extents): Cache glyph extents.
(pango_ft2_has_glyph): Remove function.
(pango_ft2_font_finalize): Free glyph info cache.
* pango/pangoft2.h:
Export pango_ft2_get_face, remove pango_ft2_has_glyph.
-rw-r--r-- | ChangeLog | 40 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 40 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 40 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 40 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 40 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 40 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 40 | ||||
-rw-r--r-- | modules/basic/Makefile.am | 13 | ||||
-rw-r--r-- | modules/basic/basic-ft2.c | 22 | ||||
-rw-r--r-- | pango-config.in | 13 | ||||
-rw-r--r-- | pango/Makefile.am | 35 | ||||
-rw-r--r-- | pango/pangoft2-fontcache.c | 3 | ||||
-rw-r--r-- | pango/pangoft2-fontmap.c | 20 | ||||
-rw-r--r-- | pango/pangoft2-private.h | 9 | ||||
-rw-r--r-- | pango/pangoft2.c | 158 | ||||
-rw-r--r-- | pango/pangoft2.h | 16 |
16 files changed, 445 insertions, 124 deletions
@@ -1,3 +1,43 @@ +2000-12-21 Alexander Larsson <alexl@redhat.com> + + * pango-config.in: + Change usage to say pango-config instead of glib-config. + Add support for pangoft2. + + * modules/basic/Makefile.am: + Compile and install pango-basic-ft2 if freetype was found. + + * modules/basic/basic-ft2.c: + Remove lang engine. Make the glyph from the glyph index instead + of the unicode index. The id is really BasicScriptEngineFT2. + + * pango/Makefile.am: + Compile and install pangoft2 if freetype was found. + + * pango/pangoft2-fontcache.c (pango_ft2_font_cache_load): + Init face->generic.data to 0, since this field will be used + to cache the current size of the face. + + * pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display): + Use g_object_new instead of g_type_create_instance. + (pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S + instead of \\. (pango_ft2_font_entry_get_coverage): Init result + to NULL. Don't write to file if open failed. + + * pango/pangoft2-private.h: + Add PangoFT2GlyphInfo. + + * pango/pangoft2.c (pango_ft2_get_face): Export function, and make + sure it sets the correct face size. (pango_ft2_load_font, + pango_ft2_get_per_char, pango_ft2_font_get_kerning): + PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value. + (pango_ft2_font_get_glyph_extents): Cache glyph extents. + (pango_ft2_has_glyph): Remove function. + (pango_ft2_font_finalize): Free glyph info cache. + + * pango/pangoft2.h: + Export pango_ft2_get_face, remove pango_ft2_has_glyph. + Wed Dec 20 19:53:09 2000 Owen Taylor <otaylor@redhat.com> * docs/Makefile.am (IGNORE_HFILES): Add opentype/. diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index 0a65e61e..873a07c8 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,43 @@ +2000-12-21 Alexander Larsson <alexl@redhat.com> + + * pango-config.in: + Change usage to say pango-config instead of glib-config. + Add support for pangoft2. + + * modules/basic/Makefile.am: + Compile and install pango-basic-ft2 if freetype was found. + + * modules/basic/basic-ft2.c: + Remove lang engine. Make the glyph from the glyph index instead + of the unicode index. The id is really BasicScriptEngineFT2. + + * pango/Makefile.am: + Compile and install pangoft2 if freetype was found. + + * pango/pangoft2-fontcache.c (pango_ft2_font_cache_load): + Init face->generic.data to 0, since this field will be used + to cache the current size of the face. + + * pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display): + Use g_object_new instead of g_type_create_instance. + (pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S + instead of \\. (pango_ft2_font_entry_get_coverage): Init result + to NULL. Don't write to file if open failed. + + * pango/pangoft2-private.h: + Add PangoFT2GlyphInfo. + + * pango/pangoft2.c (pango_ft2_get_face): Export function, and make + sure it sets the correct face size. (pango_ft2_load_font, + pango_ft2_get_per_char, pango_ft2_font_get_kerning): + PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value. + (pango_ft2_font_get_glyph_extents): Cache glyph extents. + (pango_ft2_has_glyph): Remove function. + (pango_ft2_font_finalize): Free glyph info cache. + + * pango/pangoft2.h: + Export pango_ft2_get_face, remove pango_ft2_has_glyph. + Wed Dec 20 19:53:09 2000 Owen Taylor <otaylor@redhat.com> * docs/Makefile.am (IGNORE_HFILES): Add opentype/. diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 0a65e61e..873a07c8 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,43 @@ +2000-12-21 Alexander Larsson <alexl@redhat.com> + + * pango-config.in: + Change usage to say pango-config instead of glib-config. + Add support for pangoft2. + + * modules/basic/Makefile.am: + Compile and install pango-basic-ft2 if freetype was found. + + * modules/basic/basic-ft2.c: + Remove lang engine. Make the glyph from the glyph index instead + of the unicode index. The id is really BasicScriptEngineFT2. + + * pango/Makefile.am: + Compile and install pangoft2 if freetype was found. + + * pango/pangoft2-fontcache.c (pango_ft2_font_cache_load): + Init face->generic.data to 0, since this field will be used + to cache the current size of the face. + + * pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display): + Use g_object_new instead of g_type_create_instance. + (pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S + instead of \\. (pango_ft2_font_entry_get_coverage): Init result + to NULL. Don't write to file if open failed. + + * pango/pangoft2-private.h: + Add PangoFT2GlyphInfo. + + * pango/pangoft2.c (pango_ft2_get_face): Export function, and make + sure it sets the correct face size. (pango_ft2_load_font, + pango_ft2_get_per_char, pango_ft2_font_get_kerning): + PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value. + (pango_ft2_font_get_glyph_extents): Cache glyph extents. + (pango_ft2_has_glyph): Remove function. + (pango_ft2_font_finalize): Free glyph info cache. + + * pango/pangoft2.h: + Export pango_ft2_get_face, remove pango_ft2_has_glyph. + Wed Dec 20 19:53:09 2000 Owen Taylor <otaylor@redhat.com> * docs/Makefile.am (IGNORE_HFILES): Add opentype/. diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index 0a65e61e..873a07c8 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,43 @@ +2000-12-21 Alexander Larsson <alexl@redhat.com> + + * pango-config.in: + Change usage to say pango-config instead of glib-config. + Add support for pangoft2. + + * modules/basic/Makefile.am: + Compile and install pango-basic-ft2 if freetype was found. + + * modules/basic/basic-ft2.c: + Remove lang engine. Make the glyph from the glyph index instead + of the unicode index. The id is really BasicScriptEngineFT2. + + * pango/Makefile.am: + Compile and install pangoft2 if freetype was found. + + * pango/pangoft2-fontcache.c (pango_ft2_font_cache_load): + Init face->generic.data to 0, since this field will be used + to cache the current size of the face. + + * pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display): + Use g_object_new instead of g_type_create_instance. + (pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S + instead of \\. (pango_ft2_font_entry_get_coverage): Init result + to NULL. Don't write to file if open failed. + + * pango/pangoft2-private.h: + Add PangoFT2GlyphInfo. + + * pango/pangoft2.c (pango_ft2_get_face): Export function, and make + sure it sets the correct face size. (pango_ft2_load_font, + pango_ft2_get_per_char, pango_ft2_font_get_kerning): + PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value. + (pango_ft2_font_get_glyph_extents): Cache glyph extents. + (pango_ft2_has_glyph): Remove function. + (pango_ft2_font_finalize): Free glyph info cache. + + * pango/pangoft2.h: + Export pango_ft2_get_face, remove pango_ft2_has_glyph. + Wed Dec 20 19:53:09 2000 Owen Taylor <otaylor@redhat.com> * docs/Makefile.am (IGNORE_HFILES): Add opentype/. diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 0a65e61e..873a07c8 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,43 @@ +2000-12-21 Alexander Larsson <alexl@redhat.com> + + * pango-config.in: + Change usage to say pango-config instead of glib-config. + Add support for pangoft2. + + * modules/basic/Makefile.am: + Compile and install pango-basic-ft2 if freetype was found. + + * modules/basic/basic-ft2.c: + Remove lang engine. Make the glyph from the glyph index instead + of the unicode index. The id is really BasicScriptEngineFT2. + + * pango/Makefile.am: + Compile and install pangoft2 if freetype was found. + + * pango/pangoft2-fontcache.c (pango_ft2_font_cache_load): + Init face->generic.data to 0, since this field will be used + to cache the current size of the face. + + * pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display): + Use g_object_new instead of g_type_create_instance. + (pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S + instead of \\. (pango_ft2_font_entry_get_coverage): Init result + to NULL. Don't write to file if open failed. + + * pango/pangoft2-private.h: + Add PangoFT2GlyphInfo. + + * pango/pangoft2.c (pango_ft2_get_face): Export function, and make + sure it sets the correct face size. (pango_ft2_load_font, + pango_ft2_get_per_char, pango_ft2_font_get_kerning): + PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value. + (pango_ft2_font_get_glyph_extents): Cache glyph extents. + (pango_ft2_has_glyph): Remove function. + (pango_ft2_font_finalize): Free glyph info cache. + + * pango/pangoft2.h: + Export pango_ft2_get_face, remove pango_ft2_has_glyph. + Wed Dec 20 19:53:09 2000 Owen Taylor <otaylor@redhat.com> * docs/Makefile.am (IGNORE_HFILES): Add opentype/. diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 0a65e61e..873a07c8 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,43 @@ +2000-12-21 Alexander Larsson <alexl@redhat.com> + + * pango-config.in: + Change usage to say pango-config instead of glib-config. + Add support for pangoft2. + + * modules/basic/Makefile.am: + Compile and install pango-basic-ft2 if freetype was found. + + * modules/basic/basic-ft2.c: + Remove lang engine. Make the glyph from the glyph index instead + of the unicode index. The id is really BasicScriptEngineFT2. + + * pango/Makefile.am: + Compile and install pangoft2 if freetype was found. + + * pango/pangoft2-fontcache.c (pango_ft2_font_cache_load): + Init face->generic.data to 0, since this field will be used + to cache the current size of the face. + + * pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display): + Use g_object_new instead of g_type_create_instance. + (pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S + instead of \\. (pango_ft2_font_entry_get_coverage): Init result + to NULL. Don't write to file if open failed. + + * pango/pangoft2-private.h: + Add PangoFT2GlyphInfo. + + * pango/pangoft2.c (pango_ft2_get_face): Export function, and make + sure it sets the correct face size. (pango_ft2_load_font, + pango_ft2_get_per_char, pango_ft2_font_get_kerning): + PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value. + (pango_ft2_font_get_glyph_extents): Cache glyph extents. + (pango_ft2_has_glyph): Remove function. + (pango_ft2_font_finalize): Free glyph info cache. + + * pango/pangoft2.h: + Export pango_ft2_get_face, remove pango_ft2_has_glyph. + Wed Dec 20 19:53:09 2000 Owen Taylor <otaylor@redhat.com> * docs/Makefile.am (IGNORE_HFILES): Add opentype/. diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 0a65e61e..873a07c8 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,43 @@ +2000-12-21 Alexander Larsson <alexl@redhat.com> + + * pango-config.in: + Change usage to say pango-config instead of glib-config. + Add support for pangoft2. + + * modules/basic/Makefile.am: + Compile and install pango-basic-ft2 if freetype was found. + + * modules/basic/basic-ft2.c: + Remove lang engine. Make the glyph from the glyph index instead + of the unicode index. The id is really BasicScriptEngineFT2. + + * pango/Makefile.am: + Compile and install pangoft2 if freetype was found. + + * pango/pangoft2-fontcache.c (pango_ft2_font_cache_load): + Init face->generic.data to 0, since this field will be used + to cache the current size of the face. + + * pango/pangoft2-fontmap.c (pango_ft2_font_map_for_display): + Use g_object_new instead of g_type_create_instance. + (pango_ft2_font_entry_get_coverage): Use G_DIR_SEPARATOR_S + instead of \\. (pango_ft2_font_entry_get_coverage): Init result + to NULL. Don't write to file if open failed. + + * pango/pangoft2-private.h: + Add PangoFT2GlyphInfo. + + * pango/pangoft2.c (pango_ft2_get_face): Export function, and make + sure it sets the correct face size. (pango_ft2_load_font, + pango_ft2_get_per_char, pango_ft2_font_get_kerning): + PANGO_FT2_GLYPH_INDEX stores the glyph index, not the unicode value. + (pango_ft2_font_get_glyph_extents): Cache glyph extents. + (pango_ft2_has_glyph): Remove function. + (pango_ft2_font_finalize): Free glyph info cache. + + * pango/pangoft2.h: + Export pango_ft2_get_face, remove pango_ft2_has_glyph. + Wed Dec 20 19:53:09 2000 Owen Taylor <otaylor@redhat.com> * docs/Makefile.am (IGNORE_HFILES): Add opentype/. diff --git a/modules/basic/Makefile.am b/modules/basic/Makefile.am index 389013aa..af7cd382 100644 --- a/modules/basic/Makefile.am +++ b/modules/basic/Makefile.am @@ -8,13 +8,20 @@ else XFT_MODULES= endif +if HAVE_FREETYPE +FT2_MODULES=pango-basic-ft2.la +else +FT2_MODULES= +endif + + if INCLUDE_BASIC noinst_LTLIBRARIES = libpango-basic.la moddefine = -DMODULE_PREFIX else moduledir = $(libdir)/pango/modules -module_LTLIBRARIES = $(XFT_MODULES) pango-basic.la +module_LTLIBRARIES = $(FT2_MODULES) $(XFT_MODULES) pango-basic.la moduleflags=-rpath $(libdir) endif @@ -35,6 +42,10 @@ pango_basic_xft_la_LDFLAGS = -rpath $(libdir) -export-dynamic -avoid-version -mo pango_basic_xft_la_LIBADD = pango_basic_xft_la_SOURCES = basic-xft.c +pango_basic_ft2_la_LDFLAGS = -rpath $(libdir) -export-dynamic -avoid-version -module +pango_basic_ft2_la_LIBADD = $(FREETYPE_LIBS) +pango_basic_ft2_la_SOURCES = basic-ft2.c + EXTRA_DIST = \ tables-big.i \ tables-small.i \ diff --git a/modules/basic/basic-ft2.c b/modules/basic/basic-ft2.c index d09c4c41..ed0f3e98 100644 --- a/modules/basic/basic-ft2.c +++ b/modules/basic/basic-ft2.c @@ -20,6 +20,7 @@ */ #include <glib.h> +#include <string.h> #include "pango-layout.h" #include "pangoft2.h" @@ -122,12 +123,13 @@ find_char (PangoFont *font, for (i = 0; i < n_subfonts; i++) { - PangoGlyph glyph; + FT_Face face; + FT_UInt index; - glyph = PANGO_FT2_MAKE_GLYPH (i+1, wc); - - if (pango_ft2_has_glyph (font, glyph)) - return glyph; + face = pango_ft2_get_face (font, i+1); + index = FT_Get_Char_Index (face, wc); + if (index && index <= face->num_glyphs) + return PANGO_FT2_MAKE_GLYPH (i+1, index); } return 0; @@ -281,9 +283,9 @@ basic_engine_get_coverage (PangoFont *font, const char *lang) { PangoCoverage *result = pango_coverage_new (); - gunichar wc; - #if 0 + gunichar wc; + for (wc = 0; wc < 65536; wc++) if (find_char (font, wc)) pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT); @@ -300,7 +302,7 @@ basic_engine_ft2_new (void) result = g_new (PangoEngineShape, 1); - result->engine.id = "BasicScriptEngine"; + result->engine.id = "BasicScriptEngineFT2"; result->engine.type = PANGO_ENGINE_TYPE_SHAPE; result->engine.length = sizeof (result); result->script_shape = basic_engine_shape; @@ -329,9 +331,7 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, PangoEngine * MODULE_ENTRY(script_engine_load) (const char *id) { - if (!strcmp (id, "BasicScriptEngineLangFT2")) - return basic_engine_lang_new (); - else if (!strcmp (id, "BasicScriptEngineFT2")) + if (!strcmp (id, "BasicScriptEngineFT2")) return basic_engine_ft2_new (); else return NULL; diff --git a/pango-config.in b/pango-config.in index d7e71fe2..535969ec 100644 --- a/pango-config.in +++ b/pango-config.in @@ -7,7 +7,7 @@ exec_prefix_set=no usage() { cat <<EOF -Usage: glib-config [OPTIONS] [LIBRARIES] +Usage: pango-config [OPTIONS] [LIBRARIES] Options: [--prefix[=DIR]] [--exec-prefix[=DIR]] @@ -17,6 +17,8 @@ Options: Libraries: pango pangox + pangoxft + pangoft2 EOF exit $1 } @@ -69,6 +71,9 @@ while test $# -gt 0; do pangoxft) lib_pangoxft=yes ;; + pangoft2) + lib_pangoft2=yes + ;; *) usage 1 1>&2 ;; @@ -87,6 +92,9 @@ if test "$echo_cflags" = "yes"; then if test "$lib_pangoxft" = "yes"; then cflags="@X_CFLAGS@ @FREETYPE_CFLAGS@ $cflags" fi + if test "$lib_pangoft2" = "yes"; then + cflags="@FREETYPE_CFLAGS@ $cflags" + fi # Put $cflags first, in case $includes contains a # location with GLib 1.2 headers, but we build with GLib 2.0. echo $cflags $includes @@ -99,5 +107,8 @@ if test "$echo_libs" = "yes"; then if test "$lib_pangoxft" = "yes"; then libs="@XFT_LIBS@ -lpangoxft $libs" fi + if test "$lib_pangoft2" = "yes"; then + libs="@FREETYPE_LIBS@ -lpangoft2 $libs" + fi echo -L@libdir@ $libs fi diff --git a/pango/Makefile.am b/pango/Makefile.am index fd3ae101..66287f9f 100644 --- a/pango/Makefile.am +++ b/pango/Makefile.am @@ -28,7 +28,16 @@ XFT_HFILES= XFT_BUILD_LIBS= endif -lib_LTLIBRARIES = libpango.la libpangox.la $(XFT_BUILD_LIBS) +if HAVE_FREETYPE +FT2_BUILD_LIBS=libpangoft2.la +FT2_HFILES=pangoft2.h +else +FT2_BUILD_LIBS= +FT2_HFILES= +endif + + +lib_LTLIBRARIES = libpango.la libpangox.la $(XFT_BUILD_LIBS) $(FT2_BUILD_LIBS) bin_PROGRAMS = pango-querymodules @@ -87,6 +96,16 @@ libpangoxft_la_SOURCES = \ libpangoxft_la_LIBADD = $(INCLUDED_MODULES) $(XFT_LIBS) opentype/libpango-ot.la libpangoxft_la_LDFLAGS = -release $(VERSION) +libpangoft2_la_SOURCES = \ + pangoft2.h \ + pangoft2.c \ + pangoft2-private.h \ + pangoft2-fontcache.c \ + pangoft2-fontmap.c + +libpangoxft_la_LIBADD = $(INCLUDED_MODULES) $(FREETYPE_LIBS) +libpangoxft_la_LDFLAGS = -release $(VERSION) + pangoincludedir=$(includedir)/pango-1.0/pango pango_headers= \ @@ -111,7 +130,8 @@ pango_headers= \ pangoinclude_HEADERS = \ $(pango_headers) \ $(pango_built_headers) \ - $(XFT_HFILES) + $(XFT_HFILES) \ + $(FT2_HFILES) pango-enum-types.h: @REBUILD@ $(pango_headers) makeenums.pl $(PERL) ./makeenums.pl include $(pango_headers) > pango-enum-types.h @@ -124,10 +144,11 @@ pango-enum-types.c: @REBUILD@ $(pango_headers) makeenums.pl # pango_querymodules_SOURCES = \ querymodules.c + if HAVE_XFT -pango_querymodules_LDADD = libpangox.la libpangoxft.la libpango.la $(GLIB_LIBS) $(FRIBIDI_LIBS) $(XFT_LIBS) +pango_querymodules_LDADD = $(FT2_BUILD_LIBS) libpangox.la libpangoxft.la libpango.la $(GLIB_LIBS) $(FRIBIDI_LIBS) $(XFT_LIBS) $(FREETYPE_LIBS) else -pango_querymodules_LDADD = libpangox.la libpango.la $(GLIB_LIBS) $(FRIBIDI_LIBS) $(X_LIBS) +pango_querymodules_LDADD = $(FT2_BUILD_LIBS) libpangox.la libpango.la $(GLIB_LIBS) $(FRIBIDI_LIBS) $(X_LIBS) $(FREETYPE_LIBS) endif EXTRA_DIST = \ @@ -142,11 +163,6 @@ EXTRA_DIST = \ pangowin32-fontcache.c \ pangowin32-fontmap.c \ pangoft2.def \ - pangoft2.h \ - pangoft2.c \ - pangoft2-private.h \ - pangoft2-fontcache.c \ - pangoft2-fontmap.c \ makefile.mingw \ makefile.mingw.in \ pango.rc \ @@ -155,3 +171,4 @@ EXTRA_DIST = \ pangoft2.rc.in \ pangowin32.rc \ pangowin32.rc.in + diff --git a/pango/pangoft2-fontcache.c b/pango/pangoft2-fontcache.c index 74a03edc..4ae5958c 100644 --- a/pango/pangoft2-fontcache.c +++ b/pango/pangoft2-fontcache.c @@ -218,7 +218,8 @@ pango_ft2_font_cache_load (PangoFT2FontCache *cache, pango_ft2_ft_strerror (error)); return NULL; } - + + face->generic.data = 0; PING ((" = %p", face)); entry = g_new (CacheEntry, 1); diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c index 92a051a5..6728361c 100644 --- a/pango/pangoft2-fontmap.c +++ b/pango/pangoft2-fontmap.c @@ -311,7 +311,7 @@ pango_ft2_font_map_for_display (void) if (pango_ft2_global_fontmap != NULL) return PANGO_FONT_MAP (pango_ft2_global_fontmap); - pango_ft2_global_fontmap = (PangoFT2FontMap *)g_type_create_instance (PANGO_TYPE_FT2_FONT_MAP); + pango_ft2_global_fontmap = (PangoFT2FontMap *)g_object_new (PANGO_TYPE_FT2_FONT_MAP, NULL); error = FT_Init_FreeType (&pango_ft2_global_fontmap->library); if (error != FT_Err_Ok) @@ -953,7 +953,7 @@ pango_ft2_font_entry_get_coverage (PangoFT2FontEntry *entry, description = pango_font_describe (font); cache_file_name = g_strconcat (pango_get_sysconf_subdirectory (), - "\\cache.ft2\\", + G_DIR_SEPARATOR_S "cache.ft2" G_DIR_SEPARATOR_S, pango_font_description_to_filename (description), ".", lang ? lang : "", @@ -961,6 +961,7 @@ pango_ft2_font_entry_get_coverage (PangoFT2FontEntry *entry, pango_font_description_free (description); PING (("trying to load %s", cache_file_name)); + result = NULL; if (g_file_get_contents (cache_file_name, &buf, &buflen, NULL)) { result = pango_coverage_from_bytes (buf, buflen); @@ -1001,12 +1002,15 @@ pango_ft2_font_entry_get_coverage (PangoFT2FontEntry *entry, g_hash_table_destroy (coverage_hash); cache_file = fopen (cache_file_name, "wb"); - pango_coverage_to_bytes (result, &buf, &buflen); - PING (("saving %d bytes to %s", buflen, cache_file_name)); - fwrite (buf, buflen, 1, cache_file); - fclose (cache_file); - g_free (cache_file_name); - g_free (buf); + if (cache_file) + { + pango_coverage_to_bytes (result, &buf, &buflen); + PING (("saving %d bytes to %s", buflen, cache_file_name)); + fwrite (buf, buflen, 1, cache_file); + fclose (cache_file); + g_free (cache_file_name); + g_free (buf); + } } if (entry) diff --git a/pango/pangoft2-private.h b/pango/pangoft2-private.h index 54008904..48b8453a 100644 --- a/pango/pangoft2-private.h +++ b/pango/pangoft2-private.h @@ -54,6 +54,7 @@ typedef struct _PangoFT2OA PangoFT2OA; typedef struct _PangoFT2Font PangoFT2Font; +typedef struct _PangoFT2GlyphInfo PangoFT2GlyphInfo; typedef struct _PangoFT2FontEntry PangoFT2FontEntry; typedef struct _PangoFT2SubfontInfo PangoFT2SubfontInfo; @@ -88,6 +89,14 @@ struct _PangoFT2Font gboolean in_cache; PangoFT2FontEntry *entry; + + GHashTable *glyph_info; +}; + +struct _PangoFT2GlyphInfo +{ + PangoRectangle logical_rect; + PangoRectangle ink_rect; }; struct _PangoFT2FontEntry diff --git a/pango/pangoft2.c b/pango/pangoft2.c index 7203df4b..1ec1a66f 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -101,12 +101,14 @@ pango_ft2_open_args_describe (PangoFT2OA *oa) return g_strdup_printf ("open_args at %p, face_index %ld", oa->open_args, oa->face_index); } -static inline FT_Face +FT_Face pango_ft2_get_face (PangoFont *font, PangoFT2Subfont subfont_index) { PangoFT2Font *ft2font = (PangoFT2Font *)font; PangoFT2FontCache *cache; + FT_Face face; + FT_Error error; if (subfont_index < 1 || subfont_index > ft2font->n_fonts) { @@ -127,7 +129,19 @@ pango_ft2_get_face (PangoFont *font, g_warning ("Cannot load font for %s", pango_ft2_open_args_describe (ft2font->oa[subfont_index-1])); } - return ft2font->faces[subfont_index-1]; + + face = ft2font->faces[subfont_index-1]; + + if (ft2font->size != GPOINTER_TO_UINT (face->generic.data)) + { + face->generic.data = GUINT_TO_POINTER (ft2font->size); + + error = FT_Set_Char_Size (face, 0, PANGO_PIXELS_26_6 (ft2font->size), 72, 72); + if (error) + g_warning ("Error in FT_Set_Char_Size: %d", error); + } + + return face; } /** @@ -187,6 +201,7 @@ pango_ft2_font_init (PangoFT2Font *ft2font) ft2font->metrics_by_lang = NULL; ft2font->entry = NULL; + ft2font->glyph_info = g_hash_table_new (NULL, NULL); } static void @@ -234,7 +249,7 @@ pango_ft2_load_font (PangoFontMap *fontmap, g_return_val_if_fail (face_indices != NULL, NULL); g_return_val_if_fail (n_fonts > 0, NULL); - result = (PangoFT2Font *)g_type_create_instance (PANGO_TYPE_FT2_FONT); + result = (PangoFT2Font *)g_object_new (PANGO_TYPE_FT2_FONT, NULL); result->fontmap = fontmap; g_object_ref (G_OBJECT (result->fontmap)); @@ -278,7 +293,6 @@ pango_ft2_render (FT_Bitmap *bitmap, int i; int x_position = 0; int ix, iy, ixoff, iyoff, y_start, y_limit, x_start, x_limit; - guint16 char_index; PangoFT2Subfont subfont_index; PangoGlyphInfo *gi; guchar *p, *q; @@ -293,14 +307,13 @@ pango_ft2_render (FT_Bitmap *bitmap, { if (gi->glyph) { - char_index = PANGO_FT2_GLYPH_INDEX (gi->glyph); + glyph_index = PANGO_FT2_GLYPH_INDEX (gi->glyph); subfont_index = PANGO_FT2_GLYPH_SUBFONT (gi->glyph); face = pango_ft2_get_face (font, subfont_index); if (face) { /* Draw glyph */ - glyph_index = FT_Get_Char_Index (face, char_index); /* FIXME hint or not? */ FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT); FT_Render_Glyph (face->glyph, ft_render_mode_normal); @@ -374,24 +387,13 @@ pango_ft2_render (FT_Bitmap *bitmap, static FT_Glyph_Metrics * pango_ft2_get_per_char (PangoFont *font, PangoFT2Subfont subfont_index, - guint16 char_index) + guint32 glyph_index) { - PangoFT2Font *ft2font = (PangoFT2Font *)font; FT_Face face; - FT_UInt glyph_index; - FT_Error error; if (!(face = pango_ft2_get_face (font, subfont_index))) return NULL; - glyph_index = FT_Get_Char_Index (face, char_index); - if (!glyph_index) - return NULL; - - error = FT_Set_Pixel_Sizes (face, PANGO_PIXELS (ft2font->size), 0); - if (error) - g_warning ("Error in FT_Set_Pixel_Sizes: %d", error); - FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT); return &face->glyph->metrics; } @@ -402,50 +404,55 @@ pango_ft2_font_get_glyph_extents (PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect) { - guint16 char_index = PANGO_FT2_GLYPH_INDEX (glyph); - PangoFT2Subfont subfont_index = PANGO_FT2_GLYPH_SUBFONT (glyph); + PangoFT2Font *ft2font = (PangoFT2Font *)font; + PangoFT2GlyphInfo *info; + PangoFT2Subfont subfont_index; + FT_UInt glyph_index; FT_Glyph_Metrics *gm; - if (glyph && (gm = pango_ft2_get_per_char (font, subfont_index, char_index))) + info = g_hash_table_lookup (ft2font->glyph_info, GUINT_TO_POINTER (glyph)); + + if (!info) { - if (ink_rect) - { - ink_rect->x = PANGO_UNITS_26_6 (gm->horiBearingX); - ink_rect->width = PANGO_UNITS_26_6 (gm->width); - ink_rect->y = -PANGO_UNITS_26_6 (gm->horiBearingY); - ink_rect->height = PANGO_UNITS_26_6 (gm->height); - } - if (logical_rect) + info = g_new (PangoFT2GlyphInfo, 1); + glyph_index = PANGO_FT2_GLYPH_INDEX (glyph); + subfont_index = PANGO_FT2_GLYPH_SUBFONT (glyph); + + if (glyph && (gm = pango_ft2_get_per_char (font, subfont_index, glyph_index))) { FT_Face face = pango_ft2_get_face (font, subfont_index); - - logical_rect->x = 0; - logical_rect->width = PANGO_UNITS_26_6 (gm->horiAdvance); - logical_rect->y = -PANGO_UNITS_26_6 (face->size->metrics.ascender + 64); + + info->ink_rect.x = PANGO_UNITS_26_6 (gm->horiBearingX); + info->ink_rect.width = PANGO_UNITS_26_6 (gm->width); + info->ink_rect.y = -PANGO_UNITS_26_6 (gm->horiBearingY); + info->ink_rect.height = PANGO_UNITS_26_6 (gm->height); + + info->logical_rect.x = 0; + info->logical_rect.width = PANGO_UNITS_26_6 (gm->horiAdvance); + info->logical_rect.y = -PANGO_UNITS_26_6 (face->size->metrics.ascender + 64); /* Some fonts report negative descender, some positive ! (?) */ - logical_rect->height = PANGO_UNITS_26_6 (face->size->metrics.ascender + ABS (face->size->metrics.descender) + 128); + info->logical_rect.height = PANGO_UNITS_26_6 (face->size->metrics.ascender + ABS (face->size->metrics.descender) + 128); } - PING (("glyph:%d logical: %dx%d@%d+%d", - char_index, logical_rect->width, logical_rect->height, - logical_rect->x, logical_rect->y)); - } - else - { - if (ink_rect) - { - ink_rect->x = 0; - ink_rect->width = 0; - ink_rect->y = 0; - ink_rect->height = 0; - } - if (logical_rect) + else { - logical_rect->x = 0; - logical_rect->width = 0; - logical_rect->y = 0; - logical_rect->height = 0; + info->ink_rect.x = 0; + info->ink_rect.width = 0; + info->ink_rect.y = 0; + info->ink_rect.height = 0; + + info->logical_rect.x = 0; + info->logical_rect.width = 0; + info->logical_rect.y = 0; + info->logical_rect.height = 0; } + + g_hash_table_insert (ft2font->glyph_info, GUINT_TO_POINTER(glyph), info); } + + if (ink_rect) + *ink_rect = info->ink_rect; + if (logical_rect) + *logical_rect = info->logical_rect; } int @@ -454,8 +461,6 @@ pango_ft2_font_get_kerning (PangoFont *font, PangoGlyph right) { PangoFT2Subfont subfont_index; - guint16 left_char_index; - guint16 right_char_index; FT_Face face; FT_UInt left_glyph_index, right_glyph_index; FT_Error error; @@ -472,12 +477,10 @@ pango_ft2_font_get_kerning (PangoFont *font, if (!FT_HAS_KERNING (face)) return 0; - left_char_index = PANGO_FT2_GLYPH_INDEX (left); - right_char_index = PANGO_FT2_GLYPH_INDEX (right); + left_glyph_index = PANGO_FT2_GLYPH_INDEX (left); + right_glyph_index = PANGO_FT2_GLYPH_INDEX (right); - left_glyph_index = FT_Get_Char_Index (face, left_char_index); - right_glyph_index = FT_Get_Char_Index (face, right_char_index); - if (!left_glyph_index || !right_char_index) + if (!left_glyph_index || !right_glyph_index) return 0; error = FT_Get_Kerning (face, left_glyph_index, right_glyph_index, @@ -730,33 +733,6 @@ pango_ft2_n_subfonts (PangoFont *font) return ft2font->n_fonts; } -/** - * pango_ft2_has_glyph: - * @font: a #PangoFont which must be from the FreeType2 backend. - * @glyph: the index of a glyph in the font. (Formed - * using the PANGO_FT2_MAKE_GLYPH macro) - * - * Check if the given glyph is present in a FT2 font. - * - * Return value: %TRUE if the glyph is present. - **/ -gboolean -pango_ft2_has_glyph (PangoFont *font, - PangoGlyph glyph) -{ - guint16 char_index = PANGO_FT2_GLYPH_INDEX (glyph); - PangoFT2Subfont subfont_index = PANGO_FT2_GLYPH_SUBFONT (glyph); - FT_Face face = pango_ft2_get_face (font, subfont_index); - - if (!face) - return FALSE; - - if (FT_Get_Char_Index (face, char_index) == 0) - return FALSE; - else - return TRUE; -} - PangoCoverage * pango_ft2_get_coverage (PangoFont *font, const char *lang) @@ -848,6 +824,13 @@ pango_ft2_font_shutdown (GObject *object) } +static gboolean +pango_ft2_free_glyph_info_callback (gpointer key, gpointer value, gpointer data) +{ + g_free (value); + return TRUE; +} + static void pango_ft2_font_finalize (GObject *object) { @@ -874,6 +857,9 @@ pango_ft2_font_finalize (GObject *object) g_object_unref (G_OBJECT (ft2font->fontmap)); + g_hash_table_foreach_remove (ft2font->glyph_info, pango_ft2_free_glyph_info_callback, NULL); + g_hash_table_destroy (ft2font->glyph_info); + G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/pango/pangoft2.h b/pango/pangoft2.h index 6cd8ecfe..4cd98781 100644 --- a/pango/pangoft2.h +++ b/pango/pangoft2.h @@ -66,13 +66,15 @@ typedef guint16 PangoFT2Subfont; #define PANGO_FT2_GLYPH_SUBFONT(glyph) ((glyph)>>16) #define PANGO_FT2_GLYPH_INDEX(glyph) ((glyph) & 0xFFFF) -int pango_ft2_n_subfonts (PangoFont *font); -gboolean pango_ft2_has_glyph (PangoFont *font, - PangoGlyph glyph); -PangoGlyph pango_ft2_get_unknown_glyph (PangoFont *font); -int pango_ft2_font_get_kerning (PangoFont *font, - PangoGlyph left, - PangoGlyph right); +int pango_ft2_n_subfonts (PangoFont *font); +PangoGlyph pango_ft2_get_unknown_glyph (PangoFont *font); +int pango_ft2_font_get_kerning (PangoFont *font, + PangoGlyph left, + PangoGlyph right); +PangoCoverage *pango_ft2_get_coverage (PangoFont *font, + const char *lang); +FT_Face pango_ft2_get_face (PangoFont *font, + PangoFT2Subfont subfont_index); /* API for libraries that want to use PangoFT2 mixed with classic * FT2 fonts. |