natcap / invest

InVEST®: models that map and value the goods and services from nature that sustain and fulfill human life.
Apache License 2.0
159 stars 65 forks source link

Unable to load "untrusted fonts" #649

Closed MarisaTrego-NOAA closed 2 years ago

MarisaTrego-NOAA commented 3 years ago

I keep running into an issue that seems to be related to loading the iconic_fonts.py script and unfortunately my institution (one NOAA office) is not able to unblock the fonts needed. Is there anything else we can do as a workaround that doesn't require loading that font?

emlys commented 3 years ago

@marisatrego can you please attach your log file? If fonts are the issue, you can run models without the UI via the command line (invest run --headless).

MarisaTrego-NOAA commented 3 years ago

Oh yes, sorry. I meant to paste that in:

C:\InVEST_3.9.0_x64\invest-3-x64>invest.exe run habitat_risk_assessment Traceback (most recent call last): File "src\natcap\invest\cli.py", line 575, in File "src\natcap\invest\cli.py", line 529, in main File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "C:\Miniconda\envs\winbin-env\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module File "site-packages\natcap\invest\ui\inputs.py", line 49, in File "site-packages\qtawesome__init.py", line 173, in icon File "site-packages\qtawesome\init.py", line 76, in _instance File "site-packages\qtawesome\iconic_font.py", line 214, in init__ File "site-packages\qtawesome\iconic_font.py", line 270, in load_font qtawesome.iconic_font.FontError: Font at 'C:\InVEST_3.9.0_x64\invest-3-x64\qtawesome\fonts\fontawesome4.7-webfont.ttf' appears to be empty. If you are on Windows 10, please read https://support.microsoft.com/en-us/kb/3053676 to know how to prevent Windows from blocking the fonts that come with QtAwesome. [9852] Failed to execute script cli

MarisaTrego-NOAA commented 3 years ago

Attempting to run with --headless just mentions we need Datastack. I can see if that is something we are allowed to install if that is the fix.

emlys commented 3 years ago

That's interesting. I guess we should have a fallback font, even though it's local.

To run in headless mode (without the UI), you'll need to make a datastack file. This is a JSON file that stores all the model inputs you'd normally enter in the user interface. Here's an example for the Habitat Risk Assessment sample data:

hra_datastack.json:

{
    "args": {
        "aoi_vector_path": "/Users/emily/Downloads/InVEST_3.9.0_sample_data/HabitatRiskAssess/Input/subregions.shp",
        "criteria_table_path": "/Users/emily/Downloads/InVEST_3.9.0_sample_data/HabitatRiskAssess/Input/exposure_consequence_criteria.csv",
        "decay_eq": "Linear",
        "info_table_path": "/Users/emily/Downloads/InVEST_3.9.0_sample_data/HabitatRiskAssess/Input/habitat_stressor_info.csv",
        "max_rating": "3",
        "resolution": "100",
        "results_suffix": "",
        "risk_eq": "Multiplicative",
        "visualize_outputs": true
    },
    "invest_version": "3.9.0",
    "model_name": "natcap.invest.hra"
}

Replace all the values with your actual inputs. Then invest.exe run --headless --datastack <path\to\hra_datastack.json> --workspace <path\to\workspace\directory> habitat_risk_assessment

If you prefer to use the UI, it looks like you might be able to install just the font needed for the app: https://docs.microsoft.com/en-US/troubleshoot/windows-client/shell-experience/feature-to-block-untrusted-fonts#fix-apps-that-have-problems-because-of-blocked-fonts

phargogh commented 3 years ago

As another avenue of inquiry, @marisatrego could you check the folder C:\InVEST_3.9.0_x64\invest-3-x64\qtawesome\fonts and see if there's anything in there? I'm seeing 6 .ttf files in there in the standard InVEST installation on Windows, and if they are not there for you, that might indicate a separate issue.

Either way, @emlys you're absolutely right that we should handle a fallback font.

MarisaTrego-NOAA commented 3 years ago

Thanks for following up. It does look like I have 12 files in the font folder so that doesn't seem to be the issue. I did work with my IT department to try and install fonts and they said they couldn't modify the group policy (r the registry as suggested on that website). I can see if I can get this other workaround running.

emlys commented 3 years ago

@phargogh, maybe there's also a more standard font we could use instead that would be "trusted" by default.

phargogh commented 3 years ago

@marisatrego thanks for checking out the fonts there! I don't suppose you'd be able to just install the fonts locally, would you? Is that allowed by group policy? I'm not surprised that modifying the registry would be pretty restricted.

@emlys It's possible! I think the ideal solution here would be twofold: 1) UTF-8 characters and 2) glyphs we have tested to be available on our target systems. The main reason for using QtAwesome/FontAwesome was that it offered a consistent visual language and didn't force us to manage bitmaps (which we were doing in an old version of the UI).

MarisaTrego-NOAA commented 3 years ago

I was able to have IT install the fonts for all users (I don't have admin privileges) and unfortunately I am still getting the same error. There may be one other thing to try but they are on the east coast so I will have to wait until tomorrow. Thank you!

emlys commented 2 years ago

Closing because no activity for a few months.