From 9a2b992c068b1f6ff960875d444dc12dfadf4189 Mon Sep 17 00:00:00 2001 From: coppro Date: Sat, 19 May 2007 21:15:20 +0000 Subject: [PATCH] Fixed GTK GetTextExtent bug Added resources shell script git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@401 0fc631ac-6414-0410-93d0-97cfa31319b6 --- Resources.sh | 21 +++++++++++++++++++++ src/gui/value/text.cpp | 6 ++++++ src/util/rotation.cpp | 9 ++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100755 Resources.sh diff --git a/Resources.sh b/Resources.sh new file mode 100755 index 00000000..677f9db8 --- /dev/null +++ b/Resources.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +rm -r /usr/local/share/magicseteditor/resource + +for DIR in /usr/local/share/magicseteditor /usr/local/share/magicseteditor/resource /usr/local/share/magicseteditor/resource/icon /usr/local/share/magicseteditor/resource/tool /usr/local/share/magicseteditor/resource/cursor +do +if [ -d $DIR ]; then +: ; +elif [ -a $DIR ]; then +echo $DIR "exists and is not a directory!"; +exit 1 ; +else +mkdir $DIR; +fi +done + +cp src/resource/common/* /usr/local/share/magicseteditor/resource; +cp src/resource/msw/tool/* /usr/local/share/magicseteditor/resource/tool; +cp src/resource/msw/icon/* /usr/local/share/magicseteditor/resource/icon; +cp src/resource/msw/cursor/* /usr/local/share/magicseteditor/resource/cursor; +cp src/resource/msw/other/* /usr/local/share/magicseteditor/resource; \ No newline at end of file diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index 06917ac2..4162ba84 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -457,6 +457,12 @@ void TextValueEditor::showCaret() { dc.SetFont(style().font.toWxFont(1.0)); int hi; dc.GetTextExtent(_(" "), 0, &hi); + #ifdef __WXGTK__ + // HACK: Some fonts don't get the descender height set correctly. + int charHeight = dc.GetCharHeight(); + if (charHeight != hi) + hi += hi - charHeight; + #endif cursor.height = rot.trS(hi); } } diff --git a/src/util/rotation.cpp b/src/util/rotation.cpp index 0a8af7fb..0e4c7e50 100644 --- a/src/util/rotation.cpp +++ b/src/util/rotation.cpp @@ -235,10 +235,13 @@ double RotatedDC::getFontSizeStep() const { } RealSize RotatedDC::GetTextExtent(const String& text) const { - int w, h, descend; - dc.GetTextExtent(text, &w, &h, &descend); + int w, h; + dc.GetTextExtent(text, &w, &h); #ifdef __WXGTK__ - h += descend; /// wxGTK seems to think character height does not include the descender. + // HACK: Some fonts don't get the descender height set correctly. + int charHeight = dc.GetCharHeight(); + if (charHeight != h) + h += h - charHeight; #endif if (quality == QUALITY_LOW) { return RealSize(w,h) / zoom;