Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Draw for scalable font?
#11
I had fun with that old bit of code. It is certainly the program I recall from way back.  I fiddled with it a little. I'm not sure the original programmer realized how versatile the scaling options actually are using draw. 

Here's a version of it fiddled with and cleaned up a bit before I threw some fresh spaghetti into it.




Code: (Select All)
S1& = _NewImage(800, 480, 256) 'A huge screen we would have killed for in 1997
Screen S1&
Dim Shared dfont$(0 To 255)
Dim Shared dftag$
build_font 'loading the font into an array instead of using a bunch of case options
Line (0, 0)-(800, 480), 15, BF
'using the "CALL" function...
'HOW...
Call drawFont(1, 20, 1, "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.")
Call drawFont(1, 40, 4, "Then he tripped and stumbled and fell.")

' or...

drawFont 10, 100, 2, "This uses a Font drawn by UWLabs  (Under Ware Labs?)"


Line (45, 110)-(400, 130), 7, BF
drawFont 51, 125, 15, "You can create embossed text like this."
drawFont 50, 124, 8, "You can create embossed text like this."

Line (45, 140)-(400, 160), 7, BF
drawFont 51, 155, 8, "OR,  create raised text like this."
drawFont 50, 154, 15, "OR,  create raised text like this."

Line (45, 180)-(250, 210), 7, BF
styledrawfont 54, 200, 14, "OR,Shadows...", "shadow"


styledrawfont 305, 200, 0, "(Shadows.)", "shadows.s10"

styledrawfont 50, 230, 0, "OR, BOLD text", "bold"

styledrawfont 200, 230, 0, "Double BOLD text", "dbold"

drawFont 381, 231, 4, "OR, 3-D Text."
drawFont 380, 231, 4, "OR, 3-D Text."
drawFont 381, 230, 5, "OR, 3-D Text."
drawFont 380, 230, 13, "OR, 3-D Text."

styledrawfont 54, 270, 0, "OR, Double sized BOLD text, with shadows!", "bold shadows .s8"
Draw "a1" ' <---- ROTATION ANGLE 1  (90 degrees)
drawFont 70, 400, 0, "Vertical text."
Draw "a0" ' <---- angle set back to zero

Draw "a3" ' <---- ROTATION ANGLE 3  (270 degrees)
drawFont 85, 298, 0, "Vertical text."
Draw "a0" ' <---- angle set back to zero

Draw "ta15" ' <---- TURN ANGLE 15 degrees
drawFont 420, 475, 0, "And text at an angle!"
Draw "ta0" ' <---- TURN ANGLE 0 degrees
Draw "ta30" ' <---- TURN ANGLE 30 degrees
drawFont 418, 462, 0, "And text at an angle!"
Draw "ta0" ' <---- TURN ANGLE 0 degrees
Draw "ta45" ' <---- TURN ANGLE 45 degrees
drawFont 412, 450, 0, "And text at an angle!"
Draw "ta0" ' <---- TURN ANGLE 0 degrees
Draw "ta60" ' <---- TURN ANGLE 60 degrees
drawFont 402, 438, 0, "And text at an angle!"
Draw "ta0" ' <---- TURN ANGLE 0 degrees
Draw "ta75" ' <---- TURN ANGLE 75 degrees
drawFont 390, 430, 0, "And text at an angle!"
Draw "ta0" ' <---- TURN ANGLE 0 degrees

Draw "ta180" ' <---- TURN ANGLE 180 degrees
drawFont 225, 298, 0, "Upside down."
Draw "ta0" ' <---- angle set back to zero

'Button-look UWL Logo...
PSet (10, 440), 0
Draw "r130d30l130u30f1c15r128c8d28l128c15u28f1r126c8d26l126c15u26f1c7r124d24l124u24f2c3fp7,7"
drawFont 23, 462, 15, "UWLabs(c)1997"
drawFont 22, 461, 8, "UWLabs(c)1997"

'Smallest text DRAW will allow... (This is not in the SUB).

drawFont 185, 370, 0, "Using `DRAW' even..."
PSet (200, 384), 0
Draw "u4f2e2d4br3u4br2br4l2gd2fr2br2u4r3fgnl3fdbr1beu2er2fd2gl2h"
Draw "br6bfbu2r3bd2br4"
Draw "u4l2r4br2nr3d2nr2d2r3br2e2h2br4g2f2br4u4l2r4bd4"
Draw "br8u4br6l3gfr2fgl3br12b"
Draw "u4r3fgl3bd1br6u2er2fd2gl2hbr10bu3l3gfr2fgl3br10bu4l3gfr2fgl3"
Draw "br7u4br3nr3d2nr3d2r3ehehbr3d4r3br2nr3u2nr2u2nr3"
Sleep

Sub styledrawfont (x, y, c, text$, st$)
   'Fancified version of the original sub
    '      x = starting x coordinate
    '      y = starting y coordinate
    '      c = text color
    '      Text$ = the string to display
    '      st$ = style
    '    supports: bold,dbold,shadows,shadows,and scaling
    '              should be easy as pie to add more options
    '
    If InStr(st$, ".s12") Then Draw "s12"
    If InStr(st$, ".s11") Then Draw "s11"
    If InStr(st$, ".s10") Then Draw "s10"
    If InStr(st$, ".s9") Then Draw "s9"
    If InStr(st$, ".s8") Then Draw "s8" 'make it big
    If InStr(st$, ".s7") Then Draw "s7"
    If InStr(st$, ".s6") Then Draw "s6"
    If InStr(st$, ".s5") Then Draw "s5"
    If InStr(st$, ".s4") Then Draw "s4" 'base size from origninal
    If InStr(st$, ".s3") Then Draw "s3"
    If InStr(st$, ".s2") Then Draw "s2"

    If InStr(st$, "bold") Then
        drawFont x, y, c, text$
        drawFont x + 1, y, c, text$
    End If
    If InStr(st$, "dbold") Then
        drawFont x, y, c, text$
        drawFont x + 1, y, c, text$
        drawFont x, y + 1, c, text$
        drawFont x + 1, y + 1, c, text$
    End If
    If InStr(st$, "shadow") Then
        drawFont x + 4, y + 3, 8, text$
        drawFont x, y, c, text$
    End If
    If InStr(st$, "shadows") Then
        drawFont x + 4, y + 3, 7, text$
        drawFont x + 3, y + 3, 7, text$
        drawFont x + 2, y + 3, 7, text$
        drawFont x, y, c, text$
    End If

    Draw "s4" 'return to normal size just in case it was changed
End Sub

Sub drawFont (x, y, c, Text$)
    '  Font(x,y,c,Text$) <- originally that, I changed the name for legibility reasons
    '      where:
    '      x = starting x coordinate
    '      y = starting y coordinate
    '      c = text color
    '      Text$ = the string to display
    '
    '      on 320 width screens, use less than 37 chars.
    '      on 640 width screens, use less than 74 chars.
    '
    d = Point(x, y)
    PSet (x, y), d
    color$ = Str$(c)
    Draw "c" + color$ + "bl3"

    For h = 1 To Len(Text$)
        char$ = Mid$(Text$, h, 1)
        Draw "br3"
        Draw dfont$(Asc(char$))
        Draw "c" + color$
    Next h
End Sub

Sub build_font
    'storing the font draw commands in a string array
    For ch = 0 To 255 'lets build a whole 256 character font, even if a bunch are just blank
        dfont$(ch) = "br6 "
    Next ch
    ch = Asc("A"): dfont$(ch) = "u4m+3,-8m+3,+8l6r6d4"
    ch = Asc("B"): dfont$(ch) = "u12r4f2d2g2l4r4f2d2g2l4r4br2"
    ch = Asc("C"): dfont$(ch) = "br6bu2g2l2h2u8e2r2f2bd10"
    ch = Asc("D"): dfont$(ch) = "u12r4f2d8g2l4br6"
    ch = Asc("E"): dfont$(ch) = "br6l6u6r4l4u6r6bd12"
    ch = Asc("F"): dfont$(ch) = "u6r4l4u6r6bd12"
    ch = Asc("G"): dfont$(ch) = "br3bu5r3d3g2l2h2u8e2r2f2bd10"
    ch = Asc("H"): dfont$(ch) = "u12d6r6u6d12"
    ch = Asc("I"): dfont$(ch) = "brru12lr2ld12r"
    ch = Asc("J"): dfont$(ch) = "bu4d2f2r2e2u10bd12"
    ch = Asc("K"): dfont$(ch) = "u12d6r2m+4,-6m-4,+6m+4,+6"
    ch = Asc("L"): dfont$(ch) = "u12d12r6"
    ch = Asc("M"): dfont$(ch) = "u12m+3,+6m+3,-6d12"
    ch = Asc("N"): dfont$(ch) = "u12m+6,+12u12bd12"
    ch = Asc("O"): dfont$(ch) = "br2h2u8e2r2f2d8g2l2br4"
    ch = Asc("P"): dfont$(ch) = "u12r4f2d2g2l4d6br6"
    ch = Asc("Q"): dfont$(ch) = "br2h2u8e2r2f2d8g2l2bu4f4"
    ch = Asc("R"): dfont$(ch) = "u12r4f2d2g2l4r3m+3,+6"
    ch = Asc("S"): dfont$(ch) = "bu2f2r2e2u2h2l2h2u2e2r2f2bd10"
    ch = Asc("T"): dfont$(ch) = "br3u12l3r6l3d12br3"
    ch = Asc("U"): dfont$(ch) = "bu12d10f2r2e2u10bd12"
    ch = Asc("V"): dfont$(ch) = "bu12m+4,+12m+4,-12bd12"
    ch = Asc("W"): dfont$(ch) = "br2h2u10bd12br2e2u6d6f2e2u10bd12"
    ch = Asc("X"): dfont$(ch) = "m+6,-12bl6m+6,+12"
    ch = Asc("Y"): dfont$(ch) = "bu12d3f3e3u3bd3bg3d6br3"
    ch = Asc("Z"): dfont$(ch) = "bu12r6m-6,+12r6"
    ch = Asc("1"): dfont$(ch) = "bu8m+2,-4d12"
    ch = Asc("2"): dfont$(ch) = "bu10e2r2f2d2g6d2r6"
    ch = Asc("3"): dfont$(ch) = "bu10e2r2f2d2g2l2r2f2d2g2l2h2br6bd2"
    ch = Asc("4"): dfont$(ch) = "bu4m+5,-8d8r2l7r5d4br2"
    ch = Asc("5"): dfont$(ch) = "bm+6,-12l6d4r4f2d4g2l2h2bm+6,+2"
    ch = Asc("6"): dfont$(ch) = "bu6e2r2f2d4g2l2h2u8e2r2f2bd10"
    ch = Asc("7"): dfont$(ch) = "bu12r6m-3,+8d4br3"
    ch = Asc("8"): dfont$(ch) = "br2h2u2e2r2l2h2u2e2r2f2d2g2f2d2g2l2br4"
    ch = Asc("9"): dfont$(ch) = "be6bu2g2l2h2u2e2r2f2d8g2l2h2bm+6,+2"
    ch = Asc("0"): dfont$(ch) = "bu2u8e2r2f2d8g2l2h2m+6,-8bd10"
    ch = Asc("."): dfont$(ch) = "ud"
    ch = Asc(","): dfont$(ch) = "brudge"
    ch = Asc("!"): dfont$(ch) = "brubu3u8bd12"
    ch = Asc("?"): dfont$(ch) = "bu8u2e2r2f2d2g3dbd3dbr3"
    ch = Asc("'"): dfont$(ch) = "bu10u2bd12"
    ch = Asc("*"): dfont$(ch) = "bu6bee4bebl6bff4bfbu3l6bd9br6"
    ch = Asc("\"): dfont$(ch) = "bu12m+6,+12"
    ch = Asc("/"): dfont$(ch) = "m+6,-12bd12"
    ch = Asc("("): dfont$(ch) = "br3rlh2u8e2rbd12"
    ch = Asc(")"): dfont$(ch) = "bu12rf2d8g2lbr3"
    ch = Asc("$"): dfont$(ch) = "bu4f2r2e2h2l2h2e2r2f2bu2bl3u2bd12u2bd2br3"
    ch = Asc(" "): dfont$(ch) = "br6"
    ch = Asc("a"): dfont$(ch) = "br2h2u2e2r2f2u2d6u2g2l2br4"
    ch = Asc("b"): dfont$(ch) = "u12d8e2r2f2d2g2l2h2bf2br4"
    ch = Asc("c"): dfont$(ch) = "br6bugl3h2u2e2r3fbd5"
    ch = Asc("d"): dfont$(ch) = "br6u2g2l2h2u2e2r2f2u8d12"
    ch = Asc("e"): dfont$(ch) = "br6bugl3h2u2e2r2f2dl6bd3br6"
    ch = Asc("f"): dfont$(ch) = "br2u10e2f2bl2bd4l4br5bd6"
    ch = Asc("g"): dfont$(ch) = "be6d2h2l2g2d2f2r2e2u2d6g2l2h2bu2br6"
    ch = Asc("h"): dfont$(ch) = "u12d8e2r2f2d4"
    ch = Asc("i"): dfont$(ch) = "bru5bu2ubd8"
    ch = Asc("j"): dfont$(ch) = "brbu8dbd2d8glhbe3"
    ch = Asc("k"): dfont$(ch) = "u12d10e4g2f4"
    ch = Asc("l"): dfont$(ch) = "bru12d12"
    ch = Asc("m"): dfont$(ch) = "u6d2e2f2d4u4e2f2d4"
    ch = Asc("n"): dfont$(ch) = "u6d2e2r2f2d4"
    ch = Asc("o"): dfont$(ch) = "br2h2u2e2r2f2d2g2l2br4"
    ch = Asc("p"): dfont$(ch) = "d4u10d2e2r2f2d2g2l2h2f2br4"
    ch = Asc("q"): dfont$(ch) = "br6u6d2h2l2g2d2f2r2e2d6u4"
    ch = Asc("r"): dfont$(ch) = "u6d2e2r3fbd5"
    ch = Asc("s"): dfont$(ch) = "bufr4euhl4huer4fbd5"
    ch = Asc("t"): dfont$(ch) = "bu8r2lu4d11frebd"
    ch = Asc("u"): dfont$(ch) = "bu6d4f2r2e2u4d6"
    ch = Asc("v"): dfont$(ch) = "bu6m+3,+6m+3,-6bd6"
    ch = Asc("w"): dfont$(ch) = "bu6d4f2e2u2d2f2e2u4bd6"
    ch = Asc("x"): dfont$(ch) = "e6bl6f6"
    ch = Asc("y"): dfont$(ch) = "bu6m+3,+6m+3,-6m-3,+6m-2,+4bu4br5"
    ch = Asc("z"): dfont$(ch) = "bu6r6g6r6"
    ch = Asc("#"): dfont$(ch) = "bubr2u2l2r2u6d2l2r4u2d2r2l2d4r2l4r2d2br2bd"
    ch = Asc("@"): dfont$(ch) = "br6l4h2u4e2r2f2d2g2l2u4r2d4br2bd2"
    ch = Asc("%"): dfont$(ch) = "m+6,-12bl5fghebr4bd12hefgbr"
    ch = Asc("^"): dfont$(ch) = "bu9e3f3bd9"
    ch = Asc("&"): dfont$(ch) = "br6m-5,-8u2erfd2g4d2f2r2m+2,-4bd4"
    ch = Asc(">"): dfont$(ch) = "e6h6bf6bd6"
    ch = Asc("<"): dfont$(ch) = "br6h6e6bd12"
    ch = Asc("-"): dfont$(ch) = "bu5r6bd5"
    ch = Asc("=."): dfont$(ch) = "bu6r6bd2l6bd4br6"
    ch = Asc("+"): dfont$(ch) = "br3bu2u6bg3r6bd5"
    ch = Asc(":"): dfont$(ch) = "brubu3ubd5"
    ch = Asc("`"): dfont$(ch) = "bu10u2bd12"
    ch = Asc("~"): dfont$(ch) = "bu11er2fr2ebd12"
    ch = Asc("_"): dfont$(ch) = "r6"
    ch = Asc("{"): dfont$(ch) = "br5h2u2ehlrehu2e2bd12"
    ch = Asc("}"): dfont$(ch) = "br2e2u2herlheu2h2bd12br3"
    ch = Asc("["): dfont$(ch) = "r2l2u12r2bd12"
    ch = Asc("]"): dfont$(ch) = "r2u12l2r2d12"
    ch = Asc(";"): dfont$(ch) = "brudgeubu3ubd5"
    ch = 34: dfont$(ch) = "brbu10u2br2d2bd10"
    ch = Asc("|"): dfont$(ch) = "bru5bu2u5bd12"

End Sub
Reply
#12
Here's another one I found looking through an old HD.  Again, not sure where this one came from either, it's been so many years now.  More than likely it's from one of the ABC code packets.  I did make some things like this in the 90's, but don't think this is one of them.

- Dav

Code: (Select All)
DEFINT A-Z
DECLARE SUB EYEPRINT (x%, y%, FONTCOLOR%, TEXT$)

SCREEN 13
FOR t% = 6 TO 193 STEP 6
    EYEPRINT 2, t%, t%, "01234567890abcdefghijklmnopqrstuvwxyz.,/?\+-()"
NEXT
SLEEP

SUB EYEPRINT (x%, y%, FONTCOLOR%, TEXT$)

    DRAW "C" + STR$(FONTCOLOR%) + "BM" + STR$(x%) + "," + STR$(y%)

    FOR a% = 1 TO LEN(TEXT$)
        SELECT CASE UCASE$(MID$(TEXT$, a%, 1))
            CASE "0": DRAW "BE1R2E1U1H1L2G1D1BD2BR6"
            CASE "1": DRAW "BR1R2L1U4G1BL1BD3BR6"
            CASE "2": DRAW "R4L3U1E1R1E1H1L3BD4BR6"
            CASE "3": DRAW "R3E1H1L2R2E1H1L3BD4BR6"
            CASE "4": DRAW "BR4U4D2L4U2BD4BR6"
            CASE "5": DRAW "R3E1H1L3U2R4BD4BR2"
            CASE "6": DRAW "BR1R2E1H1L3D1U2E1R3BD4BR2"
            CASE "7": DRAW "BR2U2E2L4BD4BR6"
            CASE "8": DRAW "BR1R2E1H1L2G1BU2E1R2F1BD3BR2"
            CASE "9": DRAW "BR4U3H1L2G1F1R3BD2BR2"
            CASE " ": DRAW "BR6"
            CASE "A": DRAW "BR1R3U2L3G1BU3BR1R2F1BD3BR2"
            CASE "B": DRAW "R3E1H1L3U2D4BR6"
            CASE "C": DRAW "BU1U1E1R3BD3L3BR5"
            CASE "D": DRAW "BR1R2E1U3D2L3G1BD1BR6"
            CASE "E": DRAW "BU1U2E1R2F1G1L2BD2R3BR2"
            CASE "F": DRAW "BU2R4BU2L1G1D3BR4"
            CASE "G": DRAW "R3E1U2H1L2G1F1R3BD2BR2"
            CASE "H": DRAW "U4D2R3F1D1BR2"
            CASE "I": DRAW "BR1U1BU2R0BD3BR5"
            CASE "J": DRAW "BU1F1R1E1BU2R0BD3BR3"
            CASE "K": DRAW "U4BR4G2L2R2F2BR2"
            CASE "L": DRAW "U3D3R4BR2"
            CASE "M": DRAW "U4F2E2D4BR2"
            CASE "N": DRAW "U3D2E2R1F1D2BR2"
            CASE "O": DRAW "BE1R2E1U1H1L2G1D1BD2BR6"
            CASE "P": DRAW "U2R3E1H1L2G1D2BR6"
            CASE "Q": DRAW "BU1U2E1R2F1D3L3R2U1H1BD2BR4"
            CASE "R": DRAW "U3F1E1F1BD2BR2"
            CASE "S": DRAW "R3E1H1L2H1E1R3BD4BR2"
            CASE "T": DRAW "BR2U4D1L2R4BD3BR2"
            CASE "U": DRAW "BE1R2E1U2BL4D2BD2BR6"
            CASE "V": DRAW "BU2F2E2BD2BR2"
            CASE "W": DRAW "U4BR4D4H2G2BR6"
            CASE "X": DRAW "E4BL4F4BR2"
            CASE "Y": DRAW "BU3F2D1U1E2BD3BR2"
            CASE "Z": DRAW "R4BL2H1E2L3BD3BR6"
            CASE ".": DRAW "BR1R0BR5"
            CASE "(": DRAW "BR3L1H2R1U1E1R1BD4BR3"
            CASE ")": DRAW "BR1R1E1U1R1L1U1H1L1BD4BR5"
            CASE "!": DRAW "BR1R1BU2U2L1D2BD2BR5"
            CASE "+": DRAW "BR2BU1U2D1L1R2BD2BR3"
            CASE "-": DRAW "BU2BR1R2BD2BR3"
            CASE ":": DRAW "BR2BU1R0BU2R0BD3BR4"
            CASE "\": DRAW "BU4F4BR2"
            CASE "/": DRAW "E4BD4BR2"
            CASE "@": DRAW "BU1U2E1R2F1L2G1BR2R1G1L1G1R3BR2"
            CASE "?": DRAW "BR3U1BU2U1E1H1L2G1BM+6,+5"
            CASE ",": DRAW "BR1R1D1BM+5,-1"
        END SELECT
    NEXT
END SUB

Find my programs here in Dav's QB64 Corner
Reply
#13
I never messed with draw much back in the old before times because I used to feel it was a bit of a dog but these days... it just isn't as slow because the machines aren't as slow.
Reply




Users browsing this thread: 1 Guest(s)