CFx SDK Documentation  2020SP3
TtfDescriptor.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef _OdTtfDescriptor_h_Included_
25 #define _OdTtfDescriptor_h_Included_
26 
27 #include "TD_PackPush.h"
28 
29 #include "Gi/Gi.h"
30 #include "OdString.h"
31 #include "OdFont.h"
32 
34 {
37 };
38 
46 {
47  // Members
48 
49  OdUInt32 m_nFlags;
50  OdString m_sFontFile;
51  OdString m_Typeface;
52  TextRenderingMode m_renderingMode;
53 
54 public:
55  // Constructor
56 
57  OdTtfDescriptor() : m_nFlags(0), m_renderingMode(kTextRenderingBasedA)
58  {
59  }
60 
72  OdTtfDescriptor(const OdString& typeface, bool bold, bool italic, int charset, int pitchAndFamily)
73  : m_Typeface(typeface), m_nFlags(0), m_renderingMode(kTextRenderingBasedA)
74  {
75  setTtfFlags(bold, italic, charset, pitchAndFamily);
76  }
77 
78  // Accessors /transformers
79 
83  const OdString &fileName() const { return m_sFontFile; }
84 
88  const OdString &typeface() const { return m_Typeface; }
89 
93  OdUInt32 getTtfFlags() const { return m_nFlags; }
94 
99  {
100  m_sFontFile.empty();
101  }
106  {
107  m_Typeface.empty();
108  }
112  void addTypeface(OdChar typeface)
113  {
114  m_Typeface += typeface;
115  }
116 
128  void getTtfFlags(bool& bold, bool& italic, int& charset, int& pitchAndFamily) const
129  {
130  bold = isBold();
131  italic = isItalic();
132  charset = charSet();
133  pitchAndFamily = this->pitchAndFamily();
134  }
135 
140  void setFileName(const OdString& filename) { m_sFontFile = filename; }
145  void setTypeFace(const OdString& typeface) { m_Typeface = typeface; }
150  void setTtfFlags(OdUInt32 flags) { m_nFlags = flags; }
163  void setTtfFlags(bool bold, bool italic, int charset, int pitchAndFamily)
164  {
165  setBold(bold);
166  setItalic(italic);
167  setCharSet(charset);
168  setPitchAndFamily(pitchAndFamily);
169  }
170 
175  void setBold(bool bold) { SETBIT(m_nFlags, 0x02000000, bold); }
180  void setItalic(bool italic) { SETBIT(m_nFlags, 0x01000000, italic); }
185  void setCharSet(int charset) { m_nFlags = ((m_nFlags & 0xFFFF00FF) | ((charset << 8) & 0x0000FF00)); }
194  void setPitchAndFamily(int pitchAndFamily) { m_nFlags = ((m_nFlags & 0xFFFFFF00) | (pitchAndFamily & 0x000000FF)); }
195 
199  bool isBold() const { return GETBIT(m_nFlags, 0x02000000); }
203  bool isItalic() const { return GETBIT(m_nFlags, 0x01000000); }
207  OdUInt16 charSet() const { return OdUInt16((m_nFlags & 0x0000ff00) >> 8); }
215  int pitchAndFamily() const { return (m_nFlags & 0x000000ff); }
216 
220  int getPitch() const { return (pitchAndFamily() & 0x00000003); }
224  int getFamily() const { return (pitchAndFamily() & 0x000000f0); }
225 
229  TextRenderingMode textRenderingMode() const { return m_renderingMode; }
230 
234  void setTextRenderingMode(TextRenderingMode renderingMode) { m_renderingMode = renderingMode; }
235 
236 };
237 
238 #include "TD_PackPop.h"
239 
240 #endif // _OdTtfDescriptor_h_Included_
GETBIT
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
FIRSTDLL_EXPORT
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
OdTtfDescriptor::pitchAndFamily
int pitchAndFamily() const
Definition: TtfDescriptor.h:215
OdString
Definition: OdString.h:95
OdTtfDescriptor::setFileName
void setFileName(const OdString &filename)
Definition: TtfDescriptor.h:140
kTextRenderingBasedM
@ kTextRenderingBasedM
Definition: TtfDescriptor.h:36
OdTtfDescriptor::typeface
const OdString & typeface() const
Definition: TtfDescriptor.h:88
OdTtfDescriptor::setTypeFace
void setTypeFace(const OdString &typeface)
Definition: TtfDescriptor.h:145
SETBIT
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
TD_PackPop.h
OdUInt16
unsigned short OdUInt16
Definition: OdPlatformSettings.h:760
OdTtfDescriptor::setTtfFlags
void setTtfFlags(bool bold, bool italic, int charset, int pitchAndFamily)
Definition: TtfDescriptor.h:163
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdString.h
OdTtfDescriptor::addTypeface
void addTypeface(OdChar typeface)
Definition: TtfDescriptor.h:112
kTextRenderingBasedA
@ kTextRenderingBasedA
Definition: TtfDescriptor.h:35
OdTtfDescriptor::setCharSet
void setCharSet(int charset)
Definition: TtfDescriptor.h:185
OdTtfDescriptor::charSet
OdUInt16 charSet() const
Definition: TtfDescriptor.h:207
OdChar
wchar_t OdChar
Definition: OdPlatformSettings.h:745
TD_PackPush.h
OdTtfDescriptor::isItalic
bool isItalic() const
Definition: TtfDescriptor.h:203
OdTtfDescriptor::setPitchAndFamily
void setPitchAndFamily(int pitchAndFamily)
Definition: TtfDescriptor.h:194
OdTtfDescriptor::getTtfFlags
void getTtfFlags(bool &bold, bool &italic, int &charset, int &pitchAndFamily) const
Definition: TtfDescriptor.h:128
OdTtfDescriptor::setTextRenderingMode
void setTextRenderingMode(TextRenderingMode renderingMode)
Definition: TtfDescriptor.h:234
OdTtfDescriptor::setItalic
void setItalic(bool italic)
Definition: TtfDescriptor.h:180
OdTtfDescriptor::fileName
const OdString & fileName() const
Definition: TtfDescriptor.h:83
OdTtfDescriptor::setBold
void setBold(bool bold)
Definition: TtfDescriptor.h:175
OdTtfDescriptor::isBold
bool isBold() const
Definition: TtfDescriptor.h:199
OdTtfDescriptor::OdTtfDescriptor
OdTtfDescriptor()
Definition: TtfDescriptor.h:57
TextRenderingMode
TextRenderingMode
Definition: TtfDescriptor.h:34
OdTtfDescriptor::clearFileName
void clearFileName()
Definition: TtfDescriptor.h:98
OdString::empty
void empty()
OdTtfDescriptor::textRenderingMode
TextRenderingMode textRenderingMode() const
Definition: TtfDescriptor.h:229
OdTtfDescriptor::getPitch
int getPitch() const
Definition: TtfDescriptor.h:220
OdTtfDescriptor::setTtfFlags
void setTtfFlags(OdUInt32 flags)
Definition: TtfDescriptor.h:150
OdTtfDescriptor::getFamily
int getFamily() const
Definition: TtfDescriptor.h:224
OdTtfDescriptor::getTtfFlags
OdUInt32 getTtfFlags() const
Definition: TtfDescriptor.h:93
OdTtfDescriptor
Definition: TtfDescriptor.h:46
OdFont.h
OdTtfDescriptor::clearTypeface
void clearTypeface()
Definition: TtfDescriptor.h:105
OdTtfDescriptor::OdTtfDescriptor
OdTtfDescriptor(const OdString &typeface, bool bold, bool italic, int charset, int pitchAndFamily)
Definition: TtfDescriptor.h:72
Gi.h