function css_font_size($value, $root) { $value = trim(strtolower($value)); pop_font_size(); switch (strtolower($value)) { case "xx-small": push_font_size(BASE_FONT_SIZE_PT * 3 / 5 . "pt"); return; case "x-small": push_font_size(BASE_FONT_SIZE_PT * 3 / 4 . "pt"); return; case "small": push_font_size(BASE_FONT_SIZE_PT * 8 / 9 . "pt"); return; case "medium": push_font_size(BASE_FONT_SIZE_PT . "pt"); return; case "large": push_font_size(BASE_FONT_SIZE_PT * 6 / 5 . "pt"); return; case "x-large": push_font_size(BASE_FONT_SIZE_PT * 3 / 2 . "pt"); return; case "xx-large": push_font_size(BASE_FONT_SIZE_PT * 2 / 1 . "pt"); return; } switch (strtolower($value)) { case "larger": push_font_size("1.2em"); return; case "smaller": push_font_size("0.83em"); // 0.83 = 1/1.2 return; } if (preg_match("/(\\d+\\.?\\d*)%/i", $value, $matches)) { push_font_size($matches[1] / 100 . "em"); return; } push_font_size($value); }
function pop_css_defaults() { pop_border(); pop_font_family(); pop_font_size(); pop_font_style(); pop_font_weight(); pop_line_height(); global $g_css_handlers; $keys = array_keys($g_css_handlers); foreach ($keys as $key) { $g_css_handlers[$key]->pop(); } }
function &create(&$root, &$pipeline) { // Create contents of this inline box if ($root->node_type() == XML_TEXT_NODE) { $handler = get_css_handler('white-space'); return InlineBox::create_from_text($root->content, $handler->get()); } else { $box =& new InlineBox(); // Initialize content $child = $root->first_child(); while ($child) { $child_box =& create_pdf_box($child, $pipeline); $box->add_child($child_box); $child = $child->next_sibling(); } // Add fake whitespace box with zero size for the anchor spans // We need this, as "reflow" functions will automatically remove empty inline boxes from the // document tree // if ($box->is_null()) { push_css_defaults(); pop_font_size(); push_font_size('0.01pt'); $whitespace = new WhitespaceBox(); $box->add_child($whitespace); pop_css_defaults(); } } return $box; }