repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
buger/jsonparser | escape.go | decodeSingleUnicodeEscape | func decodeSingleUnicodeEscape(in []byte) (rune, bool) {
// We need at least 6 characters total
if len(in) < 6 {
return utf8.RuneError, false
}
// Convert hex to decimal
h1, h2, h3, h4 := h2I(in[2]), h2I(in[3]), h2I(in[4]), h2I(in[5])
if h1 == badHex || h2 == badHex || h3 == badHex || h4 == badHex {
return u... | go | func decodeSingleUnicodeEscape(in []byte) (rune, bool) {
// We need at least 6 characters total
if len(in) < 6 {
return utf8.RuneError, false
}
// Convert hex to decimal
h1, h2, h3, h4 := h2I(in[2]), h2I(in[3]), h2I(in[4]), h2I(in[5])
if h1 == badHex || h2 == badHex || h3 == badHex || h4 == badHex {
return u... | [
"func",
"decodeSingleUnicodeEscape",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"rune",
",",
"bool",
")",
"{",
"// We need at least 6 characters total",
"if",
"len",
"(",
"in",
")",
"<",
"6",
"{",
"return",
"utf8",
".",
"RuneError",
",",
"false",
"\n",
"}",
... | // decodeSingleUnicodeEscape decodes a single \uXXXX escape sequence. The prefix \u is assumed to be present and
// is not checked.
// In JSON, these escapes can either come alone or as part of "UTF16 surrogate pairs" that must be handled together.
// This function only handles one; decodeUnicodeEscape handles this mor... | [
"decodeSingleUnicodeEscape",
"decodes",
"a",
"single",
"\\",
"uXXXX",
"escape",
"sequence",
".",
"The",
"prefix",
"\\",
"u",
"is",
"assumed",
"to",
"be",
"present",
"and",
"is",
"not",
"checked",
".",
"In",
"JSON",
"these",
"escapes",
"can",
"either",
"come"... | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/escape.go#L39-L53 | train |
buger/jsonparser | bytes.go | parseInt | func parseInt(bytes []byte) (v int64, ok bool, overflow bool) {
if len(bytes) == 0 {
return 0, false, false
}
var neg bool = false
if bytes[0] == '-' {
neg = true
bytes = bytes[1:]
}
var b int64 = 0
for _, c := range bytes {
if c >= '0' && c <= '9' {
b = (10 * v) + int64(c-'0')
} else {
return ... | go | func parseInt(bytes []byte) (v int64, ok bool, overflow bool) {
if len(bytes) == 0 {
return 0, false, false
}
var neg bool = false
if bytes[0] == '-' {
neg = true
bytes = bytes[1:]
}
var b int64 = 0
for _, c := range bytes {
if c >= '0' && c <= '9' {
b = (10 * v) + int64(c-'0')
} else {
return ... | [
"func",
"parseInt",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"v",
"int64",
",",
"ok",
"bool",
",",
"overflow",
"bool",
")",
"{",
"if",
"len",
"(",
"bytes",
")",
"==",
"0",
"{",
"return",
"0",
",",
"false",
",",
"false",
"\n",
"}",
"\n\n",
"var... | // About 2x faster then strconv.ParseInt because it only supports base 10, which is enough for JSON | [
"About",
"2x",
"faster",
"then",
"strconv",
".",
"ParseInt",
"because",
"it",
"only",
"supports",
"base",
"10",
"which",
"is",
"enough",
"for",
"JSON"
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/bytes.go#L11-L47 | train |
buger/jsonparser | parser.go | lastToken | func lastToken(data []byte) int {
for i := len(data) - 1; i >= 0; i-- {
switch data[i] {
case ' ', '\n', '\r', '\t':
continue
default:
return i
}
}
return -1
} | go | func lastToken(data []byte) int {
for i := len(data) - 1; i >= 0; i-- {
switch data[i] {
case ' ', '\n', '\r', '\t':
continue
default:
return i
}
}
return -1
} | [
"func",
"lastToken",
"(",
"data",
"[",
"]",
"byte",
")",
"int",
"{",
"for",
"i",
":=",
"len",
"(",
"data",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"switch",
"data",
"[",
"i",
"]",
"{",
"case",
"' '",
",",
"'\\n'",
",",
"'\\... | // Find position of last character which is not whitespace | [
"Find",
"position",
"of",
"last",
"character",
"which",
"is",
"not",
"whitespace"
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L137-L148 | train |
buger/jsonparser | parser.go | stringEnd | func stringEnd(data []byte) (int, bool) {
escaped := false
for i, c := range data {
if c == '"' {
if !escaped {
return i + 1, false
} else {
j := i - 1
for {
if j < 0 || data[j] != '\\' {
return i + 1, true // even number of backslashes
}
j--
if j < 0 || data[j] != '\\' {... | go | func stringEnd(data []byte) (int, bool) {
escaped := false
for i, c := range data {
if c == '"' {
if !escaped {
return i + 1, false
} else {
j := i - 1
for {
if j < 0 || data[j] != '\\' {
return i + 1, true // even number of backslashes
}
j--
if j < 0 || data[j] != '\\' {... | [
"func",
"stringEnd",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"bool",
")",
"{",
"escaped",
":=",
"false",
"\n",
"for",
"i",
",",
"c",
":=",
"range",
"data",
"{",
"if",
"c",
"==",
"'\"'",
"{",
"if",
"!",
"escaped",
"{",
"return",
"i"... | // Tries to find the end of string
// Support if string contains escaped quote symbols. | [
"Tries",
"to",
"find",
"the",
"end",
"of",
"string",
"Support",
"if",
"string",
"contains",
"escaped",
"quote",
"symbols",
"."
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L152-L178 | train |
buger/jsonparser | parser.go | ArrayEach | func ArrayEach(data []byte, cb func(value []byte, dataType ValueType, offset int, err error), keys ...string) (offset int, err error) {
if len(data) == 0 {
return -1, MalformedObjectError
}
offset = 1
if len(keys) > 0 {
if offset = searchKeys(data, keys...); offset == -1 {
return offset, KeyPathNotFoundErr... | go | func ArrayEach(data []byte, cb func(value []byte, dataType ValueType, offset int, err error), keys ...string) (offset int, err error) {
if len(data) == 0 {
return -1, MalformedObjectError
}
offset = 1
if len(keys) > 0 {
if offset = searchKeys(data, keys...); offset == -1 {
return offset, KeyPathNotFoundErr... | [
"func",
"ArrayEach",
"(",
"data",
"[",
"]",
"byte",
",",
"cb",
"func",
"(",
"value",
"[",
"]",
"byte",
",",
"dataType",
"ValueType",
",",
"offset",
"int",
",",
"err",
"error",
")",
",",
"keys",
"...",
"string",
")",
"(",
"offset",
"int",
",",
"err"... | // ArrayEach is used when iterating arrays, accepts a callback function with the same return arguments as `Get`. | [
"ArrayEach",
"is",
"used",
"when",
"iterating",
"arrays",
"accepts",
"a",
"callback",
"function",
"with",
"the",
"same",
"return",
"arguments",
"as",
"Get",
"."
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L902-L979 | train |
buger/jsonparser | parser.go | ObjectEach | func ObjectEach(data []byte, callback func(key []byte, value []byte, dataType ValueType, offset int) error, keys ...string) (err error) {
var stackbuf [unescapeStackBufSize]byte // stack-allocated array for allocation-free unescaping of small strings
offset := 0
// Descend to the desired key, if requested
if len(k... | go | func ObjectEach(data []byte, callback func(key []byte, value []byte, dataType ValueType, offset int) error, keys ...string) (err error) {
var stackbuf [unescapeStackBufSize]byte // stack-allocated array for allocation-free unescaping of small strings
offset := 0
// Descend to the desired key, if requested
if len(k... | [
"func",
"ObjectEach",
"(",
"data",
"[",
"]",
"byte",
",",
"callback",
"func",
"(",
"key",
"[",
"]",
"byte",
",",
"value",
"[",
"]",
"byte",
",",
"dataType",
"ValueType",
",",
"offset",
"int",
")",
"error",
",",
"keys",
"...",
"string",
")",
"(",
"e... | // ObjectEach iterates over the key-value pairs of a JSON object, invoking a given callback for each such entry | [
"ObjectEach",
"iterates",
"over",
"the",
"key",
"-",
"value",
"pairs",
"of",
"a",
"JSON",
"object",
"invoking",
"a",
"given",
"callback",
"for",
"each",
"such",
"entry"
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L982-L1086 | train |
buger/jsonparser | parser.go | GetUnsafeString | func GetUnsafeString(data []byte, keys ...string) (val string, err error) {
v, _, _, e := Get(data, keys...)
if e != nil {
return "", e
}
return bytesToString(&v), nil
} | go | func GetUnsafeString(data []byte, keys ...string) (val string, err error) {
v, _, _, e := Get(data, keys...)
if e != nil {
return "", e
}
return bytesToString(&v), nil
} | [
"func",
"GetUnsafeString",
"(",
"data",
"[",
"]",
"byte",
",",
"keys",
"...",
"string",
")",
"(",
"val",
"string",
",",
"err",
"error",
")",
"{",
"v",
",",
"_",
",",
"_",
",",
"e",
":=",
"Get",
"(",
"data",
",",
"keys",
"...",
")",
"\n\n",
"if"... | // GetUnsafeString returns the value retrieved by `Get`, use creates string without memory allocation by mapping string to slice memory. It does not handle escape symbols. | [
"GetUnsafeString",
"returns",
"the",
"value",
"retrieved",
"by",
"Get",
"use",
"creates",
"string",
"without",
"memory",
"allocation",
"by",
"mapping",
"string",
"to",
"slice",
"memory",
".",
"It",
"does",
"not",
"handle",
"escape",
"symbols",
"."
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1089-L1097 | train |
buger/jsonparser | parser.go | GetString | func GetString(data []byte, keys ...string) (val string, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return "", e
}
if t != String {
return "", fmt.Errorf("Value is not a string: %s", string(v))
}
// If no escapes return raw conten
if bytes.IndexByte(v, '\\') == -1 {
return string(v), ni... | go | func GetString(data []byte, keys ...string) (val string, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return "", e
}
if t != String {
return "", fmt.Errorf("Value is not a string: %s", string(v))
}
// If no escapes return raw conten
if bytes.IndexByte(v, '\\') == -1 {
return string(v), ni... | [
"func",
"GetString",
"(",
"data",
"[",
"]",
"byte",
",",
"keys",
"...",
"string",
")",
"(",
"val",
"string",
",",
"err",
"error",
")",
"{",
"v",
",",
"t",
",",
"_",
",",
"e",
":=",
"Get",
"(",
"data",
",",
"keys",
"...",
")",
"\n\n",
"if",
"e... | // GetString returns the value retrieved by `Get`, cast to a string if possible, trying to properly handle escape and utf8 symbols
// If key data type do not match, it will return an error. | [
"GetString",
"returns",
"the",
"value",
"retrieved",
"by",
"Get",
"cast",
"to",
"a",
"string",
"if",
"possible",
"trying",
"to",
"properly",
"handle",
"escape",
"and",
"utf8",
"symbols",
"If",
"key",
"data",
"type",
"do",
"not",
"match",
"it",
"will",
"ret... | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1101-L1118 | train |
buger/jsonparser | parser.go | GetFloat | func GetFloat(data []byte, keys ...string) (val float64, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return 0, e
}
if t != Number {
return 0, fmt.Errorf("Value is not a number: %s", string(v))
}
return ParseFloat(v)
} | go | func GetFloat(data []byte, keys ...string) (val float64, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return 0, e
}
if t != Number {
return 0, fmt.Errorf("Value is not a number: %s", string(v))
}
return ParseFloat(v)
} | [
"func",
"GetFloat",
"(",
"data",
"[",
"]",
"byte",
",",
"keys",
"...",
"string",
")",
"(",
"val",
"float64",
",",
"err",
"error",
")",
"{",
"v",
",",
"t",
",",
"_",
",",
"e",
":=",
"Get",
"(",
"data",
",",
"keys",
"...",
")",
"\n\n",
"if",
"e... | // GetFloat returns the value retrieved by `Get`, cast to a float64 if possible.
// The offset is the same as in `Get`.
// If key data type do not match, it will return an error. | [
"GetFloat",
"returns",
"the",
"value",
"retrieved",
"by",
"Get",
"cast",
"to",
"a",
"float64",
"if",
"possible",
".",
"The",
"offset",
"is",
"the",
"same",
"as",
"in",
"Get",
".",
"If",
"key",
"data",
"type",
"do",
"not",
"match",
"it",
"will",
"return... | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1123-L1135 | train |
buger/jsonparser | parser.go | GetInt | func GetInt(data []byte, keys ...string) (val int64, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return 0, e
}
if t != Number {
return 0, fmt.Errorf("Value is not a number: %s", string(v))
}
return ParseInt(v)
} | go | func GetInt(data []byte, keys ...string) (val int64, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return 0, e
}
if t != Number {
return 0, fmt.Errorf("Value is not a number: %s", string(v))
}
return ParseInt(v)
} | [
"func",
"GetInt",
"(",
"data",
"[",
"]",
"byte",
",",
"keys",
"...",
"string",
")",
"(",
"val",
"int64",
",",
"err",
"error",
")",
"{",
"v",
",",
"t",
",",
"_",
",",
"e",
":=",
"Get",
"(",
"data",
",",
"keys",
"...",
")",
"\n\n",
"if",
"e",
... | // GetInt returns the value retrieved by `Get`, cast to a int64 if possible.
// If key data type do not match, it will return an error. | [
"GetInt",
"returns",
"the",
"value",
"retrieved",
"by",
"Get",
"cast",
"to",
"a",
"int64",
"if",
"possible",
".",
"If",
"key",
"data",
"type",
"do",
"not",
"match",
"it",
"will",
"return",
"an",
"error",
"."
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1139-L1151 | train |
buger/jsonparser | parser.go | GetBoolean | func GetBoolean(data []byte, keys ...string) (val bool, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return false, e
}
if t != Boolean {
return false, fmt.Errorf("Value is not a boolean: %s", string(v))
}
return ParseBoolean(v)
} | go | func GetBoolean(data []byte, keys ...string) (val bool, err error) {
v, t, _, e := Get(data, keys...)
if e != nil {
return false, e
}
if t != Boolean {
return false, fmt.Errorf("Value is not a boolean: %s", string(v))
}
return ParseBoolean(v)
} | [
"func",
"GetBoolean",
"(",
"data",
"[",
"]",
"byte",
",",
"keys",
"...",
"string",
")",
"(",
"val",
"bool",
",",
"err",
"error",
")",
"{",
"v",
",",
"t",
",",
"_",
",",
"e",
":=",
"Get",
"(",
"data",
",",
"keys",
"...",
")",
"\n\n",
"if",
"e"... | // GetBoolean returns the value retrieved by `Get`, cast to a bool if possible.
// The offset is the same as in `Get`.
// If key data type do not match, it will return error. | [
"GetBoolean",
"returns",
"the",
"value",
"retrieved",
"by",
"Get",
"cast",
"to",
"a",
"bool",
"if",
"possible",
".",
"The",
"offset",
"is",
"the",
"same",
"as",
"in",
"Get",
".",
"If",
"key",
"data",
"type",
"do",
"not",
"match",
"it",
"will",
"return"... | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1156-L1168 | train |
buger/jsonparser | parser.go | ParseFloat | func ParseFloat(b []byte) (float64, error) {
if v, err := parseFloat(&b); err != nil {
return 0, MalformedValueError
} else {
return v, nil
}
} | go | func ParseFloat(b []byte) (float64, error) {
if v, err := parseFloat(&b); err != nil {
return 0, MalformedValueError
} else {
return v, nil
}
} | [
"func",
"ParseFloat",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"float64",
",",
"error",
")",
"{",
"if",
"v",
",",
"err",
":=",
"parseFloat",
"(",
"&",
"b",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"MalformedValueError",
"\n",
"}",
"els... | // ParseNumber parses a Number ValueType into a Go float64 | [
"ParseNumber",
"parses",
"a",
"Number",
"ValueType",
"into",
"a",
"Go",
"float64"
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1193-L1199 | train |
buger/jsonparser | parser.go | ParseInt | func ParseInt(b []byte) (int64, error) {
if v, ok, overflow := parseInt(b); !ok {
if overflow {
return 0, OverflowIntegerError
}
return 0, MalformedValueError
} else {
return v, nil
}
} | go | func ParseInt(b []byte) (int64, error) {
if v, ok, overflow := parseInt(b); !ok {
if overflow {
return 0, OverflowIntegerError
}
return 0, MalformedValueError
} else {
return v, nil
}
} | [
"func",
"ParseInt",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int64",
",",
"error",
")",
"{",
"if",
"v",
",",
"ok",
",",
"overflow",
":=",
"parseInt",
"(",
"b",
")",
";",
"!",
"ok",
"{",
"if",
"overflow",
"{",
"return",
"0",
",",
"OverflowIntegerErr... | // ParseInt parses a Number ValueType into a Go int64 | [
"ParseInt",
"parses",
"a",
"Number",
"ValueType",
"into",
"a",
"Go",
"int64"
] | bf1c66bbce23153d89b23f8960071a680dbef54b | https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1202-L1211 | train |
jung-kurt/gofpdf | fpdf.go | SetErrorf | func (f *Fpdf) SetErrorf(fmtStr string, args ...interface{}) {
if f.err == nil {
f.err = fmt.Errorf(fmtStr, args...)
}
} | go | func (f *Fpdf) SetErrorf(fmtStr string, args ...interface{}) {
if f.err == nil {
f.err = fmt.Errorf(fmtStr, args...)
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetErrorf",
"(",
"fmtStr",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"f",
".",
"err",
"==",
"nil",
"{",
"f",
".",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"fmtStr",
",",
"args",
"...... | // SetErrorf sets the internal Fpdf error with formatted text to halt PDF
// generation; this may facilitate error handling by application. If an error
// condition is already set, this call is ignored.
//
// See the documentation for printing in the standard fmt package for details
// about fmtStr and args. | [
"SetErrorf",
"sets",
"the",
"internal",
"Fpdf",
"error",
"with",
"formatted",
"text",
"to",
"halt",
"PDF",
"generation",
";",
"this",
"may",
"facilitate",
"error",
"handling",
"by",
"application",
".",
"If",
"an",
"error",
"condition",
"is",
"already",
"set",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L259-L263 | train |
jung-kurt/gofpdf | fpdf.go | SetMargins | func (f *Fpdf) SetMargins(left, top, right float64) {
f.lMargin = left
f.tMargin = top
if right < 0 {
right = left
}
f.rMargin = right
} | go | func (f *Fpdf) SetMargins(left, top, right float64) {
f.lMargin = left
f.tMargin = top
if right < 0 {
right = left
}
f.rMargin = right
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetMargins",
"(",
"left",
",",
"top",
",",
"right",
"float64",
")",
"{",
"f",
".",
"lMargin",
"=",
"left",
"\n",
"f",
".",
"tMargin",
"=",
"top",
"\n",
"if",
"right",
"<",
"0",
"{",
"right",
"=",
"left",
"\n... | // SetMargins defines the left, top and right margins. By default, they equal 1
// cm. Call this method to change them. If the value of the right margin is
// less than zero, it is set to the same as the left margin. | [
"SetMargins",
"defines",
"the",
"left",
"top",
"and",
"right",
"margins",
".",
"By",
"default",
"they",
"equal",
"1",
"cm",
".",
"Call",
"this",
"method",
"to",
"change",
"them",
".",
"If",
"the",
"value",
"of",
"the",
"right",
"margin",
"is",
"less",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L307-L314 | train |
jung-kurt/gofpdf | fpdf.go | SetLeftMargin | func (f *Fpdf) SetLeftMargin(margin float64) {
f.lMargin = margin
if f.page > 0 && f.x < margin {
f.x = margin
}
} | go | func (f *Fpdf) SetLeftMargin(margin float64) {
f.lMargin = margin
if f.page > 0 && f.x < margin {
f.x = margin
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetLeftMargin",
"(",
"margin",
"float64",
")",
"{",
"f",
".",
"lMargin",
"=",
"margin",
"\n",
"if",
"f",
".",
"page",
">",
"0",
"&&",
"f",
".",
"x",
"<",
"margin",
"{",
"f",
".",
"x",
"=",
"margin",
"\n",
... | // SetLeftMargin defines the left margin. The method can be called before
// creating the first page. If the current abscissa gets out of page, it is
// brought back to the margin. | [
"SetLeftMargin",
"defines",
"the",
"left",
"margin",
".",
"The",
"method",
"can",
"be",
"called",
"before",
"creating",
"the",
"first",
"page",
".",
"If",
"the",
"current",
"abscissa",
"gets",
"out",
"of",
"page",
"it",
"is",
"brought",
"back",
"to",
"the"... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L319-L324 | train |
jung-kurt/gofpdf | fpdf.go | SetPageBox | func (f *Fpdf) SetPageBox(t string, x, y, wd, ht float64) {
f.SetPageBoxRec(t, PageBox{SizeType{Wd: wd, Ht: ht}, PointType{X: x, Y: y}})
} | go | func (f *Fpdf) SetPageBox(t string, x, y, wd, ht float64) {
f.SetPageBoxRec(t, PageBox{SizeType{Wd: wd, Ht: ht}, PointType{X: x, Y: y}})
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetPageBox",
"(",
"t",
"string",
",",
"x",
",",
"y",
",",
"wd",
",",
"ht",
"float64",
")",
"{",
"f",
".",
"SetPageBoxRec",
"(",
"t",
",",
"PageBox",
"{",
"SizeType",
"{",
"Wd",
":",
"wd",
",",
"Ht",
":",
"... | // SetPageBox sets the page box for the current page, and any following pages.
// Allowable types are trim, trimbox, crop, cropbox, bleed, bleedbox, art and
// artbox box types are case insensitive. | [
"SetPageBox",
"sets",
"the",
"page",
"box",
"for",
"the",
"current",
"page",
"and",
"any",
"following",
"pages",
".",
"Allowable",
"types",
"are",
"trim",
"trimbox",
"crop",
"cropbox",
"bleed",
"bleedbox",
"art",
"and",
"artbox",
"box",
"types",
"are",
"case... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L383-L385 | train |
jung-kurt/gofpdf | fpdf.go | GetAutoPageBreak | func (f *Fpdf) GetAutoPageBreak() (auto bool, margin float64) {
auto = f.autoPageBreak
margin = f.bMargin
return
} | go | func (f *Fpdf) GetAutoPageBreak() (auto bool, margin float64) {
auto = f.autoPageBreak
margin = f.bMargin
return
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetAutoPageBreak",
"(",
")",
"(",
"auto",
"bool",
",",
"margin",
"float64",
")",
"{",
"auto",
"=",
"f",
".",
"autoPageBreak",
"\n",
"margin",
"=",
"f",
".",
"bMargin",
"\n",
"return",
"\n",
"}"
] | // GetAutoPageBreak returns true if automatic pages breaks are enabled, false
// otherwise. This is followed by the triggering limit from the bottom of the
// page. This value applies only if automatic page breaks are enabled. | [
"GetAutoPageBreak",
"returns",
"true",
"if",
"automatic",
"pages",
"breaks",
"are",
"enabled",
"false",
"otherwise",
".",
"This",
"is",
"followed",
"by",
"the",
"triggering",
"limit",
"from",
"the",
"bottom",
"of",
"the",
"page",
".",
"This",
"value",
"applies... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L484-L488 | train |
jung-kurt/gofpdf | fpdf.go | SetAutoPageBreak | func (f *Fpdf) SetAutoPageBreak(auto bool, margin float64) {
f.autoPageBreak = auto
f.bMargin = margin
f.pageBreakTrigger = f.h - margin
} | go | func (f *Fpdf) SetAutoPageBreak(auto bool, margin float64) {
f.autoPageBreak = auto
f.bMargin = margin
f.pageBreakTrigger = f.h - margin
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetAutoPageBreak",
"(",
"auto",
"bool",
",",
"margin",
"float64",
")",
"{",
"f",
".",
"autoPageBreak",
"=",
"auto",
"\n",
"f",
".",
"bMargin",
"=",
"margin",
"\n",
"f",
".",
"pageBreakTrigger",
"=",
"f",
".",
"h",... | // SetAutoPageBreak enables or disables the automatic page breaking mode. When
// enabling, the second parameter is the distance from the bottom of the page
// that defines the triggering limit. By default, the mode is on and the margin
// is 2 cm. | [
"SetAutoPageBreak",
"enables",
"or",
"disables",
"the",
"automatic",
"page",
"breaking",
"mode",
".",
"When",
"enabling",
"the",
"second",
"parameter",
"is",
"the",
"distance",
"from",
"the",
"bottom",
"of",
"the",
"page",
"that",
"defines",
"the",
"triggering",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L494-L498 | train |
jung-kurt/gofpdf | fpdf.go | SetKeywords | func (f *Fpdf) SetKeywords(keywordsStr string, isUTF8 bool) {
if isUTF8 {
keywordsStr = utf8toutf16(keywordsStr)
}
f.keywords = keywordsStr
} | go | func (f *Fpdf) SetKeywords(keywordsStr string, isUTF8 bool) {
if isUTF8 {
keywordsStr = utf8toutf16(keywordsStr)
}
f.keywords = keywordsStr
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetKeywords",
"(",
"keywordsStr",
"string",
",",
"isUTF8",
"bool",
")",
"{",
"if",
"isUTF8",
"{",
"keywordsStr",
"=",
"utf8toutf16",
"(",
"keywordsStr",
")",
"\n",
"}",
"\n",
"f",
".",
"keywords",
"=",
"keywordsStr",
... | // SetKeywords defines the keywords of the document. keywordStr is a
// space-delimited string, for example "invoice August". isUTF8 indicates if
// the string is encoded | [
"SetKeywords",
"defines",
"the",
"keywords",
"of",
"the",
"document",
".",
"keywordStr",
"is",
"a",
"space",
"-",
"delimited",
"string",
"for",
"example",
"invoice",
"August",
".",
"isUTF8",
"indicates",
"if",
"the",
"string",
"is",
"encoded"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L588-L593 | train |
jung-kurt/gofpdf | fpdf.go | GetStringWidth | func (f *Fpdf) GetStringWidth(s string) float64 {
if f.err != nil {
return 0
}
w := 0
for _, ch := range []byte(s) {
if ch == 0 {
break
}
w += f.currentFont.Cw[ch]
}
return float64(w) * f.fontSize / 1000
} | go | func (f *Fpdf) GetStringWidth(s string) float64 {
if f.err != nil {
return 0
}
w := 0
for _, ch := range []byte(s) {
if ch == 0 {
break
}
w += f.currentFont.Cw[ch]
}
return float64(w) * f.fontSize / 1000
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetStringWidth",
"(",
"s",
"string",
")",
"float64",
"{",
"if",
"f",
".",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"w",
":=",
"0",
"\n",
"for",
"_",
",",
"ch",
":=",
"range",
"[",
"]",
"byt... | // GetStringWidth returns the length of a string in user units. A font must be
// currently selected. | [
"GetStringWidth",
"returns",
"the",
"length",
"of",
"a",
"string",
"in",
"user",
"units",
".",
"A",
"font",
"must",
"be",
"currently",
"selected",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L914-L926 | train |
jung-kurt/gofpdf | fpdf.go | SetLineCapStyle | func (f *Fpdf) SetLineCapStyle(styleStr string) {
var capStyle int
switch styleStr {
case "round":
capStyle = 1
case "square":
capStyle = 2
default:
capStyle = 0
}
f.capStyle = capStyle
if f.page > 0 {
f.outf("%d J", f.capStyle)
}
} | go | func (f *Fpdf) SetLineCapStyle(styleStr string) {
var capStyle int
switch styleStr {
case "round":
capStyle = 1
case "square":
capStyle = 2
default:
capStyle = 0
}
f.capStyle = capStyle
if f.page > 0 {
f.outf("%d J", f.capStyle)
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetLineCapStyle",
"(",
"styleStr",
"string",
")",
"{",
"var",
"capStyle",
"int",
"\n",
"switch",
"styleStr",
"{",
"case",
"\"",
"\"",
":",
"capStyle",
"=",
"1",
"\n",
"case",
"\"",
"\"",
":",
"capStyle",
"=",
"2",... | // SetLineCapStyle defines the line cap style. styleStr should be "butt",
// "round" or "square". A square style projects from the end of the line. The
// method can be called before the first page is created. The value is
// retained from page to page. | [
"SetLineCapStyle",
"defines",
"the",
"line",
"cap",
"style",
".",
"styleStr",
"should",
"be",
"butt",
"round",
"or",
"square",
".",
"A",
"square",
"style",
"projects",
"from",
"the",
"end",
"of",
"the",
"line",
".",
"The",
"method",
"can",
"be",
"called",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L951-L965 | train |
jung-kurt/gofpdf | fpdf.go | SetLineJoinStyle | func (f *Fpdf) SetLineJoinStyle(styleStr string) {
var joinStyle int
switch styleStr {
case "round":
joinStyle = 1
case "bevel":
joinStyle = 2
default:
joinStyle = 0
}
f.joinStyle = joinStyle
if f.page > 0 {
f.outf("%d j", f.joinStyle)
}
} | go | func (f *Fpdf) SetLineJoinStyle(styleStr string) {
var joinStyle int
switch styleStr {
case "round":
joinStyle = 1
case "bevel":
joinStyle = 2
default:
joinStyle = 0
}
f.joinStyle = joinStyle
if f.page > 0 {
f.outf("%d j", f.joinStyle)
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetLineJoinStyle",
"(",
"styleStr",
"string",
")",
"{",
"var",
"joinStyle",
"int",
"\n",
"switch",
"styleStr",
"{",
"case",
"\"",
"\"",
":",
"joinStyle",
"=",
"1",
"\n",
"case",
"\"",
"\"",
":",
"joinStyle",
"=",
... | // SetLineJoinStyle defines the line cap style. styleStr should be "miter",
// "round" or "bevel". The method can be called before the first page
// is created. The value is retained from page to page. | [
"SetLineJoinStyle",
"defines",
"the",
"line",
"cap",
"style",
".",
"styleStr",
"should",
"be",
"miter",
"round",
"or",
"bevel",
".",
"The",
"method",
"can",
"be",
"called",
"before",
"the",
"first",
"page",
"is",
"created",
".",
"The",
"value",
"is",
"reta... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L970-L984 | train |
jung-kurt/gofpdf | fpdf.go | fillDrawOp | func fillDrawOp(styleStr string) (opStr string) {
switch strings.ToUpper(styleStr) {
case "", "D":
// Stroke the path.
opStr = "S"
case "F":
// fill the path, using the nonzero winding number rule
opStr = "f"
case "F*":
// fill the path, using the even-odd rule
opStr = "f*"
case "FD", "DF":
// fill a... | go | func fillDrawOp(styleStr string) (opStr string) {
switch strings.ToUpper(styleStr) {
case "", "D":
// Stroke the path.
opStr = "S"
case "F":
// fill the path, using the nonzero winding number rule
opStr = "f"
case "F*":
// fill the path, using the even-odd rule
opStr = "f*"
case "FD", "DF":
// fill a... | [
"func",
"fillDrawOp",
"(",
"styleStr",
"string",
")",
"(",
"opStr",
"string",
")",
"{",
"switch",
"strings",
".",
"ToUpper",
"(",
"styleStr",
")",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"// Stroke the path.",
"opStr",
"=",
"\"",
"\"",
"\n",
"ca... | // fillDrawOp corrects path painting operators | [
"fillDrawOp",
"corrects",
"path",
"painting",
"operators"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1031-L1052 | train |
jung-kurt/gofpdf | fpdf.go | point | func (f *Fpdf) point(x, y float64) {
f.outf("%.2f %.2f m", x*f.k, (f.h-y)*f.k)
} | go | func (f *Fpdf) point(x, y float64) {
f.outf("%.2f %.2f m", x*f.k, (f.h-y)*f.k)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"point",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"f",
".",
"outf",
"(",
"\"",
"\"",
",",
"x",
"*",
"f",
".",
"k",
",",
"(",
"f",
".",
"h",
"-",
"y",
")",
"*",
"f",
".",
"k",
")",
"\n",
"}"
] | // point outputs current point | [
"point",
"outputs",
"current",
"point"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1148-L1150 | train |
jung-kurt/gofpdf | fpdf.go | GetAlpha | func (f *Fpdf) GetAlpha() (alpha float64, blendModeStr string) {
return f.alpha, f.blendMode
} | go | func (f *Fpdf) GetAlpha() (alpha float64, blendModeStr string) {
return f.alpha, f.blendMode
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetAlpha",
"(",
")",
"(",
"alpha",
"float64",
",",
"blendModeStr",
"string",
")",
"{",
"return",
"f",
".",
"alpha",
",",
"f",
".",
"blendMode",
"\n",
"}"
] | // GetAlpha returns the alpha blending channel, which consists of the
// alpha transparency value and the blend mode. See SetAlpha for more
// details. | [
"GetAlpha",
"returns",
"the",
"alpha",
"blending",
"channel",
"which",
"consists",
"of",
"the",
"alpha",
"transparency",
"value",
"and",
"the",
"blend",
"mode",
".",
"See",
"SetAlpha",
"for",
"more",
"details",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1231-L1233 | train |
jung-kurt/gofpdf | fpdf.go | getFontKey | func getFontKey(familyStr, styleStr string) string {
familyStr = strings.ToLower(familyStr)
styleStr = strings.ToUpper(styleStr)
if styleStr == "IB" {
styleStr = "BI"
}
return familyStr + styleStr
} | go | func getFontKey(familyStr, styleStr string) string {
familyStr = strings.ToLower(familyStr)
styleStr = strings.ToUpper(styleStr)
if styleStr == "IB" {
styleStr = "BI"
}
return familyStr + styleStr
} | [
"func",
"getFontKey",
"(",
"familyStr",
",",
"styleStr",
"string",
")",
"string",
"{",
"familyStr",
"=",
"strings",
".",
"ToLower",
"(",
"familyStr",
")",
"\n",
"styleStr",
"=",
"strings",
".",
"ToUpper",
"(",
"styleStr",
")",
"\n",
"if",
"styleStr",
"==",... | // getFontKey is used by AddFontFromReader and GetFontDesc | [
"getFontKey",
"is",
"used",
"by",
"AddFontFromReader",
"and",
"GetFontDesc"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1638-L1645 | train |
jung-kurt/gofpdf | fpdf.go | AddFontFromReader | func (f *Fpdf) AddFontFromReader(familyStr, styleStr string, r io.Reader) {
if f.err != nil {
return
}
// dbg("Adding family [%s], style [%s]", familyStr, styleStr)
var ok bool
fontkey := getFontKey(familyStr, styleStr)
_, ok = f.fonts[fontkey]
if ok {
return
}
var info fontDefType
info = f.loadfont(r)
i... | go | func (f *Fpdf) AddFontFromReader(familyStr, styleStr string, r io.Reader) {
if f.err != nil {
return
}
// dbg("Adding family [%s], style [%s]", familyStr, styleStr)
var ok bool
fontkey := getFontKey(familyStr, styleStr)
_, ok = f.fonts[fontkey]
if ok {
return
}
var info fontDefType
info = f.loadfont(r)
i... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"AddFontFromReader",
"(",
"familyStr",
",",
"styleStr",
"string",
",",
"r",
"io",
".",
"Reader",
")",
"{",
"if",
"f",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// dbg(\"Adding family [%s], style [%s]\", f... | // AddFontFromReader imports a TrueType, OpenType or Type1 font and makes it
// available using a reader that satisifies the io.Reader interface. See
// AddFont for details about familyStr and styleStr. | [
"AddFontFromReader",
"imports",
"a",
"TrueType",
"OpenType",
"or",
"Type1",
"font",
"and",
"makes",
"it",
"available",
"using",
"a",
"reader",
"that",
"satisifies",
"the",
"io",
".",
"Reader",
"interface",
".",
"See",
"AddFont",
"for",
"details",
"about",
"fam... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1650-L1692 | train |
jung-kurt/gofpdf | fpdf.go | GetFontDesc | func (f *Fpdf) GetFontDesc(familyStr, styleStr string) FontDescType {
if familyStr == "" {
return f.currentFont.Desc
}
return f.fonts[getFontKey(familyStr, styleStr)].Desc
} | go | func (f *Fpdf) GetFontDesc(familyStr, styleStr string) FontDescType {
if familyStr == "" {
return f.currentFont.Desc
}
return f.fonts[getFontKey(familyStr, styleStr)].Desc
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetFontDesc",
"(",
"familyStr",
",",
"styleStr",
"string",
")",
"FontDescType",
"{",
"if",
"familyStr",
"==",
"\"",
"\"",
"{",
"return",
"f",
".",
"currentFont",
".",
"Desc",
"\n",
"}",
"\n",
"return",
"f",
".",
"... | // GetFontDesc returns the font descriptor, which can be used for
// example to find the baseline of a font. If familyStr is empty
// current font descriptor will be returned.
// See FontDescType for documentation about the font descriptor.
// See AddFont for details about familyStr and styleStr. | [
"GetFontDesc",
"returns",
"the",
"font",
"descriptor",
"which",
"can",
"be",
"used",
"for",
"example",
"to",
"find",
"the",
"baseline",
"of",
"a",
"font",
".",
"If",
"familyStr",
"is",
"empty",
"current",
"font",
"descriptor",
"will",
"be",
"returned",
".",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1699-L1704 | train |
jung-kurt/gofpdf | fpdf.go | newLink | func (f *Fpdf) newLink(x, y, w, h float64, link int, linkStr string) {
// linkList, ok := f.pageLinks[f.page]
// if !ok {
// linkList = make([]linkType, 0, 8)
// f.pageLinks[f.page] = linkList
// }
f.pageLinks[f.page] = append(f.pageLinks[f.page],
linkType{x * f.k, f.hPt - y*f.k, w * f.k, h * f.k, link, linkStr... | go | func (f *Fpdf) newLink(x, y, w, h float64, link int, linkStr string) {
// linkList, ok := f.pageLinks[f.page]
// if !ok {
// linkList = make([]linkType, 0, 8)
// f.pageLinks[f.page] = linkList
// }
f.pageLinks[f.page] = append(f.pageLinks[f.page],
linkType{x * f.k, f.hPt - y*f.k, w * f.k, h * f.k, link, linkStr... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"newLink",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
"float64",
",",
"link",
"int",
",",
"linkStr",
"string",
")",
"{",
"// linkList, ok := f.pageLinks[f.page]",
"// if !ok {",
"// linkList = make([]linkType, 0, 8)",
"// f.pageL... | // newLink adds a new clickable link on current page | [
"newLink",
"adds",
"a",
"new",
"clickable",
"link",
"on",
"current",
"page"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1855-L1863 | train |
jung-kurt/gofpdf | fpdf.go | Bookmark | func (f *Fpdf) Bookmark(txtStr string, level int, y float64) {
if y == -1 {
y = f.y
}
f.outlines = append(f.outlines, outlineType{text: txtStr, level: level, y: y, p: f.PageNo(), prev: -1, last: -1, next: -1, first: -1})
} | go | func (f *Fpdf) Bookmark(txtStr string, level int, y float64) {
if y == -1 {
y = f.y
}
f.outlines = append(f.outlines, outlineType{text: txtStr, level: level, y: y, p: f.PageNo(), prev: -1, last: -1, next: -1, first: -1})
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"Bookmark",
"(",
"txtStr",
"string",
",",
"level",
"int",
",",
"y",
"float64",
")",
"{",
"if",
"y",
"==",
"-",
"1",
"{",
"y",
"=",
"f",
".",
"y",
"\n",
"}",
"\n",
"f",
".",
"outlines",
"=",
"append",
"(",
... | // Bookmark sets a bookmark that will be displayed in a sidebar outline. txtStr
// is the title of the bookmark. level specifies the level of the bookmark in
// the outline; 0 is the top level, 1 is just below, and so on. y specifies the
// vertical position of the bookmark destination in the current page; -1
// indica... | [
"Bookmark",
"sets",
"a",
"bookmark",
"that",
"will",
"be",
"displayed",
"in",
"a",
"sidebar",
"outline",
".",
"txtStr",
"is",
"the",
"title",
"of",
"the",
"bookmark",
".",
"level",
"specifies",
"the",
"level",
"of",
"the",
"bookmark",
"in",
"the",
"outline... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1886-L1891 | train |
jung-kurt/gofpdf | fpdf.go | Cell | func (f *Fpdf) Cell(w, h float64, txtStr string) {
f.CellFormat(w, h, txtStr, "", 0, "L", false, 0, "")
} | go | func (f *Fpdf) Cell(w, h float64, txtStr string) {
f.CellFormat(w, h, txtStr, "", 0, "L", false, 0, "")
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"Cell",
"(",
"w",
",",
"h",
"float64",
",",
"txtStr",
"string",
")",
"{",
"f",
".",
"CellFormat",
"(",
"w",
",",
"h",
",",
"txtStr",
",",
"\"",
"\"",
",",
"0",
",",
"\"",
"\"",
",",
"false",
",",
"0",
","... | // Cell is a simpler version of CellFormat with no fill, border, links or
// special alignment. | [
"Cell",
"is",
"a",
"simpler",
"version",
"of",
"CellFormat",
"with",
"no",
"fill",
"border",
"links",
"or",
"special",
"alignment",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2114-L2116 | train |
jung-kurt/gofpdf | fpdf.go | Cellf | func (f *Fpdf) Cellf(w, h float64, fmtStr string, args ...interface{}) {
f.CellFormat(w, h, sprintf(fmtStr, args...), "", 0, "L", false, 0, "")
} | go | func (f *Fpdf) Cellf(w, h float64, fmtStr string, args ...interface{}) {
f.CellFormat(w, h, sprintf(fmtStr, args...), "", 0, "L", false, 0, "")
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"Cellf",
"(",
"w",
",",
"h",
"float64",
",",
"fmtStr",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"f",
".",
"CellFormat",
"(",
"w",
",",
"h",
",",
"sprintf",
"(",
"fmtStr",
",",
"args",
".... | // Cellf is a simpler printf-style version of CellFormat with no fill, border,
// links or special alignment. See documentation for the fmt package for
// details on fmtStr and args. | [
"Cellf",
"is",
"a",
"simpler",
"printf",
"-",
"style",
"version",
"of",
"CellFormat",
"with",
"no",
"fill",
"border",
"links",
"or",
"special",
"alignment",
".",
"See",
"documentation",
"for",
"the",
"fmt",
"package",
"for",
"details",
"on",
"fmtStr",
"and",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2121-L2123 | train |
jung-kurt/gofpdf | fpdf.go | SplitLines | func (f *Fpdf) SplitLines(txt []byte, w float64) [][]byte {
// Function contributed by Bruno Michel
lines := [][]byte{}
cw := &f.currentFont.Cw
wmax := int(math.Ceil((w - 2*f.cMargin) * 1000 / f.fontSize))
s := bytes.Replace(txt, []byte("\r"), []byte{}, -1)
nb := len(s)
for nb > 0 && s[nb-1] == '\n' {
nb--
}
... | go | func (f *Fpdf) SplitLines(txt []byte, w float64) [][]byte {
// Function contributed by Bruno Michel
lines := [][]byte{}
cw := &f.currentFont.Cw
wmax := int(math.Ceil((w - 2*f.cMargin) * 1000 / f.fontSize))
s := bytes.Replace(txt, []byte("\r"), []byte{}, -1)
nb := len(s)
for nb > 0 && s[nb-1] == '\n' {
nb--
}
... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SplitLines",
"(",
"txt",
"[",
"]",
"byte",
",",
"w",
"float64",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"// Function contributed by Bruno Michel",
"lines",
":=",
"[",
"]",
"[",
"]",
"byte",
"{",
"}",
"\n",
"cw",
"... | // SplitLines splits text into several lines using the current font. Each line
// has its length limited to a maximum width given by w. This function can be
// used to determine the total height of wrapped text for vertical placement
// purposes.
//
// You can use MultiCell if you want to print a text on several lines ... | [
"SplitLines",
"splits",
"text",
"into",
"several",
"lines",
"using",
"the",
"current",
"font",
".",
"Each",
"line",
"has",
"its",
"length",
"limited",
"to",
"a",
"maximum",
"width",
"given",
"by",
"w",
".",
"This",
"function",
"can",
"be",
"used",
"to",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2132-L2174 | train |
jung-kurt/gofpdf | fpdf.go | write | func (f *Fpdf) write(h float64, txtStr string, link int, linkStr string) {
// dbg("Write")
cw := &f.currentFont.Cw
w := f.w - f.rMargin - f.x
wmax := (w - 2*f.cMargin) * 1000 / f.fontSize
s := strings.Replace(txtStr, "\r", "", -1)
nb := len(s)
sep := -1
i := 0
j := 0
l := 0.0
nl := 1
for i < nb {
// Get n... | go | func (f *Fpdf) write(h float64, txtStr string, link int, linkStr string) {
// dbg("Write")
cw := &f.currentFont.Cw
w := f.w - f.rMargin - f.x
wmax := (w - 2*f.cMargin) * 1000 / f.fontSize
s := strings.Replace(txtStr, "\r", "", -1)
nb := len(s)
sep := -1
i := 0
j := 0
l := 0.0
nl := 1
for i < nb {
// Get n... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"write",
"(",
"h",
"float64",
",",
"txtStr",
"string",
",",
"link",
"int",
",",
"linkStr",
"string",
")",
"{",
"// dbg(\"Write\")",
"cw",
":=",
"&",
"f",
".",
"currentFont",
".",
"Cw",
"\n",
"w",
":=",
"f",
".",
... | // write outputs text in flowing mode | [
"write",
"outputs",
"text",
"in",
"flowing",
"mode"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2312-L2384 | train |
jung-kurt/gofpdf | fpdf.go | Writef | func (f *Fpdf) Writef(h float64, fmtStr string, args ...interface{}) {
f.write(h, sprintf(fmtStr, args...), 0, "")
} | go | func (f *Fpdf) Writef(h float64, fmtStr string, args ...interface{}) {
f.write(h, sprintf(fmtStr, args...), 0, "")
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"Writef",
"(",
"h",
"float64",
",",
"fmtStr",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"f",
".",
"write",
"(",
"h",
",",
"sprintf",
"(",
"fmtStr",
",",
"args",
"...",
")",
",",
"0",
",",... | // Writef is like Write but uses printf-style formatting. See the documentation
// for package fmt for more details on fmtStr and args. | [
"Writef",
"is",
"like",
"Write",
"but",
"uses",
"printf",
"-",
"style",
"formatting",
".",
"See",
"the",
"documentation",
"for",
"package",
"fmt",
"for",
"more",
"details",
"on",
"fmtStr",
"and",
"args",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2400-L2402 | train |
jung-kurt/gofpdf | fpdf.go | Ln | func (f *Fpdf) Ln(h float64) {
f.x = f.lMargin
if h < 0 {
f.y += f.lasth
} else {
f.y += h
}
} | go | func (f *Fpdf) Ln(h float64) {
f.x = f.lMargin
if h < 0 {
f.y += f.lasth
} else {
f.y += h
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"Ln",
"(",
"h",
"float64",
")",
"{",
"f",
".",
"x",
"=",
"f",
".",
"lMargin",
"\n",
"if",
"h",
"<",
"0",
"{",
"f",
".",
"y",
"+=",
"f",
".",
"lasth",
"\n",
"}",
"else",
"{",
"f",
".",
"y",
"+=",
"h",
... | // Ln performs a line break. The current abscissa goes back to the left margin
// and the ordinate increases by the amount passed in parameter. A negative
// value of h indicates the height of the last printed cell.
//
// This method is demonstrated in the example for MultiCell. | [
"Ln",
"performs",
"a",
"line",
"break",
".",
"The",
"current",
"abscissa",
"goes",
"back",
"to",
"the",
"left",
"margin",
"and",
"the",
"ordinate",
"increases",
"by",
"the",
"amount",
"passed",
"in",
"parameter",
".",
"A",
"negative",
"value",
"of",
"h",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2463-L2470 | train |
jung-kurt/gofpdf | fpdf.go | RegisterImageReader | func (f *Fpdf) RegisterImageReader(imgName, tp string, r io.Reader) (info *ImageInfoType) {
options := ImageOptions{
ReadDpi: false,
ImageType: tp,
}
return f.RegisterImageOptionsReader(imgName, options, r)
} | go | func (f *Fpdf) RegisterImageReader(imgName, tp string, r io.Reader) (info *ImageInfoType) {
options := ImageOptions{
ReadDpi: false,
ImageType: tp,
}
return f.RegisterImageOptionsReader(imgName, options, r)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"RegisterImageReader",
"(",
"imgName",
",",
"tp",
"string",
",",
"r",
"io",
".",
"Reader",
")",
"(",
"info",
"*",
"ImageInfoType",
")",
"{",
"options",
":=",
"ImageOptions",
"{",
"ReadDpi",
":",
"false",
",",
"ImageT... | // RegisterImageReader registers an image, reading it from Reader r, adding it
// to the PDF file but not adding it to the page.
//
// This function is now deprecated in favor of RegisterImageOptionsReader | [
"RegisterImageReader",
"registers",
"an",
"image",
"reading",
"it",
"from",
"Reader",
"r",
"adding",
"it",
"to",
"the",
"PDF",
"file",
"but",
"not",
"adding",
"it",
"to",
"the",
"page",
".",
"This",
"function",
"is",
"now",
"deprecated",
"in",
"favor",
"of... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2612-L2618 | train |
jung-kurt/gofpdf | fpdf.go | GetImageInfo | func (f *Fpdf) GetImageInfo(imageStr string) (info *ImageInfoType) {
return f.images[imageStr]
} | go | func (f *Fpdf) GetImageInfo(imageStr string) (info *ImageInfoType) {
return f.images[imageStr]
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetImageInfo",
"(",
"imageStr",
"string",
")",
"(",
"info",
"*",
"ImageInfoType",
")",
"{",
"return",
"f",
".",
"images",
"[",
"imageStr",
"]",
"\n",
"}"
] | // GetImageInfo returns information about the registered image specified by
// imageStr. If the image has not been registered, nil is returned. The
// internal error is not modified by this method. | [
"GetImageInfo",
"returns",
"information",
"about",
"the",
"registered",
"image",
"specified",
"by",
"imageStr",
".",
"If",
"the",
"image",
"has",
"not",
"been",
"registered",
"nil",
"is",
"returned",
".",
"The",
"internal",
"error",
"is",
"not",
"modified",
"b... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2737-L2739 | train |
jung-kurt/gofpdf | fpdf.go | SetX | func (f *Fpdf) SetX(x float64) {
if x >= 0 {
f.x = x
} else {
f.x = f.w + x
}
} | go | func (f *Fpdf) SetX(x float64) {
if x >= 0 {
f.x = x
} else {
f.x = f.w + x
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetX",
"(",
"x",
"float64",
")",
"{",
"if",
"x",
">=",
"0",
"{",
"f",
".",
"x",
"=",
"x",
"\n",
"}",
"else",
"{",
"f",
".",
"x",
"=",
"f",
".",
"w",
"+",
"x",
"\n",
"}",
"\n",
"}"
] | // SetX defines the abscissa of the current position. If the passed value is
// negative, it is relative to the right of the page. | [
"SetX",
"defines",
"the",
"abscissa",
"of",
"the",
"current",
"position",
".",
"If",
"the",
"passed",
"value",
"is",
"negative",
"it",
"is",
"relative",
"to",
"the",
"right",
"of",
"the",
"page",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2768-L2774 | train |
jung-kurt/gofpdf | fpdf.go | SetY | func (f *Fpdf) SetY(y float64) {
// dbg("SetY x %.2f, lMargin %.2f", f.x, f.lMargin)
f.x = f.lMargin
if y >= 0 {
f.y = y
} else {
f.y = f.h + y
}
} | go | func (f *Fpdf) SetY(y float64) {
// dbg("SetY x %.2f, lMargin %.2f", f.x, f.lMargin)
f.x = f.lMargin
if y >= 0 {
f.y = y
} else {
f.y = f.h + y
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetY",
"(",
"y",
"float64",
")",
"{",
"// dbg(\"SetY x %.2f, lMargin %.2f\", f.x, f.lMargin)",
"f",
".",
"x",
"=",
"f",
".",
"lMargin",
"\n",
"if",
"y",
">=",
"0",
"{",
"f",
".",
"y",
"=",
"y",
"\n",
"}",
"else",
... | // SetY moves the current abscissa back to the left margin and sets the
// ordinate. If the passed value is negative, it is relative to the bottom of
// the page. | [
"SetY",
"moves",
"the",
"current",
"abscissa",
"back",
"to",
"the",
"left",
"margin",
"and",
"sets",
"the",
"ordinate",
".",
"If",
"the",
"passed",
"value",
"is",
"negative",
"it",
"is",
"relative",
"to",
"the",
"bottom",
"of",
"the",
"page",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2784-L2792 | train |
jung-kurt/gofpdf | fpdf.go | SetHomeXY | func (f *Fpdf) SetHomeXY() {
f.SetY(f.tMargin)
f.SetX(f.lMargin)
} | go | func (f *Fpdf) SetHomeXY() {
f.SetY(f.tMargin)
f.SetX(f.lMargin)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetHomeXY",
"(",
")",
"{",
"f",
".",
"SetY",
"(",
"f",
".",
"tMargin",
")",
"\n",
"f",
".",
"SetX",
"(",
"f",
".",
"lMargin",
")",
"\n",
"}"
] | // SetHomeXY is a convenience method that sets the current position to the left
// and top margins. | [
"SetHomeXY",
"is",
"a",
"convenience",
"method",
"that",
"sets",
"the",
"current",
"position",
"to",
"the",
"left",
"and",
"top",
"margins",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2796-L2799 | train |
jung-kurt/gofpdf | fpdf.go | SetXY | func (f *Fpdf) SetXY(x, y float64) {
f.SetY(y)
f.SetX(x)
} | go | func (f *Fpdf) SetXY(x, y float64) {
f.SetY(y)
f.SetX(x)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetXY",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"f",
".",
"SetY",
"(",
"y",
")",
"\n",
"f",
".",
"SetX",
"(",
"x",
")",
"\n",
"}"
] | // SetXY defines the abscissa and ordinate of the current position. If the
// passed values are negative, they are relative respectively to the right and
// bottom of the page. | [
"SetXY",
"defines",
"the",
"abscissa",
"and",
"ordinate",
"of",
"the",
"current",
"position",
".",
"If",
"the",
"passed",
"values",
"are",
"negative",
"they",
"are",
"relative",
"respectively",
"to",
"the",
"right",
"and",
"bottom",
"of",
"the",
"page",
"."
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2804-L2807 | train |
jung-kurt/gofpdf | fpdf.go | SetProtection | func (f *Fpdf) SetProtection(actionFlag byte, userPassStr, ownerPassStr string) {
if f.err != nil {
return
}
f.protect.setProtection(actionFlag, userPassStr, ownerPassStr)
} | go | func (f *Fpdf) SetProtection(actionFlag byte, userPassStr, ownerPassStr string) {
if f.err != nil {
return
}
f.protect.setProtection(actionFlag, userPassStr, ownerPassStr)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"SetProtection",
"(",
"actionFlag",
"byte",
",",
"userPassStr",
",",
"ownerPassStr",
"string",
")",
"{",
"if",
"f",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"f",
".",
"protect",
".",
"setProtection",
... | // SetProtection applies certain constraints on the finished PDF document.
//
// actionFlag is a bitflag that controls various document operations.
// CnProtectPrint allows the document to be printed. CnProtectModify allows a
// document to be modified by a PDF editor. CnProtectCopy allows text and
// images to be copi... | [
"SetProtection",
"applies",
"certain",
"constraints",
"on",
"the",
"finished",
"PDF",
"document",
".",
"actionFlag",
"is",
"a",
"bitflag",
"that",
"controls",
"various",
"document",
"operations",
".",
"CnProtectPrint",
"allows",
"the",
"document",
"to",
"be",
"pri... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2827-L2832 | train |
jung-kurt/gofpdf | fpdf.go | OutputAndClose | func (f *Fpdf) OutputAndClose(w io.WriteCloser) error {
f.Output(w)
w.Close()
return f.err
} | go | func (f *Fpdf) OutputAndClose(w io.WriteCloser) error {
f.Output(w)
w.Close()
return f.err
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"OutputAndClose",
"(",
"w",
"io",
".",
"WriteCloser",
")",
"error",
"{",
"f",
".",
"Output",
"(",
"w",
")",
"\n",
"w",
".",
"Close",
"(",
")",
"\n",
"return",
"f",
".",
"err",
"\n",
"}"
] | // OutputAndClose sends the PDF document to the writer specified by w. This
// method will close both f and w, even if an error is detected and no document
// is produced. | [
"OutputAndClose",
"sends",
"the",
"PDF",
"document",
"to",
"the",
"writer",
"specified",
"by",
"w",
".",
"This",
"method",
"will",
"close",
"both",
"f",
"and",
"w",
"even",
"if",
"an",
"error",
"is",
"detected",
"and",
"no",
"document",
"is",
"produced",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2837-L2841 | train |
jung-kurt/gofpdf | fpdf.go | OutputFileAndClose | func (f *Fpdf) OutputFileAndClose(fileStr string) error {
if f.err == nil {
pdfFile, err := os.Create(fileStr)
if err == nil {
f.Output(pdfFile)
pdfFile.Close()
} else {
f.err = err
}
}
return f.err
} | go | func (f *Fpdf) OutputFileAndClose(fileStr string) error {
if f.err == nil {
pdfFile, err := os.Create(fileStr)
if err == nil {
f.Output(pdfFile)
pdfFile.Close()
} else {
f.err = err
}
}
return f.err
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"OutputFileAndClose",
"(",
"fileStr",
"string",
")",
"error",
"{",
"if",
"f",
".",
"err",
"==",
"nil",
"{",
"pdfFile",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"fileStr",
")",
"\n",
"if",
"err",
"==",
"nil",
... | // OutputFileAndClose creates or truncates the file specified by fileStr and
// writes the PDF document to it. This method will close f and the newly
// written file, even if an error is detected and no document is produced.
//
// Most examples demonstrate the use of this method. | [
"OutputFileAndClose",
"creates",
"or",
"truncates",
"the",
"file",
"specified",
"by",
"fileStr",
"and",
"writes",
"the",
"PDF",
"document",
"to",
"it",
".",
"This",
"method",
"will",
"close",
"f",
"and",
"the",
"newly",
"written",
"file",
"even",
"if",
"an",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2848-L2859 | train |
jung-kurt/gofpdf | fpdf.go | Output | func (f *Fpdf) Output(w io.Writer) error {
if f.err != nil {
return f.err
}
// dbg("Output")
if f.state < 3 {
f.Close()
}
_, err := f.buffer.WriteTo(w)
if err != nil {
f.err = err
}
return f.err
} | go | func (f *Fpdf) Output(w io.Writer) error {
if f.err != nil {
return f.err
}
// dbg("Output")
if f.state < 3 {
f.Close()
}
_, err := f.buffer.WriteTo(w)
if err != nil {
f.err = err
}
return f.err
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"Output",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"if",
"f",
".",
"err",
"!=",
"nil",
"{",
"return",
"f",
".",
"err",
"\n",
"}",
"\n",
"// dbg(\"Output\")",
"if",
"f",
".",
"state",
"<",
"3",
"{",
... | // Output sends the PDF document to the writer specified by w. No output will
// take place if an error has occurred in the document generation process. w
// remains open after this function returns. After returning, f is in a closed
// state and its methods should not be called. | [
"Output",
"sends",
"the",
"PDF",
"document",
"to",
"the",
"writer",
"specified",
"by",
"w",
".",
"No",
"output",
"will",
"take",
"place",
"if",
"an",
"error",
"has",
"occurred",
"in",
"the",
"document",
"generation",
"process",
".",
"w",
"remains",
"open",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2865-L2878 | train |
jung-kurt/gofpdf | fpdf.go | loadfont | func (f *Fpdf) loadfont(r io.Reader) (def fontDefType) {
if f.err != nil {
return
}
// dbg("Loading font [%s]", fontStr)
var buf bytes.Buffer
_, err := buf.ReadFrom(r)
if err != nil {
f.err = err
return
}
err = json.Unmarshal(buf.Bytes(), &def)
if err != nil {
f.err = err
return
}
if def.i, err = ... | go | func (f *Fpdf) loadfont(r io.Reader) (def fontDefType) {
if f.err != nil {
return
}
// dbg("Loading font [%s]", fontStr)
var buf bytes.Buffer
_, err := buf.ReadFrom(r)
if err != nil {
f.err = err
return
}
err = json.Unmarshal(buf.Bytes(), &def)
if err != nil {
f.err = err
return
}
if def.i, err = ... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"loadfont",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"def",
"fontDefType",
")",
"{",
"if",
"f",
".",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// dbg(\"Loading font [%s]\", fontStr)",
"var",
"buf",
"bytes"... | // Load a font definition file from the given Reader | [
"Load",
"a",
"font",
"definition",
"file",
"from",
"the",
"given",
"Reader"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2960-L2982 | train |
jung-kurt/gofpdf | fpdf.go | escape | func (f *Fpdf) escape(s string) string {
s = strings.Replace(s, "\\", "\\\\", -1)
s = strings.Replace(s, "(", "\\(", -1)
s = strings.Replace(s, ")", "\\)", -1)
s = strings.Replace(s, "\r", "\\r", -1)
return s
} | go | func (f *Fpdf) escape(s string) string {
s = strings.Replace(s, "\\", "\\\\", -1)
s = strings.Replace(s, "(", "\\(", -1)
s = strings.Replace(s, ")", "\\)", -1)
s = strings.Replace(s, "\r", "\\r", -1)
return s
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"escape",
"(",
"s",
"string",
")",
"string",
"{",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\\\\",
"\"",
",",
"\"",
"\\\\",
"\\\\",
"\"",
",",
"-",
"1",
")",
"\n",
"s",
"=",
"strings",
".",... | // Escape special characters in strings | [
"Escape",
"special",
"characters",
"in",
"strings"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2985-L2991 | train |
jung-kurt/gofpdf | fpdf.go | textstring | func (f *Fpdf) textstring(s string) string {
if f.protect.encrypted {
b := []byte(s)
f.protect.rc4(uint32(f.n), &b)
s = string(b)
}
return "(" + f.escape(s) + ")"
} | go | func (f *Fpdf) textstring(s string) string {
if f.protect.encrypted {
b := []byte(s)
f.protect.rc4(uint32(f.n), &b)
s = string(b)
}
return "(" + f.escape(s) + ")"
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"textstring",
"(",
"s",
"string",
")",
"string",
"{",
"if",
"f",
".",
"protect",
".",
"encrypted",
"{",
"b",
":=",
"[",
"]",
"byte",
"(",
"s",
")",
"\n",
"f",
".",
"protect",
".",
"rc4",
"(",
"uint32",
"(",
... | // textstring formats a text string | [
"textstring",
"formats",
"a",
"text",
"string"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2994-L3001 | train |
jung-kurt/gofpdf | fpdf.go | parsejpg | func (f *Fpdf) parsejpg(r io.Reader) (info *ImageInfoType) {
info = f.newImageInfo()
var (
data bytes.Buffer
err error
)
_, err = data.ReadFrom(r)
if err != nil {
f.err = err
return
}
info.data = data.Bytes()
config, err := jpeg.DecodeConfig(bytes.NewReader(info.data))
if err != nil {
f.err = err
... | go | func (f *Fpdf) parsejpg(r io.Reader) (info *ImageInfoType) {
info = f.newImageInfo()
var (
data bytes.Buffer
err error
)
_, err = data.ReadFrom(r)
if err != nil {
f.err = err
return
}
info.data = data.Bytes()
config, err := jpeg.DecodeConfig(bytes.NewReader(info.data))
if err != nil {
f.err = err
... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"parsejpg",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"info",
"*",
"ImageInfoType",
")",
"{",
"info",
"=",
"f",
".",
"newImageInfo",
"(",
")",
"\n",
"var",
"(",
"data",
"bytes",
".",
"Buffer",
"\n",
"err",
"erro... | // parsejpg extracts info from io.Reader with JPEG data
// Thank you, Bruno Michel, for providing this code. | [
"parsejpg",
"extracts",
"info",
"from",
"io",
".",
"Reader",
"with",
"JPEG",
"data",
"Thank",
"you",
"Bruno",
"Michel",
"for",
"providing",
"this",
"code",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L3037-L3071 | train |
jung-kurt/gofpdf | fpdf.go | parsepng | func (f *Fpdf) parsepng(r io.Reader, readdpi bool) (info *ImageInfoType) {
buf, err := bufferFromReader(r)
if err != nil {
f.err = err
return
}
return f.parsepngstream(buf, readdpi)
} | go | func (f *Fpdf) parsepng(r io.Reader, readdpi bool) (info *ImageInfoType) {
buf, err := bufferFromReader(r)
if err != nil {
f.err = err
return
}
return f.parsepngstream(buf, readdpi)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"parsepng",
"(",
"r",
"io",
".",
"Reader",
",",
"readdpi",
"bool",
")",
"(",
"info",
"*",
"ImageInfoType",
")",
"{",
"buf",
",",
"err",
":=",
"bufferFromReader",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // parsepng extracts info from a PNG data | [
"parsepng",
"extracts",
"info",
"from",
"a",
"PNG",
"data"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L3074-L3081 | train |
jung-kurt/gofpdf | fpdf.go | newobj | func (f *Fpdf) newobj() {
// dbg("newobj")
f.n++
for j := len(f.offsets); j <= f.n; j++ {
f.offsets = append(f.offsets, 0)
}
f.offsets[f.n] = f.buffer.Len()
f.outf("%d 0 obj", f.n)
} | go | func (f *Fpdf) newobj() {
// dbg("newobj")
f.n++
for j := len(f.offsets); j <= f.n; j++ {
f.offsets = append(f.offsets, 0)
}
f.offsets[f.n] = f.buffer.Len()
f.outf("%d 0 obj", f.n)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"newobj",
"(",
")",
"{",
"// dbg(\"newobj\")",
"f",
".",
"n",
"++",
"\n",
"for",
"j",
":=",
"len",
"(",
"f",
".",
"offsets",
")",
";",
"j",
"<=",
"f",
".",
"n",
";",
"j",
"++",
"{",
"f",
".",
"offsets",
"... | // newobj begins a new object | [
"newobj",
"begins",
"a",
"new",
"object"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L3122-L3130 | train |
jung-kurt/gofpdf | fpdf.go | out | func (f *Fpdf) out(s string) {
if f.state == 2 {
f.pages[f.page].WriteString(s)
f.pages[f.page].WriteString("\n")
} else {
f.buffer.WriteString(s)
f.buffer.WriteString("\n")
}
} | go | func (f *Fpdf) out(s string) {
if f.state == 2 {
f.pages[f.page].WriteString(s)
f.pages[f.page].WriteString("\n")
} else {
f.buffer.WriteString(s)
f.buffer.WriteString("\n")
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"out",
"(",
"s",
"string",
")",
"{",
"if",
"f",
".",
"state",
"==",
"2",
"{",
"f",
".",
"pages",
"[",
"f",
".",
"page",
"]",
".",
"WriteString",
"(",
"s",
")",
"\n",
"f",
".",
"pages",
"[",
"f",
".",
"p... | // out; Add a line to the document | [
"out",
";",
"Add",
"a",
"line",
"to",
"the",
"document"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L3143-L3151 | train |
jung-kurt/gofpdf | fpdf.go | outbuf | func (f *Fpdf) outbuf(r io.Reader) {
if f.state == 2 {
f.pages[f.page].ReadFrom(r)
f.pages[f.page].WriteString("\n")
} else {
f.buffer.ReadFrom(r)
f.buffer.WriteString("\n")
}
} | go | func (f *Fpdf) outbuf(r io.Reader) {
if f.state == 2 {
f.pages[f.page].ReadFrom(r)
f.pages[f.page].WriteString("\n")
} else {
f.buffer.ReadFrom(r)
f.buffer.WriteString("\n")
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"outbuf",
"(",
"r",
"io",
".",
"Reader",
")",
"{",
"if",
"f",
".",
"state",
"==",
"2",
"{",
"f",
".",
"pages",
"[",
"f",
".",
"page",
"]",
".",
"ReadFrom",
"(",
"r",
")",
"\n",
"f",
".",
"pages",
"[",
"... | // outbuf adds a buffered line to the document | [
"outbuf",
"adds",
"a",
"buffered",
"line",
"to",
"the",
"document"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L3154-L3162 | train |
jung-kurt/gofpdf | fpdf.go | outf | func (f *Fpdf) outf(fmtStr string, args ...interface{}) {
f.out(sprintf(fmtStr, args...))
} | go | func (f *Fpdf) outf(fmtStr string, args ...interface{}) {
f.out(sprintf(fmtStr, args...))
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"outf",
"(",
"fmtStr",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"f",
".",
"out",
"(",
"sprintf",
"(",
"fmtStr",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // outf adds a formatted line to the document | [
"outf",
"adds",
"a",
"formatted",
"line",
"to",
"the",
"document"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L3181-L3183 | train |
jung-kurt/gofpdf | util.go | fileExist | func fileExist(filename string) (ok bool) {
info, err := os.Stat(filename)
if err == nil {
if ^os.ModePerm&info.Mode() == 0 {
ok = true
}
}
return ok
} | go | func fileExist(filename string) (ok bool) {
info, err := os.Stat(filename)
if err == nil {
if ^os.ModePerm&info.Mode() == 0 {
ok = true
}
}
return ok
} | [
"func",
"fileExist",
"(",
"filename",
"string",
")",
"(",
"ok",
"bool",
")",
"{",
"info",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"^",
"os",
".",
"ModePerm",
"&",
"info",
".",
"Mode",
... | // fileExist returns true if the specified normal file exists | [
"fileExist",
"returns",
"true",
"if",
"the",
"specified",
"normal",
"file",
"exists"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L43-L51 | train |
jung-kurt/gofpdf | util.go | fileSize | func fileSize(filename string) (size int64, ok bool) {
info, err := os.Stat(filename)
ok = err == nil
if ok {
size = info.Size()
}
return
} | go | func fileSize(filename string) (size int64, ok bool) {
info, err := os.Stat(filename)
ok = err == nil
if ok {
size = info.Size()
}
return
} | [
"func",
"fileSize",
"(",
"filename",
"string",
")",
"(",
"size",
"int64",
",",
"ok",
"bool",
")",
"{",
"info",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filename",
")",
"\n",
"ok",
"=",
"err",
"==",
"nil",
"\n",
"if",
"ok",
"{",
"size",
"=",
"... | // fileSize returns the size of the specified file; ok will be false
// if the file does not exist or is not an ordinary file | [
"fileSize",
"returns",
"the",
"size",
"of",
"the",
"specified",
"file",
";",
"ok",
"will",
"be",
"false",
"if",
"the",
"file",
"does",
"not",
"exist",
"or",
"is",
"not",
"an",
"ordinary",
"file"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L55-L62 | train |
jung-kurt/gofpdf | util.go | bufferFromReader | func bufferFromReader(r io.Reader) (b *bytes.Buffer, err error) {
b = new(bytes.Buffer)
_, err = b.ReadFrom(r)
return
} | go | func bufferFromReader(r io.Reader) (b *bytes.Buffer, err error) {
b = new(bytes.Buffer)
_, err = b.ReadFrom(r)
return
} | [
"func",
"bufferFromReader",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
",",
"err",
"error",
")",
"{",
"b",
"=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"_",
",",
"err",
"=",
"b",
".",
"ReadFrom",
"(",
"r",... | // bufferFromReader returns a new buffer populated with the contents of the specified Reader | [
"bufferFromReader",
"returns",
"a",
"new",
"buffer",
"populated",
"with",
"the",
"contents",
"of",
"the",
"specified",
"Reader"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L65-L69 | train |
jung-kurt/gofpdf | util.go | slicesEqual | func slicesEqual(a, b []float64) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
} | go | func slicesEqual(a, b []float64) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
} | [
"func",
"slicesEqual",
"(",
"a",
",",
"b",
"[",
"]",
"float64",
")",
"bool",
"{",
"if",
"len",
"(",
"a",
")",
"!=",
"len",
"(",
"b",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"a",
"{",
"if",
"a",
"[",
"i",
"]"... | // slicesEqual returns true if the two specified float slices are equal | [
"slicesEqual",
"returns",
"true",
"if",
"the",
"two",
"specified",
"float",
"slices",
"are",
"equal"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L72-L82 | train |
jung-kurt/gofpdf | util.go | sliceCompress | func sliceCompress(data []byte) []byte {
var buf bytes.Buffer
cmp, _ := zlib.NewWriterLevel(&buf, zlib.BestSpeed)
cmp.Write(data)
cmp.Close()
return buf.Bytes()
} | go | func sliceCompress(data []byte) []byte {
var buf bytes.Buffer
cmp, _ := zlib.NewWriterLevel(&buf, zlib.BestSpeed)
cmp.Write(data)
cmp.Close()
return buf.Bytes()
} | [
"func",
"sliceCompress",
"(",
"data",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"cmp",
",",
"_",
":=",
"zlib",
".",
"NewWriterLevel",
"(",
"&",
"buf",
",",
"zlib",
".",
"BestSpeed",
")",
"\n",
"cmp",
... | // sliceCompress returns a zlib-compressed copy of the specified byte array | [
"sliceCompress",
"returns",
"a",
"zlib",
"-",
"compressed",
"copy",
"of",
"the",
"specified",
"byte",
"array"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L85-L91 | train |
jung-kurt/gofpdf | util.go | sliceUncompress | func sliceUncompress(data []byte) (outData []byte, err error) {
inBuf := bytes.NewReader(data)
r, err := zlib.NewReader(inBuf)
defer r.Close()
if err == nil {
var outBuf bytes.Buffer
_, err = outBuf.ReadFrom(r)
if err == nil {
outData = outBuf.Bytes()
}
}
return
} | go | func sliceUncompress(data []byte) (outData []byte, err error) {
inBuf := bytes.NewReader(data)
r, err := zlib.NewReader(inBuf)
defer r.Close()
if err == nil {
var outBuf bytes.Buffer
_, err = outBuf.ReadFrom(r)
if err == nil {
outData = outBuf.Bytes()
}
}
return
} | [
"func",
"sliceUncompress",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"outData",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"inBuf",
":=",
"bytes",
".",
"NewReader",
"(",
"data",
")",
"\n",
"r",
",",
"err",
":=",
"zlib",
".",
"NewReader",
"(",
... | // sliceUncompress returns an uncompressed copy of the specified zlib-compressed byte array | [
"sliceUncompress",
"returns",
"an",
"uncompressed",
"copy",
"of",
"the",
"specified",
"zlib",
"-",
"compressed",
"byte",
"array"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L94-L106 | train |
jung-kurt/gofpdf | util.go | intIf | func intIf(cnd bool, a, b int) int {
if cnd {
return a
}
return b
} | go | func intIf(cnd bool, a, b int) int {
if cnd {
return a
}
return b
} | [
"func",
"intIf",
"(",
"cnd",
"bool",
",",
"a",
",",
"b",
"int",
")",
"int",
"{",
"if",
"cnd",
"{",
"return",
"a",
"\n",
"}",
"\n",
"return",
"b",
"\n",
"}"
] | // intIf returns a if cnd is true, otherwise b | [
"intIf",
"returns",
"a",
"if",
"cnd",
"is",
"true",
"otherwise",
"b"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L141-L146 | train |
jung-kurt/gofpdf | util.go | strIf | func strIf(cnd bool, aStr, bStr string) string {
if cnd {
return aStr
}
return bStr
} | go | func strIf(cnd bool, aStr, bStr string) string {
if cnd {
return aStr
}
return bStr
} | [
"func",
"strIf",
"(",
"cnd",
"bool",
",",
"aStr",
",",
"bStr",
"string",
")",
"string",
"{",
"if",
"cnd",
"{",
"return",
"aStr",
"\n",
"}",
"\n",
"return",
"bStr",
"\n",
"}"
] | // strIf returns aStr if cnd is true, otherwise bStr | [
"strIf",
"returns",
"aStr",
"if",
"cnd",
"is",
"true",
"otherwise",
"bStr"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L149-L154 | train |
jung-kurt/gofpdf | util.go | UnicodeTranslator | func UnicodeTranslator(r io.Reader) (f func(string) string, err error) {
m := make(map[rune]byte)
var uPos, cPos uint32
var lineStr, nameStr string
sc := bufio.NewScanner(r)
for sc.Scan() {
lineStr = sc.Text()
lineStr = strings.TrimSpace(lineStr)
if len(lineStr) > 0 {
_, err = fmt.Sscanf(lineStr, "!%2X U+... | go | func UnicodeTranslator(r io.Reader) (f func(string) string, err error) {
m := make(map[rune]byte)
var uPos, cPos uint32
var lineStr, nameStr string
sc := bufio.NewScanner(r)
for sc.Scan() {
lineStr = sc.Text()
lineStr = strings.TrimSpace(lineStr)
if len(lineStr) > 0 {
_, err = fmt.Sscanf(lineStr, "!%2X U+... | [
"func",
"UnicodeTranslator",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"f",
"func",
"(",
"string",
")",
"string",
",",
"err",
"error",
")",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"rune",
"]",
"byte",
")",
"\n",
"var",
"uPos",
",",
"cPos",
"uint3... | // UnicodeTranslator returns a function that can be used to translate, where
// possible, utf-8 strings to a form that is compatible with the specified code
// page. The returned function accepts a string and returns a string.
//
// r is a reader that should read a buffer made up of content lines that
// pertain to the... | [
"UnicodeTranslator",
"returns",
"a",
"function",
"that",
"can",
"be",
"used",
"to",
"translate",
"where",
"possible",
"utf",
"-",
"8",
"strings",
"to",
"a",
"form",
"that",
"is",
"compatible",
"with",
"the",
"specified",
"code",
"page",
".",
"The",
"returned... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L207-L230 | train |
jung-kurt/gofpdf | util.go | UnicodeTranslatorFromFile | func UnicodeTranslatorFromFile(fileStr string) (f func(string) string, err error) {
var fl *os.File
fl, err = os.Open(fileStr)
if err == nil {
f, err = UnicodeTranslator(fl)
fl.Close()
} else {
f = doNothing
}
return
} | go | func UnicodeTranslatorFromFile(fileStr string) (f func(string) string, err error) {
var fl *os.File
fl, err = os.Open(fileStr)
if err == nil {
f, err = UnicodeTranslator(fl)
fl.Close()
} else {
f = doNothing
}
return
} | [
"func",
"UnicodeTranslatorFromFile",
"(",
"fileStr",
"string",
")",
"(",
"f",
"func",
"(",
"string",
")",
"string",
",",
"err",
"error",
")",
"{",
"var",
"fl",
"*",
"os",
".",
"File",
"\n",
"fl",
",",
"err",
"=",
"os",
".",
"Open",
"(",
"fileStr",
... | // UnicodeTranslatorFromFile returns a function that can be used to translate,
// where possible, utf-8 strings to a form that is compatible with the
// specified code page. See UnicodeTranslator for more details.
//
// fileStr identifies a font descriptor file that maps glyph positions to names.
//
// If an error occu... | [
"UnicodeTranslatorFromFile",
"returns",
"a",
"function",
"that",
"can",
"be",
"used",
"to",
"translate",
"where",
"possible",
"utf",
"-",
"8",
"strings",
"to",
"a",
"form",
"that",
"is",
"compatible",
"with",
"the",
"specified",
"code",
"page",
".",
"See",
"... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L240-L250 | train |
jung-kurt/gofpdf | util.go | Transform | func (p *PointType) Transform(x, y float64) PointType {
return PointType{p.X + x, p.Y + y}
} | go | func (p *PointType) Transform(x, y float64) PointType {
return PointType{p.X + x, p.Y + y}
} | [
"func",
"(",
"p",
"*",
"PointType",
")",
"Transform",
"(",
"x",
",",
"y",
"float64",
")",
"PointType",
"{",
"return",
"PointType",
"{",
"p",
".",
"X",
"+",
"x",
",",
"p",
".",
"Y",
"+",
"y",
"}",
"\n",
"}"
] | // Transform moves a point by given X, Y offset | [
"Transform",
"moves",
"a",
"point",
"by",
"given",
"X",
"Y",
"offset"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L285-L287 | train |
jung-kurt/gofpdf | util.go | ScaleBy | func (s *SizeType) ScaleBy(factor float64) SizeType {
return SizeType{s.Wd * factor, s.Ht * factor}
} | go | func (s *SizeType) ScaleBy(factor float64) SizeType {
return SizeType{s.Wd * factor, s.Ht * factor}
} | [
"func",
"(",
"s",
"*",
"SizeType",
")",
"ScaleBy",
"(",
"factor",
"float64",
")",
"SizeType",
"{",
"return",
"SizeType",
"{",
"s",
".",
"Wd",
"*",
"factor",
",",
"s",
".",
"Ht",
"*",
"factor",
"}",
"\n",
"}"
] | // ScaleBy expands a size by a certain factor | [
"ScaleBy",
"expands",
"a",
"size",
"by",
"a",
"certain",
"factor"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L302-L304 | train |
jung-kurt/gofpdf | util.go | ScaleToWidth | func (s *SizeType) ScaleToWidth(width float64) SizeType {
height := s.Ht * width / s.Wd
return SizeType{width, height}
} | go | func (s *SizeType) ScaleToWidth(width float64) SizeType {
height := s.Ht * width / s.Wd
return SizeType{width, height}
} | [
"func",
"(",
"s",
"*",
"SizeType",
")",
"ScaleToWidth",
"(",
"width",
"float64",
")",
"SizeType",
"{",
"height",
":=",
"s",
".",
"Ht",
"*",
"width",
"/",
"s",
".",
"Wd",
"\n",
"return",
"SizeType",
"{",
"width",
",",
"height",
"}",
"\n",
"}"
] | // ScaleToWidth adjusts the height of a size to match the given width | [
"ScaleToWidth",
"adjusts",
"the",
"height",
"of",
"a",
"size",
"to",
"match",
"the",
"given",
"width"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L307-L310 | train |
jung-kurt/gofpdf | util.go | ScaleToHeight | func (s *SizeType) ScaleToHeight(height float64) SizeType {
width := s.Wd * height / s.Ht
return SizeType{width, height}
} | go | func (s *SizeType) ScaleToHeight(height float64) SizeType {
width := s.Wd * height / s.Ht
return SizeType{width, height}
} | [
"func",
"(",
"s",
"*",
"SizeType",
")",
"ScaleToHeight",
"(",
"height",
"float64",
")",
"SizeType",
"{",
"width",
":=",
"s",
".",
"Wd",
"*",
"height",
"/",
"s",
".",
"Ht",
"\n",
"return",
"SizeType",
"{",
"width",
",",
"height",
"}",
"\n",
"}"
] | // ScaleToHeight adjusts the width of a size to match the given height | [
"ScaleToHeight",
"adjusts",
"the",
"width",
"of",
"a",
"size",
"to",
"match",
"the",
"given",
"height"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/util.go#L313-L316 | train |
jung-kurt/gofpdf | template.go | CreateTemplate | func (f *Fpdf) CreateTemplate(fn func(*Tpl)) Template {
return newTpl(PointType{0, 0}, f.curPageSize, f.defOrientation, f.unitStr, f.fontDirStr, fn, f)
} | go | func (f *Fpdf) CreateTemplate(fn func(*Tpl)) Template {
return newTpl(PointType{0, 0}, f.curPageSize, f.defOrientation, f.unitStr, f.fontDirStr, fn, f)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"CreateTemplate",
"(",
"fn",
"func",
"(",
"*",
"Tpl",
")",
")",
"Template",
"{",
"return",
"newTpl",
"(",
"PointType",
"{",
"0",
",",
"0",
"}",
",",
"f",
".",
"curPageSize",
",",
"f",
".",
"defOrientation",
",",
... | // CreateTemplate defines a new template using the current page size. | [
"CreateTemplate",
"defines",
"a",
"new",
"template",
"using",
"the",
"current",
"page",
"size",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L26-L28 | train |
jung-kurt/gofpdf | template.go | CreateTemplateCustom | func (f *Fpdf) CreateTemplateCustom(corner PointType, size SizeType, fn func(*Tpl)) Template {
return newTpl(corner, size, f.defOrientation, f.unitStr, f.fontDirStr, fn, f)
} | go | func (f *Fpdf) CreateTemplateCustom(corner PointType, size SizeType, fn func(*Tpl)) Template {
return newTpl(corner, size, f.defOrientation, f.unitStr, f.fontDirStr, fn, f)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"CreateTemplateCustom",
"(",
"corner",
"PointType",
",",
"size",
"SizeType",
",",
"fn",
"func",
"(",
"*",
"Tpl",
")",
")",
"Template",
"{",
"return",
"newTpl",
"(",
"corner",
",",
"size",
",",
"f",
".",
"defOrientati... | // CreateTemplateCustom starts a template, using the given bounds. | [
"CreateTemplateCustom",
"starts",
"a",
"template",
"using",
"the",
"given",
"bounds",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L31-L33 | train |
jung-kurt/gofpdf | template.go | CreateTpl | func CreateTpl(corner PointType, size SizeType, orientationStr, unitStr, fontDirStr string, fn func(*Tpl)) Template {
return newTpl(corner, size, orientationStr, unitStr, fontDirStr, fn, nil)
} | go | func CreateTpl(corner PointType, size SizeType, orientationStr, unitStr, fontDirStr string, fn func(*Tpl)) Template {
return newTpl(corner, size, orientationStr, unitStr, fontDirStr, fn, nil)
} | [
"func",
"CreateTpl",
"(",
"corner",
"PointType",
",",
"size",
"SizeType",
",",
"orientationStr",
",",
"unitStr",
",",
"fontDirStr",
"string",
",",
"fn",
"func",
"(",
"*",
"Tpl",
")",
")",
"Template",
"{",
"return",
"newTpl",
"(",
"corner",
",",
"size",
"... | // CreateTpl creates a template not attached to any document | [
"CreateTpl",
"creates",
"a",
"template",
"not",
"attached",
"to",
"any",
"document"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L52-L54 | train |
jung-kurt/gofpdf | template.go | UseTemplate | func (f *Fpdf) UseTemplate(t Template) {
if t == nil {
f.SetErrorf("template is nil")
return
}
corner, size := t.Size()
f.UseTemplateScaled(t, corner, size)
} | go | func (f *Fpdf) UseTemplate(t Template) {
if t == nil {
f.SetErrorf("template is nil")
return
}
corner, size := t.Size()
f.UseTemplateScaled(t, corner, size)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"UseTemplate",
"(",
"t",
"Template",
")",
"{",
"if",
"t",
"==",
"nil",
"{",
"f",
".",
"SetErrorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"corner",
",",
"size",
":=",
"t",
".",
"Size",
"(",
... | // UseTemplate adds a template to the current page or another template,
// using the size and position at which it was originally written. | [
"UseTemplate",
"adds",
"a",
"template",
"to",
"the",
"current",
"page",
"or",
"another",
"template",
"using",
"the",
"size",
"and",
"position",
"at",
"which",
"it",
"was",
"originally",
"written",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L58-L65 | train |
jung-kurt/gofpdf | template.go | UseTemplateScaled | func (f *Fpdf) UseTemplateScaled(t Template, corner PointType, size SizeType) {
if t == nil {
f.SetErrorf("template is nil")
return
}
// You have to add at least a page first
if f.page <= 0 {
f.SetErrorf("cannot use a template without first adding a page")
return
}
// make a note of the fact that we act... | go | func (f *Fpdf) UseTemplateScaled(t Template, corner PointType, size SizeType) {
if t == nil {
f.SetErrorf("template is nil")
return
}
// You have to add at least a page first
if f.page <= 0 {
f.SetErrorf("cannot use a template without first adding a page")
return
}
// make a note of the fact that we act... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"UseTemplateScaled",
"(",
"t",
"Template",
",",
"corner",
"PointType",
",",
"size",
"SizeType",
")",
"{",
"if",
"t",
"==",
"nil",
"{",
"f",
".",
"SetErrorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n... | // UseTemplateScaled adds a template to the current page or another template,
// using the given page coordinates. | [
"UseTemplateScaled",
"adds",
"a",
"template",
"to",
"the",
"current",
"page",
"or",
"another",
"template",
"using",
"the",
"given",
"page",
"coordinates",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L69-L101 | train |
jung-kurt/gofpdf | template.go | putTemplates | func (f *Fpdf) putTemplates() {
filter := ""
if f.compress {
filter = "/Filter /FlateDecode "
}
templates := sortTemplates(f.templates, f.catalogSort)
var t Template
for _, t = range templates {
corner, size := t.Size()
f.newobj()
f.templateObjects[t.ID()] = f.n
f.outf("<<%s/Type /XObject", filter)
... | go | func (f *Fpdf) putTemplates() {
filter := ""
if f.compress {
filter = "/Filter /FlateDecode "
}
templates := sortTemplates(f.templates, f.catalogSort)
var t Template
for _, t = range templates {
corner, size := t.Size()
f.newobj()
f.templateObjects[t.ID()] = f.n
f.outf("<<%s/Type /XObject", filter)
... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"putTemplates",
"(",
")",
"{",
"filter",
":=",
"\"",
"\"",
"\n",
"if",
"f",
".",
"compress",
"{",
"filter",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"templates",
":=",
"sortTemplates",
"(",
"f",
".",
"templates",
",",... | // putTemplates writes the templates to the PDF | [
"putTemplates",
"writes",
"the",
"templates",
"to",
"the",
"PDF"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L137-L205 | train |
jung-kurt/gofpdf | template.go | sortTemplates | func sortTemplates(templates map[string]Template, catalogSort bool) []Template {
chain := make([]Template, 0, len(templates)*2)
// build a full set of dependency chains
var keyList []string
var key string
var t Template
keyList = templateKeyList(templates, catalogSort)
for _, key = range keyList {
t = templat... | go | func sortTemplates(templates map[string]Template, catalogSort bool) []Template {
chain := make([]Template, 0, len(templates)*2)
// build a full set of dependency chains
var keyList []string
var key string
var t Template
keyList = templateKeyList(templates, catalogSort)
for _, key = range keyList {
t = templat... | [
"func",
"sortTemplates",
"(",
"templates",
"map",
"[",
"string",
"]",
"Template",
",",
"catalogSort",
"bool",
")",
"[",
"]",
"Template",
"{",
"chain",
":=",
"make",
"(",
"[",
"]",
"Template",
",",
"0",
",",
"len",
"(",
"templates",
")",
"*",
"2",
")"... | // sortTemplates puts templates in a suitable order based on dependices | [
"sortTemplates",
"puts",
"templates",
"in",
"a",
"suitable",
"order",
"based",
"on",
"dependices"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L225-L256 | train |
jung-kurt/gofpdf | template.go | templateChainDependencies | func templateChainDependencies(template Template) []Template {
requires := template.Templates()
chain := make([]Template, len(requires)*2)
for _, req := range requires {
chain = append(chain, templateChainDependencies(req)...)
}
chain = append(chain, template)
return chain
} | go | func templateChainDependencies(template Template) []Template {
requires := template.Templates()
chain := make([]Template, len(requires)*2)
for _, req := range requires {
chain = append(chain, templateChainDependencies(req)...)
}
chain = append(chain, template)
return chain
} | [
"func",
"templateChainDependencies",
"(",
"template",
"Template",
")",
"[",
"]",
"Template",
"{",
"requires",
":=",
"template",
".",
"Templates",
"(",
")",
"\n",
"chain",
":=",
"make",
"(",
"[",
"]",
"Template",
",",
"len",
"(",
"requires",
")",
"*",
"2"... | // templateChainDependencies is a recursive function for determining the full chain of template dependencies | [
"templateChainDependencies",
"is",
"a",
"recursive",
"function",
"for",
"determining",
"the",
"full",
"chain",
"of",
"template",
"dependencies"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/template.go#L259-L267 | train |
jung-kurt/gofpdf | spotcolor.go | AddSpotColor | func (f *Fpdf) AddSpotColor(nameStr string, c, m, y, k byte) {
if f.err == nil {
_, ok := f.spotColorMap[nameStr]
if !ok {
id := len(f.spotColorMap) + 1
f.spotColorMap[nameStr] = spotColorType{
id: id,
val: cmykColorType{
c: byteBound(c),
m: byteBound(m),
y: byteBound(y),
k: byteB... | go | func (f *Fpdf) AddSpotColor(nameStr string, c, m, y, k byte) {
if f.err == nil {
_, ok := f.spotColorMap[nameStr]
if !ok {
id := len(f.spotColorMap) + 1
f.spotColorMap[nameStr] = spotColorType{
id: id,
val: cmykColorType{
c: byteBound(c),
m: byteBound(m),
y: byteBound(y),
k: byteB... | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"AddSpotColor",
"(",
"nameStr",
"string",
",",
"c",
",",
"m",
",",
"y",
",",
"k",
"byte",
")",
"{",
"if",
"f",
".",
"err",
"==",
"nil",
"{",
"_",
",",
"ok",
":=",
"f",
".",
"spotColorMap",
"[",
"nameStr",
"... | // AddSpotColor adds an ink-based CMYK color to the gofpdf instance and
// associates it with the specified name. The individual components specify
// percentages ranging from 0 to 100. Values above this are quietly capped to
// 100. An error occurs if the specified name is already associated with a
// color. | [
"AddSpotColor",
"adds",
"an",
"ink",
"-",
"based",
"CMYK",
"color",
"to",
"the",
"gofpdf",
"instance",
"and",
"associates",
"it",
"with",
"the",
"specified",
"name",
".",
"The",
"individual",
"components",
"specify",
"percentages",
"ranging",
"from",
"0",
"to"... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/spotcolor.go#L36-L54 | train |
jung-kurt/gofpdf | spotcolor.go | GetDrawSpotColor | func (f *Fpdf) GetDrawSpotColor() (name string, c, m, y, k byte) {
return f.returnSpotColor(f.color.draw)
} | go | func (f *Fpdf) GetDrawSpotColor() (name string, c, m, y, k byte) {
return f.returnSpotColor(f.color.draw)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetDrawSpotColor",
"(",
")",
"(",
"name",
"string",
",",
"c",
",",
"m",
",",
"y",
",",
"k",
"byte",
")",
"{",
"return",
"f",
".",
"returnSpotColor",
"(",
"f",
".",
"color",
".",
"draw",
")",
"\n",
"}"
] | // GetDrawSpotColor returns the most recently used spot color information for
// drawing. This will not be the current drawing color if some other color type
// such as RGB is active. If no spot color has been set for drawing, zero
// values are returned. | [
"GetDrawSpotColor",
"returns",
"the",
"most",
"recently",
"used",
"spot",
"color",
"information",
"for",
"drawing",
".",
"This",
"will",
"not",
"be",
"the",
"current",
"drawing",
"color",
"if",
"some",
"other",
"color",
"type",
"such",
"as",
"RGB",
"is",
"ac... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/spotcolor.go#L143-L145 | train |
jung-kurt/gofpdf | spotcolor.go | GetTextSpotColor | func (f *Fpdf) GetTextSpotColor() (name string, c, m, y, k byte) {
return f.returnSpotColor(f.color.text)
} | go | func (f *Fpdf) GetTextSpotColor() (name string, c, m, y, k byte) {
return f.returnSpotColor(f.color.text)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetTextSpotColor",
"(",
")",
"(",
"name",
"string",
",",
"c",
",",
"m",
",",
"y",
",",
"k",
"byte",
")",
"{",
"return",
"f",
".",
"returnSpotColor",
"(",
"f",
".",
"color",
".",
"text",
")",
"\n",
"}"
] | // GetTextSpotColor returns the most recently used spot color information for
// text output. This will not be the current text color if some other color
// type such as RGB is active. If no spot color has been set for text, zero
// values are returned. | [
"GetTextSpotColor",
"returns",
"the",
"most",
"recently",
"used",
"spot",
"color",
"information",
"for",
"text",
"output",
".",
"This",
"will",
"not",
"be",
"the",
"current",
"text",
"color",
"if",
"some",
"other",
"color",
"type",
"such",
"as",
"RGB",
"is",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/spotcolor.go#L151-L153 | train |
jung-kurt/gofpdf | spotcolor.go | GetFillSpotColor | func (f *Fpdf) GetFillSpotColor() (name string, c, m, y, k byte) {
return f.returnSpotColor(f.color.fill)
} | go | func (f *Fpdf) GetFillSpotColor() (name string, c, m, y, k byte) {
return f.returnSpotColor(f.color.fill)
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"GetFillSpotColor",
"(",
")",
"(",
"name",
"string",
",",
"c",
",",
"m",
",",
"y",
",",
"k",
"byte",
")",
"{",
"return",
"f",
".",
"returnSpotColor",
"(",
"f",
".",
"color",
".",
"fill",
")",
"\n",
"}"
] | // GetFillSpotColor returns the most recently used spot color information for
// fill output. This will not be the current fill color if some other color
// type such as RGB is active. If no fill spot color has been set, zero values
// are returned. | [
"GetFillSpotColor",
"returns",
"the",
"most",
"recently",
"used",
"spot",
"color",
"information",
"for",
"fill",
"output",
".",
"This",
"will",
"not",
"be",
"the",
"current",
"fill",
"color",
"if",
"some",
"other",
"color",
"type",
"such",
"as",
"RGB",
"is",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/spotcolor.go#L159-L161 | train |
jung-kurt/gofpdf | layer.go | BeginLayer | func (f *Fpdf) BeginLayer(id int) {
f.EndLayer()
if id >= 0 && id < len(f.layer.list) {
f.outf("/OC /OC%d BDC", id)
f.layer.currentLayer = id
}
} | go | func (f *Fpdf) BeginLayer(id int) {
f.EndLayer()
if id >= 0 && id < len(f.layer.list) {
f.outf("/OC /OC%d BDC", id)
f.layer.currentLayer = id
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"BeginLayer",
"(",
"id",
"int",
")",
"{",
"f",
".",
"EndLayer",
"(",
")",
"\n",
"if",
"id",
">=",
"0",
"&&",
"id",
"<",
"len",
"(",
"f",
".",
"layer",
".",
"list",
")",
"{",
"f",
".",
"outf",
"(",
"\"",
... | // BeginLayer is called to begin adding content to the specified layer. All
// content added to the page between a call to BeginLayer and a call to
// EndLayer is added to the layer specified by id. See AddLayer for more
// details. | [
"BeginLayer",
"is",
"called",
"to",
"begin",
"adding",
"content",
"to",
"the",
"specified",
"layer",
".",
"All",
"content",
"added",
"to",
"the",
"page",
"between",
"a",
"call",
"to",
"BeginLayer",
"and",
"a",
"call",
"to",
"EndLayer",
"is",
"added",
"to",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/layer.go#L55-L61 | train |
jung-kurt/gofpdf | layer.go | EndLayer | func (f *Fpdf) EndLayer() {
if f.layer.currentLayer >= 0 {
f.out("EMC")
f.layer.currentLayer = -1
}
} | go | func (f *Fpdf) EndLayer() {
if f.layer.currentLayer >= 0 {
f.out("EMC")
f.layer.currentLayer = -1
}
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"EndLayer",
"(",
")",
"{",
"if",
"f",
".",
"layer",
".",
"currentLayer",
">=",
"0",
"{",
"f",
".",
"out",
"(",
"\"",
"\"",
")",
"\n",
"f",
".",
"layer",
".",
"currentLayer",
"=",
"-",
"1",
"\n",
"}",
"\n",
... | // EndLayer is called to stop adding content to the currently active layer. See
// BeginLayer for more details. | [
"EndLayer",
"is",
"called",
"to",
"stop",
"adding",
"content",
"to",
"the",
"currently",
"active",
"layer",
".",
"See",
"BeginLayer",
"for",
"more",
"details",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/layer.go#L65-L70 | train |
jung-kurt/gofpdf | contrib/barcode/barcode.go | GetUnscaledBarcodeDimensions | func GetUnscaledBarcodeDimensions(pdf barcodePdf, code string) (w, h float64) {
barcodes.Lock()
unscaled, ok := barcodes.cache[code]
barcodes.Unlock()
if !ok {
err := errors.New("Barcode not found")
pdf.SetError(err)
return
}
return convertFrom96Dpi(pdf, float64(unscaled.Bounds().Dx())),
convertFrom96Dp... | go | func GetUnscaledBarcodeDimensions(pdf barcodePdf, code string) (w, h float64) {
barcodes.Lock()
unscaled, ok := barcodes.cache[code]
barcodes.Unlock()
if !ok {
err := errors.New("Barcode not found")
pdf.SetError(err)
return
}
return convertFrom96Dpi(pdf, float64(unscaled.Bounds().Dx())),
convertFrom96Dp... | [
"func",
"GetUnscaledBarcodeDimensions",
"(",
"pdf",
"barcodePdf",
",",
"code",
"string",
")",
"(",
"w",
",",
"h",
"float64",
")",
"{",
"barcodes",
".",
"Lock",
"(",
")",
"\n",
"unscaled",
",",
"ok",
":=",
"barcodes",
".",
"cache",
"[",
"code",
"]",
"\n... | // GetUnscaledBarcodeDimensions returns the width and height of the
// unscaled barcode associated with the given code. | [
"GetUnscaledBarcodeDimensions",
"returns",
"the",
"width",
"and",
"height",
"of",
"the",
"unscaled",
"barcode",
"associated",
"with",
"the",
"given",
"code",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/contrib/barcode/barcode.go#L127-L140 | train |
jung-kurt/gofpdf | contrib/barcode/barcode.go | uniqueBarcodeName | func uniqueBarcodeName(code string, x, y float64) string {
xStr := strconv.FormatFloat(x, 'E', -1, 64)
yStr := strconv.FormatFloat(y, 'E', -1, 64)
return "barcode-" + code + "-" + xStr + yStr
} | go | func uniqueBarcodeName(code string, x, y float64) string {
xStr := strconv.FormatFloat(x, 'E', -1, 64)
yStr := strconv.FormatFloat(y, 'E', -1, 64)
return "barcode-" + code + "-" + xStr + yStr
} | [
"func",
"uniqueBarcodeName",
"(",
"code",
"string",
",",
"x",
",",
"y",
"float64",
")",
"string",
"{",
"xStr",
":=",
"strconv",
".",
"FormatFloat",
"(",
"x",
",",
"'E'",
",",
"-",
"1",
",",
"64",
")",
"\n",
"yStr",
":=",
"strconv",
".",
"FormatFloat"... | // uniqueBarcodeName makes sure every barcode has a unique name for its
// dimensions. Scaling a barcode image results in quality loss, which could be
// a problem for barcode readers. | [
"uniqueBarcodeName",
"makes",
"sure",
"every",
"barcode",
"has",
"a",
"unique",
"name",
"for",
"its",
"dimensions",
".",
"Scaling",
"a",
"barcode",
"image",
"results",
"in",
"quality",
"loss",
"which",
"could",
"be",
"a",
"problem",
"for",
"barcode",
"readers"... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/contrib/barcode/barcode.go#L252-L257 | train |
jung-kurt/gofpdf | contrib/barcode/barcode.go | barcodeKey | func barcodeKey(bcode barcode.Barcode) string {
return bcode.Metadata().CodeKind + bcode.Content()
} | go | func barcodeKey(bcode barcode.Barcode) string {
return bcode.Metadata().CodeKind + bcode.Content()
} | [
"func",
"barcodeKey",
"(",
"bcode",
"barcode",
".",
"Barcode",
")",
"string",
"{",
"return",
"bcode",
".",
"Metadata",
"(",
")",
".",
"CodeKind",
"+",
"bcode",
".",
"Content",
"(",
")",
"\n",
"}"
] | // barcodeKey combines the code type and code value into a unique identifier for
// a barcode type. This is so that we can store several barcodes with the same
// code but different type in the barcodes map. | [
"barcodeKey",
"combines",
"the",
"code",
"type",
"and",
"code",
"value",
"into",
"a",
"unique",
"identifier",
"for",
"a",
"barcode",
"type",
".",
"This",
"is",
"so",
"that",
"we",
"can",
"store",
"several",
"barcodes",
"with",
"the",
"same",
"code",
"but",... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/contrib/barcode/barcode.go#L262-L264 | train |
jung-kurt/gofpdf | grid.go | StateGet | func StateGet(pdf *Fpdf) (st StateType) {
st.clrDraw.R, st.clrDraw.G, st.clrDraw.B = pdf.GetDrawColor()
st.clrFill.R, st.clrFill.G, st.clrFill.B = pdf.GetFillColor()
st.clrText.R, st.clrText.G, st.clrText.B = pdf.GetTextColor()
st.lineWd = pdf.GetLineWidth()
_, st.fontSize = pdf.GetFontSize()
st.alpha, st.blendSt... | go | func StateGet(pdf *Fpdf) (st StateType) {
st.clrDraw.R, st.clrDraw.G, st.clrDraw.B = pdf.GetDrawColor()
st.clrFill.R, st.clrFill.G, st.clrFill.B = pdf.GetFillColor()
st.clrText.R, st.clrText.G, st.clrText.B = pdf.GetTextColor()
st.lineWd = pdf.GetLineWidth()
_, st.fontSize = pdf.GetFontSize()
st.alpha, st.blendSt... | [
"func",
"StateGet",
"(",
"pdf",
"*",
"Fpdf",
")",
"(",
"st",
"StateType",
")",
"{",
"st",
".",
"clrDraw",
".",
"R",
",",
"st",
".",
"clrDraw",
".",
"G",
",",
"st",
".",
"clrDraw",
".",
"B",
"=",
"pdf",
".",
"GetDrawColor",
"(",
")",
"\n",
"st",... | // StateGet returns a variable that contains common state values. | [
"StateGet",
"returns",
"a",
"variable",
"that",
"contains",
"common",
"state",
"values",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L35-L44 | train |
jung-kurt/gofpdf | grid.go | Put | func (st StateType) Put(pdf *Fpdf) {
pdf.SetDrawColor(st.clrDraw.R, st.clrDraw.G, st.clrDraw.B)
pdf.SetFillColor(st.clrFill.R, st.clrFill.G, st.clrFill.B)
pdf.SetTextColor(st.clrText.R, st.clrText.G, st.clrText.B)
pdf.SetLineWidth(st.lineWd)
pdf.SetFontUnitSize(st.fontSize)
pdf.SetAlpha(st.alpha, st.blendStr)
pd... | go | func (st StateType) Put(pdf *Fpdf) {
pdf.SetDrawColor(st.clrDraw.R, st.clrDraw.G, st.clrDraw.B)
pdf.SetFillColor(st.clrFill.R, st.clrFill.G, st.clrFill.B)
pdf.SetTextColor(st.clrText.R, st.clrText.G, st.clrText.B)
pdf.SetLineWidth(st.lineWd)
pdf.SetFontUnitSize(st.fontSize)
pdf.SetAlpha(st.alpha, st.blendStr)
pd... | [
"func",
"(",
"st",
"StateType",
")",
"Put",
"(",
"pdf",
"*",
"Fpdf",
")",
"{",
"pdf",
".",
"SetDrawColor",
"(",
"st",
".",
"clrDraw",
".",
"R",
",",
"st",
".",
"clrDraw",
".",
"G",
",",
"st",
".",
"clrDraw",
".",
"B",
")",
"\n",
"pdf",
".",
"... | // Put sets the common state values contained in the state structure
// specified by st. | [
"Put",
"sets",
"the",
"common",
"state",
"values",
"contained",
"in",
"the",
"state",
"structure",
"specified",
"by",
"st",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L48-L56 | train |
jung-kurt/gofpdf | grid.go | defaultFormatter | func defaultFormatter(val float64, precision int) string {
return strconv.FormatFloat(val, 'f', precision, 64)
} | go | func defaultFormatter(val float64, precision int) string {
return strconv.FormatFloat(val, 'f', precision, 64)
} | [
"func",
"defaultFormatter",
"(",
"val",
"float64",
",",
"precision",
"int",
")",
"string",
"{",
"return",
"strconv",
".",
"FormatFloat",
"(",
"val",
",",
"'f'",
",",
"precision",
",",
"64",
")",
"\n",
"}"
] | // defaultFormatter returns the string form of val with precision decimal places. | [
"defaultFormatter",
"returns",
"the",
"string",
"form",
"of",
"val",
"with",
"precision",
"decimal",
"places",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L62-L64 | train |
jung-kurt/gofpdf | grid.go | XY | func (g GridType) XY(dataX, dataY float64) (x, y float64) {
return g.xm*dataX + g.xb, g.ym*dataY + g.yb
} | go | func (g GridType) XY(dataX, dataY float64) (x, y float64) {
return g.xm*dataX + g.xb, g.ym*dataY + g.yb
} | [
"func",
"(",
"g",
"GridType",
")",
"XY",
"(",
"dataX",
",",
"dataY",
"float64",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"return",
"g",
".",
"xm",
"*",
"dataX",
"+",
"g",
".",
"xb",
",",
"g",
".",
"ym",
"*",
"dataY",
"+",
"g",
".",
"yb... | // XY converts dataX and dataY, specified in logical data units, to the X and Y
// position on the current page. | [
"XY",
"converts",
"dataX",
"and",
"dataY",
"specified",
"in",
"logical",
"data",
"units",
"to",
"the",
"X",
"and",
"Y",
"position",
"on",
"the",
"current",
"page",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L167-L169 | train |
jung-kurt/gofpdf | grid.go | Pos | func (g GridType) Pos(xRel, yRel float64) (x, y float64) {
x = g.w*xRel + g.x
y = g.h*(1-yRel) + g.y
return
} | go | func (g GridType) Pos(xRel, yRel float64) (x, y float64) {
x = g.w*xRel + g.x
y = g.h*(1-yRel) + g.y
return
} | [
"func",
"(",
"g",
"GridType",
")",
"Pos",
"(",
"xRel",
",",
"yRel",
"float64",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"x",
"=",
"g",
".",
"w",
"*",
"xRel",
"+",
"g",
".",
"x",
"\n",
"y",
"=",
"g",
".",
"h",
"*",
"(",
"1",
"-",
"y... | // Pos returns the point, in page units, indicated by the relative positions
// xRel and yRel. These are values between 0 and 1. xRel specifies the relative
// position between the grid's left and right edges. yRel specifies the
// relative position between the grid's bottom and top edges. | [
"Pos",
"returns",
"the",
"point",
"in",
"page",
"units",
"indicated",
"by",
"the",
"relative",
"positions",
"xRel",
"and",
"yRel",
".",
"These",
"are",
"values",
"between",
"0",
"and",
"1",
".",
"xRel",
"specifies",
"the",
"relative",
"position",
"between",
... | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L175-L179 | train |
jung-kurt/gofpdf | grid.go | X | func (g GridType) X(dataX float64) float64 {
return g.xm*dataX + g.xb
} | go | func (g GridType) X(dataX float64) float64 {
return g.xm*dataX + g.xb
} | [
"func",
"(",
"g",
"GridType",
")",
"X",
"(",
"dataX",
"float64",
")",
"float64",
"{",
"return",
"g",
".",
"xm",
"*",
"dataX",
"+",
"g",
".",
"xb",
"\n",
"}"
] | // X converts dataX, specified in logical data units, to the X position on the
// current page. | [
"X",
"converts",
"dataX",
"specified",
"in",
"logical",
"data",
"units",
"to",
"the",
"X",
"position",
"on",
"the",
"current",
"page",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L183-L185 | train |
jung-kurt/gofpdf | grid.go | Y | func (g GridType) Y(dataY float64) float64 {
return g.ym*dataY + g.yb
} | go | func (g GridType) Y(dataY float64) float64 {
return g.ym*dataY + g.yb
} | [
"func",
"(",
"g",
"GridType",
")",
"Y",
"(",
"dataY",
"float64",
")",
"float64",
"{",
"return",
"g",
".",
"ym",
"*",
"dataY",
"+",
"g",
".",
"yb",
"\n",
"}"
] | // Y converts dataY, specified in logical data units, to the Y position on the
// current page. | [
"Y",
"converts",
"dataY",
"specified",
"in",
"logical",
"data",
"units",
"to",
"the",
"Y",
"position",
"on",
"the",
"current",
"page",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L201-L203 | train |
jung-kurt/gofpdf | grid.go | XRange | func (g GridType) XRange() (min, max float64) {
min = g.xTicks[0]
max = g.xTicks[len(g.xTicks)-1]
return
} | go | func (g GridType) XRange() (min, max float64) {
min = g.xTicks[0]
max = g.xTicks[len(g.xTicks)-1]
return
} | [
"func",
"(",
"g",
"GridType",
")",
"XRange",
"(",
")",
"(",
"min",
",",
"max",
"float64",
")",
"{",
"min",
"=",
"g",
".",
"xTicks",
"[",
"0",
"]",
"\n",
"max",
"=",
"g",
".",
"xTicks",
"[",
"len",
"(",
"g",
".",
"xTicks",
")",
"-",
"1",
"]"... | // XRange returns the minimum and maximum values for the current tickmark
// sequence. These correspond to the data values of the graph's left and right
// edges. | [
"XRange",
"returns",
"the",
"minimum",
"and",
"maximum",
"values",
"for",
"the",
"current",
"tickmark",
"sequence",
".",
"These",
"correspond",
"to",
"the",
"data",
"values",
"of",
"the",
"graph",
"s",
"left",
"and",
"right",
"edges",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L208-L212 | train |
jung-kurt/gofpdf | grid.go | YRange | func (g GridType) YRange() (min, max float64) {
min = g.yTicks[0]
max = g.yTicks[len(g.yTicks)-1]
return
} | go | func (g GridType) YRange() (min, max float64) {
min = g.yTicks[0]
max = g.yTicks[len(g.yTicks)-1]
return
} | [
"func",
"(",
"g",
"GridType",
")",
"YRange",
"(",
")",
"(",
"min",
",",
"max",
"float64",
")",
"{",
"min",
"=",
"g",
".",
"yTicks",
"[",
"0",
"]",
"\n",
"max",
"=",
"g",
".",
"yTicks",
"[",
"len",
"(",
"g",
".",
"yTicks",
")",
"-",
"1",
"]"... | // YRange returns the minimum and maximum values for the current tickmark
// sequence. These correspond to the data values of the graph's bottom and top
// edges. | [
"YRange",
"returns",
"the",
"minimum",
"and",
"maximum",
"values",
"for",
"the",
"current",
"tickmark",
"sequence",
".",
"These",
"correspond",
"to",
"the",
"data",
"values",
"of",
"the",
"graph",
"s",
"bottom",
"and",
"top",
"edges",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/grid.go#L217-L221 | train |
jung-kurt/gofpdf | htmlbasic.go | HTMLBasicTokenize | func HTMLBasicTokenize(htmlStr string) (list []HTMLBasicSegmentType) {
// This routine is adapted from http://www.fpdf.org/
list = make([]HTMLBasicSegmentType, 0, 16)
htmlStr = strings.Replace(htmlStr, "\n", " ", -1)
htmlStr = strings.Replace(htmlStr, "\r", "", -1)
tagRe, _ := regexp.Compile(`(?U)<.*>`)
attrRe, _... | go | func HTMLBasicTokenize(htmlStr string) (list []HTMLBasicSegmentType) {
// This routine is adapted from http://www.fpdf.org/
list = make([]HTMLBasicSegmentType, 0, 16)
htmlStr = strings.Replace(htmlStr, "\n", " ", -1)
htmlStr = strings.Replace(htmlStr, "\r", "", -1)
tagRe, _ := regexp.Compile(`(?U)<.*>`)
attrRe, _... | [
"func",
"HTMLBasicTokenize",
"(",
"htmlStr",
"string",
")",
"(",
"list",
"[",
"]",
"HTMLBasicSegmentType",
")",
"{",
"// This routine is adapted from http://www.fpdf.org/",
"list",
"=",
"make",
"(",
"[",
"]",
"HTMLBasicSegmentType",
",",
"0",
",",
"16",
")",
"\n",... | // HTMLBasicTokenize returns a list of HTML tags and literal elements. This is
// done with regular expressions, so the result is only marginally better than
// useless. | [
"HTMLBasicTokenize",
"returns",
"a",
"list",
"of",
"HTML",
"tags",
"and",
"literal",
"elements",
".",
"This",
"is",
"done",
"with",
"regular",
"expressions",
"so",
"the",
"result",
"is",
"only",
"marginally",
"better",
"than",
"useless",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/htmlbasic.go#L35-L92 | train |
jung-kurt/gofpdf | htmlbasic.go | HTMLBasicNew | func (f *Fpdf) HTMLBasicNew() (html HTMLBasicType) {
html.pdf = f
html.Link.ClrR, html.Link.ClrG, html.Link.ClrB = 0, 0, 128
html.Link.Bold, html.Link.Italic, html.Link.Underscore = false, false, true
return
} | go | func (f *Fpdf) HTMLBasicNew() (html HTMLBasicType) {
html.pdf = f
html.Link.ClrR, html.Link.ClrG, html.Link.ClrB = 0, 0, 128
html.Link.Bold, html.Link.Italic, html.Link.Underscore = false, false, true
return
} | [
"func",
"(",
"f",
"*",
"Fpdf",
")",
"HTMLBasicNew",
"(",
")",
"(",
"html",
"HTMLBasicType",
")",
"{",
"html",
".",
"pdf",
"=",
"f",
"\n",
"html",
".",
"Link",
".",
"ClrR",
",",
"html",
".",
"Link",
".",
"ClrG",
",",
"html",
".",
"Link",
".",
"C... | // HTMLBasicNew returns an instance that facilitates writing basic HTML in the
// specified PDF file. | [
"HTMLBasicNew",
"returns",
"an",
"instance",
"that",
"facilitates",
"writing",
"basic",
"HTML",
"in",
"the",
"specified",
"PDF",
"file",
"."
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/htmlbasic.go#L109-L114 | train |
jung-kurt/gofpdf | font.go | getInfoFromTrueType | func getInfoFromTrueType(fileStr string, msgWriter io.Writer, embed bool, encList encListType) (info fontInfoType, err error) {
var ttf TtfType
ttf, err = TtfParse(fileStr)
if err != nil {
return
}
if embed {
if !ttf.Embeddable {
err = fmt.Errorf("font license does not allow embedding")
return
}
info... | go | func getInfoFromTrueType(fileStr string, msgWriter io.Writer, embed bool, encList encListType) (info fontInfoType, err error) {
var ttf TtfType
ttf, err = TtfParse(fileStr)
if err != nil {
return
}
if embed {
if !ttf.Embeddable {
err = fmt.Errorf("font license does not allow embedding")
return
}
info... | [
"func",
"getInfoFromTrueType",
"(",
"fileStr",
"string",
",",
"msgWriter",
"io",
".",
"Writer",
",",
"embed",
"bool",
",",
"encList",
"encListType",
")",
"(",
"info",
"fontInfoType",
",",
"err",
"error",
")",
"{",
"var",
"ttf",
"TtfType",
"\n",
"ttf",
",",... | // getInfoFromTrueType returns information from a TrueType font | [
"getInfoFromTrueType",
"returns",
"information",
"from",
"a",
"TrueType",
"font"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/font.go#L85-L138 | train |
jung-kurt/gofpdf | font.go | makeFontEncoding | func makeFontEncoding(encList encListType, refEncFileStr string) (diffStr string, err error) {
var refList encListType
if refList, err = loadMap(refEncFileStr); err != nil {
return
}
var buf fmtBuffer
last := 0
for j := 32; j < 256; j++ {
if encList[j].name != refList[j].name {
if j != last+1 {
buf.pri... | go | func makeFontEncoding(encList encListType, refEncFileStr string) (diffStr string, err error) {
var refList encListType
if refList, err = loadMap(refEncFileStr); err != nil {
return
}
var buf fmtBuffer
last := 0
for j := 32; j < 256; j++ {
if encList[j].name != refList[j].name {
if j != last+1 {
buf.pri... | [
"func",
"makeFontEncoding",
"(",
"encList",
"encListType",
",",
"refEncFileStr",
"string",
")",
"(",
"diffStr",
"string",
",",
"err",
"error",
")",
"{",
"var",
"refList",
"encListType",
"\n",
"if",
"refList",
",",
"err",
"=",
"loadMap",
"(",
"refEncFileStr",
... | // makeFontEncoding builds differences from reference encoding | [
"makeFontEncoding",
"builds",
"differences",
"from",
"reference",
"encoding"
] | 8b09ffb30d9a8716107d250631b3c580aa54ba04 | https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/font.go#L314-L332 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.