InamuraJIN / ActionRecorder

GNU General Public License v3.0
178 stars 15 forks source link

FileNotFoundError: [Errno 2] No such file or directory: 'datafiles/fonts/DejaVuSans.woff2' #73

Closed clement-nardi closed 5 months ago

clement-nardi commented 5 months ago

Describe the bug When I click on a macro element in the macro editor, I systematically get this error: FileNotFoundError: [Errno 2] No such file or directory: 'datafiles/fonts/DejaVuSans.woff2'

To Reproduce Steps to reproduce the behavior:

  1. Install the addon
  2. Record a simple macro
  3. Try to edit the macro

Expected behavior I guess a pop-up should appear? I don't know since I'm using the addon for the first time.

Screenshots

image

Version Information:

Additional context I search my system for a file named DejaVuSans.woff2 and found these 2: /usr/share/blender/datafiles/fonts/DejaVuSans.woff2 /usr/share/fonts/woff2/dejavu/DejaVuSans.woff2

Note: After installing the add-on, when I tried to activate it I got an error about module ensurepip not being found. I solved this by running this command: sudo apt install python3-pip python3-venv

RivinHD commented 5 months ago

Fixed with Version 4.1.1

clement-nardi commented 5 months ago

Hi @RivinHD ,

Thank you for your prompt action on this bug!

Unfortunately I just tested the version 4.1.1 and I still have the font error when I try to edit the macros... I updated the add-on with the embedded updater.

Regards, Clément

RivinHD commented 5 months ago

I tested in Ubuntu 22.04 VM and everything works fine.

Is the error message the exact same? I.e. /datafiles/fonts/DejaVuSans.woff2

clement-nardi commented 5 months ago

Hi!

Yes looks like the exact same callstack:

image

I tried to remove/reinstall the addon, and create a new recording, I still get the error.

RivinHD commented 5 months ago

Hi,

Can you run this script in the Text Editor?

  1. Select the 'Scripting' Workspace
  2. Copy the script and paste it into the Text Editor
  3. Run the script
  4. You should see a popup appear near your cursor position
  5. Please make a screenshot of the Popup, so I can verify path (In your case the path should be /usr/share/blender/datafiles/fonts/DejaVuSans.woff2)

image

import bpy
import os

def get_font_path() -> str:
    """
    get the font path of the active font in Blender

    Returns:
        str: path to the font
    """
    if bpy.context.preferences.view.font_path_ui == '':
        version = bpy.app.version
        version_directory = os.path.dirname(bpy.app.binary_path)
        for root, dirs, _ in os.walk(version_directory):
            if len(root) and root.strip(" /\\").endswith("datafiles") and "fonts" in dirs:
                version_directory = os.path.join(root, "fonts")
                break
        if version >= (4, 0, 0):
            return os.path.join(version_directory, "Inter.woff2")
        if version >= (3, 4, 0):
            return os.path.join(version_directory, "DejaVuSans.woff2")
        return os.path.join(version_directory, "droidsans.ttf")
    else:
        return bpy.context.preferences.view.font_path_ui

def oops(self, context):
    self.layout.label(text=get_font_path())

bpy.context.window_manager.popup_menu(oops, title="Error", icon='ERROR')
print(get_font_path())
clement-nardi commented 5 months ago

I get this: image

RivinHD commented 5 months ago

Hey, I edit it, can you run this as described above and screenshot the output.

import bpy
import os

def get_font_path() -> str:
    """
    get the font path of the active font in Blender

    Returns:
        str: path to the font
    """
    if bpy.context.preferences.view.font_path_ui == '':
        version = bpy.app.version
        version_directory = os.path.join(
            os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(bpy.__file__)))),
            "datafiles",
            "fonts"
        )
        if version >= (4, 0, 0):
            return os.path.join(version_directory, "Inter.woff2")
        if version >= (3, 4, 0):
            return os.path.join(version_directory, "DejaVuSans.woff2")
        return os.path.join(version_directory, "droidsans.ttf")
    else:
        return bpy.context.preferences.view.font_path_ui

def oops(self, context):
    self.layout.label(text=get_font_path())

bpy.context.window_manager.popup_menu(oops, title="Error", icon='ERROR')
print(get_font_path())
RivinHD commented 5 months ago

I tested on Ubuntu with a Blender apt installation and the path was correct. Can you verify?

clement-nardi commented 5 months ago

Yes this time the path is correct: image

RivinHD commented 5 months ago

This should finally be fixed with Version 4.1.2