No line spacing when using drawline #1930
Replies: 35 comments
-
Posted at 2020-06-30 by @fanoush Looks like bug, there is now new vector font which is larger for same point size (e.g. size 26 now is similar to older size 30) so maybe some line pixel size constant was not updated somewhere in drawString code |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-30 by gerardwr Thanks for your comment, would be my 1st reported bug ;-) BTW. Running latest version 2V06, but 2v05.97 of the Emulator has the same behaviour. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by @fanoush well it uses customHeight here https://github.com/espruino/Espruino/blob/master/libs/graphics/jswrap_graphics.c#L1374 and it is read here https://github.com/espruino/Espruino/blob/master/libs/graphics/jswrap_graphics.c#L1322 and this call returns value 'scale' here https://github.com/espruino/Espruino/blob/master/libs/graphics/jswrap_graphics.c#L1280 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by @gfwilliams Yes, this sounds like the new vector font... @nebbishhacker any strong feelings about this? I think it makes sense to keep the line height the same as the vector font height, so I guess we should just tweak the font size down slightly? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by NebbishHacker Currently the font size accurately represents the height of letters like A, but it doesn't take into account accented characters (like À) or descenders (like j). Accents and descenders both currently protrude by about 1/4 of the font height, so the actual maximum height of a line of text is 1.5 times what you might expect. For some stuff I'm currently working on it would be convenient if Overall, though, I don't have very strong feelings about whether we should tweak the font size. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by gerardwr As can be seen in the picture the beginletters of the lines (T B C) have zero spacing. And in the case of "accents and descenders" the characters in successive line overlap. I am too using g.clearRect to clear the result of a g.drawString and would expect to clear all pixels of drawString characters. Didn't know that this currently NOT the case. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by gerardwr In analogy with http://forum.espruino.com/conversations/302392/ I coded a "drawString" override that introduces proper line spacing in Strings witch "\n" newlines in it. In this case I have chosen for 5 pixels of space between each line.. Rather new to Espruino so maybe not the best solution, but it works for me. Hopefully Gordon will come up with a structural solution. Example code:
And the resulting output: Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by NebbishHacker So for reference: I flashed 2v05.1 onto a watch for comparison, and it looks like the old vector font exhibited the same issue with descenders overlapping the next line.Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by gerardwr OK, but in your picture at least there is 1 pixel between each successive line (between the T, B and C character). I'm running 2V06 on Bangle, and the 1 pixel spacing between the T,B, and C char is not there. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by NebbishHacker @gerardwr - That looks like a good solution to me, although I would have personally made an entirely new function named drawLines or something instead of overriding g.drawString. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by NebbishHacker If you look closely the B and the C are touching at one point, so even the 1 pixel space is not always there. In any case, I imagine you would generally want a bit more space between lines than that. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by gerardwr Fair enough, your suggestion is cleaner. But I wanted a "fix" for the drawString problem. Found my inspiration here http://forum.espruino.com/conversations/302392/ and thought "hey that's clever" and coded away. I'm a lazy coder, so in this way I did not have to change my code ;-) And if Gordon comes up with a fix to "drawString" I delete the override and I'm ready. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-01 by gerardwr Agree, 1 pixel of line-spacing is not enough, so in my override I used 5 pixels, that seems also enough for descendents. For now ...., have been using the "fix" only for a few hours. Output looks like this now:Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-02 by @gfwilliams Hmm, that's tricky.
While not quite as pretty, I think that is probably the best solution here, and it's definitely the least hacky :) I'll see about tweaking that... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-02 by gerardwr @gfwilliams - I guess this means that we can forget about a "structural solution"for the problem on the short term, and I will have to live with my Maybe I will add the |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-02 by gerardwr Changed my Not extensively tested, but seems to work ok for me. It saves a lot of Comments and suggestions welcome! Code is like this:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-02 by gerardwr @nebbishhacker My app is currently limited to text, I'm a lazy programmer, so this was the most efficient solution for me now. When I get to the graphics part of my app I will remember your suggestion, thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-02 by gerardwr Fixed a bug in my override function, updated the code in the post above. And also found some flaws in my override code. If the Back to the drawing board :-( |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-03 by gerardwr @nebbishhacker Here's my latest code including a random 'drawString` to check that the override is now OK. Seems that it's perfect for me now. Ofcourse it requires some bookkeeping of the m variable if you change to a complete different screen.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-03 by gerardwr BTW, I expected that |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-04 by @fanoush With framebuffer in memory created by Graphics.createArrayBuffer the behaviour is that after resetting it returns With display this is used so that in g.flip() implementation you know which area is modified and must be send to the display. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-04 by gerardwr If thought that it would have been more logical that Just my opinion. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-04 by @fanoush unless you call g.clear() or clearRect for whole screen it is indeed strange to get whole screen. just note that with true parameter it still returns modified region bu then clears it so with next call you should get |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-04 by gerardwr I've been working with Espruino for Bangle now for some days. Javascript a an "experience" after many years of Arduino ;-) Must say that Gordon has created a terrific environment with Espruino, excellent documentation and a fantastic development platform on the BangleJS. Kudo's to him. After the limited 1-week experience with Espruino I love the environment for prototyping. The "nasties" I experience(like with getModified" are limited, and I can live with them. The fun is in the "learning", right? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-04 by @allObjects @gerardwr, glad to hear that. In deed, it IS an experience... quite different from what MCs were for decades. Having started out with MPs 8085/Z80/Z80/6502/68XX/68K and briefly (now defunct) Ubicon SX for control I liked very much the advent of Arduino, but before I really sunk my teeth into it, I came across Espruino and in less than a blink of an eye I dropped my H and $ investment in Arduino and moved on with Espruino. For certain things though I ran into limits, some of which can be overcome using compiled JS and inline C, and some other that require really dedicated, low level coded hardware is needed to do time sensitive things with strict tolerances, repetitive and over a longer time. For those things dedicated atTiny versions do just fine that receive commands from Espruino and return interrupts / values. For most part though I can stay in JS layer. And that makes it really fun. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-04 by gerardwr @allObjects - Ok, off-topic. We seem to have a similar 'senior' background, I started decades ago with the Intel's like 8080/Z80,80x86 then moved to AVR-Arduino, in the last years ESP8266/ESp32. Really love the ESP's for their Wifi connection. It runs Arduino, Micropython and Espruino. Nothing else needed........ EXCEPT for wearables... they're power hungry beasts Just for fun I bought an NRF52832 development board to dable with BLE. Tried Arduino (works fine), Micropython (so,so) and Espruino. Was to lazy to solder a TFT display tot the NRF52832 so I'm using Bangle now. Considering my background Javascript is little "quirky" but the help from the forum I'm getting there. Also great info on NRF52832 on gitter here if you're interested in the hard-core details : https://gitter.im/nRF51822-Arduino-Mbed-smart-watch/Lobby There's 1 thing I miss in Bangle/Espruino : a Wifi connection!! My Bangle App is "done" but it needs feeding data from the internet. So I'm testing tools on Raspberry that function as a bridge between the internet and the Bangle. Exciting timings :-) All in all, @gfwilliams is doing a tremendous job! Cheers, see you! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-07 by @gfwilliams @gerardwr can you come up with some code that causes the Seems to work great for me:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-07 by gerardwr Hi @gfwilliams, thanks for getting back to me. Yes, your example works fine, as intended:
But ........ I have an App where sometimes (depending on the code) there is no drawing done, when I clear the I thought it would be more applicable if I don't get the logic for resetting to the entire screen, am I missing something? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-07 by @gfwilliams
It is... It is set to It would be clearer for me if you gave an example of what isn't working as you expect. As @fanoush said, most likely what's happening is you're clearing the whole screen with I guess it's possible that |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-07-07 by gerardwr Hmmmmmm, major error on my part :-( My code from the emulator:
Output is:
I see now dat getModified(true) returns an Apologies for wasting your time (red face), appreciate the help. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-30 by gerardwr
Hi,
When I use code like this
the "\n" creates a newline, works fine, nice feature.
But there is no spacing between the lines so the result is not very readable. In all cases the characters of the lines "touch" and in some cases characters of lines even "overlap" ( see picture in annex ).
Searched the documentation for a line-space setting, but did not find it.
Is there a line-space setting, and if not, is it a suggestion to add one?
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions