howardjones / network-weathermap

Network Weathermap draws diagrams from data
http://www.network-weathermap.com/
MIT License
425 stars 94 forks source link

V offset #35

Closed hawson closed 8 years ago

hawson commented 8 years ago

This small patch adds a new attribute to defined fonts, allowing for a vertical offset anywhere a font is used. The patch is against the git commit 70c3212 (tagged with "version-0.98").

I have a number of links that have poor bounding boxes, and they display poorly in links, as shown in this example: screen shot 2016-07-13 at 12 44 42 pm

However, with the patch, and adding a small offset, it looks much better: screen shot 2016-07-13 at 12 49 15 pm

Note that this can be (ab)used to allow for BWLABELs that are rendered above or below the link line, instead directly on top of it...similar to how BWLABELPOS can move the label to the left and right. A quick example that shows the BWLABEL text rendered just "below" it's link: screen shot 2016-07-13 at 12 54 55 pm.

In the configuration file, the offset is noted as a new, optional, element to FONTDEFINE. To create the 2nd image (with less overhead whitespace): FONTDEFINE 200 docs/example/Vera 8 -6

The 3rd image uses an offset in the other direction, plus a using existing BW* options:

FONTDEFINE 200 docs/example/Vera 8 16
BWBOXCOLOR none
BWOUTLINECOLOR none

Unfortunately, the offset will depend entirely on the font used. An offset of -6 looks good for this font (Bitstream Vera Sans), it may not for other fonts. It also depends on the size of the font: using a pt size of 12, needs a different offset.

howardjones commented 8 years ago

Thanks for your pull request!

Two things: first, this pull request should be against the 0.97-maintenance branch. master is dramatically changed from the recent 0.98 release. Your patch currently shows as changing 222 files! :-)

The other: I can't see the actual change, because 222 files, but what does this do with angled text (e.g. link comments, or bwlabels in 'angled' style)? Still a vertical offset, or an offset at a right-angle to the text baseline? Because I think it should be the second to be intuitive.

hawson commented 8 years ago

because 222 files

Yeah, oops. :-/

request should be against the 0.97-maintenance branch

Okay. I'll close this one out, and submit it against that branch.

bq. what does this do with angled text

It "just works". :-D The "fudge" only affects the height of the text box, so anything else that uses that for calculations should work correctly:

screen shot 2016-07-13 at 3 55 22 pm