parallax/jsPDF

context2d initial property values are not applied

オープン

#3,319 opened on 2021/11/16

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (4,596 件のフォーク)batch import
Bugdifficulty:mediumhelp wanted

Repository metrics

Stars
 (28,280 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Example borrowed from #2701:

var doc = new jsPDF()
var ctx = doc.context2d
ctx.strokeText(`font: ${ctx.font}, line: ${ctx.lineWidth}`, 10, 10)
ctx.font = ctx.font // font size is changed(16px → 10px)
ctx.strokeText(`font: ${ctx.font}, line: ${ctx.lineWidth}`, 10, 20)
ctx.lineWidth = ctx.lineWidth // line width is changed(0.2px → 1px)
ctx.strokeText(`font: ${ctx.font}, line: ${ctx.lineWidth}`, 10, 30)

The same thing happens after manually switching or creating pages with addPage or setPage.

A correct solution would probably check if the current document state is the same as the context2d state and if not would apply the properties that are different before executing a command like fill, fillText, stroke, etc.

コントリビューターガイド