Font path

1/5/2015 10:43 AM

After loading DWG I see that I have aroung 20 files in FileDependencies attribute ( all are shx or ttf files).
I need to grammatically resolve its locations so I do something like this:
foreach (FileDependency f in model.FileDependencies.Values)
f.FoundPath = resolveFontPath(f.FullFilename);
But after exporting the file to pdf or image fonts are wrong. Note: all fonts are in Hebrew.

when I'm putting all the fonts on the same directory of my exe everything works fine.

So I guess my question is how to set the font file location on runtime?


1/5/2015 12:23 PM

Hi Dror,

TT fonts can only be accessed if they are installed in your Windows system during conversion.

SHX fonts are always looked for in the directory of the DWG/DXF file and in the path of the executable, or somewhere in a global SHX font lookup path collection. You can modify and access this collection via static methods and properties

C# Code:
// add directories where SHX fonts are localized
// clear these directories
// access the current value

Changed paths will be used in the next load, already loaded models are not influenced.

You can define which font to use if a font defined in a file is not found via two static properties

C# Code:
// Fallback for SHX fonts
// Fallback for TT fonts

Changed fallbacks will be used in the next load, already loaded models are not influenced.
If a fallback is not found the last resort is always Arial TTF, which should be available on a sane Windows machine, or anything the Windows font access routines give back as a default if it is missing.

When converting to PDF you can embed TT fonts (if their licenses allow to do so) by setting both the GraphicsConfig.TryDrawingTextAsText property (of the GraphicsContext used in the PdfExporter) and the PdfExporter.EmbedFonts property to true. SHX fonts are never embedded as PDF cannot handle this kind of font, so SHX based texts for which the SHX font could be found during conversion are always included as graphics. You can include all texts as graphics by setting GraphicsConfig.TryDrawingTextAsText to false, which guarantees that the PDF content is as close as possible to what you see using screen display via CadLib. If EmbedFonts is false or a font does not allow to be embedded only a reference to the font is stored in the PDF, so display depends on whether the font is installed on the viewing system or not.

- Rammi