This commit is contained in:
Matthew Leibowitz 2020-07-11 00:59:54 +02:00
Родитель 364f92eea3
Коммит 23df0b47a3
3 изменённых файлов: 47 добавлений и 1 удалений

Просмотреть файл

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace SkiaSharp
@ -427,6 +428,7 @@ namespace SkiaSharp
RasterDpi = rasterDpi;
PdfA = false;
EncodingQuality = DefaultEncodingQuality;
FontSubsetterDelegate = null;
}
public SKDocumentPdfMetadata (int encodingQuality)
@ -442,6 +444,7 @@ namespace SkiaSharp
RasterDpi = DefaultRasterDpi;
PdfA = false;
EncodingQuality = encodingQuality;
FontSubsetterDelegate = null;
}
public SKDocumentPdfMetadata (float rasterDpi, int encodingQuality)
@ -457,6 +460,7 @@ namespace SkiaSharp
RasterDpi = rasterDpi;
PdfA = false;
EncodingQuality = encodingQuality;
FontSubsetterDelegate = null;
}
public string Title { readonly get; set; }
@ -471,6 +475,8 @@ namespace SkiaSharp
public bool PdfA { readonly get; set; }
public int EncodingQuality { readonly get; set; }
public Func<SKData, IEnumerable<int>, string, int, SKData> FontSubsetterDelegate { readonly get; set; }
public readonly bool Equals (SKDocumentPdfMetadata obj) =>
Title == obj.Title &&
Author == obj.Author &&

2
externals/skia поставляемый

@ -1 +1 @@
Subproject commit 802f2cb2fcb9153c2f5e675b608e421f8b16ebe7
Subproject commit accbcfece683958b7c884a6e497c4f6aca1e6459

Просмотреть файл

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using Xunit;
@ -110,6 +111,45 @@ namespace SkiaSharp.Tests
}
}
[SkippableFact]
public void CanCreatePdfWithSubsetter()
{
var metadata = SKDocumentPdfMetadata.Default;
metadata.FontSubsetterDelegate = (SKData fontData, IEnumerable<int> codepoints, string fontName, int ttcIndex) =>
{
SKData data = null;
// do something
foreach (var cp in codepoints)
{
// add cp
}
// do last
return data;
};
using (var stream = new MemoryStream())
{
using (var doc = SKDocument.CreatePdf(stream, metadata))
{
Assert.NotNull(doc);
Assert.NotNull(doc.BeginPage(100, 100));
doc.EndPage();
doc.Close();
}
Assert.True(stream.Length > 0);
Assert.True(stream.Position > 0);
stream.Position = 0;
using (var reader = new StreamReader(stream))
{
var contents = reader.ReadToEnd();
Assert.Contains("/Author (SkiaSharp Team)", contents);
}
}
}
[SkippableFact]
public void ManagedStreamDisposeOrder()
{