all: consider using //go:embed directives
sbinet opened this issue · 2 comments
sbinet commented
now that we require Go>=1.16, we can use //go:embed
directives.
flibustenet commented
Do you mean to replace embedded.go
with //go:embed
?
I would like to try this new directive, i can try to work on this issue.
Currently embeddedMapList
has only cp1250
and cp1252
but it's possible to embed all map files of font
directory.
Something like that ?
//go:embed font/*.map
var embeddedFontMap embed.FS
func (f *Fpdf) UnicodeTranslatorFromDescriptor(cpStr string) (rep func(string) string) {
if f.err == nil {
if len(cpStr) == 0 {
cpStr = "cp1252"
}
emb, err := embeddedFontMap.Open("font/" + cpStr + ".map")
if err == nil {
rep, f.err = UnicodeTranslator(emb)
} else {
rep, f.err = UnicodeTranslatorFromFile(filepath.Join(f.fontpath, cpStr) + ".map")
}
} else {
rep = doNothing
}
return
}
sbinet commented
yep, some like that.
when I filed that issue I hadn't surveyed the whole list of embedded files that fpdf
used.