summaryrefslogtreecommitdiff
path: root/pango/pangowin32.c
diff options
context:
space:
mode:
authorHans Breuer <hans@breuer.org>2001-04-13 23:47:51 +0000
committerHans Breuer <hans@src.gnome.org>2001-04-13 23:47:51 +0000
commit6cf85a472ad1b8b8320d1bcb92a5c259c7ad32be (patch)
tree5ffb1bb918c19eb1c19eceef9436c1d6d9866d45 /pango/pangowin32.c
parentf8dd42e8d90e924975b50a4f45d3ef5a15a10d3d (diff)
downloadpango-6cf85a472ad1b8b8320d1bcb92a5c259c7ad32be.tar.gz
instead of simply adding one matching font for the magic font names (sans,
2001-04-14 Hans Breuer <hans@breuer.org> * pango/pangowin32-fontmap.c : instead of simply adding one matching font for the magic font names (sans, serif, monospace) stuff any mathing font in the respective family entries (pango_win32_font_map_load_font) : do the same approximation for oblique and italic as the X version does * pango/pangowin32.c (pango_win32_font_get_glyph_extents) : initialize ink_rect and logical_rect to some more appropriate values (subfont_has_glyph) : implement glyph availability caching. IMO it needs to be done different to the other backends, because even the decision if a font has a specific glyph is increadeable slow on win32
Diffstat (limited to 'pango/pangowin32.c')
-rw-r--r--pango/pangowin32.c59
1 files changed, 51 insertions, 8 deletions
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index c14e3190..f3f91d8c 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -50,6 +50,12 @@ struct _PangoWin32SubfontInfo
LOGFONT logfont;
HFONT hfont;
+ gchar *glyphs_avail; /* cache info if a glyph is available */
+
+ gint tm_ascent; /* some info cached from GetTextMetrics */
+ gint tm_descent;
+ gint tm_overhang;
+
/* The following fields are used only to check whether a glyph is
* present in the subfont. On NT, there is the API GetGlyphIndices
* that can be used to do this very simply. But on Win9x,
@@ -359,7 +365,7 @@ pango_win32_render (HDC hdc,
#if 0
if (orig_align == (UINT) -1)
orig_align =
- SetTextAlign (hdc, TA_LEFT|TA_BOTTOM|TA_NOUPDATECP);
+ SetTextAlign (hdc, TA_LEFT|TA_BASELINE|TA_NOUPDATECP);
#endif
TextOutW (hdc,
x + (x_off + glyphs->glyphs[i].geometry.x_offset) / PANGO_SCALE,
@@ -580,20 +586,20 @@ pango_win32_font_get_glyph_extents (PangoFont *font,
if (glyph && pango_win32_find_glyph (font, glyph, &info, &size))
{
- /* This is totally bogus */
+ /* This is partly bogus */
if (ink_rect)
{
- ink_rect->x = PANGO_SCALE * size.cx;
- ink_rect->width = ink_rect->x;
- ink_rect->y = PANGO_SCALE * -size.cy;
+ ink_rect->x = PANGO_SCALE * info->tm_overhang;
+ ink_rect->width = PANGO_SCALE * (ink_rect->x - info->tm_overhang);
+ ink_rect->y = PANGO_SCALE * -info->tm_ascent;
ink_rect->height = PANGO_SCALE * size.cy;
}
if (logical_rect)
{
logical_rect->x = 0;
logical_rect->width = PANGO_SCALE * size.cx;
- logical_rect->y = - PANGO_SCALE * size.cy;
- logical_rect->height = PANGO_SCALE * size.cy;
+ logical_rect->y = -PANGO_SCALE * info->tm_ascent;
+ logical_rect->height = PANGO_SCALE * (info->tm_ascent + info->tm_descent);
}
}
else
@@ -863,6 +869,7 @@ pango_win32_insert_subfont (PangoFont *font,
info->logfont = *lfp;
info->hfont = NULL;
info->buf_hbm = NULL;
+ info->glyphs_avail = g_new0 (gchar, 16384);
win32font->n_subfonts++;
@@ -1002,6 +1009,7 @@ subfont_has_glyph (PangoFont *font,
#ifdef HEAVY_DEBUGGING
static int dispx = 5, dispy = 0;
#endif
+ gint has_glyph = 0; /* 1=yes, 2=no */
subrange = pango_win32_unicode_classify (wc);
if (PANGO_WIN32_U_LAST_PLUS_ONE == subrange)
@@ -1011,12 +1019,27 @@ subfont_has_glyph (PangoFont *font,
subrange))
return FALSE;
+ /*
+ * This is the main performance bottleneck, so lets
+ * cache the info once got ...
+ */
+ has_glyph = (info->glyphs_avail[wc / 4] >> ((wc % 4) * 2)) & 0x03;
+ if (1 == has_glyph)
+ return TRUE;
+ else if (2 == has_glyph)
+ return FALSE;
+
if (info->buf_hbm == NULL)
{
info->buf_hdc = CreateCompatibleDC (pango_win32_hdc);
info->oldfont = SelectObject (info->buf_hdc, info->hfont);
SetTextAlign (info->buf_hdc, TA_LEFT|TA_BASELINE|TA_NOUPDATECP);
GetTextMetrics (info->buf_hdc, &tm);
+
+ info->tm_overhang = tm.tmOverhang;
+ info->tm_descent = tm.tmDescent;
+ info->tm_ascent = tm.tmAscent;
+
PING(("wt:%ld,ht:%ld",tm.tmMaxCharWidth,tm.tmHeight));
info->default_char_hbm =
@@ -1086,7 +1109,11 @@ subfont_has_glyph (PangoFont *font,
}
#endif
- return (memcmp (info->buf, info->default_char_buf, info->buf_size) != 0);
+ has_glyph = (0 != memcmp (info->buf, info->default_char_buf, info->buf_size) ? 1 : 2);
+
+ info->glyphs_avail[wc / 4] |= (has_glyph << ((wc % 4) * 2));
+
+ return (1 == has_glyph);
}
/**
@@ -1197,6 +1224,7 @@ pango_win32_font_finalize (GObject *object)
DeleteObject (info->default_char_hbm);
DeleteDC (info->buf_hdc);
}
+ g_free (info->glyphs_avail);
g_free (info);
}
@@ -1284,6 +1312,21 @@ pango_win32_find_glyph (PangoFont *font,
GetTextExtentPoint32W (info->buf_hdc, &char_index, 1, &size);
+#if 0
+ {
+ GLYPHMETRICS gm;
+ MAT2 mat2 = {{0, 1}, {0, 0}, {0,0 }, {0,1 }};
+ //HFONT hfont;
+
+ //hfont = SelectObject (info->buf_hdc, info->hfont);
+ if (GDI_ERROR == GetGlyphOutline (info->buf_hdc,
+ glyph, GGO_NATIVE,
+ &gm, 0, NULL, &mat2))
+ memset (&gm, 0, sizeof (GLYPHMETRICS));
+ //SelectObject (info->buf_hdc, hfont); /* restore */
+ }
+#endif
+
if (subfont_return)
*subfont_return = info;