summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-10-12 15:15:34 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-12 15:25:05 +0900
commitca581e00baea8d8f714fdc4850dd77898db5a80b (patch)
treefee9f8d2c1bb3ecced23a4e78567bd0b5b95ebd7 /src/lib/evas/common
parent47a46323981925f715153e921fe10aec9283fb35 (diff)
evas: Implement support for different H/V font DPI
This is modifying how a rarely used environment variable that sets the DPI used for font sizing is parsed. The previous form remains valid, of course. Note that EFL tends to use "scaling" instead of this DPI. The font DPI is useful for me to open up a terminology window with almost the same size as my IDE's code viewer. Use case: export EVAS_FONT_DPI=95x94 terminology Note: I still don't get a 1:1 match with Qt's rendering, and in fact 94x95 works better than what 95x94 (which is reported by xdpyinfo). Interesting though :) @feature
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_font.h2
-rw-r--r--src/lib/evas/common/evas_font_load.c19
-rw-r--r--src/lib/evas/common/evas_font_main.c7
3 files changed, 17 insertions, 11 deletions
diff --git a/src/lib/evas/common/evas_font.h b/src/lib/evas/common/evas_font.h
index b50b68d530..132b474e2f 100644
--- a/src/lib/evas/common/evas_font.h
+++ b/src/lib/evas/common/evas_font.h
@@ -39,7 +39,7 @@ EAPI void evas_common_font_draw_do(const Cutout_Rects *reuse, const
39EAPI Eina_Bool evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func); 39EAPI Eina_Bool evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func);
40 40
41/* load */ 41/* load */
42EAPI void evas_common_font_dpi_set (int dpi); 42EAPI void evas_common_font_dpi_set (int dpi_h, int dpi_v);
43EAPI RGBA_Font_Source *evas_common_font_source_memory_load (const char *name, const void *data, int data_size); 43EAPI RGBA_Font_Source *evas_common_font_source_memory_load (const char *name, const void *data, int data_size);
44EAPI RGBA_Font_Source *evas_common_font_source_load (const char *name); 44EAPI RGBA_Font_Source *evas_common_font_source_load (const char *name);
45EAPI int evas_common_font_source_load_complete (RGBA_Font_Source *fs); 45EAPI int evas_common_font_source_load_complete (RGBA_Font_Source *fs);
diff --git a/src/lib/evas/common/evas_font_load.c b/src/lib/evas/common/evas_font_load.c
index f568fa718a..dfe94e9fb1 100644
--- a/src/lib/evas/common/evas_font_load.c
+++ b/src/lib/evas/common/evas_font_load.c
@@ -24,7 +24,8 @@ extern FT_Library evas_ft_lib;
24 24
25static int font_cache_usage = 0; 25static int font_cache_usage = 0;
26static int font_cache = 0; 26static int font_cache = 0;
27static int font_dpi = 75; 27static int font_dpi_h = 75;
28static int font_dpi_v = 75;
28 29
29static Eina_Hash *fonts_src = NULL; 30static Eina_Hash *fonts_src = NULL;
30static Eina_Hash *fonts = NULL; 31static Eina_Hash *fonts = NULL;
@@ -131,9 +132,11 @@ evas_common_font_load_shutdown(void)
131} 132}
132 133
133EAPI void 134EAPI void
134evas_common_font_dpi_set(int dpi) 135evas_common_font_dpi_set(int dpi_h, int dpi_v)
135{ 136{
136 font_dpi = dpi; 137 if (dpi_v <= 0) dpi_v = dpi_h;
138 font_dpi_h = dpi_h;
139 font_dpi_v = dpi_v;
137} 140}
138 141
139EAPI RGBA_Font_Source * 142EAPI RGBA_Font_Source *
@@ -365,7 +368,7 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size,
365#ifdef EVAS_CSERVE2 368#ifdef EVAS_CSERVE2
366 if (evas_cserve2_use_get()) 369 if (evas_cserve2_use_get())
367 { 370 {
368 fi->cs2_handler = evas_cserve2_font_load(source, name, size, font_dpi, 371 fi->cs2_handler = evas_cserve2_font_load(source, name, size, font_dpi_h,
369 wanted_rend); 372 wanted_rend);
370 if (fi->cs2_handler) 373 if (fi->cs2_handler)
371 { 374 {
@@ -409,7 +412,7 @@ evas_common_font_int_load(const char *name, int size,
409#ifdef EVAS_CSERVE2 412#ifdef EVAS_CSERVE2
410 if (evas_cserve2_use_get()) 413 if (evas_cserve2_use_get())
411 { 414 {
412 fi->cs2_handler = evas_cserve2_font_load(NULL, name, size, font_dpi, 415 fi->cs2_handler = evas_cserve2_font_load(NULL, name, size, font_dpi_h,
413 wanted_rend); 416 wanted_rend);
414 if (fi->cs2_handler) 417 if (fi->cs2_handler)
415 { 418 {
@@ -449,7 +452,7 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
449 } 452 }
450 fi->real_size = fi->size * 64; 453 fi->real_size = fi->size * 64;
451 fi->scale_factor = 1.0; 454 fi->scale_factor = 1.0;
452 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi); 455 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi_h, font_dpi_v);
453 if (error) 456 if (error)
454 error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size); 457 error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
455 FTUNLOCK(); 458 FTUNLOCK();
@@ -503,12 +506,12 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
503 FTUNLOCK(); 506 FTUNLOCK();
504 if (error) 507 if (error)
505 { 508 {
506 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi); 509 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi_h, font_dpi_v);
507 if (error) 510 if (error)
508 { 511 {
509 /* hack around broken fonts */ 512 /* hack around broken fonts */
510 fi->real_size = (chosen_size2 / 64) * 60; 513 fi->real_size = (chosen_size2 / 64) * 60;
511 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi); 514 error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi_h, font_dpi_v);
512 if (error) 515 if (error)
513 { 516 {
514 /* couldn't choose the size anyway... what now? */ 517 /* couldn't choose the size anyway... what now? */
diff --git a/src/lib/evas/common/evas_font_main.c b/src/lib/evas/common/evas_font_main.c
index 0b25e31868..c156bd7477 100644
--- a/src/lib/evas/common/evas_font_main.c
+++ b/src/lib/evas/common/evas_font_main.c
@@ -48,9 +48,12 @@ evas_common_font_init(void)
48 s = getenv("EVAS_FONT_DPI"); 48 s = getenv("EVAS_FONT_DPI");
49 if (s) 49 if (s)
50 { 50 {
51 int dpi = atoi(s); 51 int dpi_h = 75, dpi_v = 0;
52 52
53 if (dpi > 0) evas_common_font_dpi_set(dpi); 53 if (sscanf(s, "%dx%d", &dpi_h, &dpi_v) < 2)
54 dpi_h = dpi_v = atoi(s);
55
56 if (dpi_h > 0) evas_common_font_dpi_set(dpi_h, dpi_v);
54 } 57 }
55 LKI(lock_font_draw); 58 LKI(lock_font_draw);
56 LKI(lock_bidi); 59 LKI(lock_bidi);