fixes to font inheritance
This commit is contained in:
		@@ -311,11 +311,17 @@ public class VE_Font
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	public VE_Font(XmlNode fxml)
 | 
						public VE_Font(XmlNode fxml)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		XmlNode tmp = fxml.SelectSingleNode("Family");
 | 
							// The "Family", "Size", and "Style" are attributes to the "Font" node
 | 
				
			||||||
 | 
							// We were trying to get this information by fxml.SelectSingleNode("Family")
 | 
				
			||||||
 | 
							// but this would always return a NULL because this items are Attributes not Nodes.
 | 
				
			||||||
 | 
							// thus the FontFamily, FontSize, and FontStyle was never set
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							XmlAttributeCollection ac = fxml.Attributes; // get the attributes from the passed in Font node
 | 
				
			||||||
 | 
							XmlNode tmp = ac.GetNamedItem("Family"); // get the Family attribute from the Font node
 | 
				
			||||||
		if (tmp!=null)FontFamily = tmp.InnerText;
 | 
							if (tmp!=null)FontFamily = tmp.InnerText;
 | 
				
			||||||
		tmp = fxml.SelectSingleNode("Size");
 | 
							tmp = ac.GetNamedItem("Size"); // get the Size attribute from the Font node
 | 
				
			||||||
		if (tmp != null) FontSize = tmp.InnerText;
 | 
							if (tmp != null) FontSize = tmp.InnerText;
 | 
				
			||||||
		tmp = fxml.SelectSingleNode("Style");
 | 
							tmp = ac.GetNamedItem("Style"); // get the Style attribute from the Font node
 | 
				
			||||||
		if (tmp != null) FontStyle = tmp.InnerText;
 | 
							if (tmp != null) FontStyle = tmp.InnerText;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    private string _FontFamily = null;
 | 
					    private string _FontFamily = null;
 | 
				
			||||||
@@ -1346,20 +1352,44 @@ namespace fmtxml
 | 
				
			|||||||
		private bool GetPlantBaseDefaultFonts()
 | 
							private bool GetPlantBaseDefaultFonts()
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			// read the xml files for the base & plant to get the default fonts and
 | 
								// read the xml files for the base & plant to get the default fonts and
 | 
				
			||||||
			// make a VE_font for each.
 | 
								// make a VE_font for each.  If we are processing a sub-format (A.K.A. User Format),
 | 
				
			||||||
 | 
								// then the "base" format is the parent plant format (ex. the "base" format for
 | 
				
			||||||
 | 
								// NSP_00ALL.xml is NSP_ALL.xml)
 | 
				
			||||||
			try
 | 
								try
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
 | 
									bool getFontFromBase = true;
 | 
				
			||||||
				XmlDocument xdoc = new XmlDocument();
 | 
									XmlDocument xdoc = new XmlDocument();
 | 
				
			||||||
				xdoc.Load("fmt_xml\\basef.xml");
 | 
									XmlNode xfont;
 | 
				
			||||||
				XmlNode xfont = xdoc.SelectSingleNode("FormatData/Font");
 | 
					 | 
				
			||||||
				DefBaseFont = new VE_Font(xfont);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				string lfmtName = fmtName;
 | 
									string lfmtName = fmtName;
 | 
				
			||||||
				// for subformats, make the name FMT_00 where FMT is format name & 00 is number
 | 
									string parentOfSub = "";
 | 
				
			||||||
 | 
									// For sub-formats, make the name FMT_00 where FMT is format name & 00 is number
 | 
				
			||||||
				// from original name.  This will allow the data load to know it's a sub.
 | 
									// from original name.  This will allow the data load to know it's a sub.
 | 
				
			||||||
				int indx = fmtName.IndexOf('.');
 | 
									int indx = fmtName.IndexOf('.');
 | 
				
			||||||
				if (indx > 0)
 | 
									if (indx > 0) // we are working with a sub-format
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										parentOfSub = fmtName.Substring(0, fmtName.Length - 4); // name of sub format's parent
 | 
				
			||||||
					lfmtName = fmtName.Substring(0, fmtName.Length - 4) + "_" + fmtName.Substring(fmtName.Length - 2, 2);
 | 
										lfmtName = fmtName.Substring(0, fmtName.Length - 4) + "_" + fmtName.Substring(fmtName.Length - 2, 2);
 | 
				
			||||||
 | 
										getFontFromBase = false; // get the font from sub-format parent format
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									string parentName = "fmt_xml\\" + parentOfSub + "f.xml";
 | 
				
			||||||
 | 
									// if we have a valid parent format then use it to find the default font
 | 
				
			||||||
 | 
									if (!getFontFromBase && File.Exists(parentName))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										xdoc.Load(parentName);
 | 
				
			||||||
 | 
										xfont = xdoc.SelectSingleNode("FormatData/Font");
 | 
				
			||||||
 | 
										if (xfont != null)
 | 
				
			||||||
 | 
											DefBaseFont = new VE_Font(xfont);
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
											getFontFromBase = true; // font not found, use the font from base.xml
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if (getFontFromBase)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										xdoc.Load("fmt_xml\\basef.xml");
 | 
				
			||||||
 | 
										xfont = xdoc.SelectSingleNode("FormatData/Font");
 | 
				
			||||||
 | 
										DefBaseFont = new VE_Font(xfont);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									// Get the font from the current plant format (or sub-format)
 | 
				
			||||||
				string fName = "fmt_xml\\" + lfmtName + "f.xml";
 | 
									string fName = "fmt_xml\\" + lfmtName + "f.xml";
 | 
				
			||||||
				if (!File.Exists(fName)) return false;
 | 
									if (!File.Exists(fName)) return false;
 | 
				
			||||||
				xdoc.Load(fName);
 | 
									xdoc.Load(fName);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user