zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, Open Design Alliance (the "Alliance"). 
// All rights reserved. 
// 
// This software and its documentation and related materials are owned by 
// the Alliance. The software may only be incorporated into application 
// programs owned by members of the Alliance, subject to a signed 
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable  
// trade secrets of the Alliance and its suppliers. The software is also 
// protected by copyright law and international treaty provisions. Application  
// programs incorporating this software must include the following statement 
// with their copyright notices:
//   
//   This application incorporates Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 by Open Design Alliance. 
//   All rights reserved.
//
// By use of this software, its documentation or related materials, you 
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
 
 
 
 
// OdFont.h: interface for the OdFont class.
//
//////////////////////////////////////////////////////////////////////
 
#if !defined(AFX_ODFONT_H__0B76813A_DCFA_450E_8591_B6C6F1ED76EC__INCLUDED_)
#define AFX_ODFONT_H__0B76813A_DCFA_450E_8591_B6C6F1ED76EC__INCLUDED_
 
#include "RxObject.h"
#include "OdArray.h"
#include "OdCharMapper.h"
 
// For memset below
#include <memory.h>
 
class OdGiCommonDraw;
class OdGiConveyorGeometry;
class OdGePoint2d;
class OdGePoint3d;
class OdStreamBuf;
 
#include "TD_PackPush.h"
 
typedef enum {
  kFontTypeUnknown    = 0,  // Unknown.
  kFontTypeShx        = 1,  // SHX font.
  kFontTypeTrueType   = 2,  // TrueType font.
  kFontTypeShape      = 3,  // Shape file.
  kFontTypeBig        = 4,  // BigFont file.
  kFontTypeRsc        = 5   // MicroStation Recource file.
} OdFontType;
 
/** \details
    This structure implements character properties in an OdGi context. 
    Library: TD_Root
    <group !!RECORDS_TD_APIRef>
*/
struct FIRSTDLL_EXPORT OdCharacterProperties
{
  OdCharacterProperties()
  { ::memset(this, 0, sizeof(*this)); }
 
  bool  bUnderlined;
  bool  bOverlined;
  bool  bStriked;
  bool  bLastChar;
  bool  bInBigFont;
  bool  bAsian;
  bool  bValid;
};
 
/** \details
    This structure implements text properties in an OdGi context.
    Library: TD_Root
    <group !!RECORDS_TD_APIRef>
*/
struct FIRSTDLL_EXPORT OdTextProperties
{
  OdUInt16 m_flags;
  double   m_trackingPercent;
  OdUInt16 m_textQuality;
  enum
  {
    kNormalText   = 0x01,
    kVerticalText = 0x02,
    kUnderlined   = 0x04,
    kOverlined    = 0x08,
    kLastChar     = 0x10,
    kInBigFont    = 0x20,
    kInclPenups   = 0x40,
    kZeroNormals  = 0x80,
    kBezierCurves = 0x100,
    kStriked      = 0x200
  };
  OdChar  m_prevChar;
public:
  OdTextProperties() : m_flags(0), m_trackingPercent(0.0), m_textQuality(50), m_prevChar(0) {}
  /** \details
    Returns true if and only if the Normal Text flag is set for this TextProperties object.
  */
  bool isNormalText() const { return GETBIT(m_flags, kNormalText); }
  /** \details
    Controls the Normal Text flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setNormalText(bool value) { SETBIT(m_flags, kNormalText, value); }
  /** \details
    Returns true if and only if the Vertical Text flag is set for this TextProperties object.
  */
  bool isVerticalText() const { return GETBIT(m_flags, kVerticalText); }
  /** \details
    Controls the Vertical Text flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setVerticalText(bool value) { SETBIT(m_flags, kVerticalText, value); }
  /** \details
    Returns true if and only if the Underlined flag is set for this TextProperties object.
  */
  bool isUnderlined() const { return GETBIT(m_flags, kUnderlined); }
  /** \details
    Controls the Underlined flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setUnderlined(bool value) { SETBIT(m_flags, kUnderlined, value); }
  /** \details
    Returns true if and only if the Overlined flag is set for this TextProperties object.
  */
  bool isOverlined() const { return GETBIT(m_flags, kOverlined); }
  /** \details
    Controls the Overlined flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setOverlined(bool value) { SETBIT(m_flags, kOverlined, value); }
  /** \details
    Returns true if and only if the Striked flag is set for this TextProperties object.
  */
  bool isStriked() const { return GETBIT(m_flags, kStriked); }
  /** \details
    Controls the Striked flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setStriked(bool value) { SETBIT(m_flags, kStriked, value); }
  /** \details
  Returns true if and only if the LastChar flag is set for this TextProperties object.
  */
 
  /** \details
    Returns true if and only if the LastChar flag is set for this TextProperties object.
  */
  bool isLastChar() const { return GETBIT(m_flags, kLastChar); }
  /** \details
    Controls the LastChar flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setLastChar(bool value) { SETBIT(m_flags, kLastChar, value); }
  /** \details
    Returns true if and only if the InBigFont flag is set for this TextProperties object.
  */
  bool isInBigFont() const { return GETBIT(m_flags, kInBigFont); }
  /** \details
    Controls the InBigFont flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setInBigFont(bool value) { SETBIT(m_flags, kInBigFont, value); }
  /** \details
    Returns true if and only if the IncludePenups flag is set for this TextProperties object.
  */
  bool isIncludePenups() const { return GETBIT(m_flags, kInclPenups); }
  /** \details
    Controls the IncludePenups flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setIncludePenups(bool value) { SETBIT(m_flags, kInclPenups, value); }
  /** \details
    Returns true if and only if the ZeroNormals flag is set for this TextProperties object.
  */
  bool isZeroNormals() const { return GETBIT(m_flags, kZeroNormals); }
  /** \details
    Controls the kZeroNormals flag for this TextProperties object.
    \param value [in]  Controls the flag.
  */
  void setZeroNormals(bool value) { SETBIT(m_flags, kZeroNormals, value); }
  /** \details
    Returns smooth TTF text contour output flag.
  */
  bool ttfPolyDraw() const { return GETBIT(m_flags, kBezierCurves); }
  /** \details
    Sets smooth TTF text contour output flag.
 
    bFlag (in) New flag value.
  */
  void setTtfPolyDraw(bool bFlag) { SETBIT(m_flags, kBezierCurves, bFlag); }
  /** \details
    Returns the tracking percent for this TextProperties object.
  */
  double trackingPercent() const {return m_trackingPercent; }
  /** \details
    Sets the tracking percent for this TextProperties object.
    \param trackingPercent [in]  Tracking percent.
  */
  void setTrackingPercent(double trackingPercent) { m_trackingPercent = trackingPercent; }
 
  /** \details
    Returns the text quality percent for this vectorization process.
    \remarks
    Returns a value in the range [0,100]. 50 is the default.
  */
  OdUInt32 textQuality() const { return m_textQuality; }
 
  /** \details
    Returns the text quality percent for this vectorization process.
    \remarks
    Sets a value in the range [0,100]. 50 is the default.
  */
  void setTextQuality(OdUInt32 val) { m_textQuality = (OdUInt16)val; }
};
 
typedef OdUInt32 OdFontSubType;
 
class OdGePoint2d;
class OdGiConveyorGeometry;
class OdTtfDescriptor;
 
/** \details
    This class is the base interface class for classes that implements font objects.
    <group Other_Classes>
*/
class FIRSTDLL_EXPORT OdFont : public OdRxObject
{
  OdUInt32 m_Flags;
 
public:
  ODRX_DECLARE_MEMBERS(OdFont);
 
  OdFont() : m_Flags(0) {}
 
  enum
  {
    kBigFont10 = 0x0001,
    kUniFont10 = 0x0002,
    kFont10    = 0x0004,
    kFont11    = 0x0008,
    kFont10A   = 0x0010,
    kTrueType  = 0x0020,
    kFontGdt   = 0x0040,
    kFontSimplex6 = 0x0080,
    kShapes11   = 0x0100,
    kFontRsc    = 0x0200   // MicroStation Resource file.
  };
 
  /** \details
    Returns the font flags for this Font object.
    \remarks
    getFlags() returns a combination of zero or more of the following: 
    
    <table>
    Name              Value
    kBigFont10        0x0001
    kUniFont10        0x0002
    kFont10           0x0004
    kFont11           0x0008
    kFont10A          0x0010
    kTrueType         0x0020
    kFontGdt          0x0040
    kFontSimplex6     0x0080
    kShapes11         0x0100
    kFontRsc          0x0200
    </table>
  */
    OdUInt32 getFlags() const { return m_Flags; }
  /** \details
    Returns the font flags for this Font object.
    
    \remarks
    flags() returns a combination of zero or more of the following: 
    
    <table>
    Name              Value
    kBigFont10        0x0001
    kUniFont10        0x0002
    kFont10           0x0004
    kFont11           0x0008
    kFont10A          0x0010
    kTrueType         0x0020
    kFontGdt          0x0040
    kFontSimplex6     0x0080
    kShapes11         0x0100
    kFontRsc          0x0200
    </table>
  */
    OdUInt32 flags() { return m_Flags; }
 
  /** \details
    Sets the font flags for this Font object.
    \param fontFlags [in]  Font flags.
 
    \remarks
    fontFlags must be a combination of zero or more of the following:
    
    <table>
    Name              Value
    kBigFont10        0x0001
    kUniFont10        0x0002
    kFont10           0x0004
    kFont11           0x0008
    kFont10A          0x0010
    kTrueType         0x0020
    kFontGdt          0x0040
    kFontSimplex6     0x0080
    kShapes11         0x0100
    kFontRsc          0x0200
    </table>
  */
    void setFlags(OdUInt32 fontFlags) { m_Flags = fontFlags; }
 
  /** \details
    Adds the specified font flags to this Font object.
    \param fontFlags [in]  Font flags.
 
    \remarks
    fontFlags must be a combination of zero or more of the following:
     
    <table>
    Name              Value
    kBigFont10        0x0001
    kUniFont10        0x0002
    kFont10           0x0004
    kFont11           0x0008
    kFont10A          0x0010
    kTrueType         0x0020
    kFontGdt          0x0040
    kFontSimplex6     0x0080
    kShapes11         0x0100
    kFontRsc          0x0200
    </table>
  */
    void addFlag(OdUInt32 fontFlags) { m_Flags |= fontFlags; }
 
  /** \details
    Initializes this Font object to read font data from the specified StreamBuf object.
 
    \param pStreamBuf [in]  Pointer to the StreamBuf object from which the data are to be read.
    
    \remarks
    Returns eOk if successful, or an appropriate error code if not.    
  */
      virtual OdResult initialize(OdStreamBuf* pStreamBuf) = 0;
  /** \details
    Draws the specified character with this Font object.
    \param character [in]  Character to draw.
    \param advance [in]  Offset to next character.
    \param pWd [in/out] Draw object that can be used by this function to set the 
              necessary attributes and create the necessary geometry.
    \param textProperties [in] Text properties.
    \param pGeometry [in] Pointer to the modeler geometry.
 
  */
  virtual OdResult     drawCharacter(OdChar character, OdGePoint2d& advance, OdGiCommonDraw* pWd,
                                     OdTextProperties& textProperties) = 0;
  virtual OdResult     drawCharacter(OdChar character, OdGePoint2d& advance,
                                     OdGiConveyorGeometry* pGeometry,
                                     OdTextProperties& textProperties) = 0;
  /** \details
    Returns the height of this Font object above the baseline.
  */
  virtual double       getAbove() const = 0;
  /** \details
    Returns the depth of this font object below the baseline.
  */
  virtual double       getBelow() const = 0;
  /** \details
    Returns an array of the characters defined in this Font object.
    \param characters [out]  Receives the array of characters.
  */
  virtual OdUInt32     getAvailableChars(OdCharArray& characters) = 0;
  /** \details
    Returns true if and only if the specified character is defined in this Font object.
    \param character [in]  Character.
  */
  virtual bool        hasCharacter(OdChar character) = 0;
  
  /** \details
    Returns the height of this Font object.
  */
  virtual double      getHeight() const                                                   // MKU 20.02.2003
  {
    return getAbove() + getBelow();
  }
  /** \details
    Returns the internal leading of this Font object.
    \note
    The default implementation of this function always returns 0.
  */
  virtual double getInternalLeading() const
  {
    return 0;
  }
 
 
  //  removed here from GiContextForDbDatabase.cpp              // MKU 04.03.2003
 
  /** \details
    Returns the height of this Font object above the baseline.
    \note
    The default implementation of this function returns getAbove(), unless it is 0.0, in which case this function returns 1.0. 
  */
  double fontAbove() const  
  {
    double above = getAbove();
    if(OdZero(above))
    {
      above = 1.0;
    }
    return above;
  }
  /** \details
    Returns the underline position for this Font object at the specified text size.
    \param textSize [in]  Text size.
    \note
    The default implementation of this function returns -2.0 * textSize.
  */
  virtual double getUnderlinePos(double textSize) const
  {
    return -0.2 * textSize;
    
  }
  /** \details
    Returns the overline position for this Font object at the specified text size.
    \param textSize [in]  Text size.
    \note
    The default implementation of this function returns 1.2 * textSize.
  */
  virtual double getOverlinePos(double textSize) const
  {
    return 1.2 * textSize;
  }
  
  /** \details
    Returns true if and only if this Font object is an SHX font.
    \note
    The default implementation of this function always returns true.
  */
  virtual bool isShxFont()
  {
    return true;
  }
  /** \details
    Returns the average width of characters in this Font object.
    \note
    The default implementation of this function always returns 0.0.
  */
  virtual double getAverageWidth()
  {
    return 0.0;
  }
 
  /** \details
    Returns arrays of points over and under the baseline for the specified character in this OdFont object.
    \param character [in]  Character.
    \param advance [in]  Offset to next character.
    \param pointsOver [in]  Array of points over the baseline..
    \param pointsUnder [in]  Array of points under the baseline.
    \param textFlags [in] Text flags.
 
    \remarks
    textFlags must be a combination of one or more of the following:
 
    <table>
    Name                                Value
    OdTextProperties::kNormalText       0x01
    OdTextProperties::kVerticalText     0x02
    OdTextProperties::kUnderlined       0x04
    OdTextProperties::kOverlined        0x08
    OdTextProperties::kLastChar         0x10
    OdTextProperties::kInBigFont        0x20
    OdTextProperties::kInclPenups       0x40
    </table>
    
    \note
    The default implementation of this function does nothing but return.
    
  */
  virtual void getScore( OdUInt16 character, 
                         OdGePoint2d& advance, 
                         OdGePoint3d* pointsOver,
                         OdGePoint3d* pointsUnder,
                         const OdTextProperties& textFlags);
 
  /** \details
    Returns the font data for the specified character.
    \param dwTable [in]  Metric table to query.
    \param dwOffset [in]  Offset into table.
    \param pBuffer [in]  Pointer to to the buffer to receive the data.
    \param cbData [in]  ???.
    \remarks
    Returns the number of bytes returned in buffer.
    
    \note
    The default implementation of this function does nothing but return -1.
  */
  virtual OdUInt32 getFontData(
    OdUInt32 dwTable,     // metric table to query
    OdUInt32 dwOffset,    // offset into table being queried
    void * pBuffer,  // pointer to buffer for returned data
    OdUInt32 cbData       ) const;
 
  /** \details
    Returns true if and only if the font supports vertical mode.
    
    \note
    The default implementation of this function returns false.
  */
  virtual bool supportsVerticalMode()
  {
    return false;
  }
 
  /** \details
    Returns font file name.
 
    \note
    The default implementation of this function returns empty string.
  */
  virtual OdString getFileName() const
  {
    return OdString();
  }
  virtual void getDescriptor(OdTtfDescriptor& descr)
  {
  }
 
  /** \details
    Returns the LOGFONT for this font
 
    \param lpLogFont [in] Pointer to the buffer to receive the data.
    \remarks
    Returns the number of bytes returned in buffer. In case lpLogFont is NULL methods return
    number of bytes required in buffer. 
    
    \note
    The default implementation of this function does nothing but return -1.
  */
  virtual OdInt32 getLogFont(void* lpLogFont) const
  {
    return -1;
  }
};
 
inline void OdFont::getScore( OdUInt16 /*character*/, 
                         OdGePoint2d& /*advance*/, 
                         OdGePoint3d* /*pointsOver*/,
                         OdGePoint3d* /*pointsUnder*/,
                         const OdTextProperties& /*flags*/ )
  {}
 
inline OdUInt32 OdFont::getFontData(
    OdUInt32 /*dwTable*/,     // metric table to query
    OdUInt32 /*dwOffset*/,    // offset into table being queried
    void * /*lpvBuffer*/,  // pointer to buffer for returned data
    OdUInt32 /*cbData*/       ) const
  {
    return OdUInt32(-1);
  }
 
 
/** \details
    This template class is a specialization of the OdSmartPtr class for OdFont object pointers.
*/
typedef OdSmartPtr<OdFont> OdFontPtr;
 
/** \details
  This class is the base interface class for text iterators, to be used both by Teigha and DGNdirect clients.
  
  <group Other_Classes>
*/
class FIRSTDLL_EXPORT OdBaseTextIterator : public OdRxObject
{
public:
  virtual OdChar nextChar() = 0;
  /** \details
  Returns the properties of the character at the current position of this TextIterator object.
  */
  virtual const OdCharacterProperties& currProperties() const = 0;
 
  /** \details
  Returns the character at the current position of this TextIterator object.
  */
  virtual const OdChar* currPos() const = 0;
};
 
/** \details
This template class is a specialization of the OdSmartPtr class for OdBaseTextIterator object pointers.
*/
typedef OdSmartPtr<OdBaseTextIterator> OdBaseTextIteratorPtr;
 
#include "TD_PackPop.h"
 
#endif // !defined(AFX_ODFONT_H__0B76813A_DCFA_450E_8591_B6C6F1ED76EC__INCLUDED_)