diff --git a/amiga/font.c b/amiga/font.c index de84a0420..d1fcf7597 100755 --- a/amiga/font.c +++ b/amiga/font.c @@ -25,8 +25,7 @@ #include "amiga/object.h" #include "amiga/schedule.h" #include "utils/nsoption.h" -#include "css/css.h" -#include "css/utils.h" +#include "desktop/browser.h" #include "render/font.h" #include "utils/log.h" #include "utils/utf8.h" @@ -869,7 +868,7 @@ static void ami_font_cleanup(struct MinList *ami_font_list) node->dtz_Node.ln_Name, curtime.Seconds)); DelObject(node); } - }while(node=nnode); + } while(node=nnode); /* reschedule to run in five minutes */ ami_schedule(300000, ami_font_cleanup, ami_font_list); @@ -882,7 +881,7 @@ void ami_font_setdevicedpi(int id) ULONG ydpi = nsoption_int(screen_ydpi); ULONG xdpi = nsoption_int(screen_ydpi); - nscss_screen_dpi = INTTOFIX(nsoption_int(screen_ydpi)); + browser_set_dpi(nsoption_int(screen_ydpi)); if(id && (nsoption_int(monitor_aspect_x) != 0) && (nsoption_int(monitor_aspect_y) != 0)) { diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c index 7ca2d8aba..13250d4e1 100755 --- a/atari/plot/font_freetype.c +++ b/atari/plot/font_freetype.c @@ -93,8 +93,6 @@ fantasy.ttf => Fantasy #define CACHE_MIN_SIZE (100 * 1024) #define BOLD_WEIGHT 700 -extern css_fixed nscss_screen_dpi; - extern unsigned long atari_plot_flags; extern int atari_plot_vdi_handle; @@ -245,11 +243,11 @@ static void ft_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler srec) srec->width = srec->height = (fstyle->size * 64) / FONT_SIZE_SCALE; srec->pixel = 0; - /* calculate x/y resolution, when nscss_screen_dpi isn't available */ - /* 72 is an good value. */ - /* TODO: because nscss_screen_dpi is to large, calculate that value */ - /* by VDI values. */ - srec->x_res = srec->y_res = 72; // FIXTOINT(nscss_screen_dpi); + /* calculate x/y resolution, when browser_get_dpi() isn't available */ + /* 72 is an good value. */ + /* TODO: because browser_get_dpi() is to large, calculate that value */ + /* by VDI values. */ + srec->x_res = srec->y_res = 72; // browser_get_dpi(); } static FT_Glyph ft_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4) diff --git a/cocoa/plotter.m b/cocoa/plotter.m index 1d7fd2a8c..4f63424e1 100644 --- a/cocoa/plotter.m +++ b/cocoa/plotter.m @@ -22,10 +22,10 @@ #import "cocoa/plotter.h" #import "cocoa/bitmap.h" +#import "desktop/browser.h" #import "desktop/plotters.h" #import "desktop/plot_style.h" #import "utils/log.h" -#import "css/utils.h" static void cocoa_plot_render_path(NSBezierPath *path,const plot_style_t *pstyle); static void cocoa_plot_path_set_stroke_pattern(NSBezierPath *path,const plot_style_t *pstyle); @@ -323,7 +323,7 @@ void cocoa_update_scale_factor( void ) const CGFloat scale = [[NSScreen mainScreen] userSpaceScaleFactor]; cocoa_scale_factor = scale == 1.0 ? 1.0 : 1.0 / scale; cocoa_half_pixel = 0.5 * cocoa_scale_factor; - nscss_screen_dpi = FLTTOFIX( points_per_inch * scale ); + browser_set_dpi( points_per_inch * scale ); } static inline void cocoa_center_pixel( bool x, bool y ) diff --git a/desktop/browser.c b/desktop/browser.c index 1fa9de648..3ae506bcf 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -53,6 +53,7 @@ #include "desktop/scrollbar.h" #include "desktop/selection.h" #include "desktop/plotters.h" +#include "css/utils.h" #include "javascript/js.h" @@ -3124,3 +3125,17 @@ bool browser_window_stop_available(struct browser_window *bw) (content_get_status(bw->current_content) != CONTENT_STATUS_DONE)))); } + +/* exported interface documented in browser.h */ +nserror browser_set_dpi(int dpi) +{ + nscss_screen_dpi = INTTOFIX(dpi); + + return NSERROR_OK; +} + +/* exported interface documented in browser.h */ +int browser_get_dpi(void) +{ + return FIXTOINT(nscss_screen_dpi); +} diff --git a/desktop/browser.h b/desktop/browser.h index c7d8b7e79..a043f09bd 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -460,4 +460,18 @@ nserror browser_window_debug_dump(struct browser_window *bw, FILE *f, enum conte void theme_install_start(struct hlcache_handle *c); #endif +/** + * Set the DPI of the browser. + * + * \param dpi The DPI to set. + */ +nserror browser_set_dpi(int dpi); + +/** + * Get the browser DPI. + * + * \return The DPI in use. + */ +int browser_get_dpi(void); + #endif diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c index 4381db62a..eaaf2f099 100644 --- a/framebuffer/font_freetype.c +++ b/framebuffer/font_freetype.c @@ -27,10 +27,9 @@ #include "utils/utf8.h" #include "utils/log.h" #include "utils/nsoption.h" -#include "css/css.h" -#include "css/utils.h" #include "render/font.h" #include "desktop/gui.h" +#include "desktop/browser.h" #include "framebuffer/gui.h" #include "framebuffer/font.h" @@ -378,7 +377,7 @@ static void fb_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler srec) srec->width = srec->height = (fstyle->size * 64) / FONT_SIZE_SCALE; srec->pixel = 0; - srec->x_res = srec->y_res = FIXTOINT(nscss_screen_dpi); + srec->x_res = srec->y_res = browser_get_dpi(); } FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4) diff --git a/gtk/gui.c b/gtk/gui.c index eefb03a9c..a7e03b128 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -55,7 +55,6 @@ #include "desktop/sslcert_viewer.h" #include "desktop/textinput.h" #include "desktop/tree.h" -#include "css/utils.h" #include "render/form.h" #include "utils/filepath.h" #include "utils/log.h" @@ -412,10 +411,8 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) * find that out here, rather than when we create a first browser * window. */ - - nscss_screen_dpi = FLTTOFIX(gdk_screen_get_resolution( - gdk_screen_get_default())); - LOG(("Set CSS DPI to %f", FIXTOFLT(nscss_screen_dpi))); + browser_set_dpi(gdk_screen_get_resolution(gdk_screen_get_default())); + LOG(("Set CSS DPI to %d", browser_get_dpi())); if (nsgtk_history_init(glade_file_location->history) == false) die("Unable to initialise history window.\n"); diff --git a/windows/gui.c b/windows/gui.c index b7ca31366..091caca2b 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -1219,7 +1219,7 @@ static HWND nsws_window_create(struct gui_window *gw) /* set the gui window associated with this browser */ SetProp(hwnd, TEXT("GuiWnd"), (HANDLE)gw); - nscss_screen_dpi = get_window_dpi(hwnd); + browser_set_dpi(get_window_dpi(hwnd)); if ((nsoption_int(window_width) >= 100) && (nsoption_int(window_height) >= 100) &&