6

It seems like an easy question, how can I get the actual name of font from command line.

Here is an example. The font filename is segoesc.ttf. However, the actual name of font that shows up in the Font Menu is Segoe Script.

enter image description here

What I have tried:

  1. There is a python script out there, that can get the font name. But I prefer not to have Python dependency.

  2. Right clicking on Fontfile and go to Properties > Details, gives me the list of properties. I tried to use wmic but it does not show Title property.

wmic datafile "c:\Windows\fonts\segoesc.ttf" get Title

Thanks.

2
  • Possibly related: How to list installed font families?
    – nekketsuuu
    Jan 14, 2020 at 12:59
  • invalid query. any idea how i would also get the company, author, copyright, legal trademark, etc fields of metadata from a font file on windows?
    – oldboy
    Jan 22, 2020 at 6:37

3 Answers 3

8

In PowerShell:

(New-Object -TypeName Windows.Media.GlyphTypeface -ArgumentList 'C:\Windows\Fonts\segoesc.ttf').Win32FamilyNames.Values

Returns Segoe Script

Credit to Samuel Leslie and PSWinGlue.

1
  • 4
    Remember to load the assembly first: Add-Type -AssemblyName PresentationCore.
    – arielCo
    Dec 16, 2020 at 13:54
2

Try this small C program compiled with Microsoft Visual C++:

#include <stdlib.h>
#include <stdio.h>

#define QFR_DESCRIPTION 1

/* Link with GDI32 library */
int GetFontResourceInfoW(
    wchar_t* lpszFilename,
    unsigned long* cbBuffer,
    void* lpBuffer,
    unsigned long dwQueryType);

int wmain(int wargc, wchar_t** wargv) {
    int res = 0, size = 0;

    if (wargc == 2) {
        res = GetFontResourceInfoW(wargv[1], &size, NULL, QFR_DESCRIPTION);
        wchar_t* buff = malloc(size);
        res = GetFontResourceInfoW(wargv[1], &size, buff, QFR_DESCRIPTION);
        if (res)
            wprintf(L"Description: %ls\n", buff);
        free(buff);
    }

    return 0;
}
  • Command Line example: ProgramName.exe C:\path\to\font.ttf

Further Readings:

1

Every (script) language which is able to handle COM objects (J-/vbscript/PowerShell) can get extended file attributes with Shell.Application

This PowerShell script lists Extended Atrributes typical for font files

$path        = 'A:\segoescb.ttf'
$folder      = Split-Path $path
$file        = Split-Path $path -Leaf

$shell       = New-Object -COMObject Shell.Application
$shellfolder = $shell.Namespace($folder)
$shellfile   = $shellfolder.ParseName($file)

## get (localized) description and value of 
##   specified extended attributes numbers
## (0,2,21,165,166,195) 

(0,1,2,3,4,5,6,9,10,19,21,25,33,34,58,62,165,166,167,170,191,192,193,195,197,203,255)| 
Foreach-Object { 
    '{0,3} {1,-30} = {2}' -f $_,
            $shellfolder.GetDetailsOf($null, $_), 
            $shellfolder.GetDetailsOf($shellfile, $_) 
}

sample (German) output:

  0 Name                           = segoescb.ttf
  1 Größe                          = 567 KB
  2 Elementtyp                     = IrfanView TTF File
  3 Änderungsdatum                 = 2018-04-12 01:34
  4 Erstelldatum                   = 2019-05-07 15:46
  5 Letzter Zugriff                = 2019-05-07 15:46
  6 Attribute                      = AC
  9 Erkannter Typ                  = Nicht angegeben
 10 Besitzer                       = xxxxxxxx\LotPings
 19 Bewertung                      = Nicht bewertet
 21 Titel                          = Segoe Script Bold
 25 Copyright                      = © 2016 Microsoft Corporation. All Rights Reserved.
 33 Firma                          = Microsoft Corporation
 34 Dateibeschreibung              =
 58 Gesamtgröße                    = 0,99 GB
 62 Computer                       = xxxxxxxx (dieser PC)
165 Dateierweiterung               = .ttf
166 Dateiname                      = segoescb.ttf
167 Dateiversion                   = 5.02
170 Freier Speicherplatz           = 998 MB
191 Ordnername                     = A:\
192 Ordnerpfad                     = A:\
193 Ordner                         = A:\
195 Pfad                           = A:\segoescb.ttf
197 Typ                            = IrfanView TTF File
203 Verknüpfungsstatus             = Nicht aufgelöst
255 Verwendeter Speicherplatz      = ‎2%

So the absolute minimum would be 0 or 166 and 21.

4
  • how do i get the individual extended attributes of a font file with a one-liner powershell statement?
    – oldboy
    Jan 22, 2020 at 6:40
  • can it be done in a one-line statement?
    – oldboy
    Jan 22, 2020 at 7:00
  • Believe it or not, none of the extended file attributes are used for "Font name" in that font UI. Often "Title" (21) is the same "Font name", but not always.
    – Jason
    Feb 5, 2020 at 18:17
  • @oldboy: look at Jason's answer and the documentation for GlyphTypeface.
    – arielCo
    Dec 16, 2020 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.