summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--pango/pangocairo-win32font.c10
-rw-r--r--pango/pangowin32-fontcache.c6
-rw-r--r--pango/pangowin32-fontmap.c178
-rw-r--r--pango/pangowin32-private.h41
-rw-r--r--pango/pangowin32.c178
-rw-r--r--pango/pangowin32.def22
7 files changed, 223 insertions, 229 deletions
diff --git a/ChangeLog b/ChangeLog
index 12ad5ac6..e08c2692 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2007-03-10 Tor Lillqvist <tml@novell.com>
+
+ * pango/pangowin32-private.h
+ * pango/pangowin32.c
+ * pango/pangowin32-fontcache.c
+ * pango/pangowin32-fontmap.c
+ * pango/pangocairo-win32font.c
+ * pango/pangowin32.def: Move functions defined in one file and
+ used in another to the file where used, make them static, and drop
+ from pangowin32-private.h. Prefix all private non-static functions
+ with underscore. Also functions used only by the pangocairo DLL
+ are considered private. (#120195)
+
+2007-03-10 Tor Lillqvist <tml@novell.com>
+
+ * README: Uniscribe is optional only at run-time.
+
2007-03-07 Tor Lillqvist <tml@novell.com>
* configure.in
diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c
index 4710c3ff..5f7522bd 100644
--- a/pango/pangocairo-win32font.c
+++ b/pango/pangocairo-win32font.c
@@ -493,7 +493,7 @@ _pango_cairo_win32_font_new (PangoCairoWin32FontMap *cwfontmap,
{
g_object_ref (win32font);
if (win32font->in_cache)
- pango_win32_fontmap_cache_remove (PANGO_FONT_MAP (win32fontmap), win32font);
+ _pango_win32_fontmap_cache_remove (PANGO_FONT_MAP (win32fontmap), win32font);
return PANGO_FONT (win32font);
}
@@ -531,10 +531,10 @@ _pango_cairo_win32_font_new (PangoCairoWin32FontMap *cwfontmap,
else
cairo_matrix_init_identity (&cwfont->ctm);
- pango_win32_make_matching_logfontw (win32font->fontmap,
- &face->logfontw,
- win32font->size,
- &win32font->logfontw);
+ _pango_win32_make_matching_logfontw (win32font->fontmap,
+ &face->logfontw,
+ win32font->size,
+ &win32font->logfontw);
cwfont->options = cairo_font_options_copy (_pango_cairo_context_get_merged_font_options (context));
diff --git a/pango/pangowin32-fontcache.c b/pango/pangowin32-fontcache.c
index 88d2bc0c..4b66ca9f 100644
--- a/pango/pangowin32-fontcache.c
+++ b/pango/pangowin32-fontcache.c
@@ -245,9 +245,9 @@ pango_win32_font_cache_loadw (PangoWin32FontCache *cache,
* settings ask for it.
*/
if (font_smoothing &&
- (pango_win32_os_version_info.dwMajorVersion > 5 ||
- (pango_win32_os_version_info.dwMajorVersion == 5 &&
- pango_win32_os_version_info.dwMinorVersion >= 1)))
+ (_pango_win32_os_version_info.dwMajorVersion > 5 ||
+ (_pango_win32_os_version_info.dwMajorVersion == 5 &&
+ _pango_win32_os_version_info.dwMinorVersion >= 1)))
{
UINT smoothing_type;
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 2f98d453..2f126cb9 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -38,9 +38,6 @@
typedef struct _PangoWin32Family PangoWin32Family;
typedef struct _PangoWin32SizeInfo PangoWin32SizeInfo;
-/* Number of freed fonts */
-#define MAX_FREED_FONTS 16
-
struct _PangoWin32Family
{
PangoFontFamily parent_instance;
@@ -64,8 +61,7 @@ struct _PangoWin32SizeInfo
#define PANGO_WIN32_FACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_WIN32_TYPE_FACE, PangoWin32Face))
#define PANGO_WIN32_IS_FACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_WIN32_TYPE_FACE))
-GType pango_win32_family_get_type (void);
-GType pango_win32_face_get_type (void);
+static GType pango_win32_face_get_type (void);
static void pango_win32_face_list_sizes (PangoFontFace *face,
int **sizes,
@@ -91,7 +87,7 @@ static void pango_win32_insert_font (PangoWin32FontMap
static PangoWin32FontMap *default_fontmap = NULL;
-G_DEFINE_TYPE (PangoWin32FontMap, pango_win32_font_map, PANGO_TYPE_FONT_MAP)
+G_DEFINE_TYPE (PangoWin32FontMap, _pango_win32_font_map, PANGO_TYPE_FONT_MAP)
#define TOLOWER(c) \
(((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
@@ -196,7 +192,7 @@ pango_win32_enum_proc (LOGFONTW *lfp,
lf = *lfp;
- EnumFontFamiliesExW (pango_win32_hdc, &lf,
+ EnumFontFamiliesExW (_pango_win32_hdc, &lf,
(FONTENUMPROCW) pango_win32_inner_enum_proc,
lParam, 0);
@@ -240,7 +236,7 @@ ensure_italic (gpointer key,
}
static void
-pango_win32_font_map_init (PangoWin32FontMap *win32fontmap)
+_pango_win32_font_map_init (PangoWin32FontMap *win32fontmap)
{
LOGFONTW logfont;
ItalicHelper helper = { win32fontmap, NULL };
@@ -257,7 +253,7 @@ pango_win32_font_map_init (PangoWin32FontMap *win32fontmap)
memset (&logfont, 0, sizeof (logfont));
logfont.lfCharSet = DEFAULT_CHARSET;
- EnumFontFamiliesExW (pango_win32_hdc, &logfont,
+ EnumFontFamiliesExW (_pango_win32_hdc, &logfont,
(FONTENUMPROCW) pango_win32_enum_proc,
(LPARAM) win32fontmap, 0);
@@ -275,11 +271,11 @@ pango_win32_font_map_init (PangoWin32FontMap *win32fontmap)
}
g_slist_free (helper.list);
- win32fontmap->resolution = (PANGO_SCALE / (double) GetDeviceCaps (pango_win32_hdc, LOGPIXELSY)) * 72.0;
+ win32fontmap->resolution = (PANGO_SCALE / (double) GetDeviceCaps (_pango_win32_hdc, LOGPIXELSY)) * 72.0;
}
static void
-pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
+_pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class);
@@ -347,7 +343,7 @@ pango_win32_font_map_finalize (GObject *object)
pango_win32_font_cache_free (win32fontmap->font_cache);
- G_OBJECT_CLASS (pango_win32_font_map_parent_class)->finalize (object);
+ G_OBJECT_CLASS (_pango_win32_font_map_parent_class)->finalize (object);
}
/*
@@ -400,7 +396,7 @@ pango_win32_family_class_init (PangoFontFamilyClass *class)
class->is_monospace = pango_win32_family_is_monospace;
}
-GType
+static GType
pango_win32_family_get_type (void)
{
static GType object_type = 0;
@@ -535,6 +531,27 @@ pango_win32_font_map_load_font (PangoFontMap *fontmap,
return result;
}
+static PangoWin32Font *
+pango_win32_font_neww (PangoFontMap *fontmap,
+ const LOGFONTW *lfp,
+ int size)
+{
+ PangoWin32Font *result;
+
+ g_return_val_if_fail (fontmap != NULL, NULL);
+ g_return_val_if_fail (lfp != NULL, NULL);
+
+ result = (PangoWin32Font *)g_object_new (PANGO_TYPE_WIN32_FONT, NULL);
+
+ result->fontmap = fontmap;
+ g_object_ref (fontmap);
+
+ result->size = size;
+ _pango_win32_make_matching_logfontw (fontmap, lfp, size, &result->logfontw);
+
+ return result;
+}
+
static PangoFont *
pango_win32_font_map_real_find_font (PangoWin32FontMap *win32fontmap,
PangoContext *context,
@@ -560,7 +577,7 @@ pango_win32_font_map_real_find_font (PangoWin32FontMap *win32fontmap,
g_object_ref (win32font);
if (win32font->in_cache)
- pango_win32_fontmap_cache_remove (fontmap, win32font);
+ _pango_win32_fontmap_cache_remove (fontmap, win32font);
return (PangoFont *)win32font;
}
@@ -614,17 +631,17 @@ get_family_nameA (const LOGFONTA *lfp)
if ((hfont = CreateFontIndirect (lfp)) == NULL)
goto fail0;
- if ((oldhfont = SelectObject (pango_win32_hdc, hfont)) == NULL)
+ if ((oldhfont = SelectObject (_pango_win32_hdc, hfont)) == NULL)
goto fail1;
- if (!pango_win32_get_name_header (pango_win32_hdc, &header))
+ if (!_pango_win32_get_name_header (_pango_win32_hdc, &header))
goto fail2;
PING (("%d name records", header.num_records));
for (i = 0; i < header.num_records; i++)
{
- if (!pango_win32_get_name_record (pango_win32_hdc, i, &record))
+ if (!_pango_win32_get_name_record (_pango_win32_hdc, i, &record))
goto fail2;
if ((record.name_id != 1 && record.name_id != 16) || record.string_length <= 0)
@@ -658,11 +675,11 @@ get_family_nameA (const LOGFONTA *lfp)
else
goto fail2;
- if (!pango_win32_get_name_record (pango_win32_hdc, name_ix, &record))
+ if (!_pango_win32_get_name_record (_pango_win32_hdc, name_ix, &record))
goto fail2;
string = g_malloc (record.string_length + 1);
- if (GetFontData (pango_win32_hdc, NAME,
+ if (GetFontData (_pango_win32_hdc, NAME,
header.string_storage_offset + record.string_offset,
string, record.string_length) != record.string_length)
goto fail2;
@@ -687,14 +704,14 @@ get_family_nameA (const LOGFONTA *lfp)
PING(("%s", name));
- SelectObject (pango_win32_hdc, oldhfont);
+ SelectObject (_pango_win32_hdc, oldhfont);
DeleteObject (hfont);
return name;
fail2:
g_free (string);
- SelectObject (pango_win32_hdc, oldhfont);
+ SelectObject (_pango_win32_hdc, oldhfont);
fail1:
DeleteObject (hfont);
@@ -808,17 +825,17 @@ get_family_nameW (const LOGFONTW *lfp)
if ((hfont = CreateFontIndirectW (lfp)) == NULL)
goto fail0;
- if ((oldhfont = SelectObject (pango_win32_hdc, hfont)) == NULL)
+ if ((oldhfont = SelectObject (_pango_win32_hdc, hfont)) == NULL)
goto fail1;
- if (!pango_win32_get_name_header (pango_win32_hdc, &header))
+ if (!_pango_win32_get_name_header (_pango_win32_hdc, &header))
goto fail2;
PING (("%d name records", header.num_records));
for (i = 0; i < header.num_records; i++)
{
- if (!pango_win32_get_name_record (pango_win32_hdc, i, &record))
+ if (!_pango_win32_get_name_record (_pango_win32_hdc, i, &record))
goto fail2;
if ((record.name_id != 1 && record.name_id != 16) || record.string_length <= 0)
@@ -852,11 +869,11 @@ get_family_nameW (const LOGFONTW *lfp)
else
goto fail2;
- if (!pango_win32_get_name_record (pango_win32_hdc, name_ix, &record))
+ if (!_pango_win32_get_name_record (_pango_win32_hdc, name_ix, &record))
goto fail2;
string = g_malloc (record.string_length + 1);
- if (GetFontData (pango_win32_hdc, NAME,
+ if (GetFontData (_pango_win32_hdc, NAME,
header.string_storage_offset + record.string_offset,
string, record.string_length) != record.string_length)
goto fail2;
@@ -881,14 +898,14 @@ get_family_nameW (const LOGFONTW *lfp)
PING(("%s", name));
- SelectObject (pango_win32_hdc, oldhfont);
+ SelectObject (_pango_win32_hdc, oldhfont);
DeleteObject (hfont);
return name;
fail2:
g_free (string);
- SelectObject (pango_win32_hdc, oldhfont);
+ SelectObject (_pango_win32_hdc, oldhfont);
fail1:
DeleteObject (hfont);
@@ -1126,10 +1143,10 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap,
* an installed font.
*/
void
-pango_win32_make_matching_logfontw (PangoFontMap *fontmap,
- const LOGFONTW *lfp,
- int size,
- LOGFONTW *out)
+_pango_win32_make_matching_logfontw (PangoFontMap *fontmap,
+ const LOGFONTW *lfp,
+ int size,
+ LOGFONTW *out)
{
PangoWin32FontMap *win32fontmap;
GSList *tmp_list;
@@ -1182,31 +1199,6 @@ pango_win32_make_matching_logfontw (PangoFontMap *fontmap,
*out = *lfp; /* Whatever. We need to pass something... */
}
-gint
-pango_win32_coverage_language_classify (PangoLanguage *lang)
-{
- if (pango_language_matches (lang, "zh-tw"))
- return PANGO_WIN32_COVERAGE_ZH_TW;
- else if (pango_language_matches (lang, "zh-cn"))
- return PANGO_WIN32_COVERAGE_ZH_CN;
- else if (pango_language_matches (lang, "ja"))
- return PANGO_WIN32_COVERAGE_JA;
- else if (pango_language_matches (lang, "ko"))
- return PANGO_WIN32_COVERAGE_KO;
- else if (pango_language_matches (lang, "vi"))
- return PANGO_WIN32_COVERAGE_VI;
- else
- return PANGO_WIN32_COVERAGE_UNSPEC;
-}
-
-void
-pango_win32_font_entry_set_coverage (PangoWin32Face *face,
- PangoCoverage *coverage,
- PangoLanguage *lang)
-{
- face->coverages[pango_win32_coverage_language_classify (lang)] = pango_coverage_ref (coverage);
-}
-
static PangoFontDescription *
pango_win32_face_describe (PangoFontFace *face)
{
@@ -1255,55 +1247,34 @@ pango_win32_face_list_sizes (PangoFontFace *face,
*n_sizes = 0;
}
-GType
+static GType
pango_win32_face_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
- const GTypeInfo object_info =
+ static const GTypeInfo object_info =
{
- sizeof (PangoFontFaceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) pango_win32_face_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PangoWin32Face),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
+ sizeof (PangoFontFaceClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_win32_face_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoWin32Face),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
};
-
+
object_type = g_type_register_static (PANGO_TYPE_FONT_FACE,
- I_("PangoWin32Face"),
- &object_info, 0);
+ I_("PangoWin32Face"),
+ &object_info, 0);
}
-
+
return object_type;
}
-PangoCoverage *
-pango_win32_font_entry_get_coverage (PangoWin32Face *face,
- PangoLanguage *lang)
-{
- gint i = pango_win32_coverage_language_classify (lang);
- if (face->coverages[i])
- {
- pango_coverage_ref (face->coverages[i]);
- return face->coverages[i];
- }
-
- return NULL;
-}
-
-void
-pango_win32_font_entry_remove (PangoWin32Face *face,
- PangoFont *font)
-{
- face->cached_fonts = g_slist_remove (face->cached_fonts, font);
-}
-
/**
* pango_win32_font_map_get_font_cache:
* @font_map: a #PangoWin32FontMap.
@@ -1322,25 +1293,8 @@ pango_win32_font_map_get_font_cache (PangoFontMap *font_map)
}
void
-pango_win32_fontmap_cache_add (PangoFontMap *fontmap,
- PangoWin32Font *win32font)
-{
- PangoWin32FontMap *win32fontmap = PANGO_WIN32_FONT_MAP (fontmap);
-
- if (win32fontmap->freed_fonts->length == MAX_FREED_FONTS)
- {
- PangoWin32Font *old_font = g_queue_pop_tail (win32fontmap->freed_fonts);
- g_object_unref (old_font);
- }
-
- g_object_ref (win32font);
- g_queue_push_head (win32fontmap->freed_fonts, win32font);
- win32font->in_cache = TRUE;
-}
-
-void
-pango_win32_fontmap_cache_remove (PangoFontMap *fontmap,
- PangoWin32Font *win32font)
+_pango_win32_fontmap_cache_remove (PangoFontMap *fontmap,
+ PangoWin32Font *win32font)
{
PangoWin32FontMap *win32fontmap = PANGO_WIN32_FONT_MAP (fontmap);
GList *link = g_queue_find (win32fontmap->freed_fonts, win32font);
diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h
index d91452be..18fac0b6 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -33,7 +33,7 @@
#ifdef PANGO_WIN32_DEBUGGING
#ifdef __GNUC__
#define PING(printlist) \
-(pango_win32_debug ? \
+(_pango_win32_debug ? \
(g_print ("%s:%d ", __PRETTY_FUNCTION__, __LINE__), \
g_print printlist, \
g_print ("\n"), \
@@ -41,7 +41,7 @@
0)
#else
#define PING(printlist) \
-(pango_win32_debug ? \
+(_pango_win32_debug ? \
(g_print ("%s:%d ", __FILE__, __LINE__), \
g_print printlist, \
g_print ("\n"), \
@@ -66,14 +66,14 @@ typedef enum
PANGO_WIN32_N_COVERAGES
} PangoWin32CoverageLanguageClass;
-#define PANGO_TYPE_WIN32_FONT_MAP (pango_win32_font_map_get_type ())
+#define PANGO_TYPE_WIN32_FONT_MAP (_pango_win32_font_map_get_type ())
#define PANGO_WIN32_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_WIN32_FONT_MAP, PangoWin32FontMap))
#define PANGO_WIN32_IS_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_WIN32_FONT_MAP))
#define PANGO_WIN32_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_WIN32_FONT_MAP, PangoWin32FontMapClass))
#define PANGO_IS_WIN32_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_WIN32_FONT_MAP))
#define PANGO_WIN32_FONT_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_WIN32_FONT_MAP, PangoWin32FontMapClass))
-#define PANGO_TYPE_WIN32_FONT (pango_win32_font_get_type ())
+#define PANGO_TYPE_WIN32_FONT (_pango_win32_font_get_type ())
#define PANGO_WIN32_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_WIN32_FONT, PangoWin32Font))
#define PANGO_WIN32_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_WIN32_FONT, PangoWin32FontClass))
#define PANGO_WIN32_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_WIN32_FONT))
@@ -256,41 +256,26 @@ struct name_record
guint16 string_offset;
};
-GType pango_win32_font_get_type (void);
+GType _pango_win32_font_get_type (void);
-PangoWin32Font *pango_win32_font_neww (PangoFontMap *fontmap,
- const LOGFONTW *lfp,
- int size);
-PangoMap * pango_win32_get_shaper_map (PangoLanguage *lang);
-void pango_win32_make_matching_logfontw (PangoFontMap *fontmap,
+void _pango_win32_make_matching_logfontw (PangoFontMap *fontmap,
const LOGFONTW *lfp,
int size,
LOGFONTW *out);
-PangoCoverage * pango_win32_font_entry_get_coverage (PangoWin32Face *face,
- PangoLanguage *lang);
-void pango_win32_font_entry_set_coverage (PangoWin32Face *face,
- PangoCoverage *coverage,
- PangoLanguage *lang);
-void pango_win32_font_entry_remove (PangoWin32Face *face,
- PangoFont *font);
-GType pango_win32_font_map_get_type (void);
+GType _pango_win32_font_map_get_type (void);
-void pango_win32_fontmap_cache_add (PangoFontMap *fontmap,
- PangoWin32Font *xfont);
-void pango_win32_fontmap_cache_remove (PangoFontMap *fontmap,
+void _pango_win32_fontmap_cache_remove (PangoFontMap *fontmap,
PangoWin32Font *xfont);
-gint pango_win32_coverage_language_classify (PangoLanguage *lang);
-
-gboolean pango_win32_get_name_header (HDC hdc,
+gboolean _pango_win32_get_name_header (HDC hdc,
struct name_header *header);
-gboolean pango_win32_get_name_record (HDC hdc,
+gboolean _pango_win32_get_name_record (HDC hdc,
gint i,
struct name_record *record);
-extern HDC pango_win32_hdc;
-extern OSVERSIONINFO pango_win32_os_version_info;
-extern gboolean pango_win32_debug;
+extern HDC _pango_win32_hdc;
+extern OSVERSIONINFO _pango_win32_os_version_info;
+extern gboolean _pango_win32_debug;
#endif /* __PANGOWIN32_PRIVATE_H__ */
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index c3aabb27..41dfee64 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -32,14 +32,16 @@
#include "pangowin32.h"
#include "pangowin32-private.h"
+#define MAX_FREED_FONTS 16
+
#define CH_IS_UNIHAN_BMP(ch) ((ch) >= 0x3400 && (ch) <= 0x9FFF)
#define CH_IS_UNIHAN(ch) (CH_IS_UNIHAN_BMP (ch) || \
((ch) >= 0x20000 && (ch) <= 0x2A6DF) || \
((ch) >= 0x2F800 && (ch) <= 0x2FA1F))
-HDC pango_win32_hdc;
-OSVERSIONINFO pango_win32_os_version_info;
-gboolean pango_win32_debug = FALSE;
+HDC _pango_win32_hdc;
+OSVERSIONINFO _pango_win32_os_version_info;
+gboolean _pango_win32_debug = FALSE;
static void pango_win32_font_dispose (GObject *object);
static void pango_win32_font_finalize (GObject *object);
@@ -104,8 +106,8 @@ pango_win32_get_hfont (PangoFont *font)
return NULL;
}
- SelectObject (pango_win32_hdc, win32font->hfont);
- GetTextMetrics (pango_win32_hdc, &tm);
+ SelectObject (_pango_win32_hdc, win32font->hfont);
+ GetTextMetrics (_pango_win32_hdc, &tm);
win32font->tm_overhang = tm.tmOverhang;
win32font->tm_descent = tm.tmDescent;
@@ -133,10 +135,10 @@ pango_win32_get_context (void)
return result;
}
-G_DEFINE_TYPE (PangoWin32Font, pango_win32_font, PANGO_TYPE_FONT)
+G_DEFINE_TYPE (PangoWin32Font, _pango_win32_font, PANGO_TYPE_FONT)
static void
-pango_win32_font_init (PangoWin32Font *win32font)
+_pango_win32_font_init (PangoWin32Font *win32font)
{
win32font->size = -1;
@@ -155,14 +157,14 @@ pango_win32_font_init (PangoWin32Font *win32font)
HDC
pango_win32_get_dc (void)
{
- if (pango_win32_hdc == NULL)
+ if (_pango_win32_hdc == NULL)
{
- pango_win32_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
- memset (&pango_win32_os_version_info, 0,
- sizeof (pango_win32_os_version_info));
- pango_win32_os_version_info.dwOSVersionInfoSize =
+ _pango_win32_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
+ memset (&_pango_win32_os_version_info, 0,
+ sizeof (_pango_win32_os_version_info));
+ _pango_win32_os_version_info.dwOSVersionInfoSize =
sizeof (OSVERSIONINFO);
- GetVersionEx (&pango_win32_os_version_info);
+ GetVersionEx (&_pango_win32_os_version_info);
/* Also do some generic pangowin32 initialisations... this function
* is a suitable place for those as it is called from a couple
@@ -170,11 +172,11 @@ pango_win32_get_dc (void)
*/
#ifdef PANGO_WIN32_DEBUGGING
if (getenv ("PANGO_WIN32_DEBUG") != NULL)
- pango_win32_debug = TRUE;
+ _pango_win32_debug = TRUE;
#endif
}
- return pango_win32_hdc;
+ return _pango_win32_hdc;
}
/**
@@ -189,11 +191,11 @@ pango_win32_get_dc (void)
gboolean
pango_win32_get_debug_flag (void)
{
- return pango_win32_debug;
+ return _pango_win32_debug;
}
static void
-pango_win32_font_class_init (PangoWin32FontClass *class)
+_pango_win32_font_class_init (PangoWin32FontClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
PangoFontClass *font_class = PANGO_FONT_CLASS (class);
@@ -216,27 +218,6 @@ pango_win32_font_class_init (PangoWin32FontClass *class)
pango_win32_get_dc ();
}
-PangoWin32Font *
-pango_win32_font_neww (PangoFontMap *fontmap,
- const LOGFONTW *lfp,
- int size)
-{
- PangoWin32Font *result;
-
- g_return_val_if_fail (fontmap != NULL, NULL);
- g_return_val_if_fail (lfp != NULL, NULL);
-
- result = (PangoWin32Font *)g_object_new (PANGO_TYPE_WIN32_FONT, NULL);
-
- result->fontmap = fontmap;
- g_object_ref (fontmap);
-
- result->size = size;
- pango_win32_make_matching_logfontw (fontmap, lfp, size, &result->logfontw);
-
- return result;
-}
-
/**
* pango_win32_render:
* @hdc: the device context
@@ -264,7 +245,7 @@ pango_win32_render (HDC hdc,
g_return_if_fail (glyphs != NULL);
#ifdef PANGO_WIN32_DEBUGGING
- if (pango_win32_debug)
+ if (_pango_win32_debug)
{
PING (("num_glyphs:%d", glyphs->num_glyphs));
for (i = 0; i < glyphs->num_glyphs; i++)
@@ -372,7 +353,7 @@ pango_win32_render (HDC hdc,
i++;
}
#ifdef PANGO_WIN32_DEBUGGING
- if (pango_win32_debug)
+ if (_pango_win32_debug)
{
g_print ("ExtTextOutW at %d,%d deltas:",
x + PANGO_PIXELS (start_x_offset),
@@ -487,10 +468,10 @@ pango_win32_font_get_glyph_extents (PangoFont *font,
memset (&gm, 0, sizeof (gm));
hfont = pango_win32_get_hfont (font);
- SelectObject (pango_win32_hdc, hfont);
- /* FIXME: (Alex) This constant reuse of pango_win32_hdc is
+ SelectObject (_pango_win32_hdc, hfont);
+ /* FIXME: (Alex) This constant reuse of _pango_win32_hdc is
not thread-safe */
- res = GetGlyphOutlineA (pango_win32_hdc,
+ res = GetGlyphOutlineA (_pango_win32_hdc,
glyph_index,
GGO_METRICS | GGO_GLYPH_INDEX,
&gm,
@@ -589,8 +570,8 @@ pango_win32_font_get_metrics (PangoFont *font,
PangoCoverage *coverage;
TEXTMETRIC tm;
- SelectObject (pango_win32_hdc, hfont);
- GetTextMetrics (pango_win32_hdc, &tm);
+ SelectObject (_pango_win32_hdc, hfont);
+ GetTextMetrics (_pango_win32_hdc, &tm);
metrics->ascent = tm.tmAscent * PANGO_SCALE;
metrics->descent = tm.tmDescent * PANGO_SCALE;
@@ -794,6 +775,23 @@ pango_win32_font_get_metrics_factor (PangoFont *font)
}
static void
+pango_win32_fontmap_cache_add (PangoFontMap *fontmap,
+ PangoWin32Font *win32font)
+{
+ PangoWin32FontMap *win32fontmap = PANGO_WIN32_FONT_MAP (fontmap);
+
+ if (win32fontmap->freed_fonts->length == MAX_FREED_FONTS)
+ {
+ PangoWin32Font *old_font = g_queue_pop_tail (win32fontmap->freed_fonts);
+ g_object_unref (old_font);
+ }
+
+ g_object_ref (win32font);
+ g_queue_push_head (win32fontmap->freed_fonts, win32font);
+ win32font->in_cache = TRUE;
+}
+
+static void
pango_win32_font_dispose (GObject *object)
{
PangoWin32Font *win32font = PANGO_WIN32_FONT (object);
@@ -805,7 +803,7 @@ pango_win32_font_dispose (GObject *object)
if (!win32font->in_cache && win32font->fontmap)
pango_win32_fontmap_cache_add (win32font->fontmap, win32font);
- G_OBJECT_CLASS (pango_win32_font_parent_class)->dispose (object);
+ G_OBJECT_CLASS (_pango_win32_font_parent_class)->dispose (object);
}
static void
@@ -816,6 +814,13 @@ free_metrics_info (PangoWin32MetricsInfo *info)
}
static void
+pango_win32_font_entry_remove (PangoWin32Face *face,
+ PangoFont *font)
+{
+ face->cached_fonts = g_slist_remove (face->cached_fonts, font);
+}
+
+static void
pango_win32_font_finalize (GObject *object)
{
PangoWin32Font *win32font = (PangoWin32Font *)object;
@@ -834,7 +839,7 @@ pango_win32_font_finalize (GObject *object)
g_object_unref (win32font->fontmap);
- G_OBJECT_CLASS (pango_win32_font_parent_class)->finalize (object);
+ G_OBJECT_CLASS (_pango_win32_font_parent_class)->finalize (object);
}
static PangoFontDescription *
@@ -861,7 +866,7 @@ pango_win32_font_describe_absolute (PangoFont *font)
return desc;
}
-PangoMap *
+static PangoMap *
pango_win32_get_shaper_map (PangoLanguage *lang)
{
static guint engine_type_id = 0;
@@ -876,6 +881,45 @@ pango_win32_get_shaper_map (PangoLanguage *lang)
return pango_find_map (lang, engine_type_id, render_type_id);
}
+static gint
+pango_win32_coverage_language_classify (PangoLanguage *lang)
+{
+ if (pango_language_matches (lang, "zh-tw"))
+ return PANGO_WIN32_COVERAGE_ZH_TW;
+ else if (pango_language_matches (lang, "zh-cn"))
+ return PANGO_WIN32_COVERAGE_ZH_CN;
+ else if (pango_language_matches (lang, "ja"))
+ return PANGO_WIN32_COVERAGE_JA;
+ else if (pango_language_matches (lang, "ko"))
+ return PANGO_WIN32_COVERAGE_KO;
+ else if (pango_language_matches (lang, "vi"))
+ return PANGO_WIN32_COVERAGE_VI;
+ else
+ return PANGO_WIN32_COVERAGE_UNSPEC;
+}
+
+static PangoCoverage *
+pango_win32_font_entry_get_coverage (PangoWin32Face *face,
+ PangoLanguage *lang)
+{
+ gint i = pango_win32_coverage_language_classify (lang);
+ if (face->coverages[i])
+ {
+ pango_coverage_ref (face->coverages[i]);
+ return face->coverages[i];
+ }
+
+ return NULL;
+}
+
+static void
+pango_win32_font_entry_set_coverage (PangoWin32Face *face,
+ PangoCoverage *coverage,
+ PangoLanguage *lang)
+{
+ face->coverages[pango_win32_coverage_language_classify (lang)] = pango_coverage_ref (coverage);
+}
+
static PangoCoverage *
pango_win32_font_get_coverage (PangoFont *font,
PangoLanguage *lang)
@@ -1400,15 +1444,15 @@ font_get_cmap (PangoFont *font)
if (win32font->win32face->cmap)
return win32font->win32face->cmap;
- pango_win32_font_select_font (font, pango_win32_hdc);
+ pango_win32_font_select_font (font, _pango_win32_hdc);
/* Prefer the format 12 cmap */
- if ((cmap = get_format_12_cmap (pango_win32_hdc)) != NULL)
+ if ((cmap = get_format_12_cmap (_pango_win32_hdc)) != NULL)
{
win32font->win32face->cmap_format = 12;
win32font->win32face->cmap = cmap;
}
- else if ((cmap = get_format_4_cmap (pango_win32_hdc)) != NULL)
+ else if ((cmap = get_format_4_cmap (_pango_win32_hdc)) != NULL)
{
win32font->win32face->cmap_format = 4;
win32font->win32face->cmap = cmap;
@@ -1498,8 +1542,8 @@ pango_win32_font_get_glyph_index (PangoFont *font,
}
gboolean
-pango_win32_get_name_header (HDC hdc,
- struct name_header *header)
+_pango_win32_get_name_header (HDC hdc,
+ struct name_header *header)
{
if (GetFontData (hdc, NAME, 0, header, sizeof (*header)) != sizeof (*header))
return FALSE;
@@ -1511,9 +1555,9 @@ pango_win32_get_name_header (HDC hdc,
}
gboolean
-pango_win32_get_name_record (HDC hdc,
- gint i,
- struct name_record *record)
+_pango_win32_get_name_record (HDC hdc,
+ gint i,
+ struct name_record *record)
{
if (GetFontData (hdc, NAME, 6 + i * sizeof (*record),
record, sizeof (*record)) != sizeof (*record))
@@ -1543,19 +1587,19 @@ font_has_name_in (PangoFont *font,
return TRUE;
hfont = pango_win32_get_hfont (font);
- oldhfont = SelectObject (pango_win32_hdc, hfont);
+ oldhfont = SelectObject (_pango_win32_hdc, hfont);
- if (!pango_win32_get_name_header (pango_win32_hdc, &header))
+ if (!_pango_win32_get_name_header (_pango_win32_hdc, &header))
{
- SelectObject (pango_win32_hdc, oldhfont);
+ SelectObject (_pango_win32_hdc, oldhfont);
return FALSE;
}
for (i = 0; i < header.num_records; i++)
{
- if (!pango_win32_get_name_record (pango_win32_hdc, i, &record))
+ if (!_pango_win32_get_name_record (_pango_win32_hdc, i, &record))
{
- SelectObject (pango_win32_hdc, oldhfont);
+ SelectObject (_pango_win32_hdc, oldhfont);
return FALSE;
}
@@ -1587,7 +1631,7 @@ font_has_name_in (PangoFont *font,
}
}
- SelectObject (pango_win32_hdc, oldhfont);
+ SelectObject (_pango_win32_hdc, oldhfont);
return retval;
}
@@ -1643,7 +1687,7 @@ pango_win32_font_calc_coverage (PangoFont *font,
if (id_range_offset[i] == 0)
{
#ifdef PANGO_WIN32_DEBUGGING
- if (pango_win32_debug)
+ if (_pango_win32_debug)
{
if (end_count[i] == start_count[i])
g_print ("%04x ", start_count[i]);
@@ -1684,7 +1728,7 @@ pango_win32_font_calc_coverage (PangoFont *font,
#ifdef PANGO_WIN32_DEBUGGING
else if (ch0 < G_MAXUINT)
{
- if (pango_win32_debug)
+ if (_pango_win32_debug)
{
if (ch > ch0 + 2)
g_print ("%04x:%04x ", ch0, ch - 1);
@@ -1698,7 +1742,7 @@ pango_win32_font_calc_coverage (PangoFont *font,
#ifdef PANGO_WIN32_DEBUGGING
if (ch0 < G_MAXUINT)
{
- if (pango_win32_debug)
+ if (_pango_win32_debug)
{
if (ch > ch0 + 2)
g_print ("%04x:%04x ", ch0, ch - 1);
@@ -1717,7 +1761,7 @@ pango_win32_font_calc_coverage (PangoFont *font,
for (i = 0; i < cmap12->count; i++)
{
#ifdef PANGO_WIN32_DEBUGGING
- if (pango_win32_debug)
+ if (_pango_win32_debug)
{
if (cmap12->groups[i*3+0] == cmap12->groups[i*3+1])
g_print ("%04x ", cmap12->groups[i*3+0]);
@@ -1737,7 +1781,7 @@ pango_win32_font_calc_coverage (PangoFont *font,
else
g_assert_not_reached ();
#ifdef PANGO_WIN32_DEBUGGING
- if (pango_win32_debug)
+ if (_pango_win32_debug)
g_print ("\n");
#endif
}
diff --git a/pango/pangowin32.def b/pango/pangowin32.def
index 0940d7d3..13b6e8b1 100644
--- a/pango/pangowin32.def
+++ b/pango/pangowin32.def
@@ -1,4 +1,8 @@
EXPORTS
+ _pango_win32_fontmap_cache_remove
+ _pango_win32_make_matching_logfontw
+ _pango_win32_font_get_type
+ _pango_win32_font_map_get_type
pango_win32_font_cache_free
pango_win32_font_cache_load
pango_win32_font_cache_loadw
@@ -6,30 +10,20 @@ EXPORTS
pango_win32_font_cache_unload
pango_win32_font_description_from_logfont
pango_win32_font_description_from_logfontw
- pango_win32_font_entry_get_coverage
- pango_win32_font_entry_remove
pango_win32_font_get_glyph_index
- pango_win32_font_get_type
+ pango_win32_font_logfont
pango_win32_font_logfont
pango_win32_font_map_for_display
pango_win32_font_map_get_font_cache
- pango_win32_font_map_get_type
- pango_win32_font_neww
- pango_win32_font_logfont
- pango_win32_font_done_font
- pango_win32_font_get_metrics_factor
- pango_win32_font_select_font
- pango_win32_fontmap_cache_add
- pango_win32_fontmap_cache_remove
pango_win32_get_context
pango_win32_get_dc
pango_win32_get_debug_flag
- pango_win32_get_shaper_map
pango_win32_get_unknown_glyph
- pango_win32_make_matching_logfontw
pango_win32_render
pango_win32_render_layout
pango_win32_render_layout_line
pango_win32_render_transformed
pango_win32_shutdown_display
-
+ pango_win32_font_done_font
+ pango_win32_font_get_metrics_factor
+ pango_win32_font_select_font