How to use the @react-pdf/textkit/run/advanceWidth function in @react-pdf/textkit

To help you get started, we’ve selected a few @react-pdf/textkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github diegomura / react-pdf / src / render / renderSvgText.js View on Github external
const renderRun = (ctx, run) => {
  const runAdvanceWidth = runWidth(run);
  const { font, fontSize, color, opacity } = run.attributes;

  ctx.fillColor(color);
  ctx.fillOpacity(opacity);

  if (font.sbix || (font.COLR && font.CPAL)) {
    ctx.save();
    ctx.translate(0, -run.ascent);

    for (let i = 0; i < run.glyphs.length; i++) {
      const position = run.positions[i];
      const glyph = run.glyphs[i];

      ctx.save();
      ctx.translate(position.xOffset, position.yOffset);

@react-pdf/textkit

An advanced text layout framework

MIT
Latest version published 27 days ago

Package Health Score

92 / 100
Full package analysis

Similar packages