fabrizioschiavi / pragmatapro

PragmataPro font is designed to help pros to work better
https://www.fsd.it/shop/fonts/pragmatapro/
1.44k stars 39 forks source link

Stylistic Set with cursive italics (Script) variation ? #270

Closed ArnaudPigne closed 12 months ago

ArnaudPigne commented 1 year ago

First of all, thanks a lot for your incredible work on this font. I was a user of Operator Mono, and… I miss the cursive italics when reading my code with Pragmata Pro mono.

Is it possible that you include a stylistic set that swap cursive italics (Script) instead of standard italics, and leave other font styles as default ? I’m not sure to understand the purpose of stylistic set (and I’m happy to learn), but I think it fits this use case. I use VSCode, and it’s not possible to set a specific stylistic set for some textmate rules in a theme.

Or maybe stylistic set is not the answer and I must do it in another way and/or by myself ?

fabrizioschiavi commented 1 year ago

I tried to add this code to settings.json in VS Code "editor.fontFeatures": {"ss06": 1} but it doesn't work as it should.

It seems configurator is the only possible solution. @svipas can you help me?

mfocko commented 1 year ago

@fabrizioschiavi I think you could try

"editor.fontLigatures": "'ss06'",

or

"editor.fontLigatures": "'ss06' on",

Though I'm not sure about the last one

fabrizioschiavi commented 1 year ago

It works! Great @mfocko ! Thanks! How is possible to say to VS Code "do it only for Italics"?

mfocko commented 1 year ago

I don't think you can do that without patching the style itself, there used to be some tricks for “removing” the italics by using the tokens of the grammar to remove the italics, I think it could be used in the same way to change the font features, but it's rather tedious and not guaranteed to work.

Something like this: https://gist.github.com/pauldan/f3dbb3e33ee00acc36ad28c9e1de1bf9

IIRC the override is CSS, so that's where the fontFeatures come in(?)?

ArnaudPigne commented 1 year ago

But you cannot set an ss06 through fontStyle, according to (https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#:~:text=The%20value%20describes,in%20tokenColors.). There is no such font-feature-settings.

svipas commented 1 year ago

You can use https://github.com/twardoch/fonttools-opentype-feature-freezer and apply ss06 or ss09 only for italic fonts and then regular will be without applied otf features, but italic will be since it allows to apply to each font style (Bold, Italic, Bold Italic, Regular, etc.).

fabrizioschiavi commented 1 year ago

Thank you very much @svipas for sharing this amazing tool!! This is can be the solution we waiting for, so far! 🙌

ArnaudPigne commented 12 months ago

I can confirm that the tool mentionned by @svipas has solved my problem. Thanks for your advice.

PragmataPro Mono Liga Script (Italics → Script)

pyftfeatfreeze -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Script' PragmataPro_Mono_R_liga_0829.otf PragmataPro_Mono_R_liga_0829_Script.otf &&
pyftfeatfreeze -f 'ss06' -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Script' PragmataPro_Mono_I_liga_0829.otf PragmataPro_Mono_I_liga_0829_Script.otf &&
pyftfeatfreeze -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Script' PragmataPro_Mono_B_liga_0829.otf PragmataPro_Mono_B_liga_0829_Script.otf &&
pyftfeatfreeze -f 'ss07' -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Script' PragmataPro_Mono_Z_liga_0829.otf PragmataPro_Mono_Z_liga_0829_Script.otf

PragmataPro Mono Liga Serif (Italics & Bolds → Serif)

pyftfeatfreeze -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Serif' PragmataPro_Mono_R_liga_0829.otf PragmataPro_Mono_R_liga_0829_Serif.otf &&
pyftfeatfreeze -f 'ss09' -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Serif' PragmataPro_Mono_I_liga_0829.otf PragmataPro_Mono_I_liga_0829_Serif.otf &&
pyftfeatfreeze -f 'ss08' -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Serif' PragmataPro_Mono_B_liga_0829.otf PragmataPro_Mono_B_liga_0829_Serif.otf &&
pyftfeatfreeze -f 'ss10' -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Serif' PragmataPro_Mono_Z_liga_0829.otf PragmataPro_Mono_Z_liga_0829_Serif.otf

PragmataPro Mono Liga Fraktur (Italics → Fraktur)

pyftfeatfreeze -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Fraktur' PragmataPro_Mono_R_liga_0829.otf PragmataPro_Mono_R_liga_0829_Fraktur.otf &&
pyftfeatfreeze -f 'ss03' -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Fraktur' PragmataPro_Mono_I_liga_0829.otf PragmataPro_Mono_I_liga_0829_Fraktur.otf &&
pyftfeatfreeze -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Fraktur' PragmataPro_Mono_B_liga_0829.otf PragmataPro_Mono_B_liga_0829_Fraktur.otf &&
pyftfeatfreeze -f 'ss04' -R 'PragmataPro Mono Liga/PragmataPro Mono Liga Fraktur' PragmataPro_Mono_Z_liga_0829.otf PragmataPro_Mono_Z_liga_0829_Fraktur.otf
talios commented 12 months ago
"editor.fontLigatures": "'ss06'",

It looks like that was implemented long ago back in 2019: https://github.com/microsoft/vscode/issues/80577

svipas commented 12 months ago

@talios Yes, but it applies globally, you can't use it only for Italics, that's why you need a tool which will freeze OTF features in the font file itself.

svipas commented 11 months ago

I prepared a simple script for macOS (but you can adapt it to any OS quite easily) if somebody wants to use it instead of OTFeatureFreezer GUI. First you need to download PragmataPro from www.fsd.it and extract it. Open your terminal and go to the place with cd where .ttf fonts of PragmataPro are. And, run this script below:

#!/usr/bin/env bash

# Install - python and pipx
brew install python pipx &> /dev/null
pipx ensurepath &> /dev/null

# Download - OpenType Feature Freezer (https://github.com/twardoch/fonttools-opentype-feature-freezer)
pipx install opentype-feature-freezer &> /dev/null

# Build - Italic stylistic alternates
pyftfeatfreeze -f 'ss09' PragmataProI_liga_0829.ttf PragmataProI_liga_0829_script.ttf
pyftfeatfreeze -f 'ss09' PragmataPro_Mono_I_liga_0829.ttf PragmataPro_Mono_I_liga_0829_script.ttf
echo "Italic stylistic alternates have been built"

# Build - Bold Italic stylistic alternates
pyftfeatfreeze -f 'ss10' PragmataProZ_liga_0829.ttf PragmataProZ_liga_0829_script.ttf
pyftfeatfreeze -f 'ss10' PragmataPro_Mono_Z_liga_0829.ttf PragmataPro_Mono_Z_liga_0829_script.ttf
echo "Bold Italic stylistic alternates have been built"

After it's done you will find new .ttf files which will end with _script.ttf. Install them and you're good to go. Remember to kill and relaunch your IDE or Terminal so it recognizes new font files.

fabrizioschiavi commented 11 months ago

@svipas 👏