rfont.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:8k
- /*
- * rfont.h
- *
- * Realised font description
- *
- * 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: rfont.h,v $
- * Revision 1.17 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.16 1999/03/09 08:01:49 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.15 1999/02/16 08:08:46 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.14 1998/09/23 06:28:52 robertj
- * Added open source copyright license.
- *
- * Revision 1.13 1995/03/14 12:42:27 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.12 1995/01/22 00:30:41 robertj
- * Changed semantics of GetSize() and GetHeight() more in line with X definitions.
- *
- * Revision 1.11 1995/01/14 06:19:33 robertj
- * Documentation
- *
- * Revision 1.10 1995/01/07 04:39:42 robertj
- * Redesigned font enumeration code and changed font styles.
- *
- * Revision 1.9 1994/12/14 11:17:12 robertj
- * Changed PDIMENSION to be unsigned causing untold number of changes.
- *
- * Revision 1.8 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.7 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.6 1994/07/02 03:03:49 robertj
- * Changed device resolution to be protected.
- *
- * Revision 1.5 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.4 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * 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 _PREALFONT
- #ifdef __GNUC__
- #pragma interface
- #endif
- class PCanvas;
- /**A class representing the attributes of a text font that is representable
- on a Ref{PCanvas}.
-
- A canvas is always associated with a particular {it device}. This may be
- the screen as in Ref{PInteractorCanvas} or a printer as in
- Ref{PPrinterCanvas}. A particular device will only be able to render
- certain fonts, eg a screen device would only be able to display fonts that
- were installed on the system. A printer would typically only be able to
- render fonts that are built into it.
- The original Ref{PFont} only has enough information for a request to the
- device of a font. Once a font is realised, more detailed information about
- the exact font metrics is available.
- Note all sizes (height, width etc) for fonts are in printers points
- (1/72 inch).
- */
- class PRealFont : public PFont
- {
- PCLASSINFO(PRealFont, PFont);
- public:
- /**Create a real font for the canvas from the specified font request
- information. If no canvas is specified then the screen device is used,
- ie via a Ref{PInteractorCanvas}. If no font information is provided
- then the system font returned by Ref{PApplication::GetSystemFont()}
- is used.
- */
- PRealFont();
- PRealFont(
- const PFont & font /// Font request information to realise.
- );
- PRealFont(
- PCanvas & canvas, /// Canvas on which to realise the font.
- const PFont & font /// Font request information to realise.
- );
- /**@name New functions for class */
- /**Get the height of font. This is the distance from the characters on one
- line and the characters on the next line of text.
-
- The {it height} is the {it ascent} plus the {it descent} and the
- {it leading}.
-
- @return
- height of the real font.
- */
- virtual PDIMENSION GetHeight(
- BOOL inPixels = FALSE /// Whether returned in pixels or printer points.
- ) const;
- /**Get the average width of the characters in the font.
- @return
- average width of the real font.
- */
- virtual PDIMENSION GetAvgWidth(
- BOOL inPixels = FALSE /// Whether returned in pixels or printer points.
- ) const;
- /**Get the width of the widest character in the font.
-
- @return
- maximum width of the real font.
- */
- virtual PDIMENSION GetMaxWidth(
- BOOL inPixels = FALSE /// Whether returned in pixels or printer points.
- ) const;
- /**Get the ascent, height of characters above the line they sit on.
-
- The {it height} is the {it ascent} plus the {it descent}. The
- {it size} is the {it height} plus the {it leading}.
-
- @return
- ascent of the real font.
- */
- virtual PDIMENSION GetAscent(
- BOOL inPixels = FALSE /// Whether returned in pixels or printer points.
- ) const;
- /**Get the descent, height of characters below the line thet sit on. This
- would apply to characters such as 'g' or 'q' for instance.
- The {it height} is the {it ascent} plus the {it descent}. The
- {it size} is the {it height} plus the {it leading}.
-
- @return
- descent of the real font.
- */
- virtual PDIMENSION GetDescent(
- BOOL inPixels = FALSE /// Whether returned in pixels or printer points.
- ) const;
- /**Get the recommended distance between lines in consecutive lines of
- text all in this font.
-
- The {it height} is the {it ascent} plus the {it descent}. The
- {it size} is the {it height} plus the {it leading}.
-
- @return
- leading of the real font.
- */
- virtual PDIMENSION GetLeading(
- BOOL inPixels = FALSE /// Whether returned in pixels or printer points.
- ) const;
- /**Convert a horizontal dimension from printer points (1/72 inch) to
- pixels of the device the font was realised for.
-
- @return
- converted dimension.
- */
- PDIMENSION PointsToPixelsX(
- PDIMENSION x /// Horizontal dimension to convert.
- ) const;
- /**Convert a vertical dimension from printer points (1/72 inch) to pixels
- of the device the font was realised for.
-
- @return
- converted dimension.
- */
- PDIMENSION PointsToPixelsY(
- PDIMENSION y /// Vertical dimension to convert.
- ) const;
-
- /**Convert a horizontal dimension from pixels of the device the font was
- realised for to printer points (1/72 inch).
-
- @return
- converted dimension.
- */
- PDIMENSION PixelsToPointsX(
- PDIMENSION x /// Horizontal dimension to convert.
- ) const;
- /**Convert a vertical dimension from pixels of the device the font was
- realised for to printer points (1/72 inch).
- @return
- converted dimension.
- */
- PDIMENSION PixelsToPointsY(
- PDIMENSION y /// Vertical dimension to convert.
- ) const;
-
- protected:
- // Member variables
- /** Device resolution of the canvas for printer point conversion functions. */
- PDIMENSION deviceResX, deviceResY;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////