From ad8aa55bbbd87f854be3b8748123e511f6c7fe0c Mon Sep 17 00:00:00 2001 From: unodgs Date: Wed, 28 Sep 2011 15:47:27 +0000 Subject: [PATCH] Rainbow: WinGL.. git-svn-id: svn://ultimatepp.org/upp/trunk@3924 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/WinGl/DrawText.cpp | 20 +++++++++----------- rainbow/WinGl/Event.cpp | 5 ++++- uppsrc/Draw/FontWin32.cpp | 7 ++++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/rainbow/WinGl/DrawText.cpp b/rainbow/WinGl/DrawText.cpp index 9975eb9c5..8684c45d9 100644 --- a/rainbow/WinGl/DrawText.cpp +++ b/rainbow/WinGl/DrawText.cpp @@ -24,6 +24,8 @@ void OpenGLFont::Load(const String& fileName) void OpenGLFont::Parse(const char* xml, bool parsePages) { + chars.SetCount(512); + XmlParser p(xml); while(!p.IsTag()) @@ -64,11 +66,10 @@ void OpenGLFont::Parse(const char* xml, bool parsePages) { if(p.TagE("char")) { - CharInfo& ci = chars.Add(); + int id = p.Int("id"); + CharInfo& ci = chars[id]; - int page = p.Int("page"); - - ci.id = p.Int("id"); + ci.id = id; ci.x = (float) p.Double("x"); ci.y = (float) p.Double("y"); ci.width = (float) p.Double("width"); @@ -76,7 +77,7 @@ void OpenGLFont::Parse(const char* xml, bool parsePages) ci.xoffset = (float) p.Double("xoffset"); ci.yoffset = (float) p.Double("yoffset"); ci.xadvance = (float) p.Double("xadvance"); - ci.page = page; + ci.page = p.Int("page"); } else p.Skip(); @@ -176,8 +177,7 @@ void SystemDraw::Text(int x, int y, int angle, const wchar *text, Font font, Col while(*s && n > 0) { - int ch = *s; - int cn = ch - 32; + int cn = *s; if(cn >= 0 && cn < fi.chars.GetCount()) { @@ -292,14 +292,12 @@ Size GetTextSize(const wchar *text, const OpenGLFont& fi, int n) sz.cx = 0; const wchar *wtext = (const wchar *)text; while(n > 0) { - int ch = *wtext++; - int cn = ch - 32; - + int cn = *wtext++; if(cn >= 0 && cn < fi.chars.GetCount()) { const OpenGLFont::CharInfo& ci = fi.chars[cn]; sz.cx += int(ci.xadvance * fi.scale + 0.5f); - int k = fi.kerns.Find(ch); + int k = fi.kerns.Find(cn); if(k >= 0) sz.cx += int(fi.kerns[k].Get(*wtext, 0) * fi.scale); } diff --git a/rainbow/WinGl/Event.cpp b/rainbow/WinGl/Event.cpp index c4643ecad..ba73091a6 100644 --- a/rainbow/WinGl/Event.cpp +++ b/rainbow/WinGl/Event.cpp @@ -70,7 +70,10 @@ void Ctrl::DoMouseGl(int event, Point p, int zdelta) else { bool processed = consoleActive && DoMouseGl((Ctrl*) &console, event, p, zdelta); - processed = !processed && controlPanelActive && DoMouseGl((Ctrl*) &infoPanel, event, p, zdelta); + + if(!processed && controlPanelActive) + processed = DoMouseGl((Ctrl*) &infoPanel, event, p, zdelta); + if(!processed) { for(int i = topctrl.GetCount() - 1; i >= 0; i--) { diff --git a/uppsrc/Draw/FontWin32.cpp b/uppsrc/Draw/FontWin32.cpp index 97092ff46..ca3131aad 100644 --- a/uppsrc/Draw/FontWin32.cpp +++ b/uppsrc/Draw/FontWin32.cpp @@ -246,10 +246,11 @@ GlyphInfo GetGlyphInfoSys(Font font, int chr) { static GlyphInfo gi; const OpenGLFont& fi = Resources::GetFont(font); - int idx = chr - 32; - gi.width = idx < fi.chars.GetCount() - ? int(fi.chars[chr - 32].xadvance * fi.scale + 0.5f) + gi.width = chr < fi.chars.GetCount() + ? int(fi.chars[chr].xadvance * fi.scale + 0.5f) : 0; + gi.lspc = 0; + gi.rspc = 0; return gi; } #else