Created
November 3, 2011 09:27
-
-
Save junaidpv/1336126 to your computer and use it in GitHub Desktop.
Malayalam text rendering using pango-cairo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //error_reporting(0); | |
| $text = ("കണ്ണൂർ, പപ്പൻ, പൂച്ച"); | |
| $fontSize = "30"; | |
| $width = '300'; | |
| $s = new CairoImageSurface(CairoFormat::ARGB32, $width, 60); | |
| $c = new CairoContext($s); | |
| /* Set the background*/ | |
| $c->setSourceRGB(1,1,.27); | |
| $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("meera 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\">"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment