diff --git a/legacy/evas/src/lib/engines/common/evas_font.h b/legacy/evas/src/lib/engines/common/evas_font.h index 219324d855..1e15d2a5e9 100644 --- a/legacy/evas/src/lib/engines/common/evas_font.h +++ b/legacy/evas/src/lib/engines/common/evas_font.h @@ -29,7 +29,7 @@ EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGB EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index); /* load */ - +EAPI void evas_common_font_dpi_set (int dpi); EAPI RGBA_Font_Source *evas_common_font_source_memory_load (const char *name, const void *data, int data_size); EAPI RGBA_Font_Source *evas_common_font_source_load (const char *name); EAPI int evas_common_font_source_load_complete (RGBA_Font_Source *fs); diff --git a/legacy/evas/src/lib/engines/common/evas_font_load.c b/legacy/evas/src/lib/engines/common/evas_font_load.c index f571f944e8..0821f7e91d 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_load.c +++ b/legacy/evas/src/lib/engines/common/evas_font_load.c @@ -11,6 +11,7 @@ extern FT_Library evas_ft_lib; static int font_cache_usage = 0; static int font_cache = 0; +static int font_dpi = 75; static Eina_Hash * fonts_src = NULL; static Eina_Hash * fonts = NULL; @@ -114,6 +115,12 @@ evas_common_font_load_shutdown(void) fonts_src = NULL; } +EAPI void +evas_common_font_dpi_set(int dpi) +{ + font_dpi = dpi; +} + EAPI RGBA_Font_Source * evas_common_font_source_memory_load(const char *name, const void *data, int data_size) { @@ -366,7 +373,7 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi) FT_Activate_Size(fi->ft.size); } fi->real_size = fi->size * 64; - error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, 75, 75); + error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi); if (error) { fi->real_size = fi->size; diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c index f989aac2d9..37e35f0c0a 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c @@ -19,6 +19,11 @@ struct _Render_Engine { Evas_GL_X11_Window *win; int end; + + XrmDatabase xrdb; // xres - dpi + struct { // xres - dpi + int dpi; // xres - dpi + } xr; // xres - dpi }; static void * @@ -75,9 +80,55 @@ eng_setup(Evas *e, void *in) e->engine.data.output = NULL; return 0; } - + + { + int status; + char *type = NULL; + XrmValue val; + + re->xr.dpi = 75000; // dpy * 1000 + re->xrdb = XrmGetDatabase(info->info.display); + status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val); + if ((status) && (type)) + { + if (!strcmp(type, "String")) + { + const char *str, *dp; + + str = val.addr; + dp = strchr(str, '.'); + if (!dp) dp = strchr(str, ','); + + if (dp) + { + int subdpi, len, i; + char *buf; + + buf = alloca(dp - str + 1); + strncpy(buf, str, dp - str); + buf[dp - str] = 0; + len = strlen(dp + 1); + subdpi = atoi(dp + 1); + + if (len < 3) + { + for (i = len; i < 3; i++) subdpi *= 10; + } + else if (len > 3) + { + for (i = len; i > 3; i--) subdpi /= 10; + } + re->xr.dpi = atoi(buf) * 1000; + } + else + re->xr.dpi = atoi(str) * 1000; + } + } + evas_common_font_dpi_set(re->xr.dpi / 1000); + } + evas_common_cpu_init(); - + evas_common_blend_init(); evas_common_image_init(); evas_common_convert_init(); diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.h b/legacy/evas/src/modules/engines/gl_x11/evas_engine.h index 734c0abd3c..74359bd1e3 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.h +++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.h @@ -13,13 +13,7 @@ # include # include # include -//// this changed. this was the old style. above the new style -//# include -//# include -//# include -//# include -//# include -//# include +# include // xres - dpi # elif defined(GLES_VARIETY_SGX) # define SUPPORT_X11 1 # include @@ -29,13 +23,15 @@ # include # include # include -# endif +# include // xres - dpi +#endif # else # include # include # include # include # include +# include // xres - dpi # include # include # include diff --git a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.c b/legacy/evas/src/modules/engines/software_16_x11/evas_engine.c index f4460d173d..77d1362d2f 100644 --- a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_16_x11/evas_engine.c @@ -20,6 +20,12 @@ struct _Render_Engine Tilebuf *tb; Tilebuf_Rect *rects; Tilebuf_Rect *cur_rect; + + XrmDatabase xrdb; // xres - dpi + struct { // xres - dpi + int dpi; // xres - dpi + } xr; // xres - dpi + X_Output_Buffer *shbuf; Soft16_Image *tmp_out; /* used by indirect render, like rotation */ Region clip_rects; @@ -175,6 +181,54 @@ eng_setup(Evas *e, void *in) } } if (!e->engine.data.output) return 0; + + + { + int status; + char *type = NULL; + XrmValue val; + + re->xr.dpi = 75000; // dpy * 1000 + re->xrdb = XrmGetDatabase(re->disp); + status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val); + if ((status) && (type)) + { + if (!strcmp(type, "String")) + { + const char *str, *dp; + + str = val.addr; + dp = strchr(str, '.'); + if (!dp) dp = strchr(str, ','); + + if (dp) + { + int subdpi, len, i; + char *buf; + + buf = alloca(dp - str + 1); + strncpy(buf, str, dp - str); + buf[dp - str] = 0; + len = strlen(dp + 1); + subdpi = atoi(dp + 1); + + if (len < 3) + { + for (i = len; i < 3; i++) subdpi *= 10; + } + else if (len > 3) + { + for (i = len; i > 3; i--) subdpi /= 10; + } + re->xr.dpi = atoi(buf) * 1000; + } + else + re->xr.dpi = atoi(str) * 1000; + } + } + evas_common_font_dpi_set(re->xr.dpi / 1000); + } + /* add a draw context if we dont have one */ if (!e->engine.data.context) e->engine.data.context = @@ -191,6 +245,9 @@ eng_output_free(void *data) Render_Engine *re; re = (Render_Engine *)data; + + if (re->xrdb) XrmDestroyDatabase(re->xrdb); + if (re->shbuf) evas_software_x11_x_output_buffer_free(re->shbuf, 0); if (re->clip_rects) XDestroyRegion(re->clip_rects); if (re->gc) XFreeGC(re->disp, re->gc); diff --git a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.h b/legacy/evas/src/modules/engines/software_16_x11/evas_engine.h index 3aef165ac5..5ca8c17dd1 100644 --- a/legacy/evas/src/modules/engines/software_16_x11/evas_engine.h +++ b/legacy/evas/src/modules/engines/software_16_x11/evas_engine.h @@ -5,6 +5,7 @@ #include #include #include +#include // xres - dpi #include #include #include "evas_common.h" diff --git a/legacy/evas/src/modules/engines/software_x11/evas_engine.c b/legacy/evas/src/modules/engines/software_x11/evas_engine.c index a7f44b1d29..fa98684b36 100644 --- a/legacy/evas/src/modules/engines/software_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_x11/evas_engine.c @@ -30,7 +30,14 @@ struct _Render_Engine Tilebuf_Rect *rects; Eina_Inlist *cur_rect; int end : 1; - + +#ifdef BUILD_ENGINE_SOFTWARE_XLIB + XrmDatabase xrdb; // xres - dpi + struct { // xres - dpi + int dpi; // xres - dpi + } xr; // xres - dpi +#endif + void (*outbuf_free)(Outbuf *ob); void (*outbuf_reconfigure)(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth); int (*outbuf_get_rot)(Outbuf *ob); @@ -91,6 +98,52 @@ _output_xlib_setup(int w, evas_software_xlib_x_color_init(); evas_software_xlib_outbuf_init(); + { + int status; + char *type = NULL; + XrmValue val; + + re->xr.dpi = 75000; // dpy * 1000 + re->xrdb = XrmGetDatabase(disp); + status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val); + if ((status) && (type)) + { + if (!strcmp(type, "String")) + { + const char *str, *dp; + + str = val.addr; + dp = strchr(str, '.'); + if (!dp) dp = strchr(str, ','); + + if (dp) + { + int subdpi, len, i; + char *buf; + + buf = alloca(dp - str + 1); + strncpy(buf, str, dp - str); + buf[dp - str] = 0; + len = strlen(dp + 1); + subdpi = atoi(dp + 1); + + if (len < 3) + { + for (i = len; i < 3; i++) subdpi *= 10; + } + else if (len > 3) + { + for (i = len; i > 3; i--) subdpi /= 10; + } + re->xr.dpi = atoi(buf) * 1000; + } + else + re->xr.dpi = atoi(str) * 1000; + } + } + evas_common_font_dpi_set(re->xr.dpi / 1000); + } + re->ob = evas_software_xlib_outbuf_setup_x(w, h, rot, @@ -162,6 +215,8 @@ _output_xcb_setup(int w, evas_software_xcb_x_color_init(); evas_software_xcb_outbuf_init(); + // FIXME: re->xrdb + re->ob = evas_software_xcb_outbuf_setup_x(w, h, rot, @@ -498,6 +553,10 @@ eng_output_free(void *data) if (!data) return; +#ifdef BUILD_ENGINE_SOFTWARE_XLIB + if (re->xrdb) XrmDestroyDatabase(re->xrdb); +#endif + re = (Render_Engine *)data; re->outbuf_free(re->ob); evas_common_tilebuf_free(re->tb); diff --git a/legacy/evas/src/modules/engines/software_x11/evas_engine.h b/legacy/evas/src/modules/engines/software_x11/evas_engine.h index 3a9d581aea..918ce072c7 100644 --- a/legacy/evas/src/modules/engines/software_x11/evas_engine.h +++ b/legacy/evas/src/modules/engines/software_x11/evas_engine.h @@ -9,6 +9,7 @@ # include # include # include +# include #endif #ifdef BUILD_ENGINE_SOFTWARE_XCB diff --git a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c index 32d9300bc3..776c26c9ec 100644 --- a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c @@ -30,6 +30,13 @@ struct _Render_Engine } x11; unsigned char destination_alpha : 1; +#ifdef BUILD_ENGINE_XRENDER_X11 + XrmDatabase xrdb; // xres - dpi + struct { // xres - dpi + int dpi; // xres - dpi + } xr; // xres - dpi +#endif + Ximage_Info *xinf; Xrender_Surface *output; Xrender_Surface *mask_output; @@ -217,6 +224,52 @@ _output_xlib_setup(int width, re->render_surface_line_draw = _xr_xlib_render_surface_line_draw; re->render_surface_polygon_draw = _xr_xlib_render_surface_polygon_draw; + { + int status; + char *type = NULL; + XrmValue val; + + re->xr.dpi = 75000; // dpy * 1000 + re->xrdb = XrmGetDatabase((Display *)re->x11.connection); + status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val); + if ((status) && (type)) + { + if (!strcmp(type, "String")) + { + const char *str, *dp; + + str = val.addr; + dp = strchr(str, '.'); + if (!dp) dp = strchr(str, ','); + + if (dp) + { + int subdpi, len, i; + char *buf; + + buf = alloca(dp - str + 1); + strncpy(buf, str, dp - str); + buf[dp - str] = 0; + len = strlen(dp + 1); + subdpi = atoi(dp + 1); + + if (len < 3) + { + for (i = len; i < 3; i++) subdpi *= 10; + } + else if (len > 3) + { + for (i = len; i > 3; i--) subdpi /= 10; + } + re->xr.dpi = atoi(buf) * 1000; + } + else + re->xr.dpi = atoi(str) * 1000; + } + } + evas_common_font_dpi_set(re->xr.dpi / 1000); + } + return re; } @@ -446,6 +499,11 @@ eng_output_free(void *data) Render_Engine *re; re = (Render_Engine *)data; + +#ifdef BUILD_ENGINE_XRENDER_X11 + if (re->xrdb) XrmDestroyDatabase(re->xrdb); +#endif + evas_common_font_shutdown(); evas_common_image_shutdown(); while (re->updates) diff --git a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h index 9a349fc7b7..7ccb4d62d3 100644 --- a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h +++ b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h @@ -9,6 +9,7 @@ #include #include #include +#include // xres - dpi #ifdef BUILD_ENGINE_XRENDER_XCB # include