EmbeddedFontImpl.h

Go to the documentation of this file.
00001 
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #ifndef _DWFTK_EMBEDDED_FONT_IMPL_WIN32_H
00020 #define _DWFTK_EMBEDDED_FONT_IMPL_WIN32_H
00021 
00022 
00027 
00028 #include "dwf/publisher/EmbeddedFont.h"
00029 
00030 
00031 #ifdef  _DWFCORE_WIN32_SYSTEM
00032 
00033 #include "dwf/publisher/win32/t2embapi.h"
00034 
00035 
00036 #include "dwfcore/TempFile.h"
00037 #include "dwfcore/BufferInputStream.h"
00038 #include "dwfcore/BufferOutputStream.h"
00039 using namespace DWFCore;
00040 
00041 
00042 #include "dwf/package/FontResource.h"
00043 
00044 
00045 namespace DWFToolkit
00046 {
00047 
00057 class DWFEmbeddedFontImpl_Win32 : public DWFEmbeddedFontImpl
00058                                   _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00059 {
00060 
00061 public:
00062 
00063 #ifndef DWFTK_READ_ONLY
00064 
00090     _DWFTK_API
00091     DWFEmbeddedFontImpl_Win32( HFONT    hFont,
00092                                size_t   nHeapLimit = DWFTK_EMBEDDED_FONT_HEAP_LIMIT )
00093         throw();
00094 
00095 #endif
00096 
00106     _DWFTK_API
00107     DWFEmbeddedFontImpl_Win32( DWFFontResource& rFontResource )
00108         throw();
00109 
00115     _DWFTK_API
00116     virtual ~DWFEmbeddedFontImpl_Win32()
00117         throw();
00118 
00119 #ifndef DWFTK_READ_ONLY
00120 
00124     _DWFTK_API
00125     void embed()
00126         throw( DWFException );
00127 
00131     _DWFTK_API
00132     void addCharacters( const DWFString& rCharacters )
00133         throw( DWFException );
00134 
00138     _DWFTK_API
00139     DWFInputStream* getInputStream()
00140         throw( DWFException );
00141 
00145     _DWFTK_API
00146     const DWFString& getFaceName()
00147         throw( DWFException );
00148 
00152     _DWFTK_API
00153     const DWFString& getLogfontName()
00154         throw( DWFException );
00155 
00156 
00157 #endif
00158 
00162     _DWFTK_API
00163     int getRequest()
00164         throw( DWFException );
00165 
00169     _DWFTK_API
00170     DWFFontResource::tePrivilege getPrivilege()
00171         throw( DWFException );
00172 
00176     _DWFTK_API
00177     DWFFontResource::teCharacterCode getCharacterCode()
00178         throw( DWFException );
00179 
00183     _DWFTK_API
00184     void load( bool bForceRename = true )
00185         throw ( DWFException );
00186 
00190     _DWFTK_API
00191     const DWFString& loadedFontName() const
00192         throw();
00193 
00197     _DWFTK_API
00198     void unload()
00199         throw ( DWFException );
00200 
00201 private:
00202 
00203 #ifndef DWFTK_READ_ONLY
00204 
00205     //
00206     // streams the EFF to either the heap buffer or temp file
00207     //
00208     void _serializeFont( HDC hDC )
00209         throw( DWFException );
00210 
00211     //
00212     // TTEmbedFont callback
00213     //
00214     static unsigned long _WriteFontBuffer( void*               pStream,
00215                                            const void*         pBuffer,
00216                                            const unsigned long nBytesToWrite )
00217         throw( DWFException );
00218 
00219 #endif
00220 
00221     //
00222     // TTEmbedFont callback
00223     //
00224     static unsigned long _ReadFontBuffer( void*               pStream,
00225                                           void*               pBuffer,
00226                                           const unsigned long nBytesToRead )
00227         throw( DWFException );
00228 
00229     //
00230     // Loads the font embedding library 
00231     //
00232     static void _loadFontLibrary( void );
00233 
00234 private:
00235 
00236 #ifndef DWFTK_READ_ONLY
00237     size_t                  _nHeapLimit;
00238 
00239     HFONT                   _hFont;
00240     DWFString               _zFaceName;
00241     DWFString               _zLogfontName;
00242     DWFTempFile*            _pFontFile;
00243 
00244     bool                    _abCodePoints[65536];
00245     unsigned short          _nCodePoints;
00246     unsigned short*         _pSparseCharacters;
00247 #endif
00248 
00249     unsigned long           _nPriv;
00250     unsigned long           _nRequest;
00251     unsigned long           _nCharacterCode;
00252 
00253     DWFBufferOutputStream*  _pFontOutputStream;
00254     DWFFontResource*        _pFontResource;
00255     DWFInputStream*         _pFontInputStream;
00256     DWFBufferInputStream*   _pReadAheadStream;
00257     HANDLE                  _hLoadedFont;
00258     DWFString               _zLoadedFontName;
00259 
00260     static HINSTANCE                _khLib;
00261     static int                      _knLibRef;
00262     static const char*              _kz_T2Embed;
00263     static fpTTEmbedFont            _kfpTTEmbedFont;
00264     static fpTTLoadEmbeddedFont     _kfpTTLoadEmbeddedFont;
00265     static fpTTDeleteEmbeddedFont   _kfpTTDeleteEmbeddedFont;
00266 
00267 private:
00268 
00269     DWFEmbeddedFontImpl_Win32( const DWFEmbeddedFontImpl_Win32& );
00270     DWFEmbeddedFontImpl_Win32& operator=( const DWFEmbeddedFontImpl_Win32& );
00271 };
00272 
00273 
00274     //
00275     // required for win32 dll external linkage
00276     //
00277 #ifndef DWFTK_STATIC
00278 
00279 _declspec(selectany) const char* DWFEmbeddedFontImpl_Win32::_kz_T2Embed = /*NOXLATE*/"t2embed.dll";
00280 
00281 #endif
00282 
00283 };
00284 
00285 
00286 #else
00287 #error  This is a Win32 header file and is incompatible with your current system configuration
00288 #endif  
00289 
00290 #endif
00291 

Generated on Tue Jan 6 22:40:03 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5