Problem with adding fonts in python script - python

e, Hi does anyone know, I don't understand how to add my own font for text into some python script for image procesing? I found in code fontlist.txt -> a file that is used as text source. So there I put my .ttf fonts that I downloaded from here: https://www.1001fonts.com/text-fonts.html?page=1&fbclid=IwAR395plHPNmZemLoKmvpedbqRv0z8pUVU66np7LLWzia14GrAKWcZB1H5o4 and then terminal shows me and error :
Traceback (most recent call last):
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 669, in render_text
regions['homography_inv'][ireg])
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 506, in place_text
render_res = self.text_renderer.render_sample(font,collision_mask)
File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 414, in render_sample
f_h = self.font_state.get_font_size(font, f_h_px)
File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 534, in get_font_size
m = self.font_model[font.name]
KeyError: 'Fabiolo'
Traceback (most recent call last):
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 669, in render_text
regions['homography_inv'][ireg])
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 504, in place_text
font = self.text_renderer.font_state.init_font(font)
File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 565, in init_font
font = freetype.Font(fs['font'], size=fs['size'])
OSError: Failed to load font: unknown file format
This 'Fabiolo' is a name of font.
How Failed to load font: unknown file format? I'm using .ttf fonts like they who made a script. Maybe ubuntu supports some certain fonts. I'm using UBUNTU 18.04.
When I use the upper one (fontlist1.txt - mine) there shows an error.
When I use the bottom one (fontlist.txt - originally from script) that works fine everytime.
Here you can see how I add paths and names into fontlist1.txt
I also add the font names like 'Fabiolo', 'Halida Sans', ... into Font Manager but still nothing, shows the same errors.

Related

Waveshare 2.9inch_Touch_e-Paper_HAT: Getting Demo to work

I thought I just share m findings if anybody else has bought the same e-paper touch display and struggles to start the demo on a raspberry pi (python).
In my case I followed the wiki page:
https://www.waveshare.com/wiki/2.9inch_Touch_e-Paper_HAT
But then there was no "main.py" to start, so I figured i tried the existing file "TP2in9_test.py".
After doing "chmod -x TP2in9_test.py" I started the file with
sudo python3 TP2in9_test.py but got an error:
Traceback (most recent call last):
File "/home/pi/Touch_e-Paper_Code/python/examples/TP2in9_test.py", line 14, in <module>
from TP_lib import weather_2in9_V2
File "/usr/local/lib/python3.9/dist-packages/waveshare_ETP-0.0.0-py3.9.egg/TP_lib/weather_2in9_V2.py", line 60, in <module>
font12 = ImageFont.truetype(os.path.join(fontdir, 'Font.ttc'), 12)
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 852, in truetype
return freetype(font)
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 849, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 209, in __init__
self.font = core.getfont(
OSError: cannot open resource
I then commented out both lines that referenced the "weather" script/function, that is lines 14 and 112.
After that the display demo works and even the weather part is showing up, nice.
Solution: Comment out both lines that referenced the "weather" script/function,
that is lines 14 and 112.

VSCode FileNotFoundError

I am trying to create a 2D arcade style game for a project in school using Python Arcade in VSCode, but I have issues correctly locating a map I created on a map editor.
Both the game code and map file are situated in the same main folder, with the map being placed in a sub-folder within the main folder.
I have used this line of code to specify the map location:
# Map name
map_name = ("maps/map1_level_{}.tmx.".format(level))
This is the error:
C:\Users\frag>python c:/Users/frag/Documents/game/arcade_game.py
Traceback (most recent call last):
File "c:/Users/frag/Documents/game/arcade_game.py", line 310, in <module>
main()
File "c:/Users/frag/Documents/game/arcade_game.py", line 305, in main
window.setup(window.level)
File "c:/Users/frag/Documents/game/arcade_game.py", line 120, in setup
my_map = arcade.tilemap.read_tmx(map_name)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\arcade\tilemap.py", line 56, in read_tmx
tmx_file = resolve_resource_path(tmx_file)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\arcade\resources\__init__.py", line 30, in resolve_resource_path
raise FileNotFoundError(f"Cannot locate resource : {path}")
FileNotFoundError: Cannot locate resource : maps\map1_level_1.tmx
try this map_name = ("./maps/map1_level_{}.tmx.".format(level))
Fixed the issue by specifying the working absolute path:
import os
os.chdir('C:/Users/frag/Documents/game')

Set up Python tkTable

Being very new to Phyton, I’m trying to use tktable for Python and can’t get it run on my PC.
After searching a lot in the net, without finding any solution, I hope you find the time to help me a bit.
I’m sure this is peanuts for you.
I’m running Python 3.7 on a Windows 8.1. PC.
I’m getting this error:
_tkinter.TclError: invalid command name "table"
What I did so far:
Downloaded tktable and run the setup.py.
Copied the tktable.py to the Python site-packages folder.
Installed ActiveTcl.
Copied the three files tktable.tcl, Tktable.dll and pkgIndex.tcl from ActiveTcl (C:\ActiveTcl\lib\Tktable2.11) to C:........\Python\Python37-32\tcll\Tktable2.11.
According what I have found in the net, this should do it…
But, as I wrote, I keep getting the error I mentioned.
Michael
The content is:
C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\Lib\;
C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\DLLs\
Traceback:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/mschuppisser.EAD/Data/My Data/Python/Test Applikation/Test Applikation.py", line 267, in Jump_to_UebersichtsFenster3
application = clsUebersichtsFenster3(UebersichtsFenster3)
File "C:/Users/mschuppisser.EAD/Data/My Data/Python/Test Applikation/Test Applikation.py", line 447, in __init__
self.table_grid = tktable.Table(UebersichtsFenster3) # , state='disabled', width=50, titlerows=1, rows=5, cols=4, colwidth=20)
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tktable.py", line 135, in __init__
tkinter.Widget.__init__(self, master, 'table', kw)
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "table"

Winerror 3: File not found using ac2git

I was using the ac2git tool to concert my accurev depot to git repository.
I am getting the following error when running the command python ac2git.py after following the necessary steps, as instructed here.
2016-08-29 09:54:14,058 - ac2git - ERROR - The script has encountered an exception, aborting!
Traceback (most recent call last):
File "ac2git.py", line 3596, in AccuRev2GitMain
rv = state.Start(isRestart=args.restart, isSoftRestart=args.softRestart)
File "ac2git.py", line 2974, in Start
self.RetrieveStreams()
File "ac2git.py", line 1556, in RetrieveStreams
tr, commitHash = self.RetrieveStream(depot=depot, stream=streamInfo,dataRef=dataRef, stateRef=stateRef, hwmRef=hwmRef, startTransaction=self.config.accurev.startTransaction, endTransaction=endTr.id)
File "ac2git.py", line 1511, in RetrieveStream
dataTr, dataHash = self.RetrieveStreamData(stream=stream, dataRef=dataRef,stateRef=stateRef)
File "ac2git.py", line 1394, in RetrieveStreamData
commitHash = self.Commit(transaction=tr, allowEmptyCommit=True,messageOverride="transaction {trId}".format(trId=tr.id), parents=[], ref=dataRef)
File "ac2git.py", line 670, in Commit
self.PreserveEmptyDirs()
File "ac2git.py", line 440, in PreserveEmptyDirs
if git.GetGitDirPrefix(path) is None and len(os.listdir(path)) == 0:
FileNotFoundError: [WinError 3] The system cannot find the path specified:'C:///Users/*****/*****/app/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/node_modules/proto-list'
The error is quite vague and I can't seem to find any documentation on this tool that can help with the error. Has anyone faced this issue before?
I am not familiar with the tool you are using but it seems the last line in the output excerpt you provided gives the best information:
FileNotFoundError: [WinError 3] The system cannot find the path specified:'C:///Users/*****/*****/app/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/node_modules/proto-list'
That path looks to be malformed with extra slashes and directory names that are not valid within the file system. Also, the file path is at 227 characters in the output and if the directory names between "Users" and "app" are long enough, you could be hitting the 256 character path name limit in Windows.

Getting TypeError: execve() arg 3 contains a non-string value when trying to run nodejs in sublime text

I am trying to run javascript with sublime text through nodejs plugin, and been getting the following message. I've found this question that seems to be relevant but I still couldn't figure it out. The script is encoded by UTF-8. Thank you.
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
File "./lib/command_thread.py", line 41, in run
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
TypeError: execve() arg 3 contains a non-string value
ps. I am running OS X (10.8).
I had the same problem and it was fixed by putting this in my Nodejs.sublime-settings file (accessible by hitting command+shift+p and selecting Nodejs::User File Settings):
{
"node_path": "/opt/local/lib/",
"node_command": "/opt/local/bin/node"
}
Replace the paths with something that makes sense on your system.

Categories