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!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix(pdf): fall back to Indic, Ethiopic and Khmer fonts automatically (#3788)
Amruth Pillai2981bb90f2a0
diff --git a/docs/guides/customizing-typography.mdx b/docs/guides/customizing-typography.mdxindex 18abe95bc..54a1ee61c 100644--- a/docs/guides/customizing-typography.mdx+++ b/docs/guides/customizing-typography.mdx@@ -84,7 +84,7 @@ If you set an exact body line height or **Vertical spacing** in Advanced that do/></Frame>-The list contains Google Fonts plus the PDF standard fonts Helvetica, Courier and Times-Roman. Fonts for Chinese, Japanese, Korean, Arabic, Hebrew and Thai text are included, and missing characters fall back to a matching Noto font so they still print.+The list contains Google Fonts plus the PDF standard fonts Helvetica, Courier and Times-Roman. Fonts for Chinese, Japanese, Korean, Arabic, Hebrew, Thai, Indic scripts (such as Devanagari, Bengali, Tamil and Telugu), Amharic and Khmer text are included, and missing characters fall back to a matching Noto font so they still print.### Exact typography settingsdiff --git a/packages/fonts/src/index.test.ts b/packages/fonts/src/index.test.tsindex db66627c2..7c7acbc8d 100644--- a/packages/fonts/src/index.test.ts+++ b/packages/fonts/src/index.test.ts@@ -41,6 +41,23 @@ describe("getPdfFallbackFontFamilies", () => {expect(getPdfFallbackFontFamilies("Helvetica", { locale: "th-TH" })).toEqual(["Noto Sans Thai", "Noto Sans"]);expect(getPdfFallbackFontFamilies("Times-Roman", { locale: "th-TH" })).toEqual(["Noto Sans Thai", "Noto Serif"]);});++ it.each([+ ["hi-IN", "Noto Sans Devanagari", "Noto Sans Devanagari"],+ ["mr-IN", "Noto Sans Devanagari", "Noto Sans Devanagari"],+ ["ne-NP", "Noto Sans Devanagari", "Noto Sans Devanagari"],+ ["bn-BD", "Noto Sans Bengali", "Noto Serif Bengali"],+ ["or-IN", "Noto Sans Oriya", "Noto Sans Oriya"],+ ["ta-IN", "Noto Sans Tamil", "Noto Sans Tamil"],+ ["te-IN", "Noto Sans Telugu", "Noto Sans Telugu"],+ ["kn-IN", "Noto Sans Kannada", "Noto Sans Kannada"],+ ["ml-IN", "Noto Sans Malayalam", "Noto Sans Malayalam"],+ ["am-ET", "Noto Sans Ethiopic", "Noto Sans Ethiopic"],+ ["km-KH", "Noto Sans Khmer", "Noto Sans Khmer"],+ ] as const)("uses the native script's Noto font for %s", (locale, sans, serif) => {+ expect(getPdfFallbackFontFamilies("Helvetica", { locale })).toEqual([sans, "Noto Sans"]);+ expect(getPdfFallbackFontFamilies("Times-Roman", { locale })).toEqual([serif, "Noto Serif"]);+ });});describe("legacy font compatibility (#2989)", () => {diff --git a/packages/fonts/src/index.ts b/packages/fonts/src/index.tsindex 5bd8f0152..b784d4f6b 100644--- a/packages/fonts/src/index.ts+++ b/packages/fonts/src/index.ts@@ -59,7 +59,7 @@ const fontDisplayNames: Partial<Record<string, string>> = {// actual writing system: Hangul lives only in the KR fonts, Kana only in JP,// Arabic glyphs only in the Arabic fonts, etc. — so a Latin or Simplified-// Chinese font cannot render them and produces tofu. Where Noto ships no serif-// variant for a script (Hebrew, Thai), the serif slot reuses the sans font so+// variant for a script (Hebrew, Thai, most Indic scripts), the serif slot reuses the sans font so// serif resumes still render real glyphs instead of nothing. All entries are// present in webfontlist.json.const scriptFonts: Record<Script, { serif: string; sansSerif: string }> = {@@ -70,6 +70,19 @@ const scriptFonts: Record<Script, { serif: string; sansSerif: string }> = {arabic: { serif: "Noto Naskh Arabic", sansSerif: "Noto Sans Arabic" },hebrew: { serif: "Noto Sans Hebrew", sansSerif: "Noto Sans Hebrew" },thai: { serif: "Noto Sans Thai", sansSerif: "Noto Sans Thai" },+ // Indic, Ethiopic and Khmer text: Bengali is the only one shipped with a serif face.+ devanagari: { serif: "Noto Sans Devanagari", sansSerif: "Noto Sans Devanagari" },+ bengali: { serif: "Noto Serif Bengali", sansSerif: "Noto Sans Bengali" },+ gurmukhi: { serif: "Noto Sans Gurmukhi", sansSerif: "Noto Sans Gurmukhi" },+ gujarati: { serif: "Noto Sans Gujarati", sansSerif: "Noto Sans Gujarati" },+ oriya: { serif: "Noto Sans Oriya", sansSerif: "Noto Sans Oriya" },+ tamil: { serif: "Noto Sans Tamil", sansSerif: "Noto Sans Tamil" },+ telugu: { serif: "Noto Sans Telugu", sansSerif: "Noto Sans Telugu" },+ kannada: { serif: "Noto Sans Kannada", sansSerif: "Noto Sans Kannada" },+ malayalam: { serif: "Noto Sans Malayalam", sansSerif: "Noto Sans Malayalam" },+ sinhala: { serif: "Noto Sans Sinhala", sansSerif: "Noto Sans Sinhala" },+ ethiopic: { serif: "Noto Sans Ethiopic", sansSerif: "Noto Sans Ethiopic" },+ khmer: { serif: "Noto Sans Khmer", sansSerif: "Noto Sans Khmer" },// Monochrome outlines (TrueType glyf, not CBDT bitmaps) so react-pdf can// embed them; the serif/sans distinction is meaningless for emoji (#3321).emoji: { serif: "Noto Emoji", sansSerif: "Noto Emoji" },diff --git a/packages/fonts/src/webfontlist.json b/packages/fonts/src/webfontlist.jsonindex 4d80dcba6..8ff8c6f6f 100644--- a/packages/fonts/src/webfontlist.json+++ b/packages/fonts/src/webfontlist.json@@ -7578,5 +7578,131 @@"800": "https://fonts.gstatic.com/s/vazirmatn/v16/Dxx78j6PP2D_kU2muijPEe1n2vVbfJRkleg0CRCT60LA7Qdazg.ttf","900": "https://fonts.gstatic.com/s/vazirmatn/v16/Dxx78j6PP2D_kU2muijPEe1n2vVbfJRklcE0CRCT60LA7Qdazg.ttf"}+ },+ {+ "type": "web",+ "category": "sans-serif",+ "family": "Noto Sans Kannada",+ "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],+ "preview": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrDvNzSI.ttf",+ "files": {+ "100": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrDvMzSI.ttf",+ "200": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrLvNzSI.ttf",+ "300": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrGXNzSI.ttf",+ "400": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrDvNzSI.ttf",+ "500": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrAnNzSI.ttf",+ "600": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrOXKzSI.ttf",+ "700": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrNzKzSI.ttf",+ "800": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrLvKzSI.ttf",+ "900": "https://fonts.gstatic.com/s/notosanskannada/v32/8vIs7xs32H97qzQKnzfeXycxXZyUmySvZWItmf1fe6TVmgop9ndpS-BqHEyGrJLKzSI.ttf"+ }+ },+ {+ "type": "web",+ "category": "sans-serif",+ "family": "Noto Sans Oriya",+ "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],+ "preview": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5Ivj0f6_c.ttf",+ "files": {+ "100": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5Ivj0fq_c.ttf",+ "200": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5Ivh0f6_c.ttf",+ "300": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5Iviqf6_c.ttf",+ "400": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5Ivj0f6_c.ttf",+ "500": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5IvjGf6_c.ttf",+ "600": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5IvgqeK_c.ttf",+ "700": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5IvgTeK_c.ttf",+ "800": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5Ivh0eK_c.ttf",+ "900": "https://fonts.gstatic.com/s/notosansoriya/v35/AYCppXfzfccDCstK_hrjDyADv5e9748vhj3CJBLHIARtgD6TJQS0dJT5IvhdeK_c.ttf"+ }+ },+ {+ "type": "web",+ "category": "sans-serif",+ "family": "Noto Sans Gurmukhi",+ "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],+ "preview": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG1Oenbx.ttf",+ "files": {+ "100": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG1Oe3bx.ttf",+ "200": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG3Oenbx.ttf",+ "300": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG0Qenbx.ttf",+ "400": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG1Oenbx.ttf",+ "500": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG18enbx.ttf",+ "600": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG2QfXbx.ttf",+ "700": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG2pfXbx.ttf",+ "800": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG3OfXbx.ttf",+ "900": "https://fonts.gstatic.com/s/notosansgurmukhi/v29/w8g9H3EvQP81sInb43inmyN9zZ7hb7ATbSWo4q8dJ74a3cVrYFQ_bogT0-gPeG3nfXbx.ttf"+ }+ },+ {+ "type": "web",+ "category": "sans-serif",+ "family": "Noto Sans Gujarati",+ "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],+ "preview": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_ypFwPM.ttf",+ "files": {+ "100": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_ypFgPM.ttf",+ "200": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_wpFwPM.ttf",+ "300": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_z3FwPM.ttf",+ "400": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_ypFwPM.ttf",+ "500": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_ybFwPM.ttf",+ "600": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_x3EAPM.ttf",+ "700": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_xOEAPM.ttf",+ "800": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_wpEAPM.ttf",+ "900": "https://fonts.gstatic.com/s/notosansgujarati/v27/wlpWgx_HC1ti5ViekvcxnhMlCVo3f5pv17ivlzsUB14gg1TMR2Gw4VceEl7MA_wAEAPM.ttf"+ }+ },+ {+ "type": "web",+ "category": "sans-serif",+ "family": "Noto Sans Sinhala",+ "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],+ "preview": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwg2a5lg.ttf",+ "files": {+ "100": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwg2b5lg.ttf",+ "200": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwo2a5lg.ttf",+ "300": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwlOa5lg.ttf",+ "400": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwg2a5lg.ttf",+ "500": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwj-a5lg.ttf",+ "600": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwtOd5lg.ttf",+ "700": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwuqd5lg.ttf",+ "800": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwo2d5lg.ttf",+ "900": "https://fonts.gstatic.com/s/notosanssinhala/v36/yMJ2MJBya43H0SUF_WmcBEEf4rQVO2P524V5N_MxQzQtb-tf5dJbC30Fu9zUwqSd5lg.ttf"+ }+ },+ {+ "type": "web",+ "category": "sans-serif",+ "family": "Noto Sans Ethiopic",+ "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],+ "preview": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T35OK6Dj.ttf",+ "files": {+ "100": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T35OKqDj.ttf",+ "200": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T37OK6Dj.ttf",+ "300": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T34QK6Dj.ttf",+ "400": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T35OK6Dj.ttf",+ "500": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T358K6Dj.ttf",+ "600": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T36QLKDj.ttf",+ "700": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T36pLKDj.ttf",+ "800": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T37OLKDj.ttf",+ "900": "https://fonts.gstatic.com/s/notosansethiopic/v50/7cHPv50vjIepfJVOZZgcpQ5B9FBTH9KGNfhSTgtoow1KVnIvyBoMSzUMacb-T37nLKDj.ttf"+ }+ },+ {+ "type": "web",+ "category": "sans-serif",+ "family": "Noto Sans Khmer",+ "weights": ["100", "200", "300", "400", "500", "600", "700", "800", "900"],+ "preview": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYuNAJz4.ttf",+ "files": {+ "100": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYuNAZz4.ttf",+ "200": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYsNAJz4.ttf",+ "300": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYvTAJz4.ttf",+ "400": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYuNAJz4.ttf",+ "500": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYu_AJz4.ttf",+ "600": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYtTB5z4.ttf",+ "700": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYtqB5z4.ttf",+ "800": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYsNB5z4.ttf",+ "900": "https://fonts.gstatic.com/s/notosanskhmer/v29/ijw3s5roRME5LLRxjsRb-gssOenAyendxrgV2c-Zw-9vbVUti_Z_dWgtWYskB5z4.ttf"+ }}]diff --git a/packages/pdf/src/forme/export-text.integration.test.ts b/packages/pdf/src/forme/export-text.integration.test.tsindex 320dfd360..85cf12e10 100644--- a/packages/pdf/src/forme/export-text.integration.test.ts+++ b/packages/pdf/src/forme/export-text.integration.test.ts@@ -37,6 +37,8 @@ it.each([["مَرْحَبًا بِالْعَالَمِ", "Noto Sans Arabic", "ar-SA"],["नमस्ते दुनिया अनुभव कौशल", "Noto Sans Devanagari", "hi-IN"],["प्रशिक्षण क्षेत्र दृष्टि क्षत्रिय", "Noto Sans Devanagari", "hi-IN"],+ // The page language alone picks the Devanagari fallback for the default font.+ ["अमित शर्मा", "IBM Plex Serif", "hi-IN"],["日本語の履歴書 職務経験", "Noto Sans JP", "ja-JP"],["Hello 💻 engineer 🚀 coding 😀", "Noto Sans", "en-US"],["Family 👨👩👧👦 love 👩❤️💋👩 ❤️", "Noto Sans", "en-US"],@@ -60,3 +62,28 @@ it('exports characters no font can draw as "?" and names them', { timeout: 60_00const result = await act(() => renderResume(forme, { data: summaryResume("<p>Unsupported \u{10FFFF}</p>") }));expect(lostCharacters(result.warnings)).toEqual([expect.stringContaining("U+10FFFF")]);});++it.each([+ ["अमित शर्मा", "hi-IN"],+ ["अमित शर्मा हिन्दी", "en-US"],+ ["অমিত শর্মা", "bn-BD"],+ ["அமித் சர்மா", "en-US"],+ ["అమిత్ శర్మ", "te-IN"],+ ["അമിത് ശർമ്മ", "ml-IN"],+ ["ಅಮಿತ್ ಶರ್ಮಾ", "kn-IN"],+ ["ଅମିତ ଶର୍ମା", "or-IN"],+ ["ਅਮਿਤ ਸ਼ਰਮਾ", "en-US"],+ ["અમિત શર્મા", "en-US"],+ ["අමිත් ශර්මා", "en-US"],+ ["አሚት ሻርማ", "am-ET"],+ ["អមិត ស្រម៉ា", "km-KH"],+ ["Designer 👩🏽💻 coder", "en-US"],+] as const)(+ "draws %s through a script fallback for the default font (%s)",+ { timeout: 60_000 },+ async (text, locale) => {+ const data = summaryResume(`<p>${text}</p>`, "IBM Plex Serif", locale);+ const result = await act(() => renderResume(forme, { data }));+ expect(lostCharacters(result.warnings)).toBeNull();+ },+);diff --git a/packages/pdf/src/hooks/use-register-fonts.test.ts b/packages/pdf/src/hooks/use-register-fonts.test.tsindex cb2a30146..59466d754 100644--- a/packages/pdf/src/hooks/use-register-fonts.test.ts+++ b/packages/pdf/src/hooks/use-register-fonts.test.ts@@ -257,6 +257,26 @@ describe("resumeContentScripts", () => {expect(scripts.has("thai")).toBe(true);});+ it("detects Indic, Ethiopic and Khmer text", () => {+ const text = "हिन्दी বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල አማርኛ ខ្មែរ";+ expect(resumeContentScripts(withSummary(text))).toEqual(+ new Set([+ "devanagari",+ "bengali",+ "gurmukhi",+ "gujarati",+ "oriya",+ "tamil",+ "telugu",+ "kannada",+ "malayalam",+ "sinhala",+ "ethiopic",+ "khmer",+ ]),+ );+ });+it("returns an empty set for Latin-only content", () => {expect(resumeContentScripts(withSummary("Reactive Resume")).size).toBe(0);});diff --git a/packages/pdf/src/hooks/use-register-fonts.ts b/packages/pdf/src/hooks/use-register-fonts.tsindex 369834480..de20e0e47 100644--- a/packages/pdf/src/hooks/use-register-fonts.ts+++ b/packages/pdf/src/hooks/use-register-fonts.ts@@ -141,6 +141,8 @@ const hanRegex = /[\p{Script=Han}\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Kconst arabicRegex = /[-ۿݐ-ݿࢠ-ࣿﭐ-﷿ﹰ-ﻼ]/;const hebrewRegex = /[-יִ-ﭏ]/;const thaiRegex = /[-]/;+// Each Indic script, Ethiopic and Khmer needs its own Noto face; Latin and CJK fonts have none of them.+const scriptRegex = (script: string) => new RegExp(`\\p{Script=${script}}`, "u");// Emoji: regional indicators (flags) are NOT Extended_Pictographic, so union// them explicitly with the pictographic property (#3321). Keycap sequences@@ -162,6 +164,18 @@ const scriptDetectors: { script: Script; regex: RegExp }[] = [{ script: "arabic", regex: arabicRegex },{ script: "hebrew", regex: hebrewRegex },{ script: "thai", regex: thaiRegex },+ { script: "devanagari", regex: scriptRegex("Devanagari") },+ { script: "bengali", regex: scriptRegex("Bengali") },+ { script: "gurmukhi", regex: scriptRegex("Gurmukhi") },+ { script: "gujarati", regex: scriptRegex("Gujarati") },+ { script: "oriya", regex: scriptRegex("Oriya") },+ { script: "tamil", regex: scriptRegex("Tamil") },+ { script: "telugu", regex: scriptRegex("Telugu") },+ { script: "kannada", regex: scriptRegex("Kannada") },+ { script: "malayalam", regex: scriptRegex("Malayalam") },+ { script: "sinhala", regex: scriptRegex("Sinhala") },+ { script: "ethiopic", regex: scriptRegex("Ethiopic") },+ { script: "khmer", regex: scriptRegex("Khmer") },{ script: "emoji", regex: emojiRegex },{ script: "arrows", regex: arrowsRegex },{ script: "symbols", regex: symbolsRegex },diff --git a/packages/utils/src/locale.ts b/packages/utils/src/locale.tsindex e7bbc8204..822a25cf2 100644--- a/packages/utils/src/locale.ts+++ b/packages/utils/src/locale.ts@@ -110,6 +110,18 @@ export type Script =| "arabic"| "hebrew"| "thai"+ | "devanagari"+ | "bengali"+ | "gurmukhi"+ | "gujarati"+ | "oriya"+ | "tamil"+ | "telugu"+ | "kannada"+ | "malayalam"+ | "sinhala"+ | "ethiopic"+ | "khmer"| "emoji"| "arrows"| "symbols";@@ -125,7 +137,7 @@ export function isCjkScript(script: Script): boolean {// The script a locale primarily uses, used to order the fallback stack so the// dominant language renders with its native font. Persian (fa-IR) uses the-// Arabic script.+// Arabic script; Marathi and Nepali use Devanagari, like Hindi.export function getLocaleScript(locale?: Locale): Script | null {switch (locale) {case "ko-KR":@@ -143,6 +155,26 @@ export function getLocaleScript(locale?: Locale): Script | null {return "hebrew";case "th-TH":return "thai";+ case "hi-IN":+ case "mr-IN":+ case "ne-NP":+ return "devanagari";+ case "bn-BD":+ return "bengali";+ case "or-IN":+ return "oriya";+ case "ta-IN":+ return "tamil";+ case "te-IN":+ return "telugu";+ case "kn-IN":+ return "kannada";+ case "ml-IN":+ return "malayalam";+ case "am-ET":+ return "ethiopic";+ case "km-KH":+ return "khmer";default:return null;}