SDL_render_Chinese
Windows only. Linux needn't.
//
UVi Soft ( 2008 )
// Long Fei ( lf426 ), E-mail: [email protected]
// Laboratory of ZaiBieLiunNian
// http://www.cppblog.com/lf426/
// FileName: SDL_render_Chinese.h
//For Windows only
#ifndef RENDER_CHINESE_H
#define RENDER_CHINESE_H
#include " gb2312_to_Unicode.h "
#include " SDL/SDL_ttf.h "
SDL_Surface * myTTF_RenderString_Blended(TTF_Font * font, const std:: string & str, SDL_Color fg);
SDL_Surface * myTTF_RenderString_Solid(TTF_Font * font, const std:: string & str, SDL_Color fg);
SDL_Surface * myTTF_RenderString_Shaded(TTF_Font * font, const std:: string & str, SDL_Color fg, SDL_Color bg);
#endif
// Long Fei ( lf426 ), E-mail: [email protected]
// Laboratory of ZaiBieLiunNian
// http://www.cppblog.com/lf426/
// FileName: SDL_render_Chinese.h
//For Windows only
#ifndef RENDER_CHINESE_H
#define RENDER_CHINESE_H
#include " gb2312_to_Unicode.h "
#include " SDL/SDL_ttf.h "
SDL_Surface * myTTF_RenderString_Blended(TTF_Font * font, const std:: string & str, SDL_Color fg);
SDL_Surface * myTTF_RenderString_Solid(TTF_Font * font, const std:: string & str, SDL_Color fg);
SDL_Surface * myTTF_RenderString_Shaded(TTF_Font * font, const std:: string & str, SDL_Color fg, SDL_Color bg);
#endif
//
UVi Soft ( 2008 )
// Long Fei ( lf426 ), E-mail: [email protected]
// Laboratory of ZaiBieLiunNian
// http://www.cppblog.com/lf426/
//FileName: SDL_render_Chinese.cpp
//For Windows only
#include " SDL_render_Chinese.h "
SDL_Surface * myTTF_RenderString_Blended(TTF_Font * font, const std:: string & str, SDL_Color fg)
{
SDL_Surface * textbuf;
// Get Unicode
std::vector < Uint16 > unicodeUnit;
if ( getUnicode(str, unicodeUnit) == false )
return 0 ;
int arraySize = unicodeUnit.size();
Uint16 * perOne = new Uint16[arraySize + 1 ];
for ( int i = 0 ; i < arraySize; i ++ )
perOne[i] = unicodeUnit[i];
perOne[arraySize] = 0 ;
// Render the new text
textbuf = TTF_RenderUNICODE_Blended(font, perOne, fg);
// Free the text buffer and return
delete [] perOne;
return textbuf;
}
SDL_Surface * myTTF_RenderString_Solid(TTF_Font * font, const std:: string & str, SDL_Color fg)
{
SDL_Surface * textbuf;
// Get Unicode
std::vector < Uint16 > unicodeUnit;
if ( getUnicode(str, unicodeUnit) == false )
return 0 ;
int arraySize = unicodeUnit.size();
Uint16 * perOne = new Uint16[arraySize + 1 ];
for ( int i = 0 ; i < arraySize; i ++ )
perOne[i] = unicodeUnit[i];
perOne[arraySize] = 0 ;
// Render the new text
textbuf = TTF_RenderUNICODE_Solid(font, perOne, fg);
// Free the text buffer and return
delete [] perOne;
return textbuf;
}
SDL_Surface * myTTF_RenderString_Shaded(TTF_Font * font, const std:: string & str, SDL_Color fg, SDL_Color bg)
{
SDL_Surface * textbuf;
// Get Unicode
std::vector < Uint16 > unicodeUnit;
if ( getUnicode(str, unicodeUnit) == false )
return 0 ;
int arraySize = unicodeUnit.size();
Uint16 * perOne = new Uint16[arraySize + 1 ];
for ( int i = 0 ; i < arraySize; i ++ )
perOne[i] = unicodeUnit[i];
perOne[arraySize] = 0 ;
// Render the new text
textbuf = TTF_RenderUNICODE_Shaded(font, perOne, fg, bg);
// Free the text buffer and return
delete [] perOne;
return textbuf;
}
// Long Fei ( lf426 ), E-mail: [email protected]
// Laboratory of ZaiBieLiunNian
// http://www.cppblog.com/lf426/
//FileName: SDL_render_Chinese.cpp
//For Windows only
#include " SDL_render_Chinese.h "
SDL_Surface * myTTF_RenderString_Blended(TTF_Font * font, const std:: string & str, SDL_Color fg)
{
SDL_Surface * textbuf;
// Get Unicode
std::vector < Uint16 > unicodeUnit;
if ( getUnicode(str, unicodeUnit) == false )
return 0 ;
int arraySize = unicodeUnit.size();
Uint16 * perOne = new Uint16[arraySize + 1 ];
for ( int i = 0 ; i < arraySize; i ++ )
perOne[i] = unicodeUnit[i];
perOne[arraySize] = 0 ;
// Render the new text
textbuf = TTF_RenderUNICODE_Blended(font, perOne, fg);
// Free the text buffer and return
delete [] perOne;
return textbuf;
}
SDL_Surface * myTTF_RenderString_Solid(TTF_Font * font, const std:: string & str, SDL_Color fg)
{
SDL_Surface * textbuf;
// Get Unicode
std::vector < Uint16 > unicodeUnit;
if ( getUnicode(str, unicodeUnit) == false )
return 0 ;
int arraySize = unicodeUnit.size();
Uint16 * perOne = new Uint16[arraySize + 1 ];
for ( int i = 0 ; i < arraySize; i ++ )
perOne[i] = unicodeUnit[i];
perOne[arraySize] = 0 ;
// Render the new text
textbuf = TTF_RenderUNICODE_Solid(font, perOne, fg);
// Free the text buffer and return
delete [] perOne;
return textbuf;
}
SDL_Surface * myTTF_RenderString_Shaded(TTF_Font * font, const std:: string & str, SDL_Color fg, SDL_Color bg)
{
SDL_Surface * textbuf;
// Get Unicode
std::vector < Uint16 > unicodeUnit;
if ( getUnicode(str, unicodeUnit) == false )
return 0 ;
int arraySize = unicodeUnit.size();
Uint16 * perOne = new Uint16[arraySize + 1 ];
for ( int i = 0 ; i < arraySize; i ++ )
perOne[i] = unicodeUnit[i];
perOne[arraySize] = 0 ;
// Render the new text
textbuf = TTF_RenderUNICODE_Shaded(font, perOne, fg, bg);
// Free the text buffer and return
delete [] perOne;
return textbuf;
}
lib: iconv.lib
SDL_ttf.lib
SDL.lib, SDLmain.lib
dll: iconv.dll
SDL_ttf.dll, libfreetype-6.dll, zlib1.dll
SDL.dll
last update: 2008-05-12