CFx SDK Documentation  2020SP3
OdFont.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 
25 
26 
27 // OdFont.h: interface for the OdFont class.
28 //
30 
31 #if !defined(AFX_ODFONT_H__0B76813A_DCFA_450E_8591_B6C6F1ED76EC__INCLUDED_)
32 #define AFX_ODFONT_H__0B76813A_DCFA_450E_8591_B6C6F1ED76EC__INCLUDED_
33 
34 #include "RxObject.h"
35 #include "OdArray.h"
36 #include "OdCharMapper.h"
37 
38 // For memset below
39 #include <memory.h>
40 
41 class OdGiCommonDraw;
43 class OdGePoint2d;
44 class OdGePoint3d;
45 class OdStreamBuf;
46 
47 #include "TD_PackPush.h"
48 
49 typedef enum {
50  kFontTypeUnknown = 0, // Unknown.
51  kFontTypeShx = 1, // SHX font.
52  kFontTypeTrueType = 2, // TrueType font.
53  kFontTypeShape = 3, // Shape file.
54  kFontTypeBig = 4, // BigFont file.
55  kFontTypeRsc = 5 // MicroStation Recource file.
57 
64 {
66  { ::memset(this, 0, sizeof(*this)); }
67 
69  bool bOverlined;
70  bool bStriked;
71  bool bLastChar;
72  bool bInBigFont;
73  bool bAsian;
74  bool bValid;
75 };
76 
83 {
87  enum
88  {
89  kNormalText = 0x01,
90  kVerticalText = 0x02,
91  kUnderlined = 0x04,
92  kOverlined = 0x08,
93  kLastChar = 0x10,
94  kInBigFont = 0x20,
95  kInclPenups = 0x40,
96  kZeroNormals = 0x80,
97  kBezierCurves = 0x100,
98  kStriked = 0x200
99  ,kExtentsCalculation = 0x4000 //FELIX_CHANGE
100  };
102 public:
103  OdTextProperties() : m_flags(0), m_trackingPercent(0.0), m_textQuality(50), m_prevChar(0) {}
107  bool isNormalText() const { return GETBIT(m_flags, kNormalText); }
112  void setNormalText(bool value) { SETBIT(m_flags, kNormalText, value); }
116  bool isVerticalText() const { return GETBIT(m_flags, kVerticalText); }
121  void setVerticalText(bool value) { SETBIT(m_flags, kVerticalText, value); }
125  bool isUnderlined() const { return GETBIT(m_flags, kUnderlined); }
130  void setUnderlined(bool value) { SETBIT(m_flags, kUnderlined, value); }
134  bool isOverlined() const { return GETBIT(m_flags, kOverlined); }
139  void setOverlined(bool value) { SETBIT(m_flags, kOverlined, value); }
143  bool isStriked() const { return GETBIT(m_flags, kStriked); }
148  void setStriked(bool value) { SETBIT(m_flags, kStriked, value); }
156  bool isLastChar() const { return GETBIT(m_flags, kLastChar); }
161  void setLastChar(bool value) { SETBIT(m_flags, kLastChar, value); }
165  bool isInBigFont() const { return GETBIT(m_flags, kInBigFont); }
170  void setInBigFont(bool value) { SETBIT(m_flags, kInBigFont, value); }
174  bool isIncludePenups() const { return GETBIT(m_flags, kInclPenups); }
179  void setIncludePenups(bool value) { SETBIT(m_flags, kInclPenups, value); }
183  bool isZeroNormals() const { return GETBIT(m_flags, kZeroNormals); }
188  void setZeroNormals(bool value) { SETBIT(m_flags, kZeroNormals, value); }
192  bool ttfPolyDraw() const { return GETBIT(m_flags, kBezierCurves); }
198  void setTtfPolyDraw(bool bFlag) { SETBIT(m_flags, kBezierCurves, bFlag); }
202  double trackingPercent() const {return m_trackingPercent; }
207  void setTrackingPercent(double trackingPercent) { m_trackingPercent = trackingPercent; }
208 
214  OdUInt32 textQuality() const { return m_textQuality; }
215 
221  void setTextQuality(OdUInt32 val) { m_textQuality = (OdUInt16)val; }
222 };
223 
225 
226 class OdGePoint2d;
228 class OdTtfDescriptor;
229 
235 {
236  OdUInt32 m_Flags;
237 
238 public:
240 
241  OdFont() : m_Flags(0) {}
242 
243  enum
244  {
245  kBigFont10 = 0x0001,
246  kUniFont10 = 0x0002,
247  kFont10 = 0x0004,
248  kFont11 = 0x0008,
249  kFont10A = 0x0010,
250  kTrueType = 0x0020,
251  kFontGdt = 0x0040,
252  kFontSimplex6 = 0x0080,
253  kShapes11 = 0x0100,
254  kFontRsc = 0x0200 // MicroStation Resource file.
255  };
256 
276  OdUInt32 getFlags() const { return m_Flags; }
297  OdUInt32 flags() { return m_Flags; }
298 
320  void setFlags(OdUInt32 fontFlags) { m_Flags = fontFlags; }
321 
343  void addFlag(OdUInt32 fontFlags) { m_Flags |= fontFlags; }
344 
353  virtual OdResult initialize(OdStreamBuf* pStreamBuf) = 0;
362  virtual OdResult drawCharacter(OdChar character, OdGePoint2d& advance, OdGiCommonDraw* pWd,
363  OdTextProperties& textProperties) = 0;
364 
372  virtual OdResult drawCharacter(OdChar character, OdGePoint2d& advance,
373  OdGiConveyorGeometry* pGeometry,
374  OdTextProperties& textProperties) = 0;
378  virtual double getAbove() const = 0;
382  virtual double getBelow() const = 0;
387  virtual OdUInt32 getAvailableChars(OdCharArray& characters) = 0;
392  virtual bool hasCharacter(OdChar character) = 0;
393 
397  virtual double getHeight() const // MKU 20.02.2003
398  {
399  return getAbove() + getBelow();
400  }
406  virtual double getInternalLeading() const
407  {
408  return 0;
409  }
410 
411 
412  // removed here from GiContextForDbDatabase.cpp // MKU 04.03.2003
413 
419  double fontAbove() const
420  {
421  double above = getAbove();
422  if(OdZero(above))
423  {
424  above = 1.0;
425  }
426  return above;
427  }
434  virtual double getUnderlinePos(double textSize) const
435  {
436  return -0.2 * textSize;
437 
438  }
445  virtual double getOverlinePos(double textSize) const
446  {
447  return 1.2 * textSize;
448  }
449 
455  virtual bool isShxFont()
456  {
457  return true;
458  }
464  virtual double getAverageWidth()
465  {
466  return 0.0;
467  }
468 
495  virtual void getScore( OdUInt16 character,
496  OdGePoint2d& advance,
497  OdGePoint3d* pointsOver,
498  OdGePoint3d* pointsUnder,
499  const OdTextProperties& textFlags);
500 
513  virtual OdUInt32 getFontData(
514  OdUInt32 dwTable, // metric table to query
515  OdUInt32 dwOffset, // offset into table being queried
516  void * pBuffer, // pointer to buffer for returned data
517  OdUInt32 cbData ) const;
518 
525  virtual bool supportsVerticalMode()
526  {
527  return false;
528  }
529 
536  virtual OdString getFileName() const
537  {
538  return OdString();
539  }
540  virtual void getDescriptor(OdTtfDescriptor& descr)
541  {
542  }
543 
555  virtual OdInt32 getLogFont(void* lpLogFont) const
556  {
557  return -1;
558  }
559 };
560 
561 inline void OdFont::getScore( OdUInt16 /*character*/,
562  OdGePoint2d& /*advance*/,
563  OdGePoint3d* /*pointsOver*/,
564  OdGePoint3d* /*pointsUnder*/,
565  const OdTextProperties& /*flags*/ )
566  {}
567 
569  OdUInt32 /*dwTable*/, // metric table to query
570  OdUInt32 /*dwOffset*/, // offset into table being queried
571  void * /*lpvBuffer*/, // pointer to buffer for returned data
572  OdUInt32 /*cbData*/ ) const
573  {
574  return OdUInt32(-1);
575  }
576 
577 
582 
589 {
590 public:
591  virtual OdChar nextChar() = 0;
595  virtual const OdCharacterProperties& currProperties() const = 0;
596 
600  virtual const OdChar* currPos() const = 0;
601 };
602 
607 
608 #include "TD_PackPop.h"
609 
610 #endif // !defined(AFX_ODFONT_H__0B76813A_DCFA_450E_8591_B6C6F1ED76EC__INCLUDED_)
611 
GETBIT
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
FIRSTDLL_EXPORT
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
OdResult
OdResult
Definition: OdResult.h:29
OdString
Definition: OdString.h:95
OdFont::OdFont
OdFont()
Definition: OdFont.h:241
OdFont::fontAbove
double fontAbove() const
Definition: OdFont.h:419
OdFont::supportsVerticalMode
virtual bool supportsVerticalMode()
Definition: OdFont.h:525
OdTextProperties::setTrackingPercent
void setTrackingPercent(double trackingPercent)
Definition: OdFont.h:207
OdTextProperties::isUnderlined
bool isUnderlined() const
Definition: OdFont.h:125
OdTextProperties::setOverlined
void setOverlined(bool value)
Definition: OdFont.h:139
OdCharMapper.h
OdFont::getHeight
virtual double getHeight() const
Definition: OdFont.h:397
OdRxObject
Definition: RxObject.h:564
OdTextProperties::isZeroNormals
bool isZeroNormals() const
Definition: OdFont.h:183
kFontTypeBig
@ kFontTypeBig
Definition: OdFont.h:54
SETBIT
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
OdTextProperties::m_flags
OdUInt16 m_flags
Definition: OdFont.h:84
OdTextProperties::setLastChar
void setLastChar(bool value)
Definition: OdFont.h:161
OdFont::getDescriptor
virtual void getDescriptor(OdTtfDescriptor &descr)
Definition: OdFont.h:540
OdFont::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdFont)
OdFont::getInternalLeading
virtual double getInternalLeading() const
Definition: OdFont.h:406
OdCharacterProperties::OdCharacterProperties
OdCharacterProperties()
Definition: OdFont.h:65
OdFont::addFlag
void addFlag(OdUInt32 fontFlags)
Definition: OdFont.h:343
kFontTypeShx
@ kFontTypeShx
Definition: OdFont.h:51
OdFont::getFlags
OdUInt32 getFlags() const
Definition: OdFont.h:276
OdArray
Definition: OdArray.h:591
OdTextProperties::isLastChar
bool isLastChar() const
Definition: OdFont.h:156
TD_PackPop.h
OdFont::getAverageWidth
virtual double getAverageWidth()
Definition: OdFont.h:464
OdUInt16
unsigned short OdUInt16
Definition: OdPlatformSettings.h:760
RxObject.h
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdCharacterProperties::bUnderlined
bool bUnderlined
Definition: OdFont.h:68
OdGiCommonDraw
Definition: GiCommonDraw.h:572
kFontTypeUnknown
@ kFontTypeUnknown
Definition: OdFont.h:50
OdFont::hasCharacter
virtual bool hasCharacter(OdChar character)=0
OdTextProperties::setIncludePenups
void setIncludePenups(bool value)
Definition: OdFont.h:179
OdCharacterProperties::bInBigFont
bool bInBigFont
Definition: OdFont.h:72
OdPdfPublish::Border::kUnderlined
@ kUnderlined
The border is inset.
Definition: PdfPublishCommon.h:271
OdFont::getBelow
virtual double getBelow() const =0
OdGiConveyorGeometry
Definition: GiConveyorGeometry.h:270
OdTextProperties::setNormalText
void setNormalText(bool value)
Definition: OdFont.h:112
OdFont::drawCharacter
virtual OdResult drawCharacter(OdChar character, OdGePoint2d &advance, OdGiCommonDraw *pWd, OdTextProperties &textProperties)=0
OdFont::setFlags
void setFlags(OdUInt32 fontFlags)
Definition: OdFont.h:320
OdFont::getLogFont
virtual OdInt32 getLogFont(void *lpLogFont) const
Definition: OdFont.h:555
OdBaseTextIterator
Definition: OdFont.h:589
OdCharacterProperties
Definition: OdFont.h:64
OdFont::flags
OdUInt32 flags()
Definition: OdFont.h:297
OdArray.h
OdBaseTextIterator::currPos
virtual const OdChar * currPos() const =0
OdString
OdString OdString
Definition: OdString.h:1224
OdTextProperties::m_trackingPercent
double m_trackingPercent
Definition: OdFont.h:85
OdSmartPtr< OdFont >
OdGePoint3d
Definition: GePoint3d.h:55
OdTextProperties::setTextQuality
void setTextQuality(OdUInt32 val)
Definition: OdFont.h:221
OdInt32
int OdInt32
Definition: OdPlatformSettings.h:782
OdTextProperties::m_prevChar
OdChar m_prevChar
Definition: OdFont.h:101
OdTextProperties::setVerticalText
void setVerticalText(bool value)
Definition: OdFont.h:121
OdTextProperties::isStriked
bool isStriked() const
Definition: OdFont.h:143
OdCharacterProperties::bOverlined
bool bOverlined
Definition: OdFont.h:69
OdFont::getFontData
virtual OdUInt32 getFontData(OdUInt32 dwTable, OdUInt32 dwOffset, void *pBuffer, OdUInt32 cbData) const
Definition: OdFont.h:568
OdFontSubType
OdUInt32 OdFontSubType
Definition: OdFont.h:224
OdTextProperties::trackingPercent
double trackingPercent() const
Definition: OdFont.h:202
OdTextProperties::ttfPolyDraw
bool ttfPolyDraw() const
Definition: OdFont.h:192
OdTextProperties::isVerticalText
bool isVerticalText() const
Definition: OdFont.h:116
OdFontPtr
OdSmartPtr< OdFont > OdFontPtr
Definition: OdFont.h:581
OdTextProperties
Definition: OdFont.h:83
OdChar
wchar_t OdChar
Definition: OdPlatformSettings.h:745
OdTextProperties::isNormalText
bool isNormalText() const
Definition: OdFont.h:107
OdCharacterProperties::bStriked
bool bStriked
Definition: OdFont.h:70
kFontTypeShape
@ kFontTypeShape
Definition: OdFont.h:53
OdTextProperties::isInBigFont
bool isInBigFont() const
Definition: OdFont.h:165
TD_PackPush.h
OdFont::getAbove
virtual double getAbove() const =0
OdFont::drawCharacter
virtual OdResult drawCharacter(OdChar character, OdGePoint2d &advance, OdGiConveyorGeometry *pGeometry, OdTextProperties &textProperties)=0
OdFont::getUnderlinePos
virtual double getUnderlinePos(double textSize) const
Definition: OdFont.h:434
OdCharacterProperties::bAsian
bool bAsian
Definition: OdFont.h:73
OdTextProperties::setZeroNormals
void setZeroNormals(bool value)
Definition: OdFont.h:188
OdStreamBuf
Definition: OdStreamBuf.h:67
OdTextProperties::setUnderlined
void setUnderlined(bool value)
Definition: OdFont.h:130
OdTextProperties::isOverlined
bool isOverlined() const
Definition: OdFont.h:134
OdCharacterProperties::bValid
bool bValid
Definition: OdFont.h:74
OdTextProperties::m_textQuality
OdUInt16 m_textQuality
Definition: OdFont.h:86
OdTextProperties::isIncludePenups
bool isIncludePenups() const
Definition: OdFont.h:174
OdCharacterProperties::bLastChar
bool bLastChar
Definition: OdFont.h:71
value
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
OdFont::getScore
virtual void getScore(OdUInt16 character, OdGePoint2d &advance, OdGePoint3d *pointsOver, OdGePoint3d *pointsUnder, const OdTextProperties &textFlags)
Definition: OdFont.h:561
OdFont::getOverlinePos
virtual double getOverlinePos(double textSize) const
Definition: OdFont.h:445
OdFont::getFileName
virtual OdString getFileName() const
Definition: OdFont.h:536
OdFontType
OdFontType
Definition: OdFont.h:49
OdTextProperties::textQuality
OdUInt32 textQuality() const
Definition: OdFont.h:214
OdFont::isShxFont
virtual bool isShxFont()
Definition: OdFont.h:455
OdTextProperties::setInBigFont
void setInBigFont(bool value)
Definition: OdFont.h:170
OdBaseTextIterator::nextChar
virtual OdChar nextChar()=0
OdFont::getAvailableChars
virtual OdUInt32 getAvailableChars(OdCharArray &characters)=0
OdTextProperties::OdTextProperties
OdTextProperties()
Definition: OdFont.h:103
OdFont
Definition: OdFont.h:235
OdTextProperties::setStriked
void setStriked(bool value)
Definition: OdFont.h:148
OdBaseTextIteratorPtr
OdSmartPtr< OdBaseTextIterator > OdBaseTextIteratorPtr
Definition: OdFont.h:606
OdFont::initialize
virtual OdResult initialize(OdStreamBuf *pStreamBuf)=0
OdZero
bool OdZero(double x, double tol=1.e-10)
Definition: OdaDefs.h:513
kFontTypeTrueType
@ kFontTypeTrueType
Definition: OdFont.h:52
OdTtfDescriptor
Definition: TtfDescriptor.h:46
OdTextProperties::setTtfPolyDraw
void setTtfPolyDraw(bool bFlag)
Definition: OdFont.h:198
kFontTypeRsc
@ kFontTypeRsc
Definition: OdFont.h:55
OdGePoint2d
Definition: GePoint2d.h:60
OdBaseTextIterator::currProperties
virtual const OdCharacterProperties & currProperties() const =0