mPDF Open Sans font cannot render some german letters - php

I am trying to generate PDF with the german word "möchte" (the letter ö is the issue here)..
using the font that I added(Open Sans) in /ttfonts folder and set it on config_fonts.php..
"open_sans" => array(
'B' => "OpenSans-Bold.ttf",
'BI' => "OpenSans-BoldItalic.ttf",
'EB' => "OpenSans-ExtraBold.ttf",
'EBI' => "OpenSans-ExtraBoldItalic.ttf",
'I' => "OpenSans-Italic.ttf",
'L' => "OpenSans-Light.ttf",
'LI' => "OpenSans-LightItalic.ttf",
'R' => "OpenSans-Regular.ttf",
'SB' => "OpenSans-Semibold.ttf",
'SBI' => "OpenSans-SemiboldItalic.ttf",
'useOTL' => 0xFF,
'useKashida' => 75,
)
I also read https://mpdf.github.io/fonts-languages/fonts-in-mpdf-6-x.html and tried modifying config_lang2fonts.php .. I even set it everything to open_sans
$unifont = "open_sans";
return array($coreSuitable ,$unifont);
PS: The font file Open Sans I downloaded is already no subsetting.
But the output is still not like as I expected, it shows:
PHP
$mpdf = new mPDF('','A4','','open_sans' , 30 , 12 , 12 , 12 , 10 , 10);
Mark Up
#font-face{
font-family:open_sans;
src: url('mypath/mpdf60/ttfonts/OpenSans-Regular.ttf');
}
I tried using the default fonts of mPDF like dejavusans, It works perfectly. But what I need is Open Sans. Did I miss a configuration in mPDF or what? What is the problem?

The fact that you see a regular o followed by an unknown character strongly suggests the second character is a single non-spacing diaeresis, not available in the font you are using.
Checking the character sets of DejaVu Sans and Open Sans proves my hunch is right. DejaVu Sans does contain a 'COMBINING DIAERESIS' U+0308: ¨. OpenSans does not.
Use Unicode Normalization on your input text to replace the sequence o+¨ with its composite character ö U+00F6. The same goes for ä U+00E4 and ü O+00FC.

Related

Which unicode font supports all Indian fonts in mPDF library?

I am trying to write some Indian dialect texts in my pdf, using mPDF library. I've tried using these fonts:
'fontdata' => [
"sakalbharati" => [
'R' => "Sakal Bharati.ttf",
'useOTL' => 0xFF,
],
"mangal" => [
'R' => "Mangal.ttf",
'useOTL' => 0xFF,
],
"freesans" => [
'R' => "FreeSans.ttf",
'B' => "FreeSansBold.ttf",
'I' => "FreeSansOblique.ttf",
'BI' => "FreeSansBoldOblique.ttf",
'useOTL' => 0xFF,
],
]
Most of these fonts work only when rendering Hindi characters (there are some grammatical mistakes when rendering complex Hindi words though), but when I try to render other dialect characters such as Bengali, Assamese, etc., they render as squares in my pdf:
Please see this image
How do I fix this issue? Is there a font which will support all Indian unicode font characters?

arabic fonts in Laravel pdf file issue

For generating pdf files in my Laravel app, I used niklasravnsborg/laravel-pdf package that it supports arabic language, No I want add custom fonts, I followed the documentation but it's not working, the text was showin with the default font of the package (I don't know what is..)
this is config/pdf.php :
...
'font_path' => base_path('/resources/fonts/'),
'font_data' => [
'NotoKufiArabic' => [
'R' => 'NotoKufiArabic-VariableFont_wght.ttf', // regular font // I tried also NotoKufiArabic-Regular
'B' => 'NotoKufiArabic-Bold.ttf', // optional: bold font
'I' => 'NotoKufiArabic-Medium.ttf', // optional: italic font
'BI' => 'NotoKufiArabic-SemiBold.ttf' ,// optional: bold-italic font
'useOTL' => 0xFF, // required for complicated langs like Persian, Arabic and Chinese
'useKashida' => 75, // required for complicated langs like Persian, Arabic and Chinese
]
// ...add as many as you want.
]
css code in blade :
body {
font-family: "NotoKufiArabic", sans-serif;
}
and I added .ttf files in fonts directory like this

HTML lang attribute does not work in mPDF

I'm currently working on making the correct version of language dependent glyphs show up in their respective PDF files... From what I understand after reading through the mPDF documentation is that all I need to do is to set the the html lang value like below and to set autoScriptToLang and autoLangToFont to true
Example html where I want the Japanese version of the characters:
<html lang="ja">
<body>
Sample language-dependent glyphs: 直今令角雇
</body>
</html>
And yet it doesn't seem to reflect on the PDF file that is generated.
Here's the settings I'm passing over to Mpdf\Mpdf
$settings = [
'autoLangToFont' => true,
'autoScriptToLang' => true,
'format' => 'A4',
'margin_left' => 10,
'margin_right' => 10,
'margin_top' => 10,
'margin_bottom' => 20,
'margin_header' => 0,
'margin_footer' => 5,
'tempDir' => '/tmp/',
'default_font' => 'frutiger'
];
I tried displaying the HTML I'm passing over to mPDF and it works there, so I believe my issue is that I'm missing a setting to allow mPDF to display the Japanese versions of those characters.

Hindi font from google font not working in tinymce editor integrated in cakephp with elfinder

private function preset($name){
// Full Feature
if($name == 'full'){
return array(
'selector' => 'textarea',
'theme' => 'modern',
'plugins' => 'advlist,autolink,lists,link,image,charmap,print,preview,hr,anchor,pagebreak,
searchreplace,wordcount,visualblocks,visualchars,code,fullscreen,
insertdatetime,media,nonbreaking,save,table,contextmenu,directionality,
emoticons,template,paste,textcolor,youtube,colorpicker',
'relative_urls' => false,
'browser_spellcheck' => true,
'toolbar1' => 'insertfile, undo, redo, |, styleselect, fontselect, |, fontsizeselect, |, bold, italic, |, alignleft, aligncenter, alignright, alignjustify, |, bullist, numlist, outdent, indent',
'toolbar2' => 'link, image, media, youtube, emoticons, |, colorpicker, forecolor, backcolor, |, preview, print, code',
'language' => 'hi_IN',
'content_css' => ['http://englishcosmos.in/exam/hindifont.css'],
'font_formats' => 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Poppins= poppins,sans-serif;Indie Flower=indie flower, cursive;Hind= hind,sans-serif',
'image_advtab' => true,
'file_browser_callback' => 'elFinderBrowser'
);
}
Here code has option to set font dropdown, fontsize. Here all fonts from google working but Hindi font not working.
Is there any solution that I can use hindi font from google or directly.
Font I want to use here is : Kurti Dev
Try to expand it. Look at the option content_css of TinyMCE (link). Yes, U use it ( http://englishcosmos.in/exam/hindifont.css => 404 ). In that file U have to input something like :
#font-face {
font-family: "Kruti Dev";
src: url("../path_to_ttf-file/kruti.ttf");
}
body{
font-family:'Kruti Dev', Verdana;
...
}

mPDF: When I add font into .ttfonts folder then config them. mPDF is display strange text

I have this problem. I Don't know how to explain.
When I add thai font (TH sarabun) into .ttfonts folder.
and config in config_fonts.php file
follow this:
"sarabun" => array(/* Thai */
'R' => "THSarabun.ttf",
'B' => "THSarabun_Bold.ttf",
'I' => "THSarabun_Italic.ttf",
'BI' => "THSarabun_Bold_Italic.ttf",
'useOTL' => 0xFF,
),
//similar garuda font'
//"garuda" => array(/* Thai */
// 'R' => "Garuda.ttf",
// 'B' => "Garuda-Bold.ttf",
// 'I' => "Garuda-Oblique.ttf",
// 'BI' => "Garuda-BoldOblique.ttf",
// 'useOTL' => 0xFF,
// ),
Then I coding mpdf follow this (I assume my code isn't error.)
$this->pdf = new mPDF();
$html = $this->load->view('.........');
$this->pdf->writeHTML($html);
$this->pdf->Output();
Then mPDF displays the square text and text.
follow this:
The square text is wrong or bad reading
I want to remove square text or don't want to show or disappear.
How should I solve these problems?
P.S.
If I remove 'useOTL' => 0xFF is correct display.But Word wrapping is bad.
It's more than space when I used justify text. or some line is short. Some line is long.
example:

Categories