Empty Genmac fix, split cover page title fix

logic for Delta on HLS tab, better check for proportional font
different way to register fonts , check for null base font
fixed problem of too many carriage returns in some plot definitions.
This commit is contained in:
John Jenko 2011-11-21 20:55:31 +00:00
parent babe5482b2
commit 1ebcd90f48
4 changed files with 64 additions and 17 deletions

View File

@ -401,6 +401,10 @@ namespace Volian.Print.Library
VEPROMS.CSLA.Library.FormatInfo activeFormat = mySection.ActiveFormat;
VEPROMS.CSLA.Library.DocStyle docStyle = mySection.MyDocStyle;
Volian.Svg.Library.Svg mySvg = null;
//string jsj = BuildMyText(activeFormat);
//if (jsj == "")
// Console.WriteLine("here");
//mySvg = SvgSerializer<Volian.Svg.Library.Svg>.StringDeserialize(jsj);
mySvg = SvgSerializer<Volian.Svg.Library.Svg>.StringDeserialize(BuildMyText(activeFormat));
mySvg.ViewBox.Height = 1100;
mySvg.ViewBox.Width = 850;
@ -506,7 +510,8 @@ namespace Volian.Print.Library
sGenMac = tmpf.GenMac;
tmpf = FormatInfo.Get(tmpf.ParentID);
}
if (sGenMac == null || sGenMac == "") return "";
if (sGenMac == null || sGenMac == "")
sGenMac = "<svg/>";// return "";
}
if (!sGenMac.Contains("xmlns"))
sGenMac = sGenMac.Replace("<svg ", "<svg xmlns='http://www.w3.org/2000/svg' ");
@ -622,7 +627,7 @@ namespace Volian.Print.Library
case "{PROCTITLE2}":
case "{COVERPROCTITLE}":
float linelen = (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength * (float)pageItem.Font.CPI / 12;
SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)linelen, token); //,rowAdj);
SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text.ToUpper(), (int)linelen, token); //,rowAdj);
//SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token);
break;
case "{COVERTITLE1}":

View File

@ -66,18 +66,26 @@ namespace Volian.Print.Library
set { _MyMacro = value; }
}
private string symblsStr = "\u25CF"; // string of possible symbol character in a tab
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
// \x0394 - delta
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f)
{
if (f.Style == E_Style.Italics)
return System.Drawing.FontStyle.Italic;
return FontStyle.Regular;
}
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, GetSysFontStyle(vefont));
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 iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
float w = 0;
foreach (char c in Text)
foreach (char c in txt)
{
int idx = symblsStr.IndexOf(c);
if (idx >= 0) // symbol character - use symbol font to find its width
@ -95,7 +103,14 @@ namespace Volian.Print.Library
YOffset = yoffset;
Text = cleanTab;
MyFont = vFont;
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName);//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
float CCCs = GetTextWidth(MyFont, "CCCCCCCCCC", symblFontName);
float IIIs = GetTextWidth(MyFont, "iiiiiiiiii", symblFontName);
if (CCCs != IIIs)
Width = Text.Length * 6; //proportial font (7 chars * 6)
else
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName);//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
//if (MyParent.MyItemInfo.ItemID == 108)//120)
// Console.WriteLine("here");
if (origTab.Contains(@"{!"))
{
int mindx = origTab.IndexOf(@"{!");
@ -107,10 +122,24 @@ namespace Volian.Print.Library
origTab = origTab.Replace(macro,"");
origTab = origTab + " ";
cleanTab = origTab;
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
if (CCCs != IIIs)
Width = cleanTab.Length * 6; //proportial font (7 chars * 6)
else
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
if (Rtf.Contains("Caution") && vFont.Family == "VolianScript")
{
// NSP script caution
iTextSharp.text.Font myfont = pdf.GetFont(vFont.Family, 24, 0, iTextSharp.text.Color.BLACK);
if (myfont.BaseFont.CharExists(0x43)) // Capital 'C' exists as text
Rtf = Rtf; // no change necessary
else // Capital 'C' exists as Symbol
//Rtf = Rtf.Replace("Caution", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?");
Rtf = Rtf.Replace("Caution", @"\u61507?a\u61557?t\u61545?o\u61550?");
}
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0 "); // bullet 25CF // jsj- add space after \f0
Rtf = Rtf.Replace("\u0394", @"\f1\u916?\f0 "); // delta 0x0394
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
{
Rtf = Rtf.Replace("Caution:", " ");

View File

@ -30,14 +30,15 @@ namespace Volian.Svg.Library
{
if (!iTextSharp.text.FontFactory.IsRegistered(fontName))
{
foreach (string name in FontKey.GetValueNames())
{
if (name.StartsWith(fontName))
{
string fontFile = (string)FontKey.GetValue(name);
iTextSharp.text.FontFactory.Register(fontFile.Contains("\\") ? fontFile : FontFolder + "\\" + fontFile);
}
}
//foreach (string name in FontKey.GetValueNames())
//{
// if (name.StartsWith(fontName))
// {
// string fontFile = (string)FontKey.GetValue(name);
// iTextSharp.text.FontFactory.Register(fontFile.Contains("\\") ? fontFile : FontFolder + "\\" + fontFile);
// }
//}
iTextSharp.text.FontFactory.RegisterDirectories();
}
}
private static RegistryKey _FontKey = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows NT").OpenSubKey("CurrentVersion").OpenSubKey("Fonts");
@ -598,6 +599,10 @@ namespace Volian.Svg.Library
float fontSize = scale.M(new SvgMeasurement(Font.SizeInPoints, E_MeasurementUnits.PT));
int fontStyle = (Font.Bold ? iTextSharp.text.Font.BOLD : 0) + (Font.Italic ? iTextSharp.text.Font.ITALIC : 0);
VolianPdf.RegisterFont(Font.Name);
//if (iTextSharp.text.FontFactory.IsRegistered(Font.Name) == false)
//{
// //iTextSharp.text.FontFactory.RegisterDirectories();
//}
iTextSharp.text.Font font = FontFactory.GetFont(Font.Name, BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor));
Phrase ph = BuildPhrase(text, fontSize, fontStyle, font);
@ -638,6 +643,12 @@ namespace Volian.Svg.Library
private Phrase BuildPhrase(string text, float fontSize, int fontStyle, iTextSharp.text.Font font)
{
//if (text == "Caution")
//{
// if (iTextSharp.text.FontFactory.IsRegistered("VolianScript"))
// Console.WriteLine("Is Registered");
// Console.WriteLine("stop");
//}
bool fontUnderline = false;
float fontTextRise = 0;
@ -704,7 +715,7 @@ namespace Volian.Svg.Library
{
iTextSharp.text.pdf.FontSelector fs = new FontSelector();
fs.AddFont(font);
if (font.BaseFont.GetWidthPoint("m", 12) == font.BaseFont.GetWidthPoint(".", 12))
if (font.BaseFont != null && font.BaseFont.GetWidthPoint("m", 12) == font.BaseFont.GetWidthPoint(".", 12))
{
VolianPdf.RegisterFont("VESymbFix");
fs.AddFont(FontFactory.GetFont("VESymbFix", BaseFont.IDENTITY_H, true, fontSize, fontStyle, new Color(FillColor)));

View File

@ -456,6 +456,8 @@ namespace XYPlots
// some data only had carriage return, replace these with cr/nl so that following code
// will work
Buff = Buff.Replace(">\r<", ">\r\n<");
// some data had cr/cr/nl, change to cr/nl
Buff = Buff.Replace("\r\r\n", "\r\n");
while ((ptr = Buff.IndexOf(">\r\n<", ptr)) > 0)
{