QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_font.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(OPENNURBS_FONT_INC_)
17#define OPENNURBS_FONT_INC_
18
20{
22public:
23 ON_Font();
24 ~ON_Font();
25 // C++ default copy construction and operator= work fine.
26
27#if defined(ON_OS_WINDOWS_GDI)
28 ON_Font( const LOGFONT& logfont );
29 ON_Font& operator=( const LOGFONT& logfont );
30#endif
31
33 //
34 // ON_Object overrides
35
36 /*
37 Description:
38 Tests an object to see if its data members are correctly
39 initialized.
40 Parameters:
41 text_log - [in] if the object is not valid and text_log
42 is not NULL, then a brief englis description of the
43 reason the object is not valid is appened to the log.
44 The information appended to text_log is suitable for
45 low-level debugging purposes by programmers and is
46 not intended to be useful as a high level user
47 interface tool.
48 Returns:
49 @untitled table
50 true object is valid
51 false object is invalid, uninitialized, etc.
52 Remarks:
53 Overrides virtual ON_Object::IsValid
54 */
55 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
56
57 // virtual
58 void Dump( ON_TextLog& ) const; // for debugging
59
60 // virtual
62 ON_BinaryArchive& // serialize definition to binary archive
63 ) const;
64
65 // virtual
67 ON_BinaryArchive& // restore definition from binary archive
68 );
69
70 // virtual
71 ON_UUID ModelObjectId() const;
72
74 //
75 // Interface
76
77 enum
78 {
79
80#if defined(ON_OS_WINDOWS_GDI)
81
82 // Windows GDI facename length
83
84 // 13 November 2008 - Dale Lear
85 // Because:
86 // * Prior to this date the above "ON_OS_WINDOWS_GDI"
87 // was misspelled and this code did not get compiled.
88 // * The Windows headers defines LF_FACESIZE = 32
89 // * ON_Font has a member wchar_t m_facename[face_name_size] array
90 // * We cannot break the SDK by changing the size of ON_Font
91 //
92 // we cannot define face_name_size = LF_FACESIZE+1. So, I'm
93 // using the same "65" we use below. It is critical that
94 // face_name_size >= LF_FACESIZE+1
95 //
96 //face_name_size = LF_FACESIZE+1, // <- prior to 13 Nov but never used
97 face_name_size = 65,
98
99 // Windows GDI font weights
100 bold_weight = FW_BOLD,
101 medium_weight = FW_MEDIUM,
102 normal_weight = FW_NORMAL,
103 light_weight = FW_LIGHT,
104
105 // Windows GDI character sets
106 default_charset = DEFAULT_CHARSET,
107 symbol_charset = SYMBOL_CHARSET,
108
109#else
110
111 face_name_size = 65, // must be >= 33
112
113 bold_weight = 700,
114 medium_weight = 500,
115 normal_weight = 400,
116 light_weight = 300,
117
118 default_charset = 1,
119 symbol_charset = 2,
120
121#endif
122
123 normal_font_height = 256
124 };
125
126 // Ratio of linefeed to character height (1.6)
127 static
129
130 static
131 const int m_metrics_char; // ASCII code of character to used
132 // to get runtime "default" glyph
133 // metrics. (Currently an "I").
134
135 /*
136 Returns:
137 True if the font's character set should be SYMBOL_CHARSET;
138 */
139 static
140 bool IsSymbolFontFaceName(
141 const wchar_t* facename
142 );
143
144 void SetFontName( const wchar_t* );
145 void SetFontName( const char* );
146
147 void GetFontName( ON_wString& ) const;
148 const wchar_t* FontName() const;
149
150 void SetFontIndex(int);
151 int FontIndex() const;
152
153 /*
154 Returns:
155 The ratio (height of linefeed)/(height of I).
156 */
157 double LinefeedRatio() const;
158
159 void SetLinefeedRatio( double linefeed_ratio );
160
161 bool SetFontFaceName( const wchar_t* );
162 bool SetFontFaceName( const char* );
163
164 void GetFontFaceName( ON_wString& ) const;
165 const wchar_t* FontFaceName() const;
166
167 int FontWeight() const;
168 void SetFontWeight( int);
169
170 bool IsItalic() const;
171 void SetIsItalic( bool );
172 void SetItalic( bool );
173
174 bool IsBold() const;
175 void SetBold( bool );
176
177 // Added 7/12/07 LW
178 bool IsUnderlined() const;
179 void SetUnderlined( bool );
180
181 void Defaults();
182
183 /*
184 Returns:
185 Height of the 'I' character when the font is drawn
186 with m_logfont.lfHeight = ON_Font::normal_font_height.
187 */
188 int HeightOfI() const;
189
190 /*
191 Returns:
192 Height of a linefeed when the font is drawn
193 with m_logfont.lfHeight = ON_Font::normal_font_height.
194 */
195 int HeightOfLinefeed() const;
196
197 /*
198 Description:
199 Returns the ratio of the height of a typical upper case letter
200 to the height of a whole character cell.
201
202 Parameters:
203 none
204
205 Returns:
206 double - ratio of Windows Font Height / m_HeightOfH
207 */
208 double AscentRatio() const;
209
210 /*
211 Description:
212 Compare the visible characteristics to another font
213
214 Parameters:
215 font_to_compare - [in] The cont to compare this one to
216 bCompareName - [in] if this is set, test if the names match
217 otherwise don't compare the names
218
219 Returns:
220 true if font_to_compare matches this one
221 false if font_to_match doesn't match this one
222
223 Added for v5 - 5/20/07
224 */
225 bool CompareFontCharacteristics( ON_Font& font_to_compare, bool bCompareName) const;
226
227#if defined(ON_OS_WINDOWS_GDI)
228 bool SetLogFont( const LOGFONT& logfont );
229 const LOGFONT& LogFont() const;
230#endif
231
232public:
233 ON_wString m_font_name; // Name of this font in the Rhino UI
234 int m_font_weight; // Same as m_logfont.lfWeight
235 bool m_font_italic; // Same as m_logfont.lfItalic
236 bool m_font_underlined;// Same as m_logfont.lfUnderlined (Added 7/12/07 LW)
237 double m_linefeed_ratio; // defaults to static s_linefeed_ratio.
238 int m_font_index; // font index in Rhino font table
240 wchar_t m_facename[face_name_size]; // same as m_logfont.lfFaceName (
241
242public:
243#if defined(ON_OS_WINDOWS_GDI)
244 LOGFONT m_logfont;
245#endif
246
247private:
248 // volitile - can be changed by ON_Font::HeightOfI() const.
249 int m_I_height; // height of the 'I' character when the font is drawn
250 // with m_logfont.lfHeight = 256.
251};
252
253#endif
Definition opennurbs_archive.h:152
Definition opennurbs_font.h:20
int m_font_index
Definition opennurbs_font.h:238
double m_linefeed_ratio
Definition opennurbs_font.h:237
bool m_font_italic
Definition opennurbs_font.h:235
int m_font_weight
Definition opennurbs_font.h:234
ON_wString m_font_name
Definition opennurbs_font.h:233
ON_OBJECT_DECLARE(ON_Font)
static const int m_metrics_char
Definition opennurbs_font.h:131
ON_UUID m_font_id
Definition opennurbs_font.h:239
static const double m_default_linefeed_ratio
Definition opennurbs_font.h:128
bool CompareFontCharacteristics(ON_Font &font_to_compare, bool bCompareName) const
int m_I_height
Definition opennurbs_font.h:249
bool m_font_underlined
Definition opennurbs_font.h:236
Definition opennurbs_object.h:393
virtual void Dump(ON_TextLog &) const
Definition opennurbs_object.cpp:1695
virtual ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const =0
virtual ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
Definition opennurbs_object.cpp:1734
virtual ON_UUID ModelObjectId() const
Definition opennurbs_object.cpp:1622
ON_Object & operator=(const ON_Object &)
Definition opennurbs_object.cpp:1362
virtual ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_object.cpp:1714
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_string.h:392
#define ON_CLASS
Definition opennurbs_defines.h:91
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362