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 push_css_text_defaults() { // No borders for pure text boxes; border can be controlled via SPANs push_border(default_border()); push_font_family(get_font_family()); // push_font_size(get_font_size()); push_font_size("1em"); push_font_style(get_font_style()); push_font_weight(get_font_weight()); push_line_height(get_line_height()); global $g_css_handlers; $keys = array_keys($g_css_handlers); foreach ($keys as $key) { $g_css_handlers[$key]->inherit_text(); } }
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; }