File indexing completed on 2024-04-28 05:32:10
0001 #ifndef oxygenfontinfo_h 0002 #define oxygenfontinfo_h 0003 /* 0004 * this file is part of the oxygen gtk engine 0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #include <string> 0011 #include <map> 0012 0013 namespace Oxygen 0014 { 0015 0016 class FontInfo 0017 { 0018 0019 public: 0020 0021 //! font types 0022 enum FontType 0023 { 0024 Default, 0025 Desktop, 0026 Fixed, 0027 Menu, 0028 Small, 0029 Taskbar, 0030 ToolBar 0031 }; 0032 0033 typedef std::map<FontType, FontInfo> Map; 0034 0035 //! font weight 0036 enum FontWeight 0037 { 0038 Light = 0, 0039 Normal = 38, 0040 DemiBold = 57, 0041 Bold = 69, 0042 Black = 81 0043 }; 0044 0045 //! empty constructor 0046 FontInfo( void ): 0047 _weight( Normal ), 0048 _italic( false ), 0049 _fixed( false ), 0050 _size( 0 ) 0051 {} 0052 0053 //! true if font is valid 0054 bool isValid( void ) const 0055 { return _size > 0 && !_family.empty(); } 0056 0057 //! weight 0058 FontWeight weight( void ) const 0059 { return _weight; } 0060 0061 //! italic 0062 bool italic( void ) const 0063 { return _italic; } 0064 0065 //! fixed width 0066 bool fixed( void ) const 0067 { return _fixed; } 0068 0069 //! size 0070 double size( void ) const 0071 { return _size; } 0072 0073 //! family 0074 const std::string& family( void ) const 0075 { return _family; } 0076 0077 //! convert to gtk string 0078 std::string toString( bool addQuotes = true ) const; 0079 0080 //! utilities 0081 static FontInfo fromKdeOption( std::string ); 0082 0083 std::string weightString( void ) const; 0084 std::string italicString( void ) const; 0085 0086 private: 0087 0088 //! font weight 0089 FontWeight _weight; 0090 0091 //! true if italic 0092 bool _italic; 0093 0094 //! true if fixed width 0095 bool _fixed; 0096 0097 //! font size 0098 double _size; 0099 0100 //! family 0101 std::string _family; 0102 0103 }; 0104 0105 0106 0107 } 0108 0109 #endif