
This is an OpenSCAD library to generate pixelly fonts, mostly based on some PalmOS bitmap fonts from Ron Buelow. There are 29 fonts included.
I used it to make a Minecraft-themed text topper for a birthday cake. The full library code is here -- the downloads for this Thing just include a self-contained demo file.
To use, start with:
include <pixellyfont.scad>
The syntax for the main library call, with defaults indicated, is:
renderString(string,font=font_8x8,halign="left",valign="bottom",invert=false,spacing=1,size=10,pixelScale=1.01,height=0)
string
: text to render; only characters included in the CP-1252 character set are supported; other characters will be turned to spaces
font
: font to use; the fonts are defined in fontdata.scad
halign
: horizontal alignment: "left", "right" or "center"
valign
: vertical alignment: "bottom", "top" or "center"
invert
: set to true
if you want to draw the background instead of the characters
spacing
: scale for character spacing
size
: height of characters
pixelScale
: the scaling to apply to the pixels; if you increase it noticeably above 1, the pixels will join up more, and if you decrease it below 1, you'll get blank space around them
height
height to extrude pixels; set to 0 to make pixels 2D
You can also use renderString()
as a modifier for a shape. In that case, pixelScale
and height
are ignored, and instead the shape is used as a pixel. For instance, you can do this to make foreground pixels be large circles and background pixels be small circles:
renderString("abc") circle(d=1);
renderString("abc",invert=true) circle(d=0.1);
If you want to know how much horizontal space text will take up, you can call
getStringWidth(string[,options])
where the available options are the font
, spacing
and size
options that renderString()
uses.
If you want to know how many pixels high characters in a font are, call getFontHeight(font)
. You can then compute the size of an individual pixel as size/getFontHeight(font)
where size
is the size
parameter for renderString()
.
Add a comment