-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
currently i have the follwing to do
ops.showText(encodeCustom('Hello World', fontCustom)),
with
`// adapted from
// api/pdf-page.ts
// private encodeTextForFont(text: string, font: FontInput): PdfString {
function encodeCustom(text: string, font: FontInput): PdfString {
if (typeof font === "string") {
throw new Error()
}
const gids = font.encodeTextToGids(text)
const bytes = new Uint8Array(gids.length * 2)
for (let i = 0; i < gids.length; i++) {
const gid = gids[i]
bytes[i * 2] = (gid >> 8) & 0xff
bytes[i * 2 + 1] = gid & 0xff
}
return PdfString.fromBytes(bytes)
}`
otherwise the text won't show up ...
what about a second (optional) font parameter to showText
ops.showText('Hello World', fontCustom)
which would do the encoding transparently ...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels