pass the symbol font name to vlnTab

use the current symbol font (determined by Step RTB) to find the real width of a tab containing a symbol character
This commit is contained in:
John Jenko 2011-10-13 18:49:14 +00:00
parent eed402ef7f
commit 64429dcef0
2 changed files with 21 additions and 6 deletions

View File

@ -889,7 +889,7 @@ namespace Volian.Print.Library
}
if (!itemInfo.IsSection || doSectTab)
{
mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab);
mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName);
PartsLeft.Add(mytab);
if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro);
}

View File

@ -58,21 +58,36 @@ namespace Volian.Print.Library
set { _MyMacro = value; }
}
private float GetTextWidth(VE_Font vefont, string txt)
private string symblsStr = "\u25CF"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
{
System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size);
System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
float w = 0;
foreach (char c in Text)
{
int idx = symblsStr.IndexOf(c);
if (idx >= 0) // symbol character - use symbol font to find its width
w += iSymblFont.BaseFont.GetWidthPointKerned(symblsStr[idx].ToString(), (float)vefont.Size);
else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
}
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w;
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab)
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName)
{
MyContentByte = cb;
MyParent = myparent;
YOffset = yoffset;
Text = cleanTab;
MyFont = vFont;
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab));//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName);//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
if (origTab.Contains(@"{!"))
{
int mindx = origTab.IndexOf(@"{!");
@ -84,7 +99,7 @@ namespace Volian.Print.Library
origTab = origTab.Replace(macro,"");
origTab = origTab + " ";
cleanTab = origTab;
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab));//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
}
Rtf = GetRtf(origTab, vFont);
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0"); // bullet 25CF // jsj- add space after \f0