Title: | Text Rendering with Bitmap and Vector Fonts |
---|---|
Description: | Alternate font rendering is useful when rendering to novel graphics outputs where modern font rendering is not available or not appropriate. Bitmap and vector fonts allow for bespoke rendering using pixel coordinates and line drawing. A selection of fonts is included and all can be rendered to a matrix of pixel locations or returned as pixel coordinates and collections of stroke endpoints. |
Authors: | Mike Cheng [aut, cre, cph], Frederic Cambus [aut, cph] (Creator of 'spleen' font), GNU Unifont authors [cph] (Creators of 'unifont'), Anders Hoff [aut, cph] (Creator of 'gridfont' font) |
Maintainer: | Mike Cheng <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-10-29 13:26:42 UTC |
Source: | https://github.com/coolbutuseless/lofifonts |
Create a data.frame of pixel coordinate information of the rendered text
bitmap_text_coords(text, font = "unifont", line_height = NULL, missing = NULL)
bitmap_text_coords(text, font = "unifont", line_height = NULL, missing = NULL)
text |
Single text string. Can include carriage returns. |
font |
Name of bitmap font. One of the following:
|
line_height |
Integer value for the vertical distance between multiple lines of text. Use this to override the font's lineheight. Default: NULL means to use the font's built-in lineheight. |
missing |
Codepoint (integer) to use if glyph not found in font. Default: NULL means to use the default specified by the font internally. Otherwise it will default to the codepoint for '?' |
data.frame of coordinate information
char_idx
The index of the character within the provided text
string
codepoint
Unicode codepoint (integer)
x
Pixel coordinate x value for display
y
Pixel coordinate y value for display
line
Line number within input text
where this character appears
x0
Original untransformed x-coordinate
y0
Original untransformed y-coordinate
Other bitmap text functions:
bitmap_text_matrix()
,
bitmap_text_raster()
bitmap_text_coords('Hi')
bitmap_text_coords('Hi')
Create a binary matrix of the rendered text
bitmap_text_matrix( text, font = "unifont", line_height = NULL, scale = 1, missing = NULL )
bitmap_text_matrix( text, font = "unifont", line_height = NULL, scale = 1, missing = NULL )
text |
Single text string. Can include carriage returns. |
font |
Name of bitmap font. One of the following:
|
line_height |
Integer value for the vertical distance between multiple lines of text. Use this to override the font's lineheight. Default: NULL means to use the font's built-in lineheight. |
scale |
Integer size scale factor. Default: 1. Must be an integer value >= 1. Scale up the matrix or raster result by this factor |
missing |
Codepoint (integer) to use if glyph not found in font. Default: NULL means to use the default specified by the font internally. Otherwise it will default to the codepoint for '?' |
Binary matrix representation of the rendered text
Other bitmap text functions:
bitmap_text_coords()
,
bitmap_text_raster()
bitmap_text_matrix('Hi')
bitmap_text_matrix('Hi')
Create a raster image of the rendered text
bitmap_text_raster( text, font = "unifont", line_height = NULL, scale = 1, missing = NULL )
bitmap_text_raster( text, font = "unifont", line_height = NULL, scale = 1, missing = NULL )
text |
Single text string. Can include carriage returns. |
font |
Name of bitmap font. One of the following:
|
line_height |
Integer value for the vertical distance between multiple lines of text. Use this to override the font's lineheight. Default: NULL means to use the font's built-in lineheight. |
scale |
Integer size scale factor. Default: 1. Must be an integer value >= 1. Scale up the matrix or raster result by this factor |
missing |
Codepoint (integer) to use if glyph not found in font. Default: NULL means to use the default specified by the font internally. Otherwise it will default to the codepoint for '?' |
Raster image representation of the rendered text
Other bitmap text functions:
bitmap_text_coords()
,
bitmap_text_matrix()
ras <- bitmap_text_raster('Hi') plot(ras, interpolate = FALSE)
ras <- bitmap_text_raster('Hi') plot(ras, interpolate = FALSE)
Currently on includes font names and unicode codepoints available within each font
font_info
font_info
An object of class list
of length 2.
Font names
font_names
font_names
An object of class list
of length 2.
Text input can contain multiple lines separated by carriage returns
vector_text_coords( text, font = c("gridfont", "gridfont_smooth", "arcade"), dx = 0, dy = 0, missing = utf8ToInt("?"), line_height = NULL )
vector_text_coords( text, font = c("gridfont", "gridfont_smooth", "arcade"), dx = 0, dy = 0, missing = utf8ToInt("?"), line_height = NULL )
text |
Single text string. Can include carriage returns. |
font |
Name of vector font. One of
|
dx |
Additional character spacing in the horizontal direction. Default: 0 |
dy |
Additional character spacing in the vertical direction. Default: 0 |
missing |
Codepoint to use if glyph not available in font. default: Codepoint for '?' |
line_height |
line height |
data.frame of stroke information
char_idx
The index of the character within the provided text
string
codepoint
Unicode codepoint (integer)
stroke_idx
Index of the stroke within each character
point_idx
Index of the point within each stroke
x
Pixel coordinate x value for display
y
Pixel coordinate y value for display
width
Width of vector character
height
Height of vector character
x0
Original untransformed x-coordinate
y0
Original untransformed y-coordinate
line
Line number within input text
where this character appears
Other vector text functions:
vector_text_matrix()
,
vector_text_raster()
vector_text_coords('Hi')
vector_text_coords('Hi')
Create a binary matrix of the rendered text
vector_text_matrix( text, font = c("gridfont", "gridfont_smooth", "arcade"), scale = 1, dx = NULL, dy = NULL, missing = utf8ToInt("?") )
vector_text_matrix( text, font = c("gridfont", "gridfont_smooth", "arcade"), scale = 1, dx = NULL, dy = NULL, missing = utf8ToInt("?") )
text |
Single text string. Can include carriage returns. |
font |
Name of vector font. One of
|
scale |
Scale factor for text rendering. Numeric value greater than zero. Default: 1 |
dx |
Additional character spacing in the horizontal direction. Default: 0 |
dy |
Additional character spacing in the vertical direction. Default: 0 |
missing |
Codepoint to use if glyph not available in font. default: Codepoint for '?' |
Binary matrix rendering of the font
Other vector text functions:
vector_text_coords()
,
vector_text_raster()
vector_text_matrix("Hi")
vector_text_matrix("Hi")
Create a raster image of the rendered text
vector_text_raster( text, font = c("gridfont", "gridfont_smooth", "arcade"), scale = 10, dx = NULL, dy = NULL, missing = utf8ToInt("?") )
vector_text_raster( text, font = c("gridfont", "gridfont_smooth", "arcade"), scale = 10, dx = NULL, dy = NULL, missing = utf8ToInt("?") )
text |
Single text string. Can include carriage returns. |
font |
Name of vector font. One of
|
scale |
Scale factor for text rendering. Numeric value greater than zero. Default: 1 |
dx |
Additional character spacing in the horizontal direction. Default: 0 |
dy |
Additional character spacing in the vertical direction. Default: 0 |
missing |
Codepoint to use if glyph not available in font. default: Codepoint for '?' |
Raster image of rendered text
Other vector text functions:
vector_text_coords()
,
vector_text_matrix()
ras <- vector_text_raster("Hi") plot(ras, interpolate = FALSE)
ras <- vector_text_raster("Hi") plot(ras, interpolate = FALSE)