diff options
| author | bluebear94 <[email protected]> | 2016-07-22 04:55:55 -0400 |
|---|---|---|
| committer | bluebear94 <[email protected]> | 2016-07-22 04:55:55 -0400 |
| commit | 8a24caa4056ac18d8fbae84728a5ea4ee4604d32 (patch) | |
| tree | 15eff6928985402e09a736706a37314d82fa3864 /sanstop.h | |
| download | sanstop-8a24caa4056ac18d8fbae84728a5ea4ee4604d32.tar.xz sanstop-8a24caa4056ac18d8fbae84728a5ea4ee4604d32.zip | |
Initial commit (first release plus some changes)
Diffstat (limited to 'sanstop.h')
| -rwxr-xr-x | sanstop.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/sanstop.h b/sanstop.h new file mode 100755 index 0000000..5132662 --- /dev/null +++ b/sanstop.h @@ -0,0 +1,72 @@ +#pragma once
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#define IMAGE_DIM 512
+#define IMAGE_PIXELS (IMAGE_DIM * IMAGE_DIM)
+#define DDS_HEADER_SIZE 128
+
+typedef struct {
+ uint8_t* data;
+ int page;
+ int x, y; // x = left edge; y = bottom edge
+} Buffer;
+
+typedef struct {
+ char* fontFileName;
+ char* fontPrefix;
+ char* targets;
+ int size;
+} Config;
+
+typedef struct {
+ int id;
+ int page;
+ int left, right, top, bottom;
+ // For future reference:
+ // B = right - left - 2
+ // A and C are unknown
+} Glyph;
+
+// Initializes a Buffer struct.
+int initializeBuffer(Buffer* b);
+// Increments the page counter, clears the data buffer, and resets coordinates.
+void flipPage(Buffer* b);
+// Returns 1 if there is not enough room in the current row to fit another
+// glyph of a given width, and thus the program should advance to the space
+// above.
+int shouldGoUp(Buffer* b, int width);
+// Returns 1 if there is not enough room in the current image to fit another
+// glyph of a given height, and thus the program should flip to a new page.
+int shouldFlip(Buffer* b, int height);
+void goUp(Buffer* b, int height);
+void advance(Buffer* b, int width);
+
+// Writes the current page to a file.
+int writePage(Buffer* b, Config* c);
+
+// Blits the character stored in face->glyph to the buffer.
+// Assumes that there is enough room.
+// Does not advance automatically.
+// Stores glyph definition in g.
+// g->id must be set.
+void blit(Buffer* b, FT_Face face, Glyph* gp, int tw, int th, int size);
+// Same as blit, but checks if there is enough room and advances
+// automatically afterwards.
+int blitAndAdvance(Buffer* b, FT_Face face, Glyph* gp, Config* c);
+
+void writeXMLHeader(FILE* f, FT_Face face, Config* c);
+void writeXMLPageData(FILE* f, Config* c, Buffer* b);
+void writeXMLGlyphData(FILE* f, int glyphCount, Glyph* glyphs);
+void writeXMLFooter(FILE* f);
+
+int readConfig(Config* c, int argc, char** argv);
+void cleanConfig(Config* c);
+void printUsage();
+void printHelp();
|