summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
Diffstat (limited to 'fitz')
-rw-r--r--fitz/dev_null.c1
-rw-r--r--fitz/fitz.h10
-rw-r--r--fitz/res_font.c29
3 files changed, 34 insertions, 6 deletions
diff --git a/fitz/dev_null.c b/fitz/dev_null.c
index 4d40ef73..508be7e0 100644
--- a/fitz/dev_null.c
+++ b/fitz/dev_null.c
@@ -6,6 +6,7 @@ fz_new_device(void *user)
fz_device *dev = fz_malloc(sizeof(fz_device));
memset(dev, 0, sizeof(fz_device));
dev->hints = 0;
+ dev->flags = 0;
dev->user = user;
return dev;
}
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 7fe8b297..cee62bc8 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -909,9 +909,9 @@ typedef struct fz_glyph_cache_s fz_glyph_cache;
fz_glyph_cache *fz_new_glyph_cache(void);
fz_pixmap *fz_render_ft_glyph(fz_font *font, int cid, fz_matrix trm);
-fz_pixmap *fz_render_t3_glyph(fz_font *font, int cid, fz_matrix trm);
+fz_pixmap *fz_render_t3_glyph(fz_font *font, int cid, fz_matrix trm, fz_colorspace *model);
fz_pixmap *fz_render_ft_stroked_glyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *state);
-fz_pixmap *fz_render_glyph(fz_glyph_cache*, fz_font*, int, fz_matrix);
+fz_pixmap *fz_render_glyph(fz_glyph_cache*, fz_font*, int, fz_matrix, fz_colorspace *model);
fz_pixmap *fz_render_stroked_glyph(fz_glyph_cache*, fz_font*, int, fz_matrix, fz_matrix, fz_stroke_state *stroke);
void fz_free_glyph_cache(fz_glyph_cache *);
@@ -944,8 +944,13 @@ void fz_flatten_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, f
enum
{
+ /* Hints */
FZ_IGNORE_IMAGE = 1,
FZ_IGNORE_SHADE = 2,
+
+ /* Flags */
+ FZ_CHARPROC_MASK = 1,
+ FZ_CHARPROC_COLOR = 2,
};
typedef struct fz_device_s fz_device;
@@ -953,6 +958,7 @@ typedef struct fz_device_s fz_device;
struct fz_device_s
{
int hints;
+ int flags;
void *user;
void (*free_user)(void *);
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;
}