Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: consider using //go:embed directives #13

Closed
sbinet opened this issue Aug 17, 2021 · 2 comments
Closed

all: consider using //go:embed directives #13

sbinet opened this issue Aug 17, 2021 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sbinet
Copy link
Contributor

sbinet commented Aug 17, 2021

now that we require Go>=1.16, we can use //go:embed directives.

@sbinet sbinet added good first issue Good for newcomers help wanted Extra attention is needed labels Aug 17, 2021
@flibustenet
Copy link
Contributor

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
Copy link
Contributor Author

sbinet commented Sep 2, 2021

yep, some like that.

when I filed that issue I hadn't surveyed the whole list of embedded files that fpdf used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants