rougier / svg-lib

Emacs SVG libraries for creatings tags, icons and bars
GNU General Public License v3.0
335 stars 30 forks source link

Better calculations for svg-lib-tag #12

Closed aruZeta closed 2 years ago

aruZeta commented 2 years ago

After some testing and what happened in rougier/svg-tag-mode/pull/14 I decided to continue my work in this repo, since it is like the 'updated' version of the other one. I have been able to make the tags have the same width as the rest of characters on the frame, something that (at least to me) didn't work.

I also have fixed that tags in different lines, one above another, had their border next to each other without any space in between.

WIP: Making the text stay at the center, actual code:

(text-x (+ tag-x
           padding
           (/ (- tag-width
                 (* padding 2)
                 tag-txt-width)
              2.0)))

But it doesn't work as expected, it seems like the total width of the characters inside the tag is strangely big, take a look at the next output of a tag's svg-width and it's tag-txt-width:

80 svg-width, 70 tag-txt-width

And it looks like this: Sat-18-Dec-2021_21-41-42 Feels like it should be way less, like 50 instead of 70, because if I understood correctly tag-char-width is the width of the characters inside the tag. Edit: Actually, by measuring the image, it seems like the text is actually 48px (like 2/3 of the actual width it tells)

PS: My font is Iosevka Term, height 120

aruZeta commented 2 years ago

Not really sure how should the calcultions take into account the new stuff; crop-left, crop-right and alignment

aruZeta commented 2 years ago

Seems like you cant rename the branch, dont mind it.

rougier commented 2 years ago

The size correspondence between emacs and svg is wrong for some reason that need yet to be identified.