summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-11-21 14:39:26 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-11-23 11:17:35 +0100
commit1280bde7a824599bad9e277f6b3e74b850a1e6fc (patch)
treec106268328ea1e07ed991cdc13f2cfe1087d2b85
parentdd15bf347ca04cb79d1e009a7afb0f4c082820ca (diff)
downloadmupdf-1280bde7a824599bad9e277f6b3e74b850a1e6fc.tar.xz
Add 'X' option to disable document styles.
-rw-r--r--platform/gl/gl-main.c7
-rw-r--r--platform/x11/pdfapp.c4
-rw-r--r--platform/x11/pdfapp.h1
-rw-r--r--platform/x11/win_main.c14
-rw-r--r--platform/x11/x11_main.c4
-rw-r--r--source/tools/muconvert.c7
-rw-r--r--source/tools/mudraw.c7
-rw-r--r--source/tools/muraster.c15
8 files changed, 40 insertions, 19 deletions
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 8300bc0a..5cff5c3b 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -148,6 +148,7 @@ static float layout_w = DEFAULT_LAYOUT_W;
static float layout_h = DEFAULT_LAYOUT_H;
static float layout_em = DEFAULT_LAYOUT_EM;
static char *layout_css = NULL;
+static int layout_use_doc_css = 1;
static const char *title = "MuPDF/GL";
static fz_document *doc = NULL;
@@ -1340,6 +1341,7 @@ static void usage(const char *argv0)
fprintf(stderr, "\t-H -\tpage height for EPUB layout\n");
fprintf(stderr, "\t-S -\tfont size for EPUB layout\n");
fprintf(stderr, "\t-U -\tuser style sheet for EPUB layout\n");
+ fprintf(stderr, "\t-X\tdisable document styles for EPUB layout\n");
exit(1);
}
@@ -1352,7 +1354,7 @@ int main(int argc, char **argv)
const GLFWvidmode *video_mode;
int c;
- while ((c = fz_getopt(argc, argv, "p:r:W:H:S:U:")) != -1)
+ while ((c = fz_getopt(argc, argv, "p:r:W:H:S:U:X")) != -1)
{
switch (c)
{
@@ -1363,6 +1365,7 @@ int main(int argc, char **argv)
case 'H': layout_h = fz_atof(fz_optarg); break;
case 'S': layout_em = fz_atof(fz_optarg); break;
case 'U': layout_css = fz_optarg; break;
+ case 'X': layout_use_doc_css = 0; break;
}
}
@@ -1424,6 +1427,8 @@ int main(int argc, char **argv)
fz_drop_buffer(ctx, buf);
}
+ fz_set_use_document_css(ctx, layout_use_doc_css);
+
has_ARB_texture_non_power_of_two = glfwExtensionSupported("GL_ARB_texture_non_power_of_two");
if (!has_ARB_texture_non_power_of_two)
fz_warn(ctx, "OpenGL implementation does not support non-power of two texture sizes");
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index ef834aa1..63513415 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -119,6 +119,8 @@ void pdfapp_init(fz_context *ctx, pdfapp_t *app)
app->layout_w = 450;
app->layout_h = 600;
app->layout_em = 12;
+ app->layout_css = NULL;
+ app->layout_use_doc_css = 1;
app->transition.duration = 0.25;
app->transition.type = FZ_TRANSITION_FADE;
@@ -286,6 +288,8 @@ void pdfapp_open_progressive(pdfapp_t *app, char *filename, int reload, int bps)
fz_drop_buffer(ctx, buf);
}
+ fz_set_use_document_css(ctx, app->layout_use_doc_css);
+
#ifdef HAVE_CURL
if (!strncmp(filename, "http://", 7) || !strncmp(filename, "https://", 8))
{
diff --git a/platform/x11/pdfapp.h b/platform/x11/pdfapp.h
index 803ca351..8dd6e6f1 100644
--- a/platform/x11/pdfapp.h
+++ b/platform/x11/pdfapp.h
@@ -58,6 +58,7 @@ struct pdfapp_s
float layout_h;
float layout_em;
char *layout_css;
+ int layout_use_doc_css;
int pagecount;
diff --git a/platform/x11/win_main.c b/platform/x11/win_main.c
index b6a5ae6a..e004380d 100644
--- a/platform/x11/win_main.c
+++ b/platform/x11/win_main.c
@@ -1214,6 +1214,7 @@ static void usage(void)
fprintf(stderr, "\t-H -\tpage height for EPUB layout\n");
fprintf(stderr, "\t-S -\tfont size for EPUB layout\n");
fprintf(stderr, "\t-U -\tuser style sheet for EPUB layout\n");
+ fprintf(stderr, "\t-X\tdisable document styles for EPUB layout\n");
exit(1);
}
@@ -1230,7 +1231,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow
int bps = 0;
int displayRes = get_system_dpi();
int c;
- char *layout_css = NULL;
ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
if (!ctx)
@@ -1242,7 +1242,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow
argv = fz_argv_from_wargv(argc, wargv);
- while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:U:b:")) != -1)
+ while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:U:Xb:")) != -1)
{
switch (c)
{
@@ -1260,7 +1260,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow
case 'H': gapp.layout_h = fz_atoi(fz_optarg); break;
case 'S': gapp.layout_em = fz_atoi(fz_optarg); break;
case 'b': bps = (fz_optarg && *fz_optarg) ? fz_atoi(fz_optarg) : 4096; break;
- case 'U': layout_css = fz_optarg; break;
+ case 'U': gapp.layout_css = fz_optarg; break;
+ case 'X': gapp.layout_use_doc_css = 0; break;
default: usage();
}
}
@@ -1285,13 +1286,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow
winerror(&gapp, "cannot convert filename to utf-8");
}
- if (layout_css)
- {
- fz_buffer *buf = fz_read_file(ctx, layout_css);
- fz_set_user_css(ctx, fz_string_from_buffer(ctx, buf));
- fz_drop_buffer(ctx, buf);
- }
-
if (bps)
pdfapp_open_progressive(&gapp, filename, 0, bps);
else
diff --git a/platform/x11/x11_main.c b/platform/x11/x11_main.c
index ecd4d809..555e36a1 100644
--- a/platform/x11/x11_main.c
+++ b/platform/x11/x11_main.c
@@ -814,6 +814,7 @@ static void usage(void)
fprintf(stderr, "\t-H -\tpage height for EPUB layout\n");
fprintf(stderr, "\t-S -\tfont size for EPUB layout\n");
fprintf(stderr, "\t-U -\tuser style sheet for EPUB layout\n");
+ fprintf(stderr, "\t-X\tdisable document styles for EPUB layout\n");
exit(1);
}
@@ -844,7 +845,7 @@ int main(int argc, char **argv)
pdfapp_init(ctx, &gapp);
- while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:U:")) != -1)
+ while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:U:X")) != -1)
{
switch (c)
{
@@ -862,6 +863,7 @@ int main(int argc, char **argv)
case 'H': gapp.layout_h = fz_atof(fz_optarg); break;
case 'S': gapp.layout_em = fz_atof(fz_optarg); break;
case 'U': gapp.layout_css = fz_optarg; break;
+ case 'X': gapp.layout_use_doc_css = 0; break;
default: usage();
}
}
diff --git a/source/tools/muconvert.c b/source/tools/muconvert.c
index 575574be..c3673852 100644
--- a/source/tools/muconvert.c
+++ b/source/tools/muconvert.c
@@ -11,6 +11,7 @@ static float layout_w = 450;
static float layout_h = 600;
static float layout_em = 12;
static char *layout_css = NULL;
+static int layout_use_doc_css = 1;
/* output options */
static const char *output = NULL;
@@ -34,6 +35,7 @@ static void usage(void)
"\t-H -\tpage height for EPUB layout\n"
"\t-S -\tfont size for EPUB layout\n"
"\t-U -\tfile name of user stylesheet for EPUB layout\n"
+ "\t-X\tdisable document styles for EPUB layout\n"
"\n"
"\t-o -\toutput file name (%%d for page number)\n"
"\t-F -\toutput format (default inferred from output file name)\n"
@@ -86,7 +88,7 @@ int muconvert_main(int argc, char **argv)
{
int i, c;
- while ((c = fz_getopt(argc, argv, "p:A:W:H:S:U:o:F:O:")) != -1)
+ while ((c = fz_getopt(argc, argv, "p:A:W:H:S:U:Xo:F:O:")) != -1)
{
switch (c)
{
@@ -98,6 +100,7 @@ int muconvert_main(int argc, char **argv)
case 'H': layout_h = fz_atof(fz_optarg); break;
case 'S': layout_em = fz_atof(fz_optarg); break;
case 'U': layout_css = fz_optarg; break;
+ case 'X': layout_use_doc_css = 0; break;
case 'o': output = fz_optarg; break;
case 'F': format = fz_optarg; break;
@@ -135,6 +138,8 @@ int muconvert_main(int argc, char **argv)
fz_drop_buffer(ctx, buf);
}
+ fz_set_use_document_css(ctx, layout_use_doc_css);
+
/* Open the output document. */
fz_try(ctx)
out = fz_new_document_writer(ctx, output, format, options);
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 20122563..7b77f195 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -201,6 +201,7 @@ static float layout_w = 450;
static float layout_h = 600;
static float layout_em = 12;
static char *layout_css = NULL;
+static int layout_use_doc_css = 1;
static float min_line_width = 0.0f;
static int showfeatures = 0;
@@ -293,6 +294,7 @@ static void usage(void)
"\t-H -\tpage height for EPUB layout\n"
"\t-S -\tfont size for EPUB layout\n"
"\t-U -\tfile name of user stylesheet for EPUB layout\n"
+ "\t-X\tdisable document styles for EPUB layout\n"
"\n"
"\t-c -\tcolorspace (mono, gray, grayalpha, rgb, rgba, cmyk, cmykalpha)\n"
"\t-G -\tapply gamma correction\n"
@@ -1284,7 +1286,7 @@ int mudraw_main(int argc, char **argv)
fz_var(doc);
- while ((c = fz_getopt(argc, argv, "p:o:F:R:r:w:h:fB:c:G:Is:A:DiW:H:S:T:U:LvPl:y:")) != -1)
+ while ((c = fz_getopt(argc, argv, "p:o:F:R:r:w:h:fB:c:G:Is:A:DiW:H:S:T:U:XLvPl:y:")) != -1)
{
switch (c)
{
@@ -1310,6 +1312,7 @@ int mudraw_main(int argc, char **argv)
case 'H': layout_h = fz_atof(fz_optarg); break;
case 'S': layout_em = fz_atof(fz_optarg); break;
case 'U': layout_css = fz_optarg; break;
+ case 'X': layout_use_doc_css = 0; break;
case 's':
if (strchr(fz_optarg, 't')) ++showtime;
@@ -1437,6 +1440,8 @@ int mudraw_main(int argc, char **argv)
fz_drop_buffer(ctx, buf);
}
+ fz_set_use_document_css(ctx, layout_use_doc_css);
+
/* Determine output type */
if (band_height < 0)
{
diff --git a/source/tools/muraster.c b/source/tools/muraster.c
index d65074d5..96f59162 100644
--- a/source/tools/muraster.c
+++ b/source/tools/muraster.c
@@ -353,7 +353,8 @@ static int fit = 0;
static float layout_w = 450;
static float layout_h = 600;
static float layout_em = 12;
-static char *layoutput_css = NULL;
+static char *layout_css = NULL;
+static int layout_use_doc_css = 1;
static int showtime = 0;
static size_t memtrace_current = 0;
@@ -485,6 +486,7 @@ static void usage(void)
"\t-H -\tpage height for EPUB layout\n"
"\t-S -\tfont size for EPUB layout\n"
"\t-U -\tfile name of user stylesheet for EPUB layout\n"
+ "\t-X\tdisable document styles for EPUB layout\n"
"\n"
"\t-A -\tnumber of bits of antialiasing (0 to 8)\n"
"\t-A -/-\tnumber of bits of antialiasing (0 to 8) (graphics, text)\n"
@@ -1398,7 +1400,7 @@ int main(int argc, char **argv)
x_resolution = X_RESOLUTION;
y_resolution = Y_RESOLUTION;
- while ((c = fz_getopt(argc, argv, "p:o:F:R:r:w:h:fB:M:s:A:iW:H:S:T:U:vP")) != -1)
+ while ((c = fz_getopt(argc, argv, "p:o:F:R:r:w:h:fB:M:s:A:iW:H:S:T:U:XvP")) != -1)
{
switch (c)
{
@@ -1420,7 +1422,8 @@ int main(int argc, char **argv)
case 'W': layout_w = fz_atof(fz_optarg); break;
case 'H': layout_h = fz_atof(fz_optarg); break;
case 'S': layout_em = fz_atof(fz_optarg); break;
- case 'U': layoutput_css = fz_optarg; break;
+ case 'U': layout_css = fz_optarg; break;
+ case 'X': layout_use_doc_css = 0; break;
case 's':
if (strchr(fz_optarg, 't')) ++showtime;
@@ -1527,13 +1530,15 @@ int main(int argc, char **argv)
}
#endif /* DISABLE_MUTHREADS */
- if (layoutput_css)
+ if (layout_css)
{
- fz_buffer *buf = fz_read_file(ctx, layoutput_css);
+ fz_buffer *buf = fz_read_file(ctx, layout_css);
fz_set_user_css(ctx, fz_string_from_buffer(ctx, buf));
fz_drop_buffer(ctx, buf);
}
+ fz_set_use_document_css(ctx, layout_use_doc_css);
+
output_format = suffix_table[0].format;
output_cs = suffix_table[0].cs;
if (format)