public GlyphCut(BitmapSource bitmapSource, VerticalCut verticalCut, int index) { Image = bitmapSource; Left = verticalCut.Left; Right = verticalCut.Right; Index = index; }
public bool Close() { if (edited) { var result = MessageBox.Show("Save changes?", "Saving", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { var CutList = fnt.WidthTable.WidthTable; for (int i = 0; i < GlyphCuts.Count; i++) { CutList[i] = new VerticalCut((byte)GlyphCuts[i].Left, (byte)GlyphCuts[i].Right); } return(true); } else if (result == MessageBoxResult.No) { return(true); } else { return(false); } } else { return(true); } }
public void SetTable(XDocument xDoc) { XElement WT = xDoc.Element("WidthTable"); int index = 0; try { foreach (var line in WT.Elements()) { int lineindex = Convert.ToInt32(line.Name.LocalName.Split('_')[1]); foreach (var glyph in line.Elements()) { int glyphindex = Convert.ToInt32(glyph.Name.LocalName.Split('_')[1]); index = (lineindex - 1) * 16 + (glyphindex - 1); WidthTable[index] = new VerticalCut(Convert.ToByte(glyph.Element("LeftCut").Value), Convert.ToByte(glyph.Element("RightCut").Value)); } } } catch (Exception e) { Logging.Write("PersonaEditorLib", ""); } Logging.Write("PersonaEditorLib", "Width Table was writed. Get " + index + " glyphs"); }
private void OpenFont(FileStructure.FNT.FNT FNT) { try { ReadFONT(FNT); if (CutList.ContainsKey(32)) { CutList[32] = new VerticalCut(10, 20); } } catch (Exception e) { Logging.Write("PersonaEditorLib", e); } }
public Tuple <byte[], VerticalCut> GetGlyph(int index) { byte[] data = null; VerticalCut verticalCut = new VerticalCut(); if (DataList.ContainsKey(index)) { data = DataList[index]; } if (CutList.ContainsKey(index)) { verticalCut = CutList[index]; } return(new Tuple <byte[], VerticalCut>(data, verticalCut)); }
public static string SplitByWidth(this string String, Encoding FontMap, PersonaEncoding.PersonaFont Font, int width) { string returned = String.Join(" ", Regex.Split(String, @"\\n")); List <TextBaseElement> temp = returned.GetTextBaseList(FontMap); List <int> widthlist = new List <int>(); foreach (var a in temp) { if (a.IsText) { for (int i = 0; i < a.Array.Length; i++) { VerticalCut verticalCut = new VerticalCut(); if (a.Array[i] == 0x20) { widthlist.Add(9); continue; } else if (0x20 < a.Array[i] & a.Array[i] < 0x80) { verticalCut = Font.GetVerticalCut(a.Array[i]); } else if (0x80 <= a.Array[i] & a.Array[i] < 0xF0) { int newindex = (a.Array[i] - 0x81) * 0x80 + a.Array[i + 1] + 0x20; i++; verticalCut = Font.GetVerticalCut(newindex); } if (verticalCut.Right - verticalCut.Left > 0) { widthlist.Add(verticalCut.Right - verticalCut.Left - 1); } else { widthlist.Add(verticalCut.Right - verticalCut.Left); } } } else { widthlist.AddRange(new int[a.GetSystem().Length]); } } int index = 0; int widthsum = 0; while (index < widthlist.Count) { if (widthsum + widthlist[index] <= width) { widthsum += widthlist[index]; index++; } else { bool te = true; while (index != 0 & te) { if (widthlist[index - 1] != 0 & returned[index - 1] == ' ') { returned = returned.Insert(index, "\n"); widthlist.Insert(index, 0); te = false; } index--; } widthsum = 0; } } return(returned); }