TEXTOUT_P : width ? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: TEXTOUT_P : width ? (/thread-4857.html) |
TEXTOUT_P : width ? - primer - 10-02-2015 08:41 AM 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. RE: TEXTOUT_P : width ? - xset - 10-02-2015 09:17 AM 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! RE: TEXTOUT_P : width ? - komame - 10-02-2015 12:51 PM I think it can be done. I have an idea but I don't know if it will be fast enough. RE: TEXTOUT_P : width ? - komame - 10-03-2015 08:56 AM 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 RE: TEXTOUT_P : width ? - eried - 10-03-2015 05:42 PM (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 RE: TEXTOUT_P : width ? - komame - 10-03-2015 07:45 PM 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. RE: TEXTOUT_P : width ? - komame - 10-04-2015 04:21 PM 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) RE: TEXTOUT_P : width ? - primer - 10-05-2015 03:04 PM Thank you very much komame, it's really appreciated. I was afraid about performance, but that's OK. best regards, RE: TEXTOUT_P : width ? - Tyann - 10-12-2015 11:58 AM 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:
RE: TEXTOUT_P : width ? - hpfx - 10-14-2015 10:02 PM (10-12-2015 11:58 AM)Tyann Wrote: What do you think ?I think it could be a builtin command. and as a bonus, you even don't need to choose a graphic var. |