![]() |
ManaPlus
|
#include <font.h>
Public Member Functions | |
| Font (std::string filename, int size, const int style) | |
| ~Font () | |
| void | loadFont (std::string filename, const int size, const int style) |
| int | getWidth (const std::string &text) const |
| int | getHeight () const |
| const TextChunkList * | getCache () const A_CONST |
| void | drawString (Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y) |
| void | clear () |
| void | doClean () |
| void | slowLogic (const int rnd) |
| unsigned int | getCreateCounter () const |
| unsigned int | getDeleteCounter () const |
| int | getStringIndexAt (const std::string &text, const int x) const |
| void | generate (TextChunk &chunk) |
| void | insertChunk (TextChunk *const chunk) |
Static Public Attributes | |
| static bool | mSoftMode |
Static Private Member Functions | |
| static TTF_Font * | openFont (const char *const name, const int size) |
Private Attributes | |
| TTF_Font * | mFont |
| unsigned int | mCreateCounter |
| unsigned int | mDeleteCounter |
| time_t | mCleanTime |
| TextChunkList | mCache [CACHES_NUMBER] |
A wrapper around SDL_ttf for allowing the use of TrueType fonts.
NOTE: This class initializes SDL_ttf as necessary.
| Font::Font | ( | std::string | filename, |
| int | size, | ||
| const int | style | ||
| ) |
Definition at line 106 of file font.cpp.
References Logger::error(), fixDirSeparators(), fontCounter, imageHelper, Logger::log(), logger, mFont, mSoftMode, openFont(), RENDER_SOFTWARE, reportAlways, EmoteDB::size(), strBuf, and ImageHelper::useOpenGL().
| Font::~Font | ( | ) |
| void Font::clear | ( | ) |
Definition at line 248 of file font.cpp.
References CACHES_NUMBER, and mCache.
Referenced by Gui::clearFonts(), loadFont(), and ~Font().
| void Font::doClean | ( | ) |
Definition at line 367 of file font.cpp.
References CACHE_SIZE_SMALL1, CACHE_SIZE_SMALL2, CACHE_SIZE_SMALL3, CACHES_NUMBER, CAST_SIZE, Logger::log(), logger, mCache, mDeleteCounter, TextChunkList::removeBack(), TextChunkList::size, and EmoteDB::size().
Referenced by slowLogic().
| void Font::drawString | ( | Graphics *const | graphics, |
| Color | col, | ||
| const Color & | col2, | ||
| const std::string & | text, | ||
| const int | x, | ||
| const int | y | ||
| ) |
Definition at line 254 of file font.cpp.
References Color::a, BLOCK_END, BLOCK_START, CACHE_SIZE, Graphics::drawImage(), TextChunk::generate(), TextChunk::img, TextChunkList::insertFirst(), mCache, mCreateCounter, mDeleteCounter, mFont, TextChunkList::moveToFirst(), TextChunkList::removeBack(), TextChunkList::search, TextChunkList::size, x, and y.
Referenced by Game::addWatermark(), Gui::draw(), BrowserBox::draw(), ColorPage::draw(), DropDown::draw(), ExtendedListBox::draw(), ItemContainer::draw(), ItemShortcutContainer::draw(), ListBox::draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), SkillRectangleListBox::draw(), SpellShortcutContainer::draw(), StaticBrowserBox::draw(), TextBox::draw(), TextPreview::draw(), VirtShortcutContainer::draw(), EquipmentWindow::draw(), FloorItem::draw(), MapItem::draw(), AvatarListBox::draw(), EmoteShortcutContainer::draw(), Viewport::drawPath(), Being::drawPortalSpriteAt(), TouchManager::drawText(), ItemContainer::safeDraw(), ItemShortcutContainer::safeDraw(), SpellShortcutContainer::safeDraw(), VirtShortcutContainer::safeDraw(), EquipmentWindow::safeDraw(), AvatarListBox::safeDraw(), EmoteShortcutContainer::safeDraw(), and TestLauncher::testDraw().
| void Font::generate | ( | TextChunk & | chunk | ) |
Definition at line 430 of file font.cpp.
References Color::a, CACHE_SIZE, TextChunk::color, TextChunk::color2, TextChunk::generate(), TextChunk::img, mCache, mCreateCounter, mDeleteCounter, mFont, TextChunkList::moveToFirst(), TextChunkList::remove(), TextChunkList::removeBack(), TextChunkList::search, TextChunkList::size, and TextChunk::text.
Referenced by Button::draw(), CheckBox::draw(), Label::draw(), ProgressBar::draw(), RadioButton::draw(), TextField::draw(), Window::draw(), Text::draw(), Button::safeDraw(), ProgressBar::safeDraw(), and Window::safeDraw().
| const TextChunkList * Font::getCache | ( | ) | const |
|
inline |
|
inline |
| int Font::getHeight | ( | ) | const |
Definition at line 362 of file font.cpp.
References mFont.
Referenced by BrowserBox::addRow(), StaticBrowserBox::addRow(), Button::adjustSize(), Label::adjustSize(), RadioButton::adjustSize(), TextBox::adjustSize(), BrowserBox::calcHeight(), ColorPage::ColorPage(), Button::draw(), ExtendedListBox::draw(), Label::draw(), ProgressBar::draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), TextBox::draw(), TextPreview::draw(), EquipmentWindow::draw(), AvatarListBox::draw(), TouchManager::drawText(), ServersListBox::getRowHeight(), ItemPopup::ItemPopup(), TextBox::keyPressed(), Label::Label(), ListBox::ListBox(), AvatarListBox::mousePressed(), SkillRectangleListBox::mousePressed(), TextBox::mousePressed(), NpcDialog::NpcDialog(), StatusPopup::postInit(), TextBoxPopup::postInit(), TextPopup::postInit(), ConfirmDialog::postInit(), QuestsWindow::QuestsWindow(), Label::resizeTo(), Button::safeDraw(), ProgressBar::safeDraw(), EquipmentWindow::safeDraw(), AvatarListBox::safeDraw(), TextBox::scrollToCaret(), ItemPopup::setItem(), ShopListBox::ShopListBox(), BeingPopup::show(), SkillPopup::show(), SkillListBox::SkillListBox(), SkillPopup::SkillPopup(), SkillRectangleListBox::SkillRectangleListBox(), StaticBrowserBox::updateHeight(), and Window::Window().
| int Font::getStringIndexAt | ( | const std::string & | text, |
| const int | x | ||
| ) | const |
Definition at line 413 of file font.cpp.
References CAST_S32, getWidth(), and x.
Referenced by TextBox::mousePressed(), and TextField::mousePressed().
| int Font::getWidth | ( | const std::string & | text | ) | const |
Definition at line 334 of file font.cpp.
References getSafeUtf8String(), TextChunk::img, mCache, mFont, TextChunkList::moveToFirst(), TextChunkList::searchWidth, and strBuf.
Referenced by BrowserBox::addRow(), StaticBrowserBox::addRow(), Button::adjustSize(), Label::adjustSize(), RadioButton::adjustSize(), TextBox::adjustSize(), BrowserBox::calcHeight(), Gui::draw(), Button::draw(), ColorPage::draw(), ExtendedListBox::draw(), ItemContainer::draw(), ItemShortcutContainer::draw(), Label::draw(), ListBox::draw(), ProgressBar::draw(), ServersListBox::draw(), SkillListBox::draw(), SkillRectangleListBox::draw(), TextBox::draw(), TextField::draw(), TextPreview::draw(), VirtShortcutContainer::draw(), Window::draw(), EquipmentWindow::draw(), Viewport::drawPath(), TouchManager::drawText(), TextField::fixScroll(), SliderList::getMaxLabelWidth(), SetupItemSlider2::getMaxWidth(), getStringIndexAt(), InventoryWindow::InventoryWindow(), Label::Label(), ServerDialog::loadServers(), NpcDialog::NpcDialog(), OkDialog::OkDialog(), PincodeDialog::PincodeDialog(), ConfirmDialog::postInit(), Label::resizeTo(), Button::safeDraw(), ItemContainer::safeDraw(), ItemShortcutContainer::safeDraw(), ProgressBar::safeDraw(), VirtShortcutContainer::safeDraw(), Window::safeDraw(), EquipmentWindow::safeDraw(), TextBox::scrollToCaret(), TextBox::setTextWrapped(), Setup_Colors::Setup_Colors(), ServersListModel::setVersionString(), SkillRectangleListBox::SkillRectangleListBox(), TextDialog::TextDialog(), TradeWindow::TradeWindow(), and StaticBrowserBox::updateHeight().
| void Font::insertChunk | ( | TextChunk *const | chunk | ) |
Definition at line 478 of file font.cpp.
References TextChunk::color, TextChunk::color2, delete2, TextChunk::img, TextChunkList::insertFirst(), mCache, TextChunkList::search, TextChunk::text, and TextChunk::textFont.
Referenced by TextChunk::deleteImage().
| void Font::loadFont | ( | std::string | filename, |
| const int | size, | ||
| const int | style | ||
| ) |
Definition at line 219 of file font.cpp.
References clear(), fixDirSeparators(), fontCounter, Logger::log(), logger, mFont, openFont(), and EmoteDB::size().
Referenced by Gui::updateFonts().
|
staticprivate |
Definition at line 191 of file font.cpp.
References Files::existsLocal(), VirtFs::getPath(), Logger::log(), logger, reportAlways, VirtFs::rwopsOpenRead(), and EmoteDB::size().
Referenced by Font(), and loadFont().
| void Font::slowLogic | ( | const int | rnd | ) |
Definition at line 319 of file font.cpp.
References BLOCK_END, BLOCK_START, CLEAN_TIME, cur_time, doClean(), and mCleanTime.
Referenced by Gui::slowLogic().
|
mutableprivate |
Definition at line 152 of file font.h.
Referenced by clear(), doClean(), drawString(), generate(), getCache(), getWidth(), and insertChunk().
|
private |
Definition at line 151 of file font.h.
Referenced by slowLogic().
|
private |
Definition at line 147 of file font.h.
Referenced by drawString(), generate(), and getCreateCounter().
|
private |
Definition at line 148 of file font.h.
Referenced by doClean(), drawString(), generate(), and getDeleteCounter().
|
private |
Definition at line 146 of file font.h.
Referenced by drawString(), Font(), generate(), getHeight(), getWidth(), loadFont(), and ~Font().
|
static |
Definition at line 140 of file font.h.
Referenced by Font(), and TextChunkSmall::operator<().