rasterToAmigaBitmapFont | R Documentation |
Convert a two-coloured grDevices::as.raster()
image into
an AmigaBitmapFont()
class object.
rasterToAmigaBitmapFont(
x,
glyphs,
default_glyph,
baseline,
glyph_width,
glyph_space,
glyph_kern,
palette,
...
)
x |
A |
glyphs |
Specify which glyphs are included in the image
A single A A Note that Amiga bitmap fonts represent ASCII characters and may not include all special characters or symbols. |
default_glyph |
A single |
baseline |
The baseline of the font, specified in number of
pixels from the top ( |
glyph_width |
A |
glyph_space |
A |
glyph_kern |
Note that in Amiga bitmap fonts not the formal
definition from typography is used for kerning. Here, kerning is
used as the number of pixels the cursor should be moved forward or
backward after typesetting a character. It should be a
|
palette |
A When missing, it will be checked whether |
... |
Currently ignored. |
Create an AmigaBitmapFont()
class object by providing
a two-coloured raster image and specifying which characters are
depicted by the image.
Returns a AmigaBitmapFont()
class object based on x
.
Pepijn de Vries
Other AmigaBitmapFont.operations:
AmigaBitmapFont
,
availableFontSizes()
,
c()
,
fontName()
,
font_example
,
getAmigaBitmapFont()
,
rawToAmigaBitmapFontSet()
,
rawToAmigaBitmapFont()
,
read.AmigaBitmapFontSet()
,
read.AmigaBitmapFont()
,
write.AmigaBitmapFont()
Other raster.operations:
AmigaBitmapFont
,
as.raster.AmigaBasicShape()
,
bitmapToRaster()
,
dither()
,
index.colours()
,
rasterToAmigaBasicShape()
,
rasterToBitmap()
,
rasterToHWSprite()
,
rasterToIFF()
## Not run:
data("font_example")
## make a raster that we can use to create a bitmap font
font9.rast <- as.raster(getAmigaBitmapFont(font_example, 9))
## note the glyphs and the order in which they are included in
## the raster image:
plot(font9.rast)
## let's build a simple font, using only the first few glyphs
## in the raster:
font9 <- rasterToAmigaBitmapFont(
## 'x' needs the raster image:
x = font9.rast,
## 'glyphs' are the graphical representation of the characters
## that we will include in our font. We will only use the
## first 7 characters in the raster image:
glyphs = " !\"#$%&",
## We will use the '&' glyph to represent all characters that
## are not specified in the font:
default_glyph = "&",
## The raster image is 9 pixels tall, as will be the font.
## Let's use 7 as the base (it needs to be less than the height)
baseline = 7,
## Let's define the width in pixels for each of the 7
## characters. This is their width in the raster image:
glyph_width = c(0, 1, 3, 6, 5, 5, 5),
## Let's define the space the character should take in pixels
## when it is used to format text:
glyph_space = c(4, 2, 4, 7, 6, 6, 6),
## the raster uses white as background colour and black as
## foreground:
palette = c("white", "black")
)
## note that for all characters that are not specified,
## the default glyph ('&') is used:
plot(font9, text = "!@#$%ABCD")
## Let's take a subset from the font's bitmap (rasteer):
font9abc.rast <- font9.rast[,263:282]
## as you can see this bitmap only contains the lowercase
## characters 'a', 'b', 'c', 'd' and 'e':
plot(font9abc.rast)
font9.abc <- rasterToAmigaBitmapFont(
x = font9abc.rast,
## Each glyph in the image can be represented by a single
## element in a list. By specifying multiple characters in
## each element, you can recycle a glyph to represent different
## characters. So in this case, the glyph 'a' is used for
## all the accented variants of the character 'a'.
glyphs = list("a\xE0\xE1\xE2\xE3\xE4\xE5",
"b",
"c\xA2\xE7",
"d",
"e\xE8\xE9\xEA\xEB"),
default_glyph = "c", ## 'c' is used as default glyph for all other characters
baseline = 7,
glyph_width = c(4, 4, 4, 4, 4),
glyph_space = c(5, 5, 5, 5, 5),
palette = c("white", "black")
)
## see what happens when you format text using the font we just created:
plot(font9.abc, text = "a\xE0\xE1\xE2\xE3\xE4\xE5bc\xA2\xE7de\xE8\xE9\xEA\xEB, foo bar")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.