
-----------------------------------
Fexter
Tue May 01, 2012 9:21 pm

Font.Draw With Rows / Columns (Text.Locate())?
-----------------------------------
What is it you are trying to achieve?
I want to be able to center text that I enter. I found a way to do this with Text.Locate(), but I need to be able to have this work for Font.Draw() as I have a special font that I am using other than the normal put font.

What is the problem you are having?
I can't seem to find a way to use rows and columns, and pixels make it a lot tougher to center the text.


Describe what you have tried to solve this problem
I have tried checking the Turing Documentation for something that would work with this.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



procedure center (text:string)
    Text.Locate(12, 40 - length(text) div 2) % Center the text location
    put text % I want to change this to Font.Draw() for my specific font
end center

center("Hello World!")



Please specify what version of Turing you are using
Turing 4.1.1.

-----------------------------------
Amarylis
Tue May 01, 2012 9:37 pm

Re: Font.Draw With Rows / Columns (Text.Locate())?
-----------------------------------
If you're looking for the very center of the window, then it'd be something like this


Font.Draw (maxx div 2 - length(text) div 2, maxy div 2, font, black)


-----------------------------------
Fexter
Tue May 01, 2012 9:53 pm

RE:Font.Draw With Rows / Columns (Text.Locate())?
-----------------------------------
@Amarylis
I've tried that several times, and it's never worked (The letters seem to have different lengths -- For example, the letter R is longer than l). However, Font.Width() seems to work with what I want, so I can use that.. :D

-----------------------------------
Amarylis
Tue May 01, 2012 10:17 pm

RE:Font.Draw With Rows / Columns (Text.Locate())?
-----------------------------------
..Whoops, confused length with Font.Width

-----------------------------------
evildaddy911
Wed May 02, 2012 2:35 pm

Re: Font.Draw With Rows / Columns (Text.Locate())?
-----------------------------------
ive had that same problem, so i made this procedure

procedure centerfont (text:string, x, y, font, color:int)
Font.Draw (text, x - Font.Width (text, font) div 2, y, font, color)
end centerfont

the x is where the center of the text is located
