Method BorrowFonts
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
BorrowFonts(string)
Sets FontSearchPath to a path for as long as the returned scope lives, measuring in one set of fonts that every borrow of that path in this drawing shares, and puts back the path and the fonts the drawing had when the scope is disposed.
public IDisposable BorrowFonts(string path)
Parameters
pathstringThe folders of the fonts, as FontSearchPath; empty for none.
Returns
- IDisposable
The scope; dispose it to put back what the drawing measured in before.
Remarks
Setting FontSearchPath reads the fonts anew each time, so that a code page registered since is picked up; code that sets it and puts it back round each text it measures (a text's GeometricExtents in a loop of 2 000) looks for the font file and reads it again 2 000 times, some 0.12 ms each for an SHX font. A borrow reads each font of a path once for the life of the drawing, however many times and in however many scopes it is borrowed, and what it measures is what the same path set measures: "ABC" of txt.shx, 4 high and centred on (100, 50, 0), stands at (94.667, 50, 0) either way.
The set of a path is kept by the drawing, the path spelled as it is given, so that "D:\Fonts" and "d:\fonts" are two sets. A font file that changes on disk, or a code page registered after the set was first used, is not seen by a borrow of that path again: set FontSearchPath itself to read the fonts anew. A path set inside a scope is put back like any other when the scope is disposed. Scopes nest, and each puts back what was there when it began.
Exceptions
- ArgumentNullException
Thrown when the path is null.