wordSpacing with a negative number breaks the justification of a text

未关闭
#1,458 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@TheeCoderAhmed 已经在做这个了。

开始于 2026年11月3日。

  • #1863 来自 @TheeCoderAhmed —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
tooling

调研方向

首先使用 pdfkit 0.13.0,采用 justify 对齐和负的 wordSpacing 值,复现所提供的文本示例。跟踪该案例涉及的文本布局和两端对齐处理;完成的标准是负的单词间距会改变单词之间的距离,同时不会丢失两端对齐。

由索引模型根据 Issue 内容生成。

描述

Bug Report

Description of the problem

I would like to reduce the space between the words of a text.
I used the 'wordSpacing' property, but when adding a negative number to the 'wordSpacing', the justification of the text is lost. Below is the text that I am trying to change the distance between the words:

Code sample

let text = "Com a história de "o menino e o robô" compreendemos o perigo da robótica, não há dados científicos
sobre robôs dominarem o mundo, mas a riscos de exposição a novos riscos, como campos eletromagnéticos, acidentes,
desempregos devido a chegada da automação, além de ataques cibernéticos e desenvolvimento de armas autônomas.";

let textOptions = {
width: 436,
align: 'justify',
indent: 27.638,
lineBreak: true,
wordSpacing: -2.0,
lineGap: -6.0
};

pdfDoc
.font(POPPINS_REGULAR.ttf)
.fill("#000000")
.fontSize(22)
.text(text, 69, 64, textOptions)

Your environment

  • pdfkit version: 0.13.0
  • Node version: v14.21.2
  • Browser version (if applicable):
  • Operating System:
主要语言
JavaScript
星标
10.7k
派生
1.2k
平均合并
21 小时 41 分钟
30 天内合并 PR
27

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

foliojs/pdfkit 的其他 Issue

查看 foliojs/pdfkit 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。