You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using pdfMake to create a PDF. I check the content of the text and only then decide what font to use depending on the language it's working fine except the Korean.
If you could recommend how to solve it I will really appreciate it. Thanks!
Code sample
import pdfMake from "pdfmake/build/pdfmake";
import pdfFonts from "other/vfs_fonts";
pdfMake.fonts = {
"Roboto":{
"bold":"Roboto-Medium.ttf",
"normal":"Roboto-Regular.ttf"},
"NanumGothic":{
"bold": 'NanumGothic-Regular.ttf',
"normal": 'NanumGothic-Regular.ttf'},
"NotoSansEthiopic":{
"normal": 'NotoSansEthiopic-Regular.ttf',
"bold": 'NotoSansEthiopic-Bold.ttf'}
};
function getFont(string) {
if (checkAmharic(string)) {
return "amharic_font";
} else if (checkKorean(string)) {
return "korean_font";
} else {
return "default_font";
}
}
function checkAmharic(x) {
return /[\u1200-\u137F]/.test(x); // will return true if an amharic letter is present
}
function checkKorean(x) {
return /[가-힣]+/.test(x); // will return true if an Korean letter is present
}
var caseDocDefinition = {
content:
[ 'ASCII-1: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z',
'ASCII-2: a b c d e f g h i j k l m n o p q r s t u v w x y z',
'ASCII-3: 0 1 2 3 4 5 6 7 8 9',
'ASCII-4: . , : ; - _ ! ? / " \' ` ^ ~ * + = \\ | # $ @ % & ( ) < > [ ] { }',
'German: Ä Ö Ü ä ö ü ß',
'Czech-1: Á Č Ď É Ě Í Ň Ó Ř Š Ť Ú Ů Ý Ž',
'Czech-2: á č ď é ě í ň ó ř š ť ú ů ý ž',
'Romanian-1: Ă Â Î Ş Ţ',
'Romanian-2: ă â î ş ţ',
'Slovenian-1: Č Š Ž',
'Slovenian-1: č š ž',
'Slowak-1: Á Ä Č Ď É Í Ľ Ĺ Ň Ó Ô Ŕ Š Ť Ú Ý Ž',
'Slowak-2: á ä č ď é í ľ ĺ ň ó ô ŕ š ť ú ý ž',
'Special: § ´ ² ³ ° µ €',
'polish: Cześć',
{width:350, text: '여보세요', style: getFont('여보세요'), alignment: 'justify'},
{width:350, text: 'some other text', style: getFont('some other text'), alignment: 'justify'},
{width:350, text: 'ሰላም', style: getFont('ሰላም'), alignment: 'justify'}
],
defaultStyle: {
font: "Roboto"
},
styles: {
amharic_font: {
font: "NotoSansEthiopic",
margin: [10,0,0,2]
},
korean_font: {
font: "NanumGothic",
margin: [10,0,0,2]
},
default_font: {
font: "Roboto",
margin: [10,0,0,2]
}
}
}
/* Create the pdf */
pdfMake.createPdf(caseDocDefinition).open();
Your environment
pdfkit version: v0.8.3 / v0.9.0
Node version: v8.12.0
Browser version (if applicable): Google Chrome Version 71.0.3578.98
Operating System: Mac
The text was updated successfully, but these errors were encountered:
Bug Report
Description of the problem
I'm using pdfMake to create a PDF. I check the content of the text and only then decide what font to use depending on the language it's working fine except the Korean.
using this font https://fonts.google.com/specimen/Nanum+Gothic?selection.family=Nanum+Gothic&selection.subset=korean.
I checked over 10 different fonts for Korean and all of them are missing characters.
(https://www.google.com/get/noto/#sans-kore or https://fonts.google.com/?subset=korean)
vfs_fonts.js.zip
after a lot of research i fond a font that works KaigenSansSC-*.ttf (https://github.com/m13253/kaigen-fonts) but it's a very hevy (23.MB) font and and prefer using something smaller.
at pdfmake they say it mayve an issue in pdfkit... bpampuch/pdfmake#1614
If you could recommend how to solve it I will really appreciate it. Thanks!
Code sample
Your environment
The text was updated successfully, but these errors were encountered: