comparison mde/font/font.d @ 137:9f035cd139c6

BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed. Content restrutured a lot: New IContent module, Content module includes more functionality. New ContentLoader module to manage content loading/saving/translation. Translation module moved to content dir and cut down to reflect current usage. File format unchanged except renames: FontOptions -> Font, VideoOptions -> Screen. Font render mode and LCD filter options are now enums. GUI loading needs to create content (and set type for enums), but doesn't save/load value. Some setup of mainSchedule moved to mde.mainLoop. Content callbacks are called on content change now. ContentLists are set up implicitly from content symbols. Not as fast but much easier! Bug-fix in the new MTTagReader. Renamed MT *Reader maker functions to avoid confusion in paths.d. New mde.setup.logger module to allow logger setup before any other module's static this().
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 07 Feb 2009 12:46:03 +0000
parents 7ababdf97748
children
comparison
equal deleted inserted replaced
136:4084f07f2c7a 137:9f035cd139c6
15 15
16 /// Sets up freetype (in a basic way). 16 /// Sets up freetype (in a basic way).
17 module mde.font.font; 17 module mde.font.font;
18 18
19 public import mde.types.Colour; 19 public import mde.types.Colour;
20 import mde.lookup.Options;
21 import mde.font.FontTexture; 20 import mde.font.FontTexture;
22 import mde.font.exception; 21 import mde.font.exception;
23 22
24 import mde.setup.exception; // InitStage stuff 23 import mde.setup.exception; // InitStage stuff
25 import mde.file.paths; 24 import mde.file.paths;
64 logger.warn ("Using an untested FreeType version: {}.{}.{}", maj, min, patch); 63 logger.warn ("Using an untested FreeType version: {}.{}.{}", maj, min, patch);
65 logger.info ("The only tested version of freetype is 2.3"); 64 logger.info ("The only tested version of freetype is 2.3");
66 } 65 }
67 66
68 // Set LCD filtering method if LCD rendering is enabled. 67 // Set LCD filtering method if LCD rendering is enabled.
69 const RMF = FT_LOAD_TARGET_LCD | FT_LOAD_TARGET_LCD_V; 68 if (fontOpts.mode() & 2 &&
70 if (fontOpts.renderMode() & RMF &&
71 FT_Library_SetLcdFilter(library, cast(FT_LcdFilter)fontOpts.lcdFilter())) { 69 FT_Library_SetLcdFilter(library, cast(FT_LcdFilter)fontOpts.lcdFilter())) {
72 /* An error occurred, presumably because LCD rendering support 70 /* An error occurred, presumably because LCD rendering support
73 * is not compiled into the library. */ 71 * is not compiled into the library. */
74 logger.warn ("Bad/unsupported LCD filter option; disabling LCD font rendering."); 72 logger.warn ("Bad/unsupported LCD filter option; disabling LCD font rendering.");
75 logger.warn ("Your FreeType 2 library may be compiled without support for LCD/sub-pixel rendering."); 73 logger.warn ("Your FreeType 2 library may be compiled without support for LCD/sub-pixel rendering.");
77 // Reset the default filter (in case an invalid value was set in config files). 75 // Reset the default filter (in case an invalid value was set in config files).
78 fontOpts.lcdFilter = FT_LcdFilter.FT_LCD_FILTER_DEFAULT; 76 fontOpts.lcdFilter = FT_LcdFilter.FT_LCD_FILTER_DEFAULT;
79 77
80 /* If no support for LCD filtering, then LCD rendering only emulates NORMAL with 3 78 /* If no support for LCD filtering, then LCD rendering only emulates NORMAL with 3
81 * times wider glyphs. So disable and save the extra work. */ 79 * times wider glyphs. So disable and save the extra work. */
82 fontOpts.renderMode = FT_LOAD_TARGET_NORMAL; 80 fontOpts.mode = 0;
83 } 81 }
84 82
85 // Load the fallback font; if it throws let exception abort program 83 // Load the fallback font; if it throws let exception abort program
86 fallback = new FontStyle (fontOpts.defaultFont(), fontOpts.defaultSize()); 84 fallback = new FontStyle (fontOpts.defaultFont(), fontOpts.defaultSize());
87 85