font.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. #include "precomp.h"
  2. // ============================================================================================================================================================
  3. // Font abstract class + statics to install TT fonts and Bitmap fonts
  4. // ============================================================================================================================================================
  5. #include <api/font/font.h>
  6. #include <api/font/bitmapfont.h>
  7. #include <bfc/parse/pathparse.h>
  8. #ifdef WASABI_COMPILE_SKIN
  9. #include <api/skin/skin.h>
  10. #include <api/skin/skinparse.h>
  11. #endif
  12. #include <tataki/canvas/ifc_canvas.h>
  13. #include <api/wnd/fontdef.h>
  14. #ifdef WASABI_COMPILE_FONT
  15. #include <api/service/svcs/svc_font.h>
  16. //#include "services/svc_fontmaker.h"
  17. #endif
  18. #ifdef WASABI_API_CONFIG
  19. #include <api/config/options.h>
  20. #include <api/config/items/attrint.h>
  21. #include <api/config/items/attrstr.h>
  22. #include <api/config/items/attrbool.h>
  23. #endif
  24. #include <api/memmgr/api_memmgr.h>
  25. #include <api/font/FontSvcEnum.h>
  26. extern _bool cfg_options_usefontmapper;
  27. extern _string cfg_options_ttfoverridefont;
  28. extern _int cfg_options_defaultfontscale;
  29. PtrList<svc_font> Font::fontlist;
  30. PtrList<FontDef> Font::fontdefs;
  31. void Font::init()
  32. {
  33. #ifdef WASABI_API_CONFIG
  34. Wasabi::Std::setDefaultFont(cfg_options_defaultfont.getValue());
  35. Wasabi::Std::setDefaultFontScale(cfg_options_defaultfontscale.getValueAsInt());
  36. #endif
  37. }
  38. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  39. void Font::dispatchTextOut(ifc_canvas *c, int style, int x, int y, int w, int h, const wchar_t *txt)
  40. {
  41. int isoverride = 0;
  42. if (WASABI_API_APP->main_isShuttingDown()) return;
  43. int size = c->getTextSize();
  44. svc_font *f = requestSkinFont(c->getTextFont(), &size);
  45. ASSERT(f != NULL);
  46. // After we get the font we want, check to see if it is bitmap.
  47. // If bitmap fonts are disallowed, use the truetype override font.
  48. if (f->isBitmap() && useTrueTypeOverride(txt))
  49. {
  50. int gotdefault=0;
  51. svc_font *ttFont = requestSkinFont(getTrueTypeOverride(), &size, &gotdefault);
  52. if (ttFont != NULL)
  53. {
  54. if (!gotdefault)
  55. isoverride = 1;
  56. f = ttFont;
  57. }
  58. }
  59. if (isoverride)
  60. {
  61. double f = (double)getTrueTypeOverrideScale() / 100.0f;
  62. size = (int)(size*f);
  63. }
  64. int bold = c->getTextBold();
  65. int opaque = c->getTextOpaque();
  66. int underline = c->getTextUnderline();
  67. int italic = c->getTextItalic();
  68. int align = c->getTextAlign();
  69. int antialiased = c->getTextAntialias();
  70. ARGB32 color = c->getTextColor();
  71. ARGB32 bkcolor = c->getTextBkColor();
  72. int xoffset=0, yoffset=0;
  73. c->getOffsets(&xoffset, &yoffset);
  74. /* if (!f->isBitmap() && _intVal(Main::enumRootCfgItem(0), "Force antialias on all TTF"))
  75. antialiased = 1;*/
  76. switch (style)
  77. {
  78. case WA_FONT_TEXTOUT_NORMAL:
  79. f->textOut(c, x, y, txt, size, bold, opaque, underline, italic, color, bkcolor, xoffset, yoffset, antialiased);
  80. break;
  81. case WA_FONT_TEXTOUT_RECT:
  82. f->textOut(c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased);
  83. break;
  84. case WA_FONT_TEXTOUT_ELLIPSED:
  85. f->textOutEllipsed(c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased);
  86. break;
  87. case WA_FONT_TEXTOUT_WRAPPED:
  88. f->textOutWrapped(c, x, y, w, h, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased);
  89. break;
  90. case WA_FONT_TEXTOUT_WRAPPEDPATHED:
  91. f->textOutWrappedPathed(c, x, y, w, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased);
  92. break;
  93. case WA_FONT_TEXTOUT_CENTERED:
  94. RECT r;
  95. r.left = x;
  96. r.top = y;
  97. r.right = w;
  98. r.bottom = h;
  99. f->textOutCentered(c, &r, txt, size, bold, opaque, underline, italic, align, color, bkcolor, xoffset, yoffset, antialiased);
  100. break;
  101. }
  102. }
  103. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  104. int Font::dispatchGetInfo(ifc_canvas *c, const wchar_t *font, int infoid, const wchar_t *txt, int *w, int *h)
  105. {
  106. int isoverride = 0;
  107. if (WASABI_API_APP->main_isShuttingDown()) return 0;
  108. // mig: Let's not crash if we want to see how big a NULL pointer is.
  109. if (txt == NULL) {
  110. if ( infoid == WA_FONT_GETINFO_WIDTHHEIGHT ) {
  111. if (w != NULL) {
  112. *w = 0;
  113. }
  114. if (h != NULL) {
  115. *h = 0;
  116. }
  117. }
  118. return 0;
  119. }
  120. int size = c->getTextSize();
  121. svc_font *f = requestSkinFont(font, &size);
  122. ASSERT(f != NULL);
  123. // After we get the font we want, check to see if it is bitmap.
  124. // If bitmap fonts are disallowed, use the truetype override font.
  125. if (f->isBitmap() && useTrueTypeOverride(txt))
  126. {
  127. int gotdefault = 0;
  128. svc_font *ttFont = requestSkinFont(getTrueTypeOverride(), &size, &gotdefault);
  129. if (ttFont != NULL)
  130. {
  131. if (!gotdefault)
  132. isoverride = 1;
  133. f = ttFont;
  134. }
  135. }
  136. if (isoverride) {
  137. double f = (double)getTrueTypeOverrideScale() / 100.0f;
  138. size = (int)(size*f);
  139. }
  140. int bold = c->getTextBold();
  141. int underline = c->getTextUnderline();
  142. int italic = c->getTextItalic();
  143. int antialiased = c->getTextAntialias();
  144. switch (infoid) {
  145. case WA_FONT_GETINFO_WIDTH:
  146. return f->getTextWidth(c, txt, size, bold, underline, italic, antialiased);
  147. case WA_FONT_GETINFO_HEIGHT:
  148. return f->getTextHeight(c, txt, size, bold, underline, italic, antialiased);
  149. case WA_FONT_GETINFO_WIDTHHEIGHT:
  150. f->getTextExtent(c, txt, w, h, size, bold, underline, italic, antialiased);
  151. return 0;
  152. }
  153. return 0;
  154. }
  155. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  156. // Install a truetype font from its filename and associate a script_id to it
  157. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  158. svc_font *Font::installTrueTypeFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int scriptid, int allowmapping, int isttfreload) {
  159. if (!isttfreload)
  160. {
  161. FontDef *fd = new FontDef;
  162. fd->filename = filename;
  163. fd->path = path;
  164. fd->id = id;
  165. fd->scriptid = scriptid;
  166. fd->isbitmap = 0;
  167. fd->allowmapping = allowmapping;
  168. fontdefs.addItem(fd);
  169. }
  170. StringW file;
  171. OSFILETYPE ff=OPEN_FAILED;
  172. if (wcschr(filename, ':'))
  173. ff = WFOPEN(filename, WF_READONLY_BINARY);
  174. if (ff == OPEN_FAILED)
  175. {
  176. file = StringPathCombine(path, filename);
  177. ff = WFOPEN(file, WF_READONLY_BINARY);
  178. }
  179. #ifdef WASABI_COMPILE_SKIN
  180. if (ff == OPEN_FAILED)
  181. {
  182. file = StringPathCombine(SkinParser::getXmlRootPath(), filename);
  183. ff = WFOPEN(file, WF_READONLY_BINARY);
  184. if (ff == OPEN_FAILED)
  185. {
  186. file = StringPathCombine(Skin::getDefaultSkinPath(), filename);
  187. ff = WFOPEN(file, WF_READONLY_BINARY);
  188. if (ff == OPEN_FAILED)
  189. {
  190. DebugString("Font not found %s\n", filename);
  191. // todo: do something if still not found
  192. }
  193. }
  194. }
  195. #endif
  196. if (ff == OPEN_FAILED) {
  197. DebugString("Could not install font %s\n", filename);
  198. return 0;
  199. }
  200. StringW fs = filename;
  201. wchar_t *p = wcschr(fs.getNonConstVal(), '.');
  202. if (p)
  203. *p = 0;
  204. PathParserW pp(fs);
  205. fs = pp.getLastString();
  206. svc_font *f = newTrueTypeFont();
  207. if (f && f->addFontResource( ff, fs) )
  208. {
  209. f->setFontId(id);
  210. f->setScriptId(scriptid);
  211. fontlist.addItem(f);
  212. } else {
  213. DebugString("font.cpp ====== CAN'T LOAD FONT FILE.\n");
  214. }
  215. FCLOSE(ff);
  216. return f;
  217. }
  218. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  219. // Uninstall all installed fonts
  220. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  221. void Font::uninstallAll(int ttfreload) {
  222. int i;
  223. // delete all by hand
  224. for (i = 0; i < fontlist.getNumItems(); i++) {
  225. svc_font *f = fontlist.enumItem(i);
  226. if (ttfreload && f->isBitmap()) continue;
  227. deleteFont(f);
  228. fontlist.removeByPos(i);
  229. i--;
  230. }
  231. if (!ttfreload) fontdefs.deleteAll();
  232. }
  233. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  234. // Uninstall by scriptid
  235. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  236. void Font::uninstallByScriptId(int scriptid) {
  237. for (int i=0;i<fontlist.getNumItems();i++) {
  238. svc_font *f = fontlist.enumItem(i);
  239. if (f->getScriptId() == scriptid) {
  240. fontlist.removeByPos(i);
  241. deleteFont(f);
  242. i--;
  243. }
  244. }
  245. for (int i=0;i<fontdefs.getNumItems();i++) {
  246. FontDef *fd = fontdefs.enumItem(i);
  247. if (fd->scriptid == scriptid) {
  248. fontdefs.removeByPos(i);
  249. delete fd;
  250. i--;
  251. }
  252. }
  253. }
  254. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  255. // Install a bitmap font and associates a script_id to it
  256. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  257. void Font::installBitmapFont(const wchar_t *filename, const wchar_t *path, const wchar_t *id, int cw, int ch, int hs, int vs, int scriptid, int allowmapping)
  258. {
  259. FontDef *fd = new FontDef;
  260. fd->filename = filename;
  261. fd->path = path;
  262. fd->id = id;
  263. fd->scriptid = scriptid;
  264. fd->isbitmap = 1;
  265. fd->allowmapping = allowmapping;
  266. fontdefs.addItem(fd);
  267. BitmapFont *f = new BitmapFont;
  268. f->setFontBitmap(filename, path);
  269. f->setFontId(id);
  270. f->setFontMetrics(cw, ch, hs, vs);
  271. f->setScriptId(scriptid);
  272. fontlist.addItem(f);
  273. }
  274. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  275. // Requests a Font* from its id
  276. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  277. svc_font *Font::requestSkinFont(const wchar_t *id, int *size, int *gotdefault)
  278. {
  279. if (gotdefault) *gotdefault = 0;
  280. int oldsize = size ? *size : -1;
  281. const wchar_t *mapped_id = getFontMapping(id, size);
  282. if (mapped_id != NULL)
  283. id = mapped_id;
  284. // First try to get a font by that id
  285. foreach_reverse(fontlist)
  286. const wchar_t *thisid = fontlist.getfor()->getFontId();
  287. if (thisid && !WCSICMP(thisid, id))
  288. return fontlist.getfor();
  289. endfor
  290. // if it wasnt found, try to load a wa-installed ttfont with this face name
  291. foreach_reverse(fontlist)
  292. const wchar_t *facename=fontlist.getfor()->getFaceName();
  293. if (facename && !WCSICMP(facename, id)) return fontlist.getfor();
  294. endfor
  295. // not found, try to reload it front the list of fonts defined by the skin
  296. foreach(fontdefs)
  297. FontDef *fd = fontdefs.getfor();
  298. if (!WCSICMP(fd->id, id))
  299. {
  300. if (!fd->isbitmap)
  301. {
  302. svc_font *f = installTrueTypeFont(fd->filename, fd->path, fd->id, fd->scriptid, fd->allowmapping, 1);
  303. if (f) return f;
  304. }
  305. }
  306. endfor;
  307. /*
  308. for (i=fontlist.getNumItems()-1;i>=0;i--) {
  309. const char *thisid = fontlist.enumItem(i)->getFontId();
  310. if (thisid && STRCASEEQL(thisid, "wasabi.font.ttf.default" ))
  311. return fontlist.enumItem(i);
  312. }
  313. */
  314. // not found ? try to find it in the windows fonts directory
  315. {
  316. wchar_t *fp = WMALLOC(WA_MAX_PATH);
  317. Wasabi::Std::getFontPath(WA_MAX_PATH, fp);
  318. StringW file;
  319. file.own(fp);
  320. // FREE(fp); // benski> no need because we now own it
  321. file.AppendPath(StringPrintfW(L"%s%s", id, WCSCASESTR(id, L".ttf") == NULL ? L".ttf":L""));
  322. if (!WACCESS(file, 0))
  323. {
  324. svc_font *f = newTrueTypeFont();
  325. f->setFontFace(id);
  326. f->setFontId(id);
  327. OSFILETYPE ff = WFOPEN(file, WF_READONLY_BINARY);
  328. if (ff != OPEN_FAILED)
  329. {
  330. if (f->addFontResource(ff, id))
  331. {
  332. DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. USING WIN FONT FILE:\n%s\n", id, file.getValue());
  333. fontlist.addItem(f);
  334. }
  335. } else {
  336. DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. CANNOT OPEN WIN FONT FILE:\n%s\n", id, file.getValue());
  337. delete f;
  338. f = NULL;
  339. }
  340. return f;
  341. }
  342. }
  343. // not found ? ask the Std:: interface for the folder and the
  344. // default fontname (ie: one you know will always be in the OS)
  345. svc_font *f = newTrueTypeFont();
  346. if (f) {
  347. if (gotdefault) *gotdefault = 1;
  348. if (oldsize != -1 && size) {
  349. *size = oldsize;
  350. double f = (double)Wasabi::Std::getDefaultFontScale() / 100.0;
  351. *size = (int)(*size*f);
  352. }
  353. // Query Std:: and build the path to the default font file.
  354. wchar_t *fontPath = WMALLOC(WA_MAX_PATH);
  355. Wasabi::Std::getFontPath(WA_MAX_PATH, fontPath);
  356. wchar_t fontFile[WA_MAX_PATH] = {0};
  357. Wasabi::Std::getDefaultFont(WA_MAX_PATH, fontFile);
  358. StringW defaultFont;
  359. defaultFont.own(fontPath);
  360. defaultFont.AppendPath(fontFile);
  361. // FREE(fontFile);
  362. StringW fs = defaultFont;
  363. wchar_t *p = wcschr(fs.getNonConstVal(), '.');
  364. if (p) *p = 0;
  365. PathParserW pp(fs);
  366. fs = pp.getLastString();
  367. f->setFontFace(fs);
  368. f->setFontId(id);
  369. // Open it and load it as the font resource.
  370. OSFILETYPE ff = WFOPEN(defaultFont, WF_READONLY_BINARY);
  371. if (ff != OPEN_FAILED) {
  372. if (f->addFontResource(ff, fs))
  373. {
  374. DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. USING DEFAULT FONT FILE:\n%s\n", id, defaultFont);
  375. fontlist.addItem(f);
  376. }
  377. } else {
  378. DebugStringW(L"font.cpp ====== FONT FOR ID=%s NOT FOUND. CANNOT OPEN FONT FILE:\n%s\n", id, defaultFont);
  379. delete f;
  380. f = NULL;
  381. }
  382. } else {
  383. DebugString("font.cpp ====== CAN'T GET NEW FONT FILE.\n");
  384. delete f;
  385. f = NULL;
  386. }
  387. #ifdef _WIN32
  388. if (f == NULL) {
  389. // not found :((((( grab the default font data and use this, whatever it is
  390. f = newTrueTypeFont();
  391. if (f)
  392. {
  393. HDC dc = GetDC(GetDesktopWindow());
  394. HDC dc2 = CreateCompatibleDC(dc);
  395. SelectObject(dc2, GetStockObject(DEFAULT_GUI_FONT));
  396. int datalen = GetFontData(dc2, 0, 0, NULL, 0);
  397. if (datalen > 0) {
  398. void *mem = WASABI_API_MEMMGR->sysMalloc(datalen+1); // freed by the service !!
  399. ASSERT(mem != NULL);
  400. GetFontData(dc2, 0, 0, mem, datalen);
  401. f->setFontFace(id);
  402. f->setFontId(id);
  403. f->addFontResource2(mem, datalen, id);
  404. ReleaseDC(GetDesktopWindow(), dc);
  405. DeleteDC(dc2);
  406. fontlist.addItem(f);
  407. return f;
  408. }
  409. delete f;
  410. f = NULL;
  411. }
  412. }
  413. #else
  414. #warning port me
  415. #endif
  416. if (f == NULL) {
  417. // ok, NOW I'm getting pissed
  418. wchar_t fp[WA_MAX_PATH] = {0};
  419. Wasabi::Std::getFontPath(WA_MAX_PATH, fp);
  420. #ifdef _WIN32
  421. Wasabi::Std::messageBox(StringPrintfW(L"Fatal error trying to load truetype fonts.\n\nYou need arial.ttf at the very least, but it does not appear to be in %s", fp), L"Fatal Error", MB_ICONERROR);
  422. #else
  423. #warning port me
  424. #endif
  425. }
  426. //if (f == NULL) DebugString("font.cpp ====== FALLBACK FOR FONT %s CANNOT BE FOUND IN OUR LISTS.\n",f->getFontId());
  427. return f;
  428. }
  429. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  430. // Intelligently delete the font
  431. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  432. void Font::deleteFont(svc_font *f)
  433. {
  434. if (f)
  435. {
  436. if (f->isBitmap())
  437. {
  438. delete static_cast<BitmapFont *>(f); // we delete our own bitmap fonts.
  439. }
  440. else
  441. {
  442. SvcEnum::release(f);
  443. }
  444. }
  445. }
  446. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  447. // Intelligently make a new truetype font from the service interfaces
  448. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  449. svc_font *Font::newTrueTypeFont()
  450. {
  451. /*#ifdef WASABI_COMPILE_CONFIG
  452. const GUID options_guid =
  453. { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } };
  454. CfgItem *options = WASABI_API_CONFIG->config_getCfgItemByGuid(options_guid);
  455. #endif*/
  456. svc_font *retval = NULL;
  457. const wchar_t *name = NULL;
  458. #ifdef WASABI_COMPILE_CONFIG
  459. //const wchar_t *attr = L"Font Renderer";
  460. // First, try to find a font service that matches the attribute.
  461. // if (options) {
  462. // char buf[256]; // WHEEE for stack arrays
  463. // if (options->getData(attr, buf, sizeof buf)) {
  464. if (WASABI_API_SKIN->skin_getVersion() >= 1.3) // hardcode win32 renderer for v1.3+ skins
  465. retval = FontSvcEnum(L"Win32 TextOut").getFirst();
  466. else
  467. retval = FontSvcEnum(cfg_options_fontrenderer.getValue()).getFirst();
  468. #else
  469. #ifndef WASABI_FONT_RENDERER
  470. #error You need to define WASABI_FONT_RENDERER (ie: #define WASABI_FONT_RENDERER "Freetype")
  471. #endif
  472. retval = FontSvcEnum(WASABI_FONT_RENDERER).getFirst();
  473. #endif
  474. #ifdef WASABI_COMPILE_CONFIG
  475. // }
  476. // }
  477. // If we can't find one, fallback and just take the first.
  478. if (!retval)
  479. {
  480. retval = FontSvcEnum().getFirst();
  481. if (retval != NULL)
  482. name = retval->getFontSvcName();
  483. }
  484. // If we had to fallback, remember the fallback service in the attribute.
  485. if (name/* && options*/)
  486. {
  487. //options->setData(attr, name);
  488. cfg_options_fontrenderer.setValue(name);
  489. }
  490. #endif
  491. return retval;
  492. }
  493. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  494. // Test whether to forbid bitmap fonts.
  495. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  496. int Font::useTrueTypeOverride(const wchar_t *txt)
  497. {
  498. if (cfg_options_no7bitsttfoverride.getValueAsInt())
  499. {
  500. const wchar_t *p = (const wchar_t *)txt;
  501. while (p && *p)
  502. {
  503. // TODO: benski> some characters above 127 can be handled by the bitmap fonts - it might be worth checking those explicitly
  504. if (*p & 0xFF80)
  505. break;
  506. p++;
  507. }
  508. if (!*p) return 0;
  509. }
  510. #ifdef WASABI_COMPILE_CONFIG
  511. /* // {280876CF-48C0-40bc-8E86-73CE6BB462E5}
  512. const GUID options_guid =
  513. { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } };
  514. return !_intVal(WASABI_API_CONFIG->config_getCfgItemByGuid(options_guid), "Use bitmap fonts (no international support)", 1);*/
  515. return !cfg_options_allowbitmapfonts.getValueAsInt();
  516. #else
  517. return WASABI_FONT_TTFOVERRIDE;
  518. #endif
  519. }
  520. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  521. // Get the font to be used to override bitmap fonts.
  522. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  523. const wchar_t *Font::getTrueTypeOverride()
  524. {
  525. #ifdef WASABI_COMPILE_CONFIG
  526. return cfg_options_ttfoverridefont.getValue();
  527. #else
  528. return L"Arial";
  529. #warning TODO
  530. #endif
  531. }
  532. int Font::getTrueTypeOverrideScale()
  533. {
  534. #ifdef WASABI_COMPILE_CONFIG
  535. return cfg_options_ttfoverridescale.getValueAsInt();
  536. #else
  537. return 1;
  538. #warning TODO
  539. #endif
  540. }
  541. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  542. // Returns the font mapping for this font & skin, if font mapper is on and if there is a mapping, otherwise returns null
  543. // -------------------------------------------------------------------------------------------------------------------------------------------------------------
  544. const wchar_t *Font::getFontMapping(const wchar_t *id, int *size)
  545. {
  546. if (cfg_options_usefontmapper.getValueAsInt())
  547. {
  548. wchar_t t[256]=L"";
  549. StringW tmp;
  550. tmp.printf(L"Skin:%s/Font Mapping/%s",WASABI_API_SKIN->getSkinName(), id);
  551. WASABI_API_CONFIG->getStringPrivate(tmp, t, 256, L"");
  552. tmp.printf(L"Skin:%s/Font Mapping/%s_scale",WASABI_API_SKIN->getSkinName(), id);
  553. int v = WASABI_API_CONFIG->getIntPrivate(tmp, -1);
  554. if (!*t)
  555. {
  556. tmp.printf(L"Font Mapping/%s", id);
  557. WASABI_API_CONFIG->getStringPrivate(tmp, t, 256, L"");
  558. tmp.printf(L"Font Mapping/%s_scale", id);
  559. v = WASABI_API_CONFIG->getIntPrivate(tmp, -1);
  560. }
  561. mapping = t;
  562. if (mapping.isempty()) return NULL;
  563. if (size != NULL)
  564. {
  565. if (v != -1)
  566. {
  567. double f = (double)v / 100.0;
  568. *size = (int)((double)*size * f);
  569. }
  570. }
  571. return mapping;
  572. }
  573. return NULL;
  574. }
  575. StringW Font::mapping;