How to compute text length - e.g. for printing?
Moderator: Rathinagiri
How to compute text length - e.g. for printing?
I need to compute text length for given font. Can somebody help me?
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to compute text length - e.g. for printing?
Yes. Here it is. The returned length is somewhat accurate.
It is used in GridPrint. The returned value is in mm.
It is used in GridPrint. The returned value is in mm.
Code: Select all
function printLen( cString,nFontsize,cFontname)
return round(gettextwidth(Nil,cString,cFontname)*0.072/72*25.4*nFontsize,2)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to compute text length - e.g. for printing?
Most welcome.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: How to compute text length - e.g. for printing?
Hi everybody!
I need to return to this topic.
The method below computes text length with big margin of error when bold or italic is turned on.
I've added experimental factor = 1.2 for bold font, but, it isn't what I want
Do you know better method?
Regards, Marek
Everything looks ALMOST fine for ARIAL font (too big error with too much capital letters) , but looks very bad with ARIAL NARROW FONT:
I drew lines with length of computed text witdth...
I need to return to this topic.
The method below computes text length with big margin of error when bold or italic is turned on.
I've added experimental factor = 1.2 for bold font, but, it isn't what I want
Do you know better method?
Regards, Marek
Code: Select all
function printLen( cString,nFontsize,cFontname)
return round(gettextwidth(Nil,cString,cFontname)*0.072/72*25.4*nFontsize,2)
I drew lines with length of computed text witdth...