From 55055758facab7d5abff680ffc78d0a39bae003c Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Mon, 12 Feb 2018 11:05:23 +0100 Subject: [PATCH] Assume PPI=100 (typical value) if info unavailable --- zathura/document.c | 13 ++++++------- zathura/document.h | 2 +- zathura/render.c | 6 ++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/zathura/document.c b/zathura/document.c index d315273..7023d2d 100644 --- a/zathura/document.c +++ b/zathura/document.c @@ -417,15 +417,14 @@ zathura_document_get_scale(zathura_document_t* document) return 0; } - /* If monitor PPI information is available, use it to match 100% zoom to - * physical page size */ - if (document->view_ppi > DBL_EPSILON) { - /* scale = pixels per point, and there are 72 points in one inch */ - return document->zoom * document->view_ppi / 72.0; + double ppi = document->view_ppi; + if (ppi < DBL_EPSILON) { + /* No PPI information -> use a typical value */ + ppi = 100; } - /* No PPI information -> scale == zoom */ - return document->zoom; + /* scale = pixels per point, and there are 72 points in one inch */ + return document->zoom * ppi / 72.0; } unsigned int diff --git a/zathura/document.h b/zathura/document.h index a4a66dd..42d7e77 100644 --- a/zathura/document.h +++ b/zathura/document.h @@ -154,7 +154,7 @@ double zathura_document_get_zoom(zathura_document_t* document); * PPI) * * @param document The document - * @return The current scale value + * @return The current scale value, in pixels per point */ double zathura_document_get_scale(zathura_document_t* document); diff --git a/zathura/render.c b/zathura/render.c index a250efc..0a85f45 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -741,10 +741,8 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render const double width = zathura_page_get_width(page); /* page size in user pixels based on document zoom: if PPI information is - * available, 100% zoom results in 72 documents points per inch of screen - * (i.e. document size on screen matching the physical paper size). If PPI - * information is unavailable, the page size in pixels will be 1 pixel per - * document point. */ + * correct, 100% zoom will result in 72 documents points per inch of screen + * (i.e. document size on screen matching the physical paper size). */ const double real_scale = page_calc_height_width(document, height, width, &page_height, &page_width, false);