summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2000-11-19 21:09:07 +0000
committerTor Lillqvist <tml@src.gnome.org>2000-11-19 21:09:07 +0000
commit4cd0ea80ed9b8d768eb4e736403ae195f18eaccd (patch)
tree282d90f7d521354b3dce213695a802d9a87aa0da
parentad9f543f410a0e7bbdbadafa42c75bc04ff2be58 (diff)
downloadpango-4cd0ea80ed9b8d768eb4e736403ae195f18eaccd.tar.gz
New file.
2000-11-19 Tor Lillqvist <tml@iki.fi> * README.win32: New file. * pango/fonts.c (pango_font_description_to_filename): New function. As pango_font_description_to_string, but with result that is better suitable as a filename: No spaces or other strange characters, all in lowercase. (pango_font_describe): Implement this function, call the corresponding method. * pango/pango-font.h: Declare pango_font_description_to_filename. * pango/pangowin32.c (pango_win32_font_describe) * pango/pangoft2.c (pango_ft2_font_describe): Implement these. * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage) * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage): Implement file-based persistent caching of coverages. * pango/pangoft2-private.h (struct _PangoFT2FontEntry) * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move struct definition here from the -fontmap files. * pango/pango.def: Updates.
-rw-r--r--ChangeLog26
-rw-r--r--ChangeLog.pre-1-026
-rw-r--r--ChangeLog.pre-1-1026
-rw-r--r--ChangeLog.pre-1-226
-rw-r--r--ChangeLog.pre-1-426
-rw-r--r--ChangeLog.pre-1-626
-rw-r--r--ChangeLog.pre-1-826
-rw-r--r--README.win325
-rw-r--r--pango/fonts.c45
-rw-r--r--pango/pango-font.h1
-rw-r--r--pango/pango.def4
-rw-r--r--pango/pangoft2-fontcache.c10
-rw-r--r--pango/pangoft2-fontmap.c89
-rw-r--r--pango/pangoft2-private.h21
-rw-r--r--pango/pangoft2.c19
-rw-r--r--pango/pangowin32-fontmap.c108
-rw-r--r--pango/pangowin32-private.h14
-rw-r--r--pango/pangowin32.c6
18 files changed, 403 insertions, 101 deletions
diff --git a/ChangeLog b/ChangeLog
index 80621f71..9fc85fa2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2000-11-19 Tor Lillqvist <tml@iki.fi>
+
+ * README.win32: New file.
+
+ * pango/fonts.c (pango_font_description_to_filename): New
+ function. As pango_font_description_to_string, but with result
+ that is better suitable as a filename: No spaces or other strange
+ characters, all in lowercase.
+ (pango_font_describe): Implement this function, call the
+ corresponding method.
+
+ * pango/pango-font.h: Declare pango_font_description_to_filename.
+
+ * pango/pangowin32.c (pango_win32_font_describe)
+ * pango/pangoft2.c (pango_ft2_font_describe): Implement these.
+
+ * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage)
+ * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage):
+ Implement file-based persistent caching of coverages.
+
+ * pango/pangoft2-private.h (struct _PangoFT2FontEntry)
+ * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move
+ struct definition here from the -fontmap files.
+
+ * pango/pango.def: Updates.
+
Fri Nov 17 16:12:34 2000 Owen Taylor <otaylor@redhat.com>
* Released 0.13
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index 80621f71..9fc85fa2 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,29 @@
+2000-11-19 Tor Lillqvist <tml@iki.fi>
+
+ * README.win32: New file.
+
+ * pango/fonts.c (pango_font_description_to_filename): New
+ function. As pango_font_description_to_string, but with result
+ that is better suitable as a filename: No spaces or other strange
+ characters, all in lowercase.
+ (pango_font_describe): Implement this function, call the
+ corresponding method.
+
+ * pango/pango-font.h: Declare pango_font_description_to_filename.
+
+ * pango/pangowin32.c (pango_win32_font_describe)
+ * pango/pangoft2.c (pango_ft2_font_describe): Implement these.
+
+ * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage)
+ * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage):
+ Implement file-based persistent caching of coverages.
+
+ * pango/pangoft2-private.h (struct _PangoFT2FontEntry)
+ * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move
+ struct definition here from the -fontmap files.
+
+ * pango/pango.def: Updates.
+
Fri Nov 17 16:12:34 2000 Owen Taylor <otaylor@redhat.com>
* Released 0.13
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 80621f71..9fc85fa2 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,29 @@
+2000-11-19 Tor Lillqvist <tml@iki.fi>
+
+ * README.win32: New file.
+
+ * pango/fonts.c (pango_font_description_to_filename): New
+ function. As pango_font_description_to_string, but with result
+ that is better suitable as a filename: No spaces or other strange
+ characters, all in lowercase.
+ (pango_font_describe): Implement this function, call the
+ corresponding method.
+
+ * pango/pango-font.h: Declare pango_font_description_to_filename.
+
+ * pango/pangowin32.c (pango_win32_font_describe)
+ * pango/pangoft2.c (pango_ft2_font_describe): Implement these.
+
+ * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage)
+ * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage):
+ Implement file-based persistent caching of coverages.
+
+ * pango/pangoft2-private.h (struct _PangoFT2FontEntry)
+ * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move
+ struct definition here from the -fontmap files.
+
+ * pango/pango.def: Updates.
+
Fri Nov 17 16:12:34 2000 Owen Taylor <otaylor@redhat.com>
* Released 0.13
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 80621f71..9fc85fa2 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,29 @@
+2000-11-19 Tor Lillqvist <tml@iki.fi>
+
+ * README.win32: New file.
+
+ * pango/fonts.c (pango_font_description_to_filename): New
+ function. As pango_font_description_to_string, but with result
+ that is better suitable as a filename: No spaces or other strange
+ characters, all in lowercase.
+ (pango_font_describe): Implement this function, call the
+ corresponding method.
+
+ * pango/pango-font.h: Declare pango_font_description_to_filename.
+
+ * pango/pangowin32.c (pango_win32_font_describe)
+ * pango/pangoft2.c (pango_ft2_font_describe): Implement these.
+
+ * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage)
+ * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage):
+ Implement file-based persistent caching of coverages.
+
+ * pango/pangoft2-private.h (struct _PangoFT2FontEntry)
+ * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move
+ struct definition here from the -fontmap files.
+
+ * pango/pango.def: Updates.
+
Fri Nov 17 16:12:34 2000 Owen Taylor <otaylor@redhat.com>
* Released 0.13
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 80621f71..9fc85fa2 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,29 @@
+2000-11-19 Tor Lillqvist <tml@iki.fi>
+
+ * README.win32: New file.
+
+ * pango/fonts.c (pango_font_description_to_filename): New
+ function. As pango_font_description_to_string, but with result
+ that is better suitable as a filename: No spaces or other strange
+ characters, all in lowercase.
+ (pango_font_describe): Implement this function, call the
+ corresponding method.
+
+ * pango/pango-font.h: Declare pango_font_description_to_filename.
+
+ * pango/pangowin32.c (pango_win32_font_describe)
+ * pango/pangoft2.c (pango_ft2_font_describe): Implement these.
+
+ * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage)
+ * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage):
+ Implement file-based persistent caching of coverages.
+
+ * pango/pangoft2-private.h (struct _PangoFT2FontEntry)
+ * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move
+ struct definition here from the -fontmap files.
+
+ * pango/pango.def: Updates.
+
Fri Nov 17 16:12:34 2000 Owen Taylor <otaylor@redhat.com>
* Released 0.13
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 80621f71..9fc85fa2 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,29 @@
+2000-11-19 Tor Lillqvist <tml@iki.fi>
+
+ * README.win32: New file.
+
+ * pango/fonts.c (pango_font_description_to_filename): New
+ function. As pango_font_description_to_string, but with result
+ that is better suitable as a filename: No spaces or other strange
+ characters, all in lowercase.
+ (pango_font_describe): Implement this function, call the
+ corresponding method.
+
+ * pango/pango-font.h: Declare pango_font_description_to_filename.
+
+ * pango/pangowin32.c (pango_win32_font_describe)
+ * pango/pangoft2.c (pango_ft2_font_describe): Implement these.
+
+ * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage)
+ * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage):
+ Implement file-based persistent caching of coverages.
+
+ * pango/pangoft2-private.h (struct _PangoFT2FontEntry)
+ * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move
+ struct definition here from the -fontmap files.
+
+ * pango/pango.def: Updates.
+
Fri Nov 17 16:12:34 2000 Owen Taylor <otaylor@redhat.com>
* Released 0.13
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 80621f71..9fc85fa2 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,29 @@
+2000-11-19 Tor Lillqvist <tml@iki.fi>
+
+ * README.win32: New file.
+
+ * pango/fonts.c (pango_font_description_to_filename): New
+ function. As pango_font_description_to_string, but with result
+ that is better suitable as a filename: No spaces or other strange
+ characters, all in lowercase.
+ (pango_font_describe): Implement this function, call the
+ corresponding method.
+
+ * pango/pango-font.h: Declare pango_font_description_to_filename.
+
+ * pango/pangowin32.c (pango_win32_font_describe)
+ * pango/pangoft2.c (pango_ft2_font_describe): Implement these.
+
+ * pango/pangoft2-fontmap.c (pango_ft2_font_entry_get_coverage)
+ * pango/pangowin32-fontmap.c (pango_win32_font_entry_get_coverage):
+ Implement file-based persistent caching of coverages.
+
+ * pango/pangoft2-private.h (struct _PangoFT2FontEntry)
+ * pango/pangowin32-private.h (struct _PangoWin32FontEntry): Move
+ struct definition here from the -fontmap files.
+
+ * pango/pango.def: Updates.
+
Fri Nov 17 16:12:34 2000 Owen Taylor <otaylor@redhat.com>
* Released 0.13
diff --git a/README.win32 b/README.win32
new file mode 100644
index 00000000..96d90ac4
--- /dev/null
+++ b/README.win32
@@ -0,0 +1,5 @@
+There are two Pango backends written for Win32: pangowin32 and
+pangoft2. Pangowin32 uses the Win32 GDI font API. Pangoft2 uses
+FreeType2. Neither one is even close to being as useable as the X11
+backend. They are buggy and slow, and print copious amounts of
+debugging output.
diff --git a/pango/fonts.c b/pango/fonts.c
index ed27e646..d0bee3d3 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -365,6 +365,35 @@ pango_font_description_to_string (const PangoFontDescription *desc)
return str;
}
+/**
+ * pango_font_description_to_filename:
+ * @desc: a #PangoFontDescription
+ *
+ * Create a filename representation of a font description. The
+ * filename is identical to the result from calling
+ * pango_font_description_to_string(), but with underscores instead of
+ * characters that are untypical in filenames, and in lower case only.
+ *
+ * Return value: a new string that must be freed with g_free().
+ **/
+char *
+pango_font_description_to_filename (const PangoFontDescription *desc)
+{
+ char *result = pango_font_description_to_string (desc);
+ char *p;
+
+ g_strdown (result);
+ p = result;
+ while (*p)
+ {
+ if (strchr ("-_.", *p) == NULL && !isalnum (*p))
+ *p = '_';
+ p++;
+ }
+
+ return result;
+}
+
GType
pango_font_get_type (void)
{
@@ -394,6 +423,22 @@ pango_font_get_type (void)
}
/**
+ * pango_font_describe:
+ * @font: a #PangoFont
+ *
+ * Return a description of the font.
+ *
+ * Return value: a newly allocated #PangoFontDescription object.
+ **/
+PangoFontDescription *
+pango_font_describe (PangoFont *font)
+{
+ g_return_val_if_fail (font != NULL, NULL);
+
+ return PANGO_FONT_GET_CLASS (font)->describe (font);
+}
+
+/**
* pango_font_get_coverage:
* @font: a #PangoFont
* @lang: the language tag (in the form of "en_US")
diff --git a/pango/pango-font.h b/pango/pango-font.h
index 9425d5cf..cac1b7bb 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -101,6 +101,7 @@ void pango_font_descriptions_free (PangoFontDescription
PangoFontDescription *pango_font_description_from_string (const char *str);
char * pango_font_description_to_string (const PangoFontDescription *desc);
+char * pango_font_description_to_filename (const PangoFontDescription *desc);
/* Logical fonts
diff --git a/pango/pango.def b/pango/pango.def
index 1bedfb14..7842759f 100644
--- a/pango/pango.def
+++ b/pango/pango.def
@@ -47,17 +47,21 @@ EXPORTS
pango_context_set_font_description
pango_context_set_lang
pango_coverage_copy
+ pango_coverage_from_bytes
pango_coverage_get
pango_coverage_max
pango_coverage_new
pango_coverage_ref
pango_coverage_set
+ pango_coverage_to_bytes
pango_coverage_unref
pango_find_map
+ pango_font_describe
pango_font_description_copy
pango_font_description_equal
pango_font_description_free
pango_font_description_from_string
+ pango_font_description_to_filename
pango_font_description_to_string
pango_font_descriptions_free
pango_font_find_shaper
diff --git a/pango/pangoft2-fontcache.c b/pango/pangoft2-fontcache.c
index 4d895205..74a03edc 100644
--- a/pango/pangoft2-fontcache.c
+++ b/pango/pangoft2-fontcache.c
@@ -61,7 +61,7 @@ free_cache_entry (PangoFT2OA *oa,
{
FT_Error error;
- PING (("FT_Done_Face (%p)\n", entry->face));
+ PING (("FT_Done_Face (%p)", entry->face));
error = FT_Done_Face (entry->face);
if (error != FT_Err_Ok)
@@ -162,7 +162,7 @@ cache_entry_unref (PangoFT2FontCache *cache,
CacheEntry *entry)
{
entry->ref_count--;
- PING (("face:%p ref_count:%d\n", entry->face, entry->ref_count));
+ PING (("face:%p ref_count:%d", entry->face, entry->ref_count));
if (entry->ref_count == 0)
{
g_hash_table_remove (cache->forward, &entry->oa);
@@ -209,7 +209,7 @@ pango_ft2_font_cache_load (PangoFT2FontCache *cache,
FT_Face face;
FT_Error error;
- PING (("FT_Open_Face (%s,%ld)\n", args->pathname, face_index));
+ PING (("FT_Open_Face (%s,%ld)", args->pathname, face_index));
error = FT_Open_Face (cache->library, args, face_index, &face);
if (error != FT_Err_Ok)
@@ -219,7 +219,7 @@ pango_ft2_font_cache_load (PangoFT2FontCache *cache,
return NULL;
}
- PING ((" = %p\n", face));
+ PING ((" = %p", face));
entry = g_new (CacheEntry, 1);
@@ -304,6 +304,6 @@ pango_ft2_font_cache_unload (PangoFT2FontCache *cache,
entry = g_hash_table_lookup (cache->back, face);
g_return_if_fail (entry != NULL);
- PING (("pango_ft2_font_cache_unload\n"));
+ PING (("pango_ft2_font_cache_unload"));
cache_entry_unref (cache, entry);
}
diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c
index c0a2256f..92a051a5 100644
--- a/pango/pangoft2-fontmap.c
+++ b/pango/pangoft2-fontmap.c
@@ -89,17 +89,6 @@ struct _PangoFT2FamilyEntry
GSList *font_entries;
};
-struct _PangoFT2FontEntry
-{
- FT_Open_Args **open_args;
- FT_Long *face_indices;
- int n_fonts;
- PangoFontDescription description;
- PangoCoverage *coverage;
-
- GSList *cached_fonts;
-};
-
static GType pango_ft2_font_map_get_type (void);
static void pango_ft2_font_map_init (PangoFT2FontMap *fontmap);
@@ -886,7 +875,7 @@ pango_ft2_insert_face (PangoFT2FontMap *ft2fontmap,
g_free (description->family_name);
g_free (description);
#if 0
- PING ((" family and description matched (!)\n"));
+ PING ((" family and description matched (!)"));
#endif
return;
}
@@ -949,6 +938,11 @@ pango_ft2_font_entry_get_coverage (PangoFT2FontEntry *entry,
PangoCoverageLevel font_level;
PangoMapEntry *map_entry;
GHashTable *coverage_hash;
+ PangoFontDescription *description;
+ FILE *cache_file;
+ gchar *cache_file_name;
+ guchar *buf;
+ int buflen;
if (entry)
if (entry->coverage)
@@ -957,36 +951,63 @@ pango_ft2_font_entry_get_coverage (PangoFT2FontEntry *entry,
return entry->coverage;
}
- result = pango_coverage_new ();
+ description = pango_font_describe (font);
+ cache_file_name = g_strconcat (pango_get_sysconf_subdirectory (),
+ "\\cache.ft2\\",
+ pango_font_description_to_filename (description),
+ ".",
+ lang ? lang : "",
+ NULL);
+ pango_font_description_free (description);
+
+ PING (("trying to load %s", cache_file_name));
+ if (g_file_get_contents (cache_file_name, &buf, &buflen, NULL))
+ {
+ result = pango_coverage_from_bytes (buf, buflen);
+ g_free (buf);
+ }
+
+ if (!result)
+ {
+ result = pango_coverage_new ();
- coverage_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ coverage_hash = g_hash_table_new (g_str_hash, g_str_equal);
- shape_map = pango_ft2_get_shaper_map (lang);
+ shape_map = pango_ft2_get_shaper_map (lang);
- for (ch = 0; ch < 65536; ch++)
- {
- map_entry = pango_map_get_entry (shape_map, ch);
- if (map_entry->info)
+ for (ch = 0; ch < 65536; ch++)
{
- coverage = g_hash_table_lookup (coverage_hash, map_entry->info->id);
- if (!coverage)
+ map_entry = pango_map_get_entry (shape_map, ch);
+ if (map_entry->info)
{
- PangoEngineShape *engine = (PangoEngineShape *)pango_map_get_engine (shape_map, ch);
- coverage = engine->get_coverage (font, lang);
- g_hash_table_insert (coverage_hash, map_entry->info->id, coverage);
- }
-
- font_level = pango_coverage_get (coverage, ch);
- if (font_level == PANGO_COVERAGE_EXACT && !map_entry->is_exact)
- font_level = PANGO_COVERAGE_APPROXIMATE;
+ coverage = g_hash_table_lookup (coverage_hash, map_entry->info->id);
+ if (!coverage)
+ {
+ PangoEngineShape *engine = (PangoEngineShape *)pango_map_get_engine (shape_map, ch);
+ coverage = engine->get_coverage (font, lang);
+ g_hash_table_insert (coverage_hash, map_entry->info->id, coverage);
+ }
+
+ font_level = pango_coverage_get (coverage, ch);
+ if (font_level == PANGO_COVERAGE_EXACT && !map_entry->is_exact)
+ font_level = PANGO_COVERAGE_APPROXIMATE;
- if (font_level != PANGO_COVERAGE_NONE)
- pango_coverage_set (result, ch, font_level);
+ if (font_level != PANGO_COVERAGE_NONE)
+ pango_coverage_set (result, ch, font_level);
+ }
}
- }
- g_hash_table_foreach (coverage_hash, free_coverages_foreach, NULL);
- g_hash_table_destroy (coverage_hash);
+ g_hash_table_foreach (coverage_hash, free_coverages_foreach, NULL);
+ 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 (entry)
{
diff --git a/pango/pangoft2-private.h b/pango/pangoft2-private.h
index 19c0cf66..54008904 100644
--- a/pango/pangoft2-private.h
+++ b/pango/pangoft2-private.h
@@ -27,17 +27,19 @@
#include "pangoft2.h"
/* Debugging... */
-#define DEBUGGING 0
+#define DEBUGGING 1
#if defined(DEBUGGING) && DEBUGGING
#ifdef __GNUC__
#define PING(printlist) \
(g_print ("%s:%d ", __PRETTY_FUNCTION__, __LINE__), \
- g_print printlist)
+ g_print printlist, \
+ g_print ("\n"))
#else
#define PING(printlist) \
(g_print ("%s:%d ", __FILE__, __LINE__), \
- g_print printlist)
+ g_print printlist, \
+ g_print ("\n"))
#endif
#else /* !DEBUGGING */
#define PING(printlist)
@@ -85,7 +87,18 @@ struct _PangoFT2Font
*/
gboolean in_cache;
- PangoFT2FontEntry *entry; /* Used to remove cached fonts */
+ PangoFT2FontEntry *entry;
+};
+
+struct _PangoFT2FontEntry
+{
+ FT_Open_Args **open_args;
+ FT_Long *face_indices;
+ int n_fonts;
+ PangoFontDescription description;
+ PangoCoverage *coverage;
+
+ GSList *cached_fonts;
};
PangoMap *pango_ft2_get_shaper_map (const char *lang);
diff --git a/pango/pangoft2.c b/pango/pangoft2.c
index 65c9be56..e1035c8f 100644
--- a/pango/pangoft2.c
+++ b/pango/pangoft2.c
@@ -286,7 +286,7 @@ pango_ft2_render (FT_Bitmap *bitmap,
g_return_if_fail (bitmap != NULL);
g_return_if_fail (glyphs != NULL);
- PING (("bitmap: %dx%d@+%d+%d\n", bitmap->width, bitmap->rows, x, y));
+ PING (("bitmap: %dx%d@+%d+%d", bitmap->width, bitmap->rows, x, y));
gi = glyphs->glyphs;
for (i = 0; i < glyphs->num_glyphs; i++, gi++)
@@ -315,11 +315,11 @@ pango_ft2_render (FT_Bitmap *bitmap,
y_limit = MIN (face->glyph->bitmap.rows, face->glyph->bitmap_top - iyoff + bitmap->rows);
- PING (("glyph %d:%d: bitmap: %dx%d, left:%d top:%d\n",
+ PING (("glyph %d:%d: bitmap: %dx%d, left:%d top:%d",
i, glyph_index,
face->glyph->bitmap.width, face->glyph->bitmap.rows,
face->glyph->bitmap_left, face->glyph->bitmap_top));
- PING (("xstart:%d xlim:%d ystart:%d ylim:%d\n",
+ PING (("xstart:%d xlim:%d ystart:%d ylim:%d",
x_start, x_limit, y_start, y_limit));
if (face->glyph->bitmap.pixel_mode == ft_pixel_mode_grays)
@@ -425,7 +425,7 @@ pango_ft2_font_get_glyph_extents (PangoFont *font,
/* Some fonts report negative descender, some positive ! (?) */
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\n",
+ PING (("glyph:%d logical: %dx%d@%d+%d",
char_index, logical_rect->width, logical_rect->height,
logical_rect->x, logical_rect->y));
}
@@ -855,7 +855,7 @@ pango_ft2_font_finalize (GObject *object)
PangoFT2FontCache *cache = pango_ft2_font_map_get_font_cache (ft2font->fontmap);
int i;
- PING (("\n"));
+ PING ((""));
for (i = 0; i < ft2font->n_fonts; i++)
{
@@ -880,8 +880,9 @@ pango_ft2_font_finalize (GObject *object)
static PangoFontDescription *
pango_ft2_font_describe (PangoFont *font)
{
- /* FIXME: implement */
- return NULL;
+ PangoFT2Font *ft2font = PANGO_FT2_FONT (font);
+
+ return pango_font_description_copy (&ft2font->entry->description);
}
PangoMap *
@@ -1051,7 +1052,7 @@ pango_ft2_render_layout (FT_Bitmap *bitmap,
width = pango_layout_get_width (layout);
align = pango_layout_get_alignment (layout);
- PING (("x:%d y:%d indent:%d width:%d\n", x, y, indent, width));
+ PING (("x:%d y:%d indent:%d width:%d", x, y, indent, width));
if (width == -1 && align != PANGO_ALIGN_LEFT)
{
@@ -1097,7 +1098,7 @@ pango_ft2_render_layout (FT_Bitmap *bitmap,
}
}
- PING (("x_offset:%d y_offset:%d logical_rect.y:%d logical_rect.height:%d\n", x_offset, y_offset, logical_rect.y, logical_rect.height));
+ PING (("x_offset:%d y_offset:%d logical_rect.y:%d logical_rect.height:%d", x_offset, y_offset, logical_rect.y, logical_rect.height));
pango_ft2_render_layout_line (bitmap, line,
x + PANGO_PIXELS (x_offset),
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 4cb6073c..83ce9454 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -78,16 +78,6 @@ struct _PangoWin32FamilyEntry
GSList *font_entries;
};
-struct _PangoWin32FontEntry
-{
- LOGFONT *lfp;
- int n_fonts;
- PangoFontDescription description;
- PangoCoverage *coverage;
-
- GSList *cached_fonts;
-};
-
struct _PangoWin32SizeInfo
{
FONTSIGNATURE signature;
@@ -1341,54 +1331,82 @@ pango_win32_font_entry_get_coverage (PangoWin32FontEntry *entry,
guint32 ch;
PangoMap *shape_map;
PangoCoverage *coverage;
- PangoCoverage *result;
PangoCoverageLevel font_level;
PangoMapEntry *map_entry;
GHashTable *coverage_hash;
+ PangoCoverage *result = NULL;
+ PangoFontDescription *description;
+ FILE *cache_file;
+ gchar *cache_file_name;
+ guchar *buf;
+ int buflen;
+
+ if (entry->coverage)
+ {
+ pango_coverage_ref (entry->coverage);
+ return entry->coverage;
+ }
- if (entry)
- if (entry->coverage)
- {
- pango_coverage_ref (entry->coverage);
- return entry->coverage;
- }
+ description = pango_font_describe (font);
+ cache_file_name = g_strconcat (pango_get_sysconf_subdirectory (),
+ "\\cache.win32\\",
+ pango_font_description_to_filename (description),
+ ".",
+ lang ? lang : "",
+ NULL);
+ pango_font_description_free (description);
+
+ PING (("trying to load %s", cache_file_name));
+ if (g_file_get_contents (cache_file_name, &buf, &buflen, NULL))
+ {
+ result = pango_coverage_from_bytes (buf, buflen);
+ g_free (buf);
+ }
- result = pango_coverage_new ();
+ if (!result)
+ {
+ result = pango_coverage_new ();
- coverage_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ coverage_hash = g_hash_table_new (g_str_hash, g_str_equal);
- shape_map = pango_win32_get_shaper_map (lang);
+ shape_map = pango_win32_get_shaper_map (lang);
- for (ch = 0; ch < 65536; ch++)
- {
- map_entry = pango_map_get_entry (shape_map, ch);
- if (map_entry->info)
+ for (ch = 0; ch < 65536; ch++)
{
- coverage = g_hash_table_lookup (coverage_hash, map_entry->info->id);
- if (!coverage)
+ map_entry = pango_map_get_entry (shape_map, ch);
+ if (map_entry->info)
{
- PangoEngineShape *engine = (PangoEngineShape *)pango_map_get_engine (shape_map, ch);
- coverage = engine->get_coverage (font, lang);
- g_hash_table_insert (coverage_hash, map_entry->info->id, coverage);
+ coverage = g_hash_table_lookup (coverage_hash, map_entry->info->id);
+ if (!coverage)
+ {
+ PangoEngineShape *engine = (PangoEngineShape *)pango_map_get_engine (shape_map, ch);
+ coverage = engine->get_coverage (font, lang);
+ g_hash_table_insert (coverage_hash, map_entry->info->id, coverage);
+ }
+
+ font_level = pango_coverage_get (coverage, ch);
+ if (font_level == PANGO_COVERAGE_EXACT && !map_entry->is_exact)
+ font_level = PANGO_COVERAGE_APPROXIMATE;
+
+ if (font_level != PANGO_COVERAGE_NONE)
+ pango_coverage_set (result, ch, font_level);
}
-
- font_level = pango_coverage_get (coverage, ch);
- if (font_level == PANGO_COVERAGE_EXACT && !map_entry->is_exact)
- font_level = PANGO_COVERAGE_APPROXIMATE;
-
- if (font_level != PANGO_COVERAGE_NONE)
- pango_coverage_set (result, ch, font_level);
}
+
+ g_hash_table_foreach (coverage_hash, free_coverages_foreach, NULL);
+ 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);
}
-
- g_hash_table_foreach (coverage_hash, free_coverages_foreach, NULL);
- g_hash_table_destroy (coverage_hash);
-
- if (entry)
- {
- entry->coverage = result;
- pango_coverage_ref (result);
- }
+
+ entry->coverage = result;
+ pango_coverage_ref (result);
return result;
}
diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h
index b12971ce..596f7a92 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -61,7 +61,7 @@ struct _PangoWin32Font
int size;
/* hash table mapping from Unicode subranges to array of PangoWin32Subfont
- * ids, of length n_fonts
+ * ids, of length n_subfonts
*/
GHashTable *subfonts_by_subrange;
@@ -78,7 +78,17 @@ struct _PangoWin32Font
*/
gboolean in_cache;
- PangoWin32FontEntry *entry; /* Used to remove cached fonts */
+ PangoWin32FontEntry *entry;
+};
+
+struct _PangoWin32FontEntry
+{
+ LOGFONT *lfp;
+ int n_fonts;
+ PangoFontDescription description;
+ PangoCoverage *coverage;
+
+ GSList *cached_fonts;
};
PangoWin32Font *pango_win32_font_new (PangoFontMap *fontmap,
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index 0d0988cf..2b457f4c 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -1195,8 +1195,10 @@ pango_win32_font_finalize (GObject *object)
static PangoFontDescription *
pango_win32_font_describe (PangoFont *font)
{
- /* FIXME: implement */
- return NULL;
+ PangoFontDescription *result;
+ PangoWin32Font *win32font = PANGO_WIN32_FONT (font);
+
+ return pango_font_description_copy (&win32font->entry->description);
}
PangoMap *