font.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:8k
- /*
- * font.h
- *
- * Font description class.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: font.h,v $
- * Revision 1.18 1999/03/10 03:49:51 robertj
- * More documentation adjustments.
- *
- * Revision 1.17 1999/03/09 08:01:48 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.16 1999/02/16 08:08:45 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.15 1998/09/23 06:23:32 robertj
- * Added open source copyright license.
- *
- * Revision 1.14 1995/03/14 12:41:26 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.13 1995/02/16 09:45:57 robertj
- * Made constructors use PString as more general than PCaselessString.
- *
- * Revision 1.12 1995/01/27 11:07:04 robertj
- * Changed face name strings to be caseless.
- *
- * Revision 1.11 1995/01/22 07:22:40 robertj
- * Added font description string.
- *
- * Revision 1.10 1995/01/22 00:30:41 robertj
- * Changed semantics of GetSize() and GetHeight() more in line with X definitions.
- *
- * Revision 1.9 1995/01/07 04:39:37 robertj
- * Redesigned font enumeration code and changed font styles.
- *
- * Revision 1.8 1994/12/21 11:52:58 robertj
- * Documentation and variable normalisation.
- *
- * Revision 1.7 1994/12/14 11:17:05 robertj
- * Changed PDIMENSION to be unsigned causing untold number of changes.
- *
- * Revision 1.6 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.5 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.4 1994/07/02 03:03:49 robertj
- * Fixed constructor to be better optimised.
- *
- * Revision 1.3 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PFONT
- #ifdef __GNUC__
- #pragma interface
- #endif
- /**A class representing the attributes of a text font. This is the
- specification for a font request. The font may not be representable on the
- particular Ref{PCanvas} that text is to drawn. A matching algorithm is
- performed to find the nearest font that actually exists for the canvas. This
- is called {it realising} the font and will return a Ref{PRealFont}
- object. A realised font is tied to the device that a Ref{PCanvas} is
- drawing to. Thus a Ref{PPrintCanvas} may realise a different font than a
- Ref{PDrawCanvas} would given the same PFont specification.
- */
- class PFont : public PObject
- {
- PCLASSINFO(PFont, PObject);
- public:
- /** The style bits that are returned in GetStyles(). */
- enum Style {
- /// Font has no styles.
- Regular = 0,
- /// Font has the Bold style.
- Bold = 1,
- /// Font has the Italic or Oblique style.
- Italic = 2,
- /// Font has the Underline style.
- Underline = 4
- };
- /**Create a new font with the specified attributes.
-
- A font description string consists of three fields separated by
- commas. The first field is the face name, the second is the font
- size in points and the last field has the any combination of the
- letters 'B', 'I' and 'U' for bold, italic and underlined
- respectively. The last field is optional.
- Example description strings are:
- "Times,12,B" for times 12 point bold,
- "Hevetica, 24, IU" for helvetica 24 point italic with underline,
- "Courier,10" for regular courier 10 point.
- Note the font size are in printers points (1/72 inch).
- */
- PFont(
- const char * fontDescriptionPtr
- /// C String description of a font specification.
- );
- PFont(
- const PString & fontDescriptionStr
- /// String description of a font specification.
- );
- PFont(
- const PString & theFacename, /// The text name of the font face.
- PDIMENSION theSize, /// The nominal size of the font in points.
- WORD theStyle = Regular /// The style bits for the font.
- );
- /**@name Overrides from class PInteractor */
- /**Create a copy of the font object.
- @return
- a new copy of the font on the heap.
- */
- virtual PObject * Clone() const;
- /**Determine if the two fonts are the same. That is they have the same
- face name, size and attributes.
-
- @return
- #EqualTo# if fonts the same, #GreaterThan# if
- different.
- */
- virtual Comparison Compare(
- const PObject & obj /// Other font to compare against.
- ) const;
- /**@name New methods for class */
- /**Get the description string for the font specification.
-
- A font description string consists of three fields separated by
- commas. The first field is the face name, the second is the font
- size in points and the last field has the any combination of the
- letters 'B', 'I' and 'U' for bold, italic and underlined
- respectively. The last field is optional.
- Example description strings are:
- "Times,12,B" for times 12 point bold,
- "Hevetica, 24, IU" for helvetica 24 point italic with underline,
- "Courier,10" for regular courier 10 point.
- @return
- description string.
- */
- PCaselessString GetDescription() const;
- /**Get the face name of the created font eg "Courier".
- @return
- string for the font face.
- */
- PCaselessString GetFacename() const;
- /**Get the size of characters in the font. The font size is a nominal
- height for characters. The actual height of characters for the font
- is determined only when a font is realised.
-
- @return
- size of the font in printers points (1/72 inch).
- */
- PDIMENSION GetSize() const;
- /**Get the current style bits for the font. The style bits are defined by
- the constants in the Style enum.
- @return
- style bits for font.
- */
- WORD GetStyles() const;
- /**Determine if the font was created as a bold font.
- @return
- TRUE if is bold.
- */
- BOOL IsBold() const;
- /**Determine if the font was created as an italic font.
- @return
- TRUE if is italic.
- */
- BOOL IsItalic() const;
- /**Determine if the font was created as an underlined font.
- @return
- TRUE if is underlined.
- */
- BOOL IsUnderlined() const;
- protected:
- /** Face name string for the font. */
- PCaselessString facename;
- /** The size of the font. */
- PDIMENSION size;
- /** Indication of the font styles eg bold etc. */
- WORD styles;
- private:
- void Construct(const PCaselessString & fontDescription);
- // Common construction code for all constructors.
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////