Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 9 Jahren, 1 Monat
Letzter Beitrag:
vor 4 Jahren, 6 Monaten
Beteiligte Autoren:
Pierre, Yogi Yang, Jimbo, GuenterP

Embedding true type font

Startbeitrag von Pierre am 01.04.2009 17:00

Hi everybody,

Can someone help me how I can embed a true type font which i want to use in my Windev project. This true type font will not be available at the clients computer, therefore I need to insert it in the project.

Is that possible?
If not, is there another way?

Best regards,
Pierre

Antworten:


Fonts go into the \Windows\Fonts directory and can be installed during the installation process. If you're an admin, you simply can copy your font into the directory SysDir(srFonts) , so imho this is possible to do even while doing a standard WinDev installation. To programmatically install a font not copied to the srFonts directory: http://www.devx.com/tips/Tip/14736 More info: http://support.microsoft.com/kb/314960/en-us Other installers have commands for font installation, f.i. InnoSetup (freeware!). Regards, Guenter

von Jimbo - am 01.04.2009 18:51
Hi Jimbo,

as I cannot work with visual basic, how can I get a VBP file from the source you gave via that link?
I found under Windev that i need a VBP file which can be converted (To import Visual Basic elements)

Thanks,

Pierre


von Pierre - am 07.04.2009 09:31
Hi Pierre, a late answer is better than nothing:

when starting the application, let's say the main menue, just check for the presence of the font in the font directory:


Static_Version = ExeInfo(exeVersion,"SEPA_Free.exe")
MyString = Replace(FontList(fontDefault),CR," ")
IF Position(MyString,"ClearRead Mono") = 0 THEN
IF YesNo(Yes,"Die Schriftart ClearRead Mono Standard ist nicht installiert!",...
"Diese Schriftart wird unbedingt benötigt!",...
"Bei 'Ja' im aufgehenden Fenster auf [Installieren] klicken",...
"und nach der Installation das Fenster schließen!",...
"*** Dann muss der Computer neu gestartet werden!! ***",...
" Ja: installieren der Schriftart!","Nein: keine Installation!") = Yes THEN
ShellExecute(CompleteDir(fExeDir())+"ClearReadMono_2.ttf")
IF YesNo(Yes,"Der Computer muß nun neu gestartet werden,",...
"damit die Schriftart ClearRead Mono zur Verfügung steht!",...
" Ja: Neustart des Computers JETZT durchführen!",...
"Nein: den Neustart führe ich später selbst durch!") = Yes THEN
HClose("*")
SysShutdown(sysReboot)
END

END
END


The trick is: simply shell-executing a .ttf font name will offer an installation window from the control panel!
Downside: you have to re-start the computer in order to have the font available!!

The main problem is with rights. If the user / the application has not enough rights, it's impossible to simply copy the font to the \Windows\Fonts directory, which would be the most simple way to do an installation of a font.

When making the setup in WinDev, one can define the destination directory of the font as

< srWinDir >\Fonts or < srWindows >\Fonts

but this will be simply ignored. Don't know why, but simply copying the font file to \Windows\Fonts using fCopyFile(...) will not work either, so most probably this is part of the UAC mechanism.

However, there's a Microsoft program
ftp://ftp.microsoft.com/Softlib/MSLFILES/fontinst.exe

Fontinst.exe is in fact a renamed PKUNZIP program and allows to unzip any .zip file and copy it anywhere in the system. The trick here is the fact that it is a DOS-program that gives a sh** on rights and UAC. It 'sees' the file structure of the disk simply like a DOS-Harddisk. Copying to \Windows\Fonts is done with no problem.


Next, of course, would be to execute a good old XCOPY command! In order to get it working you could programmatically build a batch file like FONTINST.BAT and execute it by WinDev's ExeRun(...) command.

Note: both DOS-solutions need a restart of the computer too!


There's another one, just copied the VB-code. Imho, this one could be converted easily to WinDev ..

Try this API....

'To Install....
Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
Private Declare Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String) As Long
Dim AppPath As String
Private Sub Form_Load()

'rowdy
AppPath = App.Path
If Right$(AppPath, 1) "\" Then AppPath = AppPath + "\"
'Add the font to the Windows Font Table
AddFontResource AppPath + "myfont.ttf"
'Write something on the form
Me.AutoRedraw = True
Me.FontName = "myfont"
Me.Print "This is a test!"
End Sub

'to uninstall........
Private Sub Form_Unload(Cancel As Integer)
'Remove the font from the Windows Font Table
RemoveFontResource AppPath + "myfont.ttf"
End Sub

von GuenterP - am 27.10.2013 16:36
Use the API "AddFontResource" and then force update SystemMetric and you will not need to reboot your PC!

von Yogi Yang - am 31.10.2013 11:04
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.