Hosted by
|
with Choices.SVG;
package body Font_Loaders is
function Create
(Path : in String;
Special : in Percent)
return Font_Loader_Access
is
Result : Font_Loader_Access := new Font_Loader;
begin
To_String_Access(Path, Result.Path);
Result.Special := Special;
Result.Choices := Choice_Hash_Tables.Create;
return Result;
end Create;
function Get_Path
(This : access Font_Loader)
return String is
begin
return To_String(This.Path);
end Get_Path;
function Get_Special
(This : access Font_Loader)
return Percent is
begin
return This.Special;
end Get_Special;
function Glyph_Filename
(This : access Font_Loader;
Glyph_Name : in String)
return String is
begin
return
To_String(This.Path) & '/' &
Glyph_Name & ".svg";
end Glyph_Filename;
function Load_Glyph
(This : access Font_Loader;
Glyph_Name : in String)
return Glyph_Access
is
use Choice_Hash_Tables;
Choice : Choice_Access;
Found : Boolean;
begin
Get(This.Choices, Glyph_Name, Choice, Found);
if not Found then
Choice := SVG.Read(Glyph_Filename(This, Glyph_Name));
Put(This.Choices, Glyph_Name, Choice);
end if;
return Choose(Choice, This.Special);
exception
when Ada.IO_Exceptions.Name_Error =>
Raise_Exception(Glyph_Not_Found'Identity,
Glyph_Filename(This, Glyph_Name));
end Load_Glyph;
end Font_Loaders;
|