Skip to content

Commit f501925

Browse files
authored
SVG output, text is not centered vertically (#128)
1 parent 3ab66e3 commit f501925

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Avatar.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,13 @@ public function toSvg()
228228
.'" fill="'.$this->background.'" />';
229229
}
230230

231-
$svg .= '<text x="'.$center.'" y="'.$center;
232-
$svg .= '" font-size="'.$this->fontSize;
231+
$svg .= '<text font-size="'.$this->fontSize;
233232

234233
if ($this->fontFamily) {
235234
$svg .= '" font-family="'.$this->fontFamily;
236235
}
237236

238-
$svg .= '" fill="'.$this->foreground.'" alignment-baseline="middle" text-anchor="middle" dominant-baseline="central">';
237+
$svg .= '" fill="'.$this->foreground.'" x="50%" y="50%" dy=".1em" style="line-height:1" alignment-baseline="middle" text-anchor="middle" dominant-baseline="central">';
239238
$svg .= $this->getInitial();
240239
$svg .= '</text>';
241240

0 commit comments

Comments
 (0)