LingDong- / qiji-font

齊伋體 - typeface from Ming Dynasty woodblock printed books
https://qiji-font.netlify.com/
SIL Open Font License 1.1
1.32k stars 71 forks source link

Improve site #4

Closed antfu closed 4 years ago

antfu commented 4 years ago

Changes

The built index.html is not included in this PR.

LingDong- commented 4 years ago

@antfu Nice, thanks!

The font loading thing gave me such a big headache, glad you improved it.

One thing though, I disabled scrolling for the render, because it makes the punctuation marks (、。) invisible. (punctuation simply disappears when overflow is not hidden) I think it is a layout engine bug, but this seems to be the case on Safari, Chrome and FF. Did this happen for you, or did you somehow fixed this issue?

antfu commented 4 years ago

did you somehow fixed this issue?

Yes I think I fixed it (at least on my Chrome)

BTW, since we are already using Netlify to do the build, should we exclude the site folder and make Netlify run the make_site.js automatically? So that contributors don't accidentally commit the built html and in PRs we can see the previews too. Would love to update the PR.

(and do you mind me to introduce the package.json? XP

LingDong- commented 4 years ago

Should we exclude the site folder and make Netlify run the make_site.js automatically

That's probably the right way. I didn't know what I was thinking :P

and do you mind me to introduce the package.json

Sure! We'll need it sooner or later. I didn't add it because it happens that I don't need any library yet, but feel free to add it. For python, we can also add requirements.txt, I can work on that.

Thanks!

antfu commented 4 years ago

Netlify run the make_site.js automatically

Script updated, you can change Netlify build config after this gets merged.

S-20200208-20,46-001

Changes

I have setup Netlify on my fork, here is the demo: https://webfontloader--heuristic-lamport-e72dda.netlify.com/

LingDong- commented 4 years ago

Thanks for the improvements,

I switched to the new workflow, and it seems to be working, but

image

antfu commented 4 years ago

Is there a way to force netlify to rebuild? When I change the build settings on netlify it doesn't trigger rebuild (wtf), and I have to push some dummy changes to trigger it.

As far as I know, no. I just push a new commit for that too 😂

Vanishing punctuation bug seem to still exist.

Would that exists on Chrome too? My macbook is on the way but due to the virus situation I think I gonna wait for a while longer :|

LingDong- commented 4 years ago

Would that exists on Chrome too?

Yeah... the above screenshot is Chrome actually. I guess we have to get scrolling working eventually, if we are to display the wenyan book with the font. Since you can't reproduce, let me look into it!

gonna wait for a while longer

No hurry, be safe :)

LingDong- commented 4 years ago

Vanishing punctuation is fixed: 65fb45358a9071959bc39fd6639aa8fe4d2672b0

The cause is that the height of the punctuation spans are 0 (as they should be). Theoretically they should still display since overflow is not hidden. And it works correctly when there is no scrolling. But somehow when combined with the scrolling it screws up the browsers mind.

The hack is to make the height 0.01.

LingDong- commented 4 years ago

Hi @antfu,

I thought I could add a nice little loading animation while the font is loading:

qiji007

Only problem is that WebFont.load is blocking render, so the loading animation does not play until the font is loaded :P

Just wondering if you know more about web fonts more than me... But otherwise I can look into it. Worst case perhaps is to show a GIF...

See

/workflow/make_site_w_loader.js
/workflow/loading_anim.js

Thanks!

EDIT: Solved by using GIF, 3fa1dde34647f6cbfa97a3fa7c2fc6237df92a63. There is still a stutter in the animation the moment the text is drawn. But at least better than not rendering at all until the font is loaded. sigh.

antfu commented 4 years ago

@LingDong- The animation looks fantastic!

Only problem is that WebFont.load is blocking render

I don't think it will block rendering. I will try some experiments fist :)

EDIT: I can't get canvas installed on my Windows(wtf). Will do it later