empira / PDFsharp

PDFsharp and MigraDoc Foundation for .NET 6 and .NET Framework
https://docs.pdfsharp.net/
Other
398 stars 91 forks source link

IVS support #86

Open leesatoh opened 4 months ago

leesatoh commented 4 months ago

Hi, I am using PDFsharp version 6.1.0 preview with .NET Framework 4.6.1. When I tried to write an IVS (Ideographic Variation Sequence) word using string target = char.ConvertFromUtf32(0x2D997) + char.ConvertFromUtf32(0xE0100); and called the DrawString function of PdfSharp.Drawing.XGraphics, it threw an IndexOutOfRangeException. Does PDFsharp support IVS?

stack trace `テスト名: TestIVS テストの完全名: UnitTestProject1.UnitTest1.TestIVS テスト ソース: C:\Users\satom\source\repos\SamplePDFbyIPA\UnitTestProject1\UnitTest1.cs : 行 117 テスト成果: 失敗 テスト継続期間: 0:00:00.2094713

結果 のスタック トレース: 場所 PdfSharp.Fonts.OpenType.OpenTypeDescriptor.CharCodeToGlyphIndex(Char highSurrogate, Char lowSurrogate) 場所 D:\THHO\Repos\PDFsharp\src\foundation\src\PDFsharp\src\PdfSharp\Fonts.OpenType\OpenTypeDescriptor.cs:行 310 場所 PdfSharp.Drawing.FontHelper.MeasureString(String text, XFont font, XStringFormat stringFormat_notyetused) 場所 D:\THHO\Repos\PDFsharp\src\foundation\src\PDFsharp\src\PdfSharp\Drawing\FontHelper.cs:行 70 場所 PdfSharp.Drawing.XGraphics.MeasureString(String text, XFont font, XStringFormat stringFormat) 場所 D:\THHO\Repos\PDFsharp\src\foundation\src\PDFsharp\src\PdfSharp\Drawing\XGraphics.cs:行 3617 場所 PdfSharp.Drawing.XGraphics.MeasureString(String text, XFont font) 場所 D:\THHO\Repos\PDFsharp\src\foundation\src\PDFsharp\src\PdfSharp\Drawing\XGraphics.cs:行 3739 場所 PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawString(String s, XFont font, XBrush brush, XRect rect, XStringFormat format) 場所 D:\THHO\Repos\PDFsharp\src\foundation\src\PDFsharp\src\PdfSharp\Drawing.Pdf\XGraphicsPdfRenderer.cs:行 431 場所 PdfSharp.Drawing.XGraphics.DrawString(String text, XFont font, XBrush brush, XRect layoutRectangle, XStringFormat format) 場所 D:\THHO\Repos\PDFsharp\src\foundation\src\PDFsharp\src\PdfSharp\Drawing\XGraphics.cs:行 3601 場所 UnitTestProject1.UnitTest1.SaveIPAmjMincho(String text, String filename) 場所 C:\Users\satom\source\repos\SamplePDFbyIPA\UnitTestProject1\UnitTest1.cs:行 51 場所 UnitTestProject1.UnitTest1.TestIVS() 場所 C:\Users\satom\source\repos\SamplePDFbyIPA\UnitTestProject1\UnitTest1.cs:行 120 結果 のメッセージ: テスト メソッド UnitTestProject1.UnitTest1.TestIVS が例外をスローしました: System.IndexOutOfRangeException: インデックスが配列の境界外です。

`

ThomasHoevel commented 4 months ago

PDFsharp does not (yet) support LTR languages, Japanese, Chinese, Korean, ...

Issue here is that the font does not contain 0xE0100 and PDFsharp did not handle this correctly. Beginning with 6.1.0-preview-2 a placeholder square will be drawn when requesting 0xE0100.

If IVS requires different handling, then this still must be added to PDFsharp. PDFsharp does not handle ligatures yet either. Thanks for your feedback.