mirror of
https://github.com/ZeroHawkeye/wordZero.git
synced 2025-09-26 20:01:17 +08:00
修改高亮,文本字体使用中文名称
This commit is contained in:
@@ -17,6 +17,7 @@ func main() {
|
||||
{FontFamily: "Calibri", FontSize: 16, Bold: true, Italic: true},
|
||||
{FontFamily: "Calibri", FontSize: 16, Underline: true},
|
||||
{FontFamily: "Calibri", FontSize: 16, Strike: true},
|
||||
{FontFamily: "微软雅黑", FontSize: 18, Highlight: "yellow"},
|
||||
}
|
||||
|
||||
texts := []string{
|
||||
@@ -26,6 +27,7 @@ func main() {
|
||||
"这是粗体斜体文本",
|
||||
"这是下划线文本",
|
||||
"这是删除线文本",
|
||||
"这是高亮文本",
|
||||
}
|
||||
|
||||
for i, text := range texts {
|
||||
|
@@ -284,6 +284,7 @@ type TextFormat struct {
|
||||
FontFamily string // 字体名称
|
||||
Underline bool // 是否下划线
|
||||
Strike bool // 删除线
|
||||
Highlight string //高亮颜色
|
||||
}
|
||||
|
||||
// AlignmentType 对齐类型
|
||||
@@ -610,7 +611,7 @@ func (d *Document) AddFormattedParagraph(text string, format *TextFormat) *Parag
|
||||
|
||||
if format != nil {
|
||||
if format.FontFamily != "" {
|
||||
runProps.FontFamily = &FontFamily{ASCII: format.FontFamily}
|
||||
runProps.FontFamily = &FontFamily{EastAsia: format.FontFamily}
|
||||
}
|
||||
|
||||
if format.Bold {
|
||||
@@ -638,6 +639,10 @@ func (d *Document) AddFormattedParagraph(text string, format *TextFormat) *Parag
|
||||
if format.Strike {
|
||||
runProps.Strike = &Strike{} // 添加删除线
|
||||
}
|
||||
|
||||
if format.Highlight != "" {
|
||||
runProps.Highlight = &Highlight{Val: format.Highlight}
|
||||
}
|
||||
}
|
||||
|
||||
p := &Paragraph{
|
||||
@@ -779,7 +784,7 @@ func (p *Paragraph) AddFormattedText(text string, format *TextFormat) {
|
||||
|
||||
if format != nil {
|
||||
if format.FontFamily != "" {
|
||||
runProps.FontFamily = &FontFamily{ASCII: format.FontFamily}
|
||||
runProps.FontFamily = &FontFamily{EastAsia: format.FontFamily}
|
||||
}
|
||||
|
||||
if format.Bold {
|
||||
@@ -805,6 +810,10 @@ func (p *Paragraph) AddFormattedText(text string, format *TextFormat) {
|
||||
if format.Strike {
|
||||
runProps.Strike = &Strike{} // 添加删除线
|
||||
}
|
||||
|
||||
if format.Highlight != "" {
|
||||
runProps.Highlight = &Highlight{Val: format.Highlight}
|
||||
}
|
||||
}
|
||||
|
||||
run := Run{
|
||||
|
Reference in New Issue
Block a user