robhagemans / monobit

Tools for working with monochrome bitmap fonts
MIT License
207 stars 11 forks source link

(Windows10) Full path problem #33

Closed SlashNetUA closed 2 months ago

SlashNetUA commented 3 months ago

I get an error when using full paths to files in Windows 10

monobit-convert D:\Soft\_Tools_\Font\setfont-ibm.yaff D:\Soft\_Tools_\Font\33.png

ERROR: 'D:\\Soft\\_Tools_\\Font\\setfont-ibm.yaff' is not in the subpath of '\\' OR one path is relative and the other is absolute.

robhagemans commented 3 months ago

Thanks! Which version of monobit are you using? Asking because I fixed a similar error occurring on all OSes for the latest release.

You can use monobit --version to get the version string. Latest is 0.45.0

Could you try rerunning the command that caused the error with the debug flag and post the output here? It'll give a stack trace helping to find the error.

Thanks again Rob

SlashNetUA commented 3 months ago

That's strange. I updated yesterday and the utility updated only to version 0.43.

pip install monobit

Requirement already satisfied: monobit in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (0.43.1)
Requirement already satisfied: arabic-reshaper in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (from monobit) (3.0.0)
Requirement already satisfied: fonttools in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (from monobit) (4.53.1)
Requirement already satisfied: pillow in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (from monobit) (10.4.0)
Requirement already satisfied: python-bidi in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (from monobit) (0.6.0)
Requirement already satisfied: reportlab in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (from monobit) (4.2.2)
Requirement already satisfied: uniseg in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (from monobit) (0.8.0)
Requirement already satisfied: chardet in c:\users\slashnet\appdata\local\programs\python\python311\lib\site-packages (from reportlab->monobit) (5.2.0)

monobit-convert --version monobit v0.43

python.exe --version Python 3.11.5

robhagemans commented 3 months ago

I just checked, it looks like 0.44 and 0.45 get silently skipped by pip because of a dependency issue with yenc (possibly just a wrong package name).

I'll have to fix the dependencies and re-upload, sorry.

robhagemans commented 3 months ago

I've uploaded v0.45.1 with fixed dependencies - I was able to install it with pip. Please give it a try and let me know if it fixed the issue

Thanks!

SlashNetUA commented 3 months ago

Hi! I upgraded to 0.45.1, but it got worse. Any run of the program generates the same error: :(

monobit-convert --version

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Scripts\monobit-convert.exe\__main__.py", line 4, in <module>
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\__init__.py", line 13, in <module>
    from .storage import FileFormatError, load, save, loaders, savers
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\__init__.py", line 9, in <module>
    from .fontfiles import load, save
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontfiles.py", line 20, in <module>
    from .location import open_location, iter_funcs_from_registry
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\location.py", line 18, in <module>
    from .containerformats.directory import Directory
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\containerformats\__init__.py", line 9, in <module>
    import_all(__name__)
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\base\__init__.py", line 26, in import_all
    vars(module).update({
                        ^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\base\__init__.py", line 27, in <dictcomp>
    Path(_file).stem: import_module('.' + Path(_file.name).stem, module.__package__)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\containerformats\uselibarchive.py", line 11, in <module>
    import libarchive
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\libarchive\__init__.py", line 1, in <module>
    from .entry import ArchiveEntry
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\libarchive\entry.py", line 6, in <module>
    from . import ffi
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\libarchive\ffi.py", line 26, in <module>
    libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\ctypes\__init__.py", line 454, in LoadLibrary
    return self._dlltype(name)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\ctypes\__init__.py", line 366, in __init__
    if '/' in name or '\\' in name:
       ^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
robhagemans commented 3 months ago

Thanks for the stack trace. This is actually a different issue as the newer version tries to leverage libarchive to support more archive formats. But it seems libarchive-c doesn't gracefully fail when it can't find the dll, and it doesn't come preinstalled on Windows.

I'll need to put some code to deal with errors in external libraries.

robhagemans commented 3 months ago

I've uploaded a 0.45.2 that hopefully works around this issue.

SlashNetUA commented 3 months ago

It's better now, but converter still didn't work. :(

monobit-convert --version

WARNING:root:Error while importing module `libarchive`: argument of type 'NoneType' is not iterable
monobit v0.45

monobit-convert ep_uk.yaff to 11.png

WARNING:root:Error while importing module `libarchive`: argument of type 'NoneType' is not iterable
WARNING: Could not infer format from file 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff'. Falling back to default `yaff` format
ERROR: Unable to read fonts from 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff': format specifier `` not recognised.

monobit-convert ep_uk.yaff --debug to 11.png

WARNING:root:Error while importing module `libarchive`: argument of type 'NoneType' is not iterable
DEBUG: Executing command `load`
DEBUG: Opening file 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' for mode 'r'.
DEBUG: input stream 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' is likely text.
DEBUG: input stream 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' is likely text.
DEBUG: Cannot transcode stream 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff'
DEBUG: input stream 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' is likely text.
DEBUG: input stream 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' is likely text.
DEBUG: input stream 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' is likely text.
DEBUG: input stream 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' is likely text.
WARNING: Could not infer format from file 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff'. Falling back to default `yaff` format
DEBUG: Closing <Stream name='Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff' mode='r'>
ERROR: Unable to read fonts from 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff': format specifier `` not recognised.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Scripts\monobit-convert.exe\__main__.py", line 7, in <module>
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\scripts\convert.py", line 85, in main
    fonts += operation(*args.args, **args.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\plumbing\scripting.py", line 98, in _converted_func
    result = func(*args, **conv_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\plumbing\scripting.py", line 57, in _scriptable_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontfiles.py", line 50, in load
    return _load_stream(
           ^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontfiles.py", line 79, in _load_stream
    raise FileFormatError(message)
monobit.base.basetypes.FileFormatError: Unable to read fonts from 'Kraftwerk\Graphics\Fonts\EP-TVC\elan_enterprise\ep_uk.yaff': format specifier `` not recognised.
robhagemans commented 3 months ago

Apologies, I didn't seem to have run the tests correctly on that change, will need to redo that one

robhagemans commented 3 months ago

OK, another try with 0.45.3. At least this one works locally :)

SlashNetUA commented 3 months ago

Sorry. But still doesn't work. :(

monobit-convert --version

WARNING:root:Error while importing module `libarchive`: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Scripts\monobit-convert.exe\__main__.py", line 4, in <module>
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\__init__.py", line 13, in <module>
    from .storage import FileFormatError, load, save, loaders, savers
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\__init__.py", line 17, in <module>
    from . import fontformats as _fontformats
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontformats\__init__.py", line 9, in <module>
    import_all(__name__)
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\base\imports.py", line 18, in import_all
    vars(module).update({
                        ^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\base\imports.py", line 19, in <dictcomp>
    Path(_file).stem: import_module(
                      ^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontformats\apple\__init__.py", line 9, in <module>
    import_all(__name__)
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\base\imports.py", line 18, in import_all
    vars(module).update({
                        ^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\base\imports.py", line 19, in <dictcomp>
    Path(_file).stem: import_module(
                      ^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontformats\apple\dfont.py", line 23, in <module>
    from ..sfnt import load_sfnt, save_sfnt
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontformats\sfnt\__init__.py", line 8, in <module>
    from .sfnt import load_sfnt, load_collection
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontformats\sfnt\sfnt.py", line 20, in <module>
    from . import fonttools
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\storage\fontformats\sfnt\fonttools\__init__.py", line 13, in <module>
    ttLib = safe_import('fontTools', 'ttLib')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\SlashNet\AppData\Local\Programs\Python\Python311\Lib\site-packages\monobit\base\imports.py", line 42, in safe_import
    item = getattr(module, name)
           ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'fontTools' has no attribute 'ttLib'
SlashNetUA commented 3 months ago

Tried manualy install libarchive, but process failed.

Collecting libarchive
  Downloading libarchive-0.4.7.tar.gz (23 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting nose (from libarchive)
  Downloading nose-1.3.7-py3-none-any.whl.metadata (1.7 kB)
Downloading nose-1.3.7-py3-none-any.whl (154 kB)
Building wheels for collected packages: libarchive
  Building wheel for libarchive (pyproject.toml) ... error
  error: subprocess-exited-with-error
    .......
    note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for libarchive
Failed to build libarchive
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (libarchive)
robhagemans commented 3 months ago

Libarchive is not what's causing this error though (I think you can get rid of the first error message with pip uninstall libarchive-c) - this is some issue wher eyour setup imports fontTools in a different way than mine, weirdly.

Another try with v0.45.4. Since I don't see the issue on my setup, at this point I'm just guessing though.

SlashNetUA commented 3 months ago

Finally it working! Big thanks! :)

How about adding another .fnt format for export/import (from Elan Enterprise 64/128k)? It's quite simple, but there are some subtleties.

robhagemans commented 3 months ago

Hi @SlashNetUA, great to hear it's fixed now.

Do you have a specification/other information and sample files for the Elan Enterprise .fnt format? I can have a look.