You can use the GetCurrentConsoleFont
, information such as the numeric source index in the console font table will be returned, and # and height information.
Declare namespace :
Imports System.Runtime.InteropServices
Declare the structures:
Public Structure Coord
Dim X As Short
Dim Y As Short
End Structure
Public Structure _CONSOLE_FONT_INFO
Dim nFont As Integer
Dim dwFontSize As Coord
End Structure
Declare the functions:
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Function GetStdHandle(ByVal nStdHandle As Integer) As Integer
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Function GetCurrentConsoleFont(ByVal hConsoleOutput As Integer,
ByVal bMaximumWindow As Boolean,
ByRef lpConsoleCurrentFont As _CONSOLE_FONT_INFO) As Boolean
End Function
Declare the constant:
Private Const STD_OUTPUT_HANDLE As Integer = -11&
In the main function, do:
Sub Main()
Dim CurrentFont As _CONSOLE_FONT_INFO
Dim Coordenadas As Coord
Dim hConsoleOut As Integer = GetStdHandle(STD_OUTPUT_HANDLE)
Dim ObterFonte As Boolean = GetCurrentConsoleFont(hConsoleOut, False, CurrentFont)
If (ObterFonte) Then
Coordenadas = CurrentFont.dwFontSize
Console.WriteLine("X: {0} / Y: {1}", Coordenadas.X, Coordenadas.Y)
Else
Console.WriteLine("Não foi possível obter as informações sobre a fonte deste Console.")
End If
Console.ReadKey()
End Sub
For a wider range of information, use function COORD
.