Skip to content

Commit

Permalink
Added "leading" to the font renderer attribute stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jun 12, 2011
1 parent f975ae6 commit 4fad551
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
21 changes: 12 additions & 9 deletions doomsday/engine/api/dd_bitmapfont.h
Expand Up @@ -67,6 +67,9 @@ void FR_ResetTypeInTimer(void);

#define FR_MAX_ATTRIB_STACK_DEPTH (4)

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

/// Change the current font.
void FR_SetFont(fontid_t font);

Expand All @@ -79,20 +82,20 @@ void FR_PopAttrib(void);
/// Load the default attributes at the current stack depth.
void FR_LoadDefaultAttrib(void);

void FR_SetTracking(int tracking);

void FR_SetShadowOffset(int offsetX, int offsetY);

void FR_SetShadowStrength(float value);

void FR_SetGlitterStrength(float value);
/// Current leading.
float FR_Leading(void);

/// @return Unique identifier associated with the current font.
fontid_t FR_GetCurrentId(void);
void FR_SetLeading(float value);

/// Current tracking.
int FR_Tracking(void);

void FR_SetTracking(int value);

void FR_SetShadowOffset(int offsetX, int offsetY);
void FR_SetShadowStrength(float value);
void FR_SetGlitterStrength(float value);

/**
* Text: A block of possibly formatted and/or multi-line text.
*/
Expand Down
17 changes: 10 additions & 7 deletions doomsday/engine/api/doomsday.def
@@ -1,7 +1,7 @@
; Doomsday Engine API (Routines exported from Doomsday.exe).
;
; Highest ordinal is currently: --> 515 <--
; Other free ordinals: 121 200
; Other free ordinals: none

NAME "DOOMSDAY"
EXPORTS
Expand Down Expand Up @@ -501,12 +501,15 @@ EXPORTS
FR_PopAttrib @514 NONAME
FR_LoadDefaultAttrib @515 NONAME

FR_Tracking @122 NONAME
FR_SetTracking @123 NONAME
FR_SetShadowOffset @124 NONAME
FR_SetShadowStrength @125 NONAME
FR_SetGlitterStrength @131 NONAME
FR_ResetTypeInTimer @198 NONAME
FR_Leading @121 NONAME
FR_SetLeading @122 NONAME
FR_Tracking @123 NONAME
FR_SetTracking @124 NONAME
FR_SetShadowOffset @125 NONAME
FR_SetShadowStrength @131 NONAME
FR_SetGlitterStrength @198 NONAME

FR_ResetTypeInTimer @200 NONAME

FR_TextDimensions @112 NONAME
FR_TextWidth @113 NONAME
Expand Down
27 changes: 24 additions & 3 deletions doomsday/engine/portable/src/gl_font.c
Expand Up @@ -45,6 +45,7 @@

typedef struct fr_state_attributes_s {
int tracking;
float leading;
int shadowOffsetX, shadowOffsetY;
float shadowStrength;
float glitterStrength;
Expand Down Expand Up @@ -425,6 +426,7 @@ void FR_LoadDefaultAttrib(void)
fr_state_attributes_t* sat = currentAttributes();
if(!inited)
Con_Error("FR_LoadDefaultAttrib: Font renderer has not yet been initialized.");
sat->leading = DEFAULT_LEADING;
sat->tracking = DEFAULT_TRACKING;
sat->shadowStrength = DEFAULT_SHADOW_STRENGTH;
sat->shadowOffsetX = DEFAULT_SHADOW_XOFFSET;
Expand Down Expand Up @@ -457,6 +459,22 @@ void FR_PopAttrib(void)
--fr.attribStackDepth;
}

float FR_Leading(void)
{
fr_state_attributes_t* sat = currentAttributes();
if(!inited)
Con_Error("FR_Leading: Font renderer has not yet been initialized.");
return sat->leading;
}

void FR_SetLeading(float value)
{
fr_state_attributes_t* sat = currentAttributes();
if(!inited)
Con_Error("FR_SetLeading: Font renderer has not yet been initialized.");
sat->leading = value;
}

int FR_Tracking(void)
{
fr_state_attributes_t* sat = currentAttributes();
Expand All @@ -465,12 +483,12 @@ int FR_Tracking(void)
return sat->tracking;
}

void FR_SetTracking(int tracking)
void FR_SetTracking(int value)
{
fr_state_attributes_t* sat = currentAttributes();
if(!inited)
Con_Error("FR_SetTracking: Font renderer has not yet been initialized.");
sat->tracking = tracking;
sat->tracking = value;
}

void FR_SetShadowOffset(int offsetX, int offsetY)
Expand Down Expand Up @@ -1245,6 +1263,7 @@ void FR_DrawText(const char* inString, int x, int y, fontid_t defFont, int align
FR_PushAttrib();
FR_LoadDefaultAttrib();
FR_SetTracking(state.tracking);
FR_SetLeading(state.leading);
FR_SetShadowOffset(state.shadowOffsetX, state.shadowOffsetY);
FR_SetShadowStrength(state.shadowStrength);
FR_SetGlitterStrength(state.glitterStrength);
Expand Down Expand Up @@ -1278,6 +1297,8 @@ void FR_DrawText(const char* inString, int x, int y, fontid_t defFont, int align
FR_SetFont(state.font);
if(state.tracking != lastTracking)
FR_SetTracking(state.tracking);
if(state.leading != lastLeading)
FR_SetLeading(state.leading);
if(state.shadowStrength != lastShadowStrength)
FR_SetShadowStrength(state.shadowStrength);
if(state.glitterStrength != lastGlitterStrength)
Expand Down Expand Up @@ -1374,7 +1395,7 @@ void FR_DrawText(const char* inString, int x, int y, fontid_t defFont, int align
lastLineHeight = FR_TextFragmentHeight(temp);

cx = (float) x;
cy += (float) lastLineHeight * (1+state.leading);
cy += (float) lastLineHeight * (1+FR_Leading());
}

glMatrixMode(GL_MODELVIEW);
Expand Down

0 comments on commit 4fad551

Please sign in to comment.