pycocoa.fonts

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

# Module fonts

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

Version: 25.03.18

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 the traits mask for the named traits. |
fontTraitstrs(traits) Return the font trait names for a traits mask. |

Variables
| __all__ = `_ALL_LAZY.fonts`
| FontDesign = `FontDesign.Default`...`` Font design constants (`int`), arbitrary.
| FontTextStyle = `FontTextStyle.Body=`...`` Font text style constants (`int`), arbitrary.
| FontTrait = `FontTrait.Bold`...`` Font trait constants (`mask`).
| FontWeight = `FontWeight.Black=12 or 3<`...`` Font weight constants (`int`).
| Fonts = `Fonts.App=Font.Helvetica(family=Helvetica, size=12, we`...`` Pre-defined system fonts, all Font instances.
| FontDesign.Default 0
| FontDesign.MonoSpaced 1
| FontDesign.Rounded 2
| FontDesign.Serif 3
| FontTextStyle.Body 11
| FontTextStyle.Callout 31
| FontTextStyle.Caption 21
| FontTextStyle.Caption2 22
| FontTextStyle.Footnote 41
| FontTextStyle.Headline 51
| FontTextStyle.HeadlineSub 50
| FontTextStyle.SubHeadline 50
| FontTextStyle.Title 61
| FontTextStyle.Title2 62
| FontTextStyle.Title3 63
| FontTextStyle.TitleExtraLarge 72
| FontTextStyle.TitleExtraLarge2 73
| FontTextStyle.TitleLarge 82
| 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
| FontWeight.Black 12
| FontWeight.Bold 9
| FontWeight.BoldSemi 8
| FontWeight.Hairline 0
| FontWeight.Heavy 15
| FontWeight.Light 0
| FontWeight.Medium 7
| FontWeight.Normal 5
| FontWeight.Regular 5
| FontWeight.SemiBold 8
| FontWeight.Thin 2
| 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`.
| Fonts.TitleBar Get the `TitleBarFont`.

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 family 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 (fontname, attributes, weight, traits) of (`str`, `str`, `int`, `mask`) for each family font.

### fontTraits(*traits) |
Return the traits mask for the named traits. Parameters: `traits` - Trait names (`str`s), case-insensitive. Returns: Combined traits (`mask`). Raises: `FontTraitError` - One or more traits are invalid or incompatible, mutually exclusive.

### fontTraitstrs(traits) |
Return the font trait names for a traits mask. Parameters: `traits` - The traits (`mask`). Returns: Tuple of trait names (`str`s).

Variables Details

  ### FontDesign Font design constants (`int`), arbitrary. Value:
      FontDesign.Default=0,
                .MonoSpaced=1,
                .Rounded=2,
                .Serif=3

  ### FontTextStyle Font text style constants (`int`), arbitrary. Value:
      FontTextStyle.Body=11,
                   .Callout=31,
                   .Caption=21,
                   .Caption2=22,
                   .Footnote=41,
                   .Headline=51,
                   .HeadlineSub=50,
                   .SubHeadline=50,
      ...

  ### 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,
      ...

  ### FontWeight Font weight constants (`int`). Value:
      FontWeight.Black=12 or 3<<2,
                .Bold=9,
                .BoldSemi=8 or 1<<3,
                .Hairline=1,
                .Heavy=15,
                .Light=1,
                .Medium=7,
                .Normal=5,
      ...

  ### Fonts Pre-defined system fonts, all Font instances. Value:
      Fonts.App=Font.Helvetica(family=Helvetica, size=12, weight=5),
           .Bold=Font..AppleSystemUIFontBold(family=.AppleSystemUIFont, size
      =13, traits='Bold', weight=9),
           .BoldItalic=Font..AppleSystemUIFontEmphasizedItalic(family=.Apple
      SystemUIFont, size=13, traits='Italic Bold', weight=9),
           .Italic=Font..AppleSystemUIFontItalic(family=.AppleSystemUIFont,
      size=13, traits='Italic', weight=5),
           .Label=Font..AppleSystemUIFont(family=.AppleSystemUIFont, size=10
      ...