Commit f2ed53aa authored by Sebastian Ramacher's avatar Sebastian Ramacher

Fix the off-by-one with the poppler plugin

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 1fd5ca3e
......@@ -152,7 +152,7 @@ render(zathura_t* zathura, zathura_page_t* page)
/* create cairo surface */
unsigned int page_width = 0;
unsigned int page_height = 0;
page_calc_height_width(page, &page_height, &page_width, false);
const double real_scale = page_calc_height_width(page, &page_height, &page_width, false);
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, page_width, page_height);
......@@ -174,9 +174,8 @@ render(zathura_t* zathura, zathura_page_t* page)
cairo_restore(cairo);
cairo_save(cairo);
double scale = zathura_document_get_scale(zathura->document);
if (fabs(scale - 1.0f) > FLT_EPSILON) {
cairo_scale(cairo, scale, scale);
if (fabs(real_scale - 1.0f) > FLT_EPSILON) {
cairo_scale(cairo, real_scale, real_scale);
}
render_lock(zathura->sync.render_thread);
......
......@@ -255,7 +255,7 @@ set_adjustment(GtkAdjustment* adjustment, gdouble value)
MIN(gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment), value)));
}
void
double
page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate)
{
g_return_if_fail(page != NULL && page_height != NULL && page_width != NULL);
......@@ -268,14 +268,19 @@ page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned
double height = zathura_page_get_height(page);
double width = zathura_page_get_width(page);
double scale = zathura_document_get_scale(document);
double real_scale;
if (rotate && zathura_document_get_rotation(document) % 180) {
*page_width = ceil(height * scale);
*page_height = ceil(width * scale);
real_scale = MAX(*page_width / height, *page_height / width);
} else {
*page_width = ceil(width * scale);
*page_height = ceil(height * scale);
real_scale = MAX(*page_width / width, *page_height / height);
}
return real_scale;
}
void
......
......@@ -100,8 +100,9 @@ void set_adjustment(GtkAdjustment* adjust, gdouble value);
* @param page_height the resulting page height
* @param page_width the resultung page width
* @param rotate honor page's rotation
* @return real scale after rounding
*/
void
double
page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate);
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment