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

Module fonts

Type Font, etc., wrapping ObjC NSFont.


Version: 20.01.08

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=1<...
Font traits (mask).
  Fonts = Fonts.App=Font(name='Helvetica', family='Helvetica', s...
Pre-defined system fonts (Font).
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 traits (mask).
Value:
FontTrait.Bold=1<<1,
         .Compressed=1<<9,
         .Condensed=1<<6,
         .Expanded=1<<5,
         .Italic=1,
         .MonoSpace=1<<10,
         .Narrow=1<<4,
         .Poster=1<<8,
...

Fonts

Pre-defined system fonts (Font).
Value:
Fonts.App=Font(name='Helvetica', family='Helvetica', size=12, weight=5\
),
     .Bold=Font(name='.AppleSystemUIFontBold', family='.AppleSystemUIF\
ont', size=13, traits='Bold', weight=9),
     .BoldItalic=Font(name='.AppleSystemUIFontEmphasizedItalic', famil\
y='.AppleSystemUIFont', size=13, traits='Bold Italic', weight=9),
     .Italic=Font(name='.AppleSystemUIFontItalic', family='.AppleSyste\
mUIFont', size=13, traits='Italic', weight=5),
...