Skip to content

Commit

Permalink
Refactor: Split font management out of gl_font.c/.h and into fonts.c/…
Browse files Browse the repository at this point in the history
….h Refactor: Renamed gl_font.c/.h to rend_font.c/.h Refactor: Fonts are owned by the "Fonts Collection" rather than the font renderer.
  • Loading branch information
danij-deng committed Jun 30, 2011
1 parent 846ff09 commit 7d38bd8
Show file tree
Hide file tree
Showing 29 changed files with 598 additions and 456 deletions.
8 changes: 4 additions & 4 deletions doomsday/build/codeblocks/doomsday.cbp
Expand Up @@ -245,10 +245,10 @@
<Unit filename="..\..\engine\portable\include\fi_main.h" />
<Unit filename="..\..\engine\portable\include\filedirectory.h" />
<Unit filename="..\..\engine\portable\include\finaleinterpreter.h" />
<Unit filename="..\..\engine\portable\include\fonts.h" />
<Unit filename="..\..\engine\portable\include\gameinfo.h" />
<Unit filename="..\..\engine\portable\include\gl_defer.h" />
<Unit filename="..\..\engine\portable\include\gl_draw.h" />
<Unit filename="..\..\engine\portable\include\gl_font.h" />
<Unit filename="..\..\engine\portable\include\gl_hq2x.h" />
<Unit filename="..\..\engine\portable\include\gl_main.h" />
<Unit filename="..\..\engine\portable\include\gl_model.h" />
Expand Down Expand Up @@ -323,6 +323,7 @@
<Unit filename="..\..\engine\portable\include\rend_decor.h" />
<Unit filename="..\..\engine\portable\include\rend_dyn.h" />
<Unit filename="..\..\engine\portable\include\rend_fakeradio.h" />
<Unit filename="..\..\engine\portable\include\rend_font.h" />
<Unit filename="..\..\engine\portable\include\rend_halo.h" />
<Unit filename="..\..\engine\portable\include\rend_list.h" />
<Unit filename="..\..\engine\portable\include\rend_main.h" />
Expand Down Expand Up @@ -519,13 +520,11 @@
<Unit filename="..\..\engine\portable\src\fi_main.c" />
<Unit filename="..\..\engine\portable\src\filedirectory.c" />
<Unit filename="..\..\engine\portable\src\finaleinterpreter.c" />
<Unit filename="..\..\engine\portable\src\fonts.c" />
<Unit filename="..\..\engine\portable\src\gameinfo.c" />
<Unit filename="..\..\engine\portable\src\gl_defer.c" />
<Unit filename="..\..\engine\portable\src\gl_draw.c" />
<Unit filename="..\..\engine\portable\src\gl_drawvectorgraphic.c" />
<Unit filename="..\..\engine\portable\src\gl_font.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\engine\portable\src\gl_hq2x.c">
<Option compilerVar="CC" />
</Unit>
Expand Down Expand Up @@ -734,6 +733,7 @@
<Unit filename="..\..\engine\portable\src\rend_fakeradio.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\engine\portable\src\rend_font.c" />
<Unit filename="..\..\engine\portable\src\rend_halo.c">
<Option compilerVar="CC" />
</Unit>
Expand Down
3 changes: 2 additions & 1 deletion doomsday/build/win32/doomsday_cl.rsp
Expand Up @@ -33,6 +33,7 @@
.\..\..\engine\portable\src\fi_main.c
.\..\..\engine\portable\src\filedirectory.c
.\..\..\engine\portable\src\finaleinterpreter.c
.\..\..\engine\portable\src\fonts.c
.\..\..\engine\portable\src\gameinfo.c
.\..\..\engine\portable\src\gl_defer.c
.\..\..\engine\portable\src\gl_texmanager.c
Expand All @@ -42,7 +43,6 @@
.\..\..\engine\portable\src\gl_pcx.c
.\..\..\engine\portable\src\gl_main.c
.\..\..\engine\portable\src\gl_hq2x.c
.\..\..\engine\portable\src\gl_font.c
.\..\..\engine\portable\src\gl_draw.c
.\..\..\engine\portable\src\gl_drawvectorgraphic.c
.\..\..\engine\portable\src\texture.c
Expand All @@ -62,6 +62,7 @@
.\..\..\engine\portable\src\rend_list.c
.\..\..\engine\portable\src\rend_halo.c
.\..\..\engine\portable\src\rend_fakeradio.c
.\..\..\engine\portable\src\rend_font.c
.\..\..\engine\portable\src\rend_dyn.c
.\..\..\engine\portable\src\rend_decor.c
.\..\..\engine\portable\src\rend_clip.c
Expand Down
24 changes: 16 additions & 8 deletions doomsday/build/win32/vs8/doomsday.vcproj
Expand Up @@ -1092,6 +1092,10 @@
RelativePath="..\..\..\engine\portable\src\finaleinterpreter.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\fonts.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\gameinfo.c"
>
Expand All @@ -1108,10 +1112,6 @@
RelativePath="..\..\..\engine\portable\src\gl_drawvectorgraphic.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\gl_font.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\gl_hq2x.c"
>
Expand Down Expand Up @@ -1404,6 +1404,10 @@
RelativePath="..\..\..\engine\portable\src\rend_fakeradio.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\rend_font.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\rend_halo.c"
>
Expand Down Expand Up @@ -2786,19 +2790,19 @@
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\gameinfo.h"
RelativePath="..\..\..\engine\portable\include\fonts.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\gl_defer.h"
RelativePath="..\..\..\engine\portable\include\gameinfo.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\gl_draw.h"
RelativePath="..\..\..\engine\portable\include\gl_defer.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\gl_font.h"
RelativePath="..\..\..\engine\portable\include\gl_draw.h"
>
</File>
<File
Expand Down Expand Up @@ -3097,6 +3101,10 @@
RelativePath="..\..\..\engine\portable\include\rend_fakeradio.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\rend_font.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\rend_halo.h"
>
Expand Down
14 changes: 0 additions & 14 deletions doomsday/engine/api/dd_fontrenderer.h
Expand Up @@ -29,12 +29,6 @@
#ifndef LIBDENG_API_FONT_RENDERER_H
#define LIBDENG_API_FONT_RENDERER_H

/**
* Unique identifier allocated by this subsystem and associated to each
* known font. Used as a logical public reference/handle to a font.
*/
typedef uint32_t fontid_t;

/**
* Font attributes are managed as a finite stack of attribute sets.
* This value defines the maximum allowed depth of the attribute stack.
Expand Down Expand Up @@ -68,14 +62,6 @@ typedef uint32_t fontid_t;
#define DTF_ONLY_SHADOW (DTF_NO_TYPEIN|DTF_NO_GLITTER)
/*@}*/

/**
* Find the associated font for @a name.
*
* @param name Name of the font to lookup.
* @return Unique id of the found font.
*/
fontid_t FR_FindFontForName(const char* name);

/// @return Unique identifier associated with the current font.
fontid_t FR_Font(void);

Expand Down
6 changes: 6 additions & 0 deletions doomsday/engine/api/dd_types.h
Expand Up @@ -122,6 +122,12 @@ typedef unsigned short nodeindex_t;
typedef unsigned short thid_t;
typedef double timespan_t;

/**
* Unique identifier allocated by this subsystem and associated to each
* known font. Used as a logical public reference/handle to a font.
*/
typedef uint32_t fontid_t;

#define LUMPNAME_T_MAXLEN 9
#define LUMPNAME_T_LASTINDEX 8
typedef signed char lumpname_t[LUMPNAME_T_MAXLEN];
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/api/doomsday.def
Expand Up @@ -492,7 +492,7 @@ EXPORTS
GL_EndBorderedProjection @510 NONAME

; Graphics: Text
FR_FindFontForName @97 NONAME
Fonts_IdForName @97 NONAME

FR_Font @106 NONAME
FR_SetFont @107 NONAME
Expand Down
8 changes: 8 additions & 0 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -444,6 +444,14 @@ void Con_SetString(const char* name, const char* text);

boolean DD_IterateThinkers(think_t type, boolean (*func) (thinker_t *th, void*), void* data);

//------------------------------------------------------------------------
//
// UI.
//
//------------------------------------------------------------------------

fontid_t Fonts_IdForName(const char* name);

//------------------------------------------------------------------------
//
// Refresh.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/bitmapfont.h
Expand Up @@ -108,7 +108,7 @@ patchid_t BitmapFont_CharPatch(bitmapfont_t* font, unsigned char ch);
void BitmapFont_CharSetPatch(bitmapfont_t* font, unsigned char ch, const char* patchName);

/// @return GL-texture name.
DGLuint BitmapFont_GLTextureName(bitmapfont_t* font);
DGLuint BitmapFont_GLTextureName(const bitmapfont_t* font);

int BitmapFont_TextureHeight(const bitmapfont_t* font);
int BitmapFont_TextureWidth(const bitmapfont_t* font);
Expand Down
13 changes: 6 additions & 7 deletions doomsday/engine/portable/include/de_graphics.h
@@ -1,10 +1,10 @@
/**\file
/**\file de_graphics.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006-2011 Daniel Swanson <danij@dengine.net>
*
* 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
Expand All @@ -23,22 +23,21 @@
*/

/**
* de_graphics.h: Graphics Subsystem
* Graphics Subsystem
*/

#ifndef __DOOMSDAY_GRAPHICS__
#define __DOOMSDAY_GRAPHICS__
#ifndef LIBDENG_GRAPHICS
#define LIBDENG_GRAPHICS

#include "gl_main.h"
#include "gl_draw.h"
#include "gl_texmanager.h"
#include "gl_tex.h"
#include "gl_hq2x.h"
#include "gl_font.h"
#include "gl_model.h"
#include "gl_pcx.h"
#include "gl_png.h"
#include "gl_tga.h"
#include "gl_defer.h"

#endif
#endif /* LIBDENG_GRAPHICS */
13 changes: 7 additions & 6 deletions doomsday/engine/portable/include/de_render.h
@@ -1,10 +1,10 @@
/**\file
/**\file de_render.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2009 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2009 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006-2011 Daniel Swanson <danij@dengine.net>
*
* 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
Expand All @@ -23,11 +23,11 @@
*/

/**
* de_render.h: Rendering Subsystem
* Rendering Subsystem
*/

#ifndef __DOOMSDAY_RENDERER__
#define __DOOMSDAY_RENDERER__
#ifndef LIBDENG_RENDERER
#define LIBDENG_RENDERER

#include "rend_main.h"
#include "rend_clip.h"
Expand All @@ -40,8 +40,9 @@
#include "rend_model.h"
#include "rend_shadow.h"
#include "rend_fakeradio.h"
#include "rend_font.h"
#include "rend_bias.h"
#include "rend_decor.h"
#include "rend_console.h"

#endif
#endif /* LIBDENG_RENDERER */
9 changes: 5 additions & 4 deletions doomsday/engine/portable/include/de_ui.h
@@ -1,10 +1,10 @@
/**\file
/**\file de_ui.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2011 Daniel Swanson <danij@dengine.net>
*
* 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
Expand All @@ -23,12 +23,13 @@
*/

/**
* User Interface Subsystem.
* User Interface Subsystem
*/

#ifndef LIBDENG_USER_INTERFACE_H
#define LIBDENG_USER_INTERFACE_H

#include "fonts.h"
#include "ui_main.h"
#include "ui_mpi.h"
#include "ui_panel.h"
Expand Down
72 changes: 72 additions & 0 deletions doomsday/engine/portable/include/fonts.h
@@ -0,0 +1,72 @@
/**\file fonts.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2011 Daniel Swanson <danij@dengine.net>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#ifndef LIBDENG_FONTS_H
#define LIBDENG_FONTS_H

#include "bitmapfont.h"

struct ded_compositefont_s;

/// Register the console commands, variables, etc..., of this module.
void Fonts_Register(void);

/**
* Initialize the font renderer.
* @return @c 0 iff there are no errors.
*/
int Fonts_Init(void);
void Fonts_Shutdown(void);

/**
* Mark all fonts as requiring a full update. Called during engine/renderer reset.
*/
void Fonts_Update(void);

/**
* Load the specified font as a "system font".
*/
fontid_t Fonts_LoadSystemFont(const char* name, const char* path);

fontid_t Fonts_CreateFromDef(struct ded_compositefont_s* def);

int Fonts_ToIndex(fontid_t id);

/// @return Ptr to the font associated with the specified id.
bitmapfont_t* Fonts_FontForId(fontid_t id);
bitmapfont_t* Fonts_FontForIndex(int index);

/**
* Find the associated font for @a name.
*
* @param name Name of the font to lookup.
* @return Unique id of the found font.
*/
fontid_t Fonts_IdForName(const char* name);

void Fonts_DestroyFont(fontid_t id);

ddstring_t** Fonts_CollectNames(int* count);

#endif /* LIBDENG_FONTS_H */

0 comments on commit 7d38bd8

Please sign in to comment.