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


Messages In This Thread
Draw for scalable font? - by James D Jarvis - 05-13-2022, 01:02 PM
RE: Draw for scalable font? - by SMcNeill - 05-13-2022, 01:36 PM
RE: Draw for scalable font? - by James D Jarvis - 05-13-2022, 02:34 PM
RE: Draw for scalable font? - by bplus - 05-13-2022, 02:06 PM
RE: Draw for scalable font? - by James D Jarvis - 05-13-2022, 02:32 PM
RE: Draw for scalable font? - by James D Jarvis - 05-15-2022, 03:14 AM
RE: Draw for scalable font? - by Dav - 05-16-2022, 10:26 PM
RE: Draw for scalable font? - by James D Jarvis - 05-17-2022, 11:23 AM
RE: Draw for scalable font? - by bplus - 05-17-2022, 03:51 PM
RE: Draw for scalable font? - by James D Jarvis - 05-17-2022, 06:25 PM
RE: Draw for scalable font? - by James D Jarvis - 05-17-2022, 09:00 PM
RE: Draw for scalable font? - by Dav - 05-21-2022, 05:30 PM
RE: Draw for scalable font? - by James D Jarvis - 05-21-2022, 08:59 PM



Users browsing this thread: 8 Guest(s)