Skip to content

Commit 005f73e

Browse files
committed
Add digits to bold font for PDF embedding
1 parent 2606892 commit 005f73e

5 files changed

Lines changed: 19 additions & 10 deletions

File tree

1.26 KB
Binary file not shown.
1 Byte
Binary file not shown.

Core/PDF/EmbeddedFonts.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ internal static GeneralDict CreateLiberationSansBold(Document document)
198198

199199
var fontFile2 = new StreamData(new Dictionary<string, object>
200200
{
201-
{ "Length", 10937 },
201+
{ "Length", 12224 },
202202
{ "Filter", new Name("FlateDecode") },
203-
{ "Length1", 16652 },
203+
{ "Length1", 18444 },
204204
}, "LiberationSansBold-FontFile2.bin");
205205

206206

@@ -214,7 +214,7 @@ internal static GeneralDict CreateLiberationSansBold(Document document)
214214
var fontDescriptor = new GeneralDict(new Dictionary<string, object>
215215
{
216216
{ "Type", new Name("FontDescriptor") },
217-
{ "FontName", new Name("AAAXDL+LiberationSans-Bold") },
217+
{ "FontName", new Name("AAAPVL+LiberationSans-Bold") },
218218
{ "Flags", 4 },
219219
{ "FontWeight", 700.000000f },
220220
{ "ItalicAngle", 0.000000f },
@@ -235,16 +235,16 @@ internal static GeneralDict CreateLiberationSansBold(Document document)
235235

236236
var cIDToGIDMap = new StreamData(new Dictionary<string, object>
237237
{
238-
{ "Length", 145 },
238+
{ "Length", 165 },
239239
{ "Filter", new Name("FlateDecode") },
240-
}, new byte[] { 0x78, 0x9C, 0xED, 0x8F, 0xC7, 0x0E, 0x82, 0x50, 0x10, 0x45, 0x8F, 0xBD, 0x37, 0xEC, 0x58, 0xB0, 0x62, 0x17, 0xEC, 0xBD, 0xFF, 0xFF, 0x3F, 0x49, 0x90, 0x05, 0x0B, 0x21, 0x1A, 0x5D, 0xBE, 0x93, 0xCC, 0xDC, 0x4C, 0x4B, 0xEE, 0x80, 0x89, 0x07, 0x37, 0xBC, 0xAE, 0xD3, 0x17, 0x3E, 0xFC, 0x04, 0x08, 0x12, 0x22, 0x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9, 0x8E, 0x5D, 0x7B, 0x43, 0xD7, 0x65, 0xFB, 0x0E, 0x1C, 0x3A, 0x72, 0xAC, 0xE2, 0xC4, 0xA9, 0x33, 0xE7, 0xAA, 0x2E, 0xD4, 0x5C, 0xBA, 0x52, 0xD7, 0x70, 0xED, 0xC6, 0xAD, 0x3B, 0xF7, 0x9A, 0x5A, 0xDA, 0x3A, 0x23, 0xF3, 0x3E, 0x8C, 0xD8, 0x3F, 0x0E, 0xF4, 0x69, 0xEC, 0xB7, 0x93, 0xF3, 0x3C, 0xD0, 0x6E, 0xBF, 0xBF, 0x78, 0xF5, 0xF6, 0xAB, 0xAF, 0xF7, 0x5D, 0xEF, 0x43, 0xF3, 0xC7, 0x3F, 0xE7, 0x08, 0x08, 0x08, 0xF8, 0x1B, 0x9F, 0x5F, 0x94, 0xD0, 0x0B, 0xBC, });
241241

242242

243243
var descendantFonts = new GeneralDict(new Dictionary<string, object>
244244
{
245245
{ "Type", new Name("Font") },
246246
{ "Subtype", new Name("CIDFontType2") },
247-
{ "BaseFont", new Name("AAAXDL+LiberationSans-Bold") },
247+
{ "BaseFont", new Name("AAAPVL+LiberationSans-Bold") },
248248
{ "CIDSystemInfo", document.CreateReference(cIDSystemInfo) },
249249
{ "FontDescriptor", document.CreateReference(fontDescriptor) },
250250
{ "W", new object[] {
@@ -253,7 +253,7 @@ internal static GeneralDict CreateLiberationSansBold(Document document)
253253
3,
254254
new int[] { 278, },
255255
18,
256-
new int[] { 278, },
256+
new int[] { 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, },
257257
36,
258258
new int[] { 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, },
259259
67,
@@ -284,15 +284,15 @@ internal static GeneralDict CreateLiberationSansBold(Document document)
284284

285285
var toUnicode = new StreamData(new Dictionary<string, object>
286286
{
287-
{ "Length", 322 },
287+
{ "Length", 323 },
288288
{ "Filter", new Name("FlateDecode") },
289289
}, "LiberationSansBold-ToUnicode.bin");
290290

291291

292292
var font = new GeneralDict(new Dictionary<string, object>
293293
{
294294
{ "Type", new Name("Font") },
295-
{ "BaseFont", new Name("AAAXDL+LiberationSans-Bold") },
295+
{ "BaseFont", new Name("AAAPVL+LiberationSans-Bold") },
296296
{ "Subtype", new Name("Type0") },
297297
{ "Encoding", new Name("Identity-H") },
298298
{ "DescendantFonts", new object[] {
@@ -307,6 +307,7 @@ internal static GeneralDict CreateLiberationSansBold(Document document)
307307
// Generated code. Do not modify. See the associated PDFFonts projects.
308308
internal static readonly char[] GlyphIndexesLiberationSansBold_0041_005a = new char[] { '\x0024', '\x0025', '\x0026', '\x0027', '\x0028', '\x0029', '\x002A', '\x002B', '\x002C', '\x002D', '\x002E', '\x002F', '\x0030', '\x0031', '\x0032', '\x0033', '\x0034', '\x0035', '\x0036', '\x0037', '\x0038', '\x0039', '\x003A', '\x003B', '\x003C', '\x003D', };
309309
internal static readonly char[] GlyphIndexesLiberationSansBold_0061_007a = new char[] { '\x0044', '\x0045', '\x0046', '\x0047', '\x0048', '\x0049', '\x004A', '\x004B', '\x004C', '\x004D', '\x004E', '\x004F', '\x0050', '\x0051', '\x0052', '\x0053', '\x0054', '\x0055', '\x0056', '\x0057', '\x0058', '\x0059', '\x005A', '\x005B', '\x005C', '\x005D', };
310+
internal static readonly char[] GlyphIndexesLiberationSansBold_0030_0039 = new char[] { '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001A', '\x001B', '\x001C', };
310311
internal static readonly char[] GlyphIndexesLiberationSansBold_0020_0020 = new char[] { '\x0003', };
311312
internal static readonly char[] GlyphIndexesLiberationSansBold_002f_002f = new char[] { '\x0012', };
312313
internal static readonly char[] GlyphIndexesLiberationSansBold_00e0_00e0 = new char[] { '\x00A2', };
@@ -336,6 +337,11 @@ internal static byte[] EncodeTextLiberationSansBold(string text)
336337
glyphIndexArray = GlyphIndexesLiberationSansBold_0061_007a;
337338
glyphIndex = ch - 0x0061;
338339
}
340+
else if (ch >= 0x0030 && ch <= 0x0039)
341+
{
342+
glyphIndexArray = GlyphIndexesLiberationSansBold_0030_0039;
343+
glyphIndex = ch - 0x0030;
344+
}
339345
else if (ch >= 0x0020 && ch <= 0x0020)
340346
{
341347
glyphIndexArray = GlyphIndexesLiberationSansBold_0020_0020;

CoreTest/PdfCanvasTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ public void PDFWithEmbeddedFonts()
112112

113113
DrawTextLine(canvas, 140, true, 'A', 'Z');
114114
DrawTextLine(canvas, 130, true, 'a', 'z');
115-
DrawTextLine(canvas, 120, true, "äöüàçéèô /");
115+
DrawTextLine(canvas, 120, true, '0', '9');
116+
DrawTextLine(canvas, 110, true, "äöüàçéèô /");
116117

117118
canvas.SaveAs("fonts.pdf");
118119
}

PDFFonts/src/main/java/net/codecrete/qrbill/pdffonts/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private static void createSubsets() throws IOException {
4848
var bold = new Subsetter(fonts[1]);
4949
bold.addCharacters('A', 'Z');
5050
bold.addCharacters('a', 'z');
51+
bold.addCharacters('0', '9');
5152
bold.addCharacters(0x0020, 0x0020); // space
5253
bold.addCharacters(0x002F, 0x002F); // slash
5354
bold.addCharacters(0x00E0, 0x00E0); // à
@@ -109,6 +110,7 @@ private static void createReferenceDocument() throws IOException {
109110
contentStream.newLineAtOffset(60, 400);
110111
drawTextLine(contentStream, 'A', 'Z');
111112
drawTextLine(contentStream, 'a', 'z');
113+
drawTextLine(contentStream, '0', '9');
112114
contentStream.newLineAtOffset(0, -24f);
113115
contentStream.showText("äöüàçéèô");
114116
contentStream.endText();

0 commit comments

Comments
 (0)