Add width and height to SVG image
Beginning from Mathoid 0.2.5 the specification of a height and width attribute of the image will be required. This patch gets those information from the SVG and copies them to the img tag. See also Bug: 20202 Bug: 68295 Change-Id: I93e26a9f538acf21aea1501144bb1dd886ae0410
This commit is contained in:
parent
130c3f44f1
commit
77069f6e5f
@ -348,6 +348,15 @@ class MathMathML extends MathRenderer {
|
||||
$style = preg_replace( '/margin\-(left|right)\:\s*\d+(\%|in|cm|mm|em|ex|pt|pc|px)\;/', '', $style );
|
||||
}
|
||||
}
|
||||
// TODO: Figure out if there is a way to construct
|
||||
// a SVGReader from a string that represents the SVG
|
||||
// content
|
||||
if ( preg_match( "/height=\"(.*?)\"/" , $this->getSvg(), $matches ) ) {
|
||||
$style .= "height: " . $matches[1] . "; ";
|
||||
}
|
||||
if ( preg_match( "/width=\"(.*?)\"/", $this->getSvg(), $matches ) ) {
|
||||
$style .= "width: " . $matches[1] . ";";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,6 +373,7 @@ class MathMathML extends MathRenderer {
|
||||
} else {
|
||||
$png = false;
|
||||
}
|
||||
|
||||
$attribs = array();
|
||||
if ( $classOverride === false ) { // $class = '' suppresses class attribute
|
||||
$class = $this->getClassName( true, $png );
|
||||
@ -372,6 +382,7 @@ class MathMathML extends MathRenderer {
|
||||
$class = $classOverride;
|
||||
$style = '';
|
||||
}
|
||||
|
||||
if ( !$png ) {
|
||||
$this->correctSvgStyle( $this->getSvg(), $style );
|
||||
}
|
||||
@ -455,4 +466,4 @@ class MathMathML extends MathRenderer {
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user