public
Created

Generate line numbers to Sublime VintageLines plugin

  • Download Gist
generate.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<?php
// Set the content-type
header('Content-Type: image/png');
 
// Replace with your own font and font-size
$font = 'UbuntuMono-R.ttf';
$fontsize = 11;
 
// Create the numbers directory if it doesn't exist
if(!is_dir(dirname(__FILE__) . '/numbers/')) {
mkdir(dirname(__FILE__) . '/numbers/', 777);
}
 
for ($i = 0; $i <= 80; $i++) {
$text = ($i <= 9)? ' ' . $i : $i;
$im = imagecreatetruecolor(16, 16);
imagealphablending($im, true);
 
// Create some colors
$white = imagecolorallocatealpha($im, 255, 255, 255, 0);
$transp = imagecolorallocatealpha($im, 0, 0, 0, 127);
// $grey = imagecolorallocate($im, 128, 128, 128);
// $black = imagecolorallocate($im, 0, 0, 0);
 
imagefill($im, 0, 0, $transp);
imagesavealpha($im, true);
imagettftext($im, $fontsize, 0, 1, 11, $white, $font, $text);
 
$imagepath = 'numbers/' . $i . '.png';
imagepng($im, $imagepath);
readfile($imagepath);
imagedestroy($im);
}
?>

Example (using ubuntu mono):
Screenshot

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.