CadFonts
from OpenCAD2D import CadFonts
class CadFonts(System.Object) ยท CadFonts in the .NET reference
The fonts a document's text is drawn in, found as AutoCAD finds them: a text style's SHX font (romans.shx, txt read as txt.shx) and big font in CadFonts.Folders in their order and then in the Fonts folder beside OpenCAD2D.Core.dll (CadSupportFolders), read once and kept; a TrueType typeface as the canvas has it, else a font file of that family in those folders, a file also in the Fonts folder of Windows; a font named in CadFonts.Substitutions looked for as the font it is given for, as AutoCAD's font mapping file does; and one not found replaced by CadFonts.Replacement, as AutoCAD's FONTALT replaces it (a TrueType font not found, by the canvas's drawing font, as AutoCAD maps it through Windows), said once a font through CadDocument.FontMissing. The one font carried is the presenter's own single-stroke font, CadFonts.BuiltIn; no folder of AutoCAD's is looked in unless the user lists it.
Constructors
__init__
def __init__(
self,
folders: System.Collections.Generic.IEnumerable[str],
replacement: str,
substitutions: System.Collections.Generic.IEnumerable[System.Collections.Generic.KeyValuePair[str, str]],
familyExists: System.Func[str, bool] | None = ...,
) -> None
Makes the fonts of a document.
Properties and fields
BuiltInName
BuiltInName: ClassVar[str]
The name the presenter's own font goes by, as a replacement or a style's font: opencad2d, with or without .shx. No file has it on disk; a file of that name in a folder looked in is passed over for it.
BuiltInTitle
BuiltInTitle: ClassVar[str]
The title of the presenter's own font, as the line saying a font not found names it: OpenCAD2D ISO.
BuiltIn
BuiltIn: ClassVar[ShxFont]
Gets the presenter's own single-stroke font, OpenCAD2D ISO (CadFonts.BuiltInName), drawn as an SHX font is: upright lettering in the proportions of ISO 3098 type B (TCVN 7284), ASCII 32 to 126 with the degree, plus-minus, square, diameter and dash signs and the Vietnamese letters, 242 letters. Its capitals reach ShxFont.Above 100 units above the baseline and its descenders 30 below: "ABC123" 10 high is 10 high and its advances add to 42.5 (A 8, B 7, C 6.5, each digit 7); the compiled file is 8 685 bytes. AutoCAD 2021's textbox of TEXT "ABC123" in it, from the point the text starts at, is (1.0000, -0.6299) to (42.2488, 10.7063) at 10 high and (10.0000, -6.2992) to (422.4882, 107.0630) at 100 high: the arcs of the C, 2 and 3 reach past the baseline and the capitals' top.
DefaultFolders
DefaultFolders: ClassVar[System.Collections.Generic.IReadOnlyList[str]]
Gets the folders a drawing's fonts start with: none. SHX fonts are read from the folders the user adds in Global settings' Folder preference, then from the Fonts folder beside OpenCAD2D.Core.dll and its subfolders; a TrueType file is looked for in the Fonts folder of Windows as well, last. The drawing's own folder is not looked in, and nor are AutoCAD's Fonts folders.
Folders
@property
def Folders(self) -> System.Collections.Generic.IReadOnlyList[str]
Gets the folders the user set, which fonts are looked for in, in order, before the Fonts folder beside the dll.
IsOff
@property
def IsOff(self) -> bool
Gets whether fonts are off: no folders and no replacement.
Replacement
@property
def Replacement(self) -> str
Gets the font a font not found is drawn in, and after a comma the big font a big font not found is drawn in; empty for the canvas's own.
Substitutions
@property
def Substitutions(self) -> System.Collections.Generic.IReadOnlyDictionary[str, str]
Gets the fonts drawn in others, each name to the name it is drawn in, in the order of their names.
Methods
IsBuiltIn
@staticmethod
def IsBuiltIn(name: str) -> bool
Gets whether a font's name is that of the presenter's own font, as a text style, FONTALT or a font typed names it: opencad2d or opencad2d.shx, letters of either case the same, the spaces around it left out; no file on disk is looked for.
IsSetAs
def IsSetAs(self, other: CadFonts) -> bool
Gets whether these fonts are set as another's: the same folders, replacement and substitutions.
Load
@staticmethod
def Load(path: str) -> ShxFont
Reads the SHX font of a file, once for every document while its file is unchanged; null, said once at Debug, where it cannot be read or is no SHX font.
Locate
def Locate(self, name: str, drawingFolder: str) -> str
Finds a font's file: the path as written where it is a full path that is there, else its file name in CadFonts.Folders and then the Fonts folder beside the dll, .shx added to a name of no extension (txt is txt.shx); a TrueType file (.ttf, .ttc, .otf) last in the Fonts folder of Windows, as the system's fonts.
ReadFontMap
@staticmethod
def ReadFontMap(
path: str,
) -> System.Collections.Generic.IReadOnlyList[System.Collections.Generic.KeyValuePair[str, str]]
Reads a font mapping file as AutoCAD's FONTMAP reads acad.fmp: a line oldfont;newfont for each font drawn in another (romans.shx;isocp.shx), blank lines and lines of no semicolon or a blank half passed over, in the order of the file. A file that is not there or cannot be read gives none, said once at Debug; nothing throws.
WithSubstitution
def WithSubstitution(self, name: str, drawnIn: str) -> CadFonts
Gets these fonts with one more font drawn in another, as a font missing is given its own replacement: the same folders and replacement, the name added to CadFonts.Substitutions or its font changed.