I have used BaseFont.GetWidthPoint
to calculate the width of a string using a particular BaseFont
.
//FontInfo is my own invention
public float GetTextWidth(string text, FontInfo fontInfo)
{
return fontInfo.BaseFont.GetWidthPoint(text, fontInfo.Size);
}
But when I switch to a Bold font it calculates wrong.
I realize what my problem is. I work on BaseFonts it does not have a notion of boldd font. When I write using a bold font, I set following:
if (fontInfo.IsBold)
{
pdfContentByte.SetCharacterSpacing(1);
pdfContentByte.SetRGBColorFill(66, 00, 00);
pdfContentByte.SetLineWidth((float)0.5);
pdfContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
}
Bold is only an attribute on my own FontInfo.
Based on this starting point, is there a way of calculating how much space a text takes up when painted with a "bold" font? Now it gives the space it takes up using a none-bold font.
TIA
Best regards Soeren D.