aboutsummaryrefslogtreecommitdiff
path: root/src/fontengine.cpp
Commit message (Expand)AuthorAge
* Isolate irrlicht references and use a singleton (#6041)Loïc Blot2017-06-26
* Merge cguittfont lib in irrlicht change folder. (#6016)Loïc Blot2017-06-20
* C++11 patchset 9: move hardcoded init parameters to class definitions (part 1...Loïc Blot2017-06-16
* Font: attempt fallback font, abort if no fonts found.Auke Kok2017-03-05
* Change i++ to ++iDavid Jones2015-08-25
* Settings: pass name to callbacks by referenceest312015-07-09
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
* For usages of assert() that are meant to persist in Release builds (when NDEB...Craig Robbins2015-03-07
* Settings fixes Make the GameGlobalShaderConstantSetter use the settings callb...gregorycu2015-01-25
* Revert "Make the GameGlobalShaderConstantSetter use the settings callback (8%...Craig Robbins2015-01-25
* Make the GameGlobalShaderConstantSetter use the settings callback (8% perf im...gregorycu2015-01-23
* FontEngine: Don't use file extension to check font file compatibilitykwolekr2014-12-29
* Fix MSVC compiling warnings and remove an unused textureSmallJoker2014-12-12
* Fix segfault at exit caused by non grabbed fontKahrl2014-11-30
* Make hud use fontengine toosapier2014-11-30
* Implement proper font handlingsapier2014-11-30
vironments, some standard headers like <iomanip> // and <locale> include libintl.h. If libintl.h is included after // we define our gettext macro below, this causes a syntax error // at the declaration of the gettext function in libintl.h. // Fix this by including such a header before defining the macro. // See issue #4446. // Note that we can't include libintl.h directly since we're in // the USE_GETTEXT=0 case and can't assume that gettext is installed. #include <locale> #define gettext(String) String #endif #define _(String) gettext(String) #define gettext_noop(String) (String) #define N_(String) gettext_noop((String)) void init_gettext(const char *path, const std::string &configured_language, int argc, char *argv[]); extern wchar_t *utf8_to_wide_c(const char *str); // The returned string must be freed using delete[] inline const wchar_t *wgettext(const char *str) { // We must check here that is not an empty string to avoid trying to translate it return str[0] ? utf8_to_wide_c(gettext(str)) : utf8_to_wide_c(""); } inline std::string strgettext(const std::string &text) { return text.empty() ? "" : gettext(text.c_str()); } /** * Returns translated string with format args applied * * @tparam Args Template parameter for format args * @param src Translation source string * @param args Variable format args * @return translated string */ template <typename ...Args> inline std::wstring fwgettext(const char *src, Args&&... args) { wchar_t buf[255]; const wchar_t* str = wgettext(src); swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, std::forward<Args>(args)...); delete[] str; return std::wstring(buf); } /** * Returns translated string with format args applied * * @tparam Args Template parameter for format args * @param format Translation source string * @param args Variable format args * @return translated string. */ template <typename ...Args> inline std::string fmtgettext(const char *format, Args&&... args) { std::string buf; std::size_t buf_size = 256; buf.resize(buf_size); format = gettext(format); int len = porting::mt_snprintf(&buf[0], buf_size, format, std::forward<Args>(args)...); if (len <= 0) throw std::runtime_error("gettext format error: " + std::string(format)); if ((size_t)len >= buf.size()) { buf.resize(len+1); // extra null byte porting::mt_snprintf(&buf[0], buf.size(), format, std::forward<Args>(args)...); } buf.resize(len); // remove null bytes return buf; }