Gets the width and the height for writing some text.
329787
public static function TTFBox($font, $text, $size, $angle = 0)
    {
        $box = imagettfbbox($size, $angle, $font, $text);

        return array(
            'width'  => abs($box[2] - $box[0]),
            'height' => abs($box[3] - $box[5]),
        );
    }
913399
function(imsize, olsize) {
        if (olsize !== null) {
            imsize.width = olsize.w;
            imsize.height = olsize.h;
            imsize.printwidth = olsize.w;
            imsize.printheight = olsize.h;
        }
    }
348740
function() {
		var me = this;
		var tickFont;

		if (me.isHorizontal()) {
			return Math.ceil(me.width / 40);
		}
		tickFont = helpers.options._parseFont(me.options.ticks);
		return Math.ceil(me.height / tickFont.lineHeight);
	}
502553
def get_width():
    """"""
    # Get terminal size
    ws = struct.pack("HHHH", 0, 0, 0, 0)
    ws = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, ws)
    lines, columns, x, y = struct.unpack("HHHH", ws)
    width = min(columns * 39 // 40, columns - 2)
    return width
312586
def doLayout(self, width):
        

        # Calculate dimensions
        self.width = width

        font_sizes = [0] + [frag.get("fontSize", 0) for frag in self]
        self.fontSize = max(font_sizes)
        self.height = self.lineHeight = max(frag * self.LINEHEIGHT for frag in font_sizes)

        # Apply line height
        y = (self.lineHeight - self.fontSize) # / 2
        for frag in self:
            frag["y"] = y

        return self.height
950753
def text(self, text, x, y, width, height, color, font):
        
        # Helper function.
        def chop(word):
            """
            Take a word longer than the bounding box's width and chop off as many
            letters in the beginning as fit, followed by an ellipsis.
            """
            total_str = ""
            for c in word:
                _, _, total_width, _, _, _ = self.context.text_extents(total_str + c + "…")
                if total_width >= width:
                    return total_str + "…"
                total_str += c
            assert not "Should not be here, else 'word' fit into the bounding box"
        # Prepare the context for text rendering.
        self.context.set_source_rgb(*color)
        font_name, (font_size, font_slant, font_weight) = (font)
        self.context.select_font_face(font_name, font_slant, font_weight)
        self.context.set_font_size(font_size)
        self.context.set_antialias(cairo.ANTIALIAS_DEFAULT)
        # Get some font metrics.
        font_asc, _, font_height, _, _ = self.context.font_extents()
        # Initialize text cursor to the baseline of the font.
        width, height = self.tx(width), self.ty(height)
        w_x, w_y = self.tx(x), font_asc + self.ty(y)
        # Draw the text one line at a time and ensure the bounding box.
        line = ""
        nlines = 1
        for word in text.split(" "):
            _, _, line_width, _, _, _ = self.context.text_extents(_join(line, word))
            if line_width < width:
                line = _join(line, word)
            else:
                if not line:
                    # First word of the line extends beyond the line: chop and done.
                    self.context.move_to(w_x, w_y)
                    self.context.show_text(chop(word))
                    return nlines, font_height
                else:
                    # Filled a line, render it, and move on to the next line.
                    self.context.move_to(w_x, w_y)
                    self.context.show_text(line)
                    line = word
                    w_y += font_height

                    if w_y > height:
                        return nlines, font_height
                    nlines += 1
        self.context.move_to(w_x, w_y)
        self.context.show_text(line)
        return nlines, font_height
674901
public int getWidth(String text) {

        m_elem.setInnerText(text);
        return CmsDomUtil.getCurrentStyleInt(m_elem, CmsDomUtil.Style.width);
    }
596188
public float getWidthPointKerned(String text, float fontSize) {
        float size = getWidth(text) * 0.001f * fontSize;
        if (!hasKernPairs())
            return size;
        int len = text.length() - 1;
        int kern = 0;
        char c[] = text.toCharArray();
        for (int k = 0; k < len; ++k) {
            kern += getKerning(c[k], c[k + 1]);
        }
        return size + kern * 0.001f * fontSize;
    }
679496
function getPageDimensions() {
      var bttmRight = document.createElement("div");
      bttmRight.setAttribute("style" , "visibility:hidden;position:fixed;bottom:0px;right:0px;");
      document.getElementsByTagName("body")[0].appendChild(bttmRight);
      var pageWidth = bttmRight.offsetLeft;
      var pageHeight = bttmRight.offsetTop;
      bttmRight.parentNode.removeChild(bttmRight);
      return { width:pageWidth, height:pageHeight };
    }
518655
def size(self):
        """"""
        width = max(
            map(lambda x: x.size()[0], self.sections.itervalues()))

        height = sum(
            map(lambda x: x.size()[1], self.sections.itervalues()))

        return width, height
295239
function get_text_width($text, $font, $size, $word_spacing = 0, $letter_spacing = 0) {
    $fh = $this->_load_font($font);

    // Determine the additional width due to extra spacing
    $num_spaces = mb_substr_count($text," ");
    $delta = $word_spacing * $num_spaces;
    
    if ( $letter_spacing ) {
      $num_chars = mb_strlen($text);
      $delta += ($num_chars - $num_spaces) * $letter_spacing;
    }
    
    return $this->_pdf->stringwidth($text, $fh, $size) + $delta;
  }
168963
function () {
        var dpr = this._dpr;
        return [this._nodeWidth / this._canvas.width * dpr, this._nodeHeight / this._canvas.height * dpr];
    }
1324822
function() {
            return this.attrs.height === AUTO ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attrs.height;
        }
1129576
function (text, color, x, y, width) {
                        ctx.fillStyle = color;
                        var metric = ctx.measureText(text);
                        if (metric.width > width) {
                            while (text !== "") {
                                metric = ctx.measureText(text + "...");
                                if (metric.width <= width) {
                                    text += "...";
                                    break;
                                }
                                text = text.substr(0, text.length - 1);
                            }
                        }
                        ctx.fillText(text, x, y, width);
                    }
819416
function getDimensions(el, which) {
        switch (which) {
        case 'height':
            return  getStyle(el, "marginTop")        +
                    getStyle(el, "marginBottom")     +
                    getStyle(el, "paddingTop")       +
                    getStyle(el, "paddingBottom")    +
                    getStyle(el, "borderTopWidth")   +
                    getStyle(el, "borderBottomWidth");
        case 'width':
            return   getStyle(el, "marginLeft")      +
                     getStyle(el, "marginRight")     +
                     getStyle(el, "paddingLeft")     +
                     getStyle(el, "paddingRight")    +
                     getStyle(el, "borderLeftWidth") +
                     getStyle(el, "borderRightWidth");
        default:
            break;
        }

        return getStyle(el, which);
    }
1021647
function(){
            return {
                width:(!isNaN(window.innerWidth))?window.innerWidth:document.documentElement.clientWidth||0,
                height:(!isNaN(window.innerHeight))?window.innerHeight:document.documentElement.clientHeight||0
            };
        }
1356914
def write y, x, s, opts={}
    return if x >= @width || y >= @height

    @w.attrset Colormap.color_for(opts[:color] || :none, opts[:highlight])
    s ||= ""
    maxl = @width - x # maximum display width width

    # fill up the line with blanks to overwrite old screen contents
    @w.mvaddstr y, x, " " * maxl unless opts[:no_fill]

    @w.mvaddstr y, x, s.slice_by_display_length(maxl)
  end