| 1 |
/* interp.c -- Instruction Interpreter |
| 2 |
* Copyright (C) 1996 Li-Da Lho, All right reserved. |
| 3 |
*/ |
| 4 |
#include "config.h" |
| 5 |
#include "ttf.h" |
| 6 |
#include "ttfutil.h" |
| 7 |
|
| 8 |
/* $Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ |
| 9 |
|
| 10 |
/* A bit about error checking: The execution of a TrueType instruction is |
| 11 |
* "atomic" which means that we don't process the error until a single |
| 12 |
* instruction is fully decoded and executed */ |
| 13 |
|
| 14 |
/* Pushing data onto the interpreter stack */ |
| 15 |
|
| 16 |
void Interp_NPUSHB (VirtualMachine *vm) |
| 17 |
{ |
| 18 |
BYTE i,n; |
| 19 |
ULONG l; |
| 20 |
|
| 21 |
n = GetBYTE(vm); |
| 22 |
|
| 23 |
for (i=1;i<=n;i++) |
| 24 |
{ |
| 25 |
/* unsigned extension to four bytes */ |
| 26 |
l = (ULONG) GetBYTE(vm); |
| 27 |
Push(vm, l); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
void Interp_NPUSHW(VirtualMachine *vm) |
| 32 |
{ |
| 33 |
BYTE i,n; |
| 34 |
LONG l; |
| 35 |
|
| 36 |
n = GetBYTE(vm); |
| 37 |
|
| 38 |
for (i=1;i<=n;i++) |
| 39 |
{ |
| 40 |
/* signed extension to four bytes */ |
| 41 |
l = (LONG) GetSHORT(vm); |
| 42 |
Push(vm, l); |
| 43 |
} |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
void Interp_PUSHB(VirtualMachine *vm) |
| 48 |
{ |
| 49 |
BYTE opcode,n,i; |
| 50 |
ULONG l; |
| 51 |
|
| 52 |
opcode = (vm->iStream)[vm->ip]; |
| 53 |
n = opcode - 0xB0; |
| 54 |
|
| 55 |
for (i=0;i<=n;i++) |
| 56 |
{ |
| 57 |
l = (ULONG) GetBYTE(vm); |
| 58 |
Push(vm, l); |
| 59 |
} |
| 60 |
} |
| 61 |
/* PUSHW[abc] Push Words |
| 62 |
* Code Range 0xB8 - 0x0BF |
| 63 |
* From IS w0,w1,...wn |
| 64 |
* Pushes w0,w1,...wn */ |
| 65 |
void Interp_PUSHW(VirtualMachine *vm) |
| 66 |
{ |
| 67 |
BYTE opcode,n,i; |
| 68 |
LONG l; |
| 69 |
|
| 70 |
opcode = (vm->iStream)[vm->ip]; |
| 71 |
n = opcode - 0xB8; |
| 72 |
|
| 73 |
for (i=0;i<=n;i++) |
| 74 |
{ |
| 75 |
l = (LONG) GetSHORT(vm); |
| 76 |
Push(vm,l); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
/* Managing the Storage Area */ |
| 81 |
|
| 82 |
/* RS[] Read Store |
| 83 |
* Code Range 0x43 |
| 84 |
* Pops location: Storage Area location (ULONG) |
| 85 |
* Pushes value: Storage Area value (ULONG) |
| 86 |
* Gets Storage Area value */ |
| 87 |
void Interp_RS(VirtualMachine *vm) |
| 88 |
{ |
| 89 |
ULONG location,value; |
| 90 |
|
| 91 |
location = Pop(vm); |
| 92 |
value = (vm->StorageArea)[location]; |
| 93 |
Push(vm,value); |
| 94 |
} |
| 95 |
/* WS[] Write Store |
| 96 |
* Code Range 0x42 |
| 97 |
* Pops value: Storage Area value (ULONG) |
| 98 |
* location: Storage Area location (ULONG) |
| 99 |
* Pushes - |
| 100 |
* Sets Storage Area */ |
| 101 |
void Interp_WS(VirtualMachine *vm) |
| 102 |
{ |
| 103 |
ULONG location,value; |
| 104 |
|
| 105 |
value = Pop(vm); |
| 106 |
location = Pop(vm); |
| 107 |
(vm->StorageArea)[location] = value; |
| 108 |
} |
| 109 |
|
| 110 |
/* Managing the Control Value Table */ |
| 111 |
|
| 112 |
/* WCVTP[] Write control Value Table in Pixel units |
| 113 |
* Code Range 0x44 |
| 114 |
* Pops value: number in pixels (F26Dot6) |
| 115 |
* location: Control Value Table location (ULONG) |
| 116 |
* Pushes - |
| 117 |
* Sets Control Value Table entry */ |
| 118 |
void Interp_WCVTP(VirtualMachine *vm) |
| 119 |
{ |
| 120 |
F26Dot6 value; |
| 121 |
ULONG location; |
| 122 |
|
| 123 |
value = Pop(vm); |
| 124 |
location = Pop(vm); |
| 125 |
|
| 126 |
(vm->cvt)[location] = value; |
| 127 |
} |
| 128 |
/* WCVTF[] Write Control Value Table in FUnits |
| 129 |
* Code Range 0x70 |
| 130 |
* Pops value: number in FUnits (ULONG) (LONG actually,i think) |
| 131 |
* location: Control Value (ULONG) |
| 132 |
* Pushes - |
| 133 |
* Sets Control Value Table entry |
| 134 |
*/ |
| 135 |
void Interp_WCVTF(VirtualMachine *vm) |
| 136 |
{ |
| 137 |
ULONG location; |
| 138 |
LONG value; |
| 139 |
|
| 140 |
value = Pop(vm); |
| 141 |
location = Pop(vm); |
| 142 |
|
| 143 |
value = ScaleToPoints(vm,value); |
| 144 |
(vm->cvt)[location] = value; |
| 145 |
} |
| 146 |
/* RCVT[] Read Control Value Table |
| 147 |
* Code Range 0x45 |
| 148 |
* Pops location: CVT entry number (ULONG) |
| 149 |
* Pushes value: CVT value (F26Dot6) |
| 150 |
* Gets Control Value Table entry |
| 151 |
*/ |
| 152 |
void Interp_RCVT(VirtualMachine *vm) |
| 153 |
{ |
| 154 |
ULONG location; |
| 155 |
F26Dot6 value; |
| 156 |
|
| 157 |
location = Pop(vm); |
| 158 |
value = (vm->cvt)[location]; |
| 159 |
Push(vm,value); |
| 160 |
} |
| 161 |
|
| 162 |
/* Managing Graphics State */ |
| 163 |
|
| 164 |
/* SVTCA[a] Set freedom and projection vector to Coordinate Axia |
| 165 |
* Code Range 0x00 - 0x01 |
| 166 |
* a 0: set to y axis |
| 167 |
* 1: set to x axis |
| 168 |
* Pops - |
| 169 |
* Pushes - |
| 170 |
* Sets projection_vector |
| 171 |
* freedom_vector |
| 172 |
*/ |
| 173 |
void Interp_SVTCA(VirtualMachine *vm) |
| 174 |
{ |
| 175 |
BYTE opcode; |
| 176 |
TTFUnitVector vect; |
| 177 |
|
| 178 |
opcode = (vm->iStream)[vm->ip]; |
| 179 |
switch (opcode) |
| 180 |
{ |
| 181 |
case 0x00: |
| 182 |
vect.x = 0; |
| 183 |
vect.y = F2Dot14_ONE; |
| 184 |
break; |
| 185 |
case 0x01: |
| 186 |
vect.x = F2Dot14_ONE; |
| 187 |
vect.y = 0; |
| 188 |
break; |
| 189 |
} |
| 190 |
vm->gstate.projection_vector = vm->gstate.freedom_vector = vect; |
| 191 |
} |
| 192 |
/* SPVCA[a] Set projection vector to coordinate axis |
| 193 |
* Code Range 0x02 - 0x03 |
| 194 |
* a 0: set to y axis |
| 195 |
* 1: set to x axis |
| 196 |
* Pops - |
| 197 |
* Pushes - |
| 198 |
* Sets projection vector |
| 199 |
*/ |
| 200 |
void Interp_SPVTCA(VirtualMachine *vm) |
| 201 |
{ |
| 202 |
BYTE opcode; |
| 203 |
TTFUnitVector vect; |
| 204 |
|
| 205 |
opcode = (vm->iStream)[vm->ip]; |
| 206 |
switch (opcode) |
| 207 |
{ |
| 208 |
case 0x02: |
| 209 |
vect.x = 0; |
| 210 |
vect.y = F2Dot14_ONE; |
| 211 |
break; |
| 212 |
case 0x03: |
| 213 |
vect.x = F2Dot14_ONE; |
| 214 |
vect.y = 0; |
| 215 |
break; |
| 216 |
} |
| 217 |
vm->gstate.projection_vector = vect; |
| 218 |
} |
| 219 |
/* SFVTCA[a] Set freedom vector to coordinate axis |
| 220 |
* Code Range 0x04 - 0x05 |
| 221 |
* a 0: set to y axis |
| 222 |
* 1: set to x axis |
| 223 |
* Pops - |
| 224 |
* Pushes - |
| 225 |
* Sets freedom vector |
| 226 |
*/ |
| 227 |
void Interp_SFVTCA(VirtualMachine *vm) |
| 228 |
{ |
| 229 |
BYTE opcode; |
| 230 |
TTFUnitVector vect; |
| 231 |
|
| 232 |
opcode = (vm->iStream)[vm->ip]; |
| 233 |
switch (opcode) |
| 234 |
{ |
| 235 |
case 0x04: |
| 236 |
vect.x = 0; |
| 237 |
vect.y = F2Dot14_ONE; |
| 238 |
break; |
| 239 |
case 0x05: |
| 240 |
vect.x = F2Dot14_ONE; |
| 241 |
vect.y = 0; |
| 242 |
break; |
| 243 |
} |
| 244 |
vm->gstate.freedom_vector = vect; |
| 245 |
} |
| 246 |
/* SPVTL[a] Set projection vector to line |
| 247 |
* Code Range 0x06 - 0x07 |
| 248 |
* a 0: set projection_vector to be parallel to line segment from p1 |
| 249 |
* to p2 |
| 250 |
* 1: set projection_vector to be perpendicular to line segment from |
| 251 |
* p1 to p2; the vector is retated counter clockwise 90 degrees |
| 252 |
* Pops p1: point number (ULONG) |
| 253 |
* p2: point number (ULONG) |
| 254 |
* Pushes - |
| 255 |
* Uses point p1 in the zone pointed at by zp2 |
| 256 |
* point p2 in the zone pointed at by zp1 |
| 257 |
* Sets projection vector |
| 258 |
*/ |
| 259 |
void Interp_SPVTL(VirtualMachine *vm) |
| 260 |
{ |
| 261 |
ULONG p1,p2; |
| 262 |
BYTE opcode; |
| 263 |
TTFUnitVector vect; |
| 264 |
|
| 265 |
opcode = (vm->iStream)[vm->ip]; |
| 266 |
p1 = Pop(vm); |
| 267 |
p2 = Pop(vm); |
| 268 |
|
| 269 |
switch (opcode) |
| 270 |
{ |
| 271 |
/* not finished yet */ |
| 272 |
case 0x06: |
| 273 |
break; |
| 274 |
case 0x07: |
| 275 |
break; |
| 276 |
} |
| 277 |
vm->gstate.projection_vector = vect; |
| 278 |
} |
| 279 |
/* SFVTL[a] Set freedom vector to line |
| 280 |
* Code Range 0x08 - 0x09 |
| 281 |
* a 0: set freedom_vector to be parallel to line segment from p1 |
| 282 |
* to p2 |
| 283 |
* 1: set freedom_vector to be perpendicular to line segment from |
| 284 |
* p1 to p2; the vector is retated counter clockwise 90 degrees |
| 285 |
* Pops p1: point number (ULONG) |
| 286 |
* p2: point number (ULONG) |
| 287 |
* Pushes - |
| 288 |
* Uses point p1 in the zone pointed at by zp2 |
| 289 |
* point p2 in the zone pointed at by zp1 |
| 290 |
* Sets freedom vector |
| 291 |
*/ |
| 292 |
void Interp_SFVTL(VirtualMachine *vm) |
| 293 |
{ |
| 294 |
ULONG p1,p2; |
| 295 |
BYTE opcode; |
| 296 |
TTFUnitVector vect; |
| 297 |
|
| 298 |
opcode = (vm->iStream)[vm->ip]; |
| 299 |
p1 = Pop(vm); |
| 300 |
p2 = Pop(vm); |
| 301 |
switch (opcode) |
| 302 |
{ |
| 303 |
/* not finished yet */ |
| 304 |
case 0x08: |
| 305 |
break; |
| 306 |
case 0x09: |
| 307 |
break; |
| 308 |
} |
| 309 |
vm->gstate.freedom_vector = vect; |
| 310 |
} |
| 311 |
/* SFVTPV[] Set freedom vector to projection vector |
| 312 |
* Code Range 0x0E |
| 313 |
* Pops - |
| 314 |
* Pushes - |
| 315 |
* Sets freedom vector |
| 316 |
*/ |
| 317 |
void Interp_SFVTPV(VirtualMachine *vm) |
| 318 |
{ |
| 319 |
vm->gstate.freedom_vector = vm->gstate.projection_vector; |
| 320 |
} |
| 321 |
/* SDPVTL[a] Set dual projection vector to line |
| 322 |
* Code Range 0x86 - 0x87 |
| 323 |
* a 0: vectors are parallel to line |
| 324 |
* 1: vectors are perpendicular to line |
| 325 |
* Pops p1: first point number (ULONG) |
| 326 |
* p2: second point number (ULONG) |
| 327 |
* Pushes - |
| 328 |
* Sets dual_projection_vector and projection_vector |
| 329 |
* Uses point p1 in the zone pointed by zp2 |
| 330 |
* point p2 in the zone pointed by zp1 |
| 331 |
*/ |
| 332 |
void Interp_SDPVTL(VirtualMachine *vm) |
| 333 |
{ |
| 334 |
ULONG p1,p2; |
| 335 |
BYTE opcode; |
| 336 |
TTFUnitVector vect; |
| 337 |
|
| 338 |
opcode = (vm->iStream)[vm->ip]; |
| 339 |
p1 = Pop(vm); |
| 340 |
p2 = Pop(vm); |
| 341 |
switch (opcode) |
| 342 |
{ |
| 343 |
/* not finished yet */ |
| 344 |
case 0x86: |
| 345 |
break; |
| 346 |
case 0x87: |
| 347 |
break; |
| 348 |
} |
| 349 |
vm->gstate.dual_projection_vector = vm->gstate.projection_vector = vect; |
| 350 |
} |
| 351 |
/* SPVFS[] Set projection vector from stack |
| 352 |
* Code Range 0x0A |
| 353 |
* Pops y: y component of projection vector (2.14 padded with zeros) |
| 354 |
* x: x component of projection vector (2.14 padded with zeros) |
| 355 |
* Pushes - |
| 356 |
* Sets projection_vector |
| 357 |
*/ |
| 358 |
void Inpterp_SPVFS(VirtualMachine *vm) |
| 359 |
{ |
| 360 |
F2Dot14 x,y; |
| 361 |
|
| 362 |
x = Pop(vm); |
| 363 |
y = Pop(vm); |
| 364 |
|
| 365 |
vm->gstate.projection_vector.x = x; |
| 366 |
vm->gstate.projection_vector.y = y; |
| 367 |
/* vm->gstate.projection = Normalize(vm->gstate.projection); ?? */ |
| 368 |
} |
| 369 |
/* SFVFS[] Set freedom vector form stack |
| 370 |
* Code Range 0x0B |
| 371 |
* Pops y: y component of freedom vector (2.14 padded with zeros) |
| 372 |
* x: x component of freedom vector (2.14 padded with zeros) |
| 373 |
* Pushes - |
| 374 |
* Sets freedom_vector |
| 375 |
*/ |
| 376 |
void Inpterp_SFVFS(VirtualMachine *vm) |
| 377 |
{ |
| 378 |
F2Dot14 x,y; |
| 379 |
|
| 380 |
x = Pop(vm); |
| 381 |
y = Pop(vm); |
| 382 |
|
| 383 |
vm->gstate.freedom_vector.x = x; |
| 384 |
vm->gstate.freedom_vector.y = y; |
| 385 |
/* vm->gstate.freedom = Normalize(vm->gstate.freedom); ?? */ |
| 386 |
} |
| 387 |
/* GPV[] Get projection vector |
| 388 |
* Code Range 0x0C |
| 389 |
* Pops - |
| 390 |
* Pushes x: x component of projection vector (2.14 padded with zeros) |
| 391 |
* y: y component of projection vector (2.14 padded with zeros) |
| 392 |
* Gets projection vector |
| 393 |
*/ |
| 394 |
void Interp_GPV(VirtualMachine *vm) |
| 395 |
{ |
| 396 |
ULONG l; |
| 397 |
|
| 398 |
l = (ULONG) vm->gstate.projection_vector.x; |
| 399 |
Push(vm,l); |
| 400 |
l = (ULONG) vm->gstate.projection_vector.y; |
| 401 |
Push(vm,l); |
| 402 |
} |
| 403 |
/* GFV[] Get freedom vector |
| 404 |
* Code Range 0x0D |
| 405 |
* Pops - |
| 406 |
* Pushes x: x component of freedom vector (2.14 padded with zeros) |
| 407 |
* y: y component of freedom vector (2.14 padded with zeros) |
| 408 |
* Gets freedom vector |
| 409 |
*/ |
| 410 |
void Interp_GFV(VirtualMachine *vm) |
| 411 |
{ |
| 412 |
ULONG l; |
| 413 |
|
| 414 |
l = (ULONG) vm->gstate.freedom_vector.x; |
| 415 |
Push(vm,l); |
| 416 |
l = (ULONG) vm->gstate.freedom_vector.y; |
| 417 |
Push(vm,l); |
| 418 |
} |
| 419 |
/* SRP0[] Set reference point 0 |
| 420 |
* Code Range 0x10 |
| 421 |
* Pops p: point number (ULONG) |
| 422 |
* Pushes - |
| 423 |
* Sets rp0 |
| 424 |
* Affects IP,MDAP,MIAP,MIRP,MSIRP,SHC,SHE,SHP |
| 425 |
*/ |
| 426 |
void Inpter_SRP0(VirtualMachine *vm) |
| 427 |
{ |
| 428 |
vm->gstate.rp0 = Pop(vm); |
| 429 |
} |
| 430 |
/* SRP1[] Set reference point 1 |
| 431 |
* Code Range 0x11 |
| 432 |
* Pops p: point number (ULONG) |
| 433 |
* Pushes - |
| 434 |
* Sets rp1 |
| 435 |
* Affects IP,MDAP,MIAP,MIRP,MSIRP,SHC,SHE,SHP |
| 436 |
*/ |
| 437 |
void Inpter_SRP1(VirtualMachine *vm) |
| 438 |
{ |
| 439 |
vm->gstate.rp1 = Pop(vm); |
| 440 |
} |
| 441 |
/* SRP2[] Set reference point 2 |
| 442 |
* Code Range 0x12 |
| 443 |
* Pops p: point number (ULONG) |
| 444 |
* Pushes - |
| 445 |
* Sets rp2 |
| 446 |
* Affects IP,MDAP,MIAP,MIRP,MSIRP,SHC,SHE,SHP |
| 447 |
*/ |
| 448 |
void Inpter_SRP2(VirtualMachine *vm) |
| 449 |
{ |
| 450 |
vm->gstate.rp2 = Pop(vm); |
| 451 |
} |
| 452 |
/* SZP0[] Set zone pointer 0 |
| 453 |
* Code Range 0x13 |
| 454 |
* Pops n: zone number (ULONG) |
| 455 |
* Pushes - |
| 456 |
* Sets zp0 |
| 457 |
* Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP, |
| 458 |
* MIRP,MSIRP,SHC,SHE,SHP,UTP |
| 459 |
*/ |
| 460 |
void Inpterp_SZP0(VirtualMachine *vm) |
| 461 |
{ |
| 462 |
vm->gstate.zp0 = Pop(vm); |
| 463 |
} |
| 464 |
/* SZP1[] Set zone pointer 1 |
| 465 |
* Code Range 0x14 |
| 466 |
* Pops n: zone number (ULONG) |
| 467 |
* Pushes - |
| 468 |
* Sets zp1 |
| 469 |
* Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP, |
| 470 |
* MIRP,MSIRP,SHC,SHE,SHP,UTP |
| 471 |
*/ |
| 472 |
void Inpterp_SZP1(VirtualMachine *vm) |
| 473 |
{ |
| 474 |
vm->gstate.zp1 = Pop(vm); |
| 475 |
} |
| 476 |
/* SZP2[] Set zone pointer 2 |
| 477 |
* Code Range 0x15 |
| 478 |
* Pops n: zone number (ULONG) |
| 479 |
* Pushes - |
| 480 |
* Sets zp2 |
| 481 |
* Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP, |
| 482 |
* MIRP,MSIRP,SHC,SHE,SHP,UTP |
| 483 |
*/ |
| 484 |
void Inpterp_SZP2(VirtualMachine *vm) |
| 485 |
{ |
| 486 |
vm->gstate.zp2 = Pop(vm); |
| 487 |
} |
| 488 |
/* SZPS[] Set zone pointerS |
| 489 |
* Code Range 0x16 |
| 490 |
* Pops n: zone number (ULONG) |
| 491 |
* Pushes - |
| 492 |
* Sets zp0,zp1,zp2 |
| 493 |
* Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP, |
| 494 |
* MIRP,MSIRP,SHC,SHE,SHP,UTP |
| 495 |
*/ |
| 496 |
void Inpterp_SZPS(VirtualMachine *vm) |
| 497 |
{ |
| 498 |
vm->gstate.zp0 = vm->gstate.zp1 = vm->gstate.zp2 = Pop(vm); |
| 499 |
} |
| 500 |
/* RTHG[] Round to half grid |
| 501 |
* Code Range 0x19 |
| 502 |
* Pops - |
| 503 |
* Pushes - |
| 504 |
* Sets round_state |
| 505 |
* Affects MDAP,MDRP,MDIAP,MIRP,ROUND |
| 506 |
* Uses freedom_vector, projection_vetor |
| 507 |
*/ |
| 508 |
void Interp_RTHG(VirtualMachine *vm) |
| 509 |
{ |
| 510 |
vm->gstate.round_state = 0; |
| 511 |
} |
| 512 |
/* RTG[] Round to grid |
| 513 |
* Code Range 0x18 |
| 514 |
* Pops - |
| 515 |
* Pushes - |
| 516 |
* Sets round_state |
| 517 |
* Affects MDAP,MDRP,MDIAP,MIRP,ROUND |
| 518 |
* Uses freedom_vector, projection_vetor |
| 519 |
*/ |
| 520 |
void Interp_RTG(VirtualMachine *vm) |
| 521 |
{ |
| 522 |
vm->gstate.round_state = 1; |
| 523 |
} |
| 524 |
/* RTDG[] Round to double grid |
| 525 |
* Code Range 0x3D |
| 526 |
* Pops - |
| 527 |
* Pushes - |
| 528 |
* Sets round_state |
| 529 |
* Affects MDAP,MDRP,MDIAP,MIRP,ROUND |
| 530 |
* Uses freedom_vector, projection_vetor |
| 531 |
*/ |
| 532 |
void Interp_RTDG(VirtualMachine *vm) |
| 533 |
{ |
| 534 |
vm->gstate.round_state = 2; |
| 535 |
} |
| 536 |
/* RTHG[] Round down to grid |
| 537 |
* Code Range 0x7D |
| 538 |
* Pops - |
| 539 |
* Pushes - |
| 540 |
* Sets round_state |
| 541 |
* Affects MDAP,MDRP,MDIAP,MIRP,ROUND |
| 542 |
* Uses freedom_vector, projection_vetor |
| 543 |
*/ |
| 544 |
void Interp_RDTG(VirtualMachine *vm) |
| 545 |
{ |
| 546 |
vm->gstate.round_state = 3; |
| 547 |
} |
| 548 |
/* RUTG[] Round up to grid |
| 549 |
* Code Range 0x7C |
| 550 |
* Pops - |
| 551 |
* Pushes - |
| 552 |
* Sets round_state |
| 553 |
* Affects MDAP,MDRP,MDIAP,MIRP,ROUND |
| 554 |
* Uses freedom_vector, projection_vetor |
| 555 |
*/ |
| 556 |
void Interp_RUTG(VirtualMachine *vm) |
| 557 |
{ |
| 558 |
vm->gstate.round_state = 4; |
| 559 |
} |
| 560 |
/* ROFF[] Round off |
| 561 |
* Code Range 0x7A |
| 562 |
* Pops - |
| 563 |
* Pushes - |
| 564 |
* Sets round_state |
| 565 |
* Affects MDAP,MDRP,MDIAP,MIRP,ROUND |
| 566 |
* Uses freedom_vector, projection_vetor |
| 567 |
*/ |
| 568 |
void Interp_ROFF(VirtualMachine *vm) |
| 569 |
{ |
| 570 |
vm->gstate.round_state = 5; |
| 571 |
} |
| 572 |
/* SROUND[] Super round |
| 573 |
* Code Range 0x76 |
| 574 |
* Pops n: number (ULONG) decomposed to obtain period, phase, threshold |
| 575 |
* Pushes - |
| 576 |
* Sets round_state |
| 577 |
* Affects MDAP,MDRP,MIAP,MIRP,ROUND |
| 578 |
*/ |
| 579 |
void Interp_SROUND(VirtualMachine *vm) |
| 580 |
{ |
| 581 |
ULONG n; |
| 582 |
|
| 583 |
n = Pop(vm); |
| 584 |
/* not finished yet */ |
| 585 |
} |
| 586 |
/* S45ROUND[] Super round 45 degrees |
| 587 |
* Code Range 0x77 |
| 588 |
* Pops n: number (ULONG) decomposed to obtain period, phase, threshold |
| 589 |
* Pushes - |
| 590 |
* Sets round_state |
| 591 |
* Affects MDAP,MDRP,MIAP,MIRP,ROUND |
| 592 |
*/ |
| 593 |
void Interp_S45ROUND(VirtualMachine *vm) |
| 594 |
{ |
| 595 |
ULONG n; |
| 596 |
|
| 597 |
n = Pop(vm); |
| 598 |
/* not finished yet */ |
| 599 |
} |
| 600 |
/* SLOOP[] Set LOOP variable |
| 601 |
* Code Range 0x17 |
| 602 |
* Pops n: value for loop graphics state variable |
| 603 |
* Pushes - |
| 604 |
* Set loop |
| 605 |
* Affects ALIGNRP,FLIPPT,IP,SHP,SHIP |
| 606 |
*/ |
| 607 |
void Interp_SLOOP(VirtualMachine *vm) |
| 608 |
{ |
| 609 |
vm->gstate.loop = Pop(vm); |
| 610 |
} |
| 611 |
/* SMD[] Set minimum_distance |
| 612 |
* Code Range 0x1a |
| 613 |
* Pops distance: value for minimum_distance (F26Dot6) |
| 614 |
* Pushes - |
| 615 |
* Sets minimum_distance |
| 616 |
*/ |
| 617 |
void Interp_SMD(VirtualMachine *vm) |
| 618 |
{ |
| 619 |
vm->gstate.minimum_distance = Pop(vm); |
| 620 |
} |
| 621 |
/* INSTCTRL[] Instruction execution control |
| 622 |
* Code Range 0x8E |
| 623 |
* Pops s: selector flags |
| 624 |
* value: USHORT padded to 32 bits used to set value of |
| 625 |
* instruction control |
| 626 |
* Pushes - |
| 627 |
* Sets instruction_control |
| 628 |
*/ |
| 629 |
void Interp_INSTCTRL(VirtualMachine *vm) |
| 630 |
{ |
| 631 |
ULONG flag; |
| 632 |
|
| 633 |
flag = Pop(vm); |
| 634 |
vm->gstate.instruction_control = Pop(vm); |
| 635 |
/* not finished yet */ |
| 636 |
} |
| 637 |
/* SCANCTRL[] Scan conversion cotrol |
| 638 |
* Code Range 0x85 |
| 639 |
* Pops n: flags indication when to turn on dropout mode (16 bits padded |
| 640 |
* to 32 bits) |
| 641 |
* Pushes - |
| 642 |
* Sets scan_control |
| 643 |
*/ |
| 644 |
void Interp_SCANCTRL(VirtualMachine *vm) |
| 645 |
{ |
| 646 |
USHORT flag; |
| 647 |
|
| 648 |
flag = Pop(vm); |
| 649 |
/* not finished yet */ |
| 650 |
} |
| 651 |
/* SCANTYPE[] Scantype |
| 652 |
* Code Range 0x8D |
| 653 |
* Pops n: 16 bit interger |
| 654 |
* Pushes - |
| 655 |
* Sets scan_control |
| 656 |
*/ |
| 657 |
void Interp_SCANTYPE(VirtualMachine *vm) |
| 658 |
{ |
| 659 |
/* not finished yet */ |
| 660 |
} |
| 661 |
/* SCVTCI[] Set control value table cut in |
| 662 |
* Code Range 0x1D |
| 663 |
* Pops n: value for cut_in (F26Dot6) |
| 664 |
* Pushes - |
| 665 |
* Sets control_value_cut_in |
| 666 |
* Affects MIAP,MIRP |
| 667 |
*/ |
| 668 |
void Interp_SCVTCI(VirtualMachine *vm) |
| 669 |
{ |
| 670 |
vm->gstate.control_value_cut_in = Pop(vm); |
| 671 |
} |
| 672 |
/* SSWCI[] Single width cut in |
| 673 |
* Code Range 0x1E |
| 674 |
* Pops n: value for single_width_cut_in |
| 675 |
* Pushes - |
| 676 |
* Sets signel_width_cut_in |
| 677 |
* Affects MIAP,MIRP |
| 678 |
*/ |
| 679 |
void Interp_SSWCI(VirtualMachine *vm) |
| 680 |
{ |
| 681 |
vm->gstate.single_width_cut_in = Pop(vm); |
| 682 |
} |
| 683 |
/* SSW[] Set single width |
| 684 |
* Code Range 0x1F |
| 685 |
* Pops n: value for single_width_value (FUnits) |
| 686 |
* Pushes - |
| 687 |
* Sets single_width_value |
| 688 |
*/ |
| 689 |
void Interp_SSW(VirtualMachine *vm) |
| 690 |
{ |
| 691 |
vm->gstate.single_width_cut_in = Pop(vm); |
| 692 |
} |
| 693 |
/* FLIPON[] Set the auto_flip on |
| 694 |
* Code Range 0x4D |
| 695 |
* Pops - |
| 696 |
* Pushes - |
| 697 |
* Sets auto_flip |
| 698 |
* Affects MIRP |
| 699 |
*/ |
| 700 |
void Interp_FLIPON(VirtualMachine *vm) |
| 701 |
{ |
| 702 |
vm->gstate.auto_flip = 1; |
| 703 |
} |
| 704 |
/* FLIPOFF[] Set the auto_flip off |
| 705 |
* Code Range 0x4E |
| 706 |
* Pops - |
| 707 |
* Pushes - |
| 708 |
* Sets auto_flip |
| 709 |
* Affects MIRP |
| 710 |
*/ |
| 711 |
void Interp_FLIPOFF(VirtualMachine *vm) |
| 712 |
{ |
| 713 |
vm->gstate.auto_flip = 0; |
| 714 |
} |
| 715 |
/* SDB Set delta_base in the graphics state |
| 716 |
* Code Range 0x5E |
| 717 |
* Pops n: value for delta_base (ULONG) |
| 718 |
* Pushes - |
| 719 |
* Sets delta_base |
| 720 |
* Affects DELTAP1,DELTAP2,DELTAP3,DELTAC1,DELTAC2,DELTAC3 |
| 721 |
*/ |
| 722 |
void Interp_SDB(VirtualMachine *vm) |
| 723 |
{ |
| 724 |
vm->gstate.delta_base = Pop(vm); |
| 725 |
} |
| 726 |
/* SDS Set delta_shift in the graphics state |
| 727 |
* Code Range 0x5F |
| 728 |
* Pops n: value for delat_shift (ULONG) |
| 729 |
* Sets delta_shift |
| 730 |
* Affects DELTAP1,DELTAP2,DELTAP3,DELATC1,DELTAC2,DELTAC3 |
| 731 |
*/ |
| 732 |
void Interp_SDS(VirtualMachine *vm) |
| 733 |
{ |
| 734 |
vm->gstate.delta_shift = Pop(vm); |
| 735 |
} |
| 736 |
|
| 737 |
/* Reading and writing data */ |
| 738 |
|
| 739 |
/* GC[a] Get coordinate projected on to the projection_vector |
| 740 |
* Code Range 0x46 - 0x47 |
| 741 |
* a 0: use current position of point p |
| 742 |
* 1: use the position of point p in the original outline |
| 743 |
* Pops p: point number (ULONG) |
| 744 |
* Pushes value: coordinate location (F26Dot6) |
| 745 |
* Uses zp2,projection |
| 746 |
*/ |
| 747 |
void Interp_GC(VirtualMachine *vm) |
| 748 |
{ |
| 749 |
ULONG point; |
| 750 |
TTFVector pos; |
| 751 |
|
| 752 |
point = Pop(vm); |
| 753 |
|
| 754 |
/* not finished yet */ |
| 755 |
} |
| 756 |
/* SCFS[] Sets coordinate from the stack using projection_vector and |
| 757 |
* freedom_vector |
| 758 |
* Code Range 0x48 |
| 759 |
* Pops value: distance from origin to move point (F26Dot6) |
| 760 |
* p: point number (ULONG) |
| 761 |
* Pushes - |
| 762 |
* Uses zp2, freedom_vector, projection_vector |
| 763 |
*/ |
| 764 |
void Interp_SCFS(VirtualMachine *vm) |
| 765 |
{ |
| 766 |
#ifdef WIN32 |
| 767 |
__int64 tmp; |
| 768 |
#else |
| 769 |
long long tmp; |
| 770 |
#endif |
| 771 |
F26Dot6 value; |
| 772 |
ULONG point; |
| 773 |
|
| 774 |
value = Pop(vm); |
| 775 |
point = Pop(vm); |
| 776 |
/* not finished yet */ |
| 777 |
} |
| 778 |
/* MD[a] Measure Distance |
| 779 |
* |
| 780 |
* Code Range 0x49-0x4A |
| 781 |
* a 0: measure distance in grid-fitted outline |
| 782 |
* 1: measure distance in original outline |
| 783 |
* Pops p1: point number (ULONG) |
| 784 |
* p2: point number (ULONG); |
| 785 |
* Pushes distance (F26Dot6) |
| 786 |
* uses zp1 with point p1, zp2 withe point p2, projection_vector |
| 787 |
*/ |
| 788 |
void Interp_MD(VirtualMachine *vm) |
| 789 |
{ |
| 790 |
ULONG p1,p2; |
| 791 |
BYTE opcode; |
| 792 |
TTFUnitVector vect; |
| 793 |
|
| 794 |
opcode = (vm->iStream)[vm->ip]; |
| 795 |
p1 = Pop(vm); |
| 796 |
p2 = Pop(vm); |
| 797 |
switch (opcode) |
| 798 |
{ |
| 799 |
/* not finished yet */ |
| 800 |
case 0x49: |
| 801 |
break; |
| 802 |
case 0x4A: |
| 803 |
break; |
| 804 |
} |
| 805 |
/* not finished yet */ |
| 806 |
} |
| 807 |
/* MPPEM[] Measure Pixel Per EM |
| 808 |
* |
| 809 |
* Code Range 0x4B |
| 810 |
* Pops - |
| 811 |
* Pushes ppem:pixel per em (ULONG) |
| 812 |
*/ |
| 813 |
void Interp_MPPEM(VirtualMachine *vm) |
| 814 |
{ |
| 815 |
/* not finished yet */ |
| 816 |
} |
| 817 |
/* MPS[] Measure Point Size |
| 818 |
* |
| 819 |
* Code Range 0x4C |
| 820 |
* Pops - |
| 821 |
* Pushes pointSize: the size in points of the current glyph (F26Dot6) |
| 822 |
*/ |
| 823 |
void Interp_MPS(VirtualMachine *vm) |
| 824 |
{ |
| 825 |
F26Dot6 pointSize = vm->pointsize; |
| 826 |
|
| 827 |
Push(vm,pointSize); |
| 828 |
} |
| 829 |
|
| 830 |
/* Mananging Outlines */ |
| 831 |
|
| 832 |
/* FLIPPT[] Flip point |
| 833 |
* Code Range 0x80 |
| 834 |
* Pops p: point number (ULONG) |
| 835 |
* Pushes - |
| 836 |
* Uses loop, p is referenced in zp0 |
| 837 |
*/ |
| 838 |
void Interp_FLIPPT(VirtualMachine *vm) |
| 839 |
{ |
| 840 |
ULONG point; |
| 841 |
|
| 842 |
point = Pop(vm); |
| 843 |
|
| 844 |
/* not finished yet */ |
| 845 |
} |
| 846 |
/* FLIPRGON[] Filp range on |
| 847 |
* Code Range 0x81 |
| 848 |
* Pops hightpoint: highest point number in range of points to be flipped |
| 849 |
* lowpoint: lowest point number in range of points to be flipped |
| 850 |
* both are ULONG |
| 851 |
* Pushes - |
| 852 |
*/ |
| 853 |
void Interp_FLIPRGON(VirtualMachine *vm) |
| 854 |
{ |
| 855 |
|
| 856 |
} |