Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created November 3, 2011 09:27
Show Gist options
  • Select an option

  • Save junaidpv/1336126 to your computer and use it in GitHub Desktop.

Select an option

Save junaidpv/1336126 to your computer and use it in GitHub Desktop.
Malayalam text rendering using pango-cairo
<?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