Forum Bugs

font has no family name

hanhongfei
Hello, I encountered a warn when using prince to generate a pdf with Chinese characters:
prince: HYShuHunJ.ttf: warning: font has no family name
prince: page 1: warning: no font for CJK character U+6C49, fallback to '?'
prince: page 1: warning: no font for CJK character U+4EEA, fallback to '?'
prince: page 1: warning: no font for CJK character U+4E66, fallback to '?'
prince: page 1: warning: no font for CJK character U+9B42, fallback to '?'
prince: page 1: warning: no font for CJK character U+4F53, fallback to '?'


Html is as follows:

<!DOCTYPE html>
<html>
 <head> 
  <meta charset="utf-8" /> 
  <style>
                    html,body{
                        overflow:hidden;
                        margin: 0;
                        padding: 0;
                        width:1157.48031496063px;
                        height: 732.2834645669292px;
                        font-family:Microsoft YaHei;
                        transform-origin:left top;
                        transform:scale(1);
                    }
                     @page {
                         size: 98mm 62mm;
                         margin: 0;
                         padding: 0;
                     }
                     @prince-pdf {
                         prince-filter-resolution: 300dpi;
                     }
                     image {
                         prince-image-resolution: 300dpi;
                     }
                     .html-wrap {
                         width:1157.48031496063px;
                         height: 732.2834645669292px;
                         margin: 0 auto;
                         position: absolute;
                         background-color:#ffffff;
                         transform-origin:left top;
                         transform:scale(1);
                     }
                     .element-wrap {
                         position: absolute;
                     }
                     .element-item {
                         position: absolute;
                         left: 0;
                         right: 0;
                         top: 0;
                         bottom: 0;
                     }
@font-face {font-family: 'font_1';src: url(HYShuHunJ.ttf);}
                 </style> 
 </head> 
 <body> 
  <div class="html-wrap"> 
   <div class="element-wrap" style="
                 left:146.79503205195115px;
                 top:172.0391143807442px;
                 width:896.59375px;
                 height:185px;
                 transform:rotate(0deg);
                 "> 
    <div class="element-item" style="
                     transform:scale(1,1);opacity:1;"> 
     <div class="text-element" style="
            position:absolute;
            left:0;
            top:0;
            width:100.000%;
            height:100.000%;
            transform:scale(1.000);
            transform-origin:0% 0% 0px;
            font-size:12px;
            writing-mode:normal;
            white-space: nowrap;
            word-break:inherit;
        ">
      <font>
       <div class="text-wrap" style="font-size: 175px; text-align: center; line-height: 96%; color: rgb(25, 25, 25);">
        <div>
         <font face="font_1">汉仪书魂体</font>
        </div>
       </div></font>
     </div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>



I got the PDF file, but the characters all turned into question marks.


  1. HYShuHunJ.ttf4.2 MB
    This is the Chinese font
mikeday
Do you have any other Chinese fonts installed? Is Microsoft YaHei being used at all?
hanhongfei
The operating system is Centos 7.4, Microsoft YaHei font is intalled.
Prince version is 12.5

There are two problems:
1. Font does not fallback Microsoft YaHei
2. Why does the font HYShuHunJ.ttf get the warning :"Prince warning: font has no family name"
mikeday
Do you get any results from running:
$ fc-list | grep YaHei

The missing font family name is a Prince issue that we may hopefully be able to fix in the next maintenance release.
hanhongfei
Run fc-list | grep YaHei
Get the following results:
[root@centos7 ~]# fc-list | grep YaHei
/usr/share/fonts/win/msyh.ttf: Microsoft YaHei:style=Regular,Normal
[root@centos7 ~]#


mikeday
That looks good, can you try running "prince --verbose test.html" for a simple document like:
<p style="font-family: Microsoft YaHei">hello</p>
hanhongfei
Running prince --verbose test.html
Get the following results:
[root@centos7 ~]# prince --verbose test.html
prince: loading document: /usr/lib/prince/license/license.dat
prince: Loading document...
prince: loading HTML5 input: test.html
prince: loading document: test.html
prince: Applying style sheets...
prince: Preparing document...
prince: Converting document...
prince: used font: Microsoft YaHei, Regular
prince: Finished: success
[root@centos7 ~]#
mikeday
That looks good, does it work if "hello" is replaced with Chinese text?
hanhongfei
it's work fine when replaced with chinese text
hanhongfei
when i replace
<font face="font_1">汉仪书魂体</font>

to
<font face="font_1 'Microsoft YaHei'">汉仪书魂体</font>

I get the pdf, the chiness text font graphic showing Microsoft Yahei
mikeday
Great, that is a good start. We will try and fix the font family name issue with the other font as soon as possible.
hanhongfei
Great,Thanks for your kindly reply.
Prince is a great software!
mikeday
Thank you! :D
mikeday
The Prince latest builds now support fonts with no English font family name, thanks for letting us know about the issue! :)
hanhongfei
I have tried the latest builds and the problem is solved perfectly.
thanks very much.