From a7d3dc86eeb042ec19afe2a0fc60264ea77223e7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 19 May 2022 18:06:28 +0100 Subject: [PATCH] dice: Insist that x and y are as our Rust would calculate them Preparatory for using TextOptions::start_element, which expects to centre text at the nominal position. Signed-off-by: Ian Jackson --- dice/overlay-template-extractor | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dice/overlay-template-extractor b/dice/overlay-template-extractor index 3f75980c..62c5e509 100755 --- a/dice/overlay-template-extractor +++ b/dice/overlay-template-extractor @@ -56,6 +56,17 @@ sub filter_circle () { } sub filter_text () { + open ADJ, "src/SVG_FONT_Y_ADJUST_OF_FONT_SIZE.txt" or die $!; + my $adj = // die $!; + $adj =~ m/\d/ or die $!; + + die unless $node->getAttribute('x') eq '0'; + my $font_size = $node->getAttribute('font-size'); + die unless $font_size =~ s/px$//; + my $got_y = $node->getAttribute('y'); + my $exp_y = $adj * $font_size; + die "$got_y != $exp_y" unless $got_y == $exp_y; + filter_element('text', qw(x y font-family text-align text-anchor)); $node->setAttribute('font-size', "{{ label_options.size }}px"); $node->setAttribute('y', "{{ label_y_adjust }}"); -- 2.30.2