Package pycocoa :: Module fonts
[frames] | no frames]

Module fonts

Type Font, etc., wrapping ObjC NSFont.


Version: 25.05.27

Classes
  Font
Python Font Type, wrapping ObjC NSFont.
  FontError
Font selection error.
  FontTraitError
Font traits error.
Functions
 
fontfamilies(*prefixes)
Yield the installed font families.
 
fontnamesof(family)
Yield the available font names of a family.
 
fontsof(family, size=0, weight=None)
Yield the available fonts of a family.
 
fontsof4(family)
Yield the available fonts of a family.
 
fontTraits(*traits)
Return a font traits mask for the named traits.
 
fontTraitstrs(traits)
Return font traits as names.
Variables
  __all__ = _ALL_LAZY.fonts
  FontTrait = FontTrait.Bold...
Font trait constants (mask).
  Fonts = Fonts.App=Font({family='Helvetica', name='Helvetica', ...
Pre-defined system fonts, all Font instances.
  FontTrait.Bold
0x2
  FontTrait.Compressed
0x200
  FontTrait.Condensed
0x40
  FontTrait.Expanded
0x20
  FontTrait.Italic
0x1
  FontTrait.MonoSpace
0x400
  FontTrait.Narrow
0x10
  FontTrait.Poster
0x100
  FontTrait.SansSerif
0x80000000
  FontTrait.SmallCaps
0x80
  FontTrait.UnBold
0x4
  FontTrait.UnItalic
0x1000000
  Fonts.App
Get the UserFont.
  Fonts.Bold
Get the BoldFont.
  Fonts.BoldItalic
Get the BoldItalicFont.
  Fonts.Italic
Get the ItalicFont.
  Fonts.Label
Get the LabelFont.
  Fonts.Menu
Get the MenuFont.
  Fonts.MenuBar
Get the MenuBarFont.
  Fonts.Message
Get the MessageFont.
  Fonts.MonoSpace
Get the MonoSpaceFont.
  Fonts.Palette
Get the PaletteFont.
  Fonts.System
Get the SystemFont.
  Fonts.TableData
Get the TableDataFont.
  Fonts.TableHeader
Get the TableHeaderFont.
  Fonts.Title
Get the TitleFont.
Function Details

fontfamilies(*prefixes)

 

Yield the installed font families.

Parameters:
  • prefixes - No, one or more font family names to match (str-s).
Returns:
Each font family name (str).

fontnamesof(family)

 

Yield the available font names of a family.

Parameters:
  • family - Generic font name (str), like "Times" or "Helvetica".
Returns:
The name (str) of each font.

fontsof(family, size=0, weight=None)

 

Yield the available fonts of a family.

Parameters:
  • family - Generic font name (str), like "Times" or "Helvetica".
  • size - The point size (int), zero for any.
  • weight - The book weight (int), None for any.
Returns:
A (Font) instance for each font.
Raises:
  • ValueError - Invalid weight.

fontsof4(family)

 

Yield the available fonts of a family.

Parameters:
  • family - Generic font name (str), like "Times" or "Helvetica".
Returns:
4-Tuple (name, attributes, weight, traits) of (str, str, int, int) for each font.

fontTraits(*traits)

 

Return a font traits mask for the named traits.

Parameters:
  • traits - Trait names (strs), case-insensitive.
Returns:
Combined traits (FontTraits mask).
Raises:

fontTraitstrs(traits)

 

Return font traits as names.

Parameters:
  • traits - Traits (FontTraits mask).
Returns:
Tuple of trait names (strs).

Variables Details

FontTrait

Font trait constants (mask).
Value:
FontTrait.Bold=2,
         .Compressed=512 or 1<<9,
         .Condensed=64 or 1<<6,
         .Expanded=32 or 1<<5,
         .Italic=1,
         .MonoSpace=1024 or 1<<10,
         .Narrow=16 or 1<<4,
         .Poster=256 or 1<<8,
...

Fonts

Pre-defined system fonts, all Font instances.
Value:
Fonts.App=Font({family='Helvetica', name='Helvetica', size=12, weight=\
5}),
     .Bold=Font({family='.AppleSystemUIFont', name='.AppleSystemUIFont\
Bold', size=13, traits='Bold', weight=9}),
     .BoldItalic=Font({family='.AppleSystemUIFont', name='.AppleSystem\
UIFontEmphasizedItalic', size=13, traits='Bold Italic', weight=9}),
     .Italic=Font({family='.AppleSystemUIFont', name='.AppleSystemUIFo\
ntItalic', size=13, traits='Italic', weight=5}),
...