Turing Help (Font Commands
Posted: Tue Jan 13, 2004 5:46 pm
I have a question about the font.Draw command. Here's the basic code for my text procedure. It's suppose to get the font, what size they want, and the style of the font. After getting the information, it's suppose to use the same information to write text on the canvas. But everytime I run it, there's always an error. Somewhere around the fontID := Font.Draw line. ^^ If anybody can help me fix it or make my code grateful I'll be really happy. And just in case you're wondering, I'm still doing my paint program. It's due this Friday so the faster I get help the happier I'll be. ^^ Thanks.
import GUI
var x, y, butNum, butupdown, button, buttonnum, buttonupdown, col2 : int
var px, py, absX, absY : int
var words : string
var temppic : int
col2 := 0
var canvas : int := GUI.CreateCanvas (90, 85, 510, 245)
var fontID : int
proc myMouse (var x, y, b : int)
var absX, absY : int
Mouse.Where (absX, absY,
x := absX - 90
y := absY - 85
end myMouse
proc text
var fontName, font, size, style : string
var boxID : int := GUI.CreateTextBox (20, 390, 150, 65)
var winID, font11 : int
font11 := Font.New ("serif:12")
Font.Draw ("Font Names ", 20, 464, font11, 11)
Font.StartName
loop
fontName := Font.GetName
exit when fontName = ""
GUI.AddLine (boxID, fontName)
end loop
winID := Window.Open ("position:center;center,graphics:200;200")
put fontName
put "Type in name of font you wish to use: " ..
get font
put "Size:" ..
get size
put "Style (bold or italic) : " ..
get style
Window.Close (winID)
Mouse.ButtonWait ("down", x, y, butNum, butupdown)
temppic := Pic.New (90, 85, 600, 330)
myMouse (px, py, button)
loop
setscreen ("nocursor")
var ch : string (1)
if hasch then
getch (ch)
exit when ch = "q"
end if
var textbtn : int := GUI.CreateButtonFull (20, 130, 0, "Text", text, 0, '^T', true)
GUI.Disable (textbtn)
fontID := Font.New ("font : size")
GUI.PicDraw (canvas, temppic, 0, 0, picCopy)
loop
Mouse.Where (x, y, button)
setscreen ("cursor")
get words : *
GUI.FontDraw (canvas, words, x - 90, y - 85, fontID, 7)
end loop
end loop
end text
text
Archived topic from Iceteks, old topic ID:1908, old post ID:15611
import GUI
var x, y, butNum, butupdown, button, buttonnum, buttonupdown, col2 : int
var px, py, absX, absY : int
var words : string
var temppic : int
col2 := 0
var canvas : int := GUI.CreateCanvas (90, 85, 510, 245)
var fontID : int
proc myMouse (var x, y, b : int)
var absX, absY : int
Mouse.Where (absX, absY,
x := absX - 90
y := absY - 85
end myMouse
proc text
var fontName, font, size, style : string
var boxID : int := GUI.CreateTextBox (20, 390, 150, 65)
var winID, font11 : int
font11 := Font.New ("serif:12")
Font.Draw ("Font Names ", 20, 464, font11, 11)
Font.StartName
loop
fontName := Font.GetName
exit when fontName = ""
GUI.AddLine (boxID, fontName)
end loop
winID := Window.Open ("position:center;center,graphics:200;200")
put fontName
put "Type in name of font you wish to use: " ..
get font
put "Size:" ..
get size
put "Style (bold or italic) : " ..
get style
Window.Close (winID)
Mouse.ButtonWait ("down", x, y, butNum, butupdown)
temppic := Pic.New (90, 85, 600, 330)
myMouse (px, py, button)
loop
setscreen ("nocursor")
var ch : string (1)
if hasch then
getch (ch)
exit when ch = "q"
end if
var textbtn : int := GUI.CreateButtonFull (20, 130, 0, "Text", text, 0, '^T', true)
GUI.Disable (textbtn)
fontID := Font.New ("font : size")
GUI.PicDraw (canvas, temppic, 0, 0, picCopy)
loop
Mouse.Where (x, y, button)
setscreen ("cursor")
get words : *
GUI.FontDraw (canvas, words, x - 90, y - 85, fontID, 7)
end loop
end loop
end text
text
Archived topic from Iceteks, old topic ID:1908, old post ID:15611