Are any of the fonts in Smart Basic fixed ratio

Post Reply
apurvis57
Posts: 7
Joined: Sat Apr 18, 2015 6:35 pm
My devices: macbook, ipad, iphone

Are any of the fonts in Smart Basic fixed ratio

Post 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?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

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

Post 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.

basiccode
Posts: 100
Joined: Wed Feb 12, 2014 12:21 pm

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

Post 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$

apurvis57
Posts: 7
Joined: Sat Apr 18, 2015 6:35 pm
My devices: macbook, ipad, iphone

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

Post 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.

apurvis57
Posts: 7
Joined: Sat Apr 18, 2015 6:35 pm
My devices: macbook, ipad, iphone

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

Post 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.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

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

Post 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.

apurvis57
Posts: 7
Joined: Sat Apr 18, 2015 6:35 pm
My devices: macbook, ipad, iphone

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

Post 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.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

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

Post by Mr. Kibernetik »

You are just drawing your rectangle with wrong coordinates.

apurvis57
Posts: 7
Joined: Sat Apr 18, 2015 6:35 pm
My devices: macbook, ipad, iphone

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

Post 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.

Post Reply