Arrange all the text in this text frame to fit inside its extents by
        setting auto size off, wrap on, and setting the font of all its text
        to *font_family*, *font_size*, *is_bold*, and *is_italic*.
494668
def _apply_fit(self, font_family, font_size, is_bold, is_italic):
        
        self.auto_size = MSO_AUTO_SIZE.NONE
        self.word_wrap = True
        self._set_font(font_family, font_size, is_bold, is_italic)
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);
	}
632018
def adjustText(self):
        
        pos = self.cursorPosition()
        self.blockSignals(True)
        super(XLineEdit, self).setText(self.formatText(self.text()))
        self.setCursorPosition(pos)
        self.blockSignals(False)
1284170
protected function _text_align()
    {
        $style = $this->_frame->get_style();
        $w = $this->_frame->get_containing_block("w");
        $width = (float)$style->length_in_pt($style->width, $w);

        switch ($style->text_align) {
            default:
            case "left":
                foreach ($this->_frame->get_line_boxes() as $line) {
                    if (!$line->left) {
                        continue;
                    }

                    foreach ($line->get_frames() as $frame) {
                        if ($frame instanceof BlockFrameDecorator) {
                            continue;
                        }
                        $frame->set_position($frame->get_position("x") + $line->left);
                    }
                }
                return;

            case "right":
                foreach ($this->_frame->get_line_boxes() as $line) {
                    // Move each child over by $dx
                    $dx = $width - $line->w - $line->right;

                    foreach ($line->get_frames() as $frame) {
                        // Block frames are not aligned by text-align
                        if ($frame instanceof BlockFrameDecorator) {
                            continue;
                        }

                        $frame->set_position($frame->get_position("x") + $dx);
                    }
                }
                break;

            case "justify":
                // We justify all lines except the last one
                $lines = $this->_frame->get_line_boxes(); // needs to be a variable (strict standards)
                $last_line = array_pop($lines);

                foreach ($lines as $i => $line) {
                    if ($line->br) {
                        unset($lines[$i]);
                    }
                }

                // One space character's width. Will be used to get a more accurate spacing
                $space_width = $this->get_dompdf()->getFontMetrics()->getTextWidth(" ", $style->font_family, $style->font_size);

                foreach ($lines as $line) {
                    if ($line->left) {
                        foreach ($line->get_frames() as $frame) {
                            if (!$frame instanceof TextFrameDecorator) {
                                continue;
                            }

                            $frame->set_position($frame->get_position("x") + $line->left);
                        }
                    }

                    // Set the spacing for each child
                    if ($line->wc > 1) {
                        $spacing = ($width - ($line->left + $line->w + $line->right) + $space_width) / ($line->wc - 1);
                    } else {
                        $spacing = 0;
                    }

                    $dx = 0;
                    foreach ($line->get_frames() as $frame) {
                        if (!$frame instanceof TextFrameDecorator) {
                            continue;
                        }

                        $text = $frame->get_text();
                        $spaces = mb_substr_count($text, " ");

                        $char_spacing = (float)$style->length_in_pt($style->letter_spacing);
                        $_spacing = $spacing + $char_spacing;

                        $frame->set_position($frame->get_position("x") + $dx);
                        $frame->set_text_spacing($_spacing);

                        $dx += $spaces * $_spacing;
                    }

                    // The line (should) now occupy the entire width
                    $line->w = $width;
                }

                // Adjust the last line if necessary
                if ($last_line->left) {
                    foreach ($last_line->get_frames() as $frame) {
                        if ($frame instanceof BlockFrameDecorator) {
                            continue;
                        }
                        $frame->set_position($frame->get_position("x") + $last_line->left);
                    }
                }
                break;

            case "center":
            case "centre":
                foreach ($this->_frame->get_line_boxes() as $line) {
                    // Centre each line by moving each frame in the line by:
                    $dx = ($width + $line->left - $line->w - $line->right) / 2;

                    foreach ($line->get_frames() as $frame) {
                        // Block frames are not aligned by text-align
                        if ($frame instanceof BlockFrameDecorator) {
                            continue;
                        }

                        $frame->set_position($frame->get_position("x") + $dx);
                    }
                }
                break;
        }
    }
953519
function() {
        var ctx = this._drawContext;
        ctx.font = this._fontString();
        this.w = ctx.measureText(this._text).width;

        var size = this._textFont.size || this.defaultSize;
        this.h = 1.1 * this._getFontHeight(size);

        /* Offset the MBR for text alignment*/
        if (this._textAlign === "left" || this._textAlign === "start") {
            this.offsetBoundary(0, 0, 0, 0);
        } else if (this._textAlign === "center") {
            this.offsetBoundary(this.w / 2, 0, -this.w / 2, 0);
        } else if (this._textAlign === "end" || this._textAlign === "right") {
            this.offsetBoundary(this.w, 0, -this.w, 0);
        }
    }
447514
private void resizeValueText() {
        double maxWidth = size * 0.86466165;
        double fontSize = size * 0.2556391;
        valueText.setFont(Fonts.latoLight(fontSize));
        if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }
        valueText.relocate((size - valueText.getLayoutBounds().getWidth()) * 0.5, (size - valueText.getLayoutBounds().getHeight()) * 0.5);
    }
353667
@Override protected void resizeDynamicText() {
        double maxWidth = unitText.isVisible() ? width - size * 0.275 : width - size * 0.1;
        double fontSize = 0.24 * size;
        valueText.setFont(Fonts.latoRegular(fontSize));
        if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }

        maxWidth = width - size * 0.55;
        fontSize = size * 0.18;
        deviationText.setFont(Fonts.latoRegular(fontSize));
        if (deviationText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(deviationText, maxWidth, fontSize); }

        maxWidth = width - size * 0.9;
        fontSize = size * 0.12;
        deviationUnitText.setFont(Fonts.latoRegular(fontSize));
        if (deviationUnitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(deviationUnitText, maxWidth, fontSize); }
    }
478270
function (text) {
            var self = this;
            if (!self.inPre) {
                // collapse whitespace
                text = collapseWhitespace(text);
            }
            self.append(text);
        }
172814
private void resizeText() {
        double maxWidth = size * 0.9;
        double fontSize = size * 0.06;

        title.setFont(Fonts.latoRegular(fontSize));
        title.setText(clock.getTitle());
        if (title.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(title, maxWidth, fontSize); }
        title.setX(size * 0.05);
        title.setY(size * 0.05);

        maxWidth = size * 0.2;
        fontSize = size * 0.05;
        amPmText.setText(clock.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM");
        Helper.adjustTextSize(amPmText, maxWidth, fontSize);
        amPmText.setX((size - amPmText.getLayoutBounds().getWidth()) * 0.5);
        amPmText.setY(size * 0.4);

        maxWidth = size * 0.6;
        dateText.setFont(Fonts.latoRegular(fontSize));
        if (dateText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(dateText, maxWidth, fontSize); }
        dateText.setX((size - dateText.getLayoutBounds().getWidth()) * 0.5);
        dateText.setY(size * 0.65);

        maxWidth = size * 0.9;
        fontSize = size * 0.05;
        text.setText(clock.getText());
        if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); }
        text.setX(size * 0.05);
        text.setY(size * 0.95);
    }
775580
private void adaptHelperText() {
        if (textInputLayout != null && TextUtils.isEmpty(getText())) {
            textInputLayout.setHelperText(helperText);
            textInputLayout.setHelperTextEnabled(true);
        }
    }
163576
@Override protected void resizeDynamicText() {
        double maxWidth = unitText.isVisible() ? size * 0.725 : size * 0.9;
        double fontSize = size * 0.24;
        valueText.setFont(Fonts.latoRegular(fontSize));
        if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }

        percentageUnitText.relocate(percentageText.getLayoutBounds().getMaxX() + size * 0.075, height - size * 0.25);
    }
1016067
def auto_style(self):
        
        if self._row_size is None:
            return
        elif self._row_size == 3:
            self.set_cols_align(['l', 'l', 'l'])
            self.set_cols_valign(['t', 't', 't'])
            self.set_cols_width([12, 54, 12])
        elif self._row_size == 4:
            self.set_cols_align(['l', 'l', 'l', 'l'])
            self.set_cols_valign(['t', 't', 't', 't'])
            self.set_cols_width([10, 40, 10, 10])
283458
def _fits_inside_predicate(self):
        
        def predicate(point_size):
            """
            Return |True| if the text in *line_source* can be wrapped to fit
            entirely within *extents* when rendered at *point_size* using the
            font defined in *font_file*.
            """
            text_lines = self._wrap_lines(self._line_source, point_size)
            cy = _rendered_size('Ty', point_size, self._font_file)[1]
            return (cy * len(text_lines)) <= self._height

        return predicate
610381
def set_font_size(self, size):
        ""
        if(self.font_size_pt==size):
            return
        self.font_size_pt=size
        self.font_size=size/self.k
        if(self.page>0):
            self._out(sprintf('BT /F%d %.2f Tf ET',self.current_font['i'],self.font_size_pt))
884705
def _set_font(self, family, size, bold, italic):
        
        def iter_rPrs(txBody):
            for p in txBody.p_lst:
                for elm in p.content_children:
                    yield elm.get_or_add_rPr()
                # generate a:endParaRPr for each <a:p> element
                yield p.get_or_add_endParaRPr()

        def set_rPr_font(rPr, name, size, bold, italic):
            f = Font(rPr)
            f.name, f.size, f.bold, f.italic = family, Pt(size), bold, italic

        txBody = self._element
        for rPr in iter_rPrs(txBody):
            set_rPr_font(rPr, family, size, bold, italic)
492720
def _resize_buffers(self, font_scale):
        """"""
        new_sizes = (font_scale,) + self.size
        if new_sizes == self._current_sizes:  # don't need resize
            return
        self._n_rows = int(max(self.size[1] /
                               (self._char_height * font_scale), 1))
        self._n_cols = int(max(self.size[0] /
                               (self._char_width * font_scale), 1))
        self._bytes_012 = np.zeros((self._n_rows, self._n_cols, 3), np.float32)
        self._bytes_345 = np.zeros((self._n_rows, self._n_cols, 3), np.float32)
        pos = np.empty((self._n_rows, self._n_cols, 2), np.float32)
        C, R = np.meshgrid(np.arange(self._n_cols), np.arange(self._n_rows))
        # We are in left, top orientation
        x_off = 4.
        y_off = 4 - self.size[1] / font_scale
        pos[..., 0] = x_off + self._char_width * C
        pos[..., 1] = y_off + self._char_height * R
        self._position = VertexBuffer(pos)

        # Restore lines
        for ii, line in enumerate(self._text_lines[:self._n_rows]):
            self._insert_text_buf(line, ii)
        self._current_sizes = new_sizes
947577
public void setTextSize(int unit, float size) {
        if (!mSizeToFit) {
            mTextView.setTextSize(unit, size);
        }

        Context context = mTextView.getContext();
        Resources r = Resources.getSystem();

        if (context != null) {
            r = context.getResources();
        }

        setRawTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
    }