summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/pangocairo-font.c6
-rw-r--r--pango/pangocairo-render.c77
2 files changed, 80 insertions, 3 deletions
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 3bf83857..a49d14d4 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -720,7 +720,9 @@ _pango_cairo_font_private_get_glyph_extents_missing (PangoCairoFontPrivate *cf_p
gunichar ch;
gint rows, cols;
- if (glyph == (0x20 | PANGO_GLYPH_UNKNOWN_FLAG))
+ ch = glyph & ~PANGO_GLYPH_UNKNOWN_FLAG;
+
+ if (ch == 0x20 || ch == 0x2423)
{
get_space_extents (cf_priv, ink_rect, logical_rect);
return;
@@ -733,8 +735,6 @@ _pango_cairo_font_private_get_glyph_extents_missing (PangoCairoFontPrivate *cf_p
return;
}
- ch = glyph & ~PANGO_GLYPH_UNKNOWN_FLAG;
-
if (G_UNLIKELY (glyph == PANGO_GLYPH_INVALID_INPUT || ch > 0x10FFFF))
{
rows = hbi->rows;
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index 01d6c2ab..f4c57a87 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -394,6 +394,82 @@ _pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
rows = hbi->rows;
cols = 1;
}
+ else if (ch == 0x2423 ||
+ g_unichar_type (ch) == G_UNICODE_SPACE_SEPARATOR)
+ {
+ /* We never want to show a hex box or other drawing for
+ * space. If we want space to be visible, we replace 0x20
+ * by 0x2423 (visible space).
+ *
+ * Since we don't want to rely on glyph availability,
+ * we render a centered dot ourselves.
+ */
+ double x = cx + 0.5 *((double)gi->geometry.width / PANGO_SCALE);
+ double y = cy + hbi->box_descent - 0.5 * hbi->box_height;
+
+ cairo_new_sub_path (crenderer->cr);
+ cairo_arc (crenderer->cr, x, y, 1.5 * hbi->line_width, 0, 2 * G_PI);
+ cairo_close_path (crenderer->cr);
+ cairo_fill (crenderer->cr);
+ goto done;
+ }
+ else if (ch == '\t')
+ {
+ /* Since we don't want to rely on glyph availability,
+ * we render an arrow like ↦ ourselves.
+ */
+ double y = cy + hbi->box_descent - 0.5 * hbi->box_height;
+ double width = (double)gi->geometry.width / PANGO_SCALE;
+ double offset = 0.2 * width;
+ double x = cx + offset;
+ double al = width - 2 * offset; /* arrow length */
+ double tl = MIN (hbi->digit_width, 0.75 * al); /* tip length */
+ double tw2 = 2.5 * hbi->line_width; /* tip width / 2 */
+ double lw2 = 0.5 * hbi->line_width; /* line width / 2 */
+
+ cairo_move_to (crenderer->cr, x - lw2, y - tw2);
+ cairo_line_to (crenderer->cr, x + lw2, y - tw2);
+ cairo_line_to (crenderer->cr, x + lw2, y - lw2);
+ cairo_line_to (crenderer->cr, x + al - tl, y - lw2);
+ cairo_line_to (crenderer->cr, x + al - tl, y - tw2);
+ cairo_line_to (crenderer->cr, x + al, y);
+ cairo_line_to (crenderer->cr, x + al - tl, y + tw2);
+ cairo_line_to (crenderer->cr, x + al - tl, y + lw2);
+ cairo_line_to (crenderer->cr, x + lw2, y + lw2);
+ cairo_line_to (crenderer->cr, x + lw2, y + tw2);
+ cairo_line_to (crenderer->cr, x - lw2, y + tw2);
+ cairo_close_path (crenderer->cr);
+ cairo_fill (crenderer->cr);
+ goto done;
+ }
+ else if (ch == '\n' || ch == 0x2028 || ch == 0x2029)
+ {
+ /* Since we don't want to rely on glyph availability,
+ * we render an arrow like ↵ ourselves.
+ */
+ double width = (double)gi->geometry.width / PANGO_SCALE;
+ double offset = 0.2 * width;
+ double al = width - 2 * offset; /* arrow length */
+ double tl = MIN (hbi->digit_width, 0.75 * al); /* tip length */
+ double ah = al - 0.5 * tl; /* arrow height */
+ double tw2 = 2.5 * hbi->line_width; /* tip width / 2 */
+ double x = cx + offset;
+ double y = cy - (hbi->box_height - al) / 2;
+ double lw2 = 0.5 * hbi->line_width; /* line width / 2 */
+
+ cairo_move_to (crenderer->cr, x, y);
+ cairo_line_to (crenderer->cr, x + tl, y - tw2);
+ cairo_line_to (crenderer->cr, x + tl, y - lw2);
+ cairo_line_to (crenderer->cr, x + al - lw2, y - lw2);
+ cairo_line_to (crenderer->cr, x + al - lw2, y - ah);
+ cairo_line_to (crenderer->cr, x + al + lw2, y - ah);
+ cairo_line_to (crenderer->cr, x + al + lw2, y + lw2);
+ cairo_line_to (crenderer->cr, x + tl, y + lw2);
+ cairo_line_to (crenderer->cr, x + tl, y + tw2);
+ cairo_close_path (crenderer->cr);
+ cairo_fill (crenderer->cr);
+ goto done;
+ }
else if ((name = pango_get_ignorable_size (ch, &rows, &cols)))
{
/* Nothing else to do, we render 'default ignorable' chars
@@ -402,6 +478,7 @@ _pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
}
else
{
+ /* Everything else gets a traditional hex box. */
rows = hbi->rows;
cols = (ch > 0xffff ? 6 : 4) / rows;
g_snprintf (buf, sizeof(buf), (ch > 0xffff) ? "%06X" : "%04X", ch);