# HG changeset patch # User Diggory Hardy # Date 1209635704 -3600 # Node ID 6886402c15459b931415abc1fc3acc74e4c7fb2f # Parent 316b0230a8495d056b54e8767ad47837e48af9b6 Started implementing FreeType. Loads the freetype library and a font, but nothing else yet. committer: Diggory Hardy diff -r 316b0230a849 -r 6886402c1545 codeDoc/gui/GUI notes.txt --- a/codeDoc/gui/GUI notes.txt Wed Apr 30 18:05:56 2008 +0100 +++ b/codeDoc/gui/GUI notes.txt Thu May 01 10:55:04 2008 +0100 @@ -9,13 +9,12 @@ ->* create orthographic projection ->* draw boxes -> maybe more (text, textures, ...) -->* Windows with size & position +-> Windows with size & position + -> position from Gui -> Widgets: ->* minimum size but expandable, auto-set -> no ability to resize yet except from config files - ->* grid "layout" widgets -> scripted widgets - -> decent rendering/theme system -> Text rendering -> text library? diff -r 316b0230a849 -r 6886402c1545 codeDoc/jobs.txt --- a/codeDoc/jobs.txt Wed Apr 30 18:05:56 2008 +0100 +++ b/codeDoc/jobs.txt Thu May 01 10:55:04 2008 +0100 @@ -3,6 +3,7 @@ In progress: +FreeType implementing... diff -r 316b0230a849 -r 6886402c1545 mde/ft/init.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mde/ft/init.d Thu May 01 10:55:04 2008 +0100 @@ -0,0 +1,48 @@ +/* LICENSE BLOCK +Part of mde: a Modular D game-oriented Engine +Copyright © 2007-2008 Diggory Hardy + +This program is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, either +version 2 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ + +/// Sets up freetype (in a basic way). +module mde.ft.init; + +import derelict.freetype.ft; + +import tango.stdc.stringz; +import tango.util.log.Log : Log, Logger; + +private Logger logger; +static this () { + logger = Log.getLogger ("mde.ft.init"); +} + +FT_Library library; +FT_Face face; + +// FIXME: use a different exception +const PATH = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"; +void initFreeType () { + if (FT_Init_FreeType (&library)) + throw new Exception ("error initialising the FreeType library"); + + if (FT_New_Face (library, toStringz(PATH), 0, &face)) + throw new Exception ("Unable to read font: "~PATH); + + if (FT_Set_Pixel_Sizes (face, 32,32)) + throw new Exception ("Unable to set pixel size"); +} + +void cleanupFreeType () { + FT_Done_Face (face); + FT_Done_FreeType (library); +} diff -r 316b0230a849 -r 6886402c1545 mde/scheduler/init2.d --- a/mde/scheduler/init2.d Wed Apr 30 18:05:56 2008 +0100 +++ b/mde/scheduler/init2.d Thu May 01 10:55:04 2008 +0100 @@ -35,8 +35,9 @@ import global = mde.global; import mde.gui.Gui; import mde.input.Input; +import ft = mde.ft.init; -// NOTE: error reporting needs revision +// NOTE: error reporting needs a revision private Logger logger; static this () { @@ -44,9 +45,10 @@ init.addFunc (&initInput, "initInput"); init.addFunc (&guiLoad, "guiLoad"); + init.addFunc (&initFreeType, "initFreeType"); } -void guiLoad () { +void guiLoad () { // init func try { gui.load ("gui"); } catch (Exception e) { @@ -74,6 +76,15 @@ } } +void initFreeType () { // init func + try { + ft.initFreeType; + } catch (Exception e) { + logger.fatal ("initFreeType failed: " ~ e.msg); + setInitFailure; + } +} + /+ Potential wrapper function: // Template to call function, catching exceptions: void wrap(alias Func) () { diff -r 316b0230a849 -r 6886402c1545 mde/sdl.d --- a/mde/sdl.d Wed Apr 30 18:05:56 2008 +0100 +++ b/mde/sdl.d Thu May 01 10:55:04 2008 +0100 @@ -15,7 +15,7 @@ /** Just a temporary place to put SDL Init and Video stuff. */ -module mde.SDL; +module mde.sdl; import mde.scheduler.initFunctions; import mde.input.joystick;