Skip to content

Commit

Permalink
Merge pull request #642 from FastReports/sync_branch_2023.3.11
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2023.3.11
  • Loading branch information
0legK authored Nov 13, 2023
2 parents 764e91a + fad3c11 commit 12ad96c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
4 changes: 4 additions & 0 deletions FastReport.Base/Export/ExportBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ internal void ExportPageNew(int pageNo)
}
ExportPageEnd(page);
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
ppage.EndGetPage(page);
Expand Down
60 changes: 37 additions & 23 deletions FastReport.Base/Utils/FRPrivateFontCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -14,7 +19,6 @@ namespace FastReport.Utils
public partial class FRPrivateFontCollection
{
private readonly PrivateFontCollection collection = TypeConverters.FontConverter.PrivateFontCollection;

private readonly Dictionary<string, DictionaryFont> _fonts = new Dictionary<string, DictionaryFont>();


Expand Down Expand Up @@ -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<TrueTypeFont> 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

/// <summary>
/// Adds a font contained in system memory to this collection.
/// </summary>
/// <param name="memory">The memory address of the font to add.</param>
/// <param name="length">The memory length of the font to add.</param>
public void AddMemoryFont(IntPtr memory, int length)
/// <summary>
/// Adds a font contained in system memory to this collection.
/// </summary>
/// <param name="memory">The memory address of the font to add.</param>
/// <param name="length">The memory length of the font to add.</param>
public void AddMemoryFont(IntPtr memory, int length)
{
collection.AddMemoryFont(memory, length);
string fontName = Families[Families.Length - 1].Name;
Expand Down
6 changes: 3 additions & 3 deletions UsedPackages.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<!-- This group sets version used packages in FastReport.Core, FastReport.OpenSource, FastReport.CoreWin, FastReport.WPF -->
<PropertyGroup>

<FRCompatVersionNET>[2023.3.0]</FRCompatVersionNET>
<FRCompatVersionNET>[2023.3.1]</FRCompatVersionNET>

<FRCompatVersion>[2023.3.0]</FRCompatVersion>
<FRCompatVersion>[2023.3.1]</FRCompatVersion>
<FRCompatSkiaVersion>[2023.3.4]</FRCompatSkiaVersion>

<FRDataVisualizationVersion>[2023.3.0]</FRDataVisualizationVersion>
Expand All @@ -15,7 +15,7 @@
<FRWPFVersion>2023.3.0</FRWPFVersion>
<FRWPFRoslynPadVersion>2023.3.0</FRWPFRoslynPadVersion>
<FRFormsWPFVersion>2023.2.1</FRFormsWPFVersion>
<FRCompatWPFVersion>2023.3.0</FRCompatWPFVersion>
<FRCompatWPFVersion>2023.3.1</FRCompatWPFVersion>
<FRDataVisualizationWPFVersion>2023.3.0</FRDataVisualizationWPFVersion>

<!-- Not available in Core3 -->
Expand Down

0 comments on commit 12ad96c

Please sign in to comment.