public Handler() { var ms = new MemoryStream(); new MemoryStream(Resources.MainFont).CopyTo(ms); ms.Position = 0; font = new BCFNT(ms); }
public Handler() { var ms = new MemoryStream(); new GZipStream(new MemoryStream(Resources.MainFont_bcfnt), CompressionMode.Decompress).CopyTo(ms); ms.Position = 0; font = new BCFNT(ms); }
public void Load(string filename) { FileInfo = new FileInfo(filename); if (FileInfo.Exists) { _bcfnx = new BCFNT(FileInfo.OpenRead()); _bitmaps = _bcfnx.bmps.Select(o => new BitmapInfo { Bitmap = o }).ToList(); } }
public DaigassoHandler() { var ms = new MemoryStream(); new GZipStream(new MemoryStream(Resources.Basic_bcfnt), CompressionMode.Decompress).CopyTo(ms); ms.Position = 0; fontBasic = new BCFNT(ms); ms = new MemoryStream(); new GZipStream(new MemoryStream(Resources.SisterSymbol_bcfnt), CompressionMode.Decompress).CopyTo(ms); ms.Position = 0; fontSymbol = new BCFNT(ms); }
public void Load(string filename) { FileInfo = new FileInfo(filename); if (FileInfo.Exists) { _bcfnx = new BCFNT(FileInfo.OpenRead()); var _bmpList = _bcfnx.bmps.Select((o, i) => new BCFNTBitmapInfo { Bitmap = o, Format = _bcfnx._settings[i].Format.FormatName }).ToList(); _bitmaps = new List <BitmapInfo>(); _bitmaps.AddRange(_bmpList); } }
// Previewer public IList <Bitmap> GeneratePreviews(TextEntry entry) { var pages = new List <Bitmap>(); if (entry == null) { return(pages); } Bitmap img; float txtOffsetX, txtOffsetY, scale; float fullWidth; BCFNT font; var rawString = entry.EditedText; if (string.IsNullOrWhiteSpace(rawString)) { rawString = entry.OriginalText; } if (entry.Name.StartsWith("EDT_HELP") || entry.Name.StartsWith("VCL_HELP")) { img = new Bitmap(Resources.daigasso_box); font = fontBasic; font.SetColor(Color.Black); fontSisterSymbol.SetColor(Color.Black); fullWidth = 336; txtOffsetX = 32; txtOffsetY = 12; scale = 0.6f; } else if (entry.Name.StartsWith("Tutorial_") || rawString.Contains("\xE\x1")) { img = new Bitmap(410, 70); using (var g = Graphics.FromImage(img)) { g.FillRectangle(Brushes.White, 0, 0, img.Width, img.Height); g.FillRectangle(Brushes.LightYellow, 5, 6, 400, 58); } font = fontBasicRim; font.SetColor(Color.White); fullWidth = float.MaxValue; txtOffsetX = 5; txtOffsetY = 6; scale = 0.84f; } else { int height = 18 * (entry.OriginalText.Count(c => c == '\n') + 1); img = new Bitmap(226, height + 10); using (var g = Graphics.FromImage(img)) { g.FillRectangle(Brushes.White, 0, 0, img.Width, img.Height); g.FillRectangle(Brushes.LightYellow, 3, 5, 220, height); } font = fontCbfStd; font.SetColor(Color.Black); fontSisterSymbol.SetColor(Color.Black); fullWidth = 220; txtOffsetX = 3; txtOffsetY = 5; scale = 0.6f; } float widthMultiplier = 1; BCFNT baseFont = font; using (var g = Graphics.FromImage(img)) { g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.Bicubic; float x = 0, y = 0; for (int i = 0; i < rawString.Length; i++) { var c = rawString[i]; if (c == 0xE) { if (rawString[i + 1] == 2 && rawString[i + 2] == 0) { widthMultiplier = (rawString[i + 4] + 256 * rawString[i + 5]) / 100f; } else if (rawString[i + 1] == 0 && rawString[i + 2] == 3) { font.SetColor(Color.FromArgb(rawString[i + 7], rawString[i + 4], rawString[i + 5], rawString[i + 6])); } i += 3 + rawString[i + 3]; continue; } if (c == 0xF) { i += 2; widthMultiplier = 1; continue; } font = (c >> 8 == 0xE1) ? fontSisterSymbol : baseFont; // figure out how to merge fonts var char_width = font.GetWidthInfo(c).char_width *scale *widthMultiplier; if (c == '\n' || x + char_width >= fullWidth) { x = 0; y += font.LineFeed * scale; if (c == '\n') { continue; } } font.Draw(c, g, x + txtOffsetX, y + txtOffsetY, scale * widthMultiplier, scale); x += char_width; } } pages.Add(img); return(pages); }