本文整理汇总了PHP中Block_Frame_Decorator::set_line方法的典型用法代码示例。如果您正苦于以下问题:PHP Block_Frame_Decorator::set_line方法的具体用法?PHP Block_Frame_Decorator::set_line怎么用?PHP Block_Frame_Decorator::set_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block_Frame_Decorator
的用法示例。
在下文中一共展示了Block_Frame_Decorator::set_line方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _text_align
/**
* Adjust the justification of each of our lines.
* http://www.w3.org/TR/CSS21/text.html#propdef-text-align
*/
protected function _text_align()
{
$style = $this->_frame->get_style();
$w = $this->_frame->get_containing_block("w");
$width = $style->length_in_pt($style->width, $w);
switch ($style->text_align) {
default:
case "left":
foreach ($this->_frame->get_line_boxes() as $line) {
if (!$line->left) {
continue;
}
foreach ($line->get_frames() as $frame) {
if ($frame instanceof Block_Frame_Decorator) {
continue;
}
$frame->set_position($frame->get_position("x") + $line->left);
}
}
return;
case "right":
foreach ($this->_frame->get_line_boxes() as $line) {
// Move each child over by $dx
$dx = $width - $line->w - $line->right;
foreach ($line->get_frames() as $frame) {
// Block frames are not aligned by text-align
if ($frame instanceof Block_Frame_Decorator) {
continue;
}
$frame->set_position($frame->get_position("x") + $dx);
}
}
break;
case "justify":
// We justify all lines except the last one
$lines = $this->_frame->get_line_boxes();
// needs to be a variable (strict standards)
$lines = array_splice($lines, 0, -1);
foreach ($lines as $i => $line) {
if ($line->br) {
unset($lines[$i]);
}
}
// One space character's width. Will be used to get a more accurate spacing
$space_width = Font_Metrics::get_text_width(" ", $style->font_family, $style->font_size);
foreach ($lines as $i => $line) {
if ($line->left) {
foreach ($line->get_frames() as $frame) {
if (!$frame instanceof Text_Frame_Decorator) {
continue;
}
$frame->set_position($frame->get_position("x") + $line->left);
}
}
// Only set the spacing if the line is long enough. This is really
// just an aesthetic choice ;)
//if ( $line["left"] + $line["w"] + $line["right"] > self::MIN_JUSTIFY_WIDTH * $width ) {
// Set the spacing for each child
if ($line->wc > 1) {
$spacing = ($width - ($line->left + $line->w + $line->right) + $space_width) / ($line->wc - 1);
} else {
$spacing = 0;
}
$dx = 0;
foreach ($line->get_frames() as $frame) {
if (!$frame instanceof Text_Frame_Decorator) {
continue;
}
$text = $frame->get_text();
$spaces = mb_substr_count($text, " ");
$char_spacing = $style->length_in_pt($style->letter_spacing);
$_spacing = $spacing + $char_spacing;
$frame->set_position($frame->get_position("x") + $dx);
$frame->set_text_spacing($_spacing);
$dx += $spaces * $_spacing;
}
// The line (should) now occupy the entire width
$this->_frame->set_line($i, null, $width);
//}
}
break;
case "center":
case "centre":
foreach ($this->_frame->get_line_boxes() as $line) {
// Centre each line by moving each frame in the line by:
$dx = ($width + $line->left - $line->w - $line->right) / 2;
foreach ($line->get_frames() as $frame) {
// Block frames are not aligned by text-align
if ($frame instanceof Block_Frame_Decorator) {
continue;
}
$frame->set_position($frame->get_position("x") + $dx);
}
}
break;
}
//.........这里部分代码省略.........