TEXTOUT_P : width ?
|
10-02-2015, 08:41 AM
(This post was last modified: 10-02-2015 08:41 AM by primer.)
Post: #1
|
|||
|
|||
TEXTOUT_P : width ?
Hello,
I would like to know the width of a rendered text with TEXTOUT_P. is there a way to evaluate it ? Also by taking into account that TEXTOUT_P does use font size from home setting if not specified. (user guide page 588) I'm looking for something similar than TTF_SizeText from SDL, for the ones who knows. Thank you, Regards. primer |
|||
10-02-2015, 09:17 AM
Post: #2
|
|||
|
|||
RE: TEXTOUT_P : width ?
No such function. We need to implement it ourselves.
It needed for text editor and formula editor (to edit and print formula in natural notation), since HP does not provide such functions. I also missing natural notation in notes, so custom editor is must-have. We can't expect these features in next firmware update (i expect maximum Search-Replace in editor). So the rescue of drowning are business of drowning themselves! |
|||
10-02-2015, 12:51 PM
Post: #3
|
|||
|
|||
RE: TEXTOUT_P : width ?
I think it can be done. I have an idea but I don't know if it will be fast enough.
Piotr Kowalewski |
|||
10-03-2015, 08:56 AM
(This post was last modified: 10-03-2015 09:02 AM by komame.)
Post: #4
|
|||
|
|||
RE: TEXTOUT_P : width ?
I created a function that calculates the width (in pixels) of the text, but it is not very useful, because it is very slow.
However, I believe that it is possible to optimize and significantly speed up. I have some ideas. Code: TEXT_P_W(); function TEXT_P_W(t,s), where: t - the text to calculate width s - font size Piotr Kowalewski |
|||
10-03-2015, 05:42 PM
Post: #5
|
|||
|
|||
RE: TEXTOUT_P : width ?
(10-03-2015 08:56 AM)komame Wrote: I created a function that calculates the width (in pixels) of the text, but it is not very useful, because it is very slow. Having fixed fonts maybe is faster just having an array with the known char widths per font size My website: ried.cl |
|||
10-03-2015, 07:45 PM
Post: #6
|
|||
|
|||
RE: TEXTOUT_P : width ?
This is the fastest way I found to calculacte the width and height of the text.
The following functions should take less than 2ms. Width: Code: TEXTW_P(t,s) Height: Code: TEXTH_P(t,s) as before: t - text for check the width or height s - font size (0 = default from Home settings) During the performance tests when I created this solution I think I detected a bug (very little) in the function TEXTOUT_P, but I will write about this in a separate thread. Piotr Kowalewski |
|||
10-04-2015, 04:21 PM
Post: #7
|
|||
|
|||
RE: TEXTOUT_P : width ?
After minor changes I managed to get a little faster version.
The time required for the calculation is ~1.5ms for width and ~0.9ms for height. Width v2: Code: TEXT_P_W(t,s) Height v2: Code: TEXT_P_H(t,s) Piotr Kowalewski |
|||
10-05-2015, 03:04 PM
Post: #8
|
|||
|
|||
RE: TEXTOUT_P : width ?
Thank you very much komame, it's really appreciated.
I was afraid about performance, but that's OK. best regards, primer |
|||
10-12-2015, 11:58 AM
(This post was last modified: 10-12-2015 12:00 PM by Tyann.)
Post: #9
|
|||
|
|||
RE: TEXTOUT_P : width ?
Bonjour
Ces deux fonctions sont très utiles, bravo et merci Si je peut me permettre une suggestion. Ici vous utilisez G9, et cela peut engendrer un conflit, si le programmeur n'y pense pas. Il est possible de mettre en paramètres la variable Gx à utiliser ainsi le programmeur qui utilisera vos fonctions choisira lui même. Qu'en pensez-vous ? Hello These two functions are very useful, congratulations and thank you If I may make a suggestion . Here you use G9, and this may create a conflict if the programmer does not think . You can set parameters to use the variable Gx and the programmer who will use your duties will choose itself. What do you think ? Code:
Sorry for my english |
|||
10-14-2015, 10:02 PM
Post: #10
|
|||
|
|||
RE: TEXTOUT_P : width ? | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)