説明なし

list_bullet_frame_decorator.cls.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @package dompdf
  4. * @link http://dompdf.github.com/
  5. * @author Benj Carson <benjcarson@digitaljunkies.ca>
  6. * @author Helmut Tischer <htischer@weihenstephan.org>
  7. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  8. */
  9. /**
  10. * Decorates frames for list bullet rendering
  11. *
  12. * @access private
  13. * @package dompdf
  14. */
  15. class List_Bullet_Frame_Decorator extends Frame_Decorator {
  16. const BULLET_PADDING = 1; // Distance from bullet to text in pt
  17. // As fraction of font size (including descent). See also DECO_THICKNESS.
  18. const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04
  19. const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now.
  20. const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent.
  21. static $BULLET_TYPES = array("disc", "circle", "square");
  22. //........................................................................
  23. function __construct(Frame $frame, DOMPDF $dompdf) {
  24. parent::__construct($frame, $dompdf);
  25. }
  26. function get_margin_width() {
  27. $style = $this->_frame->get_style();
  28. // Small hack to prevent extra indenting of list text on list_style_position === "inside"
  29. // and on suppressed bullet
  30. if ( $style->list_style_position === "outside" ||
  31. $style->list_style_type === "none" ) {
  32. return 0;
  33. }
  34. return $style->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING;
  35. }
  36. //hits only on "inset" lists items, to increase height of box
  37. function get_margin_height() {
  38. $style = $this->_frame->get_style();
  39. if ( $style->list_style_type === "none" ) {
  40. return 0;
  41. }
  42. return $style->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING;
  43. }
  44. function get_width() {
  45. return $this->get_margin_height();
  46. }
  47. function get_height() {
  48. return $this->get_margin_height();
  49. }
  50. //........................................................................
  51. }