athenapdf icon indicating copy to clipboard operation
athenapdf copied to clipboard

Problem loading fonts

Open AliKamil opened this issue 6 years ago • 6 comments

Testcase to reproduce the issue:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<style type="text/css">
		@import url('https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic&subset=latin');
		body {
		  font-family: 'Lato', sans-serif ;
		}

		@media screen {
		    [class*="printer only"] {
			display: none;
		    }
		}

	</style>	
</head>
<body>

	Remove this text and the text below will ALSO disappear

	<div class="printer only" style="border: solid 1px red">
		This is the test string that should show up when printing
	</div>	
</body>
</html>

If font is not used outside of printer only block - it cannot be used from within either.

Can anyone suggest something on that matter?

AliKamil avatar Jul 05 '17 14:07 AliKamil

Change printer only to print-only (sorry, I just want to isolate the problem).

MrSaints avatar Jul 05 '17 14:07 MrSaints

I can do this in example to avoid confusion, but that doesn't fix an issue.

AliKamil avatar Jul 05 '17 14:07 AliKamil

Interesting, can you try running it with a delay of 1s (-D 1000) ? I was able to replicate this on the latest v3 too.

MrSaints avatar Jul 05 '17 14:07 MrSaints

Delay (1s or bigger) doesn't affect this issue at all.

AliKamil avatar Jul 05 '17 15:07 AliKamil

If you add a <b>test</b> to the printer only tag, it will also not show up, unless you also add <b>foobar</b> into the body tag, outside of the printer only div. Also the same with some accented characters like Ł.

The cause seems to be that Electron can only draw fonts (or variants of it) that have been "required" outside of the printer only tag. If a bold variant of the font was not already used outside of the div, it will not be available.

Curiously enough, adding the accented character into the printer only div will make even the text outside disappear.

lauri-elevant avatar Jul 05 '17 15:07 lauri-elevant

Okay, this is not a problem on v3 if a delay is set (~1s).

MrSaints avatar Jul 07 '17 08:07 MrSaints