0

According to How to implement custom fonts in TCPDF I import my custom font to TCPDF, but when I use it I see this result enter image description here.

this is part of my code

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);


// set some language dependent data:
$lg = Array();
$lg['a_meta_charset'] = 'UTF-8';
//$lg['a_meta_dir'] = 'rtl';
$lg['a_meta_language'] = 'fa';
$lg['w_page'] = 'page';

// set some language-dependent strings (optional)
$pdf->setLanguageArray($lg);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// ---------------------------------------------------------
// add a page
$pdf->AddPage();
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = TCPDF_FONTS::addTTFfont(K_PATH_FONTS.'BYekan.ttf', 'TrueTypeUnicode', '', 14);
//ym($fontname);
//die();

//$this->pdf->SetFont('byekan');
$pdf->SetFont($fontname, '', 8, '', true);

my text language is Persian and also I try some another fonts but result is some thing like this, some character not show correctly.also I try http://fonts.snm-portal.com/ but results was the same .

Community
  • 1
  • 1
Yuseferi
  • 7,931
  • 11
  • 67
  • 103
  • The first hit on google for me, for ["TCPDF use persian font"](https://www.google.com/search?q=TCPDF+use+persian+font&ie=utf-8&oe=utf-8), is the official example http://www.tcpdf.org/examples/example_018.phps -- have you tried that? Did it not work? – Mike 'Pomax' Kamermans Oct 10 '15 at 17:23
  • @Mike'Pomax'Kamermans look at the code "$pdf->SetFont('dejavusans', '', 12);" it is only use one font, I want to use another font , – Yuseferi Oct 10 '15 at 17:39
  • right, so: did *this example* work for you? And don't answer that in the comments, *put that in your post*. Put as much detail in your post as you can: what did you try, what had you done when it stopped working, what do you suspect is wrong and what did you try to see if you were right about that? If things work fine with DejaVu Sans, then it should work with other OpenType fonts. And if it doesn't, you might have a broken font. Does it work with your font but not once you change the text? [Tried other persian fonts](http://mces.blogspot.ca/2007/11/most-beautiful-persian-opentype-font.html)? – Mike 'Pomax' Kamermans Oct 10 '15 at 17:54
  • @Mike'Pomax'Kamermans , yes it worked correctly, but I need use another font in my project – Yuseferi Oct 11 '15 at 05:47
  • that's why I also asked about fonts that are not just the one you are trying right now. If the example works fine with DejaVu Sans, but it doesn't work with your font, then your font might just be broken: Tty some other fonts with Persian support as well, and if those all work, while your font doesn't, then the font you are trying to use is either not a proper font, or it's broken in some way, and you will want to find a new font with the look you want, and use that instead. – Mike 'Pomax' Kamermans Oct 11 '15 at 16:47

0 Answers0