Metode menyimpanan data font memiliki perbedaan antara vendor library.
Font Library DMD
DMD, DMD2, DMD3 menggunakan font dengan metode vertikal seperti ditunjukkan dalam diagram berikut:
Font library GFX
Font yang dikembangkan oleh adafruit dalam GFX menggunakan metode mendatar seperti diagram berikut :
Untuk keperluan konversi font dari dmd ke gfx bisa dilakukan dengan metode invert.
Coding berikut ditulis dengan bahasa php, jadi harus menggunakan web server seperti xampp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | <? php $fontHorizontal = "" ; $fontVertikal = "" ; $tinggi = 0; $lebar = 0; $charCount = 0; if (isset( $_GET [ 'konversiKeHorizontal' ])) { $fontVertikal = $_GET [ 'fontVertikal' ]; $tinggi = $_GET [ 'tinggi' ]; $lebar = $_GET [ 'lebar' ]; $charCount = $_GET [ 'jumlahKarakter' ]; $verticalHex = str_getcsv ( $fontVertikal , ',' ); for ( $i = 0; $i < sizeof( $verticalHex ); $i ++) { $verticalByte [ $i ] = hexDec( $verticalHex [ $i ]); } for ( $cc = 0; $cc < $charCount ; $cc ++) { $horizontalByte = array (); for ( $i = 0; $i < ( $tinggi * $lebar / 8); $i ++) { array_push ( $horizontalByte , 0); } $bit = 0; $byte = 0; $indexHorizontal = 0; $byteMask = 1; for ( $x = 0; $x < $lebar ; $x ++) { for ( $y = 0; $y < $tinggi ; $y ++) { $x2 = $x ; $y2 = $y ; if ( $y >= 8) { $x2 += ((int)( $y / 8) * $lebar ); $y2 = $y % 8; } $indexVertical = ( $x2 * 8) + $y2 + ( $cc * $lebar * $tinggi ); $indexVerticalByte = (int)( $indexVertical / 8); $indexVerticalBit = $indexVertical % 8; $indexHorizontal = ( $y * $lebar ) + $x ; $indexHorizontalByte = (int)( $indexHorizontal / 8); $indexHorizontalBit = $indexHorizontal % 8; $verticalBit = $verticalByte [ $indexVerticalByte ] & pow(2, $indexVerticalBit ); if ( $verticalBit ) { $horizontalByte [ $indexHorizontalByte ] |= pow(2, 7 - $indexHorizontalBit ); } } } for ( $i = 0; $i < sizeof( $horizontalByte ); $i ++) { $fontHorizontal . = "0x" ; if ( $horizontalByte [ $i ] < 0x10) { $fontHorizontal . = '0' ; } $fontHorizontal . = decHex ( $horizontalByte [ $i ]); $fontHorizontal . = ', ' ; } $fontHorizontal . = ' ' ; } } ?> <html> <head><title>font Invert ( vertical to horizontal) - semesin.com</title> </head> <body> <h4>Konversi font DMD menjadi font GFX</h4><br> <form action = "" method = "get" > Font vertikal : <br><textarea name = "fontVertikal" rows = "10" cols = "100%" > <? php echo $fontVertikal ?> < / textarea > <br> Tinggi : <input type = "text" name = "tinggi" value = "<?php echo $tinggi ?>" ><br> Lebar : <input type = "text" name = "lebar" value = "<?php echo $lebar; ?>" ><br> Jumlah : <input type = "text" name = "jumlahKarakter" value = "<?php echo $charCount; ?>" ><br> <input type = "submit" name = "konversiKeHorizontal" value = "Konversi ke Horizontal" > </form> Font horizontal : <br><textarea rows = "10" cols = "100%" > <? php echo $fontHorizontal ?> < / textarea > <br> </body > </html > |
tampilan konversi font dmd ke gfx: