summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/font.c17
-rw-r--r--source/fitz/trace-device.c22
2 files changed, 34 insertions, 5 deletions
diff --git a/source/fitz/font.c b/source/fitz/font.c
index cd5c7648..392e5a71 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -1401,6 +1401,23 @@ fz_advance_t3_glyph(fz_context *ctx, fz_font *font, int gid)
return font->t3widths[gid];
}
+void
+fz_get_glyph_name(fz_context *ctx, fz_font *font, int glyph, char *buf, int size)
+{
+ FT_Face face = font->ft_face;
+ if (face)
+ {
+ if (FT_HAS_GLYPH_NAMES(face))
+ FT_Get_Glyph_Name(face, glyph, buf, size);
+ else
+ fz_snprintf(buf, size, "%d", glyph);
+ }
+ else
+ {
+ fz_snprintf(buf, size, "%d", glyph);
+ }
+}
+
float
fz_advance_glyph(fz_context *ctx, fz_font *font, int gid, int wmode)
{
diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c
index 86a1e60e..2965f958 100644
--- a/source/fitz/trace-device.c
+++ b/source/fitz/trace-device.c
@@ -39,12 +39,24 @@ fz_trace_text_span(fz_context *ctx, fz_output *out, fz_text_span *span)
fz_printf(ctx, out, " trm=\"%g %g %g %g\">\n", span->trm.a, span->trm.b, span->trm.c, span->trm.d);
for (i = 0; i < span->len; i++)
{
- if (!isxmlmeta(span->items[i].ucs))
- fz_printf(ctx, out, "<g ucs=\"%c\" gid=\"%d\" x=\"%g\" y=\"%g\" />\n",
- span->items[i].ucs, span->items[i].gid, span->items[i].x, span->items[i].y);
+ char name[32];
+
+ if (span->items[i].ucs == -1)
+ fz_printf(ctx, out, "<g unicode=\"-1\"");
+ else if (!isxmlmeta(span->items[i].ucs))
+ fz_printf(ctx, out, "<g unicode=\"%c\"", span->items[i].ucs);
+ else
+ fz_printf(ctx, out, "<g unicode=\"U+%04x\"", span->items[i].ucs);
+
+ if (span->items[i].gid >= 0)
+ {
+ fz_get_glyph_name(ctx, span->font, span->items[i].gid, name, sizeof name);
+ fz_printf(ctx, out, " glyph=\"%s\"", name);
+ }
else
- fz_printf(ctx, out, "<g ucs=\"U+%04x\" gid=\"%d\" x=\"%g\" y=\"%g\" />\n",
- span->items[i].ucs, span->items[i].gid, span->items[i].x, span->items[i].y);
+ fz_printf(ctx, out, " glyph=\"-1\"");
+
+ fz_printf(ctx, out, " x=\"%g\" y=\"%g\" />\n", span->items[i].x, span->items[i].y);
}
fz_printf(ctx, out, "</span>\n");
}