2017-09-04 10:50:29 -05: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 drawing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"baliance.com/gooxml"
|
|
|
|
"baliance.com/gooxml/color"
|
|
|
|
"baliance.com/gooxml/measurement"
|
2017-09-23 08:39:08 -05:00
|
|
|
"baliance.com/gooxml/schema/soo/dml"
|
2017-09-04 10:50:29 -05:00
|
|
|
)
|
|
|
|
|
2017-10-03 09:55:27 -05:00
|
|
|
// RunProperties controls the run properties.
|
2017-09-04 10:50:29 -05:00
|
|
|
type RunProperties struct {
|
|
|
|
x *dml.CT_TextCharacterProperties
|
|
|
|
}
|
|
|
|
|
2017-10-03 09:55:27 -05:00
|
|
|
// MakeRunProperties constructs a new RunProperties wrapper.
|
2017-09-04 10:50:29 -05:00
|
|
|
func MakeRunProperties(x *dml.CT_TextCharacterProperties) RunProperties {
|
|
|
|
return RunProperties{x}
|
|
|
|
}
|
2017-10-03 09:55:27 -05:00
|
|
|
|
|
|
|
// SetSize sets the font size of the run text
|
2017-09-04 10:50:29 -05:00
|
|
|
func (r RunProperties) SetSize(sz measurement.Distance) {
|
|
|
|
r.x.SzAttr = gooxml.Int32(int32(sz / measurement.HundredthPoint))
|
|
|
|
}
|
|
|
|
|
2017-10-03 09:55:27 -05:00
|
|
|
// SetBold controls the bolding of a run.
|
2017-09-04 10:50:29 -05:00
|
|
|
func (r RunProperties) SetBold(b bool) {
|
|
|
|
r.x.BAttr = gooxml.Bool(b)
|
|
|
|
}
|
2017-10-03 09:55:27 -05:00
|
|
|
|
|
|
|
// SetSolidFill controls the text color of a run.
|
2017-09-04 10:50:29 -05:00
|
|
|
func (r RunProperties) SetSolidFill(c color.Color) {
|
|
|
|
r.x.NoFill = nil
|
|
|
|
r.x.BlipFill = nil
|
|
|
|
r.x.GradFill = nil
|
|
|
|
r.x.GrpFill = nil
|
|
|
|
r.x.PattFill = nil
|
|
|
|
r.x.SolidFill = dml.NewCT_SolidColorFillProperties()
|
|
|
|
r.x.SolidFill.SrgbClr = dml.NewCT_SRgbColor()
|
|
|
|
r.x.SolidFill.SrgbClr.ValAttr = *c.AsRGBString()
|
|
|
|
}
|
2017-10-03 09:55:27 -05:00
|
|
|
|
|
|
|
// SetFont controls the font of a run.
|
2017-09-04 10:50:29 -05:00
|
|
|
func (r RunProperties) SetFont(s string) {
|
|
|
|
r.x.Latin = dml.NewCT_TextFont()
|
|
|
|
r.x.Latin.TypefaceAttr = s
|
|
|
|
}
|