// measureString returns the metrics in pixels of s rendered in a font
// with pixel size pxSize.
//
// TODO: Often all I want is the leading, which is much cheaper to get
// than the width. Maybe textMetrics should have methods?
335321
func measureString(pxSize float64, s string) textMetrics {
	// TODO: This is absolutely horribly awful. Make it real,
	// perhaps using the freetype package.

	// Chrome's default font-size is 16px, so 20px is a reasonable
	// leading.
	return textMetrics{
		width:   0.5 * pxSize * float64(utf8.RuneCountInString(s)),
		leading: 1.25 * pxSize,
	}
}
714093
func (p *Parser) parseString() (string, error) {
	tok, pos, lit := p.ScanIgnoreWhitespace()
	if tok != STRING {
		return "", newParseError(tokstr(tok, lit), []string{"string"}, pos)
	}
	return lit, nil
}
673082
func (se *SizingEncoder) WriteString(value string) {
	se.WriteInt16(int16(len(value)))
	se.size += len(value)
}
277457
func cStringN(s string, size int) *C.OraText {
	p := C.malloc(C.size_t(size))
	pp := (*[1 << 30]byte)(p)
	copy(pp[:], s)
	if len(s) < size {
		pp[len(s)] = 0
	} else {
		pp[size-1] = 0
	}
	return (*C.OraText)(p)
}
1265411
func NewString(val string, p *string) *String {
	*p = val
	return (*String)(p)
}
250082
func (f *Fpdf) GetStringWidth(s string) float64 {
	if f.err != nil {
		return 0
	}
	w := 0
	for _, ch := range []byte(s) {
		if ch == 0 {
			break
		}
		w += f.currentFont.Cw[ch]
	}
	return float64(w) * f.fontSize / 1000
}
1212794
func (v *Drawable) DrawString(font *Font, gc *GC, x int, y int, str string) {
	ptr := C.CString(str)
	defer cfree(ptr)
	C.gdk_draw_string(v.GDrawable, font.GFont, gc.GGC, gint(x), gint(y), gstring(ptr))
}
1374349
func (sf *ScalarFunction) EvalString(ctx sessionctx.Context, row chunk.Row) (string, bool, error) {
	return sf.Function.evalString(row)
}
898139
func (b *builtinOctIntSig) evalString(row chunk.Row) (string, bool, error) {
	val, isNull, err := b.args[0].EvalInt(b.ctx, row)
	if isNull || err != nil {
		return "", isNull, err
	}

	return strconv.FormatUint(uint64(val), 8), false, nil
}
901720
func (s Slice) GetStringLength() (ValueLength, error) {
	h := s.head()
	if h >= 0x40 && h <= 0xbe {
		// short UTF-8 String
		length := h - 0x40
		return ValueLength(length), nil
	}

	if h == 0xbf {
		// long UTF-8 String
		length := readIntegerFixed(s[1:], 8)
		if err := checkOverflow(ValueLength(length)); err != nil {
			return 0, WithStack(err)
		}
		return ValueLength(length), nil
	}

	return 0, InvalidTypeError{"Expecting type String"}
}
876935
func (rgc *RasterGraphicContext) StrokeString(text string) (cursor float64, err error) {
	cursor, err = rgc.StrokeStringAt(text, 0, 0)
	return
}
928380
func (L *State) CheckString(narg int) string {
	var length C.size_t
	return C.GoString(C.luaL_checklstring(L.s, C.int(narg), &length))
}
57403
func (s *StatsInfo) String() string {
	return fmt.Sprintf("count %v, Cardinality %v", s.RowCount, s.Cardinality)
}
1319935
func (ya YAxis) Measure(r Renderer, canvasBox Box, ra Range, defaults Style, ticks []Tick) Box {
	var tx int
	if ya.AxisType == YAxisPrimary {
		tx = canvasBox.Right + DefaultYAxisMargin
	} else if ya.AxisType == YAxisSecondary {
		tx = canvasBox.Left - DefaultYAxisMargin
	}

	ya.TickStyle.InheritFrom(ya.Style.InheritFrom(defaults)).WriteToRenderer(r)
	var minx, maxx, miny, maxy = math.MaxInt32, 0, math.MaxInt32, 0
	var maxTextHeight int
	for _, t := range ticks {
		v := t.Value
		ly := canvasBox.Bottom - ra.Translate(v)

		tb := r.MeasureText(t.Label)
		tbh2 := tb.Height() >> 1
		finalTextX := tx
		if ya.AxisType == YAxisSecondary {
			finalTextX = tx - tb.Width()
		}

		maxTextHeight = util.Math.MaxInt(tb.Height(), maxTextHeight)

		if ya.AxisType == YAxisPrimary {
			minx = canvasBox.Right
			maxx = util.Math.MaxInt(maxx, tx+tb.Width())
		} else if ya.AxisType == YAxisSecondary {
			minx = util.Math.MinInt(minx, finalTextX)
			maxx = util.Math.MaxInt(maxx, tx)
		}

		miny = util.Math.MinInt(miny, ly-tbh2)
		maxy = util.Math.MaxInt(maxy, ly+tbh2)
	}

	if ya.NameStyle.Show && len(ya.Name) > 0 {
		maxx += (DefaultYAxisMargin + maxTextHeight)
	}

	return Box{
		Top:    miny,
		Left:   minx,
		Right:  maxx,
		Bottom: maxy,
	}
}
224340
func (p *Parser) ParseString(src string) (model.Stmts, error) {
	return p.Parse([]byte(src))
}
116648
func (rl Raw) DisplayString() string {
	if rl.displayString != "" {
		return rl.displayString
	}

	if i := rl.sepLoc; i > -1 {
		rl.displayString = util.StripANSISequence(rl.buf[:i])
	} else {
		rl.displayString = util.StripANSISequence(rl.buf)
	}
	return rl.displayString
}
1180560
func (wd *WeightDevice) WeightString() string {
	return fmt.Sprintf("%d:%d %d", wd.Major, wd.Minor, wd.Weight)
}