diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 21 | ||||
-rw-r--r-- | modules/basic/basic-win32.c | 2 | ||||
-rw-r--r-- | pango/pangowin32.c | 124 | ||||
-rw-r--r-- | pango/pangowin32.h | 12 |
9 files changed, 228 insertions, 36 deletions
@@ -1,5 +1,26 @@ 2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/pangowin32.c: Use PANGO_PIXELS macro throughout instead of + dividing by PANGO_SCALE. + (pango_win32_render): New try. This time handle both glyphs at + code point 0, specifically put there by PangoLayout to indicate + spacing (for tab handling), and actual invalid glyphs noticed by + the shaper. Invalid glyphs are indicated by the flag + PANGO_WIN32_UNKNOWN_FLAG. (Idea taken frompangoxft-font.c) + (pango_win32_get_unknown_glyph): Take also the char as parameter, + return the same char with the above flag ORed in. + (pango_win32_font_get_glyph_extents): If the glyph is flagged as + invalid, look for glyph 0 instead. Use g_win32_error_message() in + warning message instead of numeric error code. + + * pango/pangowin32.h: Add the new parameter to the + pango_win32_get_unknown_glyph() declaration. Surround the API used + by shape engines with #ifdef PANGO_ENABLE_ENGINE. + + * modules/basic/basic-win32.c: Change call accordingly. + +2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/opentype/pango-ot.def: Remove. Not used. (A static library is built here. Exported entries are in ../pangoft2.def.) diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 6f798c7e..30ca2a3c 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,5 +1,26 @@ 2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/pangowin32.c: Use PANGO_PIXELS macro throughout instead of + dividing by PANGO_SCALE. + (pango_win32_render): New try. This time handle both glyphs at + code point 0, specifically put there by PangoLayout to indicate + spacing (for tab handling), and actual invalid glyphs noticed by + the shaper. Invalid glyphs are indicated by the flag + PANGO_WIN32_UNKNOWN_FLAG. (Idea taken frompangoxft-font.c) + (pango_win32_get_unknown_glyph): Take also the char as parameter, + return the same char with the above flag ORed in. + (pango_win32_font_get_glyph_extents): If the glyph is flagged as + invalid, look for glyph 0 instead. Use g_win32_error_message() in + warning message instead of numeric error code. + + * pango/pangowin32.h: Add the new parameter to the + pango_win32_get_unknown_glyph() declaration. Surround the API used + by shape engines with #ifdef PANGO_ENABLE_ENGINE. + + * modules/basic/basic-win32.c: Change call accordingly. + +2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/opentype/pango-ot.def: Remove. Not used. (A static library is built here. Exported entries are in ../pangoft2.def.) diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index 6f798c7e..30ca2a3c 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,5 +1,26 @@ 2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/pangowin32.c: Use PANGO_PIXELS macro throughout instead of + dividing by PANGO_SCALE. + (pango_win32_render): New try. This time handle both glyphs at + code point 0, specifically put there by PangoLayout to indicate + spacing (for tab handling), and actual invalid glyphs noticed by + the shaper. Invalid glyphs are indicated by the flag + PANGO_WIN32_UNKNOWN_FLAG. (Idea taken frompangoxft-font.c) + (pango_win32_get_unknown_glyph): Take also the char as parameter, + return the same char with the above flag ORed in. + (pango_win32_font_get_glyph_extents): If the glyph is flagged as + invalid, look for glyph 0 instead. Use g_win32_error_message() in + warning message instead of numeric error code. + + * pango/pangowin32.h: Add the new parameter to the + pango_win32_get_unknown_glyph() declaration. Surround the API used + by shape engines with #ifdef PANGO_ENABLE_ENGINE. + + * modules/basic/basic-win32.c: Change call accordingly. + +2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/opentype/pango-ot.def: Remove. Not used. (A static library is built here. Exported entries are in ../pangoft2.def.) diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 6f798c7e..30ca2a3c 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,5 +1,26 @@ 2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/pangowin32.c: Use PANGO_PIXELS macro throughout instead of + dividing by PANGO_SCALE. + (pango_win32_render): New try. This time handle both glyphs at + code point 0, specifically put there by PangoLayout to indicate + spacing (for tab handling), and actual invalid glyphs noticed by + the shaper. Invalid glyphs are indicated by the flag + PANGO_WIN32_UNKNOWN_FLAG. (Idea taken frompangoxft-font.c) + (pango_win32_get_unknown_glyph): Take also the char as parameter, + return the same char with the above flag ORed in. + (pango_win32_font_get_glyph_extents): If the glyph is flagged as + invalid, look for glyph 0 instead. Use g_win32_error_message() in + warning message instead of numeric error code. + + * pango/pangowin32.h: Add the new parameter to the + pango_win32_get_unknown_glyph() declaration. Surround the API used + by shape engines with #ifdef PANGO_ENABLE_ENGINE. + + * modules/basic/basic-win32.c: Change call accordingly. + +2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/opentype/pango-ot.def: Remove. Not used. (A static library is built here. Exported entries are in ../pangoft2.def.) diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 6f798c7e..30ca2a3c 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,5 +1,26 @@ 2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/pangowin32.c: Use PANGO_PIXELS macro throughout instead of + dividing by PANGO_SCALE. + (pango_win32_render): New try. This time handle both glyphs at + code point 0, specifically put there by PangoLayout to indicate + spacing (for tab handling), and actual invalid glyphs noticed by + the shaper. Invalid glyphs are indicated by the flag + PANGO_WIN32_UNKNOWN_FLAG. (Idea taken frompangoxft-font.c) + (pango_win32_get_unknown_glyph): Take also the char as parameter, + return the same char with the above flag ORed in. + (pango_win32_font_get_glyph_extents): If the glyph is flagged as + invalid, look for glyph 0 instead. Use g_win32_error_message() in + warning message instead of numeric error code. + + * pango/pangowin32.h: Add the new parameter to the + pango_win32_get_unknown_glyph() declaration. Surround the API used + by shape engines with #ifdef PANGO_ENABLE_ENGINE. + + * modules/basic/basic-win32.c: Change call accordingly. + +2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/opentype/pango-ot.def: Remove. Not used. (A static library is built here. Exported entries are in ../pangoft2.def.) diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 6f798c7e..30ca2a3c 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,5 +1,26 @@ 2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/pangowin32.c: Use PANGO_PIXELS macro throughout instead of + dividing by PANGO_SCALE. + (pango_win32_render): New try. This time handle both glyphs at + code point 0, specifically put there by PangoLayout to indicate + spacing (for tab handling), and actual invalid glyphs noticed by + the shaper. Invalid glyphs are indicated by the flag + PANGO_WIN32_UNKNOWN_FLAG. (Idea taken frompangoxft-font.c) + (pango_win32_get_unknown_glyph): Take also the char as parameter, + return the same char with the above flag ORed in. + (pango_win32_font_get_glyph_extents): If the glyph is flagged as + invalid, look for glyph 0 instead. Use g_win32_error_message() in + warning message instead of numeric error code. + + * pango/pangowin32.h: Add the new parameter to the + pango_win32_get_unknown_glyph() declaration. Surround the API used + by shape engines with #ifdef PANGO_ENABLE_ENGINE. + + * modules/basic/basic-win32.c: Change call accordingly. + +2002-09-24 Tor Lillqvist <tml@iki.fi> + * pango/opentype/pango-ot.def: Remove. Not used. (A static library is built here. Exported entries are in ../pangoft2.def.) diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index b278717b..2c3f4629 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -230,7 +230,7 @@ basic_engine_shape (PangoFont *font, } } else - set_glyph (font, glyphs, i, p - text, pango_win32_get_unknown_glyph (font)); + set_glyph (font, glyphs, i, p - text, pango_win32_get_unknown_glyph (font, wc)); } p = g_utf8_next_char (p); diff --git a/pango/pangowin32.c b/pango/pangowin32.c index 5bf3c6d3..71bfbed8 100644 --- a/pango/pangowin32.c +++ b/pango/pangowin32.c @@ -39,6 +39,8 @@ #define PANGO_WIN32_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_WIN32_FONT)) #define PANGO_WIN32_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_WIN32_FONT, PangoWin32FontClass)) +#define PANGO_WIN32_UNKNOWN_FLAG 0x10000000 + HDC pango_win32_hdc; OSVERSIONINFO pango_win32_os_version_info; @@ -244,9 +246,11 @@ pango_win32_render (HDC hdc, { HFONT old_hfont = NULL; HFONT hfont; - int i; + int i, num_valid_glyphs; guint16 *glyph_indexes; - INT *dX; + gint *dX; + gint last_x = 0; + PangoGlyphUnit start_x_offset = 0, x_offset = 0; g_return_if_fail (glyphs != NULL); @@ -259,16 +263,65 @@ pango_win32_render (HDC hdc, glyph_indexes = g_new (guint16, glyphs->num_glyphs); dX = g_new (INT, glyphs->num_glyphs); +#ifdef PANGO_WIN32_DEBUGGING + PING (("num_glyphs:%d", glyphs->num_glyphs)); + printf (" "); + for (i = 0; i <glyphs->num_glyphs; i++) + printf ("%d:%d ", glyphs->glyphs[i].glyph, glyphs->glyphs[i].geometry.width); + printf ("\n"); +#endif + + num_valid_glyphs = 0; for (i = 0; i <glyphs->num_glyphs; i++) { - glyph_indexes[i] = glyphs->glyphs[i].glyph; - dX[i] = glyphs->glyphs[i].geometry.width / PANGO_SCALE; + if (glyphs->glyphs[i].glyph == 0) + { + /* Code point 0 glyphs should not be rendered, but their + * indicated width (set up by PangoLayout) should be taken + * into account. + */ + + /* If the string starts with spacing, must shift the + * starting point for the glyphs actually rendered. For + * spacing in the middle of the glyph string, add to the dX + * of the previous glyph to be rendered. + */ + if (num_valid_glyphs == 0) + start_x_offset += glyphs->glyphs[i].geometry.width; + else + { + x_offset += glyphs->glyphs[i].geometry.width; + dX[num_valid_glyphs-1] = PANGO_PIXELS (x_offset) - last_x; + } + } + else + { + if (glyphs->glyphs[i].glyph & PANGO_WIN32_UNKNOWN_FLAG) + { + /* Glyph index is actually the char value that doesn't + * have any glyph (ORed with the flag). We should really + * do the same that pango_xft_real_render() does: render + * a box with the char value in hex inside it in a tiny + * font. Later. For now, use the TrueType invalid glyph + * at 0. + */ + glyph_indexes[num_valid_glyphs] = 0; + } + else + glyph_indexes[num_valid_glyphs] = glyphs->glyphs[i].glyph; + + if (num_valid_glyphs > 0) + last_x += dX[num_valid_glyphs-1]; + x_offset += glyphs->glyphs[i].geometry.width; + dX[num_valid_glyphs] = PANGO_PIXELS (x_offset) - last_x; + num_valid_glyphs++; + } } - ExtTextOutW (hdc, x, y, + ExtTextOutW (hdc, x + PANGO_PIXELS (start_x_offset), y, ETO_GLYPH_INDEX, NULL, - glyph_indexes, glyphs->num_glyphs, + glyph_indexes, num_valid_glyphs, dX); SelectObject (hdc, old_hfont); /* restore */ @@ -290,6 +343,9 @@ pango_win32_font_get_glyph_extents (PangoFont *font, MAT2 m = {{0,1}, {0,0}, {0,0}, {0,1}}; PangoWin32GlyphInfo *info; + if (glyph & PANGO_WIN32_UNKNOWN_FLAG) + glyph_index = glyph = 0; + info = g_hash_table_lookup (win32font->glyph_info, GUINT_TO_POINTER (glyph)); if (!info) @@ -321,9 +377,12 @@ pango_win32_font_get_glyph_extents (PangoFont *font, if (res == GDI_ERROR) { - guint32 error = GetLastError (); - g_warning ("GetGlyphOutline() failed with error: %d\n", error); - return; + gchar *error = g_win32_error_message (GetLastError ()); + g_warning ("GetGlyphOutline(%04X) failed: %s\n", + glyph_index, error); + g_free (error); + + /* Don't just return now, use the still zeroed out gm */ } info->ink_rect.x = PANGO_SCALE * gm.gmptGlyphOrigin.x; @@ -528,9 +587,10 @@ pango_win32_font_find_shaper (PangoFont *font, * Return value: a glyph index into @font **/ PangoGlyph -pango_win32_get_unknown_glyph (PangoFont *font) +pango_win32_get_unknown_glyph (PangoFont *font, + gunichar wc) { - return 0; + return wc | PANGO_WIN32_UNKNOWN_FLAG; } /** @@ -586,10 +646,10 @@ pango_win32_render_layout_line (HDC hdc, (bg_color.color.green + 128) >> 8, (bg_color.color.blue + 128) >> 8)); oldbrush = SelectObject (hdc, brush); - Rectangle (hdc, x + (x_off + logical_rect.x) / PANGO_SCALE, - y + overall_rect.y / PANGO_SCALE, - logical_rect.width / PANGO_SCALE, - overall_rect.height / PANGO_SCALE); + Rectangle (hdc, x + PANGO_PIXELS (x_off + logical_rect.x), + y + PANGO_PIXELS (overall_rect.y), + PANGO_PIXELS (logical_rect.width), + PANGO_PIXELS (overall_rect.height)); SelectObject (hdc, oldbrush); DeleteObject (brush); } @@ -603,16 +663,16 @@ pango_win32_render_layout_line (HDC hdc, } pango_win32_render (hdc, run->item->analysis.font, run->glyphs, - x + x_off / PANGO_SCALE, y); + x + PANGO_PIXELS (x_off), y); switch (uline) { case PANGO_UNDERLINE_NONE: break; case PANGO_UNDERLINE_DOUBLE: - points[0].x = x + (x_off + ink_rect.x) / PANGO_SCALE - 1; + points[0].x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1; points[0].y = points[1].y = y + 4; - points[1].x = x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE; + points[1].x = x + PANGO_PIXELS (x_off + ink_rect.x + ink_rect.width); Polyline (hdc, points, 2); /* Fall through */ case PANGO_UNDERLINE_SINGLE: @@ -620,9 +680,9 @@ pango_win32_render_layout_line (HDC hdc, Polyline (hdc, points, 2); break; case PANGO_UNDERLINE_LOW: - points[0].x = x + (x_off + ink_rect.x) / PANGO_SCALE - 1; - points[0].y = points[1].y = y + (ink_rect.y + ink_rect.height) / PANGO_SCALE + 2; - points[1].x = x + (x_off + ink_rect.x + ink_rect.width) / PANGO_SCALE; + points[0].x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1; + points[0].y = points[1].y = y + PANGO_PIXELS (ink_rect.y + ink_rect.height) + 2; + points[1].x = x + PANGO_PIXELS (x_off + ink_rect.x + ink_rect.width); Polyline (hdc, points, 2); break; } @@ -712,8 +772,8 @@ pango_win32_render_layout (HDC hdc, } pango_win32_render_layout_line (hdc, line, - x + x_offset / PANGO_SCALE, - y + (y_offset - logical_rect.y) / PANGO_SCALE); + x + PANGO_PIXELS (x_offset), + y + PANGO_PIXELS (y_offset - logical_rect.y)); y_offset += logical_rect.height; tmp_list = tmp_list->next; @@ -1163,15 +1223,16 @@ pango_win32_font_calc_coverage (PangoFont *font, start_count = get_start_count (table); id_range_offset = get_id_range_offset (table); + PING (("coverage:")); for (i = 0; i < seg_count; i++) { if (id_range_offset[i] == 0) { #ifdef PANGO_WIN32_DEBUGGING if (end_count[i] == start_count[i]) - PING (("\\u%04x", start_count[i])); + printf ("%04x ", start_count[i]); else - PING (("\\u%04x:\\u%04x", start_count[i], end_count[i])); + printf ("%04x:%04x ", start_count[i], end_count[i]); #endif for (ch = start_count[i]; ch <= end_count[i]; @@ -1208,9 +1269,9 @@ pango_win32_font_calc_coverage (PangoFont *font, else if (ch0 < G_MAXUINT) { if (ch > ch0 + 2) - PING (("\\u%04x:\\u%04x", ch0, ch - 1)); + printf ("%04x:%04x ", ch0, ch - 1); else - PING (("\\u%04x", ch0)); + printf ("%04x ", ch0); ch0 = G_MAXUINT; } #endif @@ -1219,13 +1280,14 @@ pango_win32_font_calc_coverage (PangoFont *font, if (ch0 < G_MAXUINT) { if (ch > ch0 + 2) - PING (("\\u%04x:\\u%04x", ch0, ch - 1)); + printf ("%04x:%04x ", ch0, ch - 1); else - PING (("\\u%04x", ch0)); + printf ("%04x ", ch0); } #endif } } +#ifdef PANGO_WIN32_DEBUGGING + printf ("\n"); +#endif } - - diff --git a/pango/pangowin32.h b/pango/pangowin32.h index 6c2f2651..49dcd08a 100644 --- a/pango/pangowin32.h +++ b/pango/pangowin32.h @@ -58,13 +58,17 @@ void pango_win32_render_layout (HDC hdc, int y); +#ifdef PANGO_ENABLE_ENGINE -/* API for rendering modules +/* For shape engines */ -PangoGlyph pango_win32_get_unknown_glyph (PangoFont *font); -gint pango_win32_font_get_glyph_index (PangoFont *font, - gunichar wc); +PangoGlyph pango_win32_get_unknown_glyph (PangoFont *font, + gunichar wc); +gint pango_win32_font_get_glyph_index(PangoFont *font, + gunichar wc); + +#endif /* API for libraries that want to use PangoWin32 mixed with classic * Win32 fonts. |