-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
d.vect: label vertical alignment workaround #2857
Conversation
Using: #!/bin/sh
# nc_spm_full_v2alpha2
echo "1|629880|222510|a
2|629882|222510|b
3|629884|222510|c
4|629886|222510|d
5|629888|222510|e
6|629890|222510|f
7|629892|222510|g
8|629894|222510|h
9|629896|222510|i
10|629898|222510|1
11|629900|222510|2
12|629902|222510|3
13|629904|222510|4
14|629906|222510|5
15|629908|222510|6
16|629910|222510|7
17|629912|222510|8
18|629914|222510|9" | v.in.ascii input=- output=labelmap cat=1 x=2 y=3 --overwrite
g.region e=629916 w=629879 s=222508 n=222512 res=1
d.mon start=cairo output=map.png --overwrite
d.vect map=labelmap color=0:29:57:255 width=1 \
attribute_column=str_1 label_bcolor=13:0:200:255 \
label_size=21 \
yref=bottom xref=left
d.mon stop=cairo |
Made another attempt with this PR, results are better (must have failed to build this PR correctly before), but centring doesn't work well (here top + center): and with increased scale (greater region, larger distance between points): Script used, see in details: #!/bin/sh
# nc_spm_full_v2alpha2
g.region e=629916 w=629879 s=222508 n=222512 res=1
echo "1|629880|222510|a
2|629882|222510|b
3|629884|222510|c
4|629886|222510|d
5|629888|222510|e
6|629890|222510|f
7|629892|222510|g
8|629894|222510|h
9|629896|222510|i
10|629898|222510|1
11|629900|222510|2
12|629902|222510|3
13|629904|222510|4
14|629906|222510|5
15|629908|222510|6
16|629910|222510|7
17|629912|222510|8
18|629914|222510|9" | v.in.ascii input=- output=labelmap cat=1 x=2 y=3 --overwrite
d.mon start=cairo output=map.png --overwrite
d.vect map=labelmap color=0:29:57:255 width=1 \
attribute_column=str_1 label_bcolor=13:0:200:255 \
label_size=17 \
yref=top xref=center
d.mon stop=cairo
g.region raster=basin@PERMANENT res=100
echo "1|629880|222510|a
2|630000|222510|b
3|631000|222510|c
4|632000|222510|d
5|633000|222510|e
6|634000|222510|f
7|635000|222510|g
8|636000|222510|h
9|637000|222510|i
10|638000|222510|1
11|639000|222510|2
12|640000|222510|3
13|641000|222510|4
14|642000|222510|5
15|643000|222510|6
16|644000|222510|7
17|644500|222510|8
18|645000|222510|9" | v.in.ascii input=- output=labelmap2 cat=1 x=2 y=3 --overwrite
d.mon start=cairo output=map2.png --overwrite
d.vect map=labelmap2 color=0:29:57:255 width=1 \
attribute_column=str_1 label_bcolor=13:0:200:255 \
label_size=17 \
yref=top xref=center
d.mon stop=cairo |
I didn't touch the horizontal alignment code. It also seems to be in a need for a solution. Still I do not know how it should be made as vertical shift is easy movement of point of reference up/down by size * magic constant, then for horizontal it wouldn't work like that as length of string must be taken into account. Note – vertical alignment seems to work fine as all letters seem to be aligned on the same baseline (note – „g“ letter goes below the line, „a“ doesn't and „b“, „f“ are taller than „g“ or „a“). |
swap vertical alignment to match previous behaviour
@nilason can you, please, retest the PR if it is good now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@landam the "g" letter placement is intentional. Letters are aligned to baseline and not top or bottom. Note that "a", "c" and "e" are not as tall as "b", "d" and "f". And "g" does not jump up from its position as it goes below "a..f". |
To my knowledge there is no request for change. @marisn So feel free to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is certainly an improvement. I was hoping to get some time to explore a "a proper fix" as you mentioned in the comment, perhaps with some input from e.g. https://wiki.inkscape.org/wiki/Text_Rendering_Notes#HarfBuzz, but in vain.
Looks good to me!
@marisn As you are marked as assignee, please consider merging this PR. |
Although more fine-grained control over label placement would be better, this PR at least makes labelling to work as intended.
Fixes #2854