function units2pt($value, $font_size = null)
{
    $unit = Value::unit_from_string($value);
    switch ($unit) {
        case UNIT_PT:
            return pt2pt((double) $value);
        case UNIT_PX:
            return px2pt((double) $value);
        case UNIT_MM:
            return pt2pt(mm2pt((double) $value));
        case UNIT_CM:
            return pt2pt(mm2pt((double) $value * 10));
        case UNIT_EM:
            return em2pt((double) $value, $font_size);
        case UNIT_EX:
            return ex2pt((double) $value, $font_size);
        case UNIT_IN:
            return pt2pt((double) $value * 72);
            // points used by CSS 2.1 are equal to 1/72nd of an inch.
        // points used by CSS 2.1 are equal to 1/72nd of an inch.
        case UNIT_PC:
            return pt2pt((double) $value * 12);
            // 1 pica equals to 12 points.
        // 1 pica equals to 12 points.
        default:
            global $g_config;
            if ($g_config['mode'] === 'quirks') {
                return px2pt((double) $value);
            } else {
                return 0;
            }
    }
}
 function toPt($font_size)
 {
     switch ($this->_unit) {
         case UNIT_PT:
             return pt2pt($this->_number);
         case UNIT_PX:
             return px2pt($this->_number);
         case UNIT_MM:
             return pt2pt(mm2pt($this->_number));
         case UNIT_CM:
             return pt2pt(mm2pt($this->_number * 10));
         case UNIT_EM:
             return em2pt($this->_number, $font_size);
         case UNIT_EX:
             return ex2pt($this->_number, $font_size);
         case UNIT_IN:
             return pt2pt($this->_number * 72);
             // points used by CSS 2.1 are equal to 1/72nd of an inch.
         // points used by CSS 2.1 are equal to 1/72nd of an inch.
         case UNIT_PC:
             return pt2pt($this->_number * 12);
             // 1 pica equals to 12 points.
         // 1 pica equals to 12 points.
         default:
             global $g_config;
             if ($g_config['mode'] === 'quirks') {
                 return px2pt($this->_number);
             } else {
                 return 0;
             }
     }
 }