905788b
From b6d26111ee16d57559c5ea33b0815a02c371ec0c Mon Sep 17 00:00:00 2001
905788b
From: Bjorn Gustavsson <bjorng@users.sourceforge.net>
905788b
Date: Mon, 7 Jan 2013 20:22:34 +0100
bf95278
Subject: [PATCH 4/6] Simplify font handling and stop using parameterized
905788b
 modules
905788b
905788b
The wings__font.erl module uses the experimental feature
905788b
"parameterized modules", which is scheduled to be removed in
905788b
Erlang/OTP R16.
905788b
905788b
It turns out that wings__font for historical reasons is more
905788b
flexible than it needs to be and that it is almost unused. Most
905788b
of its functionality has been taken over by wings_font_table.
905788b
By slightly tweaking wings_text and wings_font_table we can easily
905788b
eliminate the need for wing__font.
905788b
905788b
By going a step further, we can see that there is no need to keep
905788b
the code in wings_font_table in a separate module. There is not
905788b
a large amount of code, and having code split into two modules
905788b
does not make it easier to understand since there is
905788b
wings_font_table does not hide any information from wings_text.
905788b
905788b
Therefore, move all font handling code into wings_text and remove
905788b
both wings__font and wings_font_table.
905788b
905788b
Conflicts:
905788b
	plugins_src/accel/Makefile
905788b
---
905788b
 src/Makefile             |   2 -
905788b
 src/wings__font.erl      |  75 -------------------
905788b
 src/wings_console.erl    |  10 +--
905788b
 src/wings_font_table.erl |  73 -------------------
905788b
 src/wings_io.erl         |  20 +-----
905788b
 src/wings_pref_dlg.erl   |   2 -
905788b
 src/wings_text.erl       | 184 ++++++++++++++++++++++++-----------------------
905788b
 src/wings_wm.erl         |   2 +-
905788b
 8 files changed, 101 insertions(+), 267 deletions(-)
905788b
 delete mode 100644 src/wings__font.erl
905788b
 delete mode 100644 src/wings_font_table.erl
905788b
905788b
diff --git a/src/Makefile b/src/Makefile
905788b
index 1f7380c..e1b06cc 100644
905788b
--- a/src/Makefile
905788b
+++ b/src/Makefile
905788b
@@ -70,8 +70,6 @@ MODULES= \
905788b
 	wings_file \
905788b
 	wings_ff_ndo \
905788b
 	wings_ff_wings \
905788b
-	wings_font_table \
905788b
-	wings__font \
905788b
 	wings_gl \
905788b
 	wings_help \
905788b
 	wings_hotkey \
905788b
diff --git a/src/wings__font.erl b/src/wings__font.erl
905788b
deleted file mode 100644
905788b
index bb969df..0000000
905788b
--- a/src/wings__font.erl
905788b
+++ /dev/null
905788b
@@ -1,75 +0,0 @@
905788b
-%%
905788b
-%%  wings__font.erl --
905788b
-%%
905788b
-%%     Generic font operations.
905788b
-%%
905788b
-%%  Copyright (c) 2005-2011 Bjorn Gustavsson.
905788b
-%%
905788b
-%%  See the file "license.terms" for information on usage and redistribution
905788b
-%%  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
905788b
-%%
905788b
-%%     $Id$
905788b
-%%
905788b
-
905788b
--module(wings__font, [Key,Desc,Width,Height,GlyphTab,Bitmaps]).
905788b
--export([key/0,desc/0,width/0,height/0,draw/1,char/1,char_width/1,
905788b
-	bold_char/1,bold_char_width/1]).
905788b
-
905788b
-draw([C|T]) ->
905788b
-    char(C),
905788b
-    draw(T);
905788b
-draw([]) -> ok.
905788b
-
905788b
-key() -> Key.
905788b
-desc() -> Desc.
905788b
-
905788b
-char_width(C) ->
905788b
-    element(1, glyph_info(C)).
905788b
-width() ->
905788b
-    insert_glyph(char_width, Width),
905788b
-    Width.
905788b
-height() ->
905788b
-    insert_glyph(char_height, Height),
905788b
-    Height.
905788b
-
905788b
-bold_char(C) ->
905788b
-    Glyph = glyph_info(C),
905788b
-    draw_glyph(Glyph),
905788b
-    Cw = glyph_width(Glyph),
905788b
-    gl:bitmap(1, 1, 0, 0, -Cw+1, 0, <<0>>),
905788b
-    draw_glyph(Glyph).
905788b
-
905788b
-bold_char_width(C) ->
905788b
-    Glyph = glyph_info(C),
905788b
-    glyph_width(Glyph)+1.
905788b
-
905788b
-char(C) ->
905788b
-    draw_glyph(glyph_info(C)).
905788b
-
905788b
-draw_glyph({W,H,Xorig,Yorig,Xmove,B}) ->
905788b
-    gl:bitmap(W, H, Xorig, Yorig, Xmove, 0, B).
905788b
-
905788b
-glyph_info(C) ->
905788b
-    BitMap = case ets:lookup(GlyphTab, C) of
905788b
-	[] when is_integer(C), C > 0 ->
905788b
-	    %% Undefined character. Return a filled box.
905788b
-	    NumBytes = ((Width+7) div 8) * Height,
905788b
-	    B = <<(-1):NumBytes/unit:8>>,
905788b
-	    {Width,Height,0,0,Width+1,B};
905788b
-	[{_,W,H,Xorig,Yorig,Xmove,Offset}] ->
905788b
-	    %% Valid character.
905788b
-	    NumBytes = ((W+7) div 8)*H,
905788b
-	    <<_:Offset/binary,B:NumBytes/binary,_/binary>> = Bitmaps,
905788b
-	    {W,H,Xorig,Yorig,Xmove,B}
905788b
-    end,
905788b
-    insert_glyph(C, BitMap),
905788b
-    BitMap.
905788b
-
905788b
-glyph_width({_,_,_,_,Xmove,_}) -> Xmove.
905788b
-
905788b
-insert_glyph(C, BitMap) ->
905788b
-    Font = case wings_wm:this() of
905788b
-        console -> console_font;
905788b
-        _ -> system_font
905788b
-    end,
905788b
-    ets:insert(Font, {C,BitMap}).
905788b
diff --git a/src/wings_console.erl b/src/wings_console.erl
905788b
index bc75ce4..2d79876 100644
905788b
--- a/src/wings_console.erl
905788b
+++ b/src/wings_console.erl
905788b
@@ -171,9 +171,9 @@ do_window(Name) ->
905788b
     Height0 = wings_pref:get_value(console_height),
905788b
     wings_wm:delete(Name),
905788b
     {X1,_,W1,H1} = wings_wm:viewport(desktop),
905788b
-    Font = wings_pref:get_value(new_console_font),
905788b
-    CwLh = wings_io:use_font(Font, fun() -> {?CHAR_WIDTH,?LINE_HEIGHT} end),
905788b
-    {Cw,Lh} = CwLh,
905788b
+    Font = console_font,
905788b
+    {Cw,Lh} = CwLh = wings_text:font_cw_lh(Font),
905788b
+    io:format("w h: ~p ~p\n", [Cw,Lh]),
905788b
     Sw = wings_wm:vscroller_width(),
905788b
     Th = wings_wm:title_height(),
905788b
     %%
905788b
@@ -184,8 +184,8 @@ do_window(Name) ->
905788b
     do_window(Name, Font, CwLh, PosUR, Size, []).
905788b
 
905788b
 do_window(Name, Pos, Size, Ps) ->
905788b
-    Font = wings_pref:get_value(new_console_font),
905788b
-    CwLh = wings_io:use_font(Font, fun() -> {?CHAR_WIDTH,?LINE_HEIGHT} end),
905788b
+    Font = console_font,
905788b
+    CwLh = wings_text:font_cw_lh(Font),
905788b
     do_window(Name, Font, CwLh, Pos, Size, Ps).
905788b
 
905788b
 do_window(Name, Font, {Cw,Lh}, {X,Y}, {W,H}=Size, Ps) -> % {X,Y} is upper right
905788b
diff --git a/src/wings_font_table.erl b/src/wings_font_table.erl
905788b
deleted file mode 100644
905788b
index 99732a4..0000000
905788b
--- a/src/wings_font_table.erl
905788b
+++ /dev/null
905788b
@@ -1,73 +0,0 @@
905788b
-%%
905788b
-%%  wings_font_table.erl --
905788b
-%%
905788b
-%%     Functions to access the accumulated font table in ets comprised of seen
905788b
-%%     glyphs. Seen returns the glyph, unseen returns 'undefined' and then
905788b
-%%     proceeds to look up the glyph in the full font table.
905788b
-%%
905788b
-%%  Copyright (c) 2010-2011 Richard Jones.
905788b
-%%
905788b
-%%  See the file "license.terms" for information on usage and redistribution
905788b
-%%  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
905788b
-%%
905788b
-%%
905788b
-
905788b
--module(wings_font_table).
905788b
--export([draw/1,char/1,bold_char/1,bold_char_width/1,char_width/1]).
905788b
-
905788b
-draw([C|T]) ->
905788b
-    char(C),
905788b
-    draw(T);
905788b
-draw([]) -> ok.
905788b
-
905788b
-bold_char_width(C) ->
905788b
-    case glyph_info(C) of
905788b
-        undefined -> undefined;
905788b
-    Glyph ->
905788b
-        glyph_width(Glyph)+1
905788b
-    end.
905788b
-
905788b
-char_width(C) ->
905788b
-    case glyph_info(C) of
905788b
-        undefined -> undefined;
905788b
-    Glyph ->
905788b
-        glyph_width(Glyph)
905788b
-    end.
905788b
-
905788b
-bold_char(C) ->
905788b
-    case glyph_info(C) of
905788b
-        undefined -> undefined;
905788b
-    Glyph ->
905788b
-        draw_glyph(Glyph),
905788b
-        Cw = glyph_width(Glyph),
905788b
-        gl:bitmap(1, 1, 0, 0, -Cw+1, 0, <<0>>),
905788b
-        draw_glyph(Glyph)
905788b
-    end.
905788b
-
905788b
-char(C) when C=:=char_width; C=:=char_height ->
905788b
-    case glyph_info(C) of
905788b
-        undefined -> undefined;
905788b
-        Glyph -> Glyph
905788b
-    end;
905788b
-char(C) ->
905788b
-    case glyph_info(C) of
905788b
-        undefined -> undefined;
905788b
-        Glyph -> draw_glyph(Glyph)
905788b
-    end.
905788b
-
905788b
-draw_glyph({W,H,Xorig,Yorig,Xmove,B}) -> 
905788b
-    gl:bitmap(W, H, Xorig, Yorig, Xmove, 0, B).
905788b
-
905788b
-glyph_info(C) ->
905788b
-    Font = case wings_wm:this() of
905788b
-        console -> console_font;
905788b
-        _ -> system_font
905788b
-    end,
905788b
-    case ets:lookup(Font, C) of
905788b
-        [] ->
905788b
-            undefined;
905788b
-        [{C,BitMap}] ->
905788b
-            BitMap
905788b
-    end.
905788b
-
905788b
-glyph_width({_,_,_,_,Xmove,_}) -> Xmove.
905788b
diff --git a/src/wings_io.erl b/src/wings_io.erl
905788b
index 1da919c..143bdfe 100644
905788b
--- a/src/wings_io.erl
905788b
+++ b/src/wings_io.erl
905788b
@@ -3,7 +3,7 @@
905788b
 %%
905788b
 %%     This module is a wrapper for the different backends
905788b
 %%
905788b
-%%  Copyright (c) 2001-2011 Bjorn Gustavsson
905788b
+%%  Copyright (c) 2001-2013 Bjorn Gustavsson
905788b
 %%
905788b
 %%  See the file "license.terms" for information on usage and redistribution
905788b
 %%  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
905788b
@@ -36,7 +36,7 @@
905788b
 	 sunken_gradient/7,
905788b
 	 raised_rect/4,raised_rect/5,raised_rect/6,
905788b
 	 gradient_rect/5,gradient_rect_burst/5,
905788b
-	 use_font/2,text_at/2,text_at/3,unclipped_text/3,
905788b
+	 text_at/2,text_at/3,unclipped_text/3,
905788b
 	 draw_icons/1,draw_icon/3,draw_char/1,
905788b
 	 set_color/1]).
905788b
 -export([putback_event/1,putback_event_once/1,get_event/0,get_matching_events/1,
905788b
@@ -440,22 +440,6 @@ gradient_rect(X, Y, W, H, Color) ->
905788b
     gl:'end'(),
905788b
     gl:shadeModel(?GL_FLAT).
905788b
 
905788b
-use_font(Font, Fun) ->
905788b
-    case wings_wm:this() of
905788b
-	none ->
905788b
-	    OldFont = wings_pref:get_value(new_system_font),
905788b
-	    wings_pref:set_value(new_system_font, Font),
905788b
-	    Res = Fun(),
905788b
-	    wings_pref:set_value(new_system_font, OldFont),
905788b
-	    Res;
905788b
-	This ->
905788b
-	    OldFont = wings_wm:get_prop(This, font),
905788b
-	    wings_wm:set_prop(This, font, Font),
905788b
-	    Res = Fun(),
905788b
-	    wings_wm:set_prop(This, font, OldFont),
905788b
-	    Res
905788b
-    end.
905788b
-
905788b
 text_at(X, S) ->
905788b
     text_at(X, 0, S).
905788b
 
905788b
diff --git a/src/wings_pref_dlg.erl b/src/wings_pref_dlg.erl
905788b
index 2d458d7..e560430 100644
905788b
--- a/src/wings_pref_dlg.erl
905788b
+++ b/src/wings_pref_dlg.erl
905788b
@@ -666,8 +666,6 @@ smart_set_value_1(Key, Val, St) ->
905788b
 		          delayed_set_value(Key, OldVal, Val),
905788b
 		          wings_u:message(?__(5,"The language change will take effect\nthe next time Wings 3D is started."));
905788b
 		      _ ->
905788b
-		          ets:delete_all_objects(system_font),
905788b
-		          ets:delete_all_objects(console_font),
905788b
 		          wings_lang:load_language(Val)
905788b
 		    end;
905788b
 		polygon_offset_f ->
905788b
diff --git a/src/wings_text.erl b/src/wings_text.erl
905788b
index e1be5ba..645fa24 100644
905788b
--- a/src/wings_text.erl
905788b
+++ b/src/wings_text.erl
905788b
@@ -3,7 +3,7 @@
905788b
 %%
905788b
 %%     Text and font support.
905788b
 %%
905788b
-%%  Copyright (c) 2001-2011 Bjorn Gustavsson
905788b
+%%  Copyright (c) 2001-2013 Bjorn Gustavsson
905788b
 %%
905788b
 %%  See the file "license.terms" for information on usage and redistribution
905788b
 %%  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
905788b
@@ -13,9 +13,9 @@
905788b
 
905788b
 -module(wings_text).
905788b
 -export([init/0,resize/0,width/0,width/1,height/0,draw/1,char/1,bold/1]).
905788b
+-export([font_cw_lh/1]).
905788b
 -export([break_lines/2]).
905788b
 -export([fonts/0]).
905788b
--export([current_font/0]).
905788b
 
905788b
 -define(NEED_ESDL, 1).
905788b
 -define(NEED_OPENGL, 1).
905788b
@@ -25,13 +25,16 @@
905788b
 -import(lists, [reverse/1,foreach/2]).
905788b
 
905788b
 init() ->
905788b
-    wings_pref:set_default(new_system_font, '7x14'),
905788b
-    wings_pref:set_default(new_console_font, 'fixed7x14'),
905788b
+    set_font_default(new_system_font),
905788b
+    set_font_default(new_console_font),
905788b
     ets:new(system_font, [named_table,ordered_set,public]),
905788b
     ets:new(console_font, [named_table,ordered_set,public]),
905788b
     ets:new(wings_fonts, [named_table,ordered_set,public]),
905788b
     load_fonts().
905788b
 
905788b
+set_font_default(PrefKey) ->
905788b
+    wings_pref:set_default(PrefKey, get_font_default(PrefKey)).
905788b
+
905788b
 resize() ->
905788b
     %% Force rebuild of display lists next time each font
905788b
     %% is needed.
905788b
@@ -64,31 +67,23 @@ width_1([C|Cs], W) ->
905788b
 width_1([], W) -> W.
905788b
 
905788b
 bold_string_width([C|S], W) ->
905788b
-    BCW = case wings_font_table:bold_char_width(C) of
905788b
-        undefined -> (current_font()):bold_char_width(C);
905788b
-        Other -> Other
905788b
-    end,
905788b
+    BCW = glyph_width(glyph_info(C)) + 1,
905788b
     bold_string_width(S, BCW+W);
905788b
 bold_string_width([], W) ->
905788b
     W.
905788b
 
905788b
 char_width(C) ->
905788b
-    case wings_font_table:char_width(C) of
905788b
-        undefined -> (current_font()):char_width(C);
905788b
-        Other -> Other
905788b
-    end.
905788b
+    glyph_width(glyph_info(C)).
905788b
 
905788b
 width() ->
905788b
-    case wings_font_table:char(char_width) of
905788b
-        undefined -> (current_font()):width();
905788b
-        Other -> Other
905788b
-    end.
905788b
+    glyph_info(char_width).
905788b
 
905788b
 height() ->
905788b
-    case wings_font_table:char(char_height) of
905788b
-        undefined -> (current_font()):height();
905788b
-        Other -> Other
905788b
-    end.
905788b
+    glyph_info(char_height).
905788b
+
905788b
+font_cw_lh(Font) ->
905788b
+    {glyph_info(Font, char_width),
905788b
+     glyph_info(Font, char_height)}.
905788b
 
905788b
 draw([{bold,S}|Cs]) ->
905788b
     bold(S),
905788b
@@ -109,41 +104,27 @@ draw([C|Cs]) ->
905788b
 draw([]) -> ok.
905788b
 
905788b
 char(C) when is_atom(C) -> special(C);
905788b
-char(C) ->
905788b
-    case wings_font_table:char(C) of
905788b
-        undefined -> (current_font()):char(C);
905788b
-        Other -> Other
905788b
-    end.
905788b
+char(C) -> draw_glyph(glyph_info(C)).
905788b
 
905788b
 bold([C|S]) ->
905788b
-    case wings_font_table:bold_char(C) of
905788b
-        undefined -> (current_font()):bold_char(C);
905788b
-        Other -> Other
905788b
-    end,
905788b
+    Glyph = glyph_info(C),
905788b
+    draw_glyph(Glyph),
905788b
+    Cw = glyph_width(Glyph),
905788b
+    gl:bitmap(1, 1, 0, 0, -Cw+1, 0, <<0>>),
905788b
+    draw_glyph(Glyph),
905788b
     bold(S);
905788b
 bold([]) -> ok.
905788b
 
905788b
-%% Table of characters already seen.
905788b
-%% Because the CJK fonts are HUGE (+30000 glyphs), I wrote a character
905788b
-%% accumulator. The reason for this is due to the nature of the ets, which when
905788b
-%% accessed, copies the requested data to the memory of the local process. With
905788b
-%% the smaller font libraries, this wasn't a problem, but with the CJK font for
905788b
-%% supporting Chinese, Japanese, and Korean - this became an issue.
905788b
-
905788b
 current_font() ->
905788b
     case wings_wm:this() of
905788b
 	none ->
905788b
-	    FontKey = wings_pref:get_value(new_system_font),
905788b
-	    ets:lookup_element(wings_fonts, FontKey, 2);
905788b
+	    system_font;
905788b
 	This ->
905788b
-	    FontKey = wings_wm:get_prop(This, font),
905788b
-	    ets:lookup_element(wings_fonts, FontKey, 2)
905788b
+	    wings_wm:get_prop(This, font)
905788b
     end.
905788b
-
905788b
+	    
905788b
 fonts() ->
905788b
-    MatchSpec = ets:fun2ms(fun({Key,_Font,Desc}) -> {Desc,Key} end),
905788b
-    ets:select(wings_fonts, MatchSpec).
905788b
-
905788b
+    [{Desc,Key} || {Key,Desc} <- ets:tab2list(wings_fonts)].
905788b
 
905788b
 %% Formats strings to fit the width of a line length given in PIXELS
905788b
 
905788b
@@ -227,6 +208,39 @@ string_to_text_box(#tb{text=[],line=Line,res=Res0}=Tb) ->
905788b
 reverse_list(A) when length(A) < 2 -> A;
905788b
 reverse_list(A) -> reverse(A).
905788b
 
905788b
+draw_glyph({W,H,Xorig,Yorig,Xmove,B}) -> 
905788b
+    gl:bitmap(W, H, Xorig, Yorig, Xmove, 0, B).
905788b
+
905788b
+glyph_width({_,_,_,_,Xmove,_}) -> Xmove.
905788b
+
905788b
+glyph_info(C) ->
905788b
+    glyph_info(current_font(), C).
905788b
+
905788b
+glyph_info(Font, C) ->
905788b
+    case ets:lookup(Font, C) of
905788b
+	[] when is_integer(C), C > 0 ->
905788b
+	    %% Undefined character. Return a filled box.
905788b
+	    [{char_width,Width}] = ets:lookup(Font, char_width),
905788b
+	    [{char_height,Height}] = ets:lookup(Font, char_height),
905788b
+	    NumBytes = ((Width+7) div 8) * Height,
905788b
+	    B = <<(-1):NumBytes/unit:8>>,
905788b
+	    {Width,Height,0,0,Width+1,B};
905788b
+	[{C,Bitmap}] ->
905788b
+	    %% Bitmap ready for display.
905788b
+	    Bitmap;
905788b
+	[{C,W,H,Xorig,Yorig,Xmove,Offset}] ->
905788b
+	    %% Raw valid character. We will need to extract a sub-binary
905788b
+	    %% from the binary of all fonts, and write back the result
905788b
+	    %% to the ets table to speed up the next access to this
905788b
+	    %% character.
905788b
+	    [{bitmap,Bitmaps}] = ets:lookup(Font, bitmap),
905788b
+	    NumBytes = ((W+7) div 8)*H,
905788b
+	    <<_:Offset/binary,B:NumBytes/binary,_/binary>> = Bitmaps,
905788b
+	    Bitmap = {W,H,Xorig,Yorig,Xmove,B},
905788b
+	    ets:insert(Font, {C,Bitmap}),
905788b
+	    Bitmap
905788b
+    end.
905788b
+
905788b
 %%%
905788b
 %%% Special characters.
905788b
 %%%
905788b
@@ -466,52 +480,40 @@ caret() ->
905788b
 %%%
905788b
 
905788b
 load_fonts() ->
905788b
-    SystemFont = wings_pref:get_value(new_system_font),
905788b
-    ConsoleFont = wings_pref:get_value(new_console_font),
905788b
+    Wc = font_file("*"),
905788b
+    Fonts = [begin
905788b
+		 FontNameStr = filename:basename(F, ".wingsfont"),
905788b
+		 FontNameAtom = list_to_atom(FontNameStr),
905788b
+		 {FontNameAtom,FontNameStr}
905788b
+	     end || F <- filelib:wildcard(Wc)],
905788b
+    ets:insert(wings_fonts, Fonts),
905788b
+    load_font(system_font),
905788b
+    load_font(console_font).
905788b
+
905788b
+load_font(FontTab) ->
905788b
+    PrefKey = list_to_atom(lists:concat(["new_",FontTab])),
905788b
+    FontName = wings_pref:get_value(PrefKey),
905788b
+    FontFile0 = font_file(FontName),
905788b
+    FontFile = case filelib:is_file(FontFile0) of
905788b
+		   true ->
905788b
+		       FontFile0;
905788b
+		   false ->
905788b
+		       DefFont = get_font_default(PrefKey),
905788b
+		       wings_pref:set_value(PrefKey, DefFont),
905788b
+		       font_file(DefFont)
905788b
+	       end,
905788b
+    {ok,Bin} = file:read_file(FontFile),
905788b
+    {wings_font,?wings_version,Font} = binary_to_term(Bin),
905788b
+    {_Key,_Desc,Width,Height,GlyphInfo,Bitmaps} = Font,
905788b
+    ets:insert(FontTab, GlyphInfo),
905788b
+    ets:insert(FontTab, [{char_width,Width},
905788b
+			 {char_height,Height},
905788b
+			 {bitmap,Bitmaps}|GlyphInfo]).
905788b
+
905788b
+font_file(FontName) ->
905788b
     WingsDir = wings_util:lib_dir(wings),
905788b
-    WF = ".wingsfont",
905788b
-    SFont = filename:join([WingsDir,"fonts",atom_to_list(SystemFont)++WF]),
905788b
-    CFont = filename:join([WingsDir,"fonts",atom_to_list(ConsoleFont)++WF]),
905788b
-    %% Make sure font is available, otherwise load default font
905788b
-    System = case filelib:is_file(SFont) of
905788b
-        true -> SystemFont;
905788b
-        false ->
905788b
-            wings_pref:set_value(new_system_font, '7x14'),
905788b
-            '7x14'
905788b
-    end,
905788b
-    Console = case filelib:is_file(CFont) of
905788b
-        true -> ConsoleFont;
905788b
-        false ->
905788b
-            wings_pref:set_value(new_console_font, 'fixed7x14'),
905788b
-            'fixed7x14'
905788b
-    end,
905788b
-    Wc = filename:join([WingsDir,"fonts","*.wingsfont"]),
905788b
-    Fonts = filelib:wildcard(Wc),
905788b
-    foreach(fun(F) ->
905788b
-        load_font(System, Console, F)
905788b
-    end, Fonts).
905788b
-
905788b
-load_font(SystemFont, ConsoleFont, FontDir) ->
905788b
-    FontNameStr = filename:basename(FontDir, ".wingsfont"),
905788b
-    FontNameAtom = list_to_atom(FontNameStr),
905788b
-    case FontNameAtom of
905788b
-        SystemFont -> load_font_0(FontDir);
905788b
-        ConsoleFont -> load_font_0(FontDir);
905788b
-        _other -> ets:insert(wings_fonts, {FontNameAtom,ok,FontNameStr})
905788b
-    end.
905788b
+    FontFileBase = lists:concat([FontName,".wingsfont"]),
905788b
+    filename:join([WingsDir,"fonts",FontFileBase]).
905788b
 
905788b
-load_font_0(FontDir) ->
905788b
-    {ok,Bin} = file:read_file(FontDir),
905788b
-    Font = binary_to_term(Bin),
905788b
-    Mod = load_font_1(Font),
905788b
-    Key = Mod:key(),
905788b
-    Desc = Mod:desc(),
905788b
-    ets:insert(wings_fonts, {Key,Mod,Desc}).
905788b
-
905788b
-load_font_1({wings_font,?wings_version,Font}) ->
905788b
-    load_font_2(Font).
905788b
-
905788b
-load_font_2({Key,Desc,Width,Height,GlyphInfo,Bitmaps}) ->
905788b
-    T = ets:new(font, [set,public]),
905788b
-    ets:insert(T, GlyphInfo),
905788b
-    wings__font:new(Key, Desc, Width, Height, T, Bitmaps).
905788b
+get_font_default(new_system_font) -> '7x14';
905788b
+get_font_default(new_console_font) -> 'fixed7x14'.
905788b
diff --git a/src/wings_wm.erl b/src/wings_wm.erl
905788b
index 6becc49..503a035 100644
905788b
--- a/src/wings_wm.erl
905788b
+++ b/src/wings_wm.erl
905788b
@@ -211,7 +211,7 @@ new(Name, {X,Y,Z0}, {W,H}, Op) when is_integer(X), is_integer(Y),
905788b
 				    is_integer(W), is_integer(H) ->
905788b
     Z = new_resolve_z(Z0),
905788b
     Stk = handle_response(Op, dummy_event, default_stack(Name)),
905788b
-    Props = gb_trees:from_orddict([{font,wings_pref:get_value(new_system_font)}]),
905788b
+    Props = gb_trees:from_orddict([{font,system_font}]),
905788b
     Win = #win{x=X,y=Y,z=Z,w=W,h=H,name=Name,stk=Stk,props=Props},
905788b
     put(wm_windows, gb_trees:insert(Name, Win, get(wm_windows))),
905788b
     dirty().
905788b
-- 
905788b
1.8.1.4
905788b