Page 1 of 1

Are any of the fonts in Smart Basic fixed ratio

Posted: Fri May 01, 2015 4:10 pm
by apurvis57
I am creating a screen with the patients name in a standard position and I want to draw a rectangle around the name. However, different length names end in different positions which has prevented me from predicting where the rectangle points should be. I have tried to create a font ratio to multiply the character lenghth by but becauses of different aspects of letters it is not easily predictable. Are any of the fonts in the basic program fixed ratio or fixed aspect?

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Fri May 01, 2015 4:14 pm
by Mr. Kibernetik
Please check fonts which are available in iOS - all of them are available in smart BASIC.
As far as I know, Courier font is a monospace font.
Also you can use your own fonts in smart BASIC.

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Fri May 01, 2015 5:31 pm
by basiccode
If you use TEXT_WIDTH (text$) and TEXT_HEIGHT (text$) you can get an accurate font size for the selected draw font which you can use for setting bounding boxes around text$

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Fri May 01, 2015 5:37 pm
by apurvis57
basiccode wrote:If you use TEXT_WIDTH (text$) and TEXT_HEIGHT (text$) you can get an accurate font size for the selected draw font which you can use for setting bounding boxes around text$
Ahhhh. That would be better as it would not restrict me to fixed ratio fonts as I am trying to put as much data on a screen as possible (a dashboard screen) and that would allow the more compressed/condensed fonts and thus more data on a single screen. Thanks I will try that.

I tried the text width. It returns a value but it is inaccurate. It underestimates the length of the string and the bounding box is too short? Seems to be a problem even with different fonts. I didn't try different font sizes but if it is limited to one font size it would not help me.

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Sat May 02, 2015 2:00 pm
by apurvis57
I tried using text_width to determine the length of my text. It underestimated the length of the text. I tried 2 different fonts and had the same problem. I tried correcting it by multiplying it by a ratio number but it wasn't consistent depending on the length of the name.

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Sat May 02, 2015 2:08 pm
by Mr. Kibernetik
apurvis57 wrote:I tried using text_width to determine the length of my text. It underestimated the length of the text. I tried 2 different fonts and had the same problem. I tried correcting it by multiplying it by a ratio number but it wasn't consistent depending on the length of the name.
Can you provide a sample of your code which demonstrates how you get the value and how it is proved to be wrong?
Because these functions should return correct values.

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Sun May 03, 2015 9:35 pm
by apurvis57
Rem ....................... Header and Footer ...........................
headerfooter:
maxx = screen_width()
maxy = screen_height()
graphics
graphics clear r(1),g(1),b(1)
randomize
ptindex=1
shadow off
headerheight=40
footerheight=40
headerfootermargin=40
vertheadermargin=6
headerlength=0
r(2)=.63
g(2)=.63
b(2)=.63
draw color 0,0,0
fill color r(2),g(2),b(2)

draw size 1
fname$(1)="Sylvester"
lname$(1)="Alexander"
draw font name "Avenir-Medium"

fill rect 0,0 to maxx,headerheight
fill rect 0,maxy-footerheight to maxx,740

draw font size 22
text$=lname$&", "&fname$(ptindex)
namelength=text_width(text$)

draw text text$ at headerfootermargin,vertheadermargin
draw rect headerfootermargin-10,vertheadermargin-3 to namelength+headermargin+10, headerheight-5

I print the text and try and draw a rectangle around this and it is shorter than the text.

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Sun May 03, 2015 9:59 pm
by Mr. Kibernetik
You are just drawing your rectangle with wrong coordinates.

Re: Are any of the fonts in Smart Basic fixed ratio

Posted: Sun May 03, 2015 10:09 pm
by apurvis57
In the process of copying portion of program for an example, clearing unneeded code it is working now. Sorry to be such a rookie.