Commit 250547ca authored by Jeremie Knuesel's avatar Jeremie Knuesel

Use DPI to scale documents to physical size

parent fc5a344d
......@@ -13,6 +13,14 @@ page_calc_height_width(zathura_document_t* document, double height,
g_return_val_if_fail(document != NULL && page_height != NULL && page_width != NULL, 0.0);
double scale = zathura_document_get_scale(document);
/* If monitor DPI information is available, use it to match 100% zoom to physical page size */
double dpi = zathura_document_get_viewport_dpi(document);
if (fabs(dpi) != DBL_EPSILON) {
/* real scale = 1 means: 1 point = 1 pixel, and there are 72 points in one inch */
scale *= dpi / 72.0;
}
if (rotate == true && zathura_document_get_rotation(document) % 180 != 0) {
*page_width = round(height * scale);
*page_height = round(width * scale);
......
......@@ -740,7 +740,11 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
const double height = zathura_page_get_height(page);
const double width = zathura_page_get_width(page);
/* page size in user pixels base on document zoom: 100% results in 1 pixel per point */
/* page size in user pixels based on document zoom: if DPI information is
* available, 100% results in 72 documents points per inch of screen (i.e.
* document size on screen matching the physical paper size). If DPI
* information is unavailable, the page size in pixels will be 1 pixel per
* document point. */
const double real_scale = page_calc_height_width(document, height, width,
&page_height, &page_width,
false);
......
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