-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVG Row #11
Comments
The image above is using a row with background and overlay. Hi @sabof I've got a few notes / questions / etc. that I'd like you input on...
Any ideas? |
Yes, because the form is evaluated once, upon definition. You need the fields to accept functions. |
Right |
I guess I can use
|
Any ideas on determining pixel width of a row @sabof? |
I guess that each widget would have to provide a pixel width, which we fold. |
You can multiply it by |
Or at least all internal calculations where to be done in pixels. |
Is frame char width how it derives the row width? I assumed that different font sizes of widget text might affect this measurement. Ps. |
The width is used when calculating whether widgets overlap. The system doesn't know about font sizes. What is the code? |
What is needed is for a widget to return its width in pixels, ie. smt/w-pixel-width Then it's a case of foldl / reduce on the row's widgets to get the correct pixel width. If we assume 72 or 96 ppi we can do the approximate math. Unfortunately though we will have an issue thanks to proportional fonts, before we get a true value. Let's just put a pin in this for now. We may be able to do some off screen rendering and image measurement, but I think it's going to be trouble. |
The code just changes the above s/5.5/(frame-char-width)/ |
Oh, I see I didn't post the original. In a nutshell: a svg rect inside a lambda (row)
|
the original factor was 5.5 instead of frame-char-width ... It does show that some level of approximation is useful here though. |
It's worth noting that with more accurate measures we won't be hiding rows that would actually fit. |
Never mind, I've assumed the error messages where significant. Might it be possible to wrap the row container within SVG? |
It might even be possible for it manage hiding, by putting a large line-height somewhere. |
I've done this with my scratch of SVG container, positioned by align. (background and overlay support.) The only things left are
|
Tidied up
|
Just noticed I typo'ed frame-char-size instead of frame-char-width |
Added basic left / right padding support (only applied to leading margin, ie. left/right depending on alignment.)
|
Isn't "svg" supposed to be the top-level element, similar to "html"? |
You may nest them to create a relative Cartesian coordinate space. |
Re char widths I see some options as
... ? Other options. |
I guess one could run a background process with a more full SVG API. I'm not sure if means justify the ends in this case. Perhaps an approximation + margin would work almost as well. |
It won't work well at all. However a full SVG API is not necessary. Just font / string width measurement is needed. The payoff is the ability to accurately layout the svg modeline. AFAIK that's the holy grail of this project, if it's going to be seriously useful. The font table to cache method is adequate, we might also be able to utilize something like Cairo, ImageMagick etc. obviously cross platform is something to keep an eye on. Sadly all the Emacs string font width (for proportional) functions require the string to be rendered in the window / current buffer. Which is obviously a no no. It will be quite "fun" having to deal with OsX dfont. We can make a stipulation whereby a non-text widget must be to declare its static width or provide a function to make its dynamic width available. I don't think it's much to ask a theme / widget developer. |
Approximation that is. |
I was thinking that if an additional dependency is to be brought, might as well get a full API. |
Admittedly, I'm not very fond of the idea. If similar effects can be achieved with SVG alone, I'd rather not do it. |
We can't make containers fit to the text they're displaying, with SVG alone... or can we? |
I think Emacs-Mac-Port's method of rendering SVG (using WebKit) allows it to use JS / script blocks.
An external headless webkit? :) (I'm only sort of joking.) |
If you can add a background to the text element, that should be enough -- one image for left, one for center, and one for right. |
Can you add a background to the text element? I don't think that's possible in SVG. |
Maybe indeed you can't. This seems to work:
It has the downside of requiring bash, but admittedly I doubt I'm going to implement something more complicated. It could be wrapped in something like |
Bash isn't required, ImageMagick is, on Linux. Unfortunately that won't cut it on OSX or Win. ImageMagick will install of course, but it won't support fonts (out the box.) |
BTW @sabof, I'm not expecting you to implement this, I'm spitballing possible solutions. I'm planning on implementing the solution. |
Indeed the additional overhead of reading/writing to a temporary file is probably trivial. Why, what's special about win/osx fonts? |
I can't check windows, but OSX / ImageMagick don't play together (font wise) because OS X keeps its fonts in a non compatible bundling format. (It keeps them in .dfont bundles.) Windows might be ok. I will figure that out for sure. |
There is a way to get the fonts out of dfont packages (that's required for IM) but that's a lot of finagling and friction. |
Next attempt: Node canvas, or maybe just straight to Cairo. A combination of freetype and cairo is definitely going to work out, I may just make a x-platform string/font measuring utility with these two. I'll do some experiments |
:background
:overlay
Both of which are SVG layers.
The text was updated successfully, but these errors were encountered: