Skip to content

Commit

Permalink
Use fonts from archive
Browse files Browse the repository at this point in the history
Needed to make escript work.
  • Loading branch information
psyeugenic committed Apr 3, 2017
1 parent 9cebe6e commit 5d0d45b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Binary file added priv/eplot/priv/fonts/6x11_latin1.wingsfont
Binary file not shown.
7 changes: 6 additions & 1 deletion rebar.config
Expand Up @@ -9,4 +9,9 @@
]}. ]}.


{cover_enabled, true}. {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}.
14 changes: 12 additions & 2 deletions src/egd_chart.erl
Expand Up @@ -79,7 +79,7 @@ graph(Data, Options) ->


% Fonts? Check for text enabling % 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), draw_graphs(Data, Chart, Im),


Expand Down Expand Up @@ -344,7 +344,7 @@ bar2d(Data0, Options) ->
egd:filledRectangle(Im, Pt1, Pt2, LightBlue), % background egd:filledRectangle(Im, Pt1, Pt2, LightBlue), % background


% Fonts? Check for text enabling % 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), draw_bar2d_ytick(Im, Chart, Font),


Expand Down Expand Up @@ -653,3 +653,13 @@ foreach_seq_loop(0, _, _, _) -> ok;
foreach_seq_loop(N, I, Inc, Fun) -> foreach_seq_loop(N, I, Inc, Fun) ->
_ = Fun(I), _ = Fun(I),
foreach_seq_loop(N-1, I+Inc, Inc, Fun). 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.