wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src font.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src font.cpp
Date: Sat, 18 Sep 2004 17:31:01 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/09/18 21:24:59

Modified files:
        src            : font.cpp 

Log message:
        Switched font rendering to the new logging system

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.cpp.diff?tr1=1.85&tr2=1.86&r1=text&r2=text

Patches:
Index: wesnoth/src/font.cpp
diff -u wesnoth/src/font.cpp:1.85 wesnoth/src/font.cpp:1.86
--- wesnoth/src/font.cpp:1.85   Fri Sep 10 17:41:32 2004
+++ wesnoth/src/font.cpp        Sat Sep 18 21:24:59 2004
@@ -1,4 +1,4 @@
-/* $Id: font.cpp,v 1.85 2004/09/10 17:41:32 silene Exp $ */
+/* $Id: font.cpp,v 1.86 2004/09/18 21:24:59 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -30,6 +30,10 @@
 #include <stack>
 #include <string>
 
+#define LOG_FT lg::info(lg::display)
+#define WRN_FT lg::warn(lg::display)
+#define ERR_FT lg::err(lg::display)
+
 namespace {
 
 std::map<int,TTF_Font*> font_table;
@@ -41,37 +45,38 @@
 {
        std::string name;
 
+       LOG_FT << "Opening font '" << fname << "' ...\n";
        if(game_config::path.empty() == false) {
                name = game_config::path + "/fonts/" + fname;
-               std::cerr << "Opening font file: " << name << " ...\n";
+               LOG_FT << "Trying file '" << name << "' ...\n";
 
                if(read_file(name).empty()) {
                        name = "fonts/" + fname;
-                       std::cerr << "Failed, now trying: " << name << " ...\n";
+                       WRN_FT << "Failed opening '" << name << "'; now trying 
'" << name << "' ...\n";
                        if(read_file(name).empty()) {
-                               std::cerr << "Failed :(\n";
+                               ERR_FT << "Failed opening font: " << fname << 
"\n";
                                return NULL;
                        }
                }
        } else {
                name = "fonts/" + fname;
-               std::cerr << "Opening font file: " << name << " ...\n";
+               LOG_FT << "Trying file '" << name << "' ...\n";
 
                if(read_file(name).empty()) {
-                       std::cerr << "Failed :(\n";
+                       ERR_FT << "Failed opening font '" << fname << "'\n";
                        return NULL;
                }
        }
 
-       std::cerr << "opening font '" << name << "' " << size << "\n";
+       LOG_FT << "Opening font file '" << name << "', font size is " << size 
<< "\n";
 
        TTF_Font* font = TTF_OpenFont(name.c_str(),size);
        if(font == NULL) {
-               std::cerr << "Could not open font file: " << name << '\n';
+               ERR_FT << "Failed opening font file '" << name << "'\n";
                return NULL;
        }
 
-       std::cerr << "opened font okay\n";
+       LOG_FT << "Opened font okay\n";
 
        return font;
 }
@@ -89,7 +94,7 @@
 
        TTF_SetFontStyle(font,TTF_STYLE_NORMAL);
 
-       std::cerr << "Inserting font...\n";
+       LOG_FT << "Inserting font...\n";
        font_table.insert(std::pair<int,TTF_Font*>(size,font));
        return font;
 }
@@ -145,10 +150,10 @@
 {
        const int res = TTF_Init();
        if(res == -1) {
-               std::cerr << "Could not initialize true type fonts\n";
+               ERR_FT << "Could not initialize true type fonts\n";
                throw error();
        } else {
-               std::cerr << "Initialized true type fonts\n";
+               LOG_FT << "Initialized true type fonts\n";
        }
 }
 
@@ -300,8 +305,7 @@
                cache_.push_front(t);
        }
        if (++lookup_ % 1000 == 0) {
-               std::cerr << "Text cache: " << lookup_ << " lookups, "
-                 "hit percentage: " << (hit_ / 10) << "%" << std::endl;
+               LOG_FT << "Text cache: " << lookup_ << " lookups, " << (hit_ / 
10) << "% hits\n";
                hit_ = 0;
        }
        return cache_.front();
@@ -414,7 +418,7 @@
 {
        TTF_Font* const font = get_font(size);
        if(font == NULL) {
-               std::cerr << "Could not get font\n";
+               ERR_FT << "Could not get font for size " << size << "\n";
                return NULL;
        }
 
@@ -429,7 +433,7 @@
        
        TTF_Font* const font = get_font(size);
        if(font == NULL) {
-               std::cerr << "Could not get font\n";
+               ERR_FT << "Could not get font for size " << size << "\n";
                SDL_Rect res = {0,0,0,0};
                return res;
        }
@@ -594,7 +598,7 @@
     
                TTF_Font* const font = get_font(font_size);
                if(font == NULL) {
-                       std::cerr << "Could not get font\n";
+                       ERR_FT << "Could not get font for size " << font_size 
<< "\n";
                        return 0;
                }
                int w = 0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]