Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<th>星期一</th>Unicode does not support #290

Closed
syoukaihou opened this issue Dec 1, 2016 · 21 comments
Closed

<th>星期一</th>Unicode does not support #290

syoukaihou opened this issue Dec 1, 2016 · 21 comments
Labels

Comments

@syoukaihou
Copy link

<html>
    <head>
        <title>测试pdf</title>

        <style>
            @font-face {
                font-family: 'msyh';
                font-style: normal;
                font-weight: normal;
                src: url(http://www.test.com/fonts/msyh.ttf) format('truetype');
            }
            
            body {  font-family: 'msyh';  }
            
        </style>
    </head>
    <body>
        <div class=\"container\">
            <div class=\"content\">
                <div class=\"title\"><p>(2016年12月报)本月运营方向</p></div>
                
                <table>
                      <tr>
                        <th>星期一</th>
                        <th>星期二</th>
                      </tr>
                    <tr>
                        <td>1号</td><td>2号</td>
                    </tr>
                </table>
            </div>
        </div>
    </body>
</html>

but the web page show "???",
qq20161201-0 2x

@terrylow
Copy link

terrylow commented Dec 2, 2016

try to specify encoding in your head tag
<meta charset="UTF-8"> ?

@syoukaihou
Copy link
Author

I have try add , but it don't work. @terrylow

can you give me a demo ,if you use the same method .

@meditatorzhang
Copy link

I have the same problem, even serious. All Chinese words display "?", not only in <table>

@terrylow
Copy link

terrylow commented Dec 8, 2016

@syoukaihou @meditatorzhang do you have the chinese font installed ? i have tested, without proper chinese supported font (xx.ttf, xx.ufm, and xx.ufm.php), you will get ?? or square characters

@terrylow
Copy link

terrylow commented Dec 8, 2016

@meditatorzhang @syoukaihou

Step to install your font to dompdf

  1. download load_font.php and place in ur project root
  2. edit load_font.php
  • change the line require_once "autoload.inc.php";
    to require_once "vendor/autoload.php"
  • add $fontDir = "storage/fonts";
  1. download your chinese supported font at eg: Fonts-Unicode-Chinese and place at your project root
  2. run in commandline php load_font.php xxxfont xxxfont.ttf
    eg: you have download simsun.ttf you will do php load_font.php simsun simsun.ttf then you font will be installed to storage/fonts directory
  3. use the font in ur template font-family: simsun and your good to go

@ZK998
Copy link

ZK998 commented Dec 26, 2016

@terrylow,
that is great!! it works in chinese fonts.
thanks a lot !

@meditatorzhang
Copy link

@terrylow,
I operate as your method and run in commandline php load_font.php xxxfont xxxfont.ttf, but this command returns:

Unable to find bold face file.
Unable to find italic face file.
Unable to find bold_italic face file.
Copying simsun.ttf to storage/fonts/simsun.ttf...
Generating Adobe Font Metrics for storage/fonts/simsun...

at last, pdf file also display "?" in Chinese character postion.

@ZK998
Could you tell me how do you solve this problem, thanks a lot!

@ZK998
Copy link

ZK998 commented Jan 25, 2017

@meditatorzhang
Do you set ur page charset ""?
and can you find the font file in ""storage/fonts" directory

@meditatorzhang
Copy link

meditatorzhang commented Jan 25, 2017

@ZK998
I set the page charset, such as <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>,
there are simsun.ttf and simsun.ufm files in 'storage/fonts' directory.

@terrylow
Copy link

terrylow commented Jan 25, 2017

@meditatorzhang did you set font-family in your page or for your elements ?

@meditatorzhang
Copy link

@terrylow
There are simsun.ttf and sumsun.ufm files in storage/fonts and view file as following,but also display "?"

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>测试pdf</title>

    <style>
        @font-face {font-family: 'simsun'; font-style: normal; font-weight: normal; }
        html, body {  height: 100%;  }
        body {  margin: 0;  padding: 0;  width: 100%; font-weight: 100;  font-family: 'msyh';  }
        .container {  text-align: center; vertical-align: middle;  }
        .content {  text-align: center;  display: inline-block;  }
        .title {  font-size: 96px;  }
    </style>
</head>
<body>
<div class="container">
    <div class="content">
        <div class="title">xiao中华人民共和国</div>
    </div>
</div>
</body>
</html>

@terrylow
Copy link

terrylow commented Jan 25, 2017

@meditatorzhang
meditatorzhang
instead of @font-face {font-family: 'simsun'; font-style: normal; font-weight: normal; }
try
body {font-family: 'simsun'}

you need to use simsun font instead of 'msyh' in your case

@meditatorzhang
Copy link

@terrylow
That's great. Chinese Spring Festival is approachng, Happy New Year, thanks a lot!

@schel4ok
Copy link

schel4ok commented Feb 14, 2017

I don't know if it works with Chinese, but with Russian it is enough just to change setting in config/dompdf.php

"DOMPDF_DEFAULT_FONT" => "DejaVu Sans",

Load font is also working, but my way much easier.
Please check.

@dodacvan
Copy link

dodacvan commented Apr 7, 2017

@schel4ok thanks . it work for me .

@Cyrille37
Copy link

It works like @terrylow say at #290 (comment).

I use "simhei" that works fine with mixed Chinese and Latin characters.

Cheers

@huyit218
Copy link

huyit218 commented Jan 16, 2018

please help me to resolve my problem, i type my vietnamese but display ? ? character, i'm using dompdf, so how can i do to display m data. thanks all
could you make a video clip?

@muhammadtalhaishtiaq
Copy link

you just need to add font-family: DejaVu Sans; in your body or also you can set the font family to any specific div in which you are going to display the Unicode Characters.

For body: body{font-family: DejaVu Sans;}

And for a specific div: <div style="font-family: DejaVu Sans;"> --- </div>

Hope this would help.

@zong0828
Copy link

zong0828 commented Feb 17, 2020

hello i have same problem, then i have no idea which chinese font can be used.
I try to use
php load_font.php simsun 'simsun.ttf'

but it always show error
`PHP Fatal error: Uncaught Dompdf\Exception: Unable to read 'simsun.ttf'. in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php:77
Stack trace:
#0 /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php(192): install_font_family(Object(Dompdf\Dompdf), 'simsun', 'simsun.ttf')
#1 {main}
thrown in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php on line 77

Fatal error: Uncaught Dompdf\Exception: Unable to read 'simsun.ttf'. in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php:77
Stack trace:
#0 /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php(192): install_font_family(Object(Dompdf\Dompdf), 'simsun', 'simsun.ttf')
#1 {main}
thrown in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php on line 77`

@zong0828
Copy link

hello , I have same problem, then i have no idea which chinese font can be used.
however, i try to use load_font.php.php to get some fonts testing

PHP Fatal error:  Uncaught Dompdf\Exception: Unable to read 'simsun.ttf'. in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php:77
Stack trace:
#0 /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php(192): install_font_family(Object(Dompdf\Dompdf), 'simsun', 'simsun.ttf')
#1 {main}
  thrown in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php on line 77

Fatal error: Uncaught Dompdf\Exception: Unable to read 'simsun.ttf'. in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php:77
Stack trace:
#0 /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php(192): install_font_family(Object(Dompdf\Dompdf), 'simsun', 'simsun.ttf')
#1 {main}
  thrown in /Users/zonghan/Applications/dev-backend/source-code/ubss/load_font.php on line 77

@stale
Copy link

stale bot commented Jul 28, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most issues are actually related to DompDF (eg rendering the PDF itself), so please raise an issue there: https://github.com/dompdf/dompdf
If you believe this is still an actual issue with this library, please reply to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants