|
Revision 13041, 2.3 kB
(checked in by robert, 15 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #include <osgDB/FileNameUtils> |
|---|
| 15 | #include <osgDB/FileUtils> |
|---|
| 16 | #include <osgDB/fstream> |
|---|
| 17 | #include <osgDB/Registry> |
|---|
| 18 | #include <osg/Notify> |
|---|
| 19 | |
|---|
| 20 | #include "TXFFont.h" |
|---|
| 21 | |
|---|
| 22 | class ReaderWriterTXF : public osgDB::ReaderWriter |
|---|
| 23 | { |
|---|
| 24 | public: |
|---|
| 25 | ReaderWriterTXF() |
|---|
| 26 | { |
|---|
| 27 | supportsExtension("txf","TXF Font format"); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | virtual const char* className() const { return "TXF Font Reader/Writer"; } |
|---|
| 31 | |
|---|
| 32 | virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const |
|---|
| 33 | { |
|---|
| 34 | std::string ext = osgDB::getLowerCaseFileExtension(file); |
|---|
| 35 | if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; |
|---|
| 36 | |
|---|
| 37 | std::string fileName = osgDB::findDataFile(file, options); |
|---|
| 38 | if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; |
|---|
| 39 | |
|---|
| 40 | osgDB::ifstream stream; |
|---|
| 41 | stream.open(fileName.c_str(), std::ios::in | std::ios::binary); |
|---|
| 42 | if (!stream.is_open()) return ReadResult::FILE_NOT_FOUND; |
|---|
| 43 | |
|---|
| 44 | TXFFont* impl = new TXFFont(fileName); |
|---|
| 45 | osg::ref_ptr<osgText::Font> font = new osgText::Font(impl); |
|---|
| 46 | if (!impl->loadFont(stream)) return ReadResult::FILE_NOT_HANDLED; |
|---|
| 47 | return font.release(); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | virtual ReadResult readObject(std::istream& stream, const osgDB::ReaderWriter::Options*) const |
|---|
| 51 | { |
|---|
| 52 | TXFFont* impl = new TXFFont("streamed font"); |
|---|
| 53 | osg::ref_ptr<osgText::Font> font = new osgText::Font(impl); |
|---|
| 54 | if (!impl->loadFont(stream)) return ReadResult::FILE_NOT_HANDLED; |
|---|
| 55 | return font.release(); |
|---|
| 56 | } |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | REGISTER_OSGPLUGIN(txf, ReaderWriterTXF) |
|---|