Example #1
0
 public function testGetCellWidthMultiByte()
 {
     $font = new Font();
     $font->setName('Segoe UI');
     $calculator = new SizeCalculator(new SizeCollection());
     $string = 'ä ö32 4eä18 åæçè €äÜuköß ÄöÜÖö üfzp!';
     $expectedValues = array(8 => 29, 11 => 39, 12 => 42.5, 13 => 46);
     foreach ($expectedValues as $fontSize => $minWidth) {
         $calculator->setFont($font->setSize($fontSize));
         $this->assertGreaterThanOrEqual($minWidth, $calculator->getCellWidth($string, $font));
         $this->assertLessThanOrEqual($minWidth + 2, $calculator->getCellWidth($string, $font));
     }
 }
Example #2
0
 /**
  * Set proper font sizes by font.
  *
  * @param Font $font
  */
 public function setFont(Font $font)
 {
     $this->characterSizes = $this->sizeCollection->get($font->getName(), $font->getSize());
 }
Example #3
0
 /**
  * Return single <xf> string for current style.
  *
  * @return string
  */
 public function asXml()
 {
     return sprintf(StyleXml::DEFAULT_XF_XML, $this->font->getId(), $this->fill->getId(), $this->border->getId());
 }