summaryrefslogtreecommitdiff
path: root/fitz/res_font.c
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2011-07-29 19:11:53 +0100
committerRobin Watts <Robin.Watts@artifex.com>2011-08-01 14:11:53 +0100
commit5a46065a0df691a79b75f5e61e34e344afd5349a (patch)
tree3a4f175c73fbb945a4df3d1abcd822a5571641b5 /fitz/res_font.c
parent684cd3ebbbeaffbf416a09aad6af2cb160cec6bb (diff)
downloadmupdf-5a46065a0df691a79b75f5e61e34e344afd5349a.tar.xz
Add support for colored Type3 glyphs (ones that use d0).
Detect the d0 or d1 operators by writing a bit to the new device flags word. This can then be checked by the Type3 code to create the appropriate backing pixmap. In order to know what the appropriate backing pixmap is, we pass an additional colorspace into the glyph rendering code.
Diffstat (limited to 'fitz/res_font.c')
-rw-r--r--fitz/res_font.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/fitz/res_font.c b/fitz/res_font.c
index e5027d5b..17646ea3 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -512,7 +512,7 @@ fz_new_type3_font(char *name, fz_matrix matrix)
}
fz_pixmap *
-fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm)
+fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm, fz_colorspace *model)
{
fz_error error;
fz_matrix ctm;
@@ -535,6 +535,22 @@ fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm)
error = font->t3run(font->t3xref, font->t3resources, contents, dev, ctm);
if (error)
fz_catch(error, "cannot draw type3 glyph");
+ if (dev->flags & FZ_CHARPROC_MASK)
+ {
+ if (dev->flags & FZ_CHARPROC_COLOR)
+ fz_warn("type3 glyph claims to be both masked and colored");
+ model = NULL;
+ }
+ else if (dev->flags & FZ_CHARPROC_COLOR)
+ {
+ if (model == NULL)
+ fz_warn("colored type3 glyph wanted in masked context");
+ }
+ else
+ {
+ fz_warn("type3 glyph doesn't specify masked or colored");
+ model = NULL; /* Treat as masked */
+ }
fz_free_device(dev);
bbox.x0--;
@@ -542,7 +558,7 @@ fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm)
bbox.x1++;
bbox.y1++;
- glyph = fz_new_pixmap_with_rect(fz_device_gray, bbox);
+ glyph = fz_new_pixmap_with_rect((model ? model : fz_device_gray), bbox);
fz_clear_pixmap(glyph);
cache = fz_new_glyph_cache();
@@ -553,8 +569,13 @@ fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm)
fz_free_device(dev);
fz_free_glyph_cache(cache);
- result = fz_alpha_from_gray(glyph, 0);
- fz_drop_pixmap(glyph);
+ if (model == NULL)
+ {
+ result = fz_alpha_from_gray(glyph, 0);
+ fz_drop_pixmap(glyph);
+ }
+ else
+ result = glyph;
return result;
}