From ddb46eeb41fe6a83cda2e3fb86fc147f6d69b072 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 27 Oct 2012 11:06:53 +0800 Subject: [PATCH] merge justification and full justification to one option Conflicts: koptconfig.lua koptreader.lua --- djvu.c | 5 ++--- k2pdfopt.c | 18 ++++++++++++++++-- k2pdfopt.h | 2 +- pdf.c | 5 ++--- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/djvu.c b/djvu.c index b84725ab4..3e6f0c409 100644 --- a/djvu.c +++ b/djvu.c @@ -482,10 +482,9 @@ static int reflowPage(lua_State *L) { double word_spacing = luaL_checknumber(L, 8); int text_wrap = luaL_checkint(L, 9); int justification = luaL_checkint(L, 10); - int full_just = luaL_checkint(L, 11); - double contrast = luaL_checknumber(L, 12); + double contrast = luaL_checknumber(L, 11); - k2pdfopt_set_params(width, height, page_margin, line_spacing, word_spacing, text_wrap, justification, full_just, contrast); + k2pdfopt_set_params(width, height, page_margin, line_spacing, word_spacing, text_wrap, justification, contrast); k2pdfopt_djvu_reflow(page->page_ref, page->doc->context, mode, page->doc->pixelformat, dc->zoom, \ width, height, line_spacing, word_spacing); k2pdfopt_rfbmp_size(&width, &height); diff --git a/k2pdfopt.c b/k2pdfopt.c index 725a91987..560d2236f 100644 --- a/k2pdfopt.c +++ b/k2pdfopt.c @@ -474,21 +474,35 @@ static void k2pdfopt_reflow_bmp(MASTERINFO *masterinfo, WILLUSBITMAP *src) { void k2pdfopt_set_params(int bb_width, int bb_height, double page_margin, \ double line_space, double word_space, \ - int wrapping, int justification, int full_just, double contrast) { + int wrapping, int justification, double contrast) { dst_userwidth = bb_width; // dst_width is adjusted in adjust_params_init dst_userheight = bb_height; vertical_line_spacing = line_space; word_spacing = word_space; text_wrap = wrapping; dst_justify = justification; - dst_fulljustify = full_just; gamma_correction = contrast; // contrast is only used by k2pdfopt_mupdf_reflow + // margin dst_mar = page_margin; dst_martop = -1.0; dst_marbot = -1.0; dst_marleft = -1.0; dst_marright = -1.0; + + // justification + if (justification < 0) { + dst_justify = -1; + dst_fulljustify = -1; + } + else if (justification <= 2) { + dst_justify = justification; + dst_fulljustify = 0; + } + else { + dst_justify = -1; + dst_fulljustify = 1; + } } void k2pdfopt_mupdf_reflow(fz_document *doc, fz_page *page, fz_context *ctx, \ diff --git a/k2pdfopt.h b/k2pdfopt.h index 1708f22eb..e454145dc 100644 --- a/k2pdfopt.h +++ b/k2pdfopt.h @@ -28,7 +28,7 @@ void k2pdfopt_set_params(int bb_width, int bb_height, double page_margin, \ double line_space, double word_space, \ - int wrapping, int justification, int full_just, double contrast); + int wrapping, int justification, double contrast); void k2pdfopt_mupdf_reflow(fz_document *doc, fz_page *page, fz_context *ctx, \ double zoom, double gamma, double rot_deg); void k2pdfopt_djvu_reflow(ddjvu_page_t *page, ddjvu_context_t *ctx, \ diff --git a/pdf.c b/pdf.c index b2e6a6fb3..8001d5bac 100644 --- a/pdf.c +++ b/pdf.c @@ -522,10 +522,9 @@ static int reflowPage(lua_State *L) { double word_spacing = luaL_checknumber(L, 8); int text_wrap = luaL_checkint(L, 9); int justification = luaL_checkint(L, 10); - int full_just = luaL_checkint(L, 11); - double contrast = luaL_checknumber(L, 12); + double contrast = luaL_checknumber(L, 11); - k2pdfopt_set_params(width, height, page_margin, line_spacing, word_spacing, text_wrap, justification, full_just, contrast); + k2pdfopt_set_params(width, height, page_margin, line_spacing, word_spacing, text_wrap, justification, contrast); k2pdfopt_mupdf_reflow(page->doc->xref, page->page, page->doc->context, dc->zoom, dc->gamma, 0.0); k2pdfopt_rfbmp_size(&width, &height); k2pdfopt_rfbmp_zoom(&dc->zoom);