Recalculate the text width

@return float
970112
function recalculate_width()
    {
        $style = $this->get_style();
        $text = $this->get_text();
        $size = $style->font_size;
        $font = $style->font_family;
        $word_spacing = (float)$style->length_in_pt($style->word_spacing);
        $char_spacing = (float)$style->length_in_pt($style->letter_spacing);

        return $style->width = $this->_dompdf->getFontMetrics()->getTextWidth($text, $font, $size, $word_spacing, $char_spacing);
    }
324890
public function getCellWidth($fontName, $fontSize, $value)
    {
        $width = 1;
        foreach ($this->getSingleCharacterArray($value) as $char) {
            $width += $this->getCharacterWidth($fontName, $fontSize, $char);
        }

        return $width;
    }
1121247
protected function _recalculate()
	{
		// calculate the number of pages
		$this->config['total_pages'] = (int) ceil($this->config['total_items'] / $this->config['per_page']) ?: 1;

		// get the current page number, either from the one set, or from the URI or the query string
		if ($this->config['current_page'])
		{
				$this->config['calculated_page'] = $this->config['current_page'];
		}
		else
		{
			if (is_string($this->config['uri_segment']))
			{
				$this->config['calculated_page'] = \Input::get($this->config['uri_segment'], 1);
			}
			else
			{
				$this->config['calculated_page'] = (int) \Request::main()->uri->get_segment($this->config['uri_segment']);
			}
		}

		// make sure the current page is within bounds
		if ($this->config['calculated_page'] > $this->config['total_pages'])
		{
			$this->config['calculated_page'] = $this->config['total_pages'];
		}
		elseif ($this->config['calculated_page'] < 1)
		{
			$this->config['calculated_page'] = 1;
		}

		// the current page must be zero based so that the offset for page 1 is 0.
		$this->config['offset'] = ($this->config['calculated_page'] - 1) * $this->config['per_page'];
	}
1097664
public static function getWidth()
    {
        $width = getenv('COLUMNS');
        if ($width !== false) {
            return (int) trim($width);
        }

        static::updateDimensions();

        return static::$width;
    }
933768
public function convertir()
    {
        $n_str = (string)$this->numero_entero;//Convierte el número entero a cadena

        if ($this->numero_entero == 0) {
            $letras = $this->simple[0] . " " . $this->moneda;
        }

        //Numero < 1000
        elseif ($this->numero_entero < 1000) {
            $n = $this->numero_entero;
            $n_txt = $this->menor_mil($n);
            $letras = $n_txt . " " . $this->moneda;
        }

        //Numero {1000 < n < 1,000,000}
        elseif ($this->numero_entero < 1000000) {
            $m = 0;
            $long_n = strlen($n_str);//cuenta el número de caracteres
            $f = 1;

            //Separa los miles para ser evaluados con la función menor_mil
            for ($k = $long_n; $k > 3; $k--) {
                $m += ($n_str[$k-4] * $f);    //recupera la posicion 0,1,2 y Multiplica por 1,10,y 100
                $f *= 10;
            }

            //Miles que pasan a funcion menor_mil para ser evaluadas
            $miles_txt = $this->menor_mil($m);

            $n = $this->numero_entero - $m * 1000;//Elimina los miles

            $n_txt = $this->menor_mil($n);//Unidades, Decenas y Centenas a ser evaluadas
            $letras = $miles_txt . $this->miles . $n_txt . " " . $this->moneda;
        }

        //número mayor o igual a 1,000,000
        else {
            $long_n = strlen($n_str);//cuenta el número de caracteres
            $f = 1;
            $mm = 0;
            for ($k = $long_n; $k > 6; $k--) {
                $mm += ($n_str[$k-7] * $f);    //Recupera la posición 0,1,2 del array u la Multiplica por 1,10,y 100 respectivamente
                $f *= 10;
            }

            if ($mm == 1) {
                $this->millones = $this->millon;
            }
            $millones_txt = $this->menor_mil($mm);

            $f=1;
            $m = 0;
            //Separa los miles para ser evaluados con la función menor_mil
            for ($k = $long_n; $k > $long_n - 3; $k--) {
                $m += ($n_str[$k-4] * $f);    //Multiplica por 1,10,y 100
                $f *= 10;
            }

            //Miles que pasan a funcion menor_mil para ser evaluadas
            $miles_txt = $this->menor_mil($m);
            $n = $this->numero_entero - $m*1000 - $mm*1000000;//Elimina los miles y millones
            $n_txt = $this->menor_mil($n);//Unidades, Decenas y Centenas a ser evaluadas
            $letras = $millones_txt . $this->millones . $miles_txt . $this->miles . $n_txt . " " . $this->moneda;
        }

        //Evaluación de decimales
        //Si no tiene decimal
        if (strchr($this->numero, ".") == "") {
            return ("(" . $letras . " 00/100)");
        } else {
            $dec = strchr($this->numero, ".");
            if (empty($dec[2])) {
                $d = $dec['1'] . '0';
            } else {
                $d = $dec['1'] . (integer)$dec['2'];
            }
            return ("(" . $letras . " " . $d . "/100)");
        }
    }
1371948
function getTextWidth( $size, $text )
    {
        // this function should not change any of the settings, though it will need to
        // track any directives which change during calculation, so copy them at the start
        // and put them back at the end.
        $this->pushTextState( $this->currentTextState );

        if (!$this->numFonts)
        {
            $this->selectFont('./fonts/Helvetica');
        }

        // converts a number or a float to a string so it can get the width
        $text = "$text";
        // hmm, this is where it all starts to get tricky - use the font information to
        // calculate the width of each character, add them up and convert to user units
        $w = 0;
        $len = strlen( $text );
        $cf = $this->currentFont;
        for ( $i = 0; $i < $len; $i++ )
        {
            $f = 1;
            $directiveArray = $this->PRVTcheckTextDirective( $text, $i, $f );
            $directive = $directiveArray['directive'];
            if ( $directive )
            {
                if ($f)
                {
                    $this->setCurrentFont();
                    $cf = $this->currentFont;
                }
                $i = $i + $directive-1;
            }
            else
            {
                $char = ord( $text[$i] );
                if ( isset($this->fonts[$cf]['differences'][$char] ) )
                {
                    // then this character is being replaced by another
                    $name = $this->fonts[$cf]['differences'][$char];
                    if ( isset($this->fonts[$cf]['C'][$name]['WX'] ) )
                    {
                        $w += $this->fonts[$cf]['C'][$name]['WX'];
                    }
                }
                else if ( isset($this->fonts[$cf]['C'][$char]['WX'] ) )
                {
                    $w += $this->fonts[$cf]['C'][$char]['WX'];
                }
                else
                {
                    $w += 700;
                }
            }
        }

        $this->popTextState();
        $this->setCurrentFont();

        return $w*$size/1000;
    }
663583
public function getHtmlWidth()
    {
        if (is_string($this->width) && $this->width === self::WIDTH_AUTO) {
            return '';
        } else if (intval($this->width) > 0) {
            return $this->width . '%';
        }
        
        return $this->width;
    }
438876
public function getWidth()
    {
        if ($this->_width) {
            return $this->_width;
        }
        return $this->_table->getColumn($this->_columnIndex)->getWidth();
    }
896868
function AutosizeText($text, $w, $font, $style, $szfont = 72)
	{

		$text = ' ' . $text . ' ';

		$this->SetFont($font, $style, $szfont, false);

		$text = $this->purify_utf8_text($text);
		if ($this->text_input_as_HTML) {
			$text = $this->all_entities_to_utf8($text);
		}
		if ($this->usingCoreFont) {
			$text = mb_convert_encoding($text, $this->mb_enc, 'UTF-8');
		}

		// DIRECTIONALITY
		if (preg_match("/([" . $this->pregRTLchars . "])/u", $text)) {
			$this->biDirectional = true;
		}

		$textvar = 0;
		$save_OTLtags = $this->OTLtags;
		$this->OTLtags = [];

		if ($this->useKerning) {
			if ($this->CurrentFont['haskernGPOS']) {
				$this->OTLtags['Plus'] .= ' kern';
			} else {
				$textvar = ($textvar | TextVars::FC_KERNING);
			}
		}

		/* -- OTL -- */
		// Use OTL OpenType Table Layout - GSUB & GPOS
		if (isset($this->CurrentFont['useOTL']) && $this->CurrentFont['useOTL']) {
			$text = $this->otl->applyOTL($text, $this->CurrentFont['useOTL']);
			$OTLdata = $this->otl->OTLdata;
		}
		/* -- END OTL -- */

		$this->OTLtags = $save_OTLtags;

		$this->magic_reverse_dir($text, $this->directionality, $OTLdata);

		$width = $this->sizeConverter->convert($w);
		$loop = 0;

		while ($loop == 0) {

			$this->SetFont($font, $style, $szfont, false);
			$sz = $this->GetStringWidth($text, true, $OTLdata, $textvar);

			if ($sz > $w) {
				$szfont --;
			} else {
				$loop ++;
			}
		}

		$this->SetFont($font, $style, $szfont, true, true);
		$this->Cell($w, 0, $text, 0, 0, "C", 0, '', 0, 0, 0, 'M', 0, false, $OTLdata, $textvar);
	}
671106
public function getMaxLineWidth()
    {
        $m = $this->getMargins();
        if ($this->getRTL()) {
            return ($this->getRemainingWidth() + $m['right']);
        }

        return ($this->getRemainingWidth() + $m['left']);
    }
63535
public function getWidth(): int
    {
        $lines = [];
        foreach ($this as $line) {
            $lines[] = $line->getWidth();
        }

        return max($lines);
    }
840893
protected function recalculate()
    {
        $adjusted = (new Carbon($this->date))->addDays($this->adjustment);

        $julian = Converter::gregorianToJulian($adjusted->year, $adjusted->month, $adjusted->day);

        $hijri = Converter::julianToHijri($julian);

        $this->julianDay = $julian;
        $this->day = $hijri->day;
        $this->month = $hijri->month;
        $this->day = $hijri->day;

        return $this->fillValuesArray();
    }
545043
public function getWidth() : ?float 
    {
        if ( ! $this->hasWidth()) {
            $this->setWidth($this->getDefaultWidth());
        }
        return $this->width;
    }
464284
private function calculateCellSize()
    {
        $this->_font = ZfPdf\Font::fontWithName(ZfPdf\Font::FONT_HELVETICA);
        $i = 0;
        $larg = Array();

        foreach ($this->_arrayForm['gridfieldsconfig'] as $field => $value) {
            if ($field == 'dta_cadastro' or $field == 'dta_atualizacao') {
                $larg[$i] = 4;
            } elseif ($field == 'ind_status') {
                $larg[$i] = 2;
            } elseif ($value['type'] == 'primarykey') {
                $larg[$i] = 2;
            } else {
                $fieldName = $this->_arrayLocale->translate($field);
                $larg[$i] = $this->widthForStringUsingFontSize($fieldName, $this->_font, 8);
            }
            $i++;
        }
        /*
          foreach ($this->_arrayData as $value) {
          $i = 0;
          foreach ($value as $value2) {
          $value2 = strip_tags($value2);
          if ($larg[$i] < strlen($value2)) {
          $larg[$i] = strlen($value2);
          }
          $i++;
          }
          }
         */

        return $larg;
    }
1364438
public function calculate_auto_width()
    {
        $width = 0;

        foreach ($this->_frame->get_line_boxes() as $line) {
            $line_width = 0;

            foreach ($line->get_frames() as $frame) {
                if ($frame->get_original_style()->width == 'auto') {
                    $line_width += $frame->calculate_auto_width();
                } else {
                    $line_width += $frame->get_margin_width();
                }
            }

            $width = max($line_width, $width);
        }

        $this->_frame->get_style()->width = $width;

        return $this->_frame->get_margin_width();
    }
178128
public function getStringWidth(string $text): float
    {
        $style = $this->getStyle($this->currentStyle);

        return mb_strlen($text) * ($style['size'] / 2);
    }
349149
public function get_margin_width()
    {
        $style = $this->_style;

        return (float)$style->length_in_pt(array(
            $style->width,
            $style->margin_left,
            $style->margin_right,
            $style->border_left_width,
            $style->border_right_width,
            $style->padding_left,
            $style->padding_right
        ), $this->_containing_block["w"]);
    }