Does Fontlab script have auto-import color svg files into assigned unicode slots???

WAY KYI
WAY KYI Posts: 130
edited August 2022 in Technique and Theory
I am just trying to check Fontlab for color svg files into assigned unicode slots??? I mean to automate the process of importing svg files. Is that easy to do in Fontlab???

Is Fontlab support python and also has internal scripting??? Where can I find more info on implementing the task above for newbee like me???

Just downloaded the app and playing around for creating color/variable font to see the learning curve for me. Any help and direction is very much appreciated. Thanks

Tagged:

Comments

  • Thomas Phinney
    Thomas Phinney Posts: 2,896
    edited August 2022
    FontLab can do OCR after import. You can import to the Sketchboard, and then divide it up. No reason that should care whether you import a single file (as I have done and seen demonstrated) or a bunch of separate files.

    FontLab supports Python, for internal scripting. Are you also asking if FontLab can be driven externally from the command line via Python? Not sure about that.
  • WAY KYI
    WAY KYI Posts: 130
    edited August 2022
    Thank you very much Mr. Thomas Phinney I did tried built-in OCR of Fontlab as per your suggestion and it does only recognize Latin text. Other text from Script/languages are put into Fontlab as .elm1, .elm2 etc. So, they are put in all over the places randomly. What I want is Fontlab be smart enough to place unrecognized elements starting from selected Unicode slot and continue to the end or simple dialogbox popup to ask the option of starting Unicode number ( no need OCR here ) or Use OCR. Or some kind of Python script to import each SVG file into assigned places. Fontforge has done better in this by using python/internal scripting but FF does not support Color SVGs. So, I am looking for the same import option here. Thanks
  • Ah, good point. Actually FontLab can do OCR to recognize Cyrillic as well, but nothing else as far as I know.

    No reason you can’t script it if you have a bunch of external files each with an SVG of a character. In fact, this is something Vassil Kateliev did for our work on Google Symbols / Material Symbols. Too bad it is part of a generally proprietary toolset for that project, else I would happily share the code.

    Also, if you drag-and-drop an SVG file into the font window in FontLab, but into empty space rather than a specific slot, it will create a new glyph with the name of the SVG file, leaving off the “.svg” extension.
  • Another tip: If you use standard glyph naming, you can then ask FontLab to encode all glyphs by going to Font > Generate Unicodes
  • WAY KYI
    WAY KYI Posts: 130
    edited August 2022
    Thanks again Mr. Thomas Phinney. I tried with your suggestion and it worked but not the way user would expected. I added PUA slots in the font then selected a bunch of svg files and dropped into the empty PUA slot. They all went to which ever spot that FL decided to and stacked up each other. More works for me. See image here, I moved it one by one. Look like OCR is playing me again here, instead of place them into separate slots. This happened with one or a bunch of svg files or PUA or empty slot. Doesn't matter, FL is in-charge here, FL way or no way. I am afraid that if svg file is resempled to one of the Latin glyphs, it could possibly replaced it there. It could messed up the glyph there in big time.
  • WAY KYI
    WAY KYI Posts: 130
    edited August 2022
    At least FL imported all svg files you pasted into - which is good. So the script could handle them very well. Do you have any sample or documentation for FL scripting?? Hopefully, script could avoid/skip OCR route and directly can import svg files into assigned spots. Thanks
  • @WAY KYI [this is off topic] Are you trying to build an OT-SVG font?

    In the screenshot you show above, all the symbols can easily be represented using a COLR version 0 table, which is more widely supported than the SVG table.
  • WAY KYI
    WAY KYI Posts: 130
    Hi Mr. Peter Constable, thank you for your input and your assumption is correct. I want to build simple SVG version in the beginning and later on with COLR color fonts because I have simple color text/symbols and also have more texture with images included in my creation. I started with SVG and not even look at simple COLR one yet. I am just checking how easy the process can be at FL and also thinking of Font Creator too. I like OCR in FL but it isn't completely thought out for all the situations. The editing part, I will do in Graphic Applications and thus, the import where I would need to spend a lot of time - is the main concern for me with FL. Thus I am asking automated processing of the import first. By the way, do you have any recommendation for documents or websites to learn creating COLR fonts??? How many color can you use in COLR or SVG color font??? SVG is more advanced font than COLR?? What are the differences between COLR vs SVG, pro and con??? I knew SVG is huge file. Thanks
  • OCR in FontLab specifically only supports Latin and Russian characters.

    You can turn off OCR and make other important auto-shape-grouping adjustments under Preferences > Operations > Optical Separation — check out the settings there.
  • WAY KYI
    WAY KYI Posts: 130
    Thank you and thank you very much

    Mr. Thomas Phinney

    you saved my headache and now I am very happy. No need to automate the import. The same route thru Sketch board as before but turned off OCR did the trick. But copy/paste svg files did the same as before - going into one place. Not sure individual svg file could be better quality, but this is more than good enough. Thank again and have a nice day!!!
     
  • WAY KYI
    WAY KYI Posts: 130
    I know now how to create all three color fonts COLR, Bitmap and SVG. Thanks to all of you whom helped and directed me in here. Thank you very much. You guys are the best.
  • >How many color can you use in COLR or SVG color font??? SVG is more advanced font than COLR??

    The colour space used for either COLR or SVG is sRGB.

    For COLR, the colours are defined in the CPAL table, which supports alternate palettes with each palette supporting up to 65535 colours as well as an app-specified "foreground" colour.

    The SVG table allows for colours to be specified directly within the svg markup using the mechanisms defined in the SVG 1.1 spec (e.g., colour keywords, rgb(...), #ffbb00...). But the SVG table also supports colours specified within the CPAL table, which has the advantage of allowing for alternate palettes.  

    >What are the differences between COLR vs SVG, pro and con???

    The OpenType spec now defines two versions for the COLR table. The first version (v0) was very simple for implementations to support, and is the only colour format supported in all browsers and OS platforms. Because the format is very simple, fonts can be very compact. But it was also limited in terms of 2D graphic capabilities: it allows for layered shapes with solid colour fills plus alpha. If you compare the SVG table and COLRv0, the former has much richer graphic capabilities but is less widely supported.

    There is now a second version of the COLR table, COLR v1, that has much richer graphic capabilities roughly comparable to that of the SVG table, but using a binary format that is far more compact.

    Another important difference is that COLRv0 and COLRv1 integrate well with variations while the SVG table does not integrate with variations at all.

    COLRv1 is supported in Chromium-based browsers. Mozilla has work in progress adding support in Firefox. Microsoft has also implemented support in DirectWriteCore in version 1.2 of WinAppSDK (available in experimental release).

  • WAY KYI said:
    .... Not sure individual svg file could be better quality, but this is more than good enough. 

    One small trick that helps preserve outline quality:

    Be sure to scale the placed SVG to the right size, BEFORE you use the “Make SVG Editable” function.

    When you “Make SVG Editable,” its coordinates get rounded to the unit grid of the font;  doing this on the placed SVG before scaling it up in size, can reduce outline quality, potentially a lot if it was several times smaller than desired. (And Make SVG Editable before scaling down can reduce outline quality a little, just because it will get rounded again at the final size: getting rounded only once is better than getting rounded at two different times.)
  • WAY KYI
    WAY KYI Posts: 130
    Thank you very much Mr. Thomas Phinney for your info. I just have the last question with SVG if you don't mind??? Do you happen to know which operating systems, browsers and graphic and office applications fully support SVG color fonts??? Thanks
  • I did some investigation late last year into support for the different colour formats.

    In Windows, the DirectWrite/Direct2D and system XAML platforms support OT-SVG and COLRv0, with COLRv1 support coming. But that doesn't mean that apps running on Windows support it---apps need to opt in.

    Microsoft Office apps support COLRv0. Mac versions seemed to support some OT-SVG fonts, but other OT-SVG fonts that I tried didn't work.

    For browsers, you can use ChromaCheck by PixelAmbacht to test which colour formats are supported. Chromium-based browsers do _not_ support OT-SVG, but Safari and Firefox do. Here's the results for current versions of Edge, Safari and Firefox (Chrome and Opera will be the same as Edge):



    COLRv0 is the only format supported in all. I expect COLRv1 will eventually be supported in all browsers, but it's very unlikely OT-SVG will be supported in all.

    Adobe apps (but not AfterEffects) support OT-SVG. Adobe doesn't (yet) support COLR.

    Corel Graphics Suite 2021 (Mac) supports COLRv0 and sbix, but not OT-SVG.

    Affinity Designer and Photo (Windows) supports COLRv0, but not OT-SVG.

    Figma doesn't appear to have any colour font support, though emoji fonts seemed to work (I didn't try to figure out why that worked but other colour fonts didn't).
  • WAY KYI
    WAY KYI Posts: 130
    Thank you very much Mr. Peter Constable . This is a good research. I did tried checking on the web, even going into some graphic application forum and asked this question there. But no one answer or know the answer. So this is very valuable info for me. Thanks 
  • We also maintain lists of font color support in this tutorial:
  • WAY KYI
    WAY KYI Posts: 130
    Thank you very much Mr. Erwin Denissen. There is a lot more information in the tutorial and number of color formats, supported systems and applications. Thank you.
  • WAY KYI
    WAY KYI Posts: 130
    edited August 2022
    Hi all, I have a new problem. I have this B/W symbol font and I opened it in FL, changed a few symbols to color. Then export it as OTF-COLR and OTF-SVG formats. I tried it in AI 2020 which supports both formats, but the color are not showing up. In AI font dialog, it show B/W and no SVG embedded. If SVG is embedded in the font, it shows SVG letter. So, I got all B/W symbols in AI. Even though, the glyphs show colors in Font Windows in FL, both SVG and COLR options did not work in AI. Other font I have, I went thru the same process and it did shown up color in AI 2020. The only different is - this has a lot more elements than the one which works.

    There is a lot of options for font format and also for color options in there. I tried all of the color options OTF-PS and none of them work. I attached the font here and can anyone help me take a look??? Thanks 

    https://drive.google.com/drive/folders/1nH2vn8rUP4_3SGHWfLthPylXtg_bP2jM?usp=sharing
  • WAY KYI
    WAY KYI Posts: 130
    edited August 2022
    Edit: Thank you very much Mr. Thomas Phinney I was able to solve the last problem by making "SVG element editable" option. Therefore, I am removing the font on Google drive. Thank you everyone!!!