Is there a way to make a fragment of text within a line bold in nodejs pdfkit?

Node-pdfkit http://pdfkit.org/index.html

I am using nodejs pdfkit to generate a pdf. I want to be able to bold or italic individual words in a line. It looks like pdfkit doesn't support this, so I was wondering if anyone had done something similar?

What would be really useful is to call the doc.text function, but have the document retain it's x position, so that I could do the following.

doc.text('some words then ');
doc.font('Helvetica-Oblique');
doc.text('italic');
doc.font('Helvetica');
doc.text(' then the remaining words');

and see the output:

some words then italic then the remaining words.

Right now it's outputting one line per text function.

Anyone know a good way to do this?

This feature was added by ej4 in this pull request https://github.com/devongovett/pdfkit/pull/60

It hasn't been merged in to the main project yet, so I ended up forking pdfkit myself, and including ej4s changes and a few of my own.

The basic result is that the changes make it possible to add

continued: true

to the options object. Pdfkit then remembers the caret position and returns you to that position for the next line of text.

Please see: Can I mix font weights in the same paragraph when using pdfkit?

pdf.text('Hello ', LEFT, 200, {
    //here it is, 
    lineBreak : false
}).font(bold).text('World!');