Born2Root / Fast-Font

This font provides faster reading through facilitating the reading process by guiding the eyes through text with artificial fixation points.
https://born2root.github.io/Fast-Font/
MIT License
209 stars 16 forks source link

Font seems to load, but is not adding any boldness in browser, terminal, but does on abiword #18

Closed khlsvr closed 2 weeks ago

khlsvr commented 2 weeks ago

Hi.

I wonder what my problem is. I installed all the 3 fonts to my Arch Linux through ~/.local/share/fonts/ dir and they show up in fc-list. I can also load them in qutebrowser or firefox, and I can see a difference to the font I have before loading them at least on qb. However, they just change the outlook, but do not add boldness to the characters at the begin of words. Same goes for kitty terminal when I try run kitty with kitty --override font_family='Fast_Sans' I don't see any boldness. In fact, on kitty the font may not change at all. Tried with the dotted font and no dots are added. I am succesfully loading my custom conhanzi font on qutebrowser and it also has a lot of ligature substitutions going on, so there should be ligature support there. Also kitty supports ligatures and I can load conhanzi with the override flag succesfully there.

Then running abiword and picking the Fast_Sans from the font menu I can see it working properly bolding first chars on each words so the font files themselves should be alright I guess

edit: I might have figured this out. In firefox if I pick one of the fonts as the "monospace" font, then it works there properly. Maybe it has to do with needing a monospace variation and I just need to find out how I can force one of these to be forced as monospace on terminal and qutebrowser. However it doesn't explain why on qb I can see the font appearance changing when I switch :thinking:

edit2: Kitty doesn't support non-monospaced fonts, so I guess I would need to create a monospaced variation of the font using your python script or something else I guess

khlsvr commented 2 weeks ago

Hey would it be possible for you or someone on windows computer to create a fast font from some Monospace font to add compatibility? For example DejaVu Sano Mono? https://dejavu-fonts.github.io/

I'm on linux and Fontlab is only available onWindows and Mac. I have FontForge installed and I'm already struggling at the first step adding a suffix to each character in a font.

That python script that is mentioned on the "apply to other fonts" part though.. For example, using the addfeatures.py script. https://github.com/simoncozens/test-fonts/blob/master/addfeatures.py That looks like a simple script and Chatgpt had a plan how to use it once I first got the bold glyphs copied to the regular font file.

I then tried to keep on getting the glyphs copied. Chatgpt gave me instructions on copying them with fontforge, but the options were not there or they were grayed out. Then Chatgpt tried instructing me to do it with a python script using fonttools, but after 30+ minutes with trial and error, we couldn't get them copied. I also tried asking Gemini. So apparently this is a too difficult thing for a LLM chatbot for now at least

khlsvr commented 2 weeks ago

Just an update where I have got so far.

Using Fontforge I got so far (hopefully right way) that I added new encoding slots to regular font file, then pasted these bold glyphs from bold font file to the new empty slots in regular font file. Then manually.. sigh.. renamed all of them to a.bold A.bold b.bold B.bold etc. At this point I guess I have the font file with regular and both in one.

If you need to import just a .fea file use the File menu where you must choose Merge Feature Info (File > Merge Feature Info). In this case you will be in position to import .fea files.

So next I saved the simplified snippet with just A-Z to a .fea file and tried loading it with above mentioned method. Got no output which I guess was a good sign. I then went to Element > Font Info > Lookups and I can see there are many calt lookups there including bold characters in the mix, so I guess it did the trick. After this I go generate the font, but I am getting some intersection errors or such but an option to generate the font anyway. I generate it and then try load it, but this time it doesn't show bold chars not even in Abiword, so something went wrong somewhere.

khlsvr commented 2 weeks ago

Okay this shall (I hope) be the last message I spam in this thread since I now managed to create a monospace font out of the dejavu sans mono, and it succesfully loads in Kitty terminal now.

What I did was after I had manually created those .bold variants and copied them to the regular, I then instead just tried using your python script addfeatures.py and surprisingly it works now. I'll close this thread as solved.

edit: Streamlined the process a bit and made couple more fonts:

Steps for monospaced fonts especially and in this example I have added äÄöÖ in addition to a-z and A-Z:

Contents of the create_empty_bold_placeholder_slots:

Click to expand/collapse code ``` import fontforge # Load your font font = fontforge.open("IBMPlexMono-ExtraLight.ttf") # Set the monospace width based on an existing glyph (e.g., "A") monospace_width = font["A"].width # Define characters for lowercase, uppercase, and Finnish characters lower_chars = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "adieresis", "odieresis"] upper_chars = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Adieresis", "Odieresis"] # Create .bold placeholders for lowercase characters for char in lower_chars: bold_name = char + ".bold" glyph = font.createChar(-1, bold_name) glyph.width = monospace_width # Apply the monospace width (600) # Create .bold placeholders for uppercase characters for char in upper_chars: bold_name = char + ".bold" glyph = font.createChar(-1, bold_name) glyph.width = monospace_width # Apply the monospace width (600) # Save the modified font font.save("work.ttf") ```

Contents of the fin.fea:

Click to expand/collapse code ``` feature calt { @fi = [adieresis odieresis Adieresis Odieresis]; @FI = [adieresis.bold odieresis.bold Adieresis.bold Odieresis.bold]; @az = [a-z A-Z @fi]; @AZ = [a.bold-z.bold A.bold-Z.bold @FI]; @all = [@az @AZ @fi @FI]; #17 ignore sub @all @all @all @all @all @all @all @az' @all @all @all @all @all @all @all @all @all @all; sub @all @all @all @all @all @all @az' @all @all @all @all @all @all @all @all @all @all by @AZ; #14,15,16 ignore sub @all @all @all @all @all @all @az' @all @all @all @all @all @all @all @all; sub @all @all @all @all @all @az' @all @all @all @all @all @all @all @all by @AZ; #12,13 ignore sub @all @all @all @all @all @az' @all @all @all @all @all @all; sub @all @all @all @all @az' @all @all @all @all @all @all @all by @AZ; #9,10,11 #ignore sub @all @all @all @all @az' @all @all @all @all @all @all; ignore sub @all @all @all @all @az' @all @all @all @all @all; sub @all @all @all @az' @all @all @all @all @all by @AZ; #7,8 ignore sub @all @all @all @az' @all @all @all @all; sub @all @all @az' @all @all @all @all by @AZ; #4,5,6 #ignore sub @all @all @az' @all @all @all; ignore sub @all @all @az' @all @all; sub @all @az' @all @all by @AZ; #1,2,3 ignore sub @all @az'; sub @az' by @AZ; } calt; ```

Contents of the addfeatures.py is untouched and is one provided in this repo.