Skip to content

Commit

Permalink
Added quiet argument to Fonts_FontForUri
Browse files Browse the repository at this point in the history
Allow the called to specify when warnings produced by this set of
functions should be logged.
  • Loading branch information
danij-deng committed Oct 29, 2011
1 parent 89923eb commit 68d2654
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/fonts.h
Expand Up @@ -95,6 +95,7 @@ font_t* Fonts_ToFont(fontnum_t num);
fontnum_t Fonts_ToFontNum(font_t* font);

/// @return Font associated with @a uri else @c NULL.
font_t* Fonts_FontForUri2(const Uri* uri, boolean quiet);
font_t* Fonts_FontForUri(const Uri* uri);

/**
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/def_main.c
Expand Up @@ -1030,7 +1030,7 @@ void Def_Read(void)
for(i = 0; i < defs.count.compositeFonts.num; ++i)
{
ded_compositefont_t* def = defs.compositeFonts + i;
font_t* font = Fonts_FontForUri(def->id);
font_t* font = Fonts_FontForUri2(def->id, true/*quiet please*/);
if(!font)
{ // A new Font.
Fonts_CreateBitmapCompositeFromDef(def);
Expand Down
20 changes: 15 additions & 5 deletions doomsday/engine/portable/src/fonts.c
Expand Up @@ -253,8 +253,7 @@ static font_t* findFontForUri(const Uri* uri)
return font;
}

/// \note Part of the Doomsday public API.
font_t* Fonts_FontForUri(const Uri* uri)
font_t* Fonts_FontForUri2(const Uri* uri, boolean quiet)
{
font_t* font;
if(!inited || !uri) return NULL;
Expand All @@ -273,7 +272,7 @@ font_t* Fonts_FontForUri(const Uri* uri)
if(font) return font;

// Not found.
if(verbose)
if(!quiet)
{
ddstring_t* path = Uri_ToString(uri);
Con_Message("Fonts::FontForUri: \"%s\" not found!\n", Str_Text(path));
Expand All @@ -283,18 +282,29 @@ font_t* Fonts_FontForUri(const Uri* uri)
}

/// \note Part of the Doomsday public API.
font_t* Fonts_FontForUriCString(const char* path)
font_t* Fonts_FontForUri(const Uri* uri)
{
return Fonts_FontForUri2(uri, (verbose >= 1)/*log warnings if verbose*/);
}

font_t* Fonts_FontForUriCString2(const char* path, boolean quiet)
{
if(path && path[0])
{
Uri* uri = Uri_NewWithPath2(path, RC_NULL);
font_t* font = Fonts_FontForUri(uri);
font_t* font = Fonts_FontForUri2(uri, quiet);
Uri_Delete(uri);
return font;
}
return NULL;
}

/// \note Part of the Doomsday public API.
font_t* Fonts_FontForUriCString(const char* path)
{
return Fonts_FontForUriCString2(path, (verbose >= 1)/*log warnings if verbose*/);
}

/// \note Part of the Doomsday public API.
fontnum_t Fonts_IndexForUri(const Uri* uri)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/rend_font.c
Expand Up @@ -1066,7 +1066,7 @@ static void parseParamaterBlock(char** strPtr, drawtextstate_t* state, int* numB
Uri* uri;
(*strPtr) += 4;
uri = Uri_NewWithPath2(*strPtr, RC_NULL);
font = Fonts_FontForUri(uri);
font = Fonts_FontForUri2(uri, true/*quiet please*/);
Uri_Delete(uri);
if(font)
{
Expand Down

0 comments on commit 68d2654

Please sign in to comment.