~ubuntu-branches/ubuntu/precise/vflib3/precise

« back to all changes in this revision

Viewing changes to src/mkmodelist.sh

  • Committer: Bazaar Package Importer
  • Author(s): Masayuki Hatta
  • Date: 2002-04-15 12:10:24 UTC
  • Revision ID: james.westby@ubuntu.com-20020415121024-cann32wucyfbq22f
Tags: upstream-3.6.12
ImportĀ upstreamĀ versionĀ 3.6.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
k_dev=$1
 
4
 
 
5
 
 
6
MODES_MF=`kpsewhich modes.mf`
 
7
 
 
8
if [ x-${MODES_MF} = x- ] 
 
9
then
 
10
  echo "Not found: modes.mf" >&2
 
11
  exit;
 
12
fi
 
13
 
 
14
if [ ! -f ${MODES_MF} ] 
 
15
then
 
16
  echo "Not found: modes.mf" >&2
 
17
  exit;
 
18
fi
 
19
 
 
20
 
 
21
 
 
22
cat ${MODES_MF} \
 
23
| awk -v DEVNAME=${k_dev} '
 
24
 
 
25
BEGIN {
 
26
  DEVDPI = "";
 
27
 
28
 
 
29
END {
 
30
  if (DEVDPI == ""){
 
31
    printf("-1\n");  # not found
 
32
    exit 1;
 
33
  }
 
34
  printf("%s\n", DEVDPI);
 
35
  exit 0;
 
36
 
37
 
 
38
# Line: e.g.,  mode_def ljfour =                       % 600dpi HP LaserJet 4
 
39
/^mode_def/ { 
 
40
  mode=$2; 
 
41
  ppi=-1; 
 
42
  ppiv=-1; 
 
43
  asp=1.0;
 
44
  i=index($0, "%");
 
45
  x=substr($0, i);
 
46
  desc=substr($0, i + match(x, "[a-zA-Z0-9]") - 1);
 
47
}
 
48
 
 
49
# Line: e.g.,     mode_param (pixels_per_inch, 600);
 
50
/^[ \t]*mode_param[ \t]*\([ \t]*pixels_per_inch, [ \t]*[0-9.]+\);/ {
 
51
  match($3, "[0-9.]*");
 
52
  ppi=substr($3, 1, RLENGTH);
 
53
  ppiv=-1; 
 
54
}
 
55
 
 
56
# Line: e.g.,     mode_param (aspect_ratio, 4/3);
 
57
# Currently, aspect ratio must be 1
 
58
/^[ \t]*mode_param[ \t]*\([ \t]*aspect_ratio[ \t]*,[ \t]*[0-9./]+[ \t]*);/ {
 
59
  i=match($0, ",[ \t]*");
 
60
  s0=i+RLENGTH;
 
61
  x=substr($0, s0);
 
62
  len=match(x, ")");
 
63
  asp=substr($0, s0, len-1);
 
64
  ppiv=asp*ppi;
 
65
  ppi=-1; ### ignore this entry.
 
66
}
 
67
 
 
68
# Line: e.g.,   mode_param (aspect_ratio, 180 / pixels_per_inch);
 
69
/^[ \t]*mode_param[ \t]*\([ \t]*aspect_ratio, [ \t]*.*\/[ \t]*pixels_per_inch)/ {
 
70
  i=match($0, ",[ \t]*[0-9.]");
 
71
  x=substr($0, i+RLENGTH-1);
 
72
  s0=i+RLENGTH-1;
 
73
  match(x, "[ \t]*/");
 
74
  ppiv=substr($0, s0, RSTART-1);
 
75
  asp=ppi/ppiv;
 
76
  ppi=-1; ### ignore this entry.
 
77
}
 
78
 
 
79
# Line: e.g., enddef;
 
80
/^enddef/ {
 
81
  if ((mode != "") && (ppi > 0)){
 
82
    if ((ppiv < 0) && (mode == DEVNAME)){
 
83
      DEVDPI=ppi;
 
84
    }
 
85
    mode=""; 
 
86
    ppi=-1; 
 
87
    ppiv=-1; 
 
88
    desc="";
 
89
  }
 
90
}  
 
91
'