DgnFontManager.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
60 
61 #include "DgnPlatform.h"
62 #include <Bentley/CodePages.h>
63 #include <Bentley/RefCounted.h>
65 
66 DGNPLATFORM_TYPEDEFS (DgnFontNamedSymbol);
68 DGNPLATFORM_TYPEDEFS (DgnFontList);
69 DGNPLATFORM_TYPEDEFS (DgnFontConfig);
70 DGNPLATFORM_TYPEDEFS (DgnFontConfigSet);
71 
72 
74 
77 
80 
81 
82 //=======================================================================================
84 // @bsiclass Bentley Systems
85 //=======================================================================================
87 {
91 
98  SPECIALCHAR_FirstStandardRscFraction = 0x81, // While technically customizable per-font, I have never seen this in practice, and the font utility no longer allows it.
99  SPECIALCHAR_LastStandardRscFraction = 0xbf, // While technically customizable per-font, I have never seen this in practice, and the font utility no longer allows it.
100 
119 
120  // Private use is to allow us to round-trip characters with custom meaning. It is from 0xe0000 through 0xf8ff.
126 };
127 
128 //=======================================================================================
130 // @bsiclass Bentley Systems
131 //=======================================================================================
132 enum class DgnFontType
133 {
134  None = 0,
135  Rsc = 1,
136  TrueType = 2,
137  Shx = 3,
138 };
139 
140 //=======================================================================================
142 // @bsiclass Bentley Systems
143 //=======================================================================================
144 enum class DgnFontFilter
145 {
146  None = 0,
147  Resource = 1<<0,
148  Shx = 1<<1,
149  ShxBig = 1<<2,
150  TrueType = 1<<3,
151  Missing = 1<<4,
152  Symbol = 1<<5,
153  Hidden = 1<<6,
154  Normal = 0x000b, /* Resource | Shx | TrueType, */
155  AllShx = 0x0006, /* Shx | ShxBig, */
156  All = 0x007f, /* Normal | Missing | Hidden | ShxBig, */
157  ResourceShx = 0x0003, /* Resource | Shx */
158 };
159 
161 
162 //=======================================================================================
164 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
165 // @bsiclass Bentley Systems
166 //=======================================================================================
168 {
169 
170  //=======================================================================================
171  // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
172  // @bsiclass Bentley Systems
173  //=======================================================================================
175  {
176  SORT_ByType = 0,
177  SORT_ByName = 1
178  };
179 
181  public: DGNPLATFORM_EXPORT size_t GetCount ();
182 
184  public: DGNPLATFORM_EXPORT DgnFontP GetEntryP (size_t n);
185 
187  public: DGNPLATFORM_EXPORT void Sort (SortOrder);
188 };
189 
190 
191 //=======================================================================================
193 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
194 // @bsiclass Bentley Systems
195 //=======================================================================================
197 {
198 
199  virtual ~DgnFontVisitor () {}
200 
202  virtual bool VisitFont (DgnFontR) = 0;
203 };
204 
205 //=======================================================================================
207 // @bsiclass Bentley Systems
208 //=======================================================================================
210 {
211  HardCoded,
213 };
214 
215 //=======================================================================================
217 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
218 // @bsiclass Bentley Systems
219 //=======================================================================================
221 {
222 private:
223  virtual void MakeClassAbstract() = 0;
224 public:
225 public:
227  DGNPLATFORM_EXPORT DgnFontNamedSymbolSource GetSource () const;
228 
230  DGNPLATFORM_EXPORT WStringCR GetKey () const;
231 
233  DGNPLATFORM_EXPORT WStringCR GetDisplayName () const;
234 
236  DGNPLATFORM_EXPORT UInt32 GetCodePoint () const;
237 };
238 
239 
240 //=======================================================================================
242 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
243 // @bsiclass Bentley Systems
244 //=======================================================================================
246  {
247 private:
248  virtual void MakeClassAbstract() = 0;
249 public:
250 public:
254  DGNPLATFORM_EXPORT bool IsCharacterPresent (UInt16 glyphCode) const;
255 
258  DGNPLATFORM_EXPORT bool IsPresent () const;
259 
262  DGNPLATFORM_EXPORT bool IsMissingFontReported () const;
263 
265  DGNPLATFORM_EXPORT void SetMissingFontIsReported ();
266 
268  DGNPLATFORM_EXPORT bool IsHidden () const;
269 
271  DGNPLATFORM_EXPORT bool IsShxBigFont () const;
272 
274  DGNPLATFORM_EXPORT bool IsSymbolFont () const;
275 
277  DGNPLATFORM_EXPORT bool IsUnicode () const;
278 
281  DGNPLATFORM_EXPORT bool IsValid () const;
282 
286  DGNPLATFORM_EXPORT bool IsOutlineFont () const;
287 
289  DGNPLATFORM_EXPORT WStringCR GetName () const;
290 
292  DGNPLATFORM_EXPORT DgnFontType GetType () const;
293 
295  DGNPLATFORM_EXPORT UInt16 GetDegreeCharCode () const;
296 
298  DGNPLATFORM_EXPORT UInt16 GetDiameterCharCode () const;
299 
301  DGNPLATFORM_EXPORT UInt16 GetPlusMinusCharCode () const;
302 
305  DGNPLATFORM_EXPORT UInt32 GetMaxFractionDenominator () const;
306 
312  DGNPLATFORM_EXPORT UInt16 GetCharCodeFromFraction (UInt32 numerator, UInt32 denominator, bool reduce=true) const;
313 
319  DGNPLATFORM_EXPORT BentleyStatus GetFractionFromCharCode (UInt32& numerator, UInt32& denominator, UInt16 glyphCode) const;
320 
322  DGNPLATFORM_EXPORT LangCodePage GetCodePage () const;
323 
325  DGNPLATFORM_EXPORT UInt16 GetFirstCharCode () const;
326 
328  DGNPLATFORM_EXPORT UInt16 GetLastCharCode () const;
329 
332  DGNPLATFORM_EXPORT DgnGlyphP GetGlyphP (UInt16) const;
333 
336  DGNPLATFORM_EXPORT void GetNamedSymbols (bvector<DgnFontNamedSymbolPtr>&) const;
337 
339  DGNPLATFORM_EXPORT void CompressRscFractions (WStringR outStr, WCharCP inStr) const;
340 
342  DGNPLATFORM_EXPORT void ExpandRscFractions (WStringR outStr, WCharCP inStr) const;
343 
345  DGNPLATFORM_EXPORT void CompressEscapeSequences (WStringR outStr, WCharCP inStr) const;
346 
348  DGNPLATFORM_EXPORT void ExpandEscapeSequences (WStringR outStr, WCharCP inStr) const;
349 
350  }; // DgnFont
351 
353 typedef bvector<DgnFontCP> T_DgnFontCPVector;
354 
358 
359 //=======================================================================================
361 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
362 // @bsiclass Bentley Systems
363 //=======================================================================================
365 {
366 private:
367  virtual void MakeClassAbstract() = 0;
368 public:
369 public:
370 
374  DGNPLATFORM_EXPORT DgnFontP GetFontP (UInt32 fontNum);
375 
379  DGNPLATFORM_EXPORT DgnFontR ResolveFont (UInt32 fontNum);
380 
386  DGNPLATFORM_EXPORT StatusInt GetFontNumber (UInt32& fontNum, DgnFontCR font, bool addIfNotFound);
387 
392  DGNPLATFORM_EXPORT bool VisitFonts (DgnFontVisitor& visitor, DgnFontFilter filter);
393 
399  DGNPLATFORM_EXPORT DgnFontP FindFontByName (UInt32* foundNum, WCharCP fontName, DgnFontFilter filter=DgnFontFilter::Normal);
400 
404  DGNPLATFORM_EXPORT DgnFontListPtr CreateUsedFontList (DgnFontFilter filter=DgnFontFilter::Normal);
405 };
406 
407 
408 //=======================================================================================
410 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
411 // @bsiclass Bentley Systems
412 //=======================================================================================
414 {
415 private:
416  virtual void MakeClassAbstract() = 0;
417 public:
418 public:
422  DGNPLATFORM_EXPORT static DgnFontNumMapP GetDgnFontMapP (DgnFileP dgnFile);
423 
425  static DgnFontNumMapP GetDgnFontMapP (DgnModelRefP modelRef) {return GetDgnFontMapP(modelRef->GetDgnFileP());}
426 
428  DGNPLATFORM_EXPORT static DgnFontR GetDefaultRscFont ();
429 
431  DGNPLATFORM_EXPORT static DgnFontR GetDefaultShxFont ();
432 
436  DGNPLATFORM_EXPORT static DgnFontP GetDefaultShxBigFont ();
437 
439  DGNPLATFORM_EXPORT static DgnFontR GetDefaultTrueTypeFont ();
440 
443  DGNPLATFORM_EXPORT static DgnFontR GetDecoratorFont ();
444 
450  DGNPLATFORM_EXPORT static DgnFontP GetFontByNumber (UInt32 fontNum, DgnFileP dgnFile);
451 
453  static DgnFontP GetFontByNumber (UInt32 fontNum, DgnModelRefP modelRef) {return GetFontByNumber (fontNum, modelRef->GetDgnFileP());}
454 
460  DGNPLATFORM_EXPORT static DgnFontR ResolveFontNum (UInt32 fontNum, DgnFileP dgnFile);
461 
463  static DgnFontR ResolveFontNum (UInt32 fontNum, DgnModelRefP modelRef) {return ResolveFontNum (fontNum, modelRef->GetDgnFileP());}
464 
469  DGNPLATFORM_EXPORT static DgnFontP FindSystemFont (WCharCP fontName, DgnFontFilter filter=DgnFontFilter::Normal);
470 
475  DGNPLATFORM_EXPORT static bool VisitAllSystemFonts (DgnFontVisitor& visitor, DgnFontFilter filter=DgnFontFilter::Normal);
476 
481  DGNPLATFORM_EXPORT static DgnFontListPtr CreateKnownFontList (DgnFileP dgnFile=NULL, DgnFontFilter filter=DgnFontFilter::Normal);
482 
485  DGNPLATFORM_EXPORT static DgnFontCR GetFontForCodePage (UInt32 fontNum, UInt32 bigFontNum, DgnFileR);
486 };
487 
488 
489 //=======================================================================================
491 // @remark Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib
492 // @bsiclass Bentley Systems
493 //=======================================================================================
494 struct DgnGlyph
495 {
496 private:
497  virtual void MakeClassAbstract() = 0;
498 public:
499 
500 public:
503 };
504 
505 
507 
509 
Data structure to represent a named symbol for a font, as specified in the font configuration file...
Definition: DgnFontManager.h:220
A DgnFontNumMap is a per-DgnFile object that maps "FontID" (int) values to Font objects. FontNumMaps are loaded from the FontTable element stored in the dictionary model of a DgnFile.
Definition: DgnFontManager.h:364
#define ENUM_IS_FLAGS(ENUMTYPE)
Definition: Bentley.r.h:164
find normal "known" fonts (does not return SHX bigfonts)
virtual ~DgnFontVisitor()
Definition: DgnFontManager.h:199
struct DgnPlatform::DgnFont const & DgnFontCR
Definition: DgnFontManager.h:67
RefCountedPtr< DgnFontList > DgnFontListPtr
Definition: DgnFontManager.h:78
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
The default file attribute.
DgnFontType
The types of fonts supported by MicroStation.
Definition: DgnFontManager.h:132
Definition: TextTableHandler.h:216
bvector< DgnFontCP > T_DgnFontCPVector
A bvector of DgnFontCP objects, with allocations handled by Bentley.dll (so it can be passed across D...
Definition: DgnFontManager.h:353
struct Bentley::WString const & WStringCR
Definition: Bentley.h:239
Definition: DgnFontManager.h:88
uint16_t UInt16
Definition: Bentley.r.h:118
SortOrder
Definition: DgnFontManager.h:174
DgnFileP GetDgnFileP() const
Get the file that this references.
T_DgnFontCPVector const & T_DgnFontCPVectorCR
Definition: DgnFontManager.h:357
DgnFontFilter
Flags to filter font searches.
Definition: DgnFontManager.h:144
static DgnFontR ResolveFontNum(UInt32 fontNum, DgnModelRefP modelRef)
Equivalent to the DgnFileP overload, but gets the DgnFile from the DgnModelRef as a convenience...
Definition: DgnFontManager.h:463
T_DgnFontCPVector const * T_DgnFontCPVectorCP
Definition: DgnFontManager.h:356
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
A DgnFile is an in-memory representation of a physical file, regardless of its format.
Definition: DgnFile.h:308
wchar_t const * WCharCP
Definition: Bentley.h:224
SpecialCharValues
Code points for various special characters.
Definition: DgnFontManager.h:86
find all existing fonts, including missing and hidden fonts
uint32_t UInt32
Definition: Bentley.r.h:128
#define NULL
Definition: Bentley.h:157
Definition: DgnFontManager.h:90
This is really "empty set" in unicode, should be 0x2300 but stuck with this for compatibility.
Definition: DgnFontManager.h:94
#define CLRPUBLIC
Definition: DgnPlatform/ExportMacros.h:12
T_DgnFontCPVector & T_DgnFontCPVectorR
Definition: DgnFontManager.h:355
BentleyStatus
Definition: Bentley.h:208
A DgnModelRef provides access to a model in a Bentley::DgnPlatform::DgnFile.
Definition: DgnModelRef.h:172
static DgnFontP GetFontByNumber(UInt32 fontNum, DgnModelRefP modelRef)
Equivalent to the DgnFileP overload, but gets the DgnFile from the DgnModelRef as a convenience...
Definition: DgnFontManager.h:453
#define DGNPLATFORM_TYPEDEFS(_name_)
Definition: DgnPlatform.h:73
A shared pointer template for reference-counted objects.
Definition: RefCounted.h:119
LangCodePage
Definition: CodePages.h:20
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
int StatusInt
Definition: Bentley.h:222
Concrete class that can be used to implement the reference-counting pattern.
Definition: RefCounted.h:109
All fonts in MicroStation, regardless of type, are referenced through an instance of this class...
Definition: DgnFontManager.h:245
Implement this interface to traverse a set of fonts.
Definition: DgnFontManager.h:196
Class for collecting and manipulating curve data.
Definition: GPArray.h:91
DgnFontNamedSymbolSource
Describes the type/source of a FontNamedSymbol.
Definition: DgnFontManager.h:209
The DgnFontManager provides access to all font related services.
Definition: DgnFontManager.h:413
A list of fonts. Generally this list is created for you by a search method. DgnFontLists are referenc...
Definition: DgnFontManager.h:167
Represents a glyph in a Font (agnostic of DgnFontType). The primary use is to be able to get a GPA of...
Definition: DgnFontManager.h:494
T_DgnFontCPVector * T_DgnFontCPVectorP
Definition: DgnFontManager.h:355
static DgnFontNumMapP GetDgnFontMapP(DgnModelRefP modelRef)
Equivalent to the DgnFileP overload, but gets the DgnFile from the DgnModelRef as a convenience...
Definition: DgnFontManager.h:425
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:51
Provides a list of language code page value settings (Bentley/CodePages.h).
RefCountedPtr< DgnFontNamedSymbol > DgnFontNamedSymbolPtr
Definition: DgnFontManager.h:79

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.