关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。
想改进这个问题?将问题更新为 on-topic对于堆栈溢出。
1年前关闭。
Improve this question
这是为文本着色并在 ansi 控制台上提供粗体、闪烁、突出显示效果的脚本。
import (
"fmt"
"github.com/mgutz/ansi"
)
color1Func := ansi.ColorFunc(fmt.Sprintf("%v+bh:%v", 181, 255))
color2Func := ansi.ColorFunc(fmt.Sprintf("%v+B:%v", 121, 255))
io.WriteString(os.Stdout, color1Func(text1))
io.WriteString(os.Stdout, color2Func(text2))
我尝试打印斜体字体以设置更好的控制台应用程序样式,但在几天的挣扎中找不到任何地方。
这是 ansi 控制台无法实现的吗?
更新:
这就是我检查的
mgutz/ansi
图书馆 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
}
它有“i”,但不是斜体。
最佳答案
Is there anyway to print italic font on ansi console?
不。
来自 https://en.wikipedia.org/wiki/ANSI_escape_code :
Italic Not widely supported. Sometimes treated as inverse.
这在很大程度上取决于终端的细节,以至于没有可靠的可移植方式来做到这一点。
关于go - 无论如何在ansi控制台上打印斜体字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61793058/