Discussion:
[fontforge-users] Two questions about embedded tables (python)
Abraham Lee
2016-02-29 15:18:10 UTC
Permalink
All,

I use FontForge's python scripting capabilities all the time (it is
heaven-sent for my work). I have two questions about embedded tables:

*1. Is it possible to keep non-standard tables from getting tossed when
opening a file? *

I know it's possible when using the GUI, but I can't seem to determine the
proper syntax for doing this via python scripting.

In the docs, it gives the function definition as

*fontforge.open(filename[, flags])*


with the description:

*Opens a filename and returns the font it contains. If it does.*

*If the flags argument is 4, then ff will load all glyphs in the 'glyf'
table of a ttc file (rather than just the glyphs used in the font picked).
This will not load all 'glyf' tables though.*


Am I supposed to be able to access them this way? The variable "flags" is
supposed to be an integer, and it doesn't seem to matter what integer I put
in there, so I'm not sure what to do.

2. I'm also aware that you can access and embed any table in the font via
"getTableData" and "setTableData", respectively. These functions speak of
the data being in a "binary string" format. When keeping a non-standard
table in the GUI, they are encoded in the ascii85 format. *Is this the
format they are referring to?* If not, that's fine, I'd just like to know
what the correct format is.

Thanks, everyone! Any insight would be very much appreciated!

Best,
Abraham
marty39
2016-02-29 17:06:12 UTC
Permalink
Post by Abraham Lee
*1. Is it possible to keep non-standard tables from getting tossed when
opening a file? *
I know it's possible when using the GUI, but I can't seem to determine the
proper syntax for doing this via python scripting....
2. I'm also aware that you can access and embed any table in the font via
"getTableData" and "setTableData", respectively. These functions speak of
the data being in a "binary string" format. When keeping a non-standard
table in the GUI, they are encoded in the ascii85 format. *Is this the
format they are referring to?* If not, that's fine, I'd just like to know
what the correct format is....
Not an answer but a further question. How does the GUI provide for
preserving tables that FontForge can't parse?

In Menu, File, Preferences, Open Font, Preserve Tables, I can enter a list
of four-letter tags of tables I want preserved, and they will be saved in
binary format (not "ascii85"). The only options in the File Open dialog are
font file filtering and glyph renaming. Am I missing something?



--
View this message in context: http://fontforge.10959.n7.nabble.com/Two-questions-about-embedded-tables-python-tp14999p15000.html
Sent from the User mailing list archive at Nabble.com.
Abraham Lee
2016-02-29 20:43:35 UTC
Permalink
marty89,
Post by marty39
Post by Abraham Lee
*1. Is it possible to keep non-standard tables from getting tossed when
opening a file? *
I know it's possible when using the GUI, but I can't seem to determine
the
Post by Abraham Lee
proper syntax for doing this via python scripting....
2. I'm also aware that you can access and embed any table in the font via
"getTableData" and "setTableData", respectively. These functions speak of
the data being in a "binary string" format. When keeping a non-standard
table in the GUI, they are encoded in the ascii85 format. *Is this the
format they are referring to?* If not, that's fine, I'd just like to know
what the correct format is....
Not an answer but a further question. How does the GUI provide for
preserving tables that FontForge can't parse?
In Menu, File, Preferences, Open Font, Preserve Tables, I can enter a list
of four-letter tags of tables I want preserved, and they will be saved in
binary format (not "ascii85"). The only options in the File Open dialog are
font file filtering and glyph renaming. Am I missing something?
In that preferences area, the four-letter tags must be comma-separated
without spaces (if there are more than one to be preserved), like
"ABCD,EFGH,JKLM". With that set, if I open a file that has any these tables
embedded, then save the font to an SFD file, the tables are preserved in
raw ascii85 format that you can view in any text editor. I have been
utilizing a python script to access them directly from the SFD text file in
this format and then decode them into normal ascii so I can read them.

Since sending my first message, I learned through experimentation that
getTableData returns the decoded table data (in ascii format) and
setTableData expects its "sequence" input to be in normal ascii format,
which is EXACTLY what I wanted!

Best,
Abraham
Abraham Lee
2016-03-04 17:23:16 UTC
Permalink
Post by Abraham Lee
marty89,
Post by marty39
Post by Abraham Lee
*1. Is it possible to keep non-standard tables from getting tossed when
opening a file? *
I know it's possible when using the GUI, but I can't seem to determine
the
Post by Abraham Lee
proper syntax for doing this via python scripting....
2. I'm also aware that you can access and embed any table in the font
via
Post by Abraham Lee
"getTableData" and "setTableData", respectively. These functions speak
of
Post by Abraham Lee
the data being in a "binary string" format. When keeping a non-standard
table in the GUI, they are encoded in the ascii85 format. *Is this the
format they are referring to?* If not, that's fine, I'd just like to
know
Post by Abraham Lee
what the correct format is....
Not an answer but a further question. How does the GUI provide for
preserving tables that FontForge can't parse?
In Menu, File, Preferences, Open Font, Preserve Tables, I can enter a list
of four-letter tags of tables I want preserved, and they will be saved in
binary format (not "ascii85"). The only options in the File Open dialog are
font file filtering and glyph renaming. Am I missing something?
In that preferences area, the four-letter tags must be comma-separated
without spaces (if there are more than one to be preserved), like
"ABCD,EFGH,JKLM". With that set, if I open a file that has any these tables
embedded, then save the font to an SFD file, the tables are preserved in
raw ascii85 format that you can view in any text editor. I have been
utilizing a python script to access them directly from the SFD text file in
this format and then decode them into normal ascii so I can read them.
Since sending my first message, I learned through experimentation that
getTableData returns the decoded table data (in ascii format) and
setTableData expects its "sequence" input to be in normal ascii format,
which is EXACTLY what I wanted!
Best,
Abraham
My first question still stands, BTW.

- Abraham

Loading...