2023-02-21 18:41:53 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ofMain.h"
|
2023-02-22 18:28:56 +01:00
|
|
|
#include "ofTrueTypeFont.h"
|
|
|
|
#include <freetype2/freetype/freetype.h>
|
2023-02-21 18:41:53 +01:00
|
|
|
#include <msdf-atlas-gen/msdf-atlas-gen.h>
|
2023-02-27 16:24:14 +01:00
|
|
|
#include <msdf-atlas-gen/types.h>
|
2023-02-21 18:41:53 +01:00
|
|
|
#include "conversion.h"
|
|
|
|
|
|
|
|
namespace ofxMsdfgen {
|
|
|
|
struct AtlasSettings {
|
|
|
|
float maxCornerAngle = 3.0;
|
2023-02-27 16:24:14 +01:00
|
|
|
float scale = 256.0;
|
2023-02-21 18:41:53 +01:00
|
|
|
float minimumScale = 24.0;
|
|
|
|
float pixelRange = 2.0;
|
|
|
|
float miterLimit = 1.0;
|
2023-02-27 16:24:14 +01:00
|
|
|
string characters = "charset::ascii";
|
2023-02-22 18:28:56 +01:00
|
|
|
#ifdef TARGET_EMSCRIPTEN
|
|
|
|
int threadCount = 1;
|
|
|
|
#else
|
|
|
|
int threadCount = 4;
|
|
|
|
#endif
|
2023-02-21 18:41:53 +01:00
|
|
|
};
|
|
|
|
class Atlas {
|
|
|
|
public:
|
2023-02-22 18:28:56 +01:00
|
|
|
Atlas();
|
|
|
|
~Atlas();
|
2023-02-21 18:41:53 +01:00
|
|
|
void setup(string _fontPath);
|
|
|
|
void setup(string _fontPath, AtlasSettings _settings);
|
|
|
|
bool generate();
|
|
|
|
const ofImage & getAtlasImage();
|
2023-02-27 16:24:14 +01:00
|
|
|
const vector <GlyphGeometry> & getGlyphGeometries();
|
2023-02-21 18:41:53 +01:00
|
|
|
AtlasSettings settings;
|
|
|
|
private:
|
|
|
|
string fontPath;
|
|
|
|
ofImage atlasImage;
|
2023-02-27 16:24:14 +01:00
|
|
|
vector <GlyphGeometry> glyphGeometries;
|
2023-02-21 18:41:53 +01:00
|
|
|
};
|
|
|
|
}
|