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:
parent
eed402ef7f
commit
64429dcef0
@ -889,7 +889,7 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
if (!itemInfo.IsSection || doSectTab)
|
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);
|
PartsLeft.Add(mytab);
|
||||||
if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro);
|
if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro);
|
||||||
}
|
}
|
||||||
|
@ -58,21 +58,36 @@ namespace Volian.Print.Library
|
|||||||
set { _MyMacro = value; }
|
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 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);
|
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;
|
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;
|
MyContentByte = cb;
|
||||||
MyParent = myparent;
|
MyParent = myparent;
|
||||||
YOffset = yoffset;
|
YOffset = yoffset;
|
||||||
Text = cleanTab;
|
Text = cleanTab;
|
||||||
MyFont = vFont;
|
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(@"{!"))
|
if (origTab.Contains(@"{!"))
|
||||||
{
|
{
|
||||||
int mindx = origTab.IndexOf(@"{!");
|
int mindx = origTab.IndexOf(@"{!");
|
||||||
@ -84,7 +99,7 @@ namespace Volian.Print.Library
|
|||||||
origTab = origTab.Replace(macro,"");
|
origTab = origTab.Replace(macro,"");
|
||||||
origTab = origTab + " ";
|
origTab = origTab + " ";
|
||||||
cleanTab = 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 = GetRtf(origTab, vFont);
|
||||||
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0"); // bullet 25CF // jsj- add space after \f0
|
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0"); // bullet 25CF // jsj- add space after \f0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user