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

Some ideas #2

Closed antfu closed 4 years ago

antfu commented 4 years ago

Wow! I didn't expect to see it get such a high level of completeness and I am very surprised how wide range it already covered. Great job! πŸ‘

I haven't got the build tools ready and run by myself (I am having poor network recently, will definitely try later). Here are some quick thoughts/ideas about this with my superficial view.

  1. Maybe it's better to attach the compiled font file to releases instead of source control. I think it's indeed easier and straightforward for people to find the font on early-stage, but since the Chinese font is huge (14MB currently). It's not very ideal to keep it in the source control. image

  2. The font name is not specified. (Untitled1 currently)

  3. Consider compile to different font formats (ttf, otf, woff, woff2, etc) by using fontmake. woff is optimized for the web with smaller file sizes which is useful for web display. Here is the build script of FiraCode for reference.

The characters selecting things look very interesting too! Would play with it and make some feedback when I finished the toolings.

LingDong- commented 4 years ago

Thanks for the feedback!

The font name is not specified

Hmmm... I did set it to QIJI in fontforge (workflow/forge_font.py) and it shows up correctly on Font Book (mac's built-in font manager). Which software you're using shows it as Untitled1?

ttf, otf, woff, woff2, etc

Definitely going to build them! Currently I'm remaking the ttf all the time for fixing/testing, so I don't want to complicate it by building all the other formats. I believe fontforge which I'm using to generate TTF is also capable of writing other formats. But thanks for the resources! Glad to know more ways.

Maybe it's better to attach the compiled font file to releases instead of source control

Yeah you're right, I'm just being lazy :P

Would play with it and make some feedback when I finished the toolings.

(Supposing you haven't got your new macbook yet), I'm using mac's built-in Automator to generate images of pages from PDF (workflow/split_pdf.workflow). If you have to use a different software to split the pages, the naming and the output dimension may be different, potentially breaking all other scripts. Let me know which one of the following do you prefer:

Anyways, take your time, and thanks a lot for your feed back :D

antfu commented 4 years ago

Which software you're using shows it as Untitled1?

The built-in font view of Windows. image

And as I am trying to install it: image

This may because Windows uses different filed for font name than Mac

Wait till you get a Mac

Yeah, actually I am done with Python on Windows, it's really a mess XD. Please wait :)

I upload everything as a zip to a cloud service (Google Drive, Dropbox, Baidu Yun, ...) of your choice. Maybe this will be most convenient, since you won't need to build from scratch all the other stuff (Some process are actually slow).

I think it's better to provide those files to help people better contribute to this project eventually. But do it when you feel good about it, no hurry.

antfu commented 4 years ago

Update: Windows seem to read the Title props of the file image

~I am not familiar with fontforge thing, but I can dig into later.~ Have read the doc a little, wonder if this changes will fix that

https://github.com/LingDong-/qiji-font/blob/4f6e4926ab0cca3949c8444a9386328560df9efa/workflow/forge_font.py#L18-L20

  font = fontforge.font()
  font.familyname = "QIJI"
+ font.fontname = "QIJI"
+ font.fullname= "QIJI"
LingDong- commented 4 years ago

Thanks for looking into this! Font name should be fixed in these commits: efacd12fdd20062f3394ef8df72933982d127cc2 8a7bae699eb32a5883ba14a1f1b8557745aeb76d

I also noticed the "Copyright (c) 2020, admin" in your screenshot, seems like it is automatically inferred from my laptop username, so fixed that too :)

antfu commented 4 years ago

Cool, It works now :)

antfu commented 4 years ago

attach the compiled font file to releases instead of source control

As I am trying clone it to my local machine, it now takes about 88MB to download.(and sry I have really poor network, ~250kb/s πŸ˜‚). It's not a big deal right now, but I think it's better to do it earlier.

If you are ok with it, I can peel off the QIJI.ttf from the git history and make a script that make Github release automaticly. The site/qiji.ttf and be automaticly copied as well.

LingDong- commented 4 years ago

That would be great, thanks a lot!

However the font is generated from SVG's (50MB), which are generated from BMP's(1GB), which are generated from high-res scans (15GB). Wondering if it is still possible to have Github release automatically? Otherwise I guess manual isn't too bad.

The large size is also likely because at one point I accidentally pushed a fallback font (called QIJIFALLBACK.ttf, which is 55MB) to the repo, so if you can peel that off too that would be awesome. BTW, I'm generating the fallback font by adding distortion and noise to a regular font (SourceHan), still experimenting with that.

image

In image above, 嗑睽η₯ζ–² are from the fallback font. Perhaps they can be slightly thicker and bigger, but I think they blend in kinda well :)

antfu commented 4 years ago

the font is generated from SVG's (50MB), which are generated from BMP's(1GB), which are generated from high-res scans (15GB).

That was crazy πŸ˜‚ Hope I will get enough disk space for that.

Wondering if it is still possible to have Github release automatically?

Definitely NO haha. But what I mean is something like bash publish.sh that create Github Release and uploads font files to it automatilcly (or semi-auto XD) making life a little bit easier. What do you think?

In image above, 嗑睽η₯ζ–² are from the fallback font.

It's hard to identify which are fallback without telling. Good job. The dimension is kinda wired (look more rectanglar than square). but I believe you already spot that too.

BTW, I am working on the site for this to see if I can make the font loading experience better, will make PR later :)

antfu commented 4 years ago

I used fontforge to convert ttf to woff2, I was really surprised about how much the size reduced (14MB -> 4.8MB) and maybe it can be optimized even more from the source.

S-20200207-16,04-001

LingDong- commented 4 years ago

bash publish.sh

Sounds great!

look more rectanglar than square

The real font is actually also taller than they are wide, but I guess I overdid it, will dial back a little.

make the font loading experience better

Thanks for the PR!

14MB -> 4.8MB

Amazing :D

LingDong- commented 4 years ago

@antfu , how did you manage to get woff2 so small? 'cause this is what I'm getting XD:

image

My code:

import fontforge
font = fontforge.open("../qiji.ttf")
font.generate("../qiji.woff2")
antfu commented 4 years ago

@LingDong- I am using the FontForge GUI, I just simpliy open the ttf file and output as woff2. That's it. Not sure how to work with python, maybe there are some options for compressing or optimizing?

antfu commented 4 years ago

peel off the QIJI.ttf from the git history

This will rewrite the git history, so I want to make sure you have your unsaved works committed and pushed. Let me know when you are ok with it, after I finished(it would not take long), I will share you some simple commands to pull the changes. :)

LingDong- commented 4 years ago

I've made a backup, feel free to do the git surgery, thanks :)

antfu commented 4 years ago

@LingDong- The process is finished :) You can either reclone it or run the following command to pull

git fetch --all
git reset --hard origin/master
git pull origin master

I have removed QIJI.ttf, qiji-fallback.ttf, site, __pycache__ from the history

LingDong- commented 4 years ago

Cool, I ran the commands and it seems to be working fine. Thanks a lot for doing this!

antfu commented 4 years ago

I am using the FontForge GUI

Tried out some online converters, found out the similar result https://cloudconvert.com/ttf-to-woff2

Source: Qiji.ttf 14.1MB
woff 7.32MB
woff2 4.78MB
otf 50MB (wtf?)

If we can not make fontforge optimize it, maybe we can use some other font tools to do the convertion in sh scripts? (have to say docs for fontfoge python is really... not too friendly)

LingDong- commented 4 years ago

Yeah FontForge python's documentation is non-existent XD. I basically go dir(fontforge) and then dir(fontforge.font()) to see what it has to offer...

https://fontforge.org/en-US/documentation/scripting/python/ here is an inaccurate and outdated doc which I also use as reference.

I'm switching to this tool for conversion:

https://www.npmjs.com/package/ttf2woff2

Commit: af5a229ad30f8a7b57e8b7b170f97ae36594206f

Result: QIJI.woff2 is 5.2MB, so I guess that's acceptable(?)

ttf2woff2 has a CLI, wondering if installing it globally and use it in a shell script is better, thus avoiding cluttering package.json.

antfu commented 4 years ago

Oh, I didn't expect the solution to be that simple - just a js package!

I guess 5.2MB is already a big optimization compare to 14.1MB for now. We can try to find ways to squeeze its size (maybe gzip or svg optimizing), but I think let's for later.

if installing it globally and use it in a shell script is better

I was trying to say maybe npx ttf2woff2 but I just quick peeked its document, not sure if npx works with bash pipeline (it does not support argv parsing)

Can you upload the woff2s to the release(no need to create a new one I think) so that I can help to switch to woff2 for site?

LingDong- commented 4 years ago

I added qiji.woff2 to the release. qiji-combo.woff2 is taking forever to generate, not sure why. Every tool has to break in its particular fashion πŸ€¦β€β™‚οΈ

EDIT: all three woffs are uploaded to the release.

lapomme commented 4 years ago

For many characters, the Korean version of Source Han Serif would be more suitable for the fallback since it uses θˆŠε­—ε½’. Also, I think GenWan would work nicely. E.g. η₯ from left to right: Source Han Serif SC, Source Han Serif K, GenWan. image

LingDong- commented 4 years ago

@lapomme , Good call, Thanks a lot!

Now the fallback font and the combined font are generated with the Korean version SouceHanSerifK-SemiBold, and are published on the Releases page.

P.S. GenWan looks nice, but I think since we're adding a lot more distortion & weight variations to the glyphs, the subtle variation from GenWan might not be very visible. But nevertheless I might give it a try later.