// ____ ______ __ // / __ \ / ____// / // / /_/ // / / / // / ____// /___ / /___ PixInsight Class Library // /_/ \____//_____/ PCL 2.4.23 // ---------------------------------------------------------------------------- // pcl/Font.h - Released 2022-03-12T18:59:29Z // ---------------------------------------------------------------------------- // This file is part of the PixInsight Class Library (PCL). // PCL is a multiplatform C++ framework for development of PixInsight modules. // // Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved. // // Redistribution and use in both source and binary forms, with or without // modification, is permitted provided that the following conditions are met: // // 1. All redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. All redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names // of their contributors, may be used to endorse or promote products derived // from this software without specific prior written permission. For written // permission, please contact info@pixinsight.com. // // 4. All products derived from this software, in any form whatsoever, must // reproduce the following acknowledgment in the end-user documentation // and/or other materials provided with the product: // // "This product is based on software from the PixInsight project, developed // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)." // // Alternatively, if that is where third-party acknowledgments normally // appear, this acknowledgment must be reproduced in the product itself. // // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE, // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // ---------------------------------------------------------------------------- #ifndef __PCL_Font_h #define __PCL_Font_h /// \file pcl/Font.h #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION #include #include #include #include #endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION namespace pcl { // ---------------------------------------------------------------------------- /*! * \namespace pcl::FontFamily * \brief Platform-independent, standard font families * * * * * * * * * * * * * * * * *
FontFamily::Default Default font
FontFamily::SansSerif Sans serif font: Helvetica, Swiss, Arial
FontFamily::Helvetica Equivalent to SansSerif
FontFamily::Swiss Equivalent to SansSerif
FontFamily::Serif Serif font: Times, Garamond
FontFamily::Times Equivalent to Serif
FontFamily::Script Handwriting font: Script, Comic
FontFamily::Monospace Fixed-pitch font: Courier, Vera Sans Mono
FontFamily::TypeWriter Equivalent to Monospace
FontFamily::Courier Equivalent to Monospace
FontFamily::Teletype Equivalent to Monospace
FontFamily::Decorative Decorative font: OldEnglish
FontFamily::OldEnglish Equivalent to Decorative
FontFamily::Symbol Math, greek, etc: Symbol
*/ namespace FontFamily { enum value_type { Default, // default font SansSerif, // sans serif font: Helvetica, Swiss, Arial Helvetica = SansSerif, Swiss = SansSerif, Serif, // serif font: Times, Garamond Times = Serif, Script, // handwriting font: Script, Comic Monospace, // fixed-pitch font: Courier, Vera Sans Mono TypeWriter = Monospace, Courier = Monospace, Teletype = Monospace, Decorative, // decorative font: OldEnglish, OldEnglish = Decorative, Symbol // math, greek, etc.: Symbol }; String PCL_FUNC FamilyToFace( value_type family ); } // ---------------------------------------------------------------------------- /*! * \namespace pcl::FontWeight * \brief Standard font weights * * * * * * * * * * * * * * * * *
FontWeight::Thin 100
FontWeight::ExtraLight 200
FontWeight::UltraLight = ExtraLight
FontWeight::Light 300
FontWeight::Normal 400
FontWeight::Regular = Normal
FontWeight::Medium 500
FontWeight::SemiBold 600
FontWeight::DemiBold = SemiBold
FontWeight::Bold 700
FontWeight::ExtraBold 800
FontWeight::UltraBold = ExtraBold
FontWeight::Heavy 850
FontWeight::Black 900
*/ namespace FontWeight { enum value_type { Thin = 100, ExtraLight = 200, UltraLight = ExtraLight, Light = 300, Normal = 400, Regular = Normal, Medium = 500, SemiBold = 600, DemiBold = SemiBold, Bold = 700, ExtraBold = 800, UltraBold = ExtraBold, Heavy = 850, Black = 900 }; } // ---------------------------------------------------------------------------- /*! * \namespace pcl::FontStretch * \brief Standard font stretchs * * * * * * * * * * * *
FontStretch::UltraCondensed 50
FontStretch::ExtraCondensed 62
FontStretch::Condensed 75
FontStretch::SemiCondensed 87
FontStretch::Unstretched 100
FontStretch::SemiExpanded 112
FontStretch::Expanded 125
FontStretch::ExtraExpanded 150
FontStretch::UltraExpanded 200
*/ namespace FontStretch { enum value_type { UltraCondensed = 50, ExtraCondensed = 62, Condensed = 75, SemiCondensed = 87, Unstretched = 100, SemiExpanded = 112, Expanded = 125, ExtraExpanded = 150, UltraExpanded = 200 }; } // ---------------------------------------------------------------------------- #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION // ---------------------------------------------------------------------------- /*! * \class Font * \brief Client-side interface to a PixInsight %Font object * * ### TODO: Write a detailed description for %Font. */ class PCL_CLASS Font : public UIObject { public: /*! * Represents a standard font family. */ typedef FontFamily::value_type family; /*! * Represents a standard font weight. */ typedef FontWeight::value_type std_weight; /*! * Represents a standard font stretch. */ typedef FontStretch::value_type std_stretch; /*! * Constructs a %Font object with the specified family and \a size in * points. * * ### TODO: Elaborate on font families, font matching, etc. */ Font( family f = FontFamily::Default, double size = 12.0 ); /*! * Constructs a %Font object with the specified font \a face and \a size * in points. * * ### TODO: Elaborate on font faces, font matching, etc. */ Font( const String& face, double size = 12.0 ); /*! * Copy constructor. This object will reference the same server-side font * as the specified instance \a f. */ Font( const Font& f ) : UIObject( f ) { } /*! * Move constructor. */ Font( Font&& x ) : UIObject( std::move( x ) ) { } /*! * Destroys a %Font object. If this object references an existing font in * the PixInsight core application, its reference count is decremented. If * it becomes unreferenced, it will be garbage-collected. */ virtual ~Font() { } /*! * Copy assignment operator. Returns a reference to this object. * * Makes this object reference the same server-side font as the specified * instance \a f. If the previous font becomes unreferenced, it will be * garbage-collected by the PixInsight core application. */ Font& operator =( const Font& f ) { SetHandle( f.handle ); return *this; } /*! * Move assignment operator. Returns a reference to this object. */ Font& operator =( Font&& x ) { Transfer( x ); return *this; } /*! * Returns a reference to a null font. A null %Font object does not * correspond to an existing font object in the PixInsight core application. */ static Font& Null(); /*! # */ String Face() const; /*! # */ void SetFace( const String& ); /*! # */ bool IsExactMatch() const; /*! # */ StringList AvailableWritingSystems() const { return AvailableFontWritingSystems( Face() ); } /*! # */ StringList AvailableStyles() const { return AvailableFontStyles( Face() ); } /*! # */ bool IsScalable( const String& style = String() ) const { return IsScalableFont( Face(), style ); } /*! # */ Array OptimalPointSizes( const String& style = String() ) const { return OptimalFontPointSizes( Face(), style ); } /*! # */ int PixelSize() const; /*! # */ void SetPixelSize ( int ); /*! # */ double PointSize() const; /*! # */ void SetPointSize( double ); /*! # */ bool IsFixedPitch() const; /*! # */ bool IsFixedPitch( const String& style ) const { return IsFixedPitchFont( Face(), style ); } /*! # */ void SetFixedPitch( bool = true ); /*! # */ bool IsKerningEnabled() const; /*! # */ void EnableKerning( bool = true ); /*! # */ void DisableKerning( bool = true ); /*! # */ int StretchFactor() const; /*! # */ void SetStretchFactor( int ); /*! # */ int Weight() const; /*! # */ int Weight( const String& style ) const { return FontWeight( Face(), style ); } /*! # */ void SetWeight( int ); /*! # */ bool IsBold() const { return Weight() >= FontWeight::Bold; } /*! # */ void SetBold( bool b = true ) { SetWeight( b ? FontWeight::Bold : FontWeight::Normal ); } /*! # */ bool IsItalic() const; /*! # */ bool IsItalic( const String& style ) const { return IsItalicFont( Face(), style ); } /*! # */ void SetItalic( bool = true ); /*! # */ bool IsUnderline() const; /*! # */ void SetUnderline( bool = true ); /*! # */ bool IsOverline() const; /*! # */ void SetOverline( bool = true ); /*! # */ bool IsStrikeOut() const; /*! # */ void SetStrikeOut( bool = true ); /*! # */ int Ascent() const; /*! # */ int Descent() const; /*! # */ int Height() const; /*! # */ int LineSpacing() const; /*! # */ bool IsCharDefined( int ) const; /*! # */ int MaxWidth() const; /*! # */ int Width( const String& ) const; /*! # */ int Width( int ch ) const; /*! # */ Rect BoundingRect( const String& ) const; /*! # */ Rect TightBoundingRect( const String& ) const; /*! # */ static StringList AvailableFonts( const String& writingSystem = String() ); /*! # */ static StringList AvailableFontWritingSystems( const String& font ); /*! # */ static StringList AvailableFontStyles( const String& font ); /*! # */ static Array OptimalFontPointSizes( const String& font, const String& style = String() ); /*! # */ static bool IsScalableFont( const String& font, const String& style = String() ); /*! # */ static bool IsFixedPitchFont( const String& font, const String& style = String() ); /*! # */ static bool IsItalicFont( const String& font, const String& style = String() ); /*! # */ static int FontWeight( const String& font, const String& style = String() ); private: Font( void* h ) : UIObject( h ) { } void* CloneHandle() const override; friend class InternalFontEnumerator; friend class GraphicsContextBase; friend class Control; friend class TreeBox; }; // ---------------------------------------------------------------------------- #endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION } // pcl #endif // __PCL_Font_h // ---------------------------------------------------------------------------- // EOF pcl/Font.h - Released 2022-03-12T18:59:29Z