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
/////////////////////////////////////////////////////////////////////////////// 
// 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.
///////////////////////////////////////////////////////////////////////////////
 
#ifndef __ODGITEXTSTYLE_H__
#define __ODGITEXTSTYLE_H__
 
#include "TD_PackPush.h"
 
#include "OdCodePage.h"
#include "OdFont.h"
#include "Gi/TtfDescriptor.h"
#include "DbBaseDatabase.h"
 
class OdGiWorldDraw;
class OdGiTextStyleImpl;
class OdString;
class OdGePoint2d;
 
 
/** \details
    This class provides an interface to the display attributes of text.
 
    \remarks
    This class is used as an argument to OdGiGeometry::text().
 
    \sa
    TD_Gi
 
    <group OdGi_Classes>
*/
class FIRSTDLL_EXPORT OdGiTextStyle
{
  // Members
  //
 
  // : public OdTtfDescriptor                         // MKU 14.02.2003
 
  OdTtfDescriptor       m_ttfDescriptor;
 
  mutable OdFontPtr     m_pFont;
  mutable OdFontPtr     m_pBigFont;
 
  mutable OdString      m_sFontPath;
  mutable OdString      m_sBigFontPath;
 
  OdString              m_sBigfontFile;
  double                m_dTextSize;
  double                m_dXScale;
  double                m_dObliquingAngle;
  double                m_dTrackingPercent;
  mutable OdUInt16      m_flags;
  mutable OdCodePageId  m_Codepage;
 
  OdString              m_StyleName;
 
  double                m_dIntercharSpacing;
 
public:
  enum
  {
    kShape       = 0x01,
    kUpsideDown  = 0x02,
    kVertical    = 0x04,
    kUnderlined  = 0x08,
    kOverlined   = 0x10,
    kShxFont     = 0x20,
    kPreLoaded   = 0x40,
    kBackward    = 0x80,
    kShapeLoaded = 0x100,
    kStriked     = 0x200,
    kUseIntercharSpacing   = 0x400,
    kFixedIntercharSpacing = 0x800
  };
 
  /** \details
    Controls if the text font file for this TextStyle marked as loaded.
 
    \param shapeLoaded [in]  Controls shape loaded.
  */
  /*!DOM*/
  void setShapeLoaded(
    bool shapeLoaded) const;
 
  /** \details
    Returns true if and only if the text font file for this TextStyle marked as loaded.
  */
  /*!DOM*/
  bool isShapeLoaded() const { return GETBIT(m_flags, kShapeLoaded); }
 
  OdGiTextStyle();
  ~OdGiTextStyle();
 
  /** \details
    Sets the parameters of this TextStyle object according to its parameters.
 
    \param fontName [in]  Font filename.
    \param bigFontName [in]  BigFont filename.
    \param textSize [in]  Fixed text size.
    \param xScale [in]  X-scale (width) factor of text.
    \param obliquingAngle [in]  Obliquing angle of text.
    \param trackingPercent [in]  Tracking percent of text.
    \param isBackward [in]  Controls backwards drawing of text.
    \param isUpsideDown [in]  Controls upside down drawing of text.
    \param isVertical [in]  Controls vertical drawing of text.
    \param isOverlined [in]  Controls overlined drawing of text.
    \param isUnderlined [in]  Controls overlined drawing of text.
 
    \remarks
    obliquingAngle has a domain of ±1.48335 radians (±85°). Negative angles will have Oda2PI added to them.
 
    \note
    All angles are expressed in radians.
  */
  void set(
    const OdString& fontName,
    const OdString&  bigFontName,
    const double textSize,
    const double xScale,
    const double obliquingAngle,
    const double trackingPercent,
    const bool isBackward,
    const bool isUpsideDown,
    const bool isVertical,
    const bool isOverlined,
    const bool isUnderlined);
 
  /** \details
    Loads the font file(s) associated with this TextStyle.
 
    \param pDb [in]  Pointer to the database whose OdDbHostAppServices object will be used.
 
    \remarks
    This function is run after a call to setFileName() or setBigFontFileName(), and
    must be called after loading a True Type font (TTF).
  */
  void loadStyleRec(
    OdDbBaseDatabase* pDb) const;
 
  /** \details
    Returns the fully qualified font file path associated with this TextStyle.
 
    \param pDb [in]  Pointer to the database whose OdDbHostAppServices object will be used.
 
  */
  OdString getFontFilePath(
    OdDbBaseDatabase* pDb) const;
 
  /** \details
    Returns the fully qualified BigFont file path associated with this TextStyle.
 
    \param pDb [in]  Pointer to the database whose OdDbHostAppServices object will be used.
 
  */
  OdString getBigFontFilePath(
    OdDbBaseDatabase* pDb) const;
 
  /** \details
    Sets the fully qualified font file path associated with this TextStyle.
 
    \param fontFilePath [in]  Font file path.
 
    \remarks
    loadStyleRec() should be called after calling this function:
  */
  void setFontFilePath(
    const OdString& fontFilePath){m_sFontPath = fontFilePath;}
 
  /** \details
    Sets the fully qualified BigFont file path associated with this TextStyle.
 
    \param bigFontFilePath [in]  BigFont file path.
 
    \remarks
    loadStyleRec() should be called after calling this function:
  */
  void setBigFontFilePath(
    const OdString& bigFontFilePath){m_sBigFontPath = bigFontFilePath;}
 
  /** \details
    Sets the fixed text size for this TextStyle.
 
    \param textSize [in]  Fixed text size.
  */
  void setTextSize(
    double textSize);
 
  /** \details
    Sets the X-scale (width) factor for this TextStyle.
 
    \param xScale [in]  X-scale factor.
  */
  void setXScale(
    double xScale);
 
  /** \details
    Sets the obliquing angle for this TextStyle.
 
    \param obliquingAngle [in]  Obliquing angle.
 
    \remarks
    obliquingAngle has a domain of ±1.48335 radians (±85°). Negative angles will have Oda2PI added to them.
 
    \note
    All angles are expressed in radians.
  */
  void setObliquingAngle(double obliquingAngle);
 
  /** \details
    Sets the tracking percent for this TextStyle.
 
    \param trackingPercent [in]  TrackingPercent [0.75, 4.0].
 
    \remarks
    Tracking percent is a multiplier for the spacing between characters as defined in the font file.
 
  */
  void setTrackingPercent(
    double trackingPercent);
 
  /** \details
    Controls the backwards drawing of text with this TextStyle.
 
    \param isBackwards [in]  Controls backwards drawing.
  */
  void setBackward(
    bool isBackward);
 
  /** \details
    Controls the upside down drawing of text with this TextStyle.
 
    \param isUpsideDown [in]  Controls upside down drawing.
  */
  void setUpsideDown(
    bool isUpsideDown);
 
  /** \details
    Controls the vertical drawing of text with this TextStyle.
 
    \param isVertical [in]  Controls vertical drawing.
  */
  void setVertical(
    bool isVertical);
 
  /** \details
    Controls the underlined drawing of text with this TextStyle.
 
    \param underlined [in]  Controls underlined drawing.
  */
  void setUnderlined(
    bool isUnderlined);
 
  /** \details
    Controls the overlined drawing of text with this TextStyle.
 
    \param overlined [in]  Controls overlined drawing.
  */
  void setOverlined(
    bool isOverlined);
 
  /** \details
    Controls the strike drawing of text with this TextStyle.
 
    \param overlined [in]  Controls strike drawing.
  */
  void setStriked(
    bool isStriked);
 
  /*!DOM*/
  void setPreLoaded(bool value) const;
 
  /*!DOM*/
  void setShxFont(bool value) const;
 
  /** \details
    Sets the name of the font file associated with this TextStyle.
 
    \param fontFileName [in]  Filename.
  */
  void setFileName(
    const OdString& fontFileName);
    
  /** \details
    Sets the name of the BitFont file associated with this TextStyle.
 
    \param bigFontFileName [in]  Filename.
  */
  void setBigFontFileName(
    const OdString& bigFontFileName);
 
  /** \details
    Returns true if and only if text is drawn backwards with this TextStyle.
  */
  bool isBackward() const   { return GETBIT(m_flags, kBackward);  }
 
  /** \details
    Returns true if and only if text is drawn upside down with this TextStyle.
  */
  bool isUpsideDown() const { return GETBIT(m_flags, kUpsideDown);}
 
  /** \details
    Returns true if and only if text is drawn vertical with this TextStyle.
  */
  bool isVertical() const   { return GETBIT(m_flags, kVertical);  }
 
  /** \details
    Returns true if and only if text is drawn underlined with this TextStyle.
  */
  bool isUnderlined() const { return GETBIT(m_flags, kUnderlined);}
 
  /** \details
    Returns true if and only if text is drawn overlined with this TextStyle.
  */
  bool isOverlined() const  { return GETBIT(m_flags, kOverlined); }
 
  /** \details
    Returns true if and only if text is drawn strike with this TextStyle.
  */
  bool isStriked() const  { return GETBIT(m_flags, kStriked); }
 
  /*!DOM*/
  bool isPreLoaded() const  { return GETBIT(m_flags, kPreLoaded); }
 
  /*!DOM*/
  bool isShxFont() const    { return GETBIT(m_flags, kShxFont);   }
 
  /*!DOM*/
  bool isTtfFont() const    { return !isShxFont();  }
 
  /** \details
    Controls if the font file for this TextStyle is treated as a shape file.
    \param isShape [in]  Controls setting.
  */
  /*!DOM*/
   void setIsShape(
    bool isShape) { SETBIT(m_flags, kShape, isShape); }
 
  /** \details
    Returns true if and only if the font file for this TextStyle is a shape file.
  */
  /*!DOM*/
  bool isShape() const { return GETBIT(m_flags, kShape); }
 
 
  /** \details
    Sets this TextStyle to use the specified OdFont or Windows font characteristics.
 
    \param pFont [in] Pointer to the font.
    \param typeface [in] Typeface name of the font.
    \param bold [in] Bold if and only if true.
    \param italic [in] Italic if and only if true.
    \param charset [in] Windows character set identifier.
    \param pitchAndFamily [in] Windows pitch and character family identifier.
 
    \remarks
    If typeface is null, the Windows font information is removed from this text style.
  */
  void setFont(
    const OdString& typeface, 
    bool bold, bool italic, 
    int charset, 
    int pitchAndFamily);
  void setFont(
    OdFont* font){m_pFont = font;}
 
  /** \details
    Sets this TextStyle to use the specified OdFont as the BigFont.
 
    \param pBigFont [in]  Pointer to the BigFont.
  */
  void setBigFont(
    OdFont* pBigFont){m_pBigFont = pBigFont;}
 
 
  /** \details
    Returns the Windows font characteristics for this TextStyle.
 
    \param typeface [out]  Typeface name of the font.
    \param bold [out]  True if and only if bold.
    \param italic [out]  True if and only if italic.
    \param charset [out]  Windows character set identifier.
    \param pitchAndFamily [out]  Windows pitch and character family identifier.
  */
  void font(
    OdString& typeface,
    bool& bold,
    bool& italic,
    int& charset,
    int& pitchAndFamily) const;
 
  /** \details
    Returns the OdFont associated with this TextStyle.
  */
  OdFont* getFont() const     { return m_pFont;     }
 
  /** \details
    Returns the OdFont associated with the BigFont for this TextStyle.
  */
  OdFont* getBigFont() const  { return m_pBigFont;  }
 
  /** \details
    Returns a reference to the TTF descriptor for this TextStyle.
  */
  OdTtfDescriptor& ttfdescriptor()
  {
    return m_ttfDescriptor;
  }
  const OdTtfDescriptor& ttfdescriptor() const
  {
    return m_ttfDescriptor;
  }
 
  /** \details
    Returns the BigFont filename for this TextStyle.
  */
  const OdString &bigFontFileName() const
  {
    return m_sBigfontFile;
  }
  /** \details
      Returns the fixed text size for this TextStyle.
  */
  double textSize() const
  {
    return m_dTextSize;
  }
 
  /** \details
    Returns the X-scale (width) factor for this TextStyle.
  */
  double xScale() const
  {
    return m_dXScale;
  }
 
  /** \details
    Returns the obliquing angle for this TextStyle.
 
    \remarks
    obliquingAngle has a domain of ±1.48335 radians (±85°). Negative angles will have Oda2PI added to them.
 
    \note
    All angles are expressed in radians.
  */
  double obliquingAngle() const
  {
    return m_dObliquingAngle;
  }
  /** \details
    Returns the tracking percent for this TextStyle.
 
    \remarks
    Tracking percent is a multiplier for the spacing between characters as defined in the font file.
 
    trackingPercent() has a range of  [0.75..4].
  */
  double trackingPercent() const
  {
    return m_dTrackingPercent;
  }
 
//  void odExtentsBox(const OdChar* pStr, int nStrLen, OdUInt32 flags, OdDbDatabase* pDb, OdGePoint3d& min, OdGePoint3d& max, OdGePoint3d* pEndPos = 0);     // MKU 02.06.2003
 
  /** \details
    Returns the CodePage associated with this TextStyle.
  */
  OdCodePageId getCodePage() const
  {
    return m_Codepage;
  }
 
  /** \details
    Sets the CodePage associated with this TextStyle.
    \param codePage [in]  CodePage.
  */
  void setCodePage(OdCodePageId codePage)
  {
    m_Codepage = codePage;
  }
 
  const OdString& styleName() const
  {
    return m_StyleName;
  }
 
  void setStyleName(const OdString& name)
  {
    m_StyleName = name;
  }
 
  /** \details
    Controls if interchar spacing used.
    \param isShape [in]  Controls setting.
  */
  /*!DOM*/
   void setIsUseIntercharSpacing(
    bool isUseIntercharSpacing) { SETBIT(m_flags, kUseIntercharSpacing, isUseIntercharSpacing); }
 
  /** \details
    Returns true if interchar spacing used.
  */
  /*!DOM*/
  bool isUseIntercharSpacing() const { return GETBIT(m_flags, kUseIntercharSpacing); }
 
    /** \details
    Controls if fixed interchar spacing used.
    \param isShape [in]  Controls setting.
    */
  /*!DOM*/
   void setIsFixedIntercharSpacing(
    bool isUseIntercharSpacing) { SETBIT(m_flags, kFixedIntercharSpacing, isUseIntercharSpacing); }
 
  /** \details
    Returns true if fixed interchar spacing used.
  */
  /*!DOM*/
  bool isFixedIntercharSpacing() const { return GETBIT(m_flags, kFixedIntercharSpacing); }
 
  /** \details
    Returns the interchar spacing for this TextStyle.
 
    \remarks
    Interchar spacing is a factor of text size, that determine distance from start of character to 
    start of next character for fixed interchar spacing mode or a additional distance from end of 
    character to start of next character for common interchar spacing mode.
  */
  double getIntercharSpacing() const;
 
  /** \details
    Allow to set interchar spacing for this TextStyle.
  */
 
  void setIntercharSpacing( double dSpacing );
};
 
#include "TD_PackPop.h"
 
#endif  // __ODGITEXTSTYLE_H__