PHP GD not rendering unicode fonts properly

前端 未结 2 559
傲寒
傲寒 2021-01-21 12:58

I am having problems in rendering unicode glyphs ( language : Malayalam, Tamil and Hindi) with PHP GD library. Is this something related to the rendering engine of GD library? A

相关标签:
2条回答
  • 2021-01-21 13:10

    First make sure your fonts contain the desired glyphs (system fonts such as Arial should). Then make sure you convert your parameters to unicode using utf8_decode() if neccessary.

    0 讨论(0)
  • 2021-01-21 13:29

    i have found one try this

    <?php
    //error_reporting(0);
    $text = ("Unreadable text");
    $font = "mangal.ttf";
    $fontSize = "10";
    $width = '600';
        $s = new CairoImageSurface(CairoFormat::ARGB32, $width, 21);
        $c = new CairoContext($s);
    
        /* Set the background*/
        $c->setSourceRGB(.1,149,.58);
        $c->paint();
    
        $c->setSourceRGB(.1,.1,.1);
    
        /* Make a Pango layout, set the font, then set the layout size */
        $l = new PangoLayout($c);
        $desc = new PangoFontDescription("mangal normal $fontSize");
        $l->setFontDescription($desc);
    
        /* Here, we use Pango markup to make part of the text bold */
        $l->setText($text);
    
        /* Draw the layout on the surface */
        $l->showLayout($c);
        $s->writeToPng("unicode.png");
        echo $img = "<img src=\"unicode.png\">";        
    ?> 
    
    0 讨论(0)
提交回复
热议问题