Skip to content

Commit

Permalink
Merge pull request #192 from shaehn/ngon
Browse files Browse the repository at this point in the history
Fix text 'separation' colors #187
  • Loading branch information
chunyenHuang authored Jul 17, 2020
2 parents 54d334f + dc1486c commit 0b41bfe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ exports.text = function text(text = '', x, y, options = {}) {
const addTextTraits = (ctx, options) => {
ctx.Tf(options.font, options.size);
ctx.Tc(options.charSpace);
Color.fill(ctx, options.colorModel);
if (options.colorModel.xObject) {
options.colorModel.xObject.fill(options.colorModel);
} else {
Color.fill(ctx, options.colorModel);
}
};

const emitText = (word, x, y, ctx) => {
Expand Down Expand Up @@ -442,6 +446,9 @@ exports.text = function text(text = '', x, y, options = {}) {
// https://github.com/galkahana/HummusJS/wiki/Use-the-pdf-drawing-operators
const xObject = new xObjectForm(this.writer, textBox.width, lineHeight);
const xObjectCtx = xObject.getContentContext();
if (options.colorModel) {
options.colorModel.xObject = xObject;
}

xObjectCtx.q();
xObjectCtx.gs(xObject.getGsName(options.fillGsId)); // set graphic state (here opacity)
Expand Down

0 comments on commit 0b41bfe

Please sign in to comment.