mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-05 22:34:55 +01:00
Fix the off-by-one with the poppler plugin
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
1fd5ca3ebb
commit
f2ed53aa72
3 changed files with 11 additions and 6 deletions
7
render.c
7
render.c
|
@ -152,7 +152,7 @@ render(zathura_t* zathura, zathura_page_t* page)
|
||||||
/* create cairo surface */
|
/* create cairo surface */
|
||||||
unsigned int page_width = 0;
|
unsigned int page_width = 0;
|
||||||
unsigned int page_height = 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);
|
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_restore(cairo);
|
||||||
cairo_save(cairo);
|
cairo_save(cairo);
|
||||||
|
|
||||||
double scale = zathura_document_get_scale(zathura->document);
|
if (fabs(real_scale - 1.0f) > FLT_EPSILON) {
|
||||||
if (fabs(scale - 1.0f) > FLT_EPSILON) {
|
cairo_scale(cairo, real_scale, real_scale);
|
||||||
cairo_scale(cairo, scale, scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render_lock(zathura->sync.render_thread);
|
render_lock(zathura->sync.render_thread);
|
||||||
|
|
7
utils.c
7
utils.c
|
@ -255,7 +255,7 @@ set_adjustment(GtkAdjustment* adjustment, gdouble value)
|
||||||
MIN(gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment), 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)
|
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);
|
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 height = zathura_page_get_height(page);
|
||||||
double width = zathura_page_get_width(page);
|
double width = zathura_page_get_width(page);
|
||||||
double scale = zathura_document_get_scale(document);
|
double scale = zathura_document_get_scale(document);
|
||||||
|
double real_scale;
|
||||||
|
|
||||||
if (rotate && zathura_document_get_rotation(document) % 180) {
|
if (rotate && zathura_document_get_rotation(document) % 180) {
|
||||||
*page_width = ceil(height * scale);
|
*page_width = ceil(height * scale);
|
||||||
*page_height = ceil(width * scale);
|
*page_height = ceil(width * scale);
|
||||||
|
real_scale = MAX(*page_width / height, *page_height / width);
|
||||||
} else {
|
} else {
|
||||||
*page_width = ceil(width * scale);
|
*page_width = ceil(width * scale);
|
||||||
*page_height = ceil(height * scale);
|
*page_height = ceil(height * scale);
|
||||||
|
real_scale = MAX(*page_width / width, *page_height / height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return real_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
3
utils.h
3
utils.h
|
@ -100,8 +100,9 @@ void set_adjustment(GtkAdjustment* adjust, gdouble value);
|
||||||
* @param page_height the resulting page height
|
* @param page_height the resulting page height
|
||||||
* @param page_width the resultung page width
|
* @param page_width the resultung page width
|
||||||
* @param rotate honor page's rotation
|
* @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);
|
page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue