add FontManager, Font classes
This commit is contained in:
parent
3c348fe893
commit
7eba046aa4
@ -22,9 +22,9 @@ end
|
|||||||
|
|
||||||
task :gui => :library do
|
task :gui => :library do
|
||||||
base_env.clone(clone: :all) do |env|
|
base_env.clone(clone: :all) do |env|
|
||||||
env["CFLAGS"] += `sdl2-config --cflags`.split(" ")
|
env["CFLAGS"] += `sdl2-config --cflags`.split(" ") + `freetype-config --cflags`.split(" ")
|
||||||
env["CXXFLAGS"] += `sdl2-config --cflags`.split(" ")
|
env["CXXFLAGS"] += `sdl2-config --cflags`.split(" ") + `freetype-config --cflags`.split(" ")
|
||||||
env["LDCMD"] += `sdl2-config --libs`.split(" ")
|
env["LDCMD"] += `sdl2-config --libs`.split(" ") + `freetype-config --libs`.split(" ")
|
||||||
env["LIBS"] += ["dl", "GL"]
|
env["LIBS"] += ["dl", "GL"]
|
||||||
env.Program("^/jes", Dir["src/gui/**/*.{cc,c}"])
|
env.Program("^/jes", Dir["src/gui/**/*.{cc,c}"])
|
||||||
end
|
end
|
||||||
|
18
src/gui/Font.cc
Normal file
18
src/gui/Font.cc
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include "Font.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace jes
|
||||||
|
{
|
||||||
|
bool Font::load(FT_Library ft, const char * fname, size_t size)
|
||||||
|
{
|
||||||
|
if (FT_New_Face(ft, fname, 0, &m_face) != 0)
|
||||||
|
{
|
||||||
|
std::cerr << "Could not load font " << fname << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FT_Set_Pixel_Sizes(m_face, 0, size);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
21
src/gui/Font.h
Normal file
21
src/gui/Font.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef JES_FONT_H
|
||||||
|
#define JES_FONT_H
|
||||||
|
|
||||||
|
#include "jes/Ref.h"
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
namespace jes
|
||||||
|
{
|
||||||
|
class Font
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool load(FT_Library ft, const char * fname, size_t size);
|
||||||
|
protected:
|
||||||
|
FT_Face m_face;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Ref<Font> FontRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
14
src/gui/FontManager.cc
Normal file
14
src/gui/FontManager.cc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "FontManager.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace jes
|
||||||
|
{
|
||||||
|
FontManager::FontManager()
|
||||||
|
{
|
||||||
|
if (FT_Init_FreeType(&m_ft) != 0)
|
||||||
|
{
|
||||||
|
std::cerr << "Error initializing FreeType" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
src/gui/FontManager.h
Normal file
21
src/gui/FontManager.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef JES_FONTMANAGER_H
|
||||||
|
#define JES_FONTMANAGER_H
|
||||||
|
|
||||||
|
#include "jes/Ref.h"
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
namespace jes
|
||||||
|
{
|
||||||
|
class FontManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FontManager();
|
||||||
|
protected:
|
||||||
|
FT_Library m_ft;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Ref<FontManager> FontManagerRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user