|
124 | 124 | <tr> |
125 | 125 | <td>Height:</td><td><input placeholder="Font height" type="number" id="height" value="13" max="64"/></td> |
126 | 126 | </tr> |
| 127 | + <tr> |
| 128 | + <td>NewWidth:</td><td><input placeholder="New Font width" type="number" id="newwidth" value="0"/></td> |
| 129 | + </tr> |
| 130 | + <tr> |
| 131 | + <td>NewHeight:</td><td><input placeholder="New Font height" type="number" id="newheight" value="0" max="64"/></td> |
| 132 | + </tr> |
127 | 133 | <tr> |
128 | 134 | <td colspan="3"> </td> <!--slightly improves layout--> |
129 | 135 | </tr> |
130 | 136 | <tr> |
131 | 137 | <td colspan="2"> |
132 | 138 | <button id="create">Create</button> |
133 | | - <button id="shiftUp">Shift all up</button> |
| 139 | + <br/>Shift all |
| 140 | + <button id="shiftUp">Up</button> |
| 141 | + <button id="shiftDown">Down</button> |
| 142 | + <button id="shiftLeft">Left</button> |
| 143 | + <button id="shiftRight">Right</button><br/> |
134 | 144 | <button id="generate">Generate</button> |
135 | 145 | <button id="savetoFile">Save To File</button> |
136 | 146 | </td> |
|
294 | 304 | // generates the jump table and font data |
295 | 305 | generate() { |
296 | 306 | // this.width -= 3; // hack to narrow an existing font |
| 307 | + var newheight = parseInt(document.getElementById('newheight').value); |
| 308 | + if(newheight){ |
| 309 | + this.height = newheight; |
| 310 | + this.bytesForHeight = (1 + ((this.height - 1) >> 3)); |
| 311 | + } |
| 312 | + var newwidth = parseInt(document.getElementById('newwidth').value); |
| 313 | + if(newwidth){ |
| 314 | + this.width = newwidth; |
| 315 | + } |
| 316 | + |
297 | 317 | Font.emptyOutput(); |
298 | 318 | let chars = this.fontContainer.getElementsByTagName('table'); |
299 | 319 | let firstCharCode = parseInt(document.getElementById('code').value); |
|
319 | 339 | // Browse each row starting from the bottom one, going up, and accumulate pixels in |
320 | 340 | // a string: this rotates the glyph |
321 | 341 | // Beware, row 0 is table headers. |
322 | | - for(let r = rows.length-1; r >=1 ; r--) { |
| 342 | + //for(let r = rows.length-1; r >=1 ; r--) { |
| 343 | + |
| 344 | + for(let r = this.height; r >=1 ; r--) { |
323 | 345 | let pixelState = rows[r].children[col].className; |
324 | 346 | bits += (pixelState === 'on' ? '1': '0'); |
325 | 347 | } |
|
410 | 432 | } |
411 | 433 | }); |
412 | 434 |
|
| 435 | + document.getElementById('shiftDown').addEventListener('click', function() { |
| 436 | + var chars = document.getElementById("chars"); |
| 437 | + var tables = chars.getElementsByTagName("table"); |
| 438 | + for(var i=0; i< tables.length; i++) { |
| 439 | + shiftDown(tables[i]); |
| 440 | + } |
| 441 | + }); |
| 442 | + document.getElementById('shiftLeft').addEventListener('click', function() { |
| 443 | + var chars = document.getElementById("chars"); |
| 444 | + var tables = chars.getElementsByTagName("table"); |
| 445 | + for(var i=0; i< tables.length; i++) { |
| 446 | + shiftLeft(tables[i]); |
| 447 | + } |
| 448 | + }); |
| 449 | + document.getElementById('shiftRight').addEventListener('click', function() { |
| 450 | + var chars = document.getElementById("chars"); |
| 451 | + var tables = chars.getElementsByTagName("table"); |
| 452 | + for(var i=0; i< tables.length; i++) { |
| 453 | + shiftRight(tables[i]); |
| 454 | + } |
| 455 | + }); |
| 456 | + |
413 | 457 | document.getElementById('generate').addEventListener('click', function() { |
414 | 458 | font.generate(); |
415 | 459 | }); |
|
454 | 498 |
|
455 | 499 | // Shift pixels to the left |
456 | 500 | case 'left': |
457 | | - pixels = currentContainer.getElementsByTagName('td'); |
458 | | - for(p = 0; p < pixels.length; p++) { |
459 | | - if((p + 1) % font.width) { |
460 | | - pixels[p].className = pixels[p + 1].className; |
461 | | - } else { |
462 | | - pixels[p].className = ''; |
463 | | - } |
464 | | - } |
| 501 | + shiftLeft(currentContainer); |
465 | 502 | break; |
466 | 503 |
|
467 | 504 | // Shift pixels to the right |
468 | 505 | case 'right': |
469 | | - pixels = currentContainer.getElementsByTagName('td'); |
470 | | - for(p = pixels.length-1; p >=0 ; p--) { |
471 | | - if(p % font.width) { |
472 | | - pixels[p].className = pixels[p - 1].className; |
473 | | - } else { |
474 | | - pixels[p].className = ''; |
475 | | - } |
476 | | - } |
| 506 | + shiftRight(currentContainer); |
477 | 507 | break; |
478 | 508 |
|
479 | 509 | // Shift pixels down |
480 | 510 | case 'down': |
481 | | - pixels = currentContainer.getElementsByTagName('td'); |
482 | | - for(p = pixels.length-1; p >=0 ; p--) { |
483 | | - if(p >= font.width) { |
484 | | - pixels[p].className = pixels[p - font.width].className; |
485 | | - } else { |
486 | | - pixels[p].className = ''; |
487 | | - } |
488 | | - } break; |
| 511 | + shiftDown(currentContainer); |
| 512 | + break; |
489 | 513 |
|
490 | 514 | // Shift pixels up |
491 | 515 | case 'up': |
|
532 | 556 | } |
533 | 557 | } |
534 | 558 | } |
| 559 | + function shiftDown(container) { |
| 560 | + var pixels = container.getElementsByTagName('td'); |
| 561 | + for(p = pixels.length-1; p >=0 ; p--) { |
| 562 | + if(p >= font.width) { |
| 563 | + pixels[p].className = pixels[p - font.width].className; |
| 564 | + } else { |
| 565 | + pixels[p].className = ''; |
| 566 | + } |
| 567 | + } |
| 568 | + } |
| 569 | + function shiftLeft(container) { |
| 570 | + var pixels = container.getElementsByTagName('td'); |
| 571 | + for(p = 0; p < pixels.length; p++) { |
| 572 | + if((p + 1) % font.width) { |
| 573 | + pixels[p].className = pixels[p + 1].className; |
| 574 | + } else { |
| 575 | + pixels[p].className = ''; |
| 576 | + } |
| 577 | + } |
| 578 | + } |
| 579 | + |
| 580 | + function shiftRight(container) { |
| 581 | + var pixels = container.getElementsByTagName('td'); |
| 582 | + for(p = pixels.length-1; p >=0 ; p--) { |
| 583 | + if(p % font.width) { |
| 584 | + pixels[p].className = pixels[p - 1].className; |
| 585 | + } else { |
| 586 | + pixels[p].className = ''; |
| 587 | + } |
| 588 | + } |
| 589 | + } |
535 | 590 |
|
536 | 591 | document.getElementById('chars').addEventListener('mouseover', function(e) { |
537 | 592 | let target = e.target; |
|
0 commit comments