pycocoa.fonts

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

# Module fonts

Type Font, etc., wrapping ObjC `NSFont`.

Version: 21.11.04

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 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 (`str`s), case-insensitive. Returns: Combined traits (`FontTrait` `s mask`). Raises: `FontTraitError` - One or more traits are invalid.

### fontTraitstrs(traits) |
Return font traits as names. Parameters: `traits` - Traits (`FontTrait` `s mask`). Returns: Tuple of trait names (`str`s).

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({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}),
      ...