Почему запуск PowerShell меняет мой консольный шрифт?

1861
Bevan

У меня странная проблема на моем ноутбуке - когда я запускаю Powershell в существующем окне консоли, выбор шрифта для окна меняется.

Например, это cmd.exe сразу после открытия окна: командная консоль при открытии

Шрифты, размер окна и используемые цвета являются правильными - шрифт Lucida Console в 16pt.

Затем я бегу, PowerShellи вот результат:

Почему запуск PowerShell меняет мой консольный шрифт?

Шрифт Raster Font изменился на 12x16 пикселей! Другие свойства окна - цвета, количество строк, количество столбцов - остаются неизменными.

Есть идеи, почему он переключается?

Примечание: во время исследования этого вопроса - поскольку растровый шрифт ужасно уродлив, и это меня беспокоит - я обнаружил, что другие сообщали о проблемах с установкой шрифта для окна консоли powershell (например, вопрос « Невозможно изменить стандартный шрифт powershell на Lucida Console »). Хотя моя проблема в другом (так как я запускаю Powershell из существующего окна консоли, а не со стартового экрана), я подозреваю, что решение одного может помочь другому.

13
Вы можете использовать ConEmu и вообще избежать этой проблемы. dangph 10 лет назад 0
@ChrisLively ах, я не понял, что ответ был опубликован только сегодня. По некоторым причинам я думал, что это было намного старше. я удалю свой комментарий barlop 9 лет назад 0

2 ответа на вопрос

2
Ozzy S

I was having the exact same problem and it was driving me nuts. Here is what I did to correct it, hopefully it will work for you too:

1.) While in cmd.exe, run the powershell command.

2.) While at the powershell prompt in cmd.exe, go to the settings and change the font to Lucida Console.

3.) Exit the powershell prompt and while still in cmd.exe go to the settings and change the font to Lucida Console.

4.) As an extra step for good measure I ran start powershell from cmd.exe and changed the font there also.

5.) Smile now that my OCD is able to take a rest. Now when I go to start->run->cmd.exe and use the powershell command, it stays at Lucida Console.

I restarted the computer and reopened everything, and so far it seems to be sticking for me.

I hope that this helps you on your quest =)

Большое спасибо за предложение - но это не имело никакого значения на моем ноутбуке. :-( Bevan 9 лет назад 1
1
Pimp Juice IT

This is FYI at least in case it helps anyone for a quick resolution. This may not answer the WHY but it gives a way to potentially fix or fix quickly moving forward if or as-needed.

Go to TechNet SetConsoleFont and see the details there and then follow the instructions below and look at the resources section below as well.

This is where the SetConsoleFont module comes in. Before you can use the Set-ConsoleFont cmdlet, you have to import the module. First, copy the module to a local editor. Note that when I copied the text, the last line had an unwanted line break. Make sure that the last line of the module looks like this:

Export-ModuleMember -Variable _DefaultFont, _hConsoleScreen -Function Set-ConsoleFont, Get-ConsoleFontInfo 

Next, you have to store the file in your module folder. With $env:PSModulePath on a PowerShell console, you can get a list of your module folders. For instance, you can store the SetConsoleFont module in the PowerShell module folder in the Documents directory using the file name SetConsoleFont.psm1, like this:

%USERPROFILE%\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1 

Then, you can import the module with:

Import-Module SetConsoleFont 

You can now get a list of the available fonts and their dimensions with:

Get-ConsoleFontInfo | Format-Table -AutoSize 

To set a font size, you have to choose a number from the nFont column:

Set-ConsoleFont 8 

To change your font size to the default, you can run Set-ConsoleFont without an argument

RESOURCES