razor_font

The Sharpest Font Library For D Game Development

Members

Functions

createFont
void createFont(string fileLocation, string name, bool trimming, double spacing, double spaceCharacterSize)

Create a font from your PNG JSON pairing in the directory.

disableShadowColoring
void disableShadowColoring()

Allows you to disable shadow coloring for a teeny tiny bit of performance when you're doing cool custom shadow coloring!

enableShadows
void enableShadows()

Turns on shadowing.

flush
RazorFontData flush()

Flushes out the cache, gives you back a font struct containing the raw data

getCurrentCharacterIndex
int getCurrentCharacterIndex()

Allows you to index the current amount of characters on the canvas. This does not include spaces and carriage returns. You MUST call renderToCanvas before calling this otherwise this will always be 0 when you call it.

getCurrentFontTextureFileLocation
string getCurrentFontTextureFileLocation()

Allows you to extract the current font PNG file location automatically

getMaxChars
int getMaxChars()

Allows you to get the max amount of characters allowed in canvas

getTextRenderableCharsLength
int getTextRenderableCharsLength(string input)

Processes your input string, then sends you how long it would be when rendering. Helpful for repositioning your "cursor" in the texture cache!

getTextRenderableCharsLengthWithShadows
int getTextRenderableCharsLengthWithShadows(string input)

Processes your input text string with shadows to see how long it would be when rendering. Helpful for positioning your "cursor" in the texture cache!

getTextSize
RazorTextSize getTextSize(double fontSize, string text)

Allows you to get text size to do interesting things. Returns as RazorTextSize struct

moveChar
void moveChar(int index, double posX, double posY)

Allows you to manually move around characters.

render
void render()

Automatically flushes out the cache, handing the data structure off to the delegate function you defined via setRenderFunc()

renderToCanvas
void renderToCanvas(double posX, double posY, double fontSize, string text, bool rounding)

Render to the canvas. Remember: You must run flush() to collect this canvas. If rounding is enabled, it will attempt to keep your text aligned with the pixels on screen to avoid wavy/blurry/jagged text. This will automatically render shadows for you as well.

rotateChar
void rotateChar(int index, double rotation, bool isDegrees)

Rotate a character around the centerpoint of it's face.

selectFont
void selectFont(string font)

Selects and caches the font of your choosing.

setCanvasSize
void setCanvasSize(double width, double height)

Allows you to render to a canvas using top left as a base position

setColorChar
void setColorChar(int charIndex, double r, double g, double b, double a)

Allows you to set individual character colors

setColorPoints
void setColorPoints(int charIndex, double topLeftR, double topLeftG, double topLeftB, double topLeftA, double bottomLeftR, double bottomLeftG, double bottomLeftB, double bottomLeftA, double bottomRightR, double bottomRightG, double bottomRightB, double bottomRightA, double topRightR, double topRightG, double topRightB, double topRightA)

Allows you to directly work on vertex position colors in a character. Using direct points (verbose)

setColorPoints
void setColorPoints(int charIndex, double[4] topLeft, double[4] bottomLeft, double[4] bottomRight, double[4] topRight)

Allows you to directly work on vertex position colors in a character. Using direct points (tidy). double vec is [R,G,B,A]

setColorRange
void setColorRange(int start, int end, double r, double g, double b, double a)

Allows you to blanket a range of characters in the canvas with a color.

setRenderFunc
void setRenderFunc(void delegate(RazorFontData) renderApiRenderFunction)

Allows automatic render target (OpenGL, Vulkan, Metal, DX) DIRECT rendering via RazorFont. You can simply call render() on the library and it will automatically do whatever you tell it to with this delegate function. This will also automatically run flush().

setRenderTargetAPICallRAW
void setRenderTargetAPICallRAW(void delegate(ubyte[], int, int) apiRAWFunction)

Allows automatic render target (OpenGL, Vulkan, Metal, DX) DIRECT instantiation. This allows the render engine to AUTOMATICALLY upload the image as RAW data. ubyte[] = raw data. int = width. int = height.

setRenderTargetAPICallString
void setRenderTargetAPICallString(void delegate(string) apiStringFunction)

Allows automatic render target (OpenGL, Vulkan, Metal, DX) passthrough instantiation. This can basically pass a file location off to your rendering engine and auto load it into memory.

setShadowOffset
void setShadowOffset(double x, double y)

Allows you to set the offet of the text shadowing.

switchColors
void switchColors(double r, double g, double b, double a)

Allows you to blanket set the color for the entire canvas.

switchShadowColor
void switchShadowColor(double r, double g, double b, double a)

Allows you to blanket set the shadow color for the entire canvas after the current character.

Structs

RazorFontData
struct RazorFontData

A simple struct to get the font data for the shader

RazorTextSize
struct RazorTextSize

A simple struct to get the width and height of rendered text

Meta