chiark / gitweb /
dice: Insist that x and y are as our Rust would calculate them
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 19 May 2022 17:06:28 +0000 (18:06 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 19 May 2022 18:58:17 +0000 (19:58 +0100)
Preparatory for using TextOptions::start_element, which expects
to centre text at the nominal position.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dice/overlay-template-extractor

index 3f75980c6d91c33f31b41e96282fc2b23e48c512..62c5e509590e79c78ed1ede0e34b15f1fa9456de 100755 (executable)
@@ -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 = <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 }}");