Skip to content

Commit b89907b

Browse files
author
Mikko Mononen
committedNov 12, 2013
First commit
0 parents  commit b89907b

34 files changed

+11951
-0
lines changed
 

‎.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Compiled source #
2+
*.com
3+
*.class
4+
*.dll
5+
*.exe
6+
*.o
7+
*.so
8+
test
9+
10+
## Logs and databases #
11+
*.log
12+
*.sql
13+
*.sqlite
14+
15+
## OS generated files #
16+
.DS_Store
17+
.DS_Store?
18+
._*
19+
.Spotlight-V100
20+
.Trashes
21+
ehthumbs.db
22+
Thumbs.db
23+
24+
## Build dir
25+
build/*
26+
27+
## xcode specific
28+
*xcuserdata*

‎README.md

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
Font Stash
2+
==========
3+
4+
Font stash is light-weight online font texture atlas builder written in C. It uses [stb_truetype](http://nothings.org) to render fonts on demand to a texture atlas.
5+
6+
The code is split in two parts, the font atlas and glyph quad generator [fontstash.h](/src/fontstash.h), and an example OpenGL backend ([glstash.h](/glstash.h).
7+
8+
## Screenshot
9+
10+
![screenshot of some text rendered witht the sample program](/screenshots/screen-01.png?raw=true)
11+
12+
## Example
13+
``` C
14+
// Create stash for 512x512 texture, our coordinate system has zero at top-left.
15+
struct FONSparams params;
16+
memset(&params, 0, sizeof(params));
17+
params.width = 512;
18+
params.height = 512;
19+
params.flags = FONS_ZERO_TOPLEFT;
20+
glstInit(&params);
21+
struct FONScontext* fs = fonsCreate(&params);
22+
23+
// Add font to stash.
24+
int fontNormal = fonsAddFont(fs, "DroidSerif-Regular.ttf");
25+
26+
// Render some text
27+
float dx = 10, dy = 10;
28+
unsigned int white = glstRGBA(255,255,255,255);
29+
unsigned int brown = glstRGBA(192,128,0,128);
30+
31+
struct fontstash_style styleBig = { FONT_NORMAL, 124.0f, white };
32+
33+
fonsSetFont(fs, fontNormal);
34+
fonsSetSize(fs, 124.0f);
35+
fonsSetColor(fs, white);
36+
fonsDrawText(fs, dx,dy,"The big ", &dx);
37+
38+
fonsSetSize(fs, 24.0f);
39+
fonsSetColor(fs, brown);
40+
fonsDrawText(fs, dx,dy,"brown fox", &dx);
41+
```
42+
43+
## Using Font Stash in your project
44+
45+
In order to use fontstash in your own project, just copy fontstash.h, stb_truetype.h, and potentially glstash.h to your project.
46+
In one C/C++ define FONTSTASH_IMPLEMENTATION before including the library to expand the font stash implementation in that file.
47+
48+
``` C
49+
#include <stdio.h> // malloc, free, fopen, fclose, ftell, fseek, fread
50+
#include <string.h> // memset
51+
#define FONTSTASH_IMPLEMENTATION // Expands implementation
52+
#include "fontstash.h"
53+
```
54+
55+
``` C
56+
#include <GLFW/glfw3.h> // Or any other GL header of your choice.
57+
#define GLSTASH_IMPLEMENTATION // Expands implementation
58+
#include "glstash.h"
59+
```
60+
61+
## Creating new rendering backend
62+
63+
The default rendering backend uses OpenGL to render the glyphs. If you want to render the text using some other API, or want tighter integration with your code base you can write your own rendering backend. Take a look at the [glstash.h](/src/glstash.h) for reference implementation.
64+
65+
The rendering interface FontStash assumes access to is defined in the FONSparams structure. The call to `glstInit()` fills in variables.
66+
67+
```C
68+
struct FONSparams {
69+
...
70+
void* userPtr;
71+
int (*renderCreate)(void* uptr, int width, int height);
72+
void (*renderUpdate)(void* uptr, int* rect, const unsigned char* data);
73+
void (*renderDraw)(void* uptr, const float* verts, const float* tcoords, const unsigned int* colors, int nverts);
74+
void (*renderDelete)(void* uptr);
75+
};
76+
```
77+
78+
- **renderCreate** is called to create renderer for specific API, this is where you should create a texture of given size.
79+
- return 1 of success, or 0 on failure.
80+
- **renderUpdate** is called to update texture data
81+
- _rect_ describes the region of the texture that has changed
82+
- _data_ pointer to full texture data
83+
- **renderDraw** is called when the font triangles should be drawn
84+
- _verts_ pointer to vertex position data, 2 floats per vertex
85+
- _tcoords_ pointer to texture coordinate data, 2 floats per vertex
86+
- _colors_ pointer to color data, 1 uint per vertex (or 4 bytes)
87+
- _nverts_ is the number of vertices to draw
88+
- **renderDelete** is called when the renderer should be deleted
89+
- **userPtr** is passed to all calls as first parameter
90+
91+
FontStash uses this API as follows:
92+
93+
```
94+
fonsDrawText() {
95+
foreach (glyph in input string) {
96+
if (internal buffer full) {
97+
updateTexture()
98+
render()
99+
}
100+
add glyph to interal draw buffer
101+
}
102+
updateTexture()
103+
render()
104+
}
105+
```
106+
107+
The size of the internal buffer is defined using `FONS_VERTEX_COUNT` define. The default value is 1024, you can override it when you include fontstash.h and specify the implementation:
108+
109+
``` C
110+
#define FONS_VERTEX_COUNT 2048
111+
#define FONTSTASH_IMPLEMENTATION // Expands implementation
112+
#include "fontstash.h"
113+
```
114+
115+
## Compiling
116+
117+
In order to compile the demo project, your will need to install [GLFW](http://www.glfw.org/) to compile.
118+
119+
FontStash example project uses [premake4](http://industriousone.com/premake) to build platform specific projects, now is good time to install it if you don't have it already. To build the example, navigate into the root folder in your favorite terminal, then:
120+
121+
- *OS X*: `premake4 xcode4`
122+
- *Windows*: `premake4 vs2010`
123+
- *Linux*: `premake4 gmake`
124+
125+
See premake4 documentation for full list of supported build file types. The projects will be created in `build` folder. An example of building and running the example on OS X:
126+
127+
```bash
128+
$ premake4 gmake
129+
$ cd build/
130+
$ make
131+
$ ./example
132+
```
133+
134+
# License
135+
The library is licensed under [zlib license](LICENSE.txt)
136+
137+
## Links
138+
Uses [stb_truetype](http://nothings.org) for font rendering.

‎example/FiraSans-Bold.ttf

186 KB
Binary file not shown.

‎example/FiraSans-Light.ttf

214 KB
Binary file not shown.

‎example/FiraSans-Regular.ttf

195 KB
Binary file not shown.

‎example/Roboto-Bold.ttf

133 KB
Binary file not shown.

‎example/Roboto-Light.ttf

137 KB
Binary file not shown.

‎example/Roboto-Regular.ttf

142 KB
Binary file not shown.

‎example/entypo.ttf

34.6 KB
Binary file not shown.

‎example/example.c

+767
Large diffs are not rendered by default.

‎example/glstash.h

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
//
2+
// Copyright (c) 2009-2013 Mikko Mononen memon@inside.org
3+
//
4+
// This software is provided 'as-is', without any express or implied
5+
// warranty. In no event will the authors be held liable for any damages
6+
// arising from the use of this software.
7+
// Permission is granted to anyone to use this software for any purpose,
8+
// including commercial applications, and to alter it and redistribute it
9+
// freely, subject to the following restrictions:
10+
// 1. The origin of this software must not be misrepresented; you must not
11+
// claim that you wrote the original software. If you use this software
12+
// in a product, an acknowledgment in the product documentation would be
13+
// appreciated but is not required.
14+
// 2. Altered source versions must be plainly marked as such, and must not be
15+
// misrepresented as being the original software.
16+
// 3. This notice may not be removed or altered from any source distribution.
17+
//
18+
#ifndef GLSTASH_H
19+
#define GLSTASH_H
20+
21+
int glstInit(struct FONSparams* params);
22+
unsigned int glstRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
23+
24+
#endif
25+
26+
#ifdef GLSTASH_IMPLEMENTATION
27+
28+
struct GLSTcontext {
29+
GLuint tex;
30+
int width, height;
31+
};
32+
33+
static int glst__renderCreate(void* userPtr, int width, int height)
34+
{
35+
struct GLSTcontext* gl = (struct GLSTcontext*)userPtr;
36+
glGenTextures(1, &gl->tex);
37+
if (!gl->tex) return 0;
38+
gl->width = width;
39+
gl->height = width;
40+
glBindTexture(GL_TEXTURE_2D, gl->tex);
41+
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gl->width, gl->height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0);
42+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
43+
return 1;
44+
}
45+
46+
static void glst__renderUpdate(void* userPtr, int* rect, const unsigned char* data)
47+
{
48+
struct GLSTcontext* gl = (struct GLSTcontext*)userPtr;
49+
if (gl->tex == 0) return;
50+
int w = rect[2] - rect[0];
51+
int h = rect[3] - rect[1];
52+
glBindTexture(GL_TEXTURE_2D, gl->tex);
53+
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
54+
glPixelStorei(GL_UNPACK_ROW_LENGTH, gl->width);
55+
glPixelStorei(GL_UNPACK_SKIP_PIXELS, rect[0]);
56+
glPixelStorei(GL_UNPACK_SKIP_ROWS, rect[1]);
57+
glTexSubImage2D(GL_TEXTURE_2D, 0, rect[0], rect[1], w, h, GL_ALPHA,GL_UNSIGNED_BYTE, data);
58+
}
59+
60+
static void glst__renderDraw(void* userPtr, const float* verts, const float* tcoords, const unsigned int* colors, int nverts)
61+
{
62+
struct GLSTcontext* gl = (struct GLSTcontext*)userPtr;
63+
if (gl->tex == 0) return;
64+
glBindTexture(GL_TEXTURE_2D, gl->tex);
65+
glEnable(GL_TEXTURE_2D);
66+
glEnableClientState(GL_VERTEX_ARRAY);
67+
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
68+
glEnableClientState(GL_COLOR_ARRAY);
69+
70+
glVertexPointer(2, GL_FLOAT, sizeof(float)*2, verts);
71+
glTexCoordPointer(2, GL_FLOAT, sizeof(float)*2, tcoords);
72+
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(unsigned int), colors);
73+
74+
glDrawArrays(GL_TRIANGLES, 0, nverts);
75+
76+
glDisable(GL_TEXTURE_2D);
77+
glDisableClientState(GL_VERTEX_ARRAY);
78+
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
79+
glDisableClientState(GL_COLOR_ARRAY);
80+
}
81+
82+
static void glst__renderDelete(void* userPtr)
83+
{
84+
struct GLSTcontext* gl = (struct GLSTcontext*)userPtr;
85+
if (gl->tex)
86+
glDeleteTextures(1, &gl->tex);
87+
gl->tex = 0;
88+
free(gl);
89+
}
90+
91+
92+
int glstInit(struct FONSparams* params)
93+
{
94+
struct GLSTcontext* gl = (struct GLSTcontext*)malloc(sizeof(struct GLSTcontext));
95+
if (gl == NULL) goto error;
96+
memset(gl, 0, sizeof(struct GLSTcontext));
97+
98+
params->renderCreate = glst__renderCreate;
99+
params->renderUpdate = glst__renderUpdate;
100+
params->renderDraw = glst__renderDraw;
101+
params->renderDelete = glst__renderDelete;
102+
params->userPtr = gl;
103+
104+
return 1;
105+
106+
error:
107+
if (gl != NULL) free(gl);
108+
return 0;
109+
}
110+
111+
unsigned int glstRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
112+
{
113+
return (r) | (g << 8) | (b << 16) | (a << 24);
114+
}
115+
116+
#endif

‎example/icons.txt

+431
Large diffs are not rendered by default.

‎example/images.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Image credits
2+
http://cuteoverload.com/2013/11/05/mom-taxi-xvi-birthday-party/
3+
http://cuteoverload.com/2013/11/05/benson-hedges-private-eye-in-the-case-of-the-crafty-craftsman/
4+
http://cuteoverload.com/2013/11/05/no-underwater-ballets/
5+
http://cuteoverload.com/2013/11/05/every-nose-has-a-story/
6+
http://cuteoverload.com/2013/11/04/nosevember-nozzle-nose/
7+
http://cuteoverload.com/2013/11/04/this-just-in-super-strength-cute/
8+
http://cuteoverload.com/2013/11/03/have-a-bunderful-sunday/
9+
http://cuteoverload.com/2013/11/02/caturday-sense-a-common-theme-here/
10+
http://cuteoverload.com/2013/11/01/nosevember-1st-24-hours-of-noses-1148pm-pt/
11+
http://cuteoverload.com/2013/04/02/there-might-be-something-cuter-than-this/
12+
http://cuteoverload.com/2013/07/17/snorting-micro-peeg-gets-belleh-rubs-interwebs-explode/
13+
http://cuteoverload.com/2013/08/07/bark-in-the-park-v3-0/

‎example/images/image1.jpg

25.2 KB
Loading

‎example/images/image10.jpg

3.36 KB
Loading

‎example/images/image11.jpg

3.73 KB
Loading

‎example/images/image12.jpg

5.32 KB
Loading

‎example/images/image2.jpg

23.5 KB
Loading

‎example/images/image3.jpg

28.6 KB
Loading

‎example/images/image4.jpg

23.3 KB
Loading

‎example/images/image5.jpg

26.5 KB
Loading

‎example/images/image6.jpg

24.5 KB
Loading

‎example/images/image7.jpg

25 KB
Loading

‎example/images/image8.jpg

24 KB
Loading

‎example/images/image9.jpg

3.94 KB
Loading

‎example/mfglabsiconset-webfont.ttf

44.1 KB
Binary file not shown.

‎example/templates.xml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<style>
2+
$color = rgba(255,255,255,255);
3+
4+
@font-face {
5+
font-family: "Roboto";
6+
font-weight: bold;
7+
src: "../examples/Roboto-light.ttf";
8+
}
9+
@font-face {
10+
font-family: "Entypo";
11+
src: "../examples/entypo.ttf";
12+
}
13+
14+
.icon-search {
15+
font-family: "Entypo";
16+
font-size: 28px;
17+
content: 0x1F50D;
18+
}
19+
.icon-circled-cross {
20+
font-family: "Entypo";
21+
font-size: 28px;
22+
content: 0x2716;
23+
}
24+
.icon-plus {
25+
font-family: "Entypo";
26+
font-size: 28px;
27+
content: "\2796";
28+
}
29+
30+
.search-box {
31+
padding: 5px;
32+
}
33+
34+
.footer-buttons {
35+
padding: 5px;
36+
}
37+
38+
/* default style */
39+
header {
40+
height: 30px;
41+
/*font-size: 26px;*/
42+
}
43+
44+
input {
45+
height: ;
46+
font-size: 26px;
47+
}
48+
49+
</style>
50+
51+
<template id="material-window">
52+
<win width="300px" height="500px" align="justify">
53+
<col align="justify">
54+
<header>Materials</header>
55+
<row height="auto" style="search-box">
56+
<input id="search" grow="1">
57+
<icon style="icon-search" />
58+
<field grow="1" />
59+
<icon style="icon-circled-cross" />
60+
</input>
61+
</row>
62+
<col id="materials" grow="1" height="10px" align="justify" />
63+
<row height="auto" style="footer-buttons">
64+
<spacer grow="1" />
65+
<button id="add-item"><icon style="icon-plus"/>Add</button>
66+
<button id="remove">Remove</button>
67+
</row>
68+
</col>
69+
</win>
70+
</template>
71+
72+
<template id="material-item">
73+
<item padding="4px" align="center">
74+
<img id="thumbnail" width="25px" height="25px" />
75+
<label id="name" grow="1" />
76+
</item>
77+
</template>
78+
79+
<template id="material-noitems">
80+
<col padding="4px" pack="center" align="center">
81+
<icon src="sad-face" />
82+
<label>Sorry, no items found.</label>
83+
</col>
84+
</template>

‎premake4.lua

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
local action = _ACTION or ""
3+
4+
solution "nanovg"
5+
location ( "build" )
6+
configurations { "Debug", "Release" }
7+
platforms {"native", "x64", "x32"}
8+
9+
project "example"
10+
kind "ConsoleApp"
11+
language "C"
12+
files { "example/*.c", "src/*.h", "src/*.c" }
13+
includedirs { "src" }
14+
targetdir("build")
15+
16+
configuration { "linux" }
17+
links { "X11","Xrandr", "rt", "GL", "GLU", "pthread" }
18+
19+
configuration { "windows" }
20+
links { "glu32","opengl32", "gdi32", "winmm", "user32" }
21+
22+
configuration { "macosx" }
23+
links { "glfw3" }
24+
linkoptions { "-framework OpenGL", "-framework Cocoa", "-framework IOKit" }
25+
26+
configuration "Debug"
27+
defines { "DEBUG" }
28+
flags { "Symbols", "ExtraWarnings"}
29+
30+
configuration "Release"
31+
defines { "NDEBUG" }
32+
flags { "Optimize", "ExtraWarnings"}

‎src/fontstash.h

+1,134
Large diffs are not rendered by default.

‎src/glnanovg.h

+690
Large diffs are not rendered by default.

‎src/nanovg.c

+1,586
Large diffs are not rendered by default.

‎src/nanovg.h

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
//
2+
// Copyright (c) 2013 Mikko Mononen memon@inside.org
3+
//
4+
// This software is provided 'as-is', without any express or implied
5+
// warranty. In no event will the authors be held liable for any damages
6+
// arising from the use of this software.
7+
// Permission is granted to anyone to use this software for any purpose,
8+
// including commercial applications, and to alter it and redistribute it
9+
// freely, subject to the following restrictions:
10+
// 1. The origin of this software must not be misrepresented; you must not
11+
// claim that you wrote the original software. If you use this software
12+
// in a product, an acknowledgment in the product documentation would be
13+
// appreciated but is not required.
14+
// 2. Altered source versions must be plainly marked as such, and must not be
15+
// misrepresented as being the original software.
16+
// 3. This notice may not be removed or altered from any source distribution.
17+
//
18+
19+
#ifndef NANOVG_H
20+
#define NANOVG_H
21+
22+
#define NVG_PI 3.14159265358979323846264338327f
23+
24+
enum NVGdir {
25+
NVG_CCW = 1,
26+
NVG_CW = 2,
27+
};
28+
enum NVGdir2 {
29+
NVG_SOLID = 1, // ccw
30+
NVG_HOLE = 2, // cw
31+
};
32+
33+
enum NVGpatternRepeat {
34+
NVG_REPEATX = 0x01,
35+
NVG_REPEATY = 0x02,
36+
};
37+
38+
enum NVGaling {
39+
// Horizontal align
40+
NVG_ALIGN_LEFT = 1<<0, // Default
41+
NVG_ALIGN_CENTER = 1<<1,
42+
NVG_ALIGN_RIGHT = 1<<2,
43+
// Vertical align
44+
NVG_ALIGN_TOP = 1<<3,
45+
NVG_ALIGN_MIDDLE = 1<<4,
46+
NVG_ALIGN_BOTTOM = 1<<5,
47+
NVG_ALIGN_BASELINE = 1<<6, // Default
48+
};
49+
50+
51+
// Used by the rendering API
52+
enum NVGtexture {
53+
NVG_TEXTURE_ALPHA = 0x01,
54+
NVG_TEXTURE_RGBA = 0x02,
55+
};
56+
57+
struct NVGpaint
58+
{
59+
float xform[6];
60+
float extent[2];
61+
float radius;
62+
float feather;
63+
unsigned int innerColor;
64+
unsigned int outerColor;
65+
int image;
66+
int repeat;
67+
};
68+
69+
struct NVGscissor
70+
{
71+
float xform[6];
72+
float extent[2];
73+
};
74+
75+
struct NVGvertex {
76+
float x,y,u,v;
77+
};
78+
79+
struct NVGpath {
80+
int first;
81+
int count;
82+
unsigned char closed;
83+
int nbevel;
84+
struct NVGvertex* fill;
85+
int nfill;
86+
struct NVGvertex* stroke;
87+
int nstroke;
88+
int winding;
89+
};
90+
91+
struct NVGparams {
92+
void* userPtr;
93+
int (*renderCreate)(void* uptr);
94+
int (*renderCreateTexture)(void* uptr, int type, int w, int h, const unsigned char* data);
95+
int (*renderDeleteTexture)(void* uptr, int image);
96+
int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data);
97+
int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h);
98+
void (*renderFill)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, const float* bounds, const struct NVGpath* paths, int npaths);
99+
void (*renderStroke)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, float aasize, float strokeWidth, const struct NVGpath* paths, int npaths);
100+
void (*renderTriangles)(void* uptr, struct NVGpaint* paint, struct NVGscissor* scissor, int image, const struct NVGvertex* verts, int nverts);
101+
void (*renderDelete)(void* uptr);
102+
};
103+
104+
// Contructor and destructor.
105+
struct NVGcontext* nvgCreateInternal(struct NVGparams* params);
106+
void nvgDeleteInternal(struct NVGcontext* ctx);
107+
108+
// Color utils
109+
unsigned int nvgRGB(unsigned char r, unsigned char g, unsigned char b);
110+
unsigned int nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
111+
unsigned int nvgLerpRGBA(unsigned int c0, unsigned int c1, float u);
112+
113+
// State handling
114+
void nvgSave(struct NVGcontext* ctx);
115+
void nvgRestore(struct NVGcontext* ctx);
116+
void nvgReset(struct NVGcontext* ctx);
117+
118+
// State setting
119+
void nvgStrokeColor(struct NVGcontext* ctx, unsigned int color);
120+
void nvgStrokePaint(struct NVGcontext* ctx, struct NVGpaint paint);
121+
122+
void nvgFillColor(struct NVGcontext* ctx, unsigned int color);
123+
void nvgFillPaint(struct NVGcontext* ctx, struct NVGpaint paint);
124+
125+
void nvgMiterLimit(struct NVGcontext* ctx, float limit);
126+
void nvgStrokeWidth(struct NVGcontext* ctx, float size);
127+
128+
void nvgResetTransform(struct NVGcontext* ctx);
129+
void nvgTransform(struct NVGcontext* ctx, float a, float b, float c, float d, float e, float f);
130+
void nvgTranslate(struct NVGcontext* ctx, float x, float y);
131+
void nvgRotate(struct NVGcontext* ctx, float angle);
132+
void nvgScale(struct NVGcontext* ctx, float x, float y);
133+
134+
// Images
135+
int nvgCreateImage(struct NVGcontext* ctx, const char* filename);
136+
int nvgCreateImageMem(struct NVGcontext* ctx, unsigned char* data, int ndata, int freeData);
137+
int nvgCreateImageRGBA(struct NVGcontext* ctx, int w, int h, const unsigned char* data);
138+
void nvgUpdateImage(struct NVGcontext* ctx, int image, const unsigned char* data);
139+
void nvgImageSize(struct NVGcontext* ctx, int image, int* w, int* h);
140+
void nvgDeleteImage(struct NVGcontext* ctx, int image);
141+
142+
// Paints
143+
struct NVGpaint nvgLinearGradient(struct NVGcontext* ctx, float sx, float sy, float ex, float ey, unsigned int icol, unsigned int ocol);
144+
struct NVGpaint nvgBoxGradient(struct NVGcontext* ctx, float x, float y, float w, float h, float r, float f, unsigned int icol, unsigned int ocol);
145+
struct NVGpaint nvgRadialGradient(struct NVGcontext* ctx, float cx, float cy, float inr, float outr, unsigned int icol, unsigned int ocol);
146+
struct NVGpaint nvgImagePattern(struct NVGcontext* ctx, float ox, float oy, float ex, float ey, float angle, int image, int repeat);
147+
148+
// Scissoring
149+
void nvgScissor(struct NVGcontext* ctx, float x, float y, float w, float h);
150+
void nvgResetScissor(struct NVGcontext* ctx);
151+
152+
// Draw
153+
void nvgBeginFrame(struct NVGcontext* ctx);
154+
155+
void nvgBeginPath(struct NVGcontext* ctx);
156+
void nvgMoveTo(struct NVGcontext* ctx, float x, float y);
157+
void nvgLineTo(struct NVGcontext* ctx, float x, float y);
158+
void nvgBezierTo(struct NVGcontext* ctx, float c1x, float c1y, float c2x, float c2y, float x, float y);
159+
void nvgArcTo(struct NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius);
160+
void nvgClosePath(struct NVGcontext* ctx);
161+
void nvgPathWinding(struct NVGcontext* ctx, int dir);
162+
163+
void nvgArc(struct NVGcontext* ctx, float cx, float cy, float r, float a0, float a1, int dir);
164+
void nvgRect(struct NVGcontext* ctx, float x, float y, float w, float h);
165+
void nvgRoundedRect(struct NVGcontext* ctx, float x, float y, float w, float h, float r);
166+
void nvgEllipse(struct NVGcontext* ctx, float cx, float cy, float rx, float ry);
167+
void nvgCircle(struct NVGcontext* ctx, float cx, float cy, float r);
168+
169+
void nvgFill(struct NVGcontext* ctx);
170+
void nvgStroke(struct NVGcontext* ctx);
171+
172+
// Text
173+
174+
// Add fonts
175+
int nvgCreateFont(struct NVGcontext* ctx, const char* name, const char* path);
176+
int nvgCreateFontMem(struct NVGcontext* ctx, const char* name, unsigned char* data, int ndata, int freeData);
177+
178+
// State setting
179+
void nvgFontSize(struct NVGcontext* ctx, float size);
180+
void nvgLetterSpacing(struct NVGcontext* ctx, float spacing);
181+
void nvgFontBlur(struct NVGcontext* ctx, float blur);
182+
void nvgTextAlign(struct NVGcontext* ctx, int align);
183+
void nvgFontFaceId(struct NVGcontext* ctx, int font);
184+
void nvgFontFace(struct NVGcontext* ctx, const char* font);
185+
186+
// Draw text
187+
void nvgText(struct NVGcontext* ctx, float x, float y, const char* string);
188+
189+
// Measure text
190+
void nvgTextBounds(struct NVGcontext* ctx, const char* string, float* width, float* bounds);
191+
void nvgVertMetrics(struct NVGcontext* ctx, float* ascender, float* descender, float* lineh);
192+
193+
194+
#endif // NANOVG_H

‎src/stb_image.c

+4,673
Large diffs are not rendered by default.

‎src/stb_truetype.h

+2,065
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.