PageRenderTime 39ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llrender/llfontregistry.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 112 lines | 56 code | 22 blank | 34 comment | 0 complexity | 9e8f5972c5ea4389acd77ae9d2bd5291 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfontregistry.h
  3. * @author Brad Payne
  4. * @brief Storage for fonts.
  5. *
  6. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #ifndef LL_LLFONTREGISTRY_H
  28. #define LL_LLFONTREGISTRY_H
  29. #include "llxmlnode.h"
  30. class LLFontGL;
  31. typedef std::vector<std::string> string_vec_t;
  32. class LLFontDescriptor
  33. {
  34. public:
  35. LLFontDescriptor();
  36. LLFontDescriptor(const std::string& name, const std::string& size, const U8 style);
  37. LLFontDescriptor(const std::string& name, const std::string& size, const U8 style, const string_vec_t& file_names);
  38. LLFontDescriptor normalize() const;
  39. bool operator<(const LLFontDescriptor& b) const;
  40. bool isTemplate() const;
  41. const std::string& getName() const { return mName; }
  42. void setName(const std::string& name) { mName = name; }
  43. const std::string& getSize() const { return mSize; }
  44. void setSize(const std::string& size) { mSize = size; }
  45. const std::vector<std::string>& getFileNames() const { return mFileNames; }
  46. std::vector<std::string>& getFileNames() { return mFileNames; }
  47. const U8 getStyle() const { return mStyle; }
  48. void setStyle(U8 style) { mStyle = style; }
  49. private:
  50. std::string mName;
  51. std::string mSize;
  52. string_vec_t mFileNames;
  53. U8 mStyle;
  54. };
  55. class LLFontRegistry
  56. {
  57. public:
  58. // create_gl_textures - set to false for test apps with no OpenGL window,
  59. // such as llui_libtest
  60. LLFontRegistry(const string_vec_t& xui_paths,
  61. bool create_gl_textures);
  62. ~LLFontRegistry();
  63. // Load standard font info from XML file(s).
  64. bool parseFontInfo(const std::string& xml_filename);
  65. bool initFromXML(LLXMLNodePtr node);
  66. // Clear cached glyphs for all fonts.
  67. void reset();
  68. // Destroy all fonts.
  69. void clear();
  70. // GL cleanup
  71. void destroyGL();
  72. LLFontGL *getFont(const LLFontDescriptor& desc);
  73. const LLFontDescriptor *getMatchingFontDesc(const LLFontDescriptor& desc);
  74. const LLFontDescriptor *getClosestFontTemplate(const LLFontDescriptor& desc);
  75. bool nameToSize(const std::string& size_name, F32& size);
  76. void dump();
  77. const string_vec_t& getUltimateFallbackList() const;
  78. private:
  79. LLFontGL *createFont(const LLFontDescriptor& desc);
  80. typedef std::map<LLFontDescriptor,LLFontGL*> font_reg_map_t;
  81. typedef std::map<std::string,F32> font_size_map_t;
  82. // Given a descriptor, look up specific font instantiation.
  83. font_reg_map_t mFontMap;
  84. // Given a size name, look up the point size.
  85. font_size_map_t mFontSizes;
  86. string_vec_t mUltimateFallbackList;
  87. string_vec_t mXUIPaths;
  88. bool mCreateGLTextures;
  89. };
  90. #endif // LL_LLFONTREGISTRY_H