metanorma / mn2pdf

Metanorma XML to PDF
3 stars 3 forks source link

Missing SVG fonts substitution #248

Open Intelligent2013 opened 3 months ago

Intelligent2013 commented 3 months ago

Source issue: https://github.com/metanorma/metanorma-plateau/issues/2

From full Plateau PDF generation:

WARNING: Font 'YuGothicUI-Regular' (font name 'YuGothicUI-Regular', font style 'normal', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Regular.ttf'.
WARNING: Font 'YuGothicUI-Regular' (font name 'YuGothicUI-Regular', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font 'YuGothicUI-Regular' (font name 'YuGothicUI-Regular', font style 'italic', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Italic.ttf'.
WARNING: Font 'YuGothicUI-Regular' (font name 'YuGothicUI-Regular', font style 'italic', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-BoldItalic.ttf'.
WARNING: Font 'YuGothicUI-Bold' (font name 'YuGothicUI-Bold', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font 'MS-PGothic' (font name 'MS-PGothic', font style 'normal', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Regular.ttf'.
WARNING: Font 'MS-PGothic' (font name 'MS-PGothic', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font 'MS-PGothic' (font name 'MS-PGothic', font style 'italic', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Italic.ttf'.
WARNING: Font 'MS-PGothic' (font name 'MS-PGothic', font style 'italic', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-BoldItalic.ttf'.
WARNING: Font ''YuGothicUI-Regular'' (font name ''YuGothicUI-Regular'', font style 'normal', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Regular.ttf'.
WARNING: Font ''YuGothicUI-Regular'' (font name ''YuGothicUI-Regular'', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font ''YuGothicUI-Regular'' (font name ''YuGothicUI-Regular'', font style 'italic', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Italic.ttf'.
WARNING: Font ''YuGothicUI-Regular'' (font name ''YuGothicUI-Regular'', font style 'italic', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-BoldItalic.ttf'.
WARNING: Font ''YuGothicUI-Bold'' (font name ''YuGothicUI-Bold'', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font ''MS-PGothic'' (font name ''MS-PGothic'', font style 'normal', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Regular.ttf'.
WARNING: Font ''MS-PGothic'' (font name ''MS-PGothic'', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font ''MS-PGothic'' (font name ''MS-PGothic'', font style 'italic', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Italic.ttf'.
WARNING: Font ''MS-PGothic'' (font name ''MS-PGothic'', font style 'italic', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-BoldItalic.ttf'.
WARNING: Font ''Calibri'' (font name ''Calibri'', font style 'normal', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Regular.ttf'.
WARNING: Font ''Calibri'' (font name ''Calibri'', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font ''Calibri'' (font name ''Calibri'', font style 'italic', font weight 'normal') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Italic.ttf'.
WARNING: Font ''Calibri'' (font name ''Calibri'', font style 'italic', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-BoldItalic.ttf'.
WARNING: Font ''Calibri-Bold'' (font name ''Calibri-Bold'', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\TestUser\.fontist\fonts\NotoSans-Bold.ttf'.

Font "YuGothicUI-Bold,normal,400" not found. Substituting with "any,normal,400".
Font "Calibri-BoldItalic,normal,400" not found. Substituting with "any,normal,400".
Font "Arial,normal,400" not found. Substituting with "any,normal,400".
Font "Calibri-Italic,normal,400" not found. Substituting with "any,normal,400".
Font "Meiryo-Bold,normal,400" not found. Substituting with "any,normal,400".
Font "Meiryo,normal,400" not found. Substituting with "any,normal,400".
Font "KozGoPr6N-Regular-90ms-RKSJ-H,normal,400" not found. Substituting with "any,normal,400".
Font "Meiryo-BoldItalic,normal,400" not found. Substituting with "any,normal,400".
Font "MeiryoUI,normal,400" not found. Substituting with "any,normal,400".
Font "MeiryoUI-Bold,normal,400" not found. Substituting with "any,normal,400".
Font "MeiryoUI-BoldItalic,normal,400" not found. Substituting with "any,normal,400".

Two issues:

ronaldtse commented 3 months ago

I think we need an SVG cleaning process to preprocess the files otherwise it’s too prone to breakage. I’m sure there’s a compliance check somewhere right?

ronaldtse commented 3 months ago

Fonts inside SVG have always been an issue we have to resolve, because it is not possible for us to have all fonts people specify in the SVG files.

Intelligent2013 commented 3 months ago

Regarding issue:

the fonts from the 2nd group don't replaced by NotoSans fonts

the styles determined in the element style:

<style type="text/css">
    .st0_inject_0 {opacity:0.5019608;fill-rule:evenodd;clip-rule:evenodd;fill:#969696;enable-background:new    ;}
    .st1_inject_0 {fill-rule:evenodd;clip-rule:evenodd;fill:#FFCCFF;}
    .st2_inject_0 {fill:none;stroke:#000000;stroke-width:1.5013124;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
    .st3_inject_0 {font-family:'Calibri';}
    .st4_inject_0 {font-size:9.7585306px;}
    .st5_inject_0 {font-family:'Calibri-Bold';}
    .st6_inject_0 {font-family:'Calibri-Italic';}
    .st7_inject_0 {font-family:'Calibri-BoldItalic';}
    .st8_inject_0 {fill-rule:evenodd;clip-rule:evenodd;fill:#F0F0F0;}
    .st9_inject_0 {fill:none;stroke:#D7D7D7;stroke-width:0.7506562;stroke-linecap:square;stroke-miterlimit:10;}
    .st10_inject_0 {fill-rule:evenodd;clip-rule:evenodd;fill:#CCFFCC;}
    .st11_inject_0 {fill:none;stroke:#000000;stroke-width:0.7506562;stroke-linecap:square;stroke-miterlimit:10;}
    .st12_inject_0 {enable-background:new    ;}
    .st13_inject_0 {fill:#003060;}
    .st14_inject_0 {font-family:'KozGoPr6N-Regular-90ms-RKSJ-H';}
    .st15_inject_0 {fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFCC;}
    .st16_inject_0 {font-family:'Meiryo-Bold';}
    .st17_inject_0 {font-size:12.010499px;}
    .st18_inject_0 {letter-spacing:-2.352941;}
    .st19_inject_0 {fill:none;stroke:#000000;stroke-width:1.5013124;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:10;}
    .st20_inject_0 {fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
</style>

I need to add the parsing.

Intelligent2013 commented 3 months ago

The font names from <style type="text/css" now recognizes by mn2pdf and replaced by NotoSans:

WARNING: Font 'Calibri-Italic' (font name 'Calibri-Italic', font style 'italic', font weight 'normal') doesn't exist. Replaced by 'C:\Users\IntlUser\.fontist\fonts\NotoSans-Italic.ttf'.
WARNING: Font 'Calibri-BoldItalic' (font name 'Calibri-BoldItalic', font style 'italic', font weight 'bold') doesn't exist. Replaced by 'C:\Users\IntlUser\.fontist\fonts\NotoSans-BoldItalic.ttf'.
WARNING: Font 'KozGoPr6N-Regular-90ms-RKSJ-H' (font name 'KozGoPr6N-Regular-90ms-RKSJ-H', font style 'normal', font weight 'normal') doesn't exist. Replaced by 'C:\Users\IntlUser\.fontist\fonts\NotoSans-Regular.ttf'.
WARNING: Font 'KozGoPr6N-Regular-90ms-RKSJ-H' (font name 'KozGoPr6N-Regular-90ms-RKSJ-H', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\IntlUser\.fontist\fonts\NotoSans-Bold.ttf'.
WARNING: Font 'KozGoPr6N-Regular-90ms-RKSJ-H' (font name 'KozGoPr6N-Regular-90ms-RKSJ-H', font style 'italic', font weight 'normal') doesn't exist. Replaced by 'C:\Users\IntlUser\.fontist\fonts\NotoSans-Italic.ttf'.
WARNING: Font 'KozGoPr6N-Regular-90ms-RKSJ-H' (font name 'KozGoPr6N-Regular-90ms-RKSJ-H', font style 'italic', font weight 'bold') doesn't exist. Replaced by 'C:\Users\IntlUser\.fontist\fonts\NotoSans-BoldItalic.ttf'.
WARNING: Font 'Meiryo-Bold' (font name 'Meiryo-Bold', font style 'normal', font weight 'bold') doesn't exist. Replaced by 'C:\Users\IntlUser\.fontist\fonts\NotoSans-Bold.ttf'.

but still there are messages from Apache FOP:

Font "Calibri-Italic,normal,400" not found. Substituting with "any,normal,400".
Font "Calibri-BoldItalic,normal,400" not found. Substituting with "any,normal,400".
Font "Arial,normal,400" not found. Substituting with "any,normal,400".
Font "Meiryo-Bold,normal,400" not found. Substituting with "any,normal,400".