예제 #1
0
 /**
  * Sets the width of the table
  *
  * @param string  $font     The font name
  * @param integer $fontSize The font size
  *
  * @return void
  *
  * @access private
  * @see PMA_EPS
  */
 private function _setWidthTable($font, $fontSize)
 {
     foreach ($this->fields as $field) {
         $this->width = max($this->width, PMA_Font::getStringWidth($field, $font, $fontSize));
     }
     $this->width += PMA_Font::getStringWidth('      ', $font, $fontSize);
     /*
      * it is unknown what value must be added, because
      * table title is affected by the table width value
      */
     while ($this->width < PMA_Font::getStringWidth($this->getTitle(), $font, $fontSize)) {
         $this->width += 7;
     }
 }
 /**
  * Test getStringWidth with a custom charList.
  *
  * @return void
  */
 function testGetStringWidthCharLists()
 {
     // string "a", with invalid charlist (= string)
     $this->assertEquals(6, PMA_Font::getStringWidth("a", "arial", "10", "list"));
     // string "a", with invalid charlist (= array without proper structure)
     $this->assertEquals(6, PMA_Font::getStringWidth("a", "arial", "10", array("list")));
     // string "a", with invalid charlist (= array without proper structure :
     // modifier is missing
     $this->assertEquals(6, PMA_Font::getStringWidth("a", "arial", "10", array(array("chars" => "a"))));
     // string "a", with invalid charlist (= array without proper structure :
     // chars is missing
     $this->assertEquals(6, PMA_Font::getStringWidth("a", "arial", "10", array(array("modifier" => 0.61))));
     // string "a", with invalid charlist (= array without proper structure :
     // chars is not an array
     $this->assertEquals(6, PMA_Font::getStringWidth("a", "arial", "10", array(array("chars" => "a", "modifier" => 0.61))));
     // string "a", with valid charlist
     $this->assertEquals(7, PMA_Font::getStringWidth("a", "arial", "10", array(array("chars" => array("a"), "modifier" => 0.61))));
 }