diff options
author | Owen Taylor <otaylor@redhat.com> | 2005-03-05 19:09:00 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2005-03-05 19:09:00 +0000 |
commit | b7934ca5b93621b540c9b5e956dc35d4b0700e4f (patch) | |
tree | 84316614779cb99514290cac3e323e4c5ef20e3e /tools | |
parent | 320f8cd2773015af4d3d1d5fb035c2ab11d5c921 (diff) | |
download | pango-b7934ca5b93621b540c9b5e956dc35d4b0700e4f.tar.gz |
Add mising files
2005-03-04 Owen Taylor <otaylor@redhat.com>
Reduce non-shared data (#168899, inspired by patches
from Tommi Komulainen and Ross Burton)
* pango/pango-color.c pango/pango-color-table.h
tools/gen-color-table.pl: Redo storage of colors to
use offsets into a static string rather than embedded
strings. (Inspired by a patch from Tommi Komulainen,
#168899)
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/gen-color-table.pl | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tools/gen-color-table.pl b/tools/gen-color-table.pl new file mode 100755 index 00000000..e62994e1 --- /dev/null +++ b/tools/gen-color-table.pl @@ -0,0 +1,74 @@ +#!/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($_ = <IN>)) { + 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 <<EOT; +/* 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 <<EOT; +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"; |