Are any of the fonts in Smart Basic fixed ratio
Are any of the fonts in Smart Basic fixed ratio
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?
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Are any of the fonts in Smart Basic fixed ratio
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.
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
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
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.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$
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
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.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Are any of the fonts in Smart Basic fixed ratio
Can you provide a sample of your code which demonstrates how you get the value and how it is proved to be wrong?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.
Because these functions should return correct values.
Re: Are any of the fonts in Smart Basic fixed ratio
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.
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.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Are any of the fonts in Smart Basic fixed ratio
You are just drawing your rectangle with wrong coordinates.
Re: Are any of the fonts in Smart Basic fixed ratio
In the process of copying portion of program for an example, clearing unneeded code it is working now. Sorry to be such a rookie.