Author Topic: Compressed Font  (Read 2844 times)

0 Members and 1 Guest are viewing this topic.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Compressed Font
« on: February 14, 2007 »
Heres a little conversion of this font but its been altered so that each scanline takes up only one byte of data. This compresses the font to 1/8th of its original size  ;D press any key to move on to the next charictor once the full sequence has been displayed it starts over again. This should prove useful for text displays when you really dont want to use a lot of bytes creating a font. remember that the bitmaps dont use two dimensions (x,y) so you need to get the correct index value. You may chose to change this it makes little or no difference.

Code: [Select]
open window 640, 512
size = 50
set_font(01)

label display
   for c = 1 to chars
      repeat
         setdispbuf draw
         draw = 1 - draw
         setdrawbuf draw
         clear window
         for y = 1 to fonty fy = y * size
            for x = 1 to fontx fx = x * size
               p = (y-1)*fontx + x : rem access the correct array entry through indexing
               box fx, fy to fx + size, fy + size
               if (font(c, p) <> 0) then
                  fill box fx, fy to fx + size, fy + size
               fi
            next
         next
      until (inkey$(0) <> "")
   next
   goto display

sub set_font(font_num)
   on font_num goto 01

00 read chars, fontx, fonty
   redim font(chars, fontx*fonty)
   for c = 1 to chars
      p = 1
      for y = 1 to fonty
         read f
         n = 1
         for x = 1 to fontx
            if (and(n,f) <> 0) then
               font(c, p) = 1
            else
               font(c, p) = 0
            fi
            p = p + 1
            n = n * 2
         next
      next
   next
   return

01 restore font_01 : goto 00
end sub


label font_01
data 64 : rem total charictor amount
data 08 : rem font width in pixels
data 08 : rem font height in pixels
data 000,000,000,000,000,000,000,000
data 056,056,056,056,000,056,056,056
data 238,238,238,000,000,000,000,000
data 000,110,255,110,110,255,110,000
data 124,238,031,014,014,014,014,255
data 000,230,118,056,028,110,103,000
data 024,126,126,255,255,126,126,024
data 056,056,056,000,000,000,000,000
data 060,030,014,014,014,014,030,060
data 060,120,112,112,112,112,120,060
data 000,090,060,126,126,060,090,000
data 000,024,024,126,126,024,024,000
data 000,000,000,000,000,056,056,060
data 000,000,000,126,126,000,000,000
data 000,000,000,000,000,000,024,024
data 000,224,112,056,028,014,007,000
data 126,231,231,239,247,231,231,126
data 056,060,060,056,056,056,056,124
data 124,238,224,126,007,007,199,255
data 126,231,112,224,224,224,231,126
data 119,119,254,028,028,028,028,028
data 127,119,007,126,224,224,231,126
data 003,003,003,127,231,231,231,126
data 127,231,240,224,224,224,224,224
data 126,231,126,231,231,231,231,126
data 254,227,254,224,224,224,224,224
data 000,000,056,056,000,056,056,060
data 000,000,056,056,000,056,056,056
data 000,028,014,007,007,014,028,000
data 000,060,060,000,000,060,060,000
data 000,056,112,224,224,112,056,000
data 126,231,120,056,000,056,056,056
data 000,060,102,090,066,090,060,000
data 126,231,255,231,231,231,231,231
data 127,231,127,231,231,231,231,127
data 126,231,007,007,007,231,231,126
data 127,231,231,231,231,231,231,127
data 126,231,015,007,007,231,231,126
data 126,231,015,007,007,007,007,007
data 126,231,007,007,247,231,231,126
data 231,231,255,231,231,231,231,231
data 062,028,028,028,028,028,028,062
data 254,231,224,160,239,231,231,126
data 119,119,063,231,231,231,231,231
data 007,007,007,007,007,231,231,126
data 118,255,239,239,231,231,231,231
data 127,231,231,231,231,231,231,231
data 126,231,231,231,231,231,231,126
data 127,231,127,007,007,007,007,007
data 126,231,231,231,215,183,103,126
data 127,231,127,231,231,231,231,231
data 126,231,007,126,224,231,231,126
data 062,028,028,028,028,028,028,028
data 231,231,231,231,231,231,231,126
data 231,231,231,231,231,231,102,060
data 231,231,231,231,239,239,239,126
data 231,231,126,231,231,231,231,231
data 231,231,254,224,224,231,231,126
data 254,231,224,126,007,007,231,127
data 015,007,007,007,007,007,007,015
data 003,007,014,028,056,112,224,192
data 240,224,224,224,224,224,224,240
data 024,060,102,231,000,000,000,000
data 000,000,000,000,000,000,000,126


Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Compressed Font
« Reply #1 on: February 16, 2007 »
Hehe, my font converted to Yabasic :D  :clap:
Shockwave ^ Codigos
Challenge Trophies Won: