From b40db11955b60080aab295d8e092e75099eb27d1 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Tue, 16 May 2017 15:23:34 +0800 Subject: [PATCH] Query of font size is supported --- MiniEngine.cpp | 22 ++++++++++++++++++++++ MiniEngine.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 283bcd6..0287cd3 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -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) { diff --git a/MiniEngine.h b/MiniEngine.h index 4f09bc4..c74064e 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -373,6 +373,9 @@ namespace MiniEngine std::tuple