Skip to content

Kerning and style set 2 are not respected in the configuration #1754

@Re-n-Im

Description

@Re-n-Im

What were you trying to do?

I am using Cormorant Infant font and want to use glyphs in ss02 and also to apply the kerning.

How did you attempt to do it?

This is the part of the code, where I configure this behavior:

const oCormorantInfantFont = await pdfDoc.embedFont( oCormorantInfantFontBytes, {
	features: {
		kern: true,
		ss02: true
	}
});

What actually happened?

But with or without params in features, the result is same.

What did you expect to happen?

To see the glyphs from ss02 and correct space between letters, defined by kerning.

How can we reproduce the issue?

const { PDFDocument, rgb, PageSizes } = PDFLib

const sCormorantInfantUrl = location.origin + '/CormorantInfant-Bold.ttf';
const oCormorantInfantFontBytes = await fetch( sCormorantInfantUrl ).then( res => res.arrayBuffer( ) );

const pdfDoc = await PDFDocument.create()
const mmToPoints = (mm) => mm * 2.83465;

pdfDoc.registerFontkit( fontkit );

const oCormorantInfantFont = await pdfDoc.embedFont( oCormorantInfantFontBytes, {
	features: {
		kern: true,
		ss02: true
	}
});

const oPage = pdfDoc.addPage([
  mmToPoints( 148.5 ),
  mmToPoints( 210 )
]);

const sMainTitle = 'УПРАЖНЕНИЕ'
const fMainTitleSize = 31;

const fMainTitleTextSize = oCormorantInfantFont.widthOfTextAtSize(
	sMainTitle,
	fMainTitleSize
);

// Draw the string of text on the page
oPage.drawText( sMainTitle, {
  x: ( oPage.getWidth( ) - fMainTitleTextSize ) / 2,
  y: oPage.getHeight( ) * 920675676e-9,
  size: fMainTitleSize,
  align: 'center',
  font: oCormorantInfantFont,
  color: rgb( 0.659, 0.294, 0.396 ),
})

const pdfDataUri = await pdfDoc.saveAsBase64({ dataUri: true });
document.getElementById( 'pdf' ).src = pdfDataUri;

Version

1.4.0

What environment are you running pdf-lib in?

Browser

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions