summaryrefslogtreecommitdiff
path: root/platform
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 /platform
parentdd15bf347ca04cb79d1e009a7afb0f4c082820ca (diff)
downloadmupdf-1280bde7a824599bad9e277f6b3e74b850a1e6fc.tar.xz
Add 'X' option to disable document styles.
Diffstat (limited to 'platform')
-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
5 files changed, 18 insertions, 12 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();
}
}