在使用代码打开图纸时,如果图纸中,存在一些字体的字体文件缺失,会导致我们在读取对应的文字信息时,丢失一些关键信息,在获取文字实体边界GeometricExtents时甚至会报错。
这时,我为了能正常的提取到图纸上面的正确信息,选择在打开图纸后,替换那些缺失的字体文件为标准字体库中的字体,判断字体文件是否缺失的方法如下:
bool checkIsFontFileMissing(TextStyleTableRecord textStyle)
{
bool checkFontFileExist(string file)
{
bool findSystemFontFolder()
{
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
string filePath = System.IO.Path.Combine(folderPath, file);
return System.IO.File.Exists(filePath);
}
bool findAcadFolder()
{
string acadPath = Environment.GetCommandLineArgs()[0];
string acadFolder = System.IO.Path.GetDirectoryName(