TTF/OTF Font Test – CODE

true type font test - GLSL Hacker / FreeType-GL plugin

Since version 0.8.0, GLSL Hacker comes with a new plugin based on FreeType-GL, that allows to load any TTF (True Type Font) or OTF (Open Type Font) font file. I also added a Lua layer in GLSL Hacker libs folder to make font management even easier (libs/lua/gx_font.lua).

Time to time, when I find an interesting font, I do a test, just to be sure that the plugin is able to handle it. I just tested this font and tried to reproduce their example with GLSL Hacker.

This GLSL Hacker demo is available in the code sample pack (host_api/freetype-gl/demo_gl3_v3.xml).

This demo use the high level Lua lib (gx_font.lua) to handle fonts.

INIT script:

lib_dir = gh_utils.get_scripting_libs_dir() 		
dofile(lib_dir .. "lua/gx_font.lua")
local demo_dir = gh_utils.get_demo_dir()
font1 = ftgl_load_font_v2(demo_dir .. "data/CODE Bold.otf", 160, 2, 1)
font2 = ftgl_load_font_v2(demo_dir .. "data/CODE Light.otf", 160, 1, 2)


FRAME script:

elapsed_time = gh_utils.get_elapsed_time()

gh_renderer.clear_color_depth_buffers(0.0, 0.0, 0.0, 1.0, 1.0)

ftgl_print(font2, 20, 160, 1, 1, 1, 1, "GEEKS3D")

ftgl_print(font1, 20, 290, 0.8, 0.8, 0.9, 1.0, "GLSL")
ftgl_print(font1, 20, 420, 0.5, 0.5, 0.6, 1.0, "HACKER")



SIZE script:

winW, winH = gh_window.getsize(0)
ftgl_resize(winW, winH)

Leave a Comment

Your email address will not be published. Required fields are marked *