Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

embedded_font.h

00001 //  Copyright (c) 2001 by Autodesk, Inc.
00002 //
00003 //  By using this code, you are agreeing to the terms and conditions of
00004 //  the License Agreement included in the documentation for this code.
00005 //
00006 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00007 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00008 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00009 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00010 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00011 //
00012 //  Use, duplication, or disclosure by the U.S. Government is subject to
00013 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00014 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00015 //  Data and Computer Software), as applicable.
00016 //
00017 
00018 #if !defined EMBEDDED_FONT_HEADER
00019 #define EMBEDDED_FONT_HEADER
00020 
00021 #include "whiptk/whipcore.h"
00022 #include "whiptk/file.h"
00023 #include "whiptk/object.h"
00024 
00030 
00031 
00040 class WHIPTK_API WT_Embedded_Font : public WT_Object
00041 {
00042 public:
00044     enum WT_Request_Format
00045     {
00047         Raw                           = 0x00000001,
00049         Subset                        = 0x00000002,
00051         Compressed                    = 0x00000004,
00053         Fail_If_Variations_Simulated  = 0x00000008,
00055         Eudc                          = 0x00000010,
00057         Validation_Tests              = 0x00000020,
00059         Web_Object                    = 0x00000040,
00061         Encrypt_Data                  = 0x00000080
00062     };
00063 
00065     enum WT_Character_Set
00066     {
00068         Unicode                       = 0x00000001,
00070         Symbol                        = 0x00000002,
00072         Glyphidx                      = 0x00000003
00073     };
00074 
00076     enum WT_Privilege
00077     {
00079         PreviewPrint                  = 0x00000001,
00081         Editable                      = 0x00000002,
00083         Installable                   = 0x00000003,
00085         Non_Embedding                 = 0x00000004
00086     };
00087 
00088 private:
00089 
00090     WT_Integer32            m_request;
00091     WT_Byte                 m_privilege;
00092     WT_Byte                 m_character_set_type;
00093     WT_Integer32            m_font_type_face_name_length;
00094     WT_Byte *               m_font_type_face_name_string;
00095     WT_Integer32            m_font_logfont_name_length;
00096     WT_Byte *               m_font_logfont_name_string;
00097 
00098     WT_Boolean              m_local_data_copy;
00099     WT_Integer32            m_data_size;
00100     WT_Byte *               m_data;
00101 
00102     enum
00103     {
00104         Starting,
00105         Getting_Request_Type,
00106         Getting_Privilege_Type,
00107         Getting_Character_Set_Type,
00108         Getting_Font_Type_Face_Name_Length,
00109         Getting_Font_Type_Face_Name_String,
00110         Getting_Font_LogFont_Name_Length,
00111         Getting_Font_LogFont_Name_String,
00112         Getting_Pre_Data_Size_Whitespace,
00113         Getting_Pre_Data_Size_Open_Paren,
00114         Getting_Data_Size,
00115         Getting_Data,
00116         Getting_Close
00117     }   m_stage;
00118 
00119     WT_Embedded_Font (WT_Embedded_Font const &)
00120     : WT_Object()
00121     , m_request(Raw)
00122     , m_privilege(0)
00123     , m_character_set_type(0)
00124     , m_font_type_face_name_length(0)
00125     , m_font_type_face_name_string(WD_Null)
00126     , m_font_logfont_name_length(0)
00127     , m_font_logfont_name_string(WD_Null)
00128     , m_local_data_copy(WD_False)
00129     , m_data_size(0)
00130     , m_data(WD_Null)
00131     , m_stage(Starting)
00132     {
00133         WD_Complain ("cannot copy WT_Embedded_Font");
00134     } // prohibited
00135 
00136     WT_Embedded_Font operator= (WT_Embedded_Font const &)
00137     {
00138         WD_Complain ("cannot assign WT_Embedded_Font");
00139         return *this;
00140     } // prohibited
00141 
00142 public:
00143 
00145 
00146     WT_Embedded_Font ()
00147     : m_request(Raw)
00148     , m_privilege(0)
00149     , m_character_set_type(0)
00150     , m_font_type_face_name_length(0)
00151     , m_font_type_face_name_string(WD_Null)
00152     , m_font_logfont_name_length(0)
00153     , m_font_logfont_name_string(WD_Null)
00154     , m_local_data_copy(WD_False)
00155     , m_data_size(0)
00156     , m_data(WD_Null)
00157     , m_stage(Starting)
00158     { }
00159 
00161     WT_Embedded_Font (
00162         int request_type,
00163         int privilege_type,
00164         int character_set_type)
00165     : m_request(request_type)
00166     , m_privilege(static_cast<WT_Byte>(privilege_type))
00167     , m_character_set_type(static_cast<WT_Byte>(character_set_type))
00168     , m_font_type_face_name_length(0)
00169     , m_font_type_face_name_string(WD_Null)
00170     , m_font_logfont_name_length(0)
00171     , m_font_logfont_name_string(WD_Null)
00172     , m_local_data_copy(WD_False)
00173     , m_data_size(0)
00174     , m_data(WD_Null)
00175     , m_stage(Starting)
00176     { }
00177 
00179     WT_Embedded_Font(
00181         int                            request_type,
00183         int                            privilege_type,
00185         int                            character_set_type,
00187         WT_Integer32                   data_size,
00189         WT_Byte *                      data,
00191         WT_Boolean                     copy
00192         )
00193     : m_request(request_type)
00194     , m_privilege(static_cast<WT_Byte>(privilege_type))
00195     , m_character_set_type(static_cast<WT_Byte>(character_set_type))
00196     , m_font_type_face_name_length(0)
00197     , m_font_type_face_name_string(WD_Null)
00198     , m_font_logfont_name_length(0)
00199     , m_font_logfont_name_string(WD_Null)
00200     , m_local_data_copy(copy)
00201     , m_data_size(data_size)
00202     , m_data(WD_Null)
00203     , m_stage(Starting)
00204     {
00205         if (copy)
00206         {
00207             if (m_local_data_copy)
00208             {
00209                 m_data = new WT_Byte[data_size];
00210 
00211                 if (m_data)
00212                     memcpy(m_data, data, data_size);
00213                 else
00214                     throw WT_Result::Out_Of_Memory_Error;
00215 
00216             }
00217         }  else {
00218             m_data = data;
00219         }
00220     }
00221 
00223     WT_Embedded_Font(
00225         int                            request_type,
00227         int                            privilege_type,
00229         int                            character_set_type,
00231         WT_Integer32                   data_size,
00233         WT_Byte *                      data,
00235         WT_Integer32                   font_type_face_name_length,
00237         WT_Byte *                      font_type_face_name_string,
00239         WT_Integer32                   font_logfont_name_length,
00241         WT_Byte *                      font_logfont_name_string,
00243         WT_Boolean                     copy
00244         )
00245     : m_request(request_type)
00246     , m_privilege(static_cast<WT_Byte>(privilege_type))
00247     , m_character_set_type(static_cast<WT_Byte>(character_set_type))
00248     , m_font_type_face_name_length(font_type_face_name_length)
00249     , m_font_type_face_name_string(WD_Null)
00250     , m_font_logfont_name_length(font_logfont_name_length)
00251     , m_font_logfont_name_string(WD_Null)
00252     , m_local_data_copy(copy)
00253     , m_data_size(data_size)
00254     , m_data(WD_Null)
00255     , m_stage(Starting)
00256     {
00257         if (copy)
00258         {
00259             if (m_local_data_copy)
00260             {
00261                 m_data = new WT_Byte[data_size];
00262 
00263                 if (m_data)
00264                     memcpy(m_data, data, data_size);
00265                 else
00266                     throw WT_Result::Out_Of_Memory_Error;
00267 
00268                 m_font_type_face_name_string =
00269                     new WT_Byte[font_type_face_name_length];
00270 
00271                 m_font_logfont_name_string =
00272                     new WT_Byte[font_logfont_name_length];
00273 
00274                 if(m_font_type_face_name_string)
00275                     strncpy((char *)m_font_type_face_name_string
00276                     , (const char *)font_type_face_name_string
00277                     , font_type_face_name_length);
00278                 else
00279                     throw WT_Result::Out_Of_Memory_Error;
00280 
00281                 if(m_font_logfont_name_string)
00282                     strncpy((char *)m_font_logfont_name_string
00283                     , (const char *)font_logfont_name_string
00284                     , font_logfont_name_length);
00285                 else
00286                     throw WT_Result::Out_Of_Memory_Error;
00287 
00288             }
00289         }  else {
00290             m_data = data;
00291             m_font_type_face_name_string = font_type_face_name_string;
00292             m_font_logfont_name_string = font_logfont_name_string;
00293         }
00294     }
00295 
00297     ~WT_Embedded_Font()
00298     {
00299         if (m_local_data_copy) {
00300             delete [] m_data;
00301             delete [] m_font_type_face_name_string;
00302             delete [] m_font_logfont_name_string;
00303         }
00304     }
00306 
00308 
00309     WT_Byte character_set_type() const { return m_character_set_type;  }
00311     WT_Byte const * data() const { return m_data;  }
00313     WT_Integer32 data_size() const { return m_data_size; }
00315     WT_Integer32 font_type_face_name_length() const { return m_font_type_face_name_length; }
00317     WT_Byte const * font_type_face_name_string() const { return m_font_type_face_name_string;  }
00319     WT_Integer32 font_logfont_name_length() const { return m_font_logfont_name_length; }
00321     WT_Byte const * font_logfont_name_string() const { return m_font_logfont_name_string;  }
00323     WT_Byte privilege() const { return m_privilege;  }
00325     WT_Unsigned_Integer32 request_type() const { return m_request;  }
00327 
00329     WT_ID            object_id() const;
00330     WT_Type          object_type() const;
00331     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00332     WT_Result        process(WT_File & file);
00333     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00334     WT_Result        serialize (WT_File & file) const;
00335     WT_Result        sync (WT_File & file) const;
00337 
00339 
00341     static WT_Result default_process(
00342         WT_Embedded_Font & item, 
00343         WT_File & file 
00344         );
00345 };
00346 
00348 
00349 #endif // EMBEDDED_FONT_HEADER

Generated on Tue May 17 12:07:44 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1