From 80eb3e2a5ac1dddbbf7bd76e8065298f5257f122 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 30 Jul 2016 17:30:11 -0400 Subject: Fix some glitches reported by goreportcard.com --- fpdf.go | 7 ++++--- fpdf_test.go | 24 ++++++++++++------------ internal/files/bin/Makefile | 4 +++- internal/files/files.go | 2 ++ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/fpdf.go b/fpdf.go index 35f6878..9e6c862 100644 --- a/fpdf.go +++ b/fpdf.go @@ -1405,8 +1405,9 @@ func (f *Fpdf) AddFont(familyStr, styleStr, fileStr string) { f.AddFontFromReader(familyStr, styleStr, file) } -// AddFontFronBytes imports a TrueType, OpenType or Type1 font and makes it -// available for use in the generated document. +// AddFontFromBytes imports a TrueType, OpenType or Type1 font from static +// bytes within the executable and makes it available for use in the generated +// document. // // family specifies the font family. The name can be chosen arbitrarily. If it // is a standard family name, it will override the corresponding font. This @@ -1417,7 +1418,7 @@ func (f *Fpdf) AddFont(familyStr, styleStr, fileStr string) { // "IB" for bold and italic combined. // // jsonFileBytes contain all bytes of JSON file. - +// // zFileBytes contain all bytes of Z file. func (f *Fpdf) AddFontFromBytes(familyStr string, styleStr string, jsonFileBytes []byte, zFileBytes []byte) { if f.err != nil { diff --git a/fpdf_test.go b/fpdf_test.go index bda0936..2b12bdd 100644 --- a/fpdf_test.go +++ b/fpdf_test.go @@ -1182,20 +1182,20 @@ func ExampleFpdf_CellFormat_2() { align, txt string } recList := []recType{ - recType{"TL", "top left"}, - recType{"TC", "top center"}, - recType{"TR", "top right"}, - recType{"LM", "middle left"}, - recType{"CM", "middle center"}, - recType{"RM", "middle right"}, - recType{"BL", "bottom left"}, - recType{"BC", "bottom center"}, - recType{"BR", "bottom right"}, + {"TL", "top left"}, + {"TC", "top center"}, + {"TR", "top right"}, + {"LM", "middle left"}, + {"CM", "middle center"}, + {"RM", "middle right"}, + {"BL", "bottom left"}, + {"BC", "bottom center"}, + {"BR", "bottom right"}, } recListBaseline := []recType{ - recType{"AL", "baseline left"}, - recType{"AC", "baseline center"}, - recType{"AR", "baseline right"}, + {"AL", "baseline left"}, + {"AC", "baseline center"}, + {"AR", "baseline right"}, } var formatRect = func(pdf *gofpdf.Fpdf, recList []recType) { linkStr := "" diff --git a/internal/files/bin/Makefile b/internal/files/bin/Makefile index 64b9a77..3aff64c 100644 --- a/internal/files/bin/Makefile +++ b/internal/files/bin/Makefile @@ -5,14 +5,16 @@ Z= ../../../font/calligra.z ${TRG} : ${JSON} ${Z} ./bin echo "package files" > ${TRG} echo "" >> ${TRG} + echo "// CalligraJson is embedded byte slice for calligra.json" >> ${TRG} echo "var CalligraJson = []byte{" >> ${TRG} ./bin < ${JSON} >> ${TRG} echo "}" >> ${TRG} echo "" >> ${TRG} + echo "// CalligraZ is embedded byte slice for calligra.z" >> ${TRG} echo "var CalligraZ = []byte{" >> ${TRG} ./bin < ${Z} >> ${TRG} echo "}" >> ${TRG} - gofmt -w ${TRG} + gofmt -s -w ${TRG} ./bin : bin.go go build -v diff --git a/internal/files/files.go b/internal/files/files.go index eda2fb7..7f73413 100644 --- a/internal/files/files.go +++ b/internal/files/files.go @@ -1,5 +1,6 @@ package files +// CalligraJson is embedded byte slice for calligra.json var CalligraJson = []byte{ 0x7B, 0x22, 0x54, 0x70, 0x22, 0x3A, 0x22, 0x54, 0x72, 0x75, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x2C, 0x22, 0x4E, 0x61, 0x6D, 0x65, 0x22, 0x3A, 0x22, 0x43, 0x61, 0x6C, 0x6C, 0x69, 0x67, 0x72, @@ -85,6 +86,7 @@ var CalligraJson = []byte{ 0x2C, 0x22, 0x4E, 0x22, 0x3A, 0x30, 0x2C, 0x22, 0x44, 0x69, 0x66, 0x66, 0x4E, 0x22, 0x3A, 0x30, 0x7D} +// CalligraZ is embedded byte slice for calligra.z var CalligraZ = []byte{ 0x78, 0x9C, 0xA4, 0xFC, 0x07, 0x80, 0x5C, 0x57, 0x7D, 0x2F, 0x8E, 0x9F, 0x73, 0x6E, 0xEF, 0xFD, 0xDE, 0xE9, 0xBD, 0xF7, 0x9D, 0xD9, 0x99, 0xD9, 0xDD, 0x99, 0xDD, 0x99, 0xED, 0xAB, 0xDE, 0x65, -- cgit v1.2.1-24-ge1ad