Skip to content

Commit 948880d

Browse files
Artyom YanchevskyiText-CI
authored andcommitted
Expose some font utility API for public usage
DEVSIX-5101 Autoported commit. Original commit hash: [9fadebfb1]
1 parent 5f14ad6 commit 948880d

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

itext/itext.kernel/itext/kernel/font/DocTrueTypeFont.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ source product.
5050
using iText.Kernel.Pdf;
5151

5252
namespace iText.Kernel.Font {
53-
internal class DocTrueTypeFont : TrueTypeFont, IDocFontProgram {
53+
public class DocTrueTypeFont : TrueTypeFont, IDocFontProgram {
5454
private PdfStream fontFile;
5555

5656
private PdfName fontFileName;

itext/itext.kernel/itext/kernel/font/FontUtil.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,19 @@ source product.
5151
using iText.Kernel.Pdf;
5252

5353
namespace iText.Kernel.Font {
54-
internal class FontUtil {
54+
public class FontUtil {
5555
private static readonly Dictionary<String, CMapToUnicode> uniMaps = new Dictionary<String, CMapToUnicode>(
5656
);
5757

58+
public static String AddRandomSubsetPrefixForFontName(String fontName) {
59+
StringBuilder newFontName = new StringBuilder(fontName.Length + 7);
60+
for (int k = 0; k < 6; ++k) {
61+
newFontName.Append((char)(JavaUtil.Random() * 26 + 'A'));
62+
}
63+
newFontName.Append('+').Append(fontName);
64+
return newFontName.ToString();
65+
}
66+
5867
internal static CMapToUnicode ProcessToUnicode(PdfObject toUnicode) {
5968
CMapToUnicode cMapToUnicode = null;
6069
if (toUnicode is PdfStream) {

itext/itext.kernel/itext/kernel/font/PdfFont.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ source product.
4343
*/
4444
using System;
4545
using System.Collections.Generic;
46-
using System.Text;
4746
using iText.IO.Font;
4847
using iText.IO.Font.Otf;
49-
using iText.IO.Util;
5048
using iText.Kernel;
5149
using iText.Kernel.Pdf;
5250

@@ -533,11 +531,7 @@ protected internal override bool IsWrappedObjectMustBeIndirect() {
533531
/// </returns>
534532
protected internal static String UpdateSubsetPrefix(String fontName, bool isSubset, bool isEmbedded) {
535533
if (isSubset && isEmbedded) {
536-
StringBuilder s = new StringBuilder(fontName.Length + 7);
537-
for (int k = 0; k < 6; ++k) {
538-
s.Append((char)(JavaUtil.Random() * 26 + 'A'));
539-
}
540-
return s.Append('+').Append(fontName).ToString();
534+
return FontUtil.AddRandomSubsetPrefixForFontName(fontName);
541535
}
542536
return fontName;
543537
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
21c9b38db565d1815041438f2c8b6e1d6b1a2e7e
1+
9fadebfb114a7ee9ef9058a8b0c9deec71262210

0 commit comments

Comments
 (0)