Permalink
Browse files

Use fonts from archive

Needed to make escript work.
  • Loading branch information...
1 parent 9cebe6e commit 5d0d45b0afd38f10d430e4547cea4fd82f444d7e @psyeugenic committed Apr 3, 2017
Showing with 18 additions and 3 deletions.
  1. BIN priv/eplot/priv/fonts/6x11_latin1.wingsfont
  2. +6 −1 rebar.config
  3. +12 −2 src/egd_chart.erl
Binary file not shown.
View
@@ -9,4 +9,9 @@
]}.
{cover_enabled, true}.
-{deps, [{egd, {git, "https://github.com/erlang/egd.git", {tag, "0.9.1"}}}]}.
+{deps, [{egd, {git, "https://github.com/erlang/egd.git", {tag, "0.10.0"}}}]}.
+
+{escript_incl_apps,[egd,eplot]}.
+{escript_incl_extra, [{"eplot/priv/fonts/*.wingsfont", "priv"}]}.
+{escript_main_app, eplot}.
+{escript_name, eplot}.
View
@@ -79,7 +79,7 @@ graph(Data, Options) ->
% Fonts? Check for text enabling
- Font = egd_font:load(filename:join([code:priv_dir(egd), "fonts", "6x11_latin1.wingsfont"])),
+ Font = load_font("6x11_latin1.wingsfont"),
draw_graphs(Data, Chart, Im),
@@ -344,7 +344,7 @@ bar2d(Data0, Options) ->
egd:filledRectangle(Im, Pt1, Pt2, LightBlue), % background
% Fonts? Check for text enabling
- Font = egd_font:load(filename:join([code:priv_dir(egd), "fonts", "6x11_latin1.wingsfont"])),
+ Font = load_font("6x11_latin1.wingsfont"),
draw_bar2d_ytick(Im, Chart, Font),
@@ -653,3 +653,13 @@ foreach_seq_loop(0, _, _, _) -> ok;
foreach_seq_loop(N, I, Inc, Fun) ->
_ = Fun(I),
foreach_seq_loop(N-1, I+Inc, Inc, Fun).
+
+load_font(Font) ->
+ case erl_prim_loader:get_file(filename:join([code:priv_dir(eplot),"fonts",Font])) of
+ {ok,FontBinary,_} ->
+ %% archive
+ egd_font:load_binary(FontBinary);
+ _ ->
+ {ok,FontBinary,_} = erl_prim_loader:get_file(filename:join([code:priv_dir(eplot),"eplot/priv/fonts",Font])),
+ egd_font:load_binary(FontBinary)
+ end.

0 comments on commit 5d0d45b

Please sign in to comment.