Skip to content

Commit

Permalink
gofmt on go 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
mkusaka committed Jan 8, 2023
1 parent 2dec1a9 commit 41b0339
Show file tree
Hide file tree
Showing 39 changed files with 174 additions and 174 deletions.
12 changes: 6 additions & 6 deletions buff.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package gopdf

//Buff for pdf content
// Buff for pdf content
type Buff struct {
position int
datas []byte
}

//Write : write []byte to buffer
// Write : write []byte to buffer
func (b *Buff) Write(p []byte) (int, error) {
for len(b.datas) < b.position+len(p) {
b.datas = append(b.datas, 0)
Expand All @@ -21,22 +21,22 @@ func (b *Buff) Write(p []byte) (int, error) {
return 0, nil
}

//Len : len of buffer
// Len : len of buffer
func (b *Buff) Len() int {
return len(b.datas)
}

//Bytes : get bytes
// Bytes : get bytes
func (b *Buff) Bytes() []byte {
return b.datas
}

//Position : get current postion
// Position : get current postion
func (b *Buff) Position() int {
return b.position
}

//SetPosition : set current postion
// SetPosition : set current postion
func (b *Buff) SetPosition(pos int) {
b.position = pos
}
8 changes: 4 additions & 4 deletions buff_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gopdf

import "io"

//WriteUInt32 writes a 32-bit unsigned integer value to w io.Writer
// WriteUInt32 writes a 32-bit unsigned integer value to w io.Writer
func WriteUInt32(w io.Writer, v uint) error {
a := byte(v >> 24)
b := byte(v >> 16)
Expand All @@ -15,7 +15,7 @@ func WriteUInt32(w io.Writer, v uint) error {
return nil
}

//WriteUInt16 writes a 16-bit unsigned integer value to w io.Writer
// WriteUInt16 writes a 16-bit unsigned integer value to w io.Writer
func WriteUInt16(w io.Writer, v uint) error {

a := byte(v >> 8)
Expand All @@ -27,7 +27,7 @@ func WriteUInt16(w io.Writer, v uint) error {
return nil
}

//WriteTag writes string value to w io.Writer
// WriteTag writes string value to w io.Writer
func WriteTag(w io.Writer, tag string) error {
b := []byte(tag)
_, err := w.Write(b)
Expand All @@ -37,7 +37,7 @@ func WriteTag(w io.Writer, tag string) error {
return nil
}

//WriteBytes writes []byte value to w io.Writer
// WriteBytes writes []byte value to w io.Writer
func WriteBytes(w io.Writer, data []byte, offset int, count int) error {

_, err := w.Write(data[offset : offset+count])
Expand Down
10 changes: 5 additions & 5 deletions cache_content_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const defaultCoefLineHeight = float64(1)
const defaultCoefUnderlinePosition = float64(1)
const defaultcoefUnderlineThickness = float64(1)

//ContentTypeCell cell
// ContentTypeCell cell
const ContentTypeCell = 0

//ContentTypeText text
// ContentTypeText text
const ContentTypeText = 1

type cacheContentText struct {
Expand Down Expand Up @@ -369,12 +369,12 @@ func kern(f *SubsetFontObj, leftRune rune, rightRune rune, leftIndex uint, right
return pairVal
}

//CacheContent Export cacheContent
// CacheContent Export cacheContent
type CacheContent struct {
cacheContentText
}

//Setup setup all information for cacheContent
// Setup setup all information for cacheContent
func (c *CacheContent) Setup(rectangle *Rect,
textColor ICacheColorText,
grayFill float64,
Expand Down Expand Up @@ -407,7 +407,7 @@ func (c *CacheContent) Setup(rectangle *Rect,
}
}

//WriteTextToContent write text to content
// WriteTextToContent write text to content
func (c *CacheContent) WriteTextToContent(text string) {
c.cacheContentText.text += text
}
2 changes: 1 addition & 1 deletion catalog_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
)

//CatalogObj : catalog dictionary
// CatalogObj : catalog dictionary
type CatalogObj struct { //impl IObj
outlinesObjID int
}
Expand Down
16 changes: 8 additions & 8 deletions cell_option.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package gopdf

//Left left
// Left left
const Left = 8 //001000
//Top top
// Top top
const Top = 4 //000100
//Right right
// Right right
const Right = 2 //000010
//Bottom bottom
// Bottom bottom
const Bottom = 1 //000001
//Center center
// Center center
const Center = 16 //010000
//Middle middle
// Middle middle
const Middle = 32 //100000
//AllBorders allborders
// AllBorders allborders
const AllBorders = 15 //001111

//CellOption cell option
// CellOption cell option
type CellOption struct {
Align int //Allows to align the text. Possible values are: Left,Center,Right,Top,Bottom,Middle
Border int //Indicates if borders must be drawn around the cell. Possible values are: Left, Top, Right, Bottom, ALL
Expand Down
4 changes: 2 additions & 2 deletions cid_font_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CIDFontObj struct {
func (ci *CIDFontObj) init(funcGetRoot func() *GoPdf) {
}

//SetIndexObjSubfontDescriptor set indexObjSubfontDescriptor
// SetIndexObjSubfontDescriptor set indexObjSubfontDescriptor
func (ci *CIDFontObj) SetIndexObjSubfontDescriptor(index int) {
ci.indexObjSubfontDescriptor = index
}
Expand Down Expand Up @@ -47,7 +47,7 @@ func (ci *CIDFontObj) write(w io.Writer, objID int) error {
return nil
}

//SetPtrToSubsetFontObj set PtrToSubsetFontObj
// SetPtrToSubsetFontObj set PtrToSubsetFontObj
func (ci *CIDFontObj) SetPtrToSubsetFontObj(ptr *SubsetFontObj) {
ci.PtrToSubsetFontObj = ptr
}
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
Unit_IN = UnitIN // inches
)

//Config static config
// Config static config
type Config struct {
Unit int // The unit type to use when composing the document.
TrimBox Box // The default trim box for all pages in the document
Expand All @@ -34,7 +34,7 @@ type Config struct {
Protection PDFProtectionConfig // Protection settings
}

//PDFProtectionConfig config of pdf protection
// PDFProtectionConfig config of pdf protection
type PDFProtectionConfig struct {
UseProtection bool
Permissions int
Expand Down
54 changes: 27 additions & 27 deletions content_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
)

//ContentObj content object
// ContentObj content object
type ContentObj struct { //impl IObj
listCache listCacheContent
//text bytes.Buffer
Expand Down Expand Up @@ -98,7 +98,7 @@ func (c *ContentObj) getType() string {
return "Content"
}

//AppendStreamText append text
// AppendStreamText append text
func (c *ContentObj) AppendStreamText(text string) error {

//support only CURRENT_FONT_TYPE_SUBSET
Expand Down Expand Up @@ -141,7 +141,7 @@ func (c *ContentObj) AppendStreamText(text string) error {
return nil
}

//AppendStreamSubsetFont add stream of text
// AppendStreamSubsetFont add stream of text
func (c *ContentObj) AppendStreamSubsetFont(rectangle *Rect, text string, cellOpt CellOption) error {

textColor := c.getRoot().curr.textColor()
Expand Down Expand Up @@ -179,7 +179,7 @@ func (c *ContentObj) AppendStreamSubsetFont(rectangle *Rect, text string, cellOp
return nil
}

//AppendStreamLine append line
// AppendStreamLine append line
func (c *ContentObj) AppendStreamLine(x1 float64, y1 float64, x2 float64, y2 float64, lineOpts lineOptions) {
//h := c.getRoot().config.PageSize.H
//c.stream.WriteString(fmt.Sprintf("%0.2f %0.2f m %0.2f %0.2f l s\n", x1, h-y1, x2, h-y2))
Expand All @@ -193,7 +193,7 @@ func (c *ContentObj) AppendStreamLine(x1 float64, y1 float64, x2 float64, y2 flo
c.listCache.append(&cache)
}

//AppendStreamImportedTemplate append imported template
// AppendStreamImportedTemplate append imported template
func (c *ContentObj) AppendStreamImportedTemplate(tplName string, scaleX float64, scaleY float64, tX float64, tY float64) {
var cache cacheContentImportedTemplate
cache.pageHeight = c.getRoot().curr.pageSize.H
Expand All @@ -210,7 +210,7 @@ func (c *ContentObj) AppendStreamRectangle(opts DrawableRectOptions) {
c.listCache.append(cache)
}

//AppendStreamOval append oval
// AppendStreamOval append oval
func (c *ContentObj) AppendStreamOval(x1 float64, y1 float64, x2 float64, y2 float64) {
var cache cacheContentOval
cache.pageHeight = c.getRoot().curr.pageSize.H
Expand All @@ -221,15 +221,15 @@ func (c *ContentObj) AppendStreamOval(x1 float64, y1 float64, x2 float64, y2 flo
c.listCache.append(&cache)
}

//AppendStreamCurve draw curve
// - x0, y0: Start point
// - x1, y1: Control point 1
// - x2, y2: Control point 2
// - x3, y3: End point
// - style: Style of rectangule (draw and/or fill: D, F, DF, FD)
// D or empty string: draw. This is the default value.
// F: fill
// DF or FD: draw and fill
// AppendStreamCurve draw curve
// - x0, y0: Start point
// - x1, y1: Control point 1
// - x2, y2: Control point 2
// - x3, y3: End point
// - style: Style of rectangule (draw and/or fill: D, F, DF, FD)
// D or empty string: draw. This is the default value.
// F: fill
// DF or FD: draw and fill
func (c *ContentObj) AppendStreamCurve(x0 float64, y0 float64, x1 float64, y1 float64, x2 float64, y2 float64, x3 float64, y3 float64, style string) {
var cache cacheContentCurve
cache.pageHeight = c.getRoot().curr.pageSize.H
Expand All @@ -245,22 +245,22 @@ func (c *ContentObj) AppendStreamCurve(x0 float64, y0 float64, x1 float64, y1 fl
c.listCache.append(&cache)
}

//AppendStreamSetLineWidth : set line width
// AppendStreamSetLineWidth : set line width
func (c *ContentObj) AppendStreamSetLineWidth(w float64) {
var cache cacheContentLineWidth
cache.width = w
c.listCache.append(&cache)
}

//AppendStreamSetLineType : Set linetype [solid, dashed, dotted]
// AppendStreamSetLineType : Set linetype [solid, dashed, dotted]
func (c *ContentObj) AppendStreamSetLineType(t string) {
var cache cacheContentLineType
cache.lineType = t
c.listCache.append(&cache)

}

//AppendStreamSetGrayFill set the grayscale fills
// AppendStreamSetGrayFill set the grayscale fills
func (c *ContentObj) AppendStreamSetGrayFill(w float64) {
w = fixRange10(w)
var cache cacheContentGray
Expand All @@ -269,7 +269,7 @@ func (c *ContentObj) AppendStreamSetGrayFill(w float64) {
c.listCache.append(&cache)
}

//AppendStreamSetGrayStroke set the grayscale stroke
// AppendStreamSetGrayStroke set the grayscale stroke
func (c *ContentObj) AppendStreamSetGrayStroke(w float64) {
w = fixRange10(w)
var cache cacheContentGray
Expand All @@ -278,7 +278,7 @@ func (c *ContentObj) AppendStreamSetGrayStroke(w float64) {
c.listCache.append(&cache)
}

//AppendStreamSetColorStroke set the color stroke
// AppendStreamSetColorStroke set the color stroke
func (c *ContentObj) AppendStreamSetColorStroke(r uint8, g uint8, b uint8) {
var cache cacheContentColorRGB
cache.colorType = colorTypeStrokeRGB
Expand All @@ -288,7 +288,7 @@ func (c *ContentObj) AppendStreamSetColorStroke(r uint8, g uint8, b uint8) {
c.listCache.append(&cache)
}

//AppendStreamSetColorFill set the color fill
// AppendStreamSetColorFill set the color fill
func (c *ContentObj) AppendStreamSetColorFill(r uint8, g uint8, b uint8) {
var cache cacheContentColorRGB
cache.colorType = colorTypeFillRGB
Expand All @@ -298,7 +298,7 @@ func (c *ContentObj) AppendStreamSetColorFill(r uint8, g uint8, b uint8) {
c.listCache.append(&cache)
}

//AppendStreamSetColorStrokeCMYK set the color stroke in CMYK color mode
// AppendStreamSetColorStrokeCMYK set the color stroke in CMYK color mode
func (c *ContentObj) AppendStreamSetColorStrokeCMYK(cy, m, y, k uint8) {
var cache cacheContentColorCMYK
cache.colorType = colorTypeStrokeCMYK
Expand All @@ -309,7 +309,7 @@ func (c *ContentObj) AppendStreamSetColorStrokeCMYK(cy, m, y, k uint8) {
c.listCache.append(&cache)
}

//AppendStreamSetColorFillCMYK set the color fill in CMYK color mode
// AppendStreamSetColorFillCMYK set the color fill in CMYK color mode
func (c *ContentObj) AppendStreamSetColorFillCMYK(cy, m, y, k uint8) {
var cache cacheContentColorCMYK
cache.colorType = colorTypeFillCMYK
Expand Down Expand Up @@ -347,13 +347,13 @@ func (c *ContentObj) GetCacheContentImage(index int, opts ImageOptions) *cacheCo
}
}

//AppendStreamImage append image
// AppendStreamImage append image
func (c *ContentObj) AppendStreamImage(index int, opts ImageOptions) {
cache := c.GetCacheContentImage(index, opts)
c.listCache.append(cache)
}

//AppendStreamPolygon append polygon
// AppendStreamPolygon append polygon
func (c *ContentObj) AppendStreamPolygon(points []Point, style string, opts polygonOptions) {
var cache cacheContentPolygon
cache.points = points
Expand All @@ -379,12 +379,12 @@ func (c *ContentObj) appendRotateReset() {
c.listCache.append(&cache)
}

//ContentObjCalTextHeight : calculates height of text.
// ContentObjCalTextHeight : calculates height of text.
func ContentObjCalTextHeight(fontsize int) float64 {
return ContentObjCalTextHeightPrecise(float64(fontsize))
}

//ContentObjCalTextHeightPrecise : like ContentObjCalTextHeight,
// ContentObjCalTextHeightPrecise : like ContentObjCalTextHeight,
// but fontsize float64
func ContentObjCalTextHeightPrecise(fontsize float64) float64 {
return (float64(fontsize) * 0.7)
Expand Down
2 changes: 1 addition & 1 deletion current.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gopdf

//Current current state
// Current current state
type Current struct {
setXCount int //many times we go func SetX()
X float64
Expand Down
4 changes: 2 additions & 2 deletions device_rgb_obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
)

//DeviceRGBObj DeviceRGB
// DeviceRGBObj DeviceRGB
type DeviceRGBObj struct {
data []byte
getRoot func() *GoPdf
Expand All @@ -23,7 +23,7 @@ func (d *DeviceRGBObj) getType() string {
return "devicergb"
}

//สร้าง ข้อมูลใน pdf
// สร้าง ข้อมูลใน pdf
func (d *DeviceRGBObj) write(w io.Writer, objID int) error {

io.WriteString(w, "<<\n")
Expand Down
Loading

0 comments on commit 41b0339

Please sign in to comment.