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

Class Font

  object --+    
           |    
bases._Type0 --+
               |
              Font

Python Font Type, wrapping ObjC NSFont.

Instance Methods
 
__init__(self, family_or_font, size=0, traits=0, weight=5)
New Font.
 
__str__(self)
str(x)
 
resize(self, size)
Get this font in an other point size.
 
size2(self, bstr)
Get the size of a string.
 
sizedup(self, points)
Return a font with increased point size.
 
traitsup(self, *traits)
Return a font with updated traits.

Inherited from bases._Type0: __repr__, type2strepr

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties
  count
Get the number of glyphs (int).
  family
Get the font family name (str).
  height
Get the line height (float or int).
  heightAscender
Get the ascender height (float).
  heightCap
Get the cap height (float or int).
  heightDescender
Get the descender height (float).
  heightLeading
Get the leading height (float or int).
  heightUnderline
Get the underline position (float).
  heightX
Get the x height (float or int).
  isBold
Get the Bold trait (bool).
  isCompressed
Get the Compressed trait (bool).
  isCondensed
Get the Condensed trait (bool).
  isExpanded
Get the Expanded trait (bool).
  isItalic
Get the Italic trait (bool).
  isMonoSpace
Get the MonoSpace trait (bool).
  isNarrow
Get the Narrow trait (bool).
  isPoster
Get the Poster trait (bool).
  isSansSerif
Get the SansSerif "trait" (bool).
  isSmallCaps
Get the SmallCaps trait (bool).
  isUnBold
Get the UnBold "trait" (bool).
  isUnItalic
Get the UnItalic "trait" (bool).
  isVertical
Get the Vertical "trait" (bool).
  name
Get the font name (str).
  size
Get the point size of the font (float or int).
  slant
Get the italic angle (float, int or None).
  traits
Get all font traits (FontTraits mask).
  vertical
Get the vertical version of this font (Font or None).
  weight
Get the book weight of the font (int or None).

Inherited from bases._Type0: NS

Inherited from object: __class__

Method Details

__init__(self, family_or_font, size=0, traits=0, weight=5)
(Constructor)

 

New Font.

Parameters:
  • family_or_font - Generic font name (str, Str, NSStr) like "Times" or "Helvetica" or a Font, NSFont or NSFontDescriptor instance.
  • size - Desired point size (int), zero for any.
  • traits - Desired font traits (str or FontTraits mask).
  • weigth - Desired book weight (int) in range 0..15, where 0=light, 5=regular, 9=bold and 15=heavy.
Raises:
  • FontError - No such family_or_font.
  • FontTraitError - Mutually exclusive traits.
  • TypeError - Invalid family_or_font.
  • ValueError - Invalid weight.
Overrides: object.__init__

Note: The new Font may not exhibit the desired traits and weight. The weight is ignored if traits include FontTrait.Bold, both traits and weight are ignored if family_or_font is NSFontDescriptor.

See Also: Function fontsof to obtain all available fonts of a particular font family.

__str__(self)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

resize(self, size)

 

Get this font in an other point size.

Parameters:
  • size - Desired point size (int).
Returns:
The other or this font (Font).

See Also: Font.__init__ for errors raised.

size2(self, bstr)

 

Get the size of a string.

Parameters:
  • bstr - The string (str, bytes or Str).
Returns:
2-Tuple (width, height) in (float or int).

sizedup(self, points)

 

Return a font with increased point size.

Parameters:
  • points - Point size to add (int).
Returns:
The other or this font (Font).

See Also: Font.__init__ for errors raised.

traitsup(self, *traits)

 

Return a font with updated traits.

Parameters:
  • traits - Traits to update (str or FontTraits mask).
Returns:
The other or this font (Font).

See Also: Font.__init__ for errors raised.


Property Details

count

Get the number of glyphs (int).

Get Method:
count(self) - Get the number of glyphs (int).

family

Get the font family name (str).

Get Method:
family(self) - Get the font family name (str).

height

Get the line height (float or int).

Get Method:
height(self) - Get the line height (float or int).

Note: The height is the sum of the tallest ascender, tallest descender and leading.

heightAscender

Get the ascender height (float).

Get Method:
heightAscender(self) - Get the ascender height (float).

heightCap

Get the cap height (float or int).

Get Method:
heightCap(self) - Get the cap height (float or int).

heightDescender

Get the descender height (float).

Get Method:
heightDescender(self) - Get the descender height (float).

heightLeading

Get the leading height (float or int).

Get Method:
heightLeading(self) - Get the leading height (float or int).

heightUnderline

Get the underline position (float).

Get Method:
heightUnderline(self) - Get the underline position (float).

heightX

Get the x height (float or int).

Get Method:
heightX(self) - Get the x height (float or int).

isBold

Get the Bold trait (bool).

Get Method:
isBold(self) - Get the Bold trait (bool).

isCompressed

Get the Compressed trait (bool).

Get Method:
isCompressed(self) - Get the Compressed trait (bool).

isCondensed

Get the Condensed trait (bool).

Get Method:
isCondensed(self) - Get the Condensed trait (bool).

isExpanded

Get the Expanded trait (bool).

Get Method:
isExpanded(self) - Get the Expanded trait (bool).

isItalic

Get the Italic trait (bool).

Get Method:
isItalic(self) - Get the Italic trait (bool).

isMonoSpace

Get the MonoSpace trait (bool).

Get Method:
isMonoSpace(self) - Get the MonoSpace trait (bool).

isNarrow

Get the Narrow trait (bool).

Get Method:
isNarrow(self) - Get the Narrow trait (bool).

isPoster

Get the Poster trait (bool).

Get Method:
isPoster(self) - Get the Poster trait (bool).

isSansSerif

Get the SansSerif "trait" (bool).

Get Method:
isSansSerif(self) - Get the SansSerif "trait" (bool).

isSmallCaps

Get the SmallCaps trait (bool).

Get Method:
isSmallCaps(self) - Get the SmallCaps trait (bool).

isUnBold

Get the UnBold "trait" (bool).

Get Method:
isUnBold(self) - Get the UnBold "trait" (bool).

isUnItalic

Get the UnItalic "trait" (bool).

Get Method:
isUnItalic(self) - Get the UnItalic "trait" (bool).

isVertical

Get the Vertical "trait" (bool).

Get Method:
isVertical(self) - Get the Vertical "trait" (bool).

name

Get the font name (str).

Get Method:
name(self) - Get the font name (str).
Set Method:
name(self, name) - Set the font name (str).

size

Get the point size of the font (float or int).

Get Method:
size(self) - Get the point size of the font (float or int).

slant

Get the italic angle (float, int or None).

Get Method:
slant(self) - Get the italic angle (float, int or None).

traits

Get all font traits (FontTraits mask).

Get Method:
traits(self) - Get all font traits (FontTraits mask).

vertical

Get the vertical version of this font (Font or None).

Get Method:
vertical(self) - Get the vertical version of this font (Font or None).

weight

Get the book weight of the font (int or None).

Get Method:
weight(self) - Get the book weight of the font (int or None).