Code: Select all
<?php
$FontSize = $_GET['fontsize']; // Font size of current element in px
$BaseLineHeight = $_GET['lineheight']; // line height in px
$MarginTop = $_GET['margint']; // top margin in multiples of line height
$MarginBotom = $_GET['marginb']; // bottom margin in multiples of line height
$BorderTop = $_GET['bordert']; // top border in px
$BorderBottom = $_GET['borderb']; //bottom border in px
$NewLineHeight = $BaseLineHeight / $FontSize;
$PixelBase = 1 / $FontSize;
$BorderTop = $BorderTop * $PixelBase;
$BorderBottom = $BorderBottom * $PixelBase;
$MarginTop = ($MarginTop * $NewLineHeight) - $BorderTop;
$MarginBottom = ($MarginTop * $NewLineHeight) - $BorderBottom;
if {$NewLineHeight < 1) {
$NewLineHeight = $NewLineHeight * 2;
}
echo "line-height: $NewLineHeight;
margin-top: $MarginTop;
margin-bottom: $MarginBottom;
border-bottom-width: $BorderBottom;
border-top-width: $BorderTop;"
?>