Skip to content

Commit

Permalink
#4 git attributes to stop git mangling pfb files. output svgs for vis…
Browse files Browse the repository at this point in the history
…ual verification of type 1 glyphs
  • Loading branch information
EliotJones committed Nov 22, 2018
1 parent b9c8e15 commit 0e70175
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitattributes
@@ -0,0 +1,5 @@
*.pfa binary
*.pfb binary
*.bin binary
*.pdf binary
*.ttf binary
20 changes: 20 additions & 0 deletions src/UglyToad.PdfPig.Tests/Fonts/Type1/Type1FontParserTests.cs
Expand Up @@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using PdfPig.Fonts.Type1.Parser;
using PdfPig.IO;
using Xunit;
Expand Down Expand Up @@ -52,6 +53,25 @@ public void CanReadAsciiPart()
parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);
}

[Fact]
public void OutputCmbx10Svgs()
{
var bytes = GetFileBytes("CMBX10");

var result = parser.Parse(new ByteArrayInputBytes(bytes), 0, 0);

var builder = new StringBuilder("<!DOCTYPE html><html><head></head><body>");
foreach (var charString in result.CharStrings.CharStrings)
{
var path = result.CharStrings.Generate(charString.Key);
builder.AppendLine(path.ToFullSvg());
}

builder.Append("</body></html>");

File.WriteAllText("cmbx10.html", builder.ToString());
}

[Fact]
public void CanReadFontWithCommentsInOtherSubrs()
{
Expand Down
2 changes: 1 addition & 1 deletion src/UglyToad.PdfPig/Fonts/CharacterPath.cs
Expand Up @@ -146,7 +146,7 @@ string BboxToRect(PdfRectangle box, string stroke)
var path = $"<path d='{glyph}' stroke='cyan' stroke-width='3'></path>";
var bboxRect = bbox.HasValue ? BboxToRect(bbox.Value, "yellow") : string.Empty;
var others = string.Join(" ", bboxes.Select(x => BboxToRect(x, "gray")));
var result = $"<svg transform='scale(0.2, -0.2)' width='500' height='500'>{path} {bboxRect} {others}</svg>";
var result = $"<svg width='500' height='500'><g transform=\"scale(0.2, -0.2) translate(100, -700)\">{path} {bboxRect} {others}</g></svg>";

return result;
}
Expand Down

0 comments on commit 0e70175

Please sign in to comment.