CFx SDK Documentation  2022 SP0
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 
OdFontType
Definition: OdFont.h:49
@ kFontTypeShape
Definition: OdFont.h:53
@ kFontTypeShx
Definition: OdFont.h:51
@ kFontTypeTrueType
Definition: OdFont.h:52
@ kFontTypeUnknown
Definition: OdFont.h:50
@ kFontTypeRsc
Definition: OdFont.h:55
@ kFontTypeBig
Definition: OdFont.h:54
OdUInt32 OdFontSubType
Definition: OdFont.h:224
OdSmartPtr< OdFont > OdFontPtr
Definition: OdFont.h:581
OdSmartPtr< OdBaseTextIterator > OdBaseTextIteratorPtr
Definition: OdFont.h:606
unsigned int OdUInt32
unsigned short OdUInt16
int OdInt32
wchar_t OdChar
OdResult
Definition: OdResult.h:29
OdString OdString
Definition: OdString.h:1224
bool OdZero(double x, double tol=1.e-10)
Definition: OdaDefs.h:513
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
virtual OdChar nextChar()=0
virtual const OdChar * currPos() const =0
virtual const OdCharacterProperties & currProperties() const =0
Definition: OdFont.h:235
virtual OdUInt32 getAvailableChars(OdCharArray &characters)=0
virtual bool supportsVerticalMode()
Definition: OdFont.h:525
virtual void getDescriptor(OdTtfDescriptor &descr)
Definition: OdFont.h:540
virtual OdUInt32 getFontData(OdUInt32 dwTable, OdUInt32 dwOffset, void *pBuffer, OdUInt32 cbData) const
Definition: OdFont.h:568
virtual OdString getFileName() const
Definition: OdFont.h:536
virtual double getOverlinePos(double textSize) const
Definition: OdFont.h:445
void addFlag(OdUInt32 fontFlags)
Definition: OdFont.h:343
double fontAbove() const
Definition: OdFont.h:419
virtual double getAbove() const =0
virtual OdResult initialize(OdStreamBuf *pStreamBuf)=0
virtual OdResult drawCharacter(OdChar character, OdGePoint2d &advance, OdGiCommonDraw *pWd, OdTextProperties &textProperties)=0
virtual OdInt32 getLogFont(void *lpLogFont) const
Definition: OdFont.h:555
virtual bool hasCharacter(OdChar character)=0
virtual void getScore(OdUInt16 character, OdGePoint2d &advance, OdGePoint3d *pointsOver, OdGePoint3d *pointsUnder, const OdTextProperties &textFlags)
Definition: OdFont.h:561
ODRX_DECLARE_MEMBERS(OdFont)
virtual double getHeight() const
Definition: OdFont.h:397
OdUInt32 flags()
Definition: OdFont.h:297
OdUInt32 getFlags() const
Definition: OdFont.h:276
OdFont()
Definition: OdFont.h:241
void setFlags(OdUInt32 fontFlags)
Definition: OdFont.h:320
virtual double getUnderlinePos(double textSize) const
Definition: OdFont.h:434
virtual OdResult drawCharacter(OdChar character, OdGePoint2d &advance, OdGiConveyorGeometry *pGeometry, OdTextProperties &textProperties)=0
virtual double getAverageWidth()
Definition: OdFont.h:464
virtual double getInternalLeading() const
Definition: OdFont.h:406
virtual double getBelow() const =0
virtual bool isShxFont()
Definition: OdFont.h:455
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
@ kUnderlined
The border is inset.
void setTrackingPercent(double trackingPercent)
Definition: OdFont.h:207
void setInBigFont(bool value)
Definition: OdFont.h:170
OdChar m_prevChar
Definition: OdFont.h:101
void setTtfPolyDraw(bool bFlag)
Definition: OdFont.h:198
void setOverlined(bool value)
Definition: OdFont.h:139
bool isStriked() const
Definition: OdFont.h:143
bool isNormalText() const
Definition: OdFont.h:107
void setNormalText(bool value)
Definition: OdFont.h:112
void setTextQuality(OdUInt32 val)
Definition: OdFont.h:221
OdUInt16 m_flags
Definition: OdFont.h:84
void setLastChar(bool value)
Definition: OdFont.h:161
bool isVerticalText() const
Definition: OdFont.h:116
void setVerticalText(bool value)
Definition: OdFont.h:121
double m_trackingPercent
Definition: OdFont.h:85
bool isZeroNormals() const
Definition: OdFont.h:183
bool isLastChar() const
Definition: OdFont.h:156
void setUnderlined(bool value)
Definition: OdFont.h:130
void setIncludePenups(bool value)
Definition: OdFont.h:179
void setZeroNormals(bool value)
Definition: OdFont.h:188
bool isIncludePenups() const
Definition: OdFont.h:174
OdUInt16 m_textQuality
Definition: OdFont.h:86
bool isUnderlined() const
Definition: OdFont.h:125
bool ttfPolyDraw() const
Definition: OdFont.h:192
double trackingPercent() const
Definition: OdFont.h:202
bool isInBigFont() const
Definition: OdFont.h:165
OdUInt32 textQuality() const
Definition: OdFont.h:214
void setStriked(bool value)
Definition: OdFont.h:148
bool isOverlined() const
Definition: OdFont.h:134