summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-08 15:10:06 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-08 15:39:30 +0200
commit9915a386ea1dab21c5bbd4a0c8012dd13dbda301 (patch)
tree872ba59767d5eb146bffd17deb800511525c6129
parent5526e501b4447d6cbc6ed868a3c182dba22c1f5d (diff)
downloadmupdf-9915a386ea1dab21c5bbd4a0c8012dd13dbda301.tar.xz
Various patches from SumatraPDF.
-rw-r--r--fitz/fitz.h2
-rw-r--r--fitz/res_colorspace.c15
-rw-r--r--pdf/pdf_font.c5
-rw-r--r--pdf/pdf_lex.c4
-rw-r--r--xps/muxps.h1
-rw-r--r--xps/xps_tiff.c4
-rw-r--r--xps/xps_zip.c5
7 files changed, 30 insertions, 6 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 7902b376..0ae31631 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -769,6 +769,8 @@ void fz_drop_colorspace(fz_colorspace *colorspace);
void fz_convert_color(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv);
void fz_convert_pixmap(fz_pixmap *src, fz_pixmap *dst);
+fz_colorspace *fz_find_device_colorspace(char *name);
+
/*
* Fonts come in two variants:
* Regular fonts are handled by FreeType.
diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c
index 0add872a..47df2b34 100644
--- a/fitz/res_colorspace.c
+++ b/fitz/res_colorspace.c
@@ -162,6 +162,21 @@ fz_colorspace *fz_device_rgb = &k_device_rgb;
fz_colorspace *fz_device_bgr = &k_device_bgr;
fz_colorspace *fz_device_cmyk = &k_device_cmyk;
+fz_colorspace *
+fz_find_device_colorspace(char *name)
+{
+ if (!strcmp(name, "DeviceGray"))
+ return fz_device_gray;
+ if (!strcmp(name, "DeviceRGB"))
+ return fz_device_rgb;
+ if (!strcmp(name, "DeviceBGR"))
+ return fz_device_bgr;
+ if (!strcmp(name, "DeviceCMYK"))
+ return fz_device_cmyk;
+ fz_warn("unknown device colorspace: %s", name);
+ return NULL;
+}
+
/* Fast pixmap color conversions */
static void fast_gray_to_rgb(fz_pixmap *src, fz_pixmap *dst)
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index 448ab330..2eb2e998 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -102,6 +102,11 @@ static int ft_char_index(FT_Face face, int cid)
int gid = FT_Get_Char_Index(face, cid);
if (gid == 0)
gid = FT_Get_Char_Index(face, 0xf000 + cid);
+
+ /* some chinese fonts only ship the similarly looking 0x2026 */
+ if (gid == 0 && cid == 0x22ef)
+ gid = FT_Get_Char_Index(face, 0x2026);
+
return gid;
}
diff --git a/pdf/pdf_lex.c b/pdf/pdf_lex.c
index 31d8a825..23a5781f 100644
--- a/pdf/pdf_lex.c
+++ b/pdf/pdf_lex.c
@@ -330,8 +330,10 @@ lex_hex_string(fz_stream *f, char *buf, int n)
}
break;
case '>':
- default:
+ case EOF:
goto end;
+ default:
+ fz_warn("ignoring invalid character in hex string: '%c'", c);
}
}
end:
diff --git a/xps/muxps.h b/xps/muxps.h
index bbdbfea5..f456baf5 100644
--- a/xps/muxps.h
+++ b/xps/muxps.h
@@ -233,6 +233,7 @@ struct xps_context_s
};
int xps_open_file(xps_context **ctxp, char *filename);
+int xps_open_stream(xps_context **ctxp, fz_stream *file);
void xps_free_context(xps_context *ctx);
#endif
diff --git a/xps/xps_tiff.c b/xps/xps_tiff.c
index 13c4d7f1..d946434f 100644
--- a/xps/xps_tiff.c
+++ b/xps/xps_tiff.c
@@ -303,8 +303,8 @@ xps_expand_tiff_colormap(struct tiff *tiff)
int maxval = 1 << tiff->bitspersample;
byte *samples;
byte *src, *dst;
- int stride;
- int x, y;
+ unsigned int x, y;
+ unsigned int stride;
/* colormap has first all red, then all green, then all blue values */
/* colormap values are 0..65535, bits is 4 or 8 */
diff --git a/xps/xps_zip.c b/xps/xps_zip.c
index ab36954b..57769b59 100644
--- a/xps/xps_zip.c
+++ b/xps/xps_zip.c
@@ -390,7 +390,7 @@ xps_read_part(xps_context *ctx, char *partname)
return xps_read_zip_part(ctx, partname);
}
-int
+static int
xps_open_directory(xps_context **ctxp, char *directory)
{
xps_context *ctx;
@@ -470,10 +470,9 @@ xps_open_file(xps_context **ctxp, char *filename)
return fz_throw("cannot open file '%s': %s", filename, strerror(errno));
code = xps_open_stream(ctxp, file);
+ fz_close(file);
if (code)
return fz_rethrow(code, "cannot load document '%s'", filename);
-
- fz_close(file);
return fz_okay;
}