Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

Problem in word wrapping in the templates (#3136)

Cantale08a523e13bfda3
diff --git a/packages/pdf/src/hooks/use-register-fonts.test.ts b/packages/pdf/src/hooks/use-register-fonts.test.ts
index 0b129802d..5a607abb7 100644
--- a/packages/pdf/src/hooks/use-register-fonts.test.ts
+++ b/packages/pdf/src/hooks/use-register-fonts.test.ts
@@ -156,24 +156,8 @@ describe("registerFonts", () => {
const hyphenationCallback = registerHyphenationSpy.mock.calls.at(-1)?.[0];
expect(hyphenationCallback?.("翠翠红红处处")).toEqual(["翠", "", "翠", "", "红", "", "红", "", "处", "", "处", ""]);
- expect(hyphenationCallback?.("Reactive")).toEqual([
- "R",
- "",
- "e",
- "",
- "a",
- "",
- "c",
- "",
- "t",
- "",
- "i",
- "",
- "v",
- "",
- "e",
- "",
- ]);
+ // Latin words must stay intact even in CJK mode — no character-level breaking.
+ expect(hyphenationCallback?.("Reactive")).toEqual(["Reactive"]);
});
it("returns typography with font weights sorted ascending", async () => {
diff --git a/packages/pdf/src/hooks/use-register-fonts.ts b/packages/pdf/src/hooks/use-register-fonts.ts
index 548fd652a..2c3d984cc 100644
--- a/packages/pdf/src/hooks/use-register-fonts.ts
+++ b/packages/pdf/src/hooks/use-register-fonts.ts
@@ -163,7 +163,11 @@ export const registerFonts = (typography: Typography, locale: Locale, hasCjkCont
Font.registerHyphenationCallback((word) => {
if (needsCjkTextSupport) {
if (word === " ") return ["\u200C "];
- return [...word].flatMap((l) => [l, ""]);
+ // Only break at every character for words that contain CJK characters.
+ // Latin/non-CJK words must stay intact even in a CJK-locale resume.
+ if (cjkLetterRegex.test(word)) {
+ return [...word].flatMap((l) => [l, ""]);
+ }
}
return [word];