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

Module fonts

Type Font, etc., wrapping ObjC NSFont.


Version: 25.01.25

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({<generator object <genexpr> at 0x7ff1b...
Pre-defined system fonts, all Font instances.
  FontTrait.Bold
int([x]) -> integer.
  FontTrait.Compressed
int([x]) -> integer.
  FontTrait.Condensed
int([x]) -> integer.
  FontTrait.Expanded
int([x]) -> integer.
  FontTrait.Italic
int([x]) -> integer.
  FontTrait.MonoSpace
int([x]) -> integer.
  FontTrait.Narrow
int([x]) -> integer.
  FontTrait.Poster
int([x]) -> integer.
  FontTrait.SansSerif
int([x]) -> integer.
  FontTrait.SmallCaps
int([x]) -> integer.
  FontTrait.UnBold
int([x]) -> integer.
  FontTrait.UnItalic
int([x]) -> integer.
  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=1<<9,
         .Condensed=1<<6,
         .Expanded=1<<5,
         .Italic=1,
         .MonoSpace=1<<10,
         .Narrow=1<<4,
         .Poster=1<<8,
...

Fonts

Pre-defined system fonts, all Font instances.
Value:
Fonts.App=Font({<generator object <genexpr> at 0x7ff1b8cc9960>}),
     .Bold=Font({<generator object <genexpr> at 0x7ff1b8cc9960>}),
     .BoldItalic=Font({<generator object <genexpr> at 0x7ff1b8cc9960>}\
),
     .Italic=Font({<generator object <genexpr> at 0x7ff1b8cc9960>}),
     .Label=Font({<generator object <genexpr> at 0x7ff1b8cc9960>}),
     .Menu=Font({<generator object <genexpr> at 0x7ff1b8cc9960>}),
     .MenuBar=Font({<generator object <genexpr> at 0x7ff1b8cc9960>}),
...