Mercurial > projects > mde
comparison mde/font/font.d @ 81:d8fccaa45d5f
Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 29 Aug 2008 11:59:43 +0100 |
parents | 61ea26abe4dd |
children | e0f1ec7fe73a |
comparison
equal
deleted
inserted
replaced
80:ea58f277f487 | 81:d8fccaa45d5f |
---|---|
19 public import mde.types.Colour; | 19 public import mde.types.Colour; |
20 import mde.lookup.Options; | 20 import mde.lookup.Options; |
21 import mde.font.FontTexture; | 21 import mde.font.FontTexture; |
22 import mde.font.exception; | 22 import mde.font.exception; |
23 | 23 |
24 import mde.mergetag.Reader; | 24 import mde.file.mergetag.Reader; |
25 import mde.mergetag.DataSet; | 25 import mde.file.mergetag.DataSet; |
26 import mde.mergetag.exception; | |
27 import mde.setup.paths; | 26 import mde.setup.paths; |
28 | 27 |
29 import derelict.freetype.ft; | 28 import derelict.freetype.ft; |
30 import derelict.opengl.gl; | 29 import derelict.opengl.gl; |
31 | 30 |
32 import mde.mergetag.deserialize; | 31 import mde.file.deserialize; |
33 import tango.stdc.stringz; | 32 import tango.stdc.stringz; |
34 import Util = tango.text.Util; | 33 import Util = tango.text.Util; |
35 import tango.util.log.Log : Log, Logger; | 34 import tango.util.log.Log : Log, Logger; |
36 | 35 |
37 // "Publically import" this symbol: | 36 // "Publically import" this symbol: |
57 } | 56 } |
58 | 57 |
59 /** Load the freetype library from the file fileName. */ | 58 /** Load the freetype library from the file fileName. */ |
60 private const fileName = "fonts"; | 59 private const fileName = "fonts"; |
61 void initialize () { | 60 void initialize () { |
62 if (!confDir.exists (fileName)) | |
63 throw new fontException ("No font settings file (fonts.[mtt|mtb])"); | |
64 | |
65 if (FT_Init_FreeType (&library)) | 61 if (FT_Init_FreeType (&library)) |
66 throw new fontException ("error initialising the FreeType library"); | 62 throw new fontException ("error initialising the FreeType library"); |
67 | 63 |
68 // Check version | 64 // Check version |
69 FT_Int maj, min, patch; | 65 FT_Int maj, min, patch; |
108 // get fallback name | 104 // get fallback name |
109 char[]* p = "fallback" in reader.dataset.header._charA; | 105 char[]* p = "fallback" in reader.dataset.header._charA; |
110 if (p is null) | 106 if (p is null) |
111 throw new fontException ("No fallback font style specified"); | 107 throw new fontException ("No fallback font style specified"); |
112 fallbackName = *p; | 108 fallbackName = *p; |
113 } | 109 } catch (NoFileException) { |
114 catch (MTException e) { | 110 throw new fontException ("No font settings file (fonts.[mtt|mtb])"); |
115 throw new fontException ("Mergetag exception: "~e.msg); | 111 } catch (Exception e) { |
112 throw new fontException ("Reading font settings failed: "~e.msg); | |
116 } | 113 } |
117 | 114 |
118 // Find the fallback | 115 // Find the fallback |
119 FontStyle* p = fallbackName in fonts; | 116 FontStyle* p = fallbackName in fonts; |
120 if (p is null) | 117 if (p is null) |