// Regular font with a color
3538
func (c colorBase) Regular(a ...interface{}) string {
	return color.New(color.Attribute(c)).Sprint(a...)
}
122396
func setFont(formatStyle *formatStyle) *font {
	fontUnderlineType := map[string]string{"single": "single", "double": "double"}
	if formatStyle.Font.Size < 1 {
		formatStyle.Font.Size = 11
	}
	if formatStyle.Font.Color == "" {
		formatStyle.Font.Color = "#000000"
	}
	f := font{
		B:      formatStyle.Font.Bold,
		I:      formatStyle.Font.Italic,
		Sz:     &attrValInt{Val: formatStyle.Font.Size},
		Color:  &xlsxColor{RGB: getPaletteColor(formatStyle.Font.Color)},
		Name:   &attrValString{Val: formatStyle.Font.Family},
		Family: &attrValInt{Val: 2},
	}
	if f.Name.Val == "" {
		f.Name.Val = "Calibri"
		f.Scheme = &attrValString{Val: "minor"}
	}
	val, ok := fontUnderlineType[formatStyle.Font.Underline]
	if ok {
		f.U = &attrValString{Val: val}
	}
	return &f
}
1156571
func (f *Font) Close() {
	C.TTF_CloseFont(f.f)
	f.f = nil
}
496049
func Background(str string, color int) string {
	return applyTransform(str, func(idx int, line string) string {
		return fmt.Sprintf("%s%s%s", getBgColor(color), line, RESET)
	})
}
1279030
func (m *LevelMetadata) Text(enableColor bool) string {
	if enableColor {
		return m.ColorfulText
	}
	return m.RawText
}
829838
func (i FontWeight) String() string {
	switch i {
	case FontWeightNormal:
		return "FontWeightNormal"
	case FontWeightBold:
		return "FontWeightBold"
	default:
		return fmt.Sprintf("FontWeight(%d)", i)
	}
}
1354711
func (c *Colorize) Color(v string) string {
	return colorsRe.ReplaceAllString(c.cliColor.Color(v), "")
}
209760
func (d *DropDown) SetPrefixTextColor(color tcell.Color) *DropDown {
	d.prefixTextColor = color
	return d
}
1132354
func defaultFont(size int, scaling float64) font.Face {
	defaultFontInit.Do(func() {
		fontData, _ := assets.Asset("DroidSansMono.ttf")
		ttfontDefault, _ = freetype.ParseFont(fontData)
	})

	sz := int(float64(size) * scaling)

	return truetype.NewFace(ttfontDefault, &truetype.Options{Size: float64(sz), Hinting: font.HintingFull, DPI: 72})
}
399139
func (c *Colorize) Color(v string) string {
	matches := parseRe.FindAllStringIndex(v, -1)
	if len(matches) == 0 {
		return v
	}

	result := new(bytes.Buffer)
	colored := false
	m := []int{0, 0}
	for _, nm := range matches {
		// Write the text in between this match and the last
		result.WriteString(v[m[1]:nm[0]])
		m = nm

		var replace string
		if code, ok := c.Colors[v[m[0]+1:m[1]-1]]; ok {
			colored = true

			if !c.Disable {
				replace = fmt.Sprintf("\033[%sm", code)
			}
		} else {
			replace = v[m[0]:m[1]]
		}

		result.WriteString(replace)
	}
	result.WriteString(v[m[1]:])

	if colored && c.Reset && !c.Disable {
		// Write the clear byte at the end
		result.WriteString("\033[0m")
	}

	return result.String()
}
873218
func Font(buf []byte) (types.Type, error) {
	return doMatchMap(buf, matchers.Font)
}
183108
func colorize(text string, c color) string {
	return string(c) + text + string(endColor)
}
671924
func AutoStyle(i int, fill bool) (style Style) {
	nc, nl, ns := len(StandardColors), len(StandardLineStyles), len(StandardSymbols)

	si := i % ns
	ci := i % nc
	li := i % nl

	style.Symbol = StandardSymbols[si]
	style.SymbolColor = StandardColors[ci]
	style.LineColor = StandardColors[ci]
	style.SymbolSize = 1

	if fill {
		style.LineStyle = SolidLine
		style.LineWidth = 3
		if i < nc {
			style.FillColor = lighter(style.LineColor, StandardFillFactor)
		} else if i <= 2*nc {
			style.FillColor = darker(style.LineColor, StandardFillFactor)
		} else {
			style.FillColor = style.LineColor
		}
	} else {
		style.LineStyle = StandardLineStyles[li]
		style.LineWidth = 1
	}
	return
}
1037253
func GetDefaultFont() (*truetype.Font, error) {
	if _defaultFont == nil {
		_defaultFontLock.Lock()
		defer _defaultFontLock.Unlock()
		if _defaultFont == nil {
			font, err := truetype.Parse(roboto.Roboto)
			if err != nil {
				return nil, err
			}
			_defaultFont = font
		}
	}
	return _defaultFont, nil
}
1091482
func MustParseColour(colour string) Colour {
	parsed := ParseColour(colour)
	if !parsed.IsSet() {
		panic(fmt.Errorf("invalid colour %q", colour))
	}
	return parsed
}
194839
func Italic(arg interface{}) Value {
	if val, ok := arg.(Value); ok {
		return val.Italic()
	}
	return value{value: arg, color: ItalicFm}
}
310239
func colorCode(style string) *bytes.Buffer {
	buf := bytes.NewBufferString("")
	if plain || style == "" {
		return buf
	}
	if style == "reset" {
		buf.WriteString(Reset)
		return buf
	} else if style == "off" {
		return buf
	}

	foregroundBackground := strings.Split(style, ":")
	foreground := strings.Split(foregroundBackground[0], "+")
	fgKey := foreground[0]
	fg := Colors[fgKey]
	fgStyle := ""
	if len(foreground) > 1 {
		fgStyle = foreground[1]
	}

	bg, bgStyle := "", ""

	if len(foregroundBackground) > 1 {
		background := strings.Split(foregroundBackground[1], "+")
		bg = background[0]
		if len(background) > 1 {
			bgStyle = background[1]
		}
	}

	buf.WriteString(start)
	base := normalIntensityFG
	if len(fgStyle) > 0 {
		if strings.Contains(fgStyle, "b") {
			buf.WriteString(bold)
		}
		if strings.Contains(fgStyle, "B") {
			buf.WriteString(blink)
		}
		if strings.Contains(fgStyle, "u") {
			buf.WriteString(underline)
		}
		if strings.Contains(fgStyle, "i") {
			buf.WriteString(inverse)
		}
		if strings.Contains(fgStyle, "s") {
			buf.WriteString(strikethrough)
		}
		if strings.Contains(fgStyle, "h") {
			base = highIntensityFG
		}
	}

	// if 256-color
	n, err := strconv.Atoi(fgKey)
	if err == nil {
		fmt.Fprintf(buf, "38;5;%d;", n)
	} else {
		fmt.Fprintf(buf, "%d;", base+fg)
	}

	base = normalIntensityBG
	if len(bg) > 0 {
		if strings.Contains(bgStyle, "h") {
			base = highIntensityBG
		}
		// if 256-color
		n, err := strconv.Atoi(bg)
		if err == nil {
			fmt.Fprintf(buf, "48;5;%d;", n)
		} else {
			fmt.Fprintf(buf, "%d;", base+Colors[bg])
		}
	}

	// remove last ";"
	buf.Truncate(buf.Len() - 1)
	buf.WriteRune('m')
	return buf
}