ryukau / VSTPlugins

Uhhyou Plugins VST 3 repository.

Home Page:https://ryukau.github.io/VSTPlugins/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use custom fonts.

KottV opened this issue · comments

Hi!

I see that the font handling has been changed 2e16d68 2a5563e

I'm trying to figure out how to pass the custom font to the config, fontPath is not working anymore.
So, Is it necessary to put .ttf in the plugin's Resource folder or it's possible to load a system font?

Hi.

I couldn't come up with a nice way to implement font style setting into style.json. So you have to change some code for now.

To use custom font, change default value of _fontName in common/gui/style.hpp to the target font family name. Below is the link to code.

VSTGUI::UTF8String _fontName{"Tinos"};

Next is to change the font style at fontFace in common/gui/plugeditor.hpp. Note that VSTGUI only provides options for bold and italic. I'm not sure if styles like "demi light" weight can be used.

static constexpr int fontFace = CTxtFace::kBoldFace | CTxtFace::kItalicFace;

After building plugins with above change, place the *.ttf font file into *.vst3\Contents\Resources\Fonts\some.ttf".

Yeah, it's a bit tricky. Thanks, I'll take a look!

As there is no way to substitute a font in the config (as far as we know), Is it possible to embed additional font styles and put a choice into style.json
I mean:
fontName : "Tinos" (default italic)
fontName : "Roboto" (default bold)

Or just use one font with selectable style?

I'm not sure if I understand the idea correctly, but I guess you are talking about adding multiple preset fonts. I'm against it because it increases the size of packages.

That said, adding font style options for style.json is possible as following.

{
  "fontName": "Tinos",
  "fontBold": true,
  "fontItalic": true
}

A downside is that a user has to know what combination of font style is valid. For example, if Tinos-BoldItalic.ttf is the only font placed into custom font path, and if any of fontBold and fontItalic are set to false, then plugin fails to load custom font.

If this is OK to you, I can start working on it in near future.


Off topic but I'll put some additional information. Current implementation uses one style of one font for everything. In other words, it's not possible to use bold for plugin name and regular for parameter labels, for example. Font sizes are also fixed. Changing this requires extensive refactoring and I will not work on this in near future.

My point is to be just able to have a bold or regular font, not (bold) italic only.
If it's done with one font family - it's ok.

I'm against it because it increases the size of packages.

I understand that .ttf files are big. FTOH packaged plugins (for openSUSE for example) uses symlinks, so it's just one copy of font file in whole package:

find /usr/lib64/vst3/ -name Tinos-BoldItalic.ttf -exec ls -l '{}' \;
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/MatrixShifter.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/L4Reverb.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/FDNCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/EsPhaser.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/OddPowShaper.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/ModuloShaper.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/SyncSawSynth.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/FoldShaper.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
-rw-r--r-- 1 root root 436248 мая 22 23:31 /usr/lib64/vst3/WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/FDN64Reverb.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/LightPadSynth.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/CollidingCombSynth.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/L3Reverb.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/EnvelopedSine.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/TrapezoidSynth.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/IterativeSinCluster.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/SevenDelay.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/CubicPadSynth.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/SoftClipper.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/LatticeReverb.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf
lrwxrwxrwx 1 root root 73 мая 22 23:31 /usr/lib64/vst3/BasicLimiter.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf -> ../../../../WaveCymbal.vst3/Contents/Resources/Fonts/Tinos-BoldItalic.ttf

A downside is that a user has to know what combination of font style is valid. For example, if Tinos-BoldItalic.ttf is the only font placed into custom font path, and if any of fontBold and fontItalic are set to false, then plugin fails to load custom font.

It can be noticed in the readme

Thanks for clarification. I'll work on the config options in previous comment.

Added font config options for style.json in customfont branch.

Example style.json is below. Note that it's using "fontFamily" instead of "fontName".

{
  "fontFamily": "Knewave",
  "fontBold": false,
  "fontItalic": false
}

It's working on Windows. Could you confirm it works on Linux (OpenSUSE)? For credit, font in the image below is Knewave-Regular.ttf.

キャプチャ

That's it.

"fontFamily": "Roboto",
  "fontBold": true,
  "fontItalic": false,

изображение

Thank You very-very much.

Thank you for testing, and I'm glad it worked!

I'll close this issue. If there's something left, feel free to add a comment or open another issue.