Pango is a library for layout and rendering of text, with an emphasis on internationalization. Pang

源代码在线查看: gen-color-table.pl

软件大小: 2016 K
上传用户: aoneko2009
关键词: internationalization rendering emphasis library
下载地址: 免注册下载 普通下载 VIP

相关代码

				#!/usr/bin/perl -w								if (@ARGV != 1) {				    die "Usage: gen-colors.pl rgb.txt > pango-color-table.h\n";				}								open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n";								@colors = ();				while (defined($_ = )) {				    next if /^!/;				    if (!/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*\S)\s+$/) {					die "Cannot parse line $_";				    }								    push @colors, [$1, $2, $3, $4];				}								@colors = sort { lc($a->[3]) cmp lc($b->[3]) } @colors;								$offset = 0;								$date = gmtime;								print 				/* pango-color-table.h: Generated by gen-color-table.pl from rgb.txt				 *				 *  Date: $date				 *				 * Do not edit.   				 */				static const char color_names[] =				EOT								for $color (@colors) {				    $name = $color->[3];								    if ($offset != 0) {					print qq(\n);				    }				    print qq(  "$name\\0");								    $color->[4] = $offset;				    $offset += length($name) + 1;				}								print ";\n\n";								print 				typedef struct {				    guint16 name_offset;				    guchar red;				    guchar green;				    guchar blue;				} ColorEntry;								static const ColorEntry color_entries[] = {				EOT								$i = 0;				for $color (@colors) {				    $red = $color->[0];				    $green = $color->[1];				    $blue = $color->[2];				    $offset = $color->[4];								    if ($i != 0) {					print ",\n";				    }				    print "  { $offset, $red, $green, $blue }";				    $i++;				}								print "\n};\n";							

相关资源