+#---------- pixmap database read and write ----------
+
+set database_magic/pixmap {# ypp-sc-tools pctb pixmaps v1}
+
+proc read_database_header/pixmap {f} { }
+proc read_database_entry/pixmap {f def} {
+ global database
+
+ set im ""
+
+ set p3 [db_getsl $f]; append im $p3 "\n"
+ if {[string compare $p3 P3]} { error "$p3 ?" }
+
+ set wh [db_getsl $f]; append im $wh "\n"; manyset $wh w h
+ set depth [db_getsl $f]; append im $depth "\n"
+
+ for {set y 0} {$y < $h} {incr y} {
+ set line [db_getsl $f]; append im $line "\n"
+ }
+ set database($im) $def
+}
+proc write_database_header/pixmap {f} { puts $f "" }
+proc format_database_entry/pixmap {im def} {
+ return "$def\n$im"
+}
+
+#---------- character database read and write ----------
+
+# OUT OF DATE
+# database format:
+# series of glyphs:
+# <context> <ncharacters> <hex>...
+# width
+# <hex-bitmap>
+
+# $database($context 0x<bits> 0x<bits>...) = $hex
+
+set database_magic/char {# ypp-sc-tools pctb font v1}
+
+proc read_database_header/char {f} {
+ global rows
+ if {([db_getsl $f])+0 != $rows} { error "wrong h ?" }
+}
+proc read_database_entry/char {f context} {
+ global database
+ set bm $context
+ set strq [db_getsl $f]
+ while 1 {
+ set l [db_getsl $f]
+ if {![string length $l]} break
+ lappend bm [format %x 0x$l]
+ }
+ set database($bm) $strq
+}
+
+proc write_database_header/char {f} {
+ puts $f "$rows\n"
+}
+proc format_database_entry/char {bm strq} {
+ global database rows
+ set o "[lindex $bm 0]\n$strq\n"
+ foreach x [lrange $bm 1 end] { append o "$x\n" }
+ return $o
+}
+