pzprjs icon indicating copy to clipboard operation
pzprjs copied to clipboard

In Display, there is an option for Font Family > serif, but it doesn't seem to do anything.

Open robx opened this issue 6 years ago • 13 comments

In Display, there is an option for Font Family > serif, but it doesn't seem to do anything.

Originally posted by @boboquack in https://github.com/robx/pzprjs/issues/1#issuecomment-533868237

robx avatar Dec 14 '19 12:12 robx

@boboquack This actually works for me, tested with a five cells puzzle where it changed the clue font. This is with Chrome?

robx avatar Dec 14 '19 22:12 robx

This is with Chrome. I just tested it with an Easy as ABC and a FiveCells: http://pzv.jp/p?easyasabc/6/6/4/1211j2242i4i33i and http://pzv.jp/p.html?fivecells/10/10/l3d2c3c0c1l0b3h3b0m1b0d3f3f2d3a.

boboquack avatar Dec 14 '19 23:12 boboquack

strange, it works with all my browsers on macos, both on pzv.jp and on puzz.link...

looking at the code, another question: what OS are you on? there's some special code for Android

if you want to dig a bit deeper and can use the browser developer tools, here's how I can check and change the font style manually:

> ui.puzzle.painter.fontfamily
"sans-serif"
// change font family in the menu
> ui.puzzle.painter.fontfamily
"serif"
> ui.puzzle.painter.fontfamily = 'Comic Sans MS'
> ui.puzzle.painter.paintAll()
// puzzle now rendered with Comic Sans

robx avatar Dec 15 '19 11:12 robx

I managed to get the puzzle rendered in Comic Sans successfully, so maybe the "serif" font isn't installed and it's defaulting to sans-serif? I'm on Windows 10.0.18362.

boboquack avatar Dec 15 '19 23:12 boboquack

That's strange, "serif" should choose any serif font, and I'm sure Times New Roman is available. Perhaps you changed the default serif font to a sans-serif font in Chrome preferences?

At any rate, I'm inclined to let this one rest until it gets confirmed by other users.

robx avatar Dec 16 '19 10:12 robx

Curiouser and curiouser... if it helps - changing the source on the github css to

.markdown-body {
    font-family: serif;
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

produces Times New Roman in the comments as desired...

boboquack avatar Dec 16 '19 12:12 boboquack

You could try digging down into the svg in the inspector (or maybe your browser is not even using svg, which might explain things?). For me, the font family appears on the top svg element as shown below.

Screenshot 2019-12-16 at 16 17 24

(I don't understand the rendering backend particularly well so far; I know there's also a canvas backend. And from reading the code I wouldn't have expected the font family to show up there...)

robx avatar Dec 16 '19 15:12 robx

As far as I can see, editing that particular font-family does nothing whatsoever. Has anyone else confirmed this behaviour on their own machine?

boboquack avatar Dec 17 '19 06:12 boboquack

Chrome 79.0.3945.79 macOS 10.15.2

Changing the font actually toggles between two different serif fonts. This is with the default browser settings.

Edit: pzv.jp does apply the sans-serif font properly.

x-sheep avatar Dec 17 '19 08:12 x-sheep

@x-sheep thanks, that's useful

For me, it works as "expected" with

Chromium 73.0.3675.0 macOS 10.14.6

Still works with

Chromium 81.0.4000.0

robx avatar Dec 17 '19 12:12 robx

I should also point out that the rest of the page is rendered in Times New Roman, which is probably the same font as used in the grid with the sans-serif option.

x-sheep avatar Dec 17 '19 12:12 x-sheep

I found this strange fragment:

                if(pzpr.env.OS.Android){
                        ui.misc.modifyCSS({'body, .btn':{fontFamily:'Verdana, Arial, sans-serif'}});
                }

But that shouldn't affect this, since the trouble is with Windows...

robx avatar Jan 09 '20 13:01 robx

I noticed the same on Windows with Chrome and Firefox: image

On Edge it is working when changing the font family. But on Edge it uses canvas and not svg.

The problem is here:

			initFont: function() {
				var isgothic = this.puzzle.getConfig("font") === 1;
				if (this.puzzle.pzpr.env.OS.Android) {
					this.fontfamily = isgothic
						? "Helvetica, Verdana, Arial, "
						: '"Times New Roman", ';
				} else {
					this.fontfamily = "";
				}
				this.fontfamily += isgothic ? "sans-serif" : "serif";
			},

It will remove the font itself of the CSS style font-family. font-family: "serif"; or font-family: "sans-serif" is then not working.

ropeko avatar Feb 29 '20 11:02 ropeko