swffont.cpp

Go to the documentation of this file.
00001 // $Id: swffont.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 #include "camtypes.h"
00099 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00100 #include "swffont.h"
00101 
00102 CC_IMPLEMENT_DYNAMIC( FlashFontRecord, CCObject )
00103 
00104 #define new CAM_DEBUG_NEW
00105 
00106 /********************************************************************************************
00107 
00108 >   FlashFontRecord::FlashFontRecord ( void )
00109 
00110     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00111     Created:    4/10/99
00112     Inputs:     -
00113     Returns:    -
00114     Purpose:    Creates a FlashFontRecord list node, and initialises any values.
00115 
00116 ********************************************************************************************/
00117 
00118 FlashFontRecord::FlashFontRecord ( void )
00119 {
00120     // Initialise the member variables, so as to avoid any unpleasentness later.
00121     mFontID     = 0;        // Set as 0.
00122     mTypeface   = 0;        // Default to 0.
00123     mIsBold     = FALSE;    // Initially the font isn't bold.
00124     mIsItalic   = FALSE;    // Initially the font isn't italic.
00125 
00126     // Pointers should always be initialised to NULL when created.
00127     mpLast      = NULL;     // No previous nodes.
00128     mpNext      = NULL;     // No subsequent nodes.
00129 
00130     // Ensure that the arrays are full of 0s.
00131     for ( UINT32 i = 0; i < FLASH_TEXT_ARRAY_SIZE; i++ )
00132     {
00133         mGlyphs [i] = 0;
00134         mPaths [i] = NULL;
00135     }
00136 }
00137 
00138 /********************************************************************************************
00139 
00140 >   FlashFontRecord::~FlashFontRecord ( void )
00141 
00142     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00143     Created:    4/10/99
00144     Inputs:     -
00145     Returns:    -
00146     Purpose:    Destroys this instance of FlashFontRecord.
00147 
00148 ********************************************************************************************/
00149 
00150 FlashFontRecord::~FlashFontRecord ( void )
00151 {
00152     // Clean up any stray values.
00153     for ( UINT32 i = 0; i < FLASH_TEXT_ARRAY_SIZE; i++ )
00154     {
00155         Path* pPath = mPaths[i];
00156 
00157         if(pPath)
00158             delete pPath;
00159     }
00160 }
00161 
00162 /********************************************************************************************
00163 
00164 >   FlashFontRecord* FlashFontRecord::AddElement ( void )
00165 
00166     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00167     Created:    4/10/99
00168     Inputs:     -
00169     Returns:    pTail - The pointer to the new node.
00170     Purpose:    Adds an element to the tail of the list.
00171 
00172 ********************************************************************************************/
00173 
00174 FlashFontRecord* FlashFontRecord::AddElement ( void )
00175 {
00176     FlashFontRecord *pTail = new FlashFontRecord;
00177     
00178     // Set the appropriate pointers.
00179     pTail->SetLast ( this );        // Ensure that a reference exists to this object...
00180     pTail->SetNext ( mpNext );      // Avoids any problems if mpLast isn't NULL.
00181     mpNext = pTail;                 // ... and a reference exists to the new one.
00182 
00183     return pTail;
00184 }
00185 
00186 /********************************************************************************************
00187 
00188 >   void FlashFontRecord::DeleteLastElement ( void )
00189 
00190     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00191     Created:    4/10/99
00192     Inputs:     -
00193     Returns:    -
00194     Purpose:    Deletes the previous item in the list.
00195 
00196 ********************************************************************************************/
00197 
00198 void FlashFontRecord::DeleteLastElement ( void )
00199 {
00200     FlashFontRecord *pToDelete = mpLast;
00201     
00202     // Reset mpLast to be mpLast->GetLast (), so that the list isn't broken.
00203     mpLast = mpLast->GetLast ();
00204 
00205     delete pToDelete;
00206 }
00207 
00208 /********************************************************************************************
00209 
00210 >   void FlashFontRecord::DeleteNextElement ( void )
00211 
00212     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00213     Created:    4/10/99
00214     Inputs:     -
00215     Returns:    -
00216     Purpose:    Deletes the next item in the list.
00217 
00218 ********************************************************************************************/
00219 
00220 void FlashFontRecord::DeleteNextElement ( void )
00221 {
00222     FlashFontRecord *pToDelete = mpNext;
00223     
00224     // Reset mpNext to be mpNext->GetNext (), so that the list isn't broken.
00225     mpNext = mpNext->GetNext ();
00226 
00227     delete pToDelete;
00228 }
00229 
00230 /********************************************************************************************
00231 
00232 >   WORD FlashFontRecord::GetTypeface ( void )
00233 
00234     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00235     Created:    26/10/99
00236     Inputs:     -
00237     Returns:    mTypeface - The typeface ID number.
00238     Purpose:    Gets the value of mFontID.
00239 
00240 ********************************************************************************************/
00241 
00242 WORD FlashFontRecord::GetTypeface ( void )
00243 {
00244     return mTypeface;
00245 }
00246 
00247 /********************************************************************************************
00248 
00249 >   WORD FlashFontRecord::GetFontID ( void )
00250 
00251     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00252     Created:    4/10/99
00253     Inputs:     -
00254     Returns:    mFontID - The font ID number.
00255     Purpose:    Gets the value of mFontID.
00256 
00257 ********************************************************************************************/
00258 
00259 WORD FlashFontRecord::GetFontID ( void )
00260 {
00261     return mFontID;
00262 }
00263 
00264 
00265 /********************************************************************************************
00266 
00267 >   BOOL FlashFontRecord::GetIsBold ( void )
00268 
00269     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00270     Created:    4/10/99
00271     Inputs:     -
00272     Returns:    IsBold - mIs this font style bold?
00273     Purpose:    Gets the value of mIsBold.
00274 
00275 ********************************************************************************************/
00276 
00277 BOOL FlashFontRecord::GetIsBold ( void )
00278 {
00279     return mIsBold;
00280 }
00281 
00282 /********************************************************************************************
00283 
00284 >   BOOL FlashFontRecord::GetIsItalic ( void )
00285 
00286     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00287     Created:    4/10/99
00288     Inputs:     -
00289     Returns:    IsItalic - mIs this font style Italic?
00290     Purpose:    Gets the value of mIsItalic.
00291 
00292 ********************************************************************************************/
00293 
00294 BOOL FlashFontRecord::GetIsItalic ( void )
00295 {
00296     return mIsItalic;
00297 }
00298 
00299 /********************************************************************************************
00300 
00301 >   WCHAR* FlashFontRecord::GetGlyphs ( void )
00302 
00303     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00304     Created:    4/10/99
00305     Inputs:     -
00306     Returns:    *mGlyphs - A pointer to the array of characters used.
00307     Purpose:    Gets a pointer to mGlyphs.
00308 
00309 ********************************************************************************************/
00310 
00311 WCHAR* FlashFontRecord::GetGlyphs ( void )
00312 {
00313     return mGlyphs;
00314 }
00315 
00316 /********************************************************************************************
00317 
00318 >   Path** FlashFontRecord::GetPaths ( void )
00319 
00320     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00321     Created:    7/10/99
00322     Inputs:     -
00323     Returns:    *mpPaths - A pointer to the array of paths of the characters used.
00324     Purpose:    Gets a pointer to mpPaths.
00325 
00326 ********************************************************************************************/
00327 
00328 Path** FlashFontRecord::GetPaths ( void )
00329 {
00330     return mPaths;
00331 }
00332 
00333 /********************************************************************************************
00334 
00335 >   FlashFontRecord* FlashFontRecord::GetLast ( void )
00336 
00337     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00338     Created:    4/10/99
00339     Inputs:     -
00340     Returns:    *mpLast - A pointer to the previous node in the linked list.
00341     Purpose:    Gets mpLast.
00342 
00343 ********************************************************************************************/
00344 
00345 FlashFontRecord* FlashFontRecord::GetLast ( void )
00346 {
00347     return mpLast;
00348 }
00349 
00350 /********************************************************************************************
00351 
00352 >   FlashFontRecord* FlashFontRecord::GetNext ( void )
00353 
00354     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00355     Created:    4/10/99
00356     Inputs:     -
00357     Returns:    *mpNext - A pointer to the next node in the linked list.
00358     Purpose:    Gets mpNext.
00359 
00360 ********************************************************************************************/
00361 
00362 FlashFontRecord* FlashFontRecord::GetNext ( void )
00363 {
00364     return mpNext;
00365 }
00366 
00367 /********************************************************************************************
00368 
00369 >   void FlashFontRecord::SetTypeface ( WORD Typeface )
00370 
00371     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00372     Created:    26/10/99
00373     Inputs:     Typeface - The ID number of a font in the Camelot image.
00374     Returns:    -
00375     Purpose:    Sets the value of mTypeface. This is a handle to a font name that is stored
00376                 within the Camelot font manager.
00377 
00378 ********************************************************************************************/
00379 
00380 void FlashFontRecord::SetTypeface ( WORD Typeface )
00381 {
00382     mTypeface = Typeface;
00383 }
00384 
00385 /********************************************************************************************
00386 
00387 >   void FlashFontRecord::SetFontID ( WORD FontID )
00388 
00389     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00390     Created:    4/10/99
00391     Inputs:     FontID - The ID number of a font within a Flash file.
00392     Returns:    -
00393     Purpose:    Sets the value of mFontID, which is the number used to relate a DefineFont
00394                 entry to a DefineText entry.
00395 
00396 ********************************************************************************************/
00397 
00398 void FlashFontRecord::SetFontID ( WORD FontID )
00399 {
00400     mFontID = FontID;
00401 }
00402 
00403 /********************************************************************************************
00404 
00405 >   void FlashFontRecord::SetIsBold ( BOOL IsBold )
00406 
00407     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00408     Created:    4/10/99
00409     Inputs:     IsBold - Is the current font in a bold typeface?
00410     Returns:    -
00411     Purpose:    Sets the value of mIsBold.
00412 
00413 ********************************************************************************************/
00414 
00415 void FlashFontRecord::SetIsBold ( BOOL IsBold )
00416 {
00417     mIsBold = IsBold;
00418 }
00419 
00420 /********************************************************************************************
00421 
00422 >   void FlashFontRecord::SetIsItalic ( BOOL IsItalic )
00423 
00424     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00425     Created:    4/10/99
00426     Inputs:     IsItalic - Is the current font in an Italic typeface?
00427     Returns:    -
00428     Purpose:    Sets the value of mIsItalic.
00429 
00430 ********************************************************************************************/
00431 
00432 void FlashFontRecord::SetIsItalic ( BOOL IsItalic )
00433 {
00434     mIsItalic = IsItalic;
00435 }
00436 
00437 /********************************************************************************************
00438 
00439 >   BOOL FlashFontRecord::AddGlyph ( WCHAR Glyph,
00440                                      INT32 &Code )
00441 
00442     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00443     Created:    4/10/99
00444     Inputs:     Glyph - A single unicode character.
00445                 &Code - A reference which contains the position of the glyph in the array.
00446     Returns:    TRUE if a character is added, otherwise false.
00447     Purpose:    Adds a glyph to mGlyphs.
00448 
00449 ********************************************************************************************/
00450 
00451 BOOL FlashFontRecord::AddGlyph ( WCHAR Glyph,
00452                                  INT32 &Code )
00453 {
00454     // Set up the return values.
00455     BOOL bResult = TRUE;
00456     Code = 0;
00457 
00458     // Compare the value of the new character to the entries in the array.
00459     while ( mGlyphs [Code] != 0 )
00460     {
00461         if ( mGlyphs [Code] == Glyph )
00462         {
00463             // The character is already present within the listing, so quit out.
00464             bResult = FALSE;
00465             break;
00466         }
00467 
00468         // Increment the value of Code so that it points to the next element in the array.
00469         Code++;
00470     }
00471 
00472     mGlyphs[Code] = Glyph;          // Write the new value into the array.
00473 
00474     return bResult;
00475 }
00476 
00477 /********************************************************************************************
00478 
00479 >   void FlashFontRecord::AddPath ( Path* ToAdd, INT32 Index )
00480 
00481     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00482     Created:    4/10/99
00483     Inputs:     ToAdd - A pointer to a path.
00484                 Index - The matrix element to which you want to add it to.
00485     Returns:    -
00486     Purpose:    Adds a path reference to mpPaths.
00487 
00488 ********************************************************************************************/
00489 
00490 void FlashFontRecord::AddPath ( Path* ToAdd, INT32 Index )
00491 {
00492     mPaths [ Index ] = ToAdd;
00493 }
00494 
00495 /********************************************************************************************
00496 
00497 >   void FlashFontRecord::SetLast ( FlashFontRecord *pLast )
00498 
00499     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00500     Created:    4/10/99
00501     Inputs:     pLast - A pointer to the previous FlashFontRecord in the linked list.
00502     Returns:    -
00503     Purpose:    Sets the value of mpLast.
00504 
00505 ********************************************************************************************/
00506 
00507 void FlashFontRecord::SetLast ( FlashFontRecord *pLast )
00508 {
00509     mpLast = pLast;
00510 }
00511 
00512 /********************************************************************************************
00513 
00514 >   void FlashFontRecord::SetNext ( FlashFontRecord *pNext )
00515 
00516     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00517     Created:    4/10/99
00518     Inputs:     pNext - A pointer to the next FlashFontRecord in the linked list.
00519     Returns:    -
00520     Purpose:    Sets the value of mpNext.
00521 
00522 ********************************************************************************************/
00523 
00524 void FlashFontRecord::SetNext ( FlashFontRecord *pNext )
00525 {
00526     mpNext = pNext;
00527 }

Generated on Sat Nov 10 03:47:07 2007 for Camelot by  doxygen 1.4.4