mirror of
https://github.com/fumiama/go-docx.git
synced 2026-06-17 23:52:34 +08:00
add w:kern
This commit is contained in:
@@ -49,6 +49,12 @@ type Highlight struct {
|
|||||||
Val string `xml:"w:val,attr,omitempty"`
|
Val string `xml:"w:val,attr,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kern ...
|
||||||
|
type Kern struct {
|
||||||
|
XMLName xml.Name `xml:"w:kern,omitempty"`
|
||||||
|
Val int64 `xml:"w:val,attr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Justification contains the way of the horizonal alignment
|
// Justification contains the way of the horizonal alignment
|
||||||
//
|
//
|
||||||
// w:jc 属性的取值可以是以下之一:
|
// w:jc 属性的取值可以是以下之一:
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
"io"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ type ParagraphProperties struct {
|
|||||||
XMLName xml.Name `xml:"w:pPr,omitempty"`
|
XMLName xml.Name `xml:"w:pPr,omitempty"`
|
||||||
Justification *Justification
|
Justification *Justification
|
||||||
Shade *Shade
|
Shade *Shade
|
||||||
|
Kern *Kern
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalXML ...
|
// UnmarshalXML ...
|
||||||
@@ -56,6 +58,17 @@ func (p *ParagraphProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElemen
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.Shade = &value
|
p.Shade = &value
|
||||||
|
case "kern":
|
||||||
|
var value Kern
|
||||||
|
v := getAtt(tt.Attr, "val")
|
||||||
|
if v == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
value.Val, err = strconv.ParseInt(v, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.Kern = &value
|
||||||
default:
|
default:
|
||||||
err = d.Skip() // skip unsupported tags
|
err = d.Skip() // skip unsupported tags
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
13
structrun.go
13
structrun.go
@@ -23,6 +23,7 @@ package docx
|
|||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
"io"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -148,6 +149,7 @@ type RunProperties struct {
|
|||||||
RunStyle *RunStyle
|
RunStyle *RunStyle
|
||||||
Style *Style
|
Style *Style
|
||||||
Shade *Shade
|
Shade *Shade
|
||||||
|
Kern *Kern
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalXML ...
|
// UnmarshalXML ...
|
||||||
@@ -205,6 +207,17 @@ func (r *RunProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.Shade = &value
|
r.Shade = &value
|
||||||
|
case "kern":
|
||||||
|
var value Kern
|
||||||
|
v := getAtt(tt.Attr, "val")
|
||||||
|
if v == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
value.Val, err = strconv.ParseInt(v, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
r.Kern = &value
|
||||||
default:
|
default:
|
||||||
err = d.Skip() // skip unsupported tags
|
err = d.Skip() // skip unsupported tags
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user