Hershey Vector Fonts 0.1.0
A C++ library for working with the Hershey vector fonts
Loading...
Searching...
No Matches
hershey_svg.hpp File Reference
#include <fstream>
#include <iostream>
#include "font.hpp"
#include "glyph.hpp"
#include "string.hpp"

Go to the source code of this file.

Functions

void write_header (std::ofstream &svg_file, int width, int height, int scale)
 Write the svg file header.
 
void write_footer (std::ofstream &svg_file)
 Write the svg file header.
 
void draw_glyph (std::ofstream &svg_file, Hershey::Glyph glyph, int x0, int y0, int scale)
 Draw a glyph.
 
void draw_glyphs (std::ofstream &svg_file, Hershey::String string, int x0, int y0, int scale)
 Draw a string of glyphs.
 
void draw_font (std::ofstream &svg_file, Hershey::Font font, int width, int height)
 Draw the glyphs in a font.
 
float position (float fraction, float x, float X)
 Calculate a fractional position.
 

Detailed Description

This header file contains the declaration of the functions for the svg interface.

Function Documentation

◆ draw_font()

void draw_font ( std::ofstream &  svg_file,
Hershey::Font  font,
int  width,
int  height 
)

Draw the glyphs in a font.

Parameters
svg_fileThe file to draw to
fontThe font to draw
widthThe width of the image
heightThe height of the image

◆ draw_glyph()

void draw_glyph ( std::ofstream &  svg_file,
Hershey::Glyph  glyph,
int  x0,
int  y0,
int  scale 
)

Draw a glyph.

Parameters
svg_fileThe file to draw to
glyphThe glyph to draw
x0The starting x position
y0The starting x position
scaleThe amount to scale the glyph by

◆ draw_glyphs()

void draw_glyphs ( std::ofstream &  svg_file,
Hershey::String  string,
int  x0,
int  y0,
int  scale 
)

Draw a string of glyphs.

Parameters
svg_fileThe file to draw to
stringThe string of glyphs to draw
x0The starting x position
y0The starting x position
scaleThe amount to scale the glyphs by

◆ position()

float position ( float  fraction,
float  x,
float  X 
)

Calculate a fractional position.

Parameters
fractionThe fraction to use
xThe object's size
XThe total size

◆ write_footer()

void write_footer ( std::ofstream &  svg_file)

Write the svg file header.

Parameters
svg_fileThe file to draw to

◆ write_header()

void write_header ( std::ofstream &  svg_file,
int  width,
int  height,
int  scale 
)

Write the svg file header.

Parameters
svg_fileThe file to draw to
widthThe width of the image
heightThe height of the image
scaleThe amount to scale the image by