Chinese characters showing as question marks

前端 未结 1 1572
有刺的猬
有刺的猬 2021-01-17 07:03

This has been asked before, but I can\'t figure out what\'s wrong. I\'m printing pdfs using phantomjs .render().

The rendered page is basically a local

相关标签:
1条回答
  • 2021-01-17 07:36

    You need a chinese font. None of them is in a chinese font family.

    font: normal 17px helvetica,arial,verdana,sans-serif

    Here are some font has chinese char.

    宋体:SimSun; 黑体:SimHei; 新宋体:NSimSun; 微软雅黑:Microsoft YaHei; 新細明體:PMingLiU

    This is much more than a guide.Chinese Standard Web Fonts: A Guide to CSS Font Family Declarations for Web Design in Simplified Chinese

    This has Traditional Chinese fonts.Chinese web fonts

    Google's font. Sorry for not being a link, there is a limit for me.

    noto-sans-hans

    Adobe's typekit

    source-han-sans

    Test Html file:

    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="utf-8" />
        <title>你好中文!</title>
        <style type="text/css">
            p.serif{font-family:"Times New Roman",Georgia,Serif}
            p.sansserif{font-family:SimSun}
            p.s1{font-family: 黑体}
            p.s2{font-family: KaiTi}
            p.s3{font-family: Microsoft YaHei}
        </style>
    </head>
    
    <body>
        <div>
        <p class="serif">你好中文!111</p>
        <p class="sansserif">宋体</p>
        </div>
        <div>
            <p class="s1">黑体</p>
            <p class="s2">楷体</p>
            <p class="s3">微软雅黑</p>
        </div>
    </body>
    </html>
    

    Result

    enter image description here

    Lastest to do, try to change your location to china. I don't expect this working, as I tried the phantomjs in win10 ENG preview, working very well. Control Panel > Region > Administrative > Language for non-Unicode programs

    enter image description here

    0 讨论(0)
提交回复
热议问题