|
bpp-core
2.1.0
|
00001 // 00002 // File: Font.h 00003 // Created by: Julien Dutheil 00004 // Created on: Mon Mar 03 2008 00005 // 00006 00007 /* 00008 Copyright or © or Copr. CNRS, (November 17, 2004) 00009 00010 This software is a computer program whose purpose is to provide utilitary 00011 classes. This file belongs to the Bio++ Project. 00012 00013 This software is governed by the CeCILL license under French law and 00014 abiding by the rules of distribution of free software. You can use, 00015 modify and/ or redistribute the software under the terms of the CeCILL 00016 license as circulated by CEA, CNRS and INRIA at the following URL 00017 "http://www.cecill.info". 00018 00019 As a counterpart to the access to the source code and rights to copy, 00020 modify and redistribute granted by the license, users are provided only 00021 with a limited warranty and the software's author, the holder of the 00022 economic rights, and the successive licensors have only limited 00023 liability. 00024 00025 In this respect, the user's attention is drawn to the risks associated 00026 with loading, using, modifying and/or developing or reproducing the 00027 software by the user in light of its specific status of free software, 00028 that may mean that it is complicated to manipulate, and that also 00029 therefore means that it is reserved for developers and experienced 00030 professionals having in-depth computer knowledge. Users are therefore 00031 encouraged to load and test the software's suitability as regards their 00032 requirements in conditions enabling the security of their systems and/or 00033 data to be ensured and, more generally, to use and operate it in the 00034 same conditions as regards security. 00035 00036 The fact that you are presently reading this means that you have had 00037 knowledge of the CeCILL license and that you accept its terms. 00038 */ 00039 00040 #ifndef _FONT_H_ 00041 #define _FONT_H_ 00042 00043 #include "../../Clonable.h" 00044 #include "../../Text/TextTools.h" 00045 00046 //From the STL: 00047 #include <map> 00048 #include <string> 00049 00050 namespace bpp 00051 { 00052 00056 class Font: 00057 public virtual Clonable 00058 { 00059 private: 00060 std::string family_; 00061 short int style_; 00062 short int weight_; 00063 unsigned int size_; 00064 mutable std::map<short int, std::string> styleDesc_; 00065 mutable std::map<short int, std::string> weightDesc_; 00066 00067 public: 00068 Font(const std::string& family = "Default", short int style = STYLE_NORMAL, short int weight = WEIGHT_NORMAL, unsigned int size = 12): 00069 family_(family), style_(style), weight_(weight), size_(size), styleDesc_(), weightDesc_() 00070 { 00071 init_(); 00072 } 00073 00074 virtual ~Font() {} 00075 00076 #ifdef NO_VIRTUAL_COV 00077 Clonable* 00078 #else 00079 Font* 00080 #endif 00081 clone() const { return new Font(*this); } 00082 00083 private: 00084 void init_(); 00085 00086 public: 00087 bool operator==(const Font& font) const 00088 { 00089 return family_ == font.family_ 00090 && style_ == font.style_ 00091 && weight_ == font.weight_; 00092 } 00093 00097 const std::string& getFamily() const { return family_; } 00098 00102 const short int getStyle() const { return style_; } 00103 00108 const short int getShape() const { return style_; } 00109 00113 const short int getWeight() const { return weight_; } 00114 00119 const short int getSeries() const { return weight_; } 00120 00124 const unsigned int& getSize() const { return size_; } 00125 00129 void setFamily(const std::string& family) { family_ = family; } 00130 00134 void setStyle(short int style) { style_ = style; } 00135 00140 void setShape(short int shape) { style_ = shape; } 00141 00142 00146 void setWeight(short int weight) { weight_ = weight; } 00147 00152 void setSeries(short int series) { weight_ = series; } 00153 00157 void setSize(unsigned int size) { size_ = size; } 00158 00162 std::string toString() const 00163 { 00164 return family_ + "/" + styleDesc_[style_] + "/" + weightDesc_[weight_] + "/" + TextTools::toString(size_); 00165 } 00166 00167 public: 00168 static const short int STYLE_NORMAL; 00169 static const short int STYLE_ITALIC; 00170 00171 static const short int WEIGHT_NORMAL; 00172 static const short int WEIGHT_BOLD; 00173 }; 00174 00175 } // end of namespace bpp. 00176 00177 #endif //_FONT_H_ 00178 00179