Terminal-Icons icon indicating copy to clipboard operation
Terminal-Icons copied to clipboard

QuickStart Guide

Open potatoqualitee opened this issue 5 years ago • 2 comments

Thanks so much for the module! I want exactly what's in the screenshot on Twitter. Can you create QuickStart guide on how to do that? Which font you used, etc. That way we can expand into the module slowly?

potatoqualitee avatar Jun 10 '19 11:06 potatoqualitee

Definitely @potatoqualitee! I see others are having issues with getting the fonts working as well. I'll try to make that process clear.

devblackops avatar Jun 10 '19 15:06 devblackops

It's been a bit painful trying to get this to work today. Only a limited number of fonts seem to be viable and fonts like Consolas seem to refuse to patch in a compatible manner.

However, I think I've successfully patched Lucida Console now. I have icons in PS 5 and 6 and it's very pretty.

You are welcome to the how-to I made for my colleagues if it helps at all :)

How to: Patch Lucida Console font

Clone nerd-fonts

This creates a shall clone of the nerd-fonts repository. This is a large repository and may take some time to clone, even with depth set to 1.

Pull request 288 includes a fix for mono-spaced fonts compatible with conhost (powershell, cmd.exe, and so on).

git clone --depth 1 [email protected]:ryanoasis/nerd-fonts.git
Push-Location nerd-fonts
git fetch origin --depth 1 pull/288/head:monospace-fixed
git checkout monospace-fixed

Enable TLS1.2 on PowerShell 5

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 'Tls12'

Acquire portable fontforge

$params = @{
    Uri     = 'https://iweb.dl.sourceforge.net/project/fontforgebuilds/x86_64/Portable/FontForge-mingw-w64-x86_64-65163d-r1.7z'
    OutFile = '.\fontforge.7z'
}
Invoke-WebRequest @params

Unzip using 7-zip

The method below uses chocolatey to install 7-zip. This may be substituted or skipped as appropriate.

The archive content is unzipped to the current directory, nerd-fonts.

#Requires -RunAsAdministrator

choco install 7zip.portable -y
7z x -o"$($pwd)" fontforge.7z

Fix-up environment variables

$env:PYTHONHOME = $pwd
$env:PYTHONPATH = Join-Path $pwd 'lib\python3.7'
$env:PATH = '{0};{0}\bin;{1}' -f $pwd, $env:PATH

Patch Lucidia

New-Item patched -ItemType Directory
ffpython font-patcher -s -c -w c:\windows\fonts\lucon.ttf -out .\patched

Install the font

#Requires -RunAsAdministrator

$shell = New-Object -ComObject Shell.Application
$fontsFolder = $shell.Namespace(0x14)

Get-ChildItem patched | ForEach-Object {
    $fontsFolder.CopyHere($_.FullName)
}

Add the font to the built-in console list

#Requires -RunAsAdministrator

$fonts = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts').PSObject.Properties
Get-ChildItem patched | ForEach-Object {
    $fontName =  $fonts |
        Where-Object Value -like ('{0}*' -f $_.BaseName) |
        ForEach-Object { $_.Name -replace ' \(.+$' }

    $params = @{
        Path  = $path = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont'
        Name  = '{0}0' -f ((Get-ItemProperty -Name '0*' -Path $path).PSObject.Properties.Match('0*').Name | Sort-Object { $_.Length } | Select-Object -Last 1)
        Value = $fontName
    }
    Set-ItemProperty @params
}

indented-automation avatar Jun 12 '19 15:06 indented-automation