Posted 19 November 2018, 12:14 am EST
Hello there,
We are evaluating Documents for PDF and I found some minor issues when using Combining Characters and/or Clusters:
- Combining Diacritical Marks are not rendered over the previous character but as a separate character.
- Thai Combining Characters are overwritten
For example the standard font Helvetica uses for the decomposed ö character a Yu Gothic Fallback printing a big O and making a double line height.
By adding a Fallback to “Arial” and “Leelawadee UI” the output is better, still Helvetica uses a big O and Courier New print the combining characters separately.
The Courier New issue can be fixed by manually converting the decomposed characters into their equivalent combined form (when possible). I understand that it’s an understandable API design to not do that automatically withing Documents for PDF.
As a comparation the same output with Microsoft Word 2016 and the source code.
Actually we are using a library where we have to handle the font fallback manually, it requires much work (character clusters are Font dependent), especially for a cross platform application. A library that can handle this well would be welcome.
Thank you
// Create a new PDF document:
var doc = new GrapeCity.Documents.Pdf.GcPdfDocument();
// Add a page, get its graphics:
var g = doc.NewPage().Graphics;
// Get some fonts
var fc = new GrapeCity.Documents.Text.FontCollection();
fc.RegisterDirectory(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts));
fc.AppendFallbackFonts(fc.FindFamilyName("Arial"));
fc.AppendFallbackFonts(fc.FindFamilyName("Leelawadee UI"));
g.FontCollection = fc;
GrapeCity.Documents.Text.TextFormat[] textFormats =
{
new GrapeCity.Documents.Text.TextFormat() { Font = GrapeCity.Documents.Pdf.StandardFonts.Times },
new GrapeCity.Documents.Text.TextFormat() { Font = GrapeCity.Documents.Pdf.StandardFonts.Courier },
new GrapeCity.Documents.Text.TextFormat() { Font = GrapeCity.Documents.Pdf.StandardFonts.Helvetica },
new GrapeCity.Documents.Text.TextFormat() { Font = fc.FindFamilyName("Arial") },
new GrapeCity.Documents.Text.TextFormat() { Font = fc.FindFamilyName("Courier New") },
new GrapeCity.Documents.Text.TextFormat() { Font = fc.FindFamilyName("Segoe UI Symbol") },
new GrapeCity.Documents.Text.TextFormat() { Font = fc.FindFamilyName("Leelawadee UI") }
};
// Build Text Layout
var tl = g.CreateTextLayout();
tl.DefaultFormat.FontSize = 12;
// Print some text using various fonts
var text = ": Composed:ö\u1E8D, Decomposed:o\u0308x\u0308, Cluster:p\u0308 \u0E17\u0E37\u0E49\u0E48\n";
foreach (var tf in textFormats)
tl.Append(tf.Font.FontFamilyName + text, tf);
tl.PerformLayout(true);
doc.Pages.Last.Graphics.DrawTextLayout(tl, new PointF(72,72));
// Use GcPdfDocument object to set the FontEmbedMode
doc.FontEmbedMode = GrapeCity.Documents.Pdf.FontEmbedMode.EmbedFullFont;
// Save the PDF:
var filename = "DecomposedText.pdf";
doc.Save(filename);
System.Diagnostics.Process.Start(filename);
```[img]https://gccontent.blob.core.windows.net/forum-uploads/file-7e33731f-d53c-4cf7-8253-be31c0e0817f.png[/img][img]https://gccontent.blob.core.windows.net/forum-uploads/file-11eb8b7f-2ff8-489e-8869-436fa16ceef5.png[/img][img]https://gccontent.blob.core.windows.net/forum-uploads/file-2f665bd8-f123-4df7-881b-b997e2d03f2f.png[/img]