Browse Source

More robust checking for font attributes

Brian Smith 10 years ago
parent
commit
9a0749bfbd
1 changed files with 6 additions and 6 deletions
  1. 6 6
      xmlStyle.go

+ 6 - 6
xmlStyle.go

@@ -105,13 +105,13 @@ func (styles *xlsxStyleSheet) getStyle(styleIndex int) (style *Style) {
 			style.Font.Charset, _ = strconv.Atoi(xfont.Charset.Val)
 			style.Font.Color = styles.argbValue(xfont.Color)
 
-			if xfont.B != nil {
+			if bold := xfont.B; bold != nil && bold.Val != "0" {
 				style.Font.Bold = true
 			}
-			if xfont.I != nil {
+			if italic := xfont.I; italic != nil && italic.Val != "0" {
 				style.Font.Italic = true
 			}
-			if xfont.U != nil {
+			if underline := xfont.U; underline != nil && underline.Val != "0"  {
 				style.Font.Underline = true
 			}
 		}
@@ -445,9 +445,9 @@ type xlsxFont struct {
 	Family  xlsxVal   `xml:"family,omitempty"`
 	Charset xlsxVal   `xml:"charset,omitempty"`
 	Color   xlsxColor `xml:"color,omitempty"`
-	B       *struct{} `xml:"b,omitempty"`
-	I       *struct{} `xml:"i,omitempty"`
-	U       *struct{} `xml:"u,omitempty"`
+	B       *xlsxVal  `xml:"b,omitempty"`
+	I       *xlsxVal  `xml:"i,omitempty"`
+	U       *xlsxVal  `xml:"u,omitempty"`
 }
 
 func (font *xlsxFont) Equals(other xlsxFont) bool {