mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 02:36:00 +01:00
Use DPI to scale documents to physical size
This commit is contained in:
parent
fc5a344dc1
commit
250547cabd
2 changed files with 13 additions and 1 deletions
|
@ -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);
|
g_return_val_if_fail(document != NULL && page_height != NULL && page_width != NULL, 0.0);
|
||||||
|
|
||||||
double scale = zathura_document_get_scale(document);
|
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) {
|
if (rotate == true && zathura_document_get_rotation(document) % 180 != 0) {
|
||||||
*page_width = round(height * scale);
|
*page_width = round(height * scale);
|
||||||
*page_height = round(width * 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 height = zathura_page_get_height(page);
|
||||||
const double width = zathura_page_get_width(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,
|
const double real_scale = page_calc_height_width(document, height, width,
|
||||||
&page_height, &page_width,
|
&page_height, &page_width,
|
||||||
false);
|
false);
|
||||||
|
|
Loading…
Reference in a new issue