Skip to content

Commit

Permalink
Remove bold text from SVG/PNG output, switch font.
Browse files Browse the repository at this point in the history
For some reason, the translation from SVG to PNG causes bold text to be
typeset incorrectly (it looks like Imagemagick doesn't know to leave
more space for bold or similar). So remove all the bold text from the
body.
  • Loading branch information
dracos committed Feb 15, 2021
1 parent 4dc6e23 commit 2a442a7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions www/includes/easyparliament/templates/html/mp/votes_svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
$stance_padding_top = 14;
$stance_padding_bottom = 8;

$tspan_bold_open = '<tspan font-weight="bold">';
$tspan_bold_close = '</tspan>';

header("Content-type: image/svg+xml");

echo '<?xml version="1.0" encoding="utf-8"?>';

?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1000" height="500" viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" font-family="Droid Sans, Trebuchet">
<svg width="1000" height="500" viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" font-family="Source Sans Pro">

<rect fill="<?= $color_cream; ?>" x="0" y="0" width="1000" height="500"></rect>

Expand All @@ -50,7 +47,7 @@
if (strpos($line, '*') !== False) {
echo preg_replace(
'#(?:^|[*])([^\r\n *][^*\n]*[^\r\n *])(?:$|[*])#i',
$tspan_bold_open . '$1' . $tspan_bold_close,
'$1',
$line
);
} else {
Expand Down

0 comments on commit 2a442a7

Please sign in to comment.