python opengl freetype

Solutions on MaxInterview for python opengl freetype by the best coders in the world

showing results for - "python opengl freetype"
Camilla
17 Oct 2017
1import freetype as ft
2
3# change the filename if necessary
4face = ft.Face("Vera.ttf")
5# the size is specified in 1/64 pixel
6face.set_char_size(48*64)
7# initialize Stroker
8stroker = ft.Stroker()
9# change the outline size if necessary
10stroker.set(1, ft.FT_STROKER_LINECAPS['FT_STROKER_LINECAP_ROUND'], ft.FT_STROKER_LINEJOINS['FT_STROKER_LINEJOIN_ROUND'], 0)
11# override default load flags to avoid rendering the character during loading
12face.load_char('S', ft.FT_LOAD_FLAGS['FT_LOAD_DEFAULT'])
13# initialize C FreeType Glyph object
14glyph = ft.FT_Glyph()
15# extract independent glyph from the face
16ft.FT_Get_Glyph(face.glyph._FT_GlyphSlot, ft.byref(glyph))
17# initialize Python FreeType Glyph object
18glyph = ft.Glyph(glyph)
19# stroke border and check errors
20error = ft.FT_Glyph_StrokeBorder(ft.byref(glyph._FT_Glyph), stroker._FT_Stroker, False, False)
21if error:
22    raise ft.FT_Exception(error)
23# bitmapGlyph is the rendered glyph that we want
24bitmapGlyph = glyph.to_bitmap(ft.FT_RENDER_MODES['FT_RENDER_MODE_NORMAL'], 0)
25