e alert - use the provided font ttf for the alert

this enforces the look i wanted, and also makes this work when no sans
or mono font exist.
This commit is contained in:
Carsten Haitzler 2019-10-09 18:36:54 +01:00
parent acee84c8eb
commit 1a867c180d
6 changed files with 49 additions and 8 deletions

16
data/fonts/README.txt Normal file
View File

@ -0,0 +1,16 @@
Comes from:
https://github.com/rewtnull/amigafonts
These fonts are released under the Creative Commons v3.0 license:
http://creativecommons.org/licenses/by-nc-sa/3.0/
From 2013-02-06 you are also allowed to use them according to
the GPL-FE:
http://www.gnu.org/licenses/gpl-faq.html#FontException
This licensing change was done for bundled resource compatibility.
You are now allowed to bundle any of these fonts with your WordPress
themes, and what have you.

Binary file not shown.

4
data/fonts/meson.build Normal file
View File

@ -0,0 +1,4 @@
install_data([ 'Topaz_a500_v1.0.ttf',
],
install_dir: join_paths(dir_data, 'enlightenment/data/fonts')
)

View File

@ -360,6 +360,7 @@ subdir('data/desktop')
subdir('data/etc')
subdir('data/favorites')
subdir('data/flags')
subdir('data/fonts')
subdir('data/icons')
subdir('data/images')
subdir('data/input_methods')

View File

@ -12,7 +12,10 @@ static pid_t pid;
static Eina_Bool tainted = EINA_FALSE;
static const char *backtrace_str = NULL;
#define FONT "Mono"
//#define FONT "TopazPlus_a500_v1.0.pcf"
//#define FONT "terminus-16.pcf"
#define FONT "Topaz_a500_v1.0.ttf"
#define FONT_FALLBACK "Mono"
#define COL_BG 0, 0, 0, 255
#define COL_FG 255, 0, 0, 255
#define HDIV 10
@ -85,10 +88,22 @@ key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED
}
}
static const char *
font_get(void)
{
const char *s = getenv("E_ALERT_FONT_DIR");
static char buf[4096];
if (s) snprintf(buf, sizeof(buf), "%s/"FONT, s);
else snprintf(buf, sizeof(buf), "%s", FONT_FALLBACK);
return buf;
}
static void
resize(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o, void *info EINA_UNUSED)
{
Evas_Coord w, h, tw, th;
const char *font = font_get();
evas_object_geometry_get(o, NULL, NULL, &w, &h);
h = w / HDIV;
@ -99,15 +114,15 @@ resize(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o, void *info E
evas_object_geometry_set(obj_inner, (2 * h) / PDIV, (2 * h) / PDIV,
w - ((h * 4) / PDIV), h - ((h * 4) / PDIV));
evas_object_text_font_set(obj_line1, FONT, h / 8);
evas_object_text_font_set(obj_line1, font, h / 8);
evas_object_geometry_get(obj_line1, NULL, NULL, &tw, &th);
evas_object_move(obj_line1, (w - tw) / 2, (3 * h) / PDIV);
evas_object_text_font_set(obj_line2, FONT, h / 8);
evas_object_text_font_set(obj_line2, font, h / 8);
evas_object_geometry_get(obj_line2, NULL, NULL, &tw, &th);
evas_object_move(obj_line2, (w - tw) / 2, (h - th) / 2);
evas_object_text_font_set(obj_line3, FONT, h / 8);
evas_object_text_font_set(obj_line3, font, h / 8);
evas_object_geometry_get(obj_line3, NULL, NULL, &tw, &th);
evas_object_move(obj_line3, (w - tw) / 2, h - th - (3 * h) / PDIV);
}
@ -125,6 +140,7 @@ setup_display(void)
{
Evas *e;
Evas_Object *win, *o;
const char *font = font_get();
win = o = elm_win_add(NULL, "e-alert", ELM_WIN_SPLASH);
if (!win) return EINA_FALSE;
@ -147,21 +163,21 @@ setup_display(void)
obj_line1 = o = evas_object_text_add(e);
evas_object_color_set(o, COL_FG);
evas_object_text_font_set(o, FONT, 10);
evas_object_text_font_set(o, font, 10);
evas_object_text_text_set(o, title1());
evas_object_pass_events_set(o, EINA_TRUE);
evas_object_show(o);
obj_line2 = o = evas_object_text_add(e);
evas_object_color_set(o, COL_FG);
evas_object_text_font_set(o, FONT, 10);
evas_object_text_font_set(o, font, 10);
evas_object_text_text_set(o, title2());
evas_object_pass_events_set(o, EINA_TRUE);
evas_object_show(o);
obj_line3 = o = evas_object_text_add(e);
evas_object_color_set(o, COL_FG);
evas_object_text_font_set(o, FONT, 10);
evas_object_text_font_set(o, font, 10);
evas_object_text_text_set(o, title3());
evas_object_pass_events_set(o, EINA_TRUE);
evas_object_show(o);

View File

@ -484,6 +484,7 @@ _e_call_alert(int child, siginfo_t sig, int exit_gdb, const char *backtrace_str,
Eina_Bool susr1)
{
char buf[4096];
snprintf(buf, sizeof(buf),
backtrace_str ?
"%s/enlightenment/utils/enlightenment_alert %i %i %i '%s'" :
@ -552,7 +553,7 @@ main(int argc, char **argv)
int i, valgrind_mode = 0;
int valgrind_tool = 0;
int valgrind_gdbserver = 0;
char buf[16384], **args, *home;
char buf[8192], buf2[4096], **args, *home;
char valgrind_path[PATH_MAX] = "";
const char *valgrind_log = NULL;
const char *bindir;
@ -659,6 +660,9 @@ main(int argc, char **argv)
if (really_know) _env_path_append("PATH", bindir);
else _env_path_prepend("PATH", bindir);
}
snprintf(buf2, sizeof(buf2),
"E_ALERT_FONT_DIR=%s/data/fonts", eina_prefix_data_get(pfx));
putenv(buf2);
if ((valgrind_mode || valgrind_tool) &&
!find_valgrind(valgrind_path, sizeof(valgrind_path)))