Non-system fonte til PrintDocument
GodaftenJeg står og skal bruge en udskriftsfunktion til et program, og har implementeret denne - men med ét problem.
I fald at jeg ønsker at udskrive tekst med en skrifttype som ikke er installeret i systemet, så udskiftes denne blot med "MS Sans Serif"
Kan dette være en begrænsning i PrintDocument klassen, eller er det blot en fejl fra min side?
Del af udskriftsmetoden:
-----------------------------------------------------
// Printing the font name
e.Graphics.DrawString(
"sdf",
verdana,
Brushes.Black,
new Rectangle((int) leftMargin, (int) yPosition, e.MarginBounds.Width, (int) Math.Ceiling(printFont.GetHeight(e.Graphics))),
new StringFormat());
// New line
yPosition += verdana.GetHeight(e.Graphics);
// Set maximum layout size.
SizeF layoutSize = new SizeF(e.MarginBounds.Width, e.MarginBounds.Height);
// Measure string.
SizeF stringSize = new SizeF();
stringSize = e.Graphics.MeasureString(
_DrawString,
printFont,
layoutSize,
new StringFormat());
// Draw string withing measured box
e.Graphics.DrawString(
_DrawString,
printFont,
Brushes.Black,
new Rectangle((int) leftMargin, (int) yPosition, (int) Math.Ceiling(stringSize.Width), (int) Math.Ceiling(stringSize.Height)),
new StringFormat());
// New line
yPosition += stringSize.Height;
-----------------------------------------------------
Selve Font objekterne bliver lavet via en PrivateFontCollection og AddFontFile - og kan vises korrekt i andre dele af programmet.
Nogle forslag?
Med venlig hilsen
Thomas René Sidor