Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

TTFont.cpp

Go to the documentation of this file.
00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 #include <SDL.h> 00024 #include "guitypedefs.h" 00025 #ifdef _WIN32 00026 #pragma warning(push) 00027 00028 #include <yvals.h> // warning numbers get enabled in yvals.h 00029 00030 #pragma warning(disable: 4251) 00031 #pragma warning(disable: 4786) // identifier was truncated to 'number' characters in the debug information 00032 00033 // BUG: C4786 Warning Is Not Disabled with #pragma Warning 00034 // STATUS: Microsoft has confirmed this to be a bug in the Microsoft product. This warning can be ignored. 00035 // This occured only in the <map> container. 00036 00037 #include <sge.h> 00038 00039 #pragma warning(pop) 00040 #else 00041 #include <sge.h> 00042 #endif 00043 00044 #include "TTFont.h" 00045 00046 00047 namespace gui 00048 { 00049 00050 bool TTFont::m_init = false; 00051 00052 TTFont::TTFont(const string &filename,int size) : m_font(NULL) 00053 ,m_h(size) 00054 { 00055 /* Init TTF */ 00056 if (!m_init) 00057 { 00058 m_init = true; 00059 if (sge_TTF_Init()!=0) 00060 { 00061 fprintf(stderr,"TT error: %s\n", SDL_GetError()); 00062 // exit(1); 00063 } 00064 } 00065 00066 m_font = sge_TTF_OpenFont( (char *)filename.c_str(), size); 00067 if (m_font == NULL) 00068 { 00069 fprintf(stderr,"TT error: %s\n", SDL_GetError()); 00070 // exit(1); 00071 } 00072 00073 //sge_TTF_SetFontStyle(m_font, SGE_TTF_ITALIC); 00074 } 00075 00076 00077 TTFont::~TTFont() 00078 { 00079 /* Clean up */ 00080 if (m_font) 00081 { 00082 sge_TTF_CloseFont(m_font); 00083 } 00084 } 00085 00086 00087 sge_TTFont *TTFont::GetFont() 00088 { 00089 return m_font; 00090 } 00091 00092 00093 int TTFont::GetH() 00094 { 00095 return m_h; 00096 } 00097 00098 00099 void TTFont::SetH(int h) 00100 { 00101 m_h = h; 00102 sge_TTF_SetFontSize(m_font, h); 00103 } 00104 00105 00106 void TTFont::GetRect(const string &str, SDL_Rect &rect) 00107 { 00108 rect = sge_TTF_TextSize(m_font, (char *)str.c_str() ); 00109 } 00110 00111 00112 } // namespace

Generated for My SDL C++ Gui by doxygen 1.3.6

www.TV-friendship.com
The matchmaking service with an all new twist.

Quantum 'Teleportation'
Some thoughts
Page, code, and content Copyright (C) 2004 by Anders Hedström