DFRobot / uPyCraft_src

137 stars 82 forks source link

"Please install SourceCodePro font" error message #14

Open SensorsIot opened 5 years ago

SensorsIot commented 5 years ago

"Please install SourceCodePro font" error message pops up at each startup of uPyCraft on Windows 10

mkroiss commented 5 years ago

message pops up after the font was installed on win 10

wally666 commented 5 years ago

true, true

wally666 commented 5 years ago

Solution:

  1. Download and unpack font package 'SourceCodeProFonts' (use Google for it).
  2. Copy 'SourceCodePro-Regular.ttf' next to 'uPyCraft_V1.1.exe' and rename it to 'SourceCodePro.ttf'
  3. Run 'uPyCraft_V1.1.exe'
  4. Select 'Yes' when Popup appear
  5. In font viewer window choose install font button
  6. Done.
vvkuryshev commented 5 years ago

Unfortunately, this solution doesn't work.

bertlderschreckliche commented 5 years ago

Worked for me. Using uPyCraft V1.0 on Windows 10

vvkuryshev commented 5 years ago

uPyCraft V1.1 with Win10 (1809, build 17763.253) repeat asking for font installation again an again.

dachshund-digital commented 5 years ago

Fix this please. This really needs to be fixed.

Kabron287 commented 5 years ago

Solution:

  1. Download and unpack font package 'SourceCodeProFonts' (use Google for it).
  2. Copy 'SourceCodePro-Regular.ttf' next to 'uPyCraft_V1.1.exe' and rename it to 'SourceCodePro.ttf'
  3. Run 'uPyCraft_V1.1.exe'
  4. Select 'Yes' when Popup appear
  5. In font viewer window choose install font button
  6. Done.

What a fucking advice? Now it's impossible to use due to giant letters.

dachshund-digital commented 5 years ago

Yeah, the solution does not work, has been documented by many that IT DOES NOT WORK, and nothing but silence so far from the developers. This one of the reasons that open source solutions some times are a horrible option. Let me state it again... right now... the stated solution DOES NOT WORK with 1.0 or 1.1 on Windows 10 (current). It is clear that the issue is with uPyCraft, since the font is DEFINITELY INSTALLED per the Windows environment.

barbudor commented 5 years ago

@dachshund-digital : "It is clear that the issue is with uPyCraft, since the font is DEFINITELY INSTALLED per the Windows environment." If you are an expert in QT and Python, you may better help the community by forking, fixing the code and sending a push request.

I have uPyCraft v1.1 with SourceCodePro.ttf installed in Windows and I don't have any more the error message which is the topic of this issue. So as far as I'm concerned the issue is closed.

johannesrave commented 5 years ago

I have the font installed and get the error message as well. Using uPyCraft 1.1 on Windows 10.

barbudor commented 5 years ago

I have the font installed and doesn't get the message on either Win7 or Win10. Are you sure that the font is properly installed ? Can you select it in another app such as wordpad or word?

johannesrave commented 5 years ago

I checked in Krita, LibreOffice and C:\System\Fonts - the font is definitely installed. I recentely had problems making fonts that WEREN'T installed to C:\System\Fonts show up in Inkspace - it seems something had changed regarding user-based Windows 10-font managment, so maybe something is going on there?

barbudor commented 5 years ago

I had to install the font with admin privilege and manually. Installing it from the window that popped up from uPyCraft didn't worked. But as far as you see the font in other programs it should mean it is installed. It seems the font file as to be named SourceCodePro.ttf without any other attribute (no '-regular' or other stuff) At least this how it is on my Win10 PC

Kabron287 commented 5 years ago

To stop missunderstandings, maybe better to share here correct font file?

barbudor commented 5 years ago

Here is the file I'm using : https://1drv.ms/u/s!Auf-S164xmLJhKFp_UbfZmAMernazA

dachshund-digital commented 5 years ago

Installed the 'newer' font per link above, Windows 10 told me I was replacing and existing font, which is correct since I had it installed previously. Then executed uPyCraft. Still the same popup dialog asking for font to be installed. I think you need to review the code in uPyCraft that attempts to determine if the font is in fact installed. I suspect you tested on a copy of Windows 10 that was not fully updated? I am using Windows 10 Pro 64 bit version 1809 (OS build 17763.379).

dachshund-digital commented 5 years ago

Are you installing for a single user or install for all users? There is a difference. Install for all users should not be required, your code maybe looking for validation in the wrong way if you require font installed for all users. Testing... popup now does NOT appear if font is installed for all users, but DOES appear if font only installed for current user. You need to change your code. Install for all users is NOT a privilege that users will have by default. I had to invoke privileged access to install font for all users. It appears your code design is not compliant with Microsoft stated guidelines for single user versus all user scopes.

barbudor commented 5 years ago

Hi 1st to clarify I am a user like you but quite a satisfied one. So not my code. Indeed I've installed the font for all users because 1) I didn't know about another way 2) I am my own PC admin Regarding the code, I have no idea where to look and I'm still fighting to be able to rebuild because it looks like the code requires Python 3.4 and I have 3.7 installed. This might also be a limitation of QT (who knows). If you have a better idea where to fix, I'm sure the owner will appreciate a pull request.

dachshund-digital commented 5 years ago

The code that displays to warning dialog about the font not being installed is that core to the application?

dachshund-digital commented 5 years ago
def setFont(self):
    fonts=None
    if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):#for windows
        FONTDIRS=os.path.join(os.environ['WINDIR'],'Fonts')
        fonts=os.listdir(FONTDIRS)
        flags=False
    elif sys.platform.startswith('darwin'):#for mac
        FONTDIRS=rootDirectoryPath+"/Library/Fonts"
        fonts=os.listdir(FONTDIRS)
        flags=False
    if fonts==None:
        return
    for filename in fonts:
        if(filename.upper().find('SOURCECODEPRO.TTF')==0):
            flags=True
            break
    if flags is False:
        checkfont=QMessageBox.question(self,"SourceCodePro Font",  
                                "Please install SourceCodePro font",
                                QMessageBox.Ok|QMessageBox.Cancel,  
                                QMessageBox.Ok)  
        if checkfont==QMessageBox.Ok:
            ttf=binascii.unhexlify(SourceCodePro)
            try:
                fp=open(rootDirectoryPath+'/Desktop/'+'SourceCodePro.ttf','wb')
                fp.write(ttf)
                fp.close()
                if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
                    os.system('SourceCodePro.ttf')
                elif sys.platform.startswith('darwin'):
                    subprocess.call(['open',rootDirectoryPath+'/Desktop/'+'SourceCodePro.ttf'])
                #os.remove("SourceCodePro.ttf")
            except:
                print("install ttf false.")

    font=QFont(self.tr("Source Code Pro"),10)
    QApplication.setFont(font)

Clearly when the application tries to install the font, it can't, hence the repeated warning/prompt dialog. Moreover, when the font is installed only under current user in Windows 10, it is in a location that the above code does not see or understand. As my testing experience showed, when I installed the font for all users (similar to your experience), only then did the above code find the font as already installed, hence no warning/dialog presented.

Security in Windows, especially in Windows 10, is severely controlled in reference to font installation, because you can actually embed malware in font files. I do not see any where in the above code the the in application installation attempt, enhanced privilege is requested by the application from the operating system which would allow installation by all user scenario. So at a minimum, the attempt of the application to install the font should be changed or removed.

Discussion of how to do privilege access request or impersonation as the Microsoft API references it, is a rather deep subject, which I will not itemize here. To correct this in a proper manner, is not going to be trivial.

Suggestions, one of these:

1) Remove the application attempt to install the font. Make user install font correctly from Windows. 2) Add code to have application request administrative access, before installation attempt, this is tricky to consistently implement 3) Warning at application start up the if font is missing, administrative access is required, and exit application. Thus the user must run application at an administrative level.

Per the Microsoft API guidelines, the best practice would #1 above. Thus the application should not attempt to install the font its self. The application should then just check for the font existence in a consistent manner for current user and all users in turn.

barbudor commented 5 years ago

Look at the code you identified, it seems they are looking for the font in a speocifc directory which I agreee is wrong. Would be better to try/catch around the last to lines

If I only could succeed in installing PyQt4 I could try the changes...

ruegi commented 5 years ago

The same error occured for me. But the source-code helped out: It is looking for a file called 'SourceCodePro.ttf'. But SourceCodePro is a whole family of fonts. The one font recommended for uPyCraft was 'SourceCodePro_Regular-0.ttf' on my system. I replaced it with 'SourceCodePro.ttf' and the error message was gone. (It was a bit strange for me, that the code excpects the file "SourceCodePro.ttf" on the Desktop!? IMHO simply a hint for the missing file would be better...)

devel-itwca commented 5 years ago

Late to the game, but renaming the file to SourceCodePro.ttf and installing it didn't work for me, as others.

But - installing for all users was the trick for me. No more error message.

uPyCraft 1.1, on Win10 Home, v1809.

2019-05-27 12_44_26-Source_Code_Pro

vvkuryshev commented 5 years ago

Yes, installation for all users solved the problem for me too. uPyCraft 1.1, Win10 Home (1809, build 17763.615).