EmscriptenFont.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. // Portions Copyright (c) 2014 James S Urquhart
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //-----------------------------------------------------------------------------
  23. #include "platform/platform.h"
  24. #include "platformEmscripten/platformEmscripten.h"
  25. #include "platformEmscripten/EmscriptenFont.h"
  26. #include "string/Unicode.h"
  27. //------------------------------------------------------------------------------
  28. // New Unicode capable font class.
  29. PlatformFont *createPlatformFont(const char *name, U32 size, U32 charset /* = TGE_ANSI_CHARSET */)
  30. {
  31. return NULL;
  32. }
  33. //------------------------------------------------------------------------------
  34. void PlatformFont::enumeratePlatformFonts( Vector<StringTableEntry>& fonts )
  35. {
  36. }
  37. //------------------------------------------------------------------------------
  38. EmscriptenFont::EmscriptenFont()
  39. {
  40. }
  41. //------------------------------------------------------------------------------
  42. EmscriptenFont::~EmscriptenFont()
  43. {
  44. }
  45. //------------------------------------------------------------------------------
  46. bool EmscriptenFont::create( const char* name, U32 size, U32 charset )
  47. {
  48. return false;
  49. }
  50. //------------------------------------------------------------------------------
  51. bool EmscriptenFont::isValidChar( const UTF8* str ) const
  52. {
  53. // since only low order characters are invalid, and since those characters
  54. // are single codeunits in UTF8, we can safely cast here.
  55. return isValidChar((UTF16)*str);
  56. }
  57. //------------------------------------------------------------------------------
  58. bool EmscriptenFont::isValidChar( const UTF16 character) const
  59. {
  60. // We cut out the ASCII control chars here. Only printable characters are valid.
  61. // 0x20 == 32 == space
  62. if( character < 0x20 )
  63. return false;
  64. return true;
  65. }
  66. //------------------------------------------------------------------------------
  67. PlatformFont::CharInfo& EmscriptenFont::getCharInfo(const UTF8 *str) const
  68. {
  69. return getCharInfo( oneUTF32toUTF16(oneUTF8toUTF32(str,NULL)) );
  70. }
  71. //------------------------------------------------------------------------------
  72. PlatformFont::CharInfo& EmscriptenFont::getCharInfo(const UTF16 character) const
  73. {
  74. // Declare and clear out the CharInfo that will be returned.
  75. static PlatformFont::CharInfo characterInfo;
  76. dMemset(&characterInfo, 0, sizeof(characterInfo));
  77. // Return character information.
  78. return characterInfo;
  79. }