Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining command line options -script and -new does not work #3905

Open
ctrlcctrlv opened this issue Aug 28, 2019 · 1 comment
Open

Combining command line options -script and -new does not work #3905

ctrlcctrlv opened this issue Aug 28, 2019 · 1 comment

Comments

@ctrlcctrlv
Copy link
Member

This could be useful for development, but results in an error:

[fred@pc fontforge]$ fontforge -script imp.py -new -quiet
Traceback (most recent call last):
  File "imp.py", line 3, in <module>
    f = fontforge.fonts()[0]
IndexError: tuple index out of range
import fontforge

f = fontforge.fonts()[0]

f.createChar(ord("A"))
f["A"].right_side_bearing = 100
f["A"].importOutlines("/home/fred/Workspace/fontforge/B.jpg", 32)

Apparently the script is run before a new font is made.

Of course, we can do:

--- imp.py      2019-08-28 14:59:17.100865945 +0800
+++ imp2.py     2019-08-28 14:59:02.004199156 +0800
@@ -1,6 +1,6 @@
 import fontforge
 
-f = fontforge.fonts()[0]
+f = fontforge.font()
 
 f.createChar(ord("A"))
 f["A"].right_side_bearing = 100

But now we can't run the same script in the «Execute Script» dialog as in the command line interface.

@skef
Copy link
Contributor

skef commented Sep 10, 2019

Seems like trying to solve this in the totally general way would be a big pain. Better to add -new to the arguments processed by scripting.c:_CheckIsScript() (possibly enhancing the loop to remove the ordering constraints). That way this would also pose no barrier to #3922 .

(I take it the alternative is to try to get the scripting initialization to use the general options processing code.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants