1*0Sstevel@tonic-gate#! /bin/awk -f 2*0Sstevel@tonic-gate# 3*0Sstevel@tonic-gate# CDDL HEADER START 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*0Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*0Sstevel@tonic-gate# with the License. 9*0Sstevel@tonic-gate# 10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*0Sstevel@tonic-gate# See the License for the specific language governing permissions 13*0Sstevel@tonic-gate# and limitations under the License. 14*0Sstevel@tonic-gate# 15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*0Sstevel@tonic-gate# 21*0Sstevel@tonic-gate# CDDL HEADER END 22*0Sstevel@tonic-gate# 23*0Sstevel@tonic-gate# 24*0Sstevel@tonic-gate# Copyright (c) 1998-1999 by Sun Microsystems, Inc. 25*0Sstevel@tonic-gate# All rights reserved. 26*0Sstevel@tonic-gate# 27*0Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate# 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gateBEGIN { 31*0Sstevel@tonic-gate pats["0"]=" "; 32*0Sstevel@tonic-gate pats["1"]=" X"; 33*0Sstevel@tonic-gate pats["2"]=" X "; 34*0Sstevel@tonic-gate pats["3"]=" XX"; 35*0Sstevel@tonic-gate pats["4"]=" X "; 36*0Sstevel@tonic-gate pats["5"]=" X X"; 37*0Sstevel@tonic-gate pats["6"]=" XX "; 38*0Sstevel@tonic-gate pats["7"]=" XXX"; 39*0Sstevel@tonic-gate pats["8"]="X "; 40*0Sstevel@tonic-gate pats["9"]="X X"; 41*0Sstevel@tonic-gate pats["a"]="X X "; pats["A"] = pats["a"]; 42*0Sstevel@tonic-gate pats["b"]="X XX"; pats["B"] = pats["b"]; 43*0Sstevel@tonic-gate pats["c"]="XX "; pats["C"] = pats["c"]; 44*0Sstevel@tonic-gate pats["d"]="XX X"; pats["D"] = pats["d"]; 45*0Sstevel@tonic-gate pats["e"]="XXX "; pats["E"] = pats["e"]; 46*0Sstevel@tonic-gate pats["f"]="XXXX"; pats["F"] = pats["f"]; 47*0Sstevel@tonic-gate} 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate$1=="ENDCHAR" { 50*0Sstevel@tonic-gate in_bitmap = 0; 51*0Sstevel@tonic-gate next; 52*0Sstevel@tonic-gate} 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gatein_bitmap != 0 { 55*0Sstevel@tonic-gate if (ignoring) next; 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate for (c = 0; c < byteswide; c++) 58*0Sstevel@tonic-gate printf "0x%s, ", substr($0,c*2+1,2); 59*0Sstevel@tonic-gate s=""; 60*0Sstevel@tonic-gate for (c = 0; c < byteswide*2; c++) 61*0Sstevel@tonic-gate s = s pats[substr($0,c+1,1)]; 62*0Sstevel@tonic-gate s = substr(s, 1, bitswide); 63*0Sstevel@tonic-gate printf "/* %s */\n", s; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate offset += length($0)/2; 66*0Sstevel@tonic-gate next; 67*0Sstevel@tonic-gate} 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate$1=="STARTFONT" { 70*0Sstevel@tonic-gate if ($2 != "2.1") { 71*0Sstevel@tonic-gate printf "Unknown BDF version number %s!\n", $2; 72*0Sstevel@tonic-gate exit 1; 73*0Sstevel@tonic-gate } 74*0Sstevel@tonic-gate in_bitmap = 0; 75*0Sstevel@tonic-gate ignoring = 1; 76*0Sstevel@tonic-gate first = 1; 77*0Sstevel@tonic-gate offset = 0; 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate for (i = 0; i < 256; i++) 80*0Sstevel@tonic-gate encoding[i] = -1; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate next; 83*0Sstevel@tonic-gate} 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate$1=="COMMENT" { 86*0Sstevel@tonic-gate if (NF > 1) { 87*0Sstevel@tonic-gate printf "/*"; 88*0Sstevel@tonic-gate for (i = 2; i < NF; i++) 89*0Sstevel@tonic-gate printf " %s",$i; 90*0Sstevel@tonic-gate printf " */"; 91*0Sstevel@tonic-gate } 92*0Sstevel@tonic-gate printf "\n"; 93*0Sstevel@tonic-gate next; 94*0Sstevel@tonic-gate} 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate$1=="FONT" { 97*0Sstevel@tonic-gate printf "/* %s */\n", $0; 98*0Sstevel@tonic-gate next; 99*0Sstevel@tonic-gate} 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate$1=="SIZE" { 102*0Sstevel@tonic-gate next; 103*0Sstevel@tonic-gate} 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate$1=="FONTBOUNDINGBOX" { 106*0Sstevel@tonic-gate rows = $3; 107*0Sstevel@tonic-gate byteswide = int(($2 + 7)/8); 108*0Sstevel@tonic-gate bitswide = $2; 109*0Sstevel@tonic-gate next; 110*0Sstevel@tonic-gate} 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate$1=="STARTPROPERTIES" { 113*0Sstevel@tonic-gate next; 114*0Sstevel@tonic-gate} 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate$1=="FONTNAME_REGISTRY" { 117*0Sstevel@tonic-gate next; 118*0Sstevel@tonic-gate} 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate$1=="FOUNDRY" { 121*0Sstevel@tonic-gate next; 122*0Sstevel@tonic-gate} 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate$1=="FAMILY_NAME" { 125*0Sstevel@tonic-gate next; 126*0Sstevel@tonic-gate} 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate$1=="WEIGHT_NAME" { 129*0Sstevel@tonic-gate next; 130*0Sstevel@tonic-gate} 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate$1=="SLANT" { 133*0Sstevel@tonic-gate next; 134*0Sstevel@tonic-gate} 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate$1=="SETWIDTH_NAME" { 137*0Sstevel@tonic-gate next; 138*0Sstevel@tonic-gate} 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate$1=="ADD_STYLE_NAME" { 141*0Sstevel@tonic-gate next; 142*0Sstevel@tonic-gate} 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate$1=="PIXEL_SIZE" { 145*0Sstevel@tonic-gate next; 146*0Sstevel@tonic-gate} 147*0Sstevel@tonic-gate 148*0Sstevel@tonic-gate$1=="POINT_SIZE" { 149*0Sstevel@tonic-gate next; 150*0Sstevel@tonic-gate} 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate$1=="RESOLUTION_X" { 153*0Sstevel@tonic-gate next; 154*0Sstevel@tonic-gate} 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate$1=="RESOLUTION_Y" { 157*0Sstevel@tonic-gate next; 158*0Sstevel@tonic-gate} 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate$1=="SPACING" { 162*0Sstevel@tonic-gate if ($2 != "\"C\"") printf "Unsupported format %s!\n",$2; 163*0Sstevel@tonic-gate next; 164*0Sstevel@tonic-gate} 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate$1=="AVERAGE_WIDTH" { 167*0Sstevel@tonic-gate next; 168*0Sstevel@tonic-gate} 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate$1=="CHARSET_REGISTRY" { 171*0Sstevel@tonic-gate next; 172*0Sstevel@tonic-gate} 173*0Sstevel@tonic-gate 174*0Sstevel@tonic-gate$1=="CHARSET_ENCODING" { 175*0Sstevel@tonic-gate next; 176*0Sstevel@tonic-gate} 177*0Sstevel@tonic-gate 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate$1=="DEFAULT_CHAR" { 180*0Sstevel@tonic-gate default_char = $2; 181*0Sstevel@tonic-gate next; 182*0Sstevel@tonic-gate} 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate$1=="FONT_DESCENT" { 185*0Sstevel@tonic-gate next; 186*0Sstevel@tonic-gate} 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate$1=="FONT_ASCENT" { 189*0Sstevel@tonic-gate next; 190*0Sstevel@tonic-gate} 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gate$1=="COPYRIGHT" { 194*0Sstevel@tonic-gate printf "/* Copyright notice from .bdf file: */\n"; 195*0Sstevel@tonic-gate printf "/* %s */\n", $0; 196*0Sstevel@tonic-gate next; 197*0Sstevel@tonic-gate} 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate$1=="ENDPROPERTIES" { 200*0Sstevel@tonic-gate next; 201*0Sstevel@tonic-gate} 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate$1=="CHARS" { 204*0Sstevel@tonic-gate next; 205*0Sstevel@tonic-gate} 206*0Sstevel@tonic-gate 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate$1=="STARTCHAR" { 209*0Sstevel@tonic-gate if (first) { 210*0Sstevel@tonic-gate printf "unsigned char FONTDATA[] = {\n"; 211*0Sstevel@tonic-gate first = 0; 212*0Sstevel@tonic-gate } 213*0Sstevel@tonic-gate ignoring = 1; 214*0Sstevel@tonic-gate row = 0; 215*0Sstevel@tonic-gate next; 216*0Sstevel@tonic-gate} 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate$1=="ENCODING" { 219*0Sstevel@tonic-gate encoding[$2] = offset; 220*0Sstevel@tonic-gate ignoring = 0; 221*0Sstevel@tonic-gate got[$2] = 1; 222*0Sstevel@tonic-gate printf "\n"; 223*0Sstevel@tonic-gate if ($2 >= 32 && $2 < 127) printf "/* '%c' */\n", $2; 224*0Sstevel@tonic-gate else printf "/* 0x%2.2x */\n", $2; 225*0Sstevel@tonic-gate next; 226*0Sstevel@tonic-gate} 227*0Sstevel@tonic-gate 228*0Sstevel@tonic-gate$1=="SWIDTH" { 229*0Sstevel@tonic-gate next; 230*0Sstevel@tonic-gate} 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate$1=="DWIDTH" { 233*0Sstevel@tonic-gate next; 234*0Sstevel@tonic-gate} 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate$1=="BBX" { 237*0Sstevel@tonic-gate next; 238*0Sstevel@tonic-gate} 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate$1=="BITMAP" { 241*0Sstevel@tonic-gate in_bitmap = 1; 242*0Sstevel@tonic-gate next; 243*0Sstevel@tonic-gate} 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate$1=="ENDFONT" { 246*0Sstevel@tonic-gate printf "};\n"; 247*0Sstevel@tonic-gate printf "\n"; 248*0Sstevel@tonic-gate printf "unsigned char *ENCODINGS[256] = {\n"; 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate for (i = 0; i < 256; i++) { 251*0Sstevel@tonic-gate if (encoding[i] == -1) encoding[i] = encoding[default_char]; 252*0Sstevel@tonic-gate printf "\tFONTDATA+%d,\n", encoding[i]; 253*0Sstevel@tonic-gate } 254*0Sstevel@tonic-gate printf "};\n"; 255*0Sstevel@tonic-gate next; 256*0Sstevel@tonic-gate} 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gate{ 259*0Sstevel@tonic-gate printf "?!? %s\n", $0; 260*0Sstevel@tonic-gate} 261