//newSilAAA.bcpl
get "sil.defs"
let doMapping(obj,length) be
[
// used by Control Y Command for mapping of the extended fonts
// currently ttable is defined only for ChemTimes8
let font =(obj>>item.font)/2
let FontItem = FontOrientation!font
let ttable = FontItem & #177400
if ttable eq 0 then
[
obj>>item.string.length = length -1
return
]
let char = obj>>item.string.char↑length
let newchar = 0
newchar = selecton char into
[
case #041: 275b // $!: 275b
case #042: 264b // $": 264b
case #043: 354b // $#: 354b //added 12-17-80
case #044: 355b // $$: 355b //added 12-17-80
case #045: 373b // $%: 373b
case #046: 356b // $&: 356b //added 12-17-80
case #047: 140b // $': 140b
case #050: 300b // $(: 300b
case #051: 212b // $): 212b
case #052: 265b // $*: 265b
case #053: 274b // $+: 274b
case #054: 374b // $,: 374b
case #055: 277b // $-: 277b // changed from 337b to 277b 12-17-80
case #056: 236b // $.: 236b
case #057: 340b // $/: 340b
case #060: 232b // $0: 232b
case #061: 341b // $1: 341b
case #062: 342b // $2: 342b
case #063: 343b // $3: 343b
case #064: 344b // $4: 344b
case #065: 345b // $5: 345b
case #066: 346b // $6: 346b
case #067: 347b // $7: 347b
case #070: 375b // $8: 375b
case #071: 251b // $9: 251b
case #072: 350b // $:: 350b
case #073: 351b // $;: 351b
case #074: 333b // $<: 333b
case #075: 352b // $=: 352b //added 12-17-80
case #076: 334b // $>: 334b
case #077: 276b // $?: 276b
case #100: 353b // $@: 353b //added 12-17-80
case #141: 242b // $a: 242b
case #142: 267b // $b: 267b
case #143: 244b // $c: 244b
case #144: 270b // $d: 270b
case #145: 246b // $e: 246b
case #146: 220b // $f: 220b
case #147: 240b // $g: 240b
case #150: 241b // $h:241b
case #151: 223b // $i: 223b
case #152: 226b // $j: 226b
case #153: 336b // $k: 336b
case #154: 224b // $l: 224b
case #155: 234b // $m: 234b
case #156: 233b // $n: 233b
case #157: 245b // $o: 245b
case #160: 272b // $p: 272b
case #161: 221b // $q: 221b
case #162: 222b // $r: 222b
case #163: 266b // $s: 266b
case #165: 243b // $u: 243b
case #167: 247b // $w: 247b
case #170: 372b // $x: 372b
case #171: 255b // $y: 255b
case #172: 210b // $z: 210b
case #173: 250b // ${: 250b
case #175: 252b // $}: 252b
case #176: 260b // $~: 260b
case #101: 202b // $A: 202b
case #102: 0b // $B: 0b
case #103: 204b // $C: 204b
case #104: 271b // $D: 271b
case #105: 206b // $E: 206b
case #106: 263b // $F: 263b
case #107: 200b // $G: 200b
case #110: 201b // $H: 201b
case #111: 376b // $I: 376b
case #113: 335b // $K: 335b
case #114: 261b // $L: 261b
case #115: 231b // $M: 231b
case #116: 230b // $N: 230b
case #117: 205b // $O: 205b
case #120: 213b // $P: 213b
case #122: 262b // $R: 262b
case #123: 225b // $S: 225b
case #124: 237b // $T: 237b
case #125: 203b // $U: 203b
case #127: 207b // $W:207b
case #131: 214b // $Y: 214b
case #133: 254b // $[: 254b
case #134: 273b // $\: 273b
case #135: 253b // $]: 253b
case #136: 256b // $↑: 256b
case #137: 257b // $←: 257b
]
test newchar eq 0
ifso [ obj>>item.string.length = length -1 ]
ifnot [
// check character within range or well defined
let font =(obj>>item.font)/2
let fontptr = FontVec!font
let width = getStringWidth(fontptr,newchar)
test width gr 0 & width le 100
ifso [ obj>>item.string.char↑length = newchar ]
ifnot [ obj>>item.string.length = length -1 ]
]
ReWriteObj(obj)
]