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

Output blank png image when use custom font family in windows #80

Open
lrh3321 opened this issue Apr 17, 2024 · 5 comments · May be fixed by #83
Open

Output blank png image when use custom font family in windows #80

lrh3321 opened this issue Apr 17, 2024 · 5 comments · May be fixed by #83

Comments

@lrh3321
Copy link

lrh3321 commented Apr 17, 2024

Describe the bug

Output blank png image when use custom font family in windows

To Reproduce
Steps to reproduce the behavior:

  1. Execute freeze -x "echo Something" --font.family "Microsoft YaHei" -o freeze.png
  2. Execute explorer freeze.png

Expected behavior

Got an blank image.

Screenshots
If applicable, add screenshots to help explain your problem.
Snipaste_2024-04-17_20-49-36

Desktop (please complete the following information):

  • OS: Microsoft Windows
  • Browser chrome
  • Version 23H2 10.0.22635.3495

Additional context

Load the default fonts dir may help this

freeze/png.go

Lines 50 to 57 in 80803eb

err = fontdb.LoadFontData(font.JetBrainsMonoTTF)
if err != nil {
printErrorFatal("Unable to load font", err)
}
err = fontdb.LoadFontData(font.JetBrainsMonoNLTTF)
if err != nil {
printErrorFatal("Unable to load font", err)
}

fontdb.LoadFontsDir(OS_FONTS_DIR)
@lrh3321
Copy link
Author

lrh3321 commented Apr 17, 2024

--font.file option could not help for png format output.Seems embed font file has no effect for github.com/kanrichan/resvg-go .

@getify
Copy link

getify commented Jun 3, 2024

I am having the same problem -- using the linux build of freeze from inside wsl2 on windows 11 -- trying to specify font.family as "Source Code Pro", or setting font.file as the path to the "SourceCodePro-Regular.ttf" file in my windows\fonts directory. Either way, I get a blank .PNG file. If I use "JetBrains Mono" for the font.family, the file renders correctly (but with an undesirable font).

@divinedragon
Copy link

I am having the same problem -- using the linux build of freeze from inside wsl2 on windows 11 -- trying to specify font.family as "Source Code Pro", or setting font.file as the path to the "SourceCodePro-Regular.ttf" file in my windows\fonts directory. Either way, I get a blank .PNG file. If I use "JetBrains Mono" for the font.family, the file renders correctly (but with an undesirable font).

Same for me in Ubuntu 22.04

@jradtilbrook
Copy link

jradtilbrook commented Jul 10, 2024

I'm getting this on mac as well. It looks like the font config is not actually considered on this line:

freeze/png.go

Line 50 in 578e9d0

err = fontdb.LoadFontData(font.JetBrainsMonoTTF)

I've had a quick play to see if I can hard code another font file but its not working. Must be more at play here. I'll make do with default font for now as I don't have more time

@remino
Copy link

remino commented Aug 15, 2024

Came here to say I’m having the same issue:

freeze css.css -t dracula --font.family 'Sarasa Term J Nerd Font' --font.size 16 -o css.png

This just outputs a PNG file with a background but no text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants