Changeset 230
- Timestamp:
- 07/02/11 23:22:28 (1 year ago)
- Files:
-
- trunk/src/yage/gui/style.d (modified) (2 diffs)
- trunk/src/yage/gui/surface.d (modified) (1 diff)
- trunk/src/yage/gui/textblock.d (modified) (2 diffs)
- trunk/src/yage/resource/manager.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/yage/gui/style.d
r205 r230 270 270 271 271 /// Font properties 272 Font fontFamily; // TODO: Convert to string so FreeType doesn't have to be loaded in order to make Surfaces.272 char[] fontFamily; 273 273 CSSValue fontSize; /// ditto 274 274 FontStyle fontStyle; /// ditto 275 275 FontWeight fontWeight; /// ditto 276 277 private char[] lastFontFamily; 278 private Font internalFont; 279 280 Font getFont() 281 { if (!internalFont || lastFontFamily != fontFamily) 282 { lastFontFamily = fontFamily; 283 internalFont = ResourceManager.font(fontFamily); 284 } 285 return internalFont; 286 } 276 287 277 288 /// Text properties … … 350 361 fontSize = token; 351 362 } else if (i>0) 352 fontFamily = ResourceManager.font(removeUrl(token));363 fontFamily = removeUrl(token); 353 364 } 354 365 break; 355 366 case "font-size": fontSize = tokens[0]; break; 356 case "font-family": fontFamily = ResourceManager.font(removeUrl(tokens[0])); break;367 case "font-family": fontFamily = removeUrl(tokens[0]); break; 357 368 case "font-style": fontStyle = Style.stringToEnum!(FontStyle)(tokens[0]); break; 358 369 case "font-weight": fontWeight = Style.stringToEnum!(FontWeight)(tokens[0]); break; trunk/src/yage/gui/surface.d
r211 r230 825 825 static Style getDefaultStyle() 826 826 { if (!defaultStyle.fontFamily) // Create on first request 827 { defaultStyle.fontFamily = ResourceManager. getDefaultFont(); // TODO: This prevents surfaces from being constructed before freetype!.827 { defaultStyle.fontFamily = ResourceManager.DEFAULT_FONT; 828 828 defaultStyle.fontSize = 12; 829 829 defaultStyle.fontStyle = Style.FontStyle.NORMAL; trunk/src/yage/gui/textblock.d
r216 r230 606 606 { 607 607 InlineStyle result; 608 result.fontFamily = style. fontFamily ? style.fontFamily : ResourceManager.getDefaultFont();608 result.fontFamily = style.getFont(); 609 609 610 610 float fontSizePx = style.fontSize.toPx(0); // incorrect, should inherit from parent font size … … 627 627 Style toStyle() 628 628 { Style result; 629 result.fontFamily = fontFamily ;629 result.fontFamily = fontFamily.toString(); 630 630 result.fontSize = fontSize; 631 631 result.color = color; trunk/src/yage/resource/manager.d
r203 r230 58 58 } 59 59 } 60 61 static const DEFAULT_FONT = "__DEFAULT_FONT__"; // Used to specify the default font that's embedded as a resource in the yage executable. 60 62 61 63 private static char[][] paths = [""]; // paths to look for resources … … 161 163 * If it has already been loaded, the in-memory copy will be returned. 162 164 * If not, it will be loaded and then returned. 163 * Params: filename = The Font file that will be loaded .*/165 * Params: filename = The Font file that will be loaded, or Resource.DEFAULT_FONT */ 164 166 static Font font(char[] filename) 165 167 { 168 if (filename==DEFAULT_FONT) 169 return getDefaultFont(); 170 166 171 filename = resolvePath(filename); 167 172 if (filename in fonts)
