PageRenderTime 43ms CodeModel.GetById 18ms app.highlight 19ms 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
  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
 28#ifndef LL_LLFONTREGISTRY_H
 29#define LL_LLFONTREGISTRY_H
 30
 31#include "llxmlnode.h"
 32
 33class LLFontGL;
 34
 35typedef std::vector<std::string> string_vec_t;
 36
 37class LLFontDescriptor
 38{
 39public:
 40	LLFontDescriptor();
 41	LLFontDescriptor(const std::string& name, const std::string& size, const U8 style);
 42	LLFontDescriptor(const std::string& name, const std::string& size, const U8 style, const string_vec_t& file_names);
 43	LLFontDescriptor normalize() const;
 44
 45	bool operator<(const LLFontDescriptor& b) const;
 46
 47	bool isTemplate() const;
 48	
 49	const std::string& getName() const { return mName; }
 50	void setName(const std::string& name) { mName = name; }
 51	const std::string& getSize() const { return mSize; }
 52	void setSize(const std::string& size) { mSize = size; }
 53	const std::vector<std::string>& getFileNames() const { return mFileNames; }
 54	std::vector<std::string>& getFileNames() { return mFileNames; }
 55	const U8 getStyle() const { return mStyle; }
 56	void setStyle(U8 style) { mStyle = style; }
 57
 58private:
 59	std::string mName;
 60	std::string mSize;
 61	string_vec_t mFileNames;
 62	U8 mStyle;
 63};
 64
 65class LLFontRegistry
 66{
 67public:
 68	// create_gl_textures - set to false for test apps with no OpenGL window,
 69	// such as llui_libtest
 70	LLFontRegistry(const string_vec_t& xui_paths,
 71		bool create_gl_textures);
 72	~LLFontRegistry();
 73
 74	// Load standard font info from XML file(s).
 75	bool parseFontInfo(const std::string& xml_filename); 
 76	bool initFromXML(LLXMLNodePtr node);
 77
 78	// Clear cached glyphs for all fonts.
 79	void reset();
 80
 81	// Destroy all fonts.
 82	void clear();
 83
 84	// GL cleanup
 85	void destroyGL();
 86		
 87	LLFontGL *getFont(const LLFontDescriptor& desc);
 88	const LLFontDescriptor *getMatchingFontDesc(const LLFontDescriptor& desc);
 89	const LLFontDescriptor *getClosestFontTemplate(const LLFontDescriptor& desc);
 90
 91	bool nameToSize(const std::string& size_name, F32& size);
 92
 93	void dump();
 94	
 95	const string_vec_t& getUltimateFallbackList() const;
 96
 97private:
 98	LLFontGL *createFont(const LLFontDescriptor& desc);
 99	typedef std::map<LLFontDescriptor,LLFontGL*> font_reg_map_t;
100	typedef std::map<std::string,F32> font_size_map_t;
101
102	// Given a descriptor, look up specific font instantiation.
103	font_reg_map_t mFontMap;
104	// Given a size name, look up the point size.
105	font_size_map_t mFontSizes;
106
107	string_vec_t mUltimateFallbackList;
108	string_vec_t mXUIPaths;
109	bool mCreateGLTextures;
110};
111
112#endif // LL_LLFONTREGISTRY_H