From 5e1dc59411cd7973fb4208ae76d0970bd2ea87d6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 24 Jan 2009 16:44:27 -0700 Subject: Updated DejaVuSans ttf file, as well as adding the bolded version, which is used in a few spots. Signed-off-by: Ira Rice --- data/fonts/CMakeLists.txt | 1 + data/fonts/Makefile.am | 3 ++- data/fonts/dejavusans-bold.ttf | Bin 0 -> 569880 bytes data/fonts/dejavusans.ttf | Bin 569716 -> 619108 bytes src/being.cpp | 7 ++++--- src/gui/gui.cpp | 21 +++++++++++++-------- src/gui/gui.h | 4 ++++ src/gui/ministatus.cpp | 8 ++++++++ src/gui/speechbubble.cpp | 25 ++++++++++++++++++------- src/gui/speechbubble.h | 1 + src/text.cpp | 6 +++--- 11 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 data/fonts/dejavusans-bold.ttf diff --git a/data/fonts/CMakeLists.txt b/data/fonts/CMakeLists.txt index 8393b923..d5b6ed85 100644 --- a/data/fonts/CMakeLists.txt +++ b/data/fonts/CMakeLists.txt @@ -1,5 +1,6 @@ SET (FILES dejavusans.ttf + dejavusans-bold.ttf ) INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/fonts) diff --git a/data/fonts/Makefile.am b/data/fonts/Makefile.am index 1384818c..1b575f7d 100644 --- a/data/fonts/Makefile.am +++ b/data/fonts/Makefile.am @@ -2,7 +2,8 @@ fontdir = $(pkgdatadir)/data/fonts font_DATA = \ - dejavusans.ttf + dejavusans.ttf \ + dejavusans-bold.ttf EXTRA_DIST = \ $(font_DATA) diff --git a/data/fonts/dejavusans-bold.ttf b/data/fonts/dejavusans-bold.ttf new file mode 100644 index 00000000..ebefb0ca Binary files /dev/null and b/data/fonts/dejavusans-bold.ttf differ diff --git a/data/fonts/dejavusans.ttf b/data/fonts/dejavusans.ttf index 627cef46..6253857c 100644 Binary files a/data/fonts/dejavusans.ttf and b/data/fonts/dejavusans.ttf differ diff --git a/src/being.cpp b/src/being.cpp index 65e9f9d1..e30ccee4 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -510,11 +510,12 @@ void Being::drawSpeech(Graphics *graphics, int offsetX, int offsetY) mText = 0; } - mSpeechBubble->setCaption(mName); - mSpeechBubble->setWindowName(mName); + if (mName != mSpeechBubble->getCaption()) + mSpeechBubble->setName(mName); + // Not quite centered, but close enough. However, it's not too important to get // it right right now, as it doesn't take bubble collision into account yet. - mSpeechBubble->setText( mSpeech ); + mSpeechBubble->setText(mSpeech); mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() * 4 / 11), py - 70 - (mSpeechBubble->getNumRows()*14)); mSpeechBubble->setVisible(true); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5314b9ba..fe8cae78 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -50,15 +50,9 @@ SDLInput *guiInput = 0; gcn::Font *hitRedFont = 0; gcn::Font *hitBlueFont = 0; gcn::Font *hitYellowFont = 0; -// Font used to display speech and player names -gcn::Font *speechFont; -// Font for displaying NPC names -gcn::Font *npcNameFont; -// Font for displaying mob names -gcn::Font *mobNameFont; -// Font for displaying GM names -gcn::Font *gmNameFont; +// Bolded font +gcn::Font *boldFont = 0; class GuiConfigListener : public ConfigListener { @@ -122,6 +116,17 @@ Gui::Gui(Graphics *graphics): + e.getMessage()); } + // Set bold font + path = resman->getPath("fonts/dejavusans-bold.ttf"); + try { + boldFont = new TrueTypeFont(path, 11); + } + catch (gcn::Exception e) + { + logger->error(std::string("Unable to load dejavusans-bold.ttf: ") + + e.getMessage()); + } + gcn::Widget::setGlobalFont(mGuiFont); // Load hits' colourful fonts diff --git a/src/gui/gui.h b/src/gui/gui.h index bb14d4dc..9f45a3f3 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -125,5 +125,9 @@ extern gcn::Font *hitRedFont; extern gcn::Font *hitBlueFont; extern gcn::Font *hitYellowFont; +/** + * Bolded text font + */ +extern gcn::Font *boldFont; #endif diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index f2e466f4..6e162141 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -46,6 +46,14 @@ MiniStatusWindow::MiniStatusWindow(): mMpLabel = new gcn::Label(""); mXpLabel = new gcn::Label(""); + mHpLabel->setForegroundColor(gcn::Color(50, 50, 50)); + mMpLabel->setForegroundColor(gcn::Color(50, 50, 50)); + mXpLabel->setForegroundColor(gcn::Color(50, 50, 50)); + + mHpLabel->setFont(boldFont); + mMpLabel->setFont(boldFont); + mXpLabel->setFont(boldFont); + mHpBar->setPosition(0, 3); mMpBar->setPosition(mHpBar->getWidth() + 3, 3); mXpBar->setPosition(mMpBar->getX() + mMpBar->getWidth() + 3, 3); diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 4fa63973..eb3232ea 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -22,6 +22,7 @@ #include +#include "gui.h" #include "speechbubble.h" #include "../resources/image.h" @@ -32,7 +33,7 @@ // TODO: Fix windows so that they can each load their own skins without the // other windows overriding another window's skin. SpeechBubble::SpeechBubble(): - Window(_("Message"), false, NULL, "graphics/gui/speechbubble.xml") + Window(_(""), false, NULL, "graphics/gui/speechbubble.xml") { mSpeechBox = new TextBox(); mSpeechBox->setEditable(false); @@ -59,28 +60,38 @@ SpeechBubble::SpeechBubble(): mSpeechBox->setTextWrapped( "" ); } +void SpeechBubble::setName(const std::string &name) +{ + setWindowName(name); + setCaption(name); +} + void SpeechBubble::setText(std::string mText) { mSpeechBox->setMinWidth(140); mSpeechBox->setTextWrapped( mText ); + const int fontHeight = getFont()->getHeight(); int numRows = mSpeechBox->getNumberOfRows(); if (numRows > 1) { // 15 == height of each line of text (based on font heights) // 14 == speechbubble Top + Bottom graphic pixel heights - setContentSize(mSpeechBox->getMinWidth() + 15, 15 + (numRows * 15)); - mSpeechArea->setDimension(gcn::Rectangle(4, 15, mSpeechBox->getMinWidth() + 5, - 3 +(numRows * 14))); + setContentSize(mSpeechBox->getMinWidth() + fontHeight, fontHeight + + (numRows * fontHeight)); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight, + mSpeechBox->getMinWidth() + 5, + 3 + (numRows * fontHeight))); } else { - int width = getFont()->getWidth(this->getCaption()); + int width = boldFont->getWidth(this->getCaption()); if (width < getFont()->getWidth(mText)) width = getFont()->getWidth(mText); - setContentSize(width + 15, 30); - mSpeechArea->setDimension(gcn::Rectangle(4, 15, width + 5, 17)); + setContentSize(width + fontHeight, fontHeight * 2); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight, + width + 5, fontHeight + 2)); } } diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 9b8eab70..6d8a94d4 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -33,6 +33,7 @@ class SpeechBubble : public Window SpeechBubble(); + void setName(const std::string &name); void setText(std::string mText); void setLocation(int x, int y); unsigned int getNumRows(); diff --git a/src/text.cpp b/src/text.cpp index ba581dab..14ee3919 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -38,8 +38,8 @@ Text::Text(const std::string &text, int x, int y, textManager = new TextManager(); } ++mInstances; - mHeight = gui->getFont()->getHeight(); - mWidth = gui->getFont()->getWidth(text); + mHeight = boldFont->getHeight(); + mWidth = boldFont->getWidth(text); switch (alignment) { case gcn::Graphics::LEFT: @@ -74,7 +74,7 @@ Text::~Text() void Text::draw(Graphics *graphics, int xOff, int yOff) { - graphics->setFont(gui->getFont()); + graphics->setFont(boldFont); // Text shadow graphics->setColor(gcn::Color(0, 0, 0)); -- cgit v1.2.3-60-g2f50