Re: [python-win32] Load custom font

2022-06-09 Thread Steven Manross
Sorry…

But, I need to Give credit where credit is due.

https://superuser.com/questions/1432800/get-actual-font-name-of-ttf-file-from-command-line

From: python-win32  On 
Behalf Of Steven Manross
Sent: Thursday, June 9, 2022 12:24 PM
To: Jérémie Bergeron ; python-win32@python.org
Subject: Re: [python-win32] Load custom font

Here’s a more windows centric approach and it foreaches through all the Windows 
fonts:
  ** It’s interesting that it says that it was last modified today…  odd, but 
whatever

from win32com.client.dynamic import Dispatch

ids = 
[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]

shell_app = Dispatch('Shell.Application')
shell_app.Namespace('c:\\windows\\fonts')
folder = shell_app.Namespace('c:\\windows\\fonts')
myfile = ""

for font in folder.Items():
print(font.Name)
#if font.Name == "Verdana":
#break

for num in ids:
val = None
val = folder.GetDetailsOf(font, num)
item = folder.GetDetailsOf(None, num)
if val:
print("\t", num, f'{item} = {val}')

**
partial output:
**
Verdana
 0 Name = Verdana
 1 Font style = Regular; Bold; Bold Italic; Italic
 2 Show/hide = Show
 3 Designed for = Latin; Greek; Cyrillic
 4 Category = Text
 5 Designer/foundry = Carter + Cone
 6 Font embeddability = Editable
 10 Date modified = ‎6/‎9/‎2022 ‏‎11:16 AM

From: python-win32 
mailto:python-win32-bounces+steven=manross@python.org>>
 On Behalf Of Jérémie Bergeron
Sent: Wednesday, June 8, 2022 6:28 AM
To: python-win32@python.org
Subject: [python-win32] Load custom font

Hi,

Is it possible to get the family name of a font and/or any other information 
from the naming table from a font file?

Something like that:
font = win32ui.loadFont(pathToTheFont)
familyName = font.getNameId(1)

Have a nice day
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Load custom font

2022-06-09 Thread Steven Manross
Here’s a more windows centric approach and it foreaches through all the Windows 
fonts:
  ** It’s interesting that it says that it was last modified today…  odd, but 
whatever

from win32com.client.dynamic import Dispatch

ids = 
[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]

shell_app = Dispatch('Shell.Application')
shell_app.Namespace('c:\\windows\\fonts')
folder = shell_app.Namespace('c:\\windows\\fonts')
myfile = ""

for font in folder.Items():
print(font.Name)
#if font.Name == "Verdana":
#break

for num in ids:
val = None
val = folder.GetDetailsOf(font, num)
item = folder.GetDetailsOf(None, num)
if val:
print("\t", num, f'{item} = {val}')

**
partial output:
**
Verdana
 0 Name = Verdana
 1 Font style = Regular; Bold; Bold Italic; Italic
 2 Show/hide = Show
 3 Designed for = Latin; Greek; Cyrillic
 4 Category = Text
 5 Designer/foundry = Carter + Cone
 6 Font embeddability = Editable
 10 Date modified = ‎6/‎9/‎2022 ‏‎11:16 AM

From: python-win32  On 
Behalf Of Jérémie Bergeron
Sent: Wednesday, June 8, 2022 6:28 AM
To: python-win32@python.org
Subject: [python-win32] Load custom font

Hi,

Is it possible to get the family name of a font and/or any other information 
from the naming table from a font file?

Something like that:
font = win32ui.loadFont(pathToTheFont)
familyName = font.getNameId(1)

Have a nice day
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Load custom font

2022-06-09 Thread Steven Manross
While this isn't win32ui, I hope it helps.

pip install Pillow

from PIL import ImageFont
font = ImageFont.truetype("c:\\windows\\Fonts\\verdana.ttf", 28, 
encoding="unic")
font.font.family
font.font.height
font.font.style

google search revealed this:

https://stackoverflow.com/questions/24085996/how-i-can-load-a-font-file-with-pil-imagefont-truetype-without-specifying-the-ab

HTH

Steven
From: python-win32  On 
Behalf Of Jérémie Bergeron
Sent: Wednesday, June 8, 2022 6:28 AM
To: python-win32@python.org
Subject: [python-win32] Load custom font

Hi,

Is it possible to get the family name of a font and/or any other information 
from the naming table from a font file?

Something like that:
font = win32ui.loadFont(pathToTheFont)
familyName = font.getNameId(1)

Have a nice day
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Load custom font

2022-06-09 Thread Jérémie Bergeron
Hi,

Is it possible to get the family name of a font and/or any other information 
from the naming table from a font file?

Something like that:
font = win32ui.loadFont(pathToTheFont)
familyName = font.getNameId(1)

Have a nice day
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32