ftCLI / FoundryTools-CLI

A collection of command line tools to inspect, manipulate and convert font files
https://ftcli.github.io/FoundryTools-CLI/
MIT License
86 stars 4 forks source link

Weird render effect in IDEA #166

Closed subframe7536 closed 6 months ago

subframe7536 commented 6 months ago

Thanks for your great work!

I'm making a new monospace variable font and instantiate it using: ftcli converter vf2i {input_file} -out {output_ttf}

Everything works well until I encounter a issue https://github.com/subframe7536/maple-font/issues/182. The character spacing will change between different font weights in small font size, and the issue resolved when the font is exported by FontLab.

I need some help to deal with this issue, thanks🙏

ftCLI commented 6 months ago

Can the fonts with the issue be posted here?

subframe7536 commented 6 months ago

sure, just the release file

ftCLI commented 6 months ago

Usint TTF or OTF? Btw, nameIDs 1 and 2 are all wrong:

pasted

NameID 2 should be one of Regular, Italic, Bold, BoldItalic. I'll fix them with ftcli assistant

subframe7536 commented 6 months ago

ttf

Also, thanks for point that out. I have poor knowledge in font tables

ftCLI commented 6 months ago

I have PyCharm and have the same issue for the Thin and ExtraLight cuts,

The issue seems to disappear if I change the usWeightClass as follows:

Thin: 100 -> 250
ExtraLight: 200 -> 275

See images

pasted

pasted

Let me know if it works for you.

More: I have fixed the name table, so keep these files: MapleMono-TTF (fix).zip

subframe7536 commented 6 months ago

More: I have fixed the name table, so keep these files: MapleMono-TTF (fix).zip

I test with Light and Regular, it works well, but the usWeightClass in Light is not changed. How to make it possible?

Can you share your commands to manipulate the fonts?

Btw, I can not find any document on how to show Name Table Viewer😂

ftCLI commented 6 months ago

To show the name table viewer: ftcli print font-names PATH

This is how I patched the fonts:

In the MapleMono-TTF folder, run ftcli assistant ui .

image

Recalculate the values by pressing c and using the default choice (0)

pasted

Look how the weight class changed:

Cattura

Now, press x to exit and run the following:

ftcli assistant commit . -ls 400 700

pasted

Final touch, to delete all names from the Macintosh table except 1, 2, 4, 5 and 6:

ftcli name del-mac-names .

ftCLI commented 6 months ago

Read more about the usWeightClass < 250 issue here:

ftCLI commented 6 months ago

I test with Light and Regular, it works well, but the usWeightClass in Light is not changed. How to make it possible?

Because Light has usWeightClass value = 300, that is greater than 250

subframe7536 commented 6 months ago

Thanks for such detailed guide!

Because Light has usWeightClass value = 300, that is greater than 250

But as for Jetbrains Mono, it renders correctly, even if it has 100 for Thin and 200 for ExtraLight (which I reference from)

~~I finally fix it in my local machine by load and save the variable font 😅 https://github.com/subframe7536/maple-font/commit/f5e5307da7059e8a45bc03bd0a8459aaa5e5775a~~

Wait... still exist when I install Thin and ExtraLight weight

just my fault

ftCLI commented 6 months ago

But as for Jetbrains Mono, it renders correctly, even if it has 100 for Thin and 200 for ExtraLight (which I reference from)

Yes, Light should work well regardless of the weight classes of other cuts. The issue is for styles with usWeightClass lower than 250, so 300 is not affected.

Do you still face the issue? I closed PyCharm, uninstalled the first version, installed the patched files (all the family) and the re-opened PyCharm.

subframe7536 commented 6 months ago

Noop, it is solved by following your guide. Just try to find out the reason.

Moreover, is there any way to process it programmly? the ftcli assistant ui . seems to have no option to run without interaction

ftCLI commented 6 months ago

If the fonts you export from variable have the correct usWeightClass values, you could just run:

ftcli assistant init .
ftcli assistant commit . -ls 400 700

If Thin and ExtraLight are still 100 and 200, it's a bit more complex. The tool is not thought to be command-line only because every designer uses his custom style names (Hairline, UltraLight, ExtraThin) or uses the default names for different weight classes (sometimes Book is 350, other times 450). So fine tuning requires manual intervention.

A command to recalculate values without interaction could be added, but you must be sure that the styles mapping (see ftCLI_files/styles_mapping.json file) is correct. I'll think about it and in case I'll make a release.

subframe7536 commented 6 months ago

I have setup Extralight to 275 and Thin to 200 and try to fix it in https://github.com/subframe7536/maple-font/commit/c5a04b8d2ff64b5fdcea77597ee977066b240cfe, but still have no effect unless manually run the ftcli assistant ui .. I think it may be solve by the recalculation

250&275.zip

ftCLI commented 6 months ago

Fonts have italic bits not properly set, be careful. And still the names are messed.

Try the following (order is important):

ftcli fix italic-angle .
ftcli assistant init .
ftcli assistant commit . -ls 400 700
subframe7536 commented 6 months ago

hmmm... it correctly rendered when fix the name, but the option fails

image fix names.zip

ftCLI commented 6 months ago

That's correct. The fonts are grouped under the same family and you can choose the regular and bold styles under the Typography Settings panel.

Try to install on Windows the files int the 250&275.zip archive you posted before. On Windows 10, I only get 9 styles installed. The other 7 become accessible once I uninstall the others.

A basice principle: NameID 2 can have only the following values: Regular, Italic, Bold, Bold Italic.

Not correct:

NameID1: Maple Mono
NamiID2: ExtraBold

Correct:

NameID1: Maple Mono ExtraBold
NameID2: Regular
NameID16: Maple Mono
NameID17: ExtraBold

This is what the ftcli assistand does: apply the weight/width class values from the CSV file, set the Bold/Italic/Oblique bits and correctly compile the name table.

P.S.: remember to close the IDE every time you uninstall/install fonts.

ftCLI commented 6 months ago

Anyway, what's your process? You convert the variable fonts to static? And then?

EDIT: now I see that the font preview is not showed, sorry for the unrelated comment.

Give me something to start with and I'll check the fonts.

subframe7536 commented 6 months ago

Everything works now😊 I am deeply thankful for your thorough investigation and help in addressing this problem😘

recording

subframe7536 commented 6 months ago

Seems that Regular / Italic / Bold / Bold Italic should remove NameID 16 & 17 https://github.com/subframe7536/maple-font/issues/183

ftCLI commented 5 months ago

Yes, they are not added (or automatically deleted if present) when you use the -ls/--linked-styles option. They were still present?

subframe7536 commented 5 months ago

Oh... Find that I call them before manually setup the name

Everything works well

ftCLI commented 5 months ago

I'd check the uni0259 contour in MapleMono-ExtraLightItalic, seems broken.

More: after the variable to static conversion, I'd add a line to check the contours of the TTFs

run(f"ftcli fix italic-angle {output_ttf}")
run(f"ftcli ttf fix-contours {output_ttf}")
run(f"ftcli assistant init {output_ttf}")
run(f"ftcli assistant commit {output_ttf} -ls 400 700")
shutil.rmtree(path.join(output_ttf, "ftCLI_files"))

This ensures that the contours direction is correct and that overlaps and tiny paths are removed.

A tiny path is present in the 'thorn' glyph of MapleMono-Bold

Before:

pasted

After:

image

subframe7536 commented 5 months ago

Thanks for so much wonderful tools!