juanitogan / mkwinfont

Update to Simon Tatham's font utilities for working with Windows FNT and FON font files.
http://www.chiark.greenend.org.uk/~sgtatham/fonts/
21 stars 5 forks source link

Need help with *.FON font file #1

Open MikhailGolovin1982 opened 3 years ago

MikhailGolovin1982 commented 3 years ago

Hello! Thanks a lot for the information about .FON files. I work in Siemens NX CAM system, and we need .FON single line font for text graving By some reasons, we want to make our own *.FON font.

I tried to use your phyton-scripts for it. With yours files they work good. I checked several fonts in Windows by using your phyton-scripts. For example, this one GOST_A.zip

Unfortunately, script result is error with message, that it a vector font. So, *.fon file font can be based not only in bitmap image, but it can be a vector to???

Can you help me, please. How to edit such vector *.FON files for my aims?

juanitogan commented 3 years ago

Ah, yes, the old "plotter" fonts from the Windows 1 to 3 era. Yes, they can also be contained in FON files... but the tools here are only for bitmap fonts and not vector fonts. I just updated the readme here to help make this a bit more clear.

30 years ago I could have maybe told you what tools to use (other than Microsoft developer tools). I made a vector font once for max speed, but it was all in code. Anyhow, I looked it up and this site looks helpful:

http://imajeenyus.com/computer/20150110_single_line_fonts/index.shtml

I see you found the FontForge discussion on this. It's too bad that tool can't do it yet.

juanitogan commented 3 years ago

Unfortunately, that site doesn't appear to contain anything on how to make the old vector FNT files that can then be compiled into FON files. There's not much intel on that on the net. Thus, it looks like you need a Windows SDK from the Windows 1 to 3 era that includes Microsoft's "Font Editor" and then run that on an old Windows install. I have an old SDK but it's buried too deep to check right now to see if it support vector as well as raster.

juanitogan commented 3 years ago

Found the old SDKs here:

https://winworldpc.com/product/windows-sdk-ddk/windows-30

But, Font Editor doesn't do vector. It did seem too much to expect from an SDK tool. To quote the help file from 3.1: "You can use Font Editor to create and edit only raster fonts."

To quote the manual from 2.0: "Font Editor can be used only to create and edit raster fonts. Vector font files are created as described in the Microsoft Windows Pro­grammer's Reference." And, when you check that, you just get a description of the FNT file format. In other words, programmer needed... and ingenuity for converting vector data from your favorite vector tool to the structure FNT requires.

MikhailGolovin1982 commented 3 years ago

Thank you! I found this description: https://www.metagraphics.com/metawindow/fonts/fnt-specs.htm Is it correct?

So, if this description correct and if we even could create vector FNT file with single line font what we need. After that we should convert it to FON. But it will be the same question - How to do it?)

May be you know alternative font format files in Windows with single lines (stroke font).

juanitogan commented 3 years ago

No, that looks like another FNT file type. Not the Windows one. Someone mentioned that Windows FNT files are nearly identical to Hershey files. The spec is in the Windows Programmer's Ref, which can be found in the Win 3.1 SDK help files if not on the web somewhere. Originally, FNTs were packaged into a FON with the MASM assembler. But, fnt2fon tools exist to shortcut that (like what was being talked about on that FontForge discussion you posted on). Even the mkwinfont tool here does a similar shortcut and could be adapted to vector FNTs. FON is really just a container for one or more FNTs.

I'm not going into detail because it is sounding like you should ignore all of that. Unless you are working with an engraver that is 30 years old, and can only engrave text, and can only read FON files, you are looking at this from the wrong direction.

You should instead be looking at the specs of the engraver and what kind of data it can read to make a cut. HPGL, DXF, PS, PDF, SVG, what? Why does it need to be a Windows native format? If you are building Windows software, a programmer can grab a library to read any standard format. If you are building embedded software, you probably don't want any file type and the just want the vector data converted into code. The links you have found already lead to the Hershey data converted to SVG, C, Java, and whatever. When I wrote my single-line font, it was just Visual Basic data I keyed in from graph paper that I would then output to HPGL or screen draw commands. Making a new font for code would still be much like that, except I would probably use Inkscape as my graph paper, and then scrub the data from the SVG.

So, it's really about what tool you need to use (or build) to produce your engraving data. And, then, finding all the ways you can produce single-line characters in that tool. That's what that link I shared is all about. It showed solutions for Inkscape, Rhino, and others. It mentions that some people have put single-line data in TTFs, even though that's not what TTFs are for. But, if a tool can work with it regardless, fine.

The latest solution appears to be SVG fonts (https://www.w3.org/TR/SVG11/fonts.html). All the Hershey fonts have been converted to SVG fonts and can be found in the latest Inkscape and its Hershey Text plugin (or here: https://wiki.evilmadscientist.com/Hershey). Inkscape also has tools for building new SVG fonts (single-line or outline is up to you in SVG). Adobe Illustrator and CorelDRAW may have similar tools. FontForge can build SVG fonts but it doesn't really know how to preview single-line data, and you probably need to build with all the warnings turned off. Other font foundry tools may do better... or not.

SVG data can also be embedded in OpenType (OTF) files. So, that's another possible modern solution. It's really just up to you and your specs. FNT/FON is just one of many containers... and limited to just straight lines... no Bezier's, for example, if your equipment can handle such curves.