diff --git a/FastReport.Base/Export/ExportBase.cs b/FastReport.Base/Export/ExportBase.cs index e6c0c4b0..440a4610 100644 --- a/FastReport.Base/Export/ExportBase.cs +++ b/FastReport.Base/Export/ExportBase.cs @@ -508,6 +508,10 @@ internal void ExportPageNew(int pageNo) } ExportPageEnd(page); } + catch(Exception e) + { + Console.WriteLine(e.ToString()); + } finally { ppage.EndGetPage(page); diff --git a/FastReport.Base/Utils/FRPrivateFontCollection.cs b/FastReport.Base/Utils/FRPrivateFontCollection.cs index b1424749..3d4e3a7c 100644 --- a/FastReport.Base/Utils/FRPrivateFontCollection.cs +++ b/FastReport.Base/Utils/FRPrivateFontCollection.cs @@ -5,6 +5,11 @@ using System.Drawing.Text; using System.Drawing; using System.Linq; +#if SKIA +using static SkiaSharp.HarfBuzz.SKShaper; +using System.Diagnostics; +using FastReport.Fonts; +#endif namespace FastReport.Utils { @@ -14,7 +19,6 @@ namespace FastReport.Utils public partial class FRPrivateFontCollection { private readonly PrivateFontCollection collection = TypeConverters.FontConverter.PrivateFontCollection; - private readonly Dictionary _fonts = new Dictionary(); @@ -86,34 +90,44 @@ public bool AddFontFile(string filename) #if SKIA public void AddFontFromStream(Stream stream) { + using (FontStream fs = new FontStream(stream)) + { + FontType font_type = TrueTypeCollection.CheckFontType(fs); + IList list = TrueTypeCollection.AddFontData(font_type, fs); + foreach (var ttf in list) + { + if (!_fonts.ContainsKey(ttf.FastName)) + { + stream.Position = 0; + var ms = new MemoryStream(); + stream.CopyTo(ms); + ms.Position = 0; + _fonts.Add(ttf.FastName, new FontFromStream(ms)); + } + else + Console.WriteLine("Font {0} already registered\n", ttf.FastName); + } + fs.LeaveOpen = true; + } + + stream.Position = 0; collection.AddFont(stream); stream.Position = 0; + } + + public void AddTempFontStream(Stream stream) + { - var fontFamily = Families[Families.Length - 1]; - string fontName = fontFamily.Name; - - var isBold = fontFamily.IsStyleAvailable(FontStyle.Bold); - // every time is false - //var isItalic = fontFamily.IsStyleAvailable(FontStyle.Italic); - - fontName = fontName + (isBold ? "-B" : "") /*+ (isItalic ? "-I" : "")*/; - - if (!_fonts.ContainsKey(fontName)) - { - var ms = new MemoryStream(); - stream.CopyTo(ms); - ms.Position = 0; - _fonts.Add(fontName, new FontFromStream(ms)); - } } + #endif - /// - /// Adds a font contained in system memory to this collection. - /// - /// The memory address of the font to add. - /// The memory length of the font to add. - public void AddMemoryFont(IntPtr memory, int length) + /// + /// Adds a font contained in system memory to this collection. + /// + /// The memory address of the font to add. + /// The memory length of the font to add. + public void AddMemoryFont(IntPtr memory, int length) { collection.AddMemoryFont(memory, length); string fontName = Families[Families.Length - 1].Name; diff --git a/UsedPackages.version b/UsedPackages.version index 461f1fdb..b3191e34 100644 --- a/UsedPackages.version +++ b/UsedPackages.version @@ -3,9 +3,9 @@ - [2023.3.0] + [2023.3.1] - [2023.3.0] + [2023.3.1] [2023.3.4] [2023.3.0] @@ -15,7 +15,7 @@ 2023.3.0 2023.3.0 2023.2.1 - 2023.3.0 + 2023.3.1 2023.3.0