1 Star 0 Fork 0

墙外行人/gooxml

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
font.go 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
墙外行人 提交于 2025-09-23 22:17 +08:00 . 替换
// Copyright 2017 Baliance. All rights reserved.
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package spreadsheet
import (
"gitee.com/qwxren/gooxml/color"
"gitee.com/qwxren/gooxml/schema/soo/sml"
)
// Font allows editing fonts within a spreadsheet stylesheet.
type Font struct {
font *sml.CT_Font
styles *sml.StyleSheet
}
// X returns the inner wrapped XML type.
func (f Font) X() *sml.CT_Font {
return f.font
}
func (f Font) Index() uint32 {
for i, sf := range f.styles.Fonts.Font {
if f.font == sf {
return uint32(i)
}
}
return 0
}
func (f Font) SetBold(b bool) {
if b {
f.font.B = []*sml.CT_BooleanProperty{{}}
} else {
f.font.B = nil
}
}
func (f Font) SetItalic(b bool) {
if b {
f.font.I = []*sml.CT_BooleanProperty{{}}
} else {
f.font.I = nil
}
}
func (f Font) SetName(name string) {
f.font.Name = []*sml.CT_FontName{{ValAttr: name}}
}
func (f Font) SetSize(size float64) {
f.font.Sz = []*sml.CT_FontSize{{ValAttr: size}}
}
func (f Font) SetColor(c color.Color) {
clr := sml.NewCT_Color()
clr.RgbAttr = c.AsRGBString()
f.font.Color = []*sml.CT_Color{clr}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/qwxren/gooxml.git
git@gitee.com:qwxren/gooxml.git
qwxren
gooxml
gooxml
v1.0.17-alpha

搜索帮助