fontimpl.h

Go to the documentation of this file.
00001 // $Id: fontimpl.h 853 2006-04-21 12:32:46Z luke $
00002 // $Id: fontimpl.h 853 2006-04-21 12:32:46Z luke $
00003 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00004 ================================XARAHEADERSTART===========================
00005  
00006                Xara LX, a vector drawing and manipulation program.
00007                     Copyright (C) 1993-2006 Xara Group Ltd.
00008        Copyright on certain contributions may be held in joint with their
00009               respective authors. See AUTHORS file for details.
00010 
00011 LICENSE TO USE AND MODIFY SOFTWARE
00012 ----------------------------------
00013 
00014 This file is part of Xara LX.
00015 
00016 Xara LX is free software; you can redistribute it and/or modify it
00017 under the terms of the GNU General Public License version 2 as published
00018 by the Free Software Foundation.
00019 
00020 Xara LX and its component source files are distributed in the hope
00021 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00022 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00023 See the GNU General Public License for more details.
00024 
00025 You should have received a copy of the GNU General Public License along
00026 with Xara LX (see the file GPL in the root directory of the
00027 distribution); if not, write to the Free Software Foundation, Inc., 51
00028 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00029 
00030 
00031 ADDITIONAL RIGHTS
00032 -----------------
00033 
00034 Conditional upon your continuing compliance with the GNU General Public
00035 License described above, Xara Group Ltd grants to you certain additional
00036 rights. 
00037 
00038 The additional rights are to use, modify, and distribute the software
00039 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00040 library and any other such library that any version of Xara LX relased
00041 by Xara Group Ltd requires in order to compile and execute, including
00042 the static linking of that library to XaraLX. In the case of the
00043 "CDraw" library, you may satisfy obligation under the GNU General Public
00044 License to provide source code by providing a binary copy of the library
00045 concerned and a copy of the license accompanying it.
00046 
00047 Nothing in this section restricts any of the rights you have under
00048 the GNU General Public License.
00049 
00050 
00051 SCOPE OF LICENSE
00052 ----------------
00053 
00054 This license applies to this program (XaraLX) and its constituent source
00055 files only, and does not necessarily apply to other Xara products which may
00056 in part share the same code base, and are subject to their own licensing
00057 terms.
00058 
00059 This license does not apply to files in the wxXtra directory, which
00060 are built into a separate library, and are subject to the wxWindows
00061 license contained within that directory in the file "WXXTRA-LICENSE".
00062 
00063 This license does not apply to the binary libraries (if any) within
00064 the "libs" directory, which are subject to a separate license contained
00065 within that directory in the file "LIBS-LICENSE".
00066 
00067 
00068 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00069 ----------------------------------------------
00070 
00071 Subject to the terms of the GNU Public License (see above), you are
00072 free to do whatever you like with your modifications. However, you may
00073 (at your option) wish contribute them to Xara's source tree. You can
00074 find details of how to do this at:
00075   http://www.xaraxtreme.org/developers/
00076 
00077 Prior to contributing your modifications, you will need to complete our
00078 contributor agreement. This can be found at:
00079   http://www.xaraxtreme.org/developers/contribute/
00080 
00081 Please note that Xara will not accept modifications which modify any of
00082 the text between the start and end of this header (marked
00083 XARAHEADERSTART and XARAHEADEREND).
00084 
00085 
00086 MARKS
00087 -----
00088 
00089 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00090 designs are registered or unregistered trademarks, design-marks, and/or
00091 service marks of Xara Group Ltd. All rights in these marks are reserved.
00092 
00093 
00094       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00095                         http://www.xara.com/
00096 
00097 =================================XARAHEADEREND============================
00098  */
00099 
00100 // Implementation-specific definitions for fontbase.cpp. Not meant to
00101 // included by any other file.
00102 
00103 #include "fontbase.h"
00104 #include <map>
00105 
00106 /********************************************************************************************
00107 >   class FontMetricsCacheEntry : public CC_CLASS_MEMDUMP
00108             
00109     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00110     Created:    14/1/96
00111     Purpose:    Holds a cache of char widths, ascent, descent and em for a particular font.
00112 ********************************************************************************************/
00113 
00114 class FontMetricsCacheEntry: public CC_CLASS_MEMDUMP
00115 {
00116     CC_DECLARE_MEMDUMP(FontMetricsCacheEntry);
00117     
00118 public:
00119     FontMetricsCacheEntry();
00120 
00121     BOOL CacheFontMetrics(wxDC* pDC, CharDescription FontDesc, MILLIPOINT DefaultHeight, INT32 DesignSize);
00122 
00123     void CheckCharWidthsSameAsABCWidths(wxDC* pDC, CharDescription FontDesc);   // debug test
00124 
00125     inline static BOOL CharInCacheRange(WCHAR ch) { return (ch>=FIRSTCHAR && ch<=LASTCHAR); }
00126 
00127     inline INT32 GetCharWidthFromCache(WCHAR ch) { return pCharWidths[ch-FIRSTCHAR]; }
00128 
00129     inline MILLIPOINT      GetFontEmWidth() { return FontEmWidth; }
00130     inline MILLIPOINT      GetFontAscent()  { return FontAscent; }
00131     inline MILLIPOINT      GetFontDescent() { return FontDescent; }
00132     inline CharDescription GetFontDesc()    { return FontDesc; }
00133 
00134     inline void SetFontEmWidth(MILLIPOINT NewFontEmWidth) { FontEmWidth = NewFontEmWidth; }
00135     inline void SetFontAscent( MILLIPOINT NewFontAscent)  { FontAscent  = NewFontAscent; }
00136     inline void SetFontDescent(MILLIPOINT NewFontDescent) { FontDescent = NewFontDescent; }
00137     inline void SetFontDesc(CharDescription NewFontDesc)  { FontDesc    = NewFontDesc; }
00138 
00139 protected:
00140     // this seems the only way to define constants in a class assigning values
00141     enum CharRange { FIRSTCHAR=32, LASTCHAR=127, NUMCHARS=(LASTCHAR-FIRSTCHAR+1) };
00142 
00143     MILLIPOINT pCharWidths[NUMCHARS];
00144     MILLIPOINT FontEmWidth;
00145     MILLIPOINT FontAscent;
00146     MILLIPOINT FontDescent;
00147     CharDescription FontDesc;
00148 };
00149 
00150 /********************************************************************************************
00151 >   class FontMetricsCache : public CC_CLASS_MEMDUMP
00152             
00153     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00154     Created:    14/1/96
00155     Purpose:    Holds a cache of char widths, ascent, descent and em for a particular font.
00156 ********************************************************************************************/
00157 
00158 class FontMetricsCache: public CC_CLASS_MEMDUMP
00159 {
00160     CC_DECLARE_MEMDUMP(FontMetricsCache);
00161     
00162 public:
00163     static void InvalidateCharMetrics();
00164     static BOOL GetCharMetrics(wxDC* pDC, WCHAR ch, CharDescription& FontDesc, CharMetrics* pCharMetrics);
00165 
00166 protected:
00167     // this seems the only way to define constants in a class assigning values
00168     enum CacheInfo { NUMENTRIES=3 };
00169 
00170     static FontMetricsCacheEntry mpFontMetricsData[NUMENTRIES];
00171 };
00172 
00173 
00174 /********************************************************************************************
00175 
00176 >   class CharOutlineCache : public CC_CLASS_MEMDUMP
00177             
00178     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00179     Created:    14/9/95
00180     Purpose:    A cache for a character outline. This cache can only be accessed via the
00181                 OILFontMan character outline calls
00182 
00183 ********************************************************************************************/
00184 
00185 class CharOutlineCache : public CC_CLASS_MEMDUMP
00186 {
00187     CC_DECLARE_MEMDUMP(CharOutlineCache);
00188     
00189     friend class OILFontMan;
00190     
00191     private:
00192         #if _DEBUG
00193         static void Dump();
00194         #endif
00195 
00196         static DocCoord CacheCoords[OILFONTLIMIT];
00197         static PathVerb CacheVerbs[OILFONTLIMIT];
00198         static UINT32 CacheSize;
00199         static DocCoord LastMoveTo;
00200 };
00201 
00202 // Forward decleration
00203 struct MillipointKerningPair;
00204 
00205 /********************************************************************************************
00206 >   class FontKerningPairsCacheEntry : public CC_CLASS_MEMDUMP
00207             
00208     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
00209     Created:    16/10/2000
00210     Purpose:    Holds a cache of kerning pairs for a font
00211 ********************************************************************************************/
00212 
00213 class FontKerningPairsCacheEntry : public CC_CLASS_MEMDUMP
00214 {
00215     CC_DECLARE_MEMDUMP(FontKerningPairsCacheEntry);
00216     
00217 public:
00218     FontKerningPairsCacheEntry();       // constructor
00219     ~FontKerningPairsCacheEntry();      // destructor
00220 
00221     void Reinitialise(CharDescription& NewFontDesc);
00222 
00223     MILLIPOINT GetCharsKerning(WCHAR chLeft, WCHAR chRight);
00224     inline CharDescription GetFontDesc()                    { return FontDesc; }
00225     inline void SetFontDesc(CharDescription NewFontDesc)    { FontDesc = NewFontDesc; }
00226 
00227 #ifdef _DEBUG
00228 public:
00229     void Dump();
00230 #endif //_DEBUG
00231 
00232 protected:
00233     CharDescription FontDesc;
00234 
00235 protected: // Kerning data
00236     std::map<UINT32,INT32>* m_pPairsCacheMap;
00237 
00238 private:
00239     // declare private copy constructor and assignment operator to prevent
00240     // copy/assignment operations - the methods are not implemented
00241     FontKerningPairsCacheEntry(const FontKerningPairsCacheEntry&);
00242     FontKerningPairsCacheEntry& operator=(const FontKerningPairsCacheEntry&);
00243 };
00244 
00245 
00246 /********************************************************************************************
00247 
00248 >   class FontKerningPairsCache : public CC_CLASS_MEMDUMP
00249             
00250     Author:     Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
00251     Created:    16/10/2000
00252     Purpose:    A cache for the kerning pairs for a font
00253 
00254 ********************************************************************************************/
00255 
00256 class FontKerningPairsCache : public CC_CLASS_MEMDUMP
00257 {
00258     CC_DECLARE_MEMDUMP(FontKerningPairsCache);
00259     
00260 public:
00261     static MILLIPOINT GetCharsKerning(wxDC* pDC, WCHAR chLeft, WCHAR chRight,
00262                                       CharDescription& FontDesc);
00263 
00264 #ifdef _DEBUG
00265 public:
00266     static void Dump();
00267 #endif//_DEBUG
00268 
00269 protected:
00270     // this seems the only way to define constants in a class assigning values
00271     enum CacheInfo { NUMENTRIES=3 };
00272 
00273     static FontKerningPairsCacheEntry m_FontKerningPairsCacheData[NUMENTRIES];
00274 };
00275 

Generated on Sat Nov 10 03:48:29 2007 for Camelot by  doxygen 1.4.4