From 9acbfb9d19460fc6d004dab49bd771c6556858f1 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 11 Jan 2011 19:03:41 +0000 Subject: [PATCH] - patch from Nebososo for 2 byte characters and font widths --- source/shared_lib/sources/graphics/font.cpp | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index ff470b78..86de6259 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -3,9 +3,9 @@ // // Copyright (C) 2001-2007 Martio Figueroa // -// You can redistribute this code and/or modify it under -// the terms of the GNU General Public License as published -// by the Free Software Foundation; either version 2 of the +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version // ============================================================== @@ -26,28 +26,35 @@ std::string Font::fontTypeName = "Times New Roman"; // class FontMetrics // ===================================================== -FontMetrics::FontMetrics(){ +FontMetrics::FontMetrics() { widths= new float[Font::charCount]; height= 0; - for(int i=0; i= Font::charCount) { string sError = "str[i] >= Font::charCount, [" + str + "] i = " + intToStr(i); throw runtime_error(sError); } - width+= widths[str[i]]; + //Treat 2 byte characters as spaces + if(str[i] < 0) { + width+= widths[32]; + i++; + } + else { + width+= widths[str[i]]; + } } return width; }