summaryrefslogtreecommitdiff
path: root/src/gui/truetypefont.cpp
AgeCommit message (Collapse)AuthorFilesLines
14 daysFixed issues related to wrong alpha mod set on texturesThorbjørn Lindeijer1-8/+0
Due to the use of SubImage, there can be multiple images pointing to the same SDL_Texture with different alpha values. However, since the alpha mod set on the texture was only set from Image::setAlpha, images were not always rendered with the correct alpha value. Now the alpha mod is always set right before rendering each image. Most of the time the alpha will remain the same, but I don't expect this to become a performance issue so I've not added extra variables and checks to suppress such calls when they aren't needed. On the upside, this simplifies the "use color" option, which previously had to restore the previously set alpha mod. Closes #117
2025-07-15Render font outlines using TTF_SetFontOutlineThorbjørn Lindeijer1-45/+100
Rather than rendering the same texture 4 additional times, render a specific outline version of the text. While reducing the number of times the text is drawn, it does increase font texture use. Result is a generally prettier outline due to rendering it properly at sharp corners of the characters. The shadow for outlined text is now also thicker, as appropriate. As part of this change, the `TextRenderer` class was merged into the `Graphics` and `TrueTypeFont` classes. There seemed to be little point in having a separate function for this, apart from needing more static casts to `Graphics*`. Also fixed an issue where the font style was not being restored after adjusting the font scale, when using an older SDL_ttf than 2.0.18. Closes #87
2025-03-31Use color modulation to render text in different colorsThorbjørn Lindeijer1-19/+6
No need to cache the image in different colors since color modulation is cheap these days.
2024-03-26Added support for HiDPI fontsThorbjørn Lindeijer1-68/+86
* TrueTypeFont class now takes into account the graphics scale, in order to render an appropriate higher-resolution texture. * Removed TrueTypeFont::fontCounter, since TTF_Init/TTF_Quit already keep a counter. * Avoid copying the rendered string needlessly, when it already exists in the cache. Avoid another copy, when inserting a new chunk into the cache.
2024-03-25Avoid string allocations during text rendering and sizingThorbjørn Lindeijer1-4/+11
Now a text chunk has a maximum length of 4k characters, but that should be plenty of space since they're only single lines.
2024-03-12General code cleanupsThorbjørn Lindeijer1-4/+1
* Use default member initializers * Use range-based for loops * Avoid needless pointer references for ShopItem::mDuplicates * Removed type aliases that are only used once or twice * Removed more unused includes * Removed some unused functions * Removed superfluous .c_str() * Rely on default copy and assignment operators for Vector class * Use std::unique_ptr in some places * Removed duplicated mPlayerMoney updating in SellDialog * Removed duplicated Game::handleInput call * Removed unused SDLInput::mMouseInWindow * Removed remnant of manual widget positioning in HelpWindow * Removed superfluous initialization of static pointers
2024-02-09C++11: Use default member initializersThorbjørn Lindeijer1-2/+2
This patch is not exhaustive.
2024-01-26Apply C++11 fixitsThorbjørn Lindeijer1-6/+6
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2024-01-25Ported to SDL2Thorbjørn Lindeijer1-1/+3
2012-03-18Removed some 'const' keywords from value returnsThorbjørn Lindeijer1-2/+2
It makes no sense to mark a return value as const when it is returned by value. This only makes sense if the return value is passed by reference, in order to prevent the receiver from modifying the value. Also made some other small adjustments. A std::string does not need to be initialized to "" explicitly and getSafeUtf8String could take its parameter by reference. Reviewed-by: Yohann Ferreira
2012-02-07Made BrowserBox use the recommended line skip for its fontThorbjørn Lindeijer1-0/+5
SDL_ttf provides a separate function for getting the recommended line skip, or the spacing between two lines of text. When rendering multiple lines of text this should be used rather than the visual height of the font. Since the information is only available for TrueTypeFont, a dynamic_cast was used with a fallback on gcn::Font::getHeight. Also made some small tweaks but nothing that really affects performance. Reviewed-by: Yohann Ferreira
2012-01-26Updated copyrights to 2012Thorbjørn Lindeijer1-1/+1
2010-10-19Fix crash in drawing incorrect strings.Andrei Karas1-11/+11
Reviewed-by: cody
2010-05-28Fix memory leak in last patch.Andrei Karas1-0/+1
Reviewed-by: Bertram
2010-05-27Fix drawing incorrect utf8 strings issue.Andrei Karas1-3/+8
Reviewed-by: Bertram Resolve: Manasource Mantis #143
2010-02-22Modify copyright headersFreeyorp1-1/+2
2010-02-20License header update for The Mana ClientThorbjørn Lindeijer1-4/+3
2010-02-13Remove imprecise operator== and just compare the textThorbjørn Lindeijer1-6/+1
2010-02-13Optimise TrueTypeFont::getWidthSteve Cotton1-0/+17
Use the cache created by TTF::drawString, drops the cost of TTF::getWidth from 5% of runtime to 0.5%. It increases the cost of calculating line-wrapping in the BrowserBox, but overall it's a saving, even with the BrowserBox recalculating on every redraw.
2010-02-07Updated Copyright year to 2010!Bertram1-1/+1
Also added the update copyright tool from the Wormux Team. ( And not forgetting credit's due. :P )
2010-01-11Cleanup GUI classesJared Adams1-0/+1
Moved remaining widgets into widgets folder, standardized include order, moved TextRenderer out.
2009-05-14Don't apply GUI opacity to the selected value of a DropDownBjørn Lindeijer1-4/+4
2009-04-15Also hardcode the bold font, we ship it after allBjørn Lindeijer1-1/+1
Plus some tweaks and cleanups.
2009-03-30Fixed checking for loading fonts before applying a styleBernd Wachter1-1/+2
2009-02-19Added a pickup notification as particle effect. Also make a ui option to ↵Majin Sniper1-1/+2
enable/disable this effect (default is off) and another option to disable the pickup notification in the chat log (default is on).
2009-02-15Fixes some variable names to conform to naming conventionBjørn Lindeijer1-8/+8
Please do remember that member variables are prefixes with 'm', so that they are easily distinguishable.
2009-02-15Merge commit 'aethyra/master'Bjørn Lindeijer1-4/+0
Conflicts: CMakeLists.txt configure.ac data/help/header.txt packaging/windows/setup.nsi po/POTFILES.in src/being.cpp src/being.h src/game.cpp src/gui/color.cpp src/gui/color.h src/gui/equipmentwindow.h src/gui/popupmenu.cpp src/gui/recorder.cpp src/gui/setup_colors.h src/gui/setup_keyboard.cpp src/gui/setup_keyboard.h src/gui/skill.cpp src/gui/speechbubble.cpp src/gui/speechbubble.h src/gui/table.cpp src/keyboardconfig.cpp src/keyboardconfig.h src/localplayer.cpp src/main.cpp src/main.h src/map.cpp src/resources/colordb.cpp src/resources/colordb.h src/resources/emotedb.cpp src/resources/emotedb.h src/text.cpp src/text.h src/tmw.rc src/winver.h
2009-02-10Removed many pointless comparisons with NULLBjørn Lindeijer1-1/+1
Sometimes it's nice for clarity, but most of the time this is just clutter. C++ != Java. :)
2009-02-10Fixed header files, as well as removed the unused buddy list class (notIra Rice1-2/+3
useful since buddy lists are tracked through the player relation interface instead) Signed-off-by: Ira Rice <irarice@gmail.com>
2009-02-11Removed many pointless comparisons with NULLBjørn Lindeijer1-1/+1
Sometimes it's nice for clarity, but most of the time this is just clutter. C++ != Java. :)
2009-02-10Fixed font glyph caching.Ira Rice1-4/+0
Signed-off-by: Ira Rice <irarice@gmail.com>
2009-02-09Merged with Aethyra master as of 2009-01-27Bjørn Lindeijer1-3/+2
Conflicts: Almost everywhere.
2009-01-24Code reformattingBjørn Lindeijer1-2/+0
2009-01-24Code reformattingBjørn Lindeijer1-4/+2
2009-01-23Removed unnecessary references to The Mana World in code headersBjørn Lindeijer1-4/+4
This dates back to the old days of TMW, but the usage instructions of GPLv2 don't mention this being necessary. Since it doesn't add anything, avoid the branding in these sections.
2009-01-23Removed unnecessary references to The Mana World in code headersBjørn Lindeijer1-4/+4
This dates back to the old days of TMW, but the usage instructions of GPLv2 don't mention this being necessary. Since it doesn't add anything, avoid the branding in these sections.
2009-01-15Style cleanups throughout most of the code. Splitting function type fromIra Rice1-7/+4
the function names should no longer be around. Signed-off-by: Ira Rice <irarice@gmail.com>
2009-01-06Fixed the true type font to render unicode nowBjørn Lindeijer1-2/+2
2009-01-06Fixed the true type font to render unicode nowBjørn Lindeijer1-2/+2
2009-01-05Fixed rendering of special charactersBjørn Lindeijer1-2/+2
The font was interpreting the strings as UTF8, as they are in the mainline client. But in the eAthena client they are regular text.
2009-01-05Increased text chunk cache size to improve performance when a lot of text is ↵Philipp Sehmisch1-1/+1
on the screen. (cherry picked from mainline commit 483c76d1b2433bc34f67406a10bf409fb2daafe1)
2009-01-05Image alpha should also be set to 1, in case it was changed before.Bjørn Lindeijer1-7/+7
(cherry picked from mainline commit 0962fc8b567279a6e97e13e4b3f2f9f2ffe304c0)
2009-01-05Added support for alpha blending to true type font drawing.Philipp Sehmisch1-0/+7
(cherry picked from mainline commit 89a1dcb59be3e531cc0761c32d1aa70e141d4a12)
2009-01-05Fixed double-free of true-type resources.Guillaume Melquiond1-2/+5
(cherry-picked from mainline)
2009-01-05Modified the Aethyra client to use the TMW TrueType class, rather thanEugenio Favalli1-0/+170
the inbuilt GUIChan TrueType class. (Didn't use it originally because I didn't see the difference, when there's a considerable speedup, and that originally the import for TMW was broken code at the time, which has been fixed since.)
2009-01-04Fixed rendering of special charactersBjørn Lindeijer1-2/+2
The font was interpreting the strings as UTF8, as they are in the mainline client. But in the eAthena client they are regular text.
2009-01-02Removed duplicate TrueTypeFont class declarationBjørn Lindeijer1-6/+3
Noticed by QOAL
2008-12-29Increased text chunk cache size to improve performance when a lot of text is ↵Philipp Sehmisch1-1/+1
on the screen. (cherry picked from mainline commit 483c76d1b2433bc34f67406a10bf409fb2daafe1)
2008-12-29Image alpha should also be set to 1, in case it was changed before.Bjørn Lindeijer1-7/+7
(cherry picked from mainline commit 0962fc8b567279a6e97e13e4b3f2f9f2ffe304c0)
2008-12-29Added support for alpha blending to true type font drawing.Philipp Sehmisch1-0/+7
(cherry picked from mainline commit 89a1dcb59be3e531cc0761c32d1aa70e141d4a12)