Query of font size is supported

This commit is contained in:
Kirigaya Kazuto 2017-05-16 15:23:34 +08:00
parent d77c894adc
commit b40db11955
2 changed files with 25 additions and 0 deletions

View File

@ -1164,6 +1164,28 @@ namespace MiniEngine
return 0;
}
Rect Font::sizeText(const std::string& Text) throw (ErrorViewer)
{
int w=0,h=0;
if(TTF_SizeText(_get(),Text.c_str(),&w,&h)!=0)
{
/// Something might be wrong
throw ErrorViewer();
}
return Rect(0,0,w,h);
}
Rect Font::sizeUTF8(const std::string& Text) throw (ErrorViewer)
{
int w=0,h=0;
if(TTF_SizeUTF8(_get(),Text.c_str(),&w,&h)!=0)
{
/// Something might be wrong
throw ErrorViewer();
}
return Rect(0,0,w,h);
}
/// rendering surfaces...
Surface Font::renderText(std::string Text,RGBA fg)
{

View File

@ -373,6 +373,9 @@ namespace MiniEngine
std::tuple<Style> getFontStyles();
Rect sizeText(const std::string& Text) throw (ErrorViewer);
Rect sizeUTF8(const std::string& Text) throw (ErrorViewer);
Surface renderText(std::string Text, RGBA fg);
Surface renderTextWrapped(std::string Text, RGBA fg, int WrapLength);
Surface renderTextShaded(std::string Text, RGBA fg, RGBA bg);