From Mathias Fröhlich, txf plugin for reading .txf textured texture files.

This commit is contained in:
Robert Osfield
2007-01-08 12:04:04 +00:00
parent fdc6e675aa
commit b9f629f0cb
7 changed files with 585 additions and 2 deletions

View File

@@ -66,16 +66,15 @@ endif
PLUGIN_DIRS = \
3dc \
bsp \
ac3d \
bmp \
bsp \
dds \
directx \
dw \
dxf \
ESRIShape \
flt \
OpenFlight \
hdr \
ive \
lib3ds \
@@ -86,6 +85,7 @@ PLUGIN_DIRS = \
net \
normals \
obj \
OpenFlight \
osg \
osga \
osgFX \
@@ -102,6 +102,7 @@ PLUGIN_DIRS = \
tga \
tgz \
trans \
txf \
txp \
zip \

View File

@@ -3135,6 +3135,27 @@ Package=<4>
###############################################################################
Project: "osgPlugin txf"=.\osgPlugins\txf\txf.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Core osg
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgDB
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgText
End Project Dependency
}}}
###############################################################################
Project: "osgPlugin gdal"=.\osgPlugins\gdal\gdal.dsp - Package Owner=<4>
Package=<5>

View File

@@ -0,0 +1,181 @@
# Microsoft Developer Studio Project File - Name="osgPlugin txf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=osgPlugin txf - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "txf.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "txf.mak" CFG="osgPlugin txf - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "osgPlugin txf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "osgPlugin txf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "osgPlugin txf - Win32 Release Static" (based on "Win32 (x86) Static Library")
!MESSAGE "osgPlugin txf - Win32 Debug Static" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "osgPlugin txf - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../bin/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 OpenThreadsWin32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /opt:ref /opt:icf /out:"$(OutDir)/osgdb_txf.dll" /implib:"../../../lib/$(PlatformName)/osgdb_txf.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "osgPlugin txf - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../bin/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /vmg /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 OpenThreadsWin32d.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"$(OutDir)/osgdb_txfd.dll" /pdbtype:sept /implib:"../../../lib/$(PlatformName)/osgdb_txfd.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "osgPlugin txf - Win32 Release Static"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "../../../lib"
# PROP BASE Intermediate_Dir "Release_Static"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../lib/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "WIN32" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgdb_txf_s.lib"
# SUBTRACT LIB32 /nodefaultlib
!ELSEIF "$(CFG)" == "osgPlugin txf - Win32 Debug Static"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "../../../lib"
# PROP BASE Intermediate_Dir "Debug_Static"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../lib/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /vmg /GR /GX /Z7 /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_MBCS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgdb_txfd_s.lib"
# SUBTRACT LIB32 /nodefaultlib
!ENDIF
# Begin Target
# Name "osgPlugin txf - Win32 Release"
# Name "osgPlugin txf - Win32 Debug"
# Name "osgPlugin txf - Win32 Release Static"
# Name "osgPlugin txf - Win32 Debug Static"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\txf\ReaderWriterTXF.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\txf\TXFFont.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\txf\TXFFont.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,15 @@
TOPDIR = ../../..
include $(TOPDIR)/Make/makedefs
CXXFILES =\
TXFFont.cpp\
ReaderWriterTXF.cpp\
LIBS += -losgText -losg -losgDB $(OTHER_LIBS)
TARGET_BASENAME = txf
include $(TOPDIR)/Make/cygwin_plugin_def
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
include $(TOPDIR)/Make/makerules

View File

@@ -0,0 +1,62 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2006 Mathias Froehlich
*
* 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.
*/
#include <fstream>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <osg/Notify>
#include "TXFFont.h"
class ReaderWriterTXF : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "TXF Font Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension, "txf"); // GLU texture fonts
}
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile(file, options);
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream stream;
stream.open(fileName.c_str(), std::ios::in);
if (!stream.is_open()) return ReadResult::FILE_NOT_FOUND;
TXFFont* impl = new TXFFont(fileName);
osg::ref_ptr<osgText::Font> font = new osgText::Font(impl);
if (!impl->loadFont(stream)) return ReadResult::FILE_NOT_HANDLED;
return font.release();
}
virtual ReadResult readObject(std::istream& stream, const osgDB::ReaderWriter::Options*) const
{
TXFFont* impl = new TXFFont("streamed font");
osg::ref_ptr<osgText::Font> font = new osgText::Font(impl);
if (!impl->loadFont(stream)) return ReadResult::FILE_NOT_HANDLED;
return font.release();
}
};
// now register with Registry to instantiate the above
// reader/writer.
osgDB::RegisterReaderWriterProxy<ReaderWriterTXF> g_readerWriter_TXF_Proxy;

View File

@@ -0,0 +1,255 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2006 Mathias Froehlich
*
* 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.
*/
#include "TXFFont.h"
#include <iostream>
#include <osg/Notify>
#define FNT_BYTE_FORMAT 0
#define FNT_BITMAP_FORMAT 1
struct GlyphData {
unsigned short ch;
unsigned char width;
unsigned char height;
signed char x_off;
signed char y_off;
signed char advance;
short x;
short y;
};
static inline void swap(unsigned short& x, bool isSwapped)
{
if (!isSwapped)
return;
x = ((x >> 8) & 0x00FF) | ((x << 8) & 0xFF00);
}
static inline void swap(unsigned& x, bool isSwapped)
{
if (!isSwapped)
return;
x = ((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) | ((x << 24) & 0xFF000000);
}
static inline unsigned char readByte(std::istream& stream)
{
unsigned char x;
stream.readsome(reinterpret_cast<std::istream::char_type*>(&x), 1);
return x;
}
static inline unsigned short readShort(std::istream& stream, bool isSwapped)
{
unsigned short x;
stream.readsome(reinterpret_cast<std::istream::char_type*>(&x), 2);
swap(x, isSwapped);
return x;
}
static inline unsigned readInt(std::istream& stream, bool isSwapped)
{
unsigned x;
stream.readsome(reinterpret_cast<std::istream::char_type*>(&x), 4);
swap(x, isSwapped);
return x;
}
TXFFont::TXFFont(const std::string& filename):
_filename(filename)
{
}
TXFFont::~TXFFont()
{
}
std::string
TXFFont::getFileName() const
{
return _filename;
}
void
TXFFont::setFontResolution(unsigned int, unsigned int)
{
osg::notify(osg::INFO) << "TXFFont::setFontResolution(,) call is ignored." << std::endl;
}
osgText::Font::Glyph*
TXFFont::getGlyph(unsigned int charcode)
{
GlyphMap::iterator i = _chars.find(charcode);
if (i == _chars.end())
return 0;
return i->second.get();
}
bool
TXFFont::hasVertical() const
{
return true;
}
osg::Vec2
TXFFont::getKerning(unsigned int, unsigned int, osgText::KerningType)
{
return osg::Vec2(0, 0);
}
bool
TXFFont::loadFont(std::istream& stream)
{
unsigned char magic[4];
stream.readsome(reinterpret_cast<std::istream::char_type*>(&magic), 4);
if (magic[0] != 0xFF || magic[1] != 't' || magic[2] != 'x' || magic[3] != 'f' )
{
osg::notify(osg::FATAL) << "osgdb_txf: input file \"" << _filename << "\" is not a texture font file!" << std::endl;
return false;
}
// read endianess hint
bool isSwapped = 0x12345678u != readInt(stream, false);
unsigned format = readInt(stream, isSwapped);
unsigned texwidth = readInt(stream, isSwapped);
unsigned texheight = readInt(stream, isSwapped);
unsigned maxheight = readInt(stream, isSwapped);
readInt(stream, isSwapped);
unsigned num_glyphs = readInt(stream, isSwapped);
unsigned maxwidth = 0;
unsigned w = texwidth;
unsigned h = texheight;
std::vector<GlyphData> glyphs;
for (unsigned i = 0; i < num_glyphs; ++i)
{
GlyphData glyphData;
glyphData.ch = readShort(stream, isSwapped);
glyphData.width = readByte(stream);
glyphData.height = readByte(stream);
glyphData.x_off = readByte(stream);
glyphData.y_off = readByte(stream);
glyphData.advance = readByte(stream);
readByte(stream);
glyphData.x = readShort(stream, isSwapped);
glyphData.y = readShort(stream, isSwapped);
maxwidth = std::max(maxwidth, (unsigned)glyphData.width);
glyphs.push_back(glyphData);
}
setFontWidth(maxwidth);
setFontHeight(maxheight);
unsigned ntexels = w * h;
osg::ref_ptr<osg::Image> image = new osg::Image;
image->allocateImage(w, h, 1, GL_ALPHA, GL_UNSIGNED_BYTE);
if (format == FNT_BYTE_FORMAT)
{
stream.read(reinterpret_cast<std::istream::char_type*>(image->data()), ntexels);
if (!stream)
{
osg::notify(osg::FATAL) << "osgdb_txf: unxpected end of file in txf file \"" << _filename << "\"!" << std::endl;
return false;
}
}
else if (format == FNT_BITMAP_FORMAT)
{
unsigned stride = (w + 7) >> 3;
unsigned char *texbitmap = new unsigned char[stride*h] ;
stream.read(reinterpret_cast<std::istream::char_type*>(texbitmap), stride*h);
if (!stream)
{
delete [] texbitmap;
osg::notify(osg::FATAL) << "osgdb_txf: unxpected end of file in txf file \"" << _filename << "\"!" << std::endl;
return false;
}
for (unsigned i = 0; i < h; i++)
{
for (unsigned j = 0; j < w; j++)
{
if (texbitmap[i * stride + (j >> 3)] & (1 << (j & 7)))
{
*image->data(j, i) = 255;
}
else
{
*image->data(j, i) = 0;
}
}
}
delete [] texbitmap;
}
else
{
osg::notify(osg::FATAL) << "osgdb_txf: unxpected txf file!" << std::endl;
return false;
}
for (unsigned i = 0; i < glyphs.size(); ++i)
{
// add the characters ...
osgText::Font::Glyph* glyph = new osgText::Font::Glyph;
unsigned sourceWidth = glyphs[i].width;
unsigned sourceHeight = glyphs[i].height;
unsigned margin = _facade->getGlyphImageMargin();
unsigned width = sourceWidth + 2*margin;
unsigned height = sourceHeight + 2*margin;
glyph->allocateImage(width, height, 1, GL_ALPHA, GL_UNSIGNED_BYTE);
glyph->setInternalTextureFormat(GL_ALPHA);
for (unsigned k = 0; k < width; ++k)
{
for (unsigned l = 0; l < height; ++l)
{
*glyph->data(k, l) = 0;
}
}
for (unsigned k = 0; k < glyphs[i].width; ++k)
{
for (unsigned l = 0; l < glyphs[i].height; ++l)
{
*glyph->data(margin + k, margin + l) = *image->data(glyphs[i].x + k, glyphs[i].y + l);
}
}
float texToVertX = float(glyphs[i].width)/width;
float texToVertY = float(glyphs[i].height)/height;
glyph->setHorizontalAdvance(glyphs[i].advance);
glyph->setHorizontalBearing(osg::Vec2((glyphs[i].x_off - 0.5f)*texToVertX,
(glyphs[i].y_off - 0.5f)*texToVertY));
glyph->setVerticalAdvance(sourceHeight);
glyph->setVerticalBearing(osg::Vec2(glyphs[i].x_off*texToVertX - 0.5f*glyphs[i].advance*texToVertX,
- glyphs[i].height*texToVertY));
_chars[glyphs[i].ch] = glyph;
addGlyph(width, height, glyphs[i].ch, glyph);
}
return true;
}

View File

@@ -0,0 +1,48 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2006 Mathias Froehlich
*
* 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 TXF_FONT
#define TXF_FONT
#include <iosfwd>
#include <string>
#include <map>
#include <osgText/Font>
class TXFFont : public osgText::Font::FontImplementation
{
public:
TXFFont(const std::string& filename);
virtual ~TXFFont();
virtual std::string getFileName() const;
virtual void setFontResolution(unsigned int width, unsigned int height);
virtual osgText::Font::Glyph* getGlyph(unsigned int charcode);
virtual bool hasVertical() const;
virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType);
bool loadFont(std::istream& stream);
protected:
typedef std::map<unsigned int, osg::ref_ptr<osgText::Font::Glyph> > GlyphMap;
std::string _filename;
GlyphMap _chars;
};
#endif