CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TtfDescriptor.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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
54public:
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_
unsigned int OdUInt32
unsigned short OdUInt16
wchar_t OdChar
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:516
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
TextRenderingMode
Definition: TtfDescriptor.h:34
@ kTextRenderingBasedA
Definition: TtfDescriptor.h:35
@ kTextRenderingBasedM
Definition: TtfDescriptor.h:36
void empty()
void setTextRenderingMode(TextRenderingMode renderingMode)
const OdString & typeface() const
Definition: TtfDescriptor.h:88
void clearFileName()
Definition: TtfDescriptor.h:98
void setCharSet(int charset)
void setTtfFlags(bool bold, bool italic, int charset, int pitchAndFamily)
int getFamily() const
int getPitch() const
bool isBold() const
void addTypeface(OdChar typeface)
void setTtfFlags(OdUInt32 flags)
void setBold(bool bold)
void setTypeFace(const OdString &typeface)
int pitchAndFamily() const
TextRenderingMode textRenderingMode() const
bool isItalic() const
void setPitchAndFamily(int pitchAndFamily)
void setItalic(bool italic)
OdUInt32 getTtfFlags() const
Definition: TtfDescriptor.h:93
OdUInt16 charSet() const
OdTtfDescriptor(const OdString &typeface, bool bold, bool italic, int charset, int pitchAndFamily)
Definition: TtfDescriptor.h:72
void setFileName(const OdString &filename)
const OdString & fileName() const
Definition: TtfDescriptor.h:83
void getTtfFlags(bool &bold, bool &italic, int &charset, int &pitchAndFamily) const