1 /**
2  * Copyright:       Copyright (C) 2018 Gabriel Gheorghe, All Rights Reserved
3  * Authors:         $(Gabriel Gheorghe)
4  * License:         $(LINK2 https://www.gnu.org/licenses/gpl-3.0.txt, GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007)
5  * Source:          $(LINK2 https://github.com/GabyForceQ/LibertyEngine/blob/master/source/liberty/text/io.d)
6  * Documentation:
7  * Coverage:
8 **/
9 module liberty.text.io;
10 
11 import std.stdio : File;
12 import std..string : strip;
13 import std.array : split;
14 
15 import liberty.logger;
16 
17 /**
18  *
19 **/
20 final abstract class TextIO {
21   /**
22    *
23   **/
24   static void loadFont(string path) {
25     import std.array : split;
26 
27     // Check extension
28     string[] splitArray = path.split(".");	
29     immutable extension = splitArray[$ - 1];
30     switch (extension) {
31       case "fnt":
32         return loadFNTFile(path);
33       default:
34         Logger.error(	
35           "File format not supported for font data: " ~ extension,	
36           typeof(this).stringof	
37         );
38     }
39 
40     assert(0, "Unreachable");
41   }
42 
43   private static void loadFNTFile(string path) {
44     // Open the file
45     auto file = File(path);
46     scope(exit) file.close();
47 
48     // Read the file and build text data
49     auto range = file.byLine();
50     foreach (line; range) {
51       line = line.strip();
52       char[][] tokens = line.split(" ");
53 
54     }
55   }
56 }