Jump to content

Fontları Katılımsız Yapmak


MAKINCI
 Share

Recommended Posts

Selamün Aleyküm;

 

Arkadaşlar fontları yani yazı tiplerini katılımsız yapmak istiyorum ama olmuyor...

 

Denediğim uygulamalar;

 

Autoit

FileInstall

FileCopy

 

Winrar, 7zip

SFX

 

Bu proğramlarla denememe rağmen ilgili fontları C:\Windows\Fonts dizinine birtürlü kopyalatamadım,

 

Fikri olan varmıdır arkadaşlar...

Link to comment
Share on other sites

Kullanımı:
 

InstallFont("\\server.local\Software\_Install\_Default\1\CORPORATE FONT\*.*")

Func InstallFont($sSourceFile, $sFontDescript="", $sFontsPath="")
Local Const $HWND_BROADCAST = 0xFFFF
Local Const $WM_FONTCHANGE = 0x1D

If $sFontsPath = "" Then $sFontsPath = @WindowsDir & "\fonts"

Local $sFontName = StringRegExpReplace($sSourceFile, "^.*\\", "")
If Not FileCopy($sSourceFile, $sFontsPath & "\" & $sFontName, 1) Then Return SetError(1, 0, 0)

Local $hSearch = FileFindFirstFile($sSourceFile)
Local $iFontIsWildcard = StringRegExp($sFontName, "\*|\?")
Local $aRet, $hGdi32_DllOpen = DllOpen("gdi32.dll")

If $hSearch = -1 Then Return SetError(2, 0, 0)
If $hGdi32_DllOpen = -1 Then Return SetError(3, 0, 0)

While 1
$sFontName = FileFindNextFile($hSearch)
If @error Then ExitLoop

If $iFontIsWildcard Then $sFontDescript = StringRegExpReplace($sFontName, "\.[^\.]*$", "")

$aRet = DllCall($hGdi32_DllOpen, "Int", "AddFontResource", "str", $sFontsPath & "\" & $sFontName)
If IsArray($aRet) And $aRet[0] > 0 Then
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", _
$sFontDescript, "REG_SZ", $sFontsPath & "\" & $sFontName)
EndIf
WEnd

DllClose($hGdi32_DllOpen)
DllCall("user32.dll", "Int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_FONTCHANGE, "int", 0, "int", 0)
Return 1
EndFunc

#RequireAdmin eklemeyi unutmayın. Kodları kendinize göre düzenleyebileceğinizi düşündüğümden açıklama vermedim. Gerekirse verebilirim.
Link to comment
Share on other sites

#RequireAdmin eklemeyi unutmayın
çeşitli örnekler var  :)

hangisi uyarsa başka işletim sisteminde deneme şansım olmadığı için

en iyisi size uyar bilemiyorum

kendine göre uyarla :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)

Global $guititle = 'Install Fonts Manager'

Local $hForm = GUICreate($guititle, 363, 112, -1, 200)
GUISetIcon(@ProgramFilesDir&'\AutoIt3\Aut2Exe\Icons\AutoIt_Old4.ico', "", $hForm)
WinSetOnTop($guititle, "", 1)
Local $Input = GUICtrlCreateInput("", 16, 32, 249, 21)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("Fonts Dir path", 112, 15, 70, 17)
Local $Btn_sel = GUICtrlCreateButton("Browse", 272, 32, 75, 25, $WS_GROUP)
Local $Btn_ins = GUICtrlCreateButton("Insatll", 128, 72, 75, 25, $WS_GROUP)
GUICtrlSetCursor (-1, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
TraySetIcon(@ProgramFilesDir&'\AutoIt3\Aut2Exe\Icons\AutoIt_Old4.ico', "")
While 1
   Local $nMsg = GUIGetMsg()
   Switch $nMsg
	  Case $GUI_EVENT_CLOSE
		 GUIDelete()
		 Exit
		Case $Btn_sel
		  Local $dialog_text = 'Choose a folder new fonts'
			Local $source_dir = FileSelectFolder($dialog_text, "", "", "", $hForm)
		 If @error = 1 Then ContinueLoop
		 GUICtrlSetData($Input, $source_dir)
		 GUICtrlSetState($Btn_ins, $GUI_ENABLE)
	  Case $Btn_ins
			Local $dest_dir = @WindowsDir&'\Fonts'
		 Local $chk_err = DirCopy($source_dir, $dest_dir, 1)
		 If $chk_err = 1 Then
			MsgBox(64, "", "Installation fonts complete.", 0, $hForm)
			_reset()
		 Else
			MsgBox(48, "Error!", "Cannot install fonts.", 0, $hForm)
			_reset()
		 EndIf
   EndSwitch
WEnd

Func _reset()
   GUICtrlSetData($Input, "")
   GUICtrlSetState($Btn_ins, $GUI_DISABLE)
EndFunc

 
 

#Include <WinAPIEx.au3>

ConsoleWrite(_FontInstall('MyFont.ttf') & @CR)

Func _FontInstall($sFile)

    Local $Font, $Name, $Path

    $Name = _WinAPI_GetFontResourceInfo($sFile, 1)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    $Name &= ' (TrueType)'
    $Font = StringRegExpReplace($sFile, '^.*\\', '')
    If Not RegWrite('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', $Name, 'REG_SZ', $Font) Then
        Return SetError(2, 0, 0)
    EndIf
    $Path = _WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS)
    If Not FileCopy($sFile, $Path) Then
        RegDelete('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', $Name)
        Return SetError(3, 0, 0)
    EndIf
    If Not _WinAPI_AddFontResourceEx($Path & '\' & $Font, 0, 1) Then
        Return SetError(4, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_FontInstall

 

#Include <APIConstants.au3>
#Include <StaticConstants.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
FileCopy("myfont.ttf", @WindowsDir & "Fonts")
_WinAPI_AddFontResourceEx(@WindowsDir & 'Fontsmyfont.ttf', $FR_PRIVATE, 1)

 

Const $FONTS = 0x14
$oShell = ObjCreate("Shell.Application")
$oWinFonts = $oShell.Namespace($FONTS)
; The fonts must be in the same directory
$sFirstFile = FileFindFirstFile("*.*")
If $sFirstFile = -1 Then
Exit
EndIf
While 1
Local $sFile = FileFindNextFile($sFirstFile)
If @error Then ExitLoop
Switch StringRight($sFile, 3)
Case 'ttf', 'otf', 'pfm', 'fon'
	 $sWinFontsPath = @WindowsDir & 'Fonts' & $sFile
	 $sLocFontsPath = @ScriptDir & '' & $sFile
	 If NOT FileExists($sWinFontsPath) Then
		 $oWinFonts.CopyHere($sLocFontsPath)
	 Else
		 MsgBox(262144, $sFile, 'The file is already installed', 1)
	 EndIf
EndSwitch
WEnd
Edited by mesale0077
Link to comment
Share on other sites

#Include <File.au3>

$_Dir = FileSelectFolder ( "Choose the folder where are fonts to install.", @DesktopDir )
If Not FileExists ( $_Dir ) Then Exit
$_Filelist = _FileListToArray ( $_Dir, "*.ttf", 1 )
If Not IsArray ( $_Filelist ) Or @Error Then Exit MsgBox ( 0, "", "No Files\Folders Found." )

For $_I = 1 To  $_Filelist[0]
    $_Installed = _InstallFont ( $_Dir & "\" & $_Filelist[$_I] )
    If Not $_Installed Then ConsoleWrite ( "Install Font of " & $_Filelist[$_I] & " : " & $_Installed & @LF )
Next

Func _InstallFont ( $sSourceFile, $sFontDescript="", $sFontsPath="" )
    Local Const $HWND_BROADCAST = 0xFFFF
    Local Const $WM_FONTCHANGE = 0x1D
    If $sFontsPath = "" Then $sFontsPath = @WindowsDir & "\fonts"
    Local $sFontName = StringRegExpReplace ( $sSourceFile, "^.*\\", "" )
    If Not FileCopy ( $sSourceFile, $sFontsPath & "\" & $sFontName, 1 ) Then Return SetError ( 1, 0, 0 )
    Local $hSearch = FileFindFirstFile ( $sSourceFile )
    Local $iFontIsWildcard = StringRegExp ( $sFontName, "\*|\?" )
    Local $aRet, $hGdi32_DllOpen = DllOpen ( "gdi32.dll" )
    If $hSearch = -1 Then Return SetError ( 2, 0, 0 )
    If $hGdi32_DllOpen = -1 Then Return SetError ( 3, 0, 0 )
    While 1
        $sFontName = FileFindNextFile ( $hSearch )
        If @error Then ExitLoop
        If $iFontIsWildcard Then $sFontDescript = StringRegExpReplace ( $sFontName, "\.[^\.]*$", "" )
        $aRet = DllCall ( $hGdi32_DllOpen, "Int", "AddFontResource", "str", $sFontsPath & "\" & $sFontName )
        If IsArray ( $aRet ) And $aRet[0] > 0 Then RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", $sFontDescript, "REG_SZ", $sFontsPath & "\" & $sFontName )
    WEnd
    DllClose ( $hGdi32_DllOpen )
    DllCall ( "user32.dll", "Int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_FONTCHANGE, "int", 0, "int", 0 )
    Return 1
EndFunc ; _InstallFont ( )
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...