При создании экземпляра BaseFont
с включенным внедрением необходимо вызвать myBaseFont.setSubset(true)
.Обратите внимание, что с кодировкой «Identity-H» (AKA BaseFont.IDENTITY_H
) это происходит автоматически:
// find all fonts in the usual places across multiple OSs.
// This can be pretty slow if you have a large number fonts, or the fonts
// themselves are Really Big (ArialUnicodeMS: 23mb).
FontFactory.registerDirectories();
// here's one way to do it, using identity-h forces subsetting
Font myFontSubset1 = FontFactory.getFont(fontName1, BaseFont.IDENTITY_H);
// here's another, explicitly enable subsetting for the underlying BaseFont.
Font myFontSubset2 = FontFactory.getFont(fontName2, FontFactory.defaultEncoding, true);
myFontSubset2.getBaseFont().setSubset(true);
//or you can create the BaseFont yourself, with automagic subsetting
BaseFont myFontSubset3 = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H);
// or create it with some other encoding, and enable subsetting.
BaseFont myFontSubset4 = BaseFont.createFont(fontPath, BaseFont.WINANSI, true);
myFontSubset4.setSubset(true);
Обратите внимание, что это все Java.В C # первая буква имен функций начинается с заглавных букв, а setX(newX)
и getX()
становятся свойствами.