/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#ifndef OSGTEXT_FONT
#define OSGTEXT_FONT 1

#include <string>
#include <istream>

#include <osg/TexEnv>
#include <osgText/Glyph>
#include <osgDB/Options>

#include <OpenThreads/Mutex>

namespace osgText {

// forward declare Font
class Font;

#ifdef OSG_PROVIDE_READFILE
/** Read a font from specified file. The filename may contain a path.
  * It will search for the font file in the following places in this order:
  * - In the current directory
  * - All paths defined in OSG_FILE_PATH or OSGFILEPATH environment variable
  * - Filename with path stripped: In the current directory
  * - Filename with path stripped: All paths defined in OSG_FILE_PATH or OSGFILEPATH
  *
  * Then the file will be searched in OS specific directories in the following order:
  * - Again in the current directory
  * - Windows: In C:/winnt/fonts
  * - Windows: In C:/windows/fonts
  * - Windows: In the fonts directory of the windows install directory
  * - Other OS: In /usr/share/fonts/ttf
  * - Other OS: In /usr/share/fonts/ttf/western
  * - Other OS: In /usr/share/fonts/ttf/decoratives
  *
  * If the given file could not be found, the path part will be stripped and
  * the file will be searched again in the OS specific directories.
  */
extern OSGTEXT_EXPORT Font* readFontFile(const std::string& filename, const osgDB::Options* userOptions = 0);

/** read a font from specified stream.*/
extern OSGTEXT_EXPORT Font* readFontStream(std::istream& stream, const osgDB::Options* userOptions = 0);
#endif

extern OSGTEXT_EXPORT osg::ref_ptr<Font> readRefFontFile(const std::string& filename, const osgDB::Options* userOptions = 0);

extern OSGTEXT_EXPORT osg::ref_ptr<Font> readRefFontStream(std::istream& stream, const osgDB::Options* userOptions = 0);

extern OSGTEXT_EXPORT std::string findFontFile(const std::string& str);

/** Pure virtual base class for fonts.
  * Concrete implementation are the DefaultFont found in src/osgText/Defa                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      