The
ImageFont
module defines a class with the same name. Instances ofthis class store bitmap fonts, and are used with thePIL.ImageDraw.ImageDraw.text()
method.PIL uses its own font file format to store bitmap fonts. You can use thepilfont utility frompillow-scriptsto convert BDF and PCF font descriptors (X window font formats) to this format.
A Bitmap-Font is like a font file but contains bitmaps (preferably in various sizes) for each character. He needs a font to be rendered to a texture, so the result won't be a bitmap-font but an image. $ endgroup $ – bummzack Aug 14 '10 at 8:02. Windows bitmap font editor free download. Etherpad Etherpad is a highly customizable online document editor that allows for collaborative editing in re. Bitmap font tools for windows. Hello, I'm using Windows and Flash develop to develop Flash games. But I didn't find a good tool to export a.
Free Bitmap fonts (.ttf &.otf). Bitmap available in Windows and Mac OS X version. TrueType and OpenType fonts. Search from a wide range of typography fonts. Tip: To delete a font, open the Windows 10 fonts folder. Click the font you want to delete. To select more than one font at a time in Windows 10 explorer, press and hold down the Ctrl button while you click each font.
Starting with version 1.1.4, PIL can be configured to support TrueType andOpenType fonts (as well as other font formats supported by the FreeTypelibrary). For earlier versions, TrueType support is only available as part ofthe imToolkit package.
Example¶
Functions¶
PIL.ImageFont.
load
(filename)[source]¶Load a font file. This function loads a font object from the givenbitmap font file, and returns the corresponding font object.
filename – Name of font file.
A font object.
OSError – If the file could not be read.
PIL.ImageFont.
load_path
(filename)[source]¶Load font file. Same as
load()
, but searches for abitmap font along the Python path.filename – Name of font file.
A font object.
OSError – If the file could not be read.
PIL.ImageFont.
truetype
(font=None, size=10, index=0, encoding=', layout_engine=None)[source]¶Load a TrueType or OpenType font from a file or file-like object,and create a font object.This function loads a font object from the given file or file-likeobject, and creates a font object for a font of the given size.
Pillow uses FreeType to open font files. If you are opening many fontssimultaneously on Windows, be aware that Windows limits the number of filesthat can be open in C at once to 512. If you approach that limit, an
OSError
may be thrown, reporting that FreeType “cannot open resource”.This function requires the _imagingft service.
Bitmap Font Generator Online
- font – A filename or file-like object containing a TrueType font.If the file is not found in this filename, the loader may alsosearch in other directories, such as the
fonts/
directory on Windows or/Library/Fonts/
,/System/Library/Fonts/
and~/Library/Fonts/
onmacOS. - size – The requested size, in points.
- index – Which font face to load (default is first available face).
- encoding – Maccleanse 7 0 1.Which font encoding to use (default is Unicode). Possibleencodings include (see the FreeType documentation for moreinformation):
- ”unic” (Unicode)
- ”symb” (Microsoft Symbol)
- ”ADOB” (Adobe Standard)
- ”ADBE” (Adobe Expert)
- ”ADBC” (Adobe Custom)
- ”armn” (Apple Roman)
- ”sjis” (Shift JIS)
- ”gb ” (PRC)
- ”big5”
- ”wans” (Extended Wansung)
- ”joha” (Johab)
- ”lat1” (Latin-1)
This specifies the character set to use. It does not alter theencoding of any text provided in subsequent operations. - layout_engine –Which layout engine to use, if available:
ImageFont.LAYOUT_BASIC
orImageFont.LAYOUT_RAQM
.You can check support for Raqm layout usingPIL.features.check_feature()
withfeature='raqm'
.
A font object.
OSError – If the file could not be read.
PIL.ImageFont.
load_default
()[source]¶Load a “better than nothing” default font.
New in version 1.1.4.
A font object.
Methods¶
PIL.ImageFont.
ImageFont
[source]¶PIL font wrapper
getmask
(text, mode=', *args, **kwargs)[source]¶Create a bitmap for the text.
If the font uses antialiasing, the bitmap should have mode
L
and use amaximum value of 255. Otherwise, it should have mode 1
.- text – Text to render.
- mode –Used by some graphics drivers to indicate what mode thedriver prefers; if empty, the renderer may return eithermode. Note that the mode is always a string, to simplifyC-level implementations.
![Bitmap Bitmap](https://befonts.com/wp-content/uploads/2015/06/4Music.jpg)
An internal PIL storage memory instance as defined by the
PIL.Image.core
interface module.getsize
(text, *args, **kwargs)[source]¶Returns width and height (in pixels) of given text.
text – Text to measure.
(width, height)
PIL.ImageFont.
FreeTypeFont
(font=None, size=10, index=0, encoding=', layout_engine=None)[source]¶FreeType font wrapper (requires _imagingft service)
font_variant
(font=None, size=None, index=None, encoding=None, layout_engine=None)[source]¶Create a copy of this FreeTypeFont object,using any specified arguments to override the settings.
Parameters are identical to the parameters used to initialize thisobject.
A FreeTypeFont object.
get_variation_axes
()[source]¶A list of the axes in a variation font.
OSError – If the font is not a variation font.
get_variation_names
()[source]¶A list of the named styles in a variation font.
Raster Font
OSError – If the font is not a variation font.
getbbox
(text, mode=', direction=None, features=None, language=None, stroke_width=0, anchor=None)[source]¶Returns bounding box (in pixels) of given text relative to given anchorwhen rendered in font with provided direction, features, and language.
Use
getlength()
to get the offset of following text with1/64 pixel precision. The bounding box includes extra margins forsome fonts, e.g. italics or accents.New in version 8.0.0.
- text – Text to render.
- mode – Used by some graphics drivers to indicate what mode thedriver prefers; if empty, the renderer may return eithermode. Note that the mode is always a string, to simplifyC-level implementations.
- direction – Direction of the text. It can be ‘rtl’ (right toleft), ‘ltr’ (left to right) or ‘ttb’ (top to bottom).Requires libraqm.
- features – A list of OpenType font features to be used during textlayout. This is usually used to turn on optionalfont features that are not enabled by default,for example ‘dlig’ or ‘ss01’, but can be alsoused to turn off default font features forexample ‘-liga’ to disable ligatures or ‘-kern’to disable kerning. To get all supportedfeatures, seehttps://docs.microsoft.com/en-us/typography/opentype/spec/featurelistRequires libraqm.
- language – Language of the text. Different languages may usedifferent glyph shapes or ligatures. This parameter tellsthe font which language the text is in, and to apply thecorrect substitutions as appropriate, if available.It should be a BCP 47 language code<https://www.w3.org/International/articles/language-tags/>Requires libraqm.
- stroke_width – The width of the text stroke.
- anchor – The text anchor alignment. Determines the relative location ofthe anchor to the text. The default alignment is top left.See Text anchors for valid values.
(left,top,right,bottom)
bounding boxgetlength
(text, mode=', direction=None, features=None, language=None)[source]¶Returns length (in pixels with 1/64 precision) of given text when renderedin font with provided direction, features, and language.
This is the amount by which following text should be offset.Text bounding box may extend past the length in some fonts,e.g. when using italics or accents.
The result is returned as a float; it is a whole number if using basic layout.
Note that the sum of two lengths may not equal the length of a concatenatedstring due to kerning. If you need to adjust for kerning, include the followingcharacter and subtract its length.
For example, instead of El capitan cache cleaner 10 0 1 download free.
use
or disable kerning with (requires libraqm)
New in version 8.0.0.
- text – Text to measure.
- mode – Used by some graphics drivers to indicate what mode thedriver prefers; if empty, the renderer may return eithermode. Note that the mode is always a string, to simplifyC-level implementations.
- direction – Direction of the text. It can be ‘rtl’ (right toleft), ‘ltr’ (left to right) or ‘ttb’ (top to bottom).Requires libraqm.
- features – A list of OpenType font features to be used during textlayout. This is usually used to turn on optionalfont features that are not enabled by default,for example ‘dlig’ or ‘ss01’, but can be alsoused to turn off default font features forexample ‘-liga’ to disable ligatures or ‘-kern’to disable kerning. To get all supportedfeatures, seehttps://docs.microsoft.com/en-us/typography/opentype/spec/featurelistRequires libraqm.
- language – Language of the text. Different languages may usedifferent glyph shapes or ligatures. This parameter tellsthe font which language the text is in, and to apply thecorrect substitutions as appropriate, if available.It should be a BCP 47 language code<https://www.w3.org/International/articles/language-tags/>Requires libraqm.
Width for horizontal, height for vertical text.
getmask
(text, mode=', direction=None, features=None, language=None, stroke_width=0, anchor=None, ink=0)[source]¶Create a bitmap for the text.
If the font uses antialiasing, the bitmap should have mode
L
and use amaximum value of 255. If the font has embedded color data, the bitmapshould have mode RGBA
. Otherwise, it should have mode 1
.- text – Text to render.
- mode –Used by some graphics drivers to indicate what mode thedriver prefers; if empty, the renderer may return eithermode. Note that the mode is always a string, to simplifyC-level implementations.
- direction –Direction of the text. It can be ‘rtl’ (right toleft), ‘ltr’ (left to right) or ‘ttb’ (top to bottom).Requires libraqm.New in version 4.2.0.
- features –A list of OpenType font features to be used during textlayout. This is usually used to turn on optionalfont features that are not enabled by default,for example ‘dlig’ or ‘ss01’, but can be alsoused to turn off default font features forexample ‘-liga’ to disable ligatures or ‘-kern’to disable kerning. To get all supportedfeatures, seehttps://docs.microsoft.com/en-us/typography/opentype/spec/featurelistRequires libraqm.
- language –Language of the text. Different languages may usedifferent glyph shapes or ligatures. This parameter tellsthe font which language the text is in, and to apply thecorrect substitutions as appropriate, if available.It should be a BCP 47 language code<https://www.w3.org/International/articles/language-tags/>Requires libraqm.New in version 6.0.0.
- stroke_width –The width of the text stroke.
- anchor –The text anchor alignment. Determines the relative location ofthe anchor to the text. The default alignment is top left.See Text anchors for valid values.
- ink –Foreground ink for rendering in RGBA mode.New in version 8.0.0.
An internal PIL storage memory instance as defined by the
PIL.Image.core
interface module.getmask2
(text, mode=', fill=<built-in function fill>, direction=None, features=None, language=None, stroke_width=0, anchor=None, ink=0, *args, **kwargs)[source]¶Create a bitmap for the text.
If the font uses antialiasing, the bitmap should have mode
L
and use amaximum value of 255. If the font has embedded color data, the bitmapshould have mode RGBA
. Otherwise, it should have mode 1
.- text – Text to render.
- mode –Used by some graphics drivers to indicate what mode thedriver prefers; if empty, the renderer may return eithermode. Note that the mode is always a string, to simplifyC-level implementations.
- direction –Direction of the text. It can be ‘rtl’ (right toleft), ‘ltr’ (left to right) or ‘ttb’ (top to bottom).Requires libraqm.New in version 4.2.0.
- features –A list of OpenType font features to be used during textlayout. This is usually used to turn on optionalfont features that are not enabled by default,for example ‘dlig’ or ‘ss01’, but can be alsoused to turn off default font features forexample ‘-liga’ to disable ligatures or ‘-kern’to disable kerning. To get all supportedfeatures, seehttps://docs.microsoft.com/en-us/typography/opentype/spec/featurelistRequires libraqm.
- language –Language of the text. Different languages may usedifferent glyph shapes or ligatures. This parameter tellsthe font which language the text is in, and to apply thecorrect substitutions as appropriate, if available.It should be a BCP 47 language code<https://www.w3.org/International/articles/language-tags/>Requires libraqm.New in version 6.0.0.
- stroke_width –The width of the text stroke.
- anchor –The text anchor alignment. Determines the relative location ofthe anchor to the text. The default alignment is top left.See Text anchors for valid values.
- ink –Foreground ink for rendering in RGBA mode.New in version 8.0.0.
A tuple of an internal PIL storage memory instance as defined by the
PIL.Image.core
interface module, and the text offset, thegap between the starting coordinate and the first markinggetmetrics
()[source]¶A tuple of the font ascent (the distance from the baseline tothe highest outline point) and descent (the distance from thebaseline to the lowest outline point, a negative value)
getname
()[source]¶A tuple of the font family (e.g. Helvetica) and the font style(e.g. Bold)
getoffset
(text)[source]¶Returns the offset of given text. This is the gap between thestarting coordinate and the first marking. Note that this gap isincluded in the result of
getsize()
.text – Text to measure.
A tuple of the x and y offset
getsize
(text, direction=None, features=None, language=None, stroke_width=0)[source]¶Returns width and height (in pixels) of given text if rendered in font withprovided direction, features, and language.
Use
getlength()
to measure the offset of following text with1/64 pixel precision.Use getbbox()
to get the exact bounding box based on an anchor.Note
For historical reasons this function measures text height fromthe ascender line instead of the top, see Text anchors.If you wish to measure text height from the top, it is recommendedto use the bottom value of
getbbox()
with anchor='lt'
instead.- text – Text to measure.
- direction –Direction of the text. It can be ‘rtl’ (right toleft), ‘ltr’ (left to right) or ‘ttb’ (top to bottom).Requires libraqm.
- features –A list of OpenType font features to be used during textlayout. This is usually used to turn on optionalfont features that are not enabled by default,for example ‘dlig’ or ‘ss01’, but can be alsoused to turn off default font features forexample ‘-liga’ to disable ligatures or ‘-kern’to disable kerning. To get all supportedfeatures, seehttps://docs.microsoft.com/en-us/typography/opentype/spec/featurelistRequires libraqm.New in version 4.2.0.
- language –Language of the text. Different languages may usedifferent glyph shapes or ligatures. This parameter tellsthe font which language the text is in, and to apply thecorrect substitutions as appropriate, if available.It should be a BCP 47 language code<https://www.w3.org/International/articles/language-tags/>Requires libraqm.
- stroke_width –The width of the text stroke.New in version 6.2.0.
(width, height)
getsize_multiline
(text, direction=None, spacing=4, features=None, language=None, stroke_width=0)[source]¶Returns width and height (in pixels) of given text if rendered in fontwith provided direction, features, and language, while respectingnewline characters.
- text – Text to measure.
- direction – Direction of the text. It can be ‘rtl’ (right toleft), ‘ltr’ (left to right) or ‘ttb’ (top to bottom).Requires libraqm.
- spacing – The vertical gap between lines, defaulting to 4 pixels.
- features – A list of OpenType font features to be used during textlayout. This is usually used to turn on optionalfont features that are not enabled by default,for example ‘dlig’ or ‘ss01’, but can be alsoused to turn off default font features forexample ‘-liga’ to disable ligatures or ‘-kern’to disable kerning. To get all supportedfeatures, seehttps://docs.microsoft.com/en-us/typography/opentype/spec/featurelistRequires libraqm.
- language –Language of the text. Different languages may usedifferent glyph shapes or ligatures. This parameter tellsthe font which language the text is in, and to apply thecorrect substitutions as appropriate, if available.It should be a BCP 47 language code<https://www.w3.org/International/articles/language-tags/>Requires libraqm.
- stroke_width –The width of the text stroke.Vuescan 9 7 02 – scanner software with advanced features. New in version 6.2.0.
(width, height)
set_variation_by_axes
(axes)[source]¶axes – A list of values for each axis.
OSError – If the font is not a variation font.
set_variation_by_name
(name)[source]¶name – The name of the style.
OSError – If the font is not a variation font.
PIL.ImageFont.
TransposedFont
(font, orientation=None)[source]¶Wrapper for writing rotated or mirrored text
Constants¶
PIL.ImageFont.
LAYOUT_BASIC
¶Use basic text layout for TrueType font.Advanced features such as text direction are not supported.
PIL.ImageFont.
LAYOUT_RAQM
¶Use Raqm text layout for TrueType font.Advanced features are supported.
Requires Raqm, you can check support using
PIL.features.check_feature()
with feature='raqm'
.