/** * Align inline children vertically. * Aligns each child vertically after each line is reflowed */ function vertical_align() { foreach ($this->_frame->get_lines() as $i => $line) { $height = $line["h"]; foreach ($line["frames"] as $frame) { $style = $frame->get_style(); if ($style->display !== "inline" && $style->display !== "text") { continue; } // FIXME? if ($this instanceof Table_Cell_Frame_Reflower) { $align = $frame->get_frame()->get_style()->vertical_align; } else { $align = $frame->get_frame()->get_parent()->get_style()->vertical_align; } $frame_h = $frame->get_margin_height(); $y = $line["y"]; switch ($align) { case "baseline": $y += $height - $frame_h; break; case "middle": $y += ($height + $frame_h) / 2; break; case "sub": $y += 0.2 * $height; break; case "super": $y += -0.3 * $height; break; case "text-top": case "top": // Not strictly accurate, but good enough for now break; case "text-bottom": case "bottom": $y += $height - $frame_h; break; } $x = $frame->get_position("x"); $frame->set_position($x, $y); } } }