Class: ImFontAtlas
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- ImFontAtlas
- Defined in:
- lib/imgui.rb
Overview
Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding:
- One or more fonts.
- Custom graphics data needed to render the shapes needed by Dear ImGui.
- Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas).
It is the user-code responsibility to setup/build the atlas, then upload the pixel data into a texture accessible by your graphics api.
- Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you.
- Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
- Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples)
- Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API.
This value will be passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details.
Common pitfalls:
-
If you pass a ‘glyph_ranges’ array to AddFont*** functions, you need to make sure that your array persist up until the atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data.
-
Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction. You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won’t be freed,
-
Even though many functions are suffixed with “TTF”, OTF data is supported just as well.
-
This is an old API and it is currently awkward for those and various other reasons! We will address them in the future!
Class Method Summary collapse
Instance Method Summary collapse
- #AddCustomRectFontGlyph(font, id, width, height, advance_x, offset = ImVec2.create(0,0)) ⇒ Object
- #AddCustomRectRegular(width, height) ⇒ Object
- #AddFont(font_cfg) ⇒ Object
- #AddFontDefault(font_cfg = nil) ⇒ Object
- #AddFontFromFileTTF(filename, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
- #AddFontFromMemoryCompressedBase85TTF(compressed_font_data_base85, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
- #AddFontFromMemoryCompressedTTF(compressed_font_data, compressed_font_data_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
- #AddFontFromMemoryTTF(font_data, font_data_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
- #Build ⇒ Object
- #CalcCustomRectUV(rect, out_uv_min, out_uv_max) ⇒ Object
- #Clear ⇒ Object
- #ClearFonts ⇒ Object
- #ClearInputData ⇒ Object
- #ClearTexData ⇒ Object
- #destroy ⇒ Object
- #GetCustomRectByIndex(index) ⇒ Object
- #GetGlyphRangesChineseFull ⇒ Object
- #GetGlyphRangesChineseSimplifiedCommon ⇒ Object
- #GetGlyphRangesCyrillic ⇒ Object
- #GetGlyphRangesDefault ⇒ Object
- #GetGlyphRangesGreek ⇒ Object
- #GetGlyphRangesJapanese ⇒ Object
- #GetGlyphRangesKorean ⇒ Object
- #GetGlyphRangesThai ⇒ Object
- #GetGlyphRangesVietnamese ⇒ Object
- #GetMouseCursorTexData(cursor, out_offset, out_size, out_uv_border, out_uv_fill) ⇒ Object
- #GetTexDataAsAlpha8(out_pixels, out_width, out_height, out_bytes_per_pixel = nil) ⇒ Object
- #GetTexDataAsRGBA32(out_pixels, out_width, out_height, out_bytes_per_pixel = nil) ⇒ Object
- #IsBuilt ⇒ Object
- #SetTexID(id) ⇒ Object
Class Method Details
.create ⇒ Object
1415 1416 1417 |
# File 'lib/imgui.rb', line 1415 def self.create() return ImFontAtlas.new(ImGui::ImFontAtlas_ImFontAtlas()) end |
Instance Method Details
#AddCustomRectFontGlyph(font, id, width, height, advance_x, offset = ImVec2.create(0,0)) ⇒ Object
1307 1308 1309 |
# File 'lib/imgui.rb', line 1307 def AddCustomRectFontGlyph(font, id, width, height, advance_x, offset = ImVec2.create(0,0)) ImGui::ImFontAtlas_AddCustomRectFontGlyph(self, font, id, width, height, advance_x, offset) end |
#AddCustomRectRegular(width, height) ⇒ Object
1311 1312 1313 |
# File 'lib/imgui.rb', line 1311 def AddCustomRectRegular(width, height) ImGui::ImFontAtlas_AddCustomRectRegular(self, width, height) end |
#AddFont(font_cfg) ⇒ Object
1315 1316 1317 |
# File 'lib/imgui.rb', line 1315 def AddFont(font_cfg) ImGui::ImFontAtlas_AddFont(self, font_cfg) end |
#AddFontDefault(font_cfg = nil) ⇒ Object
1319 1320 1321 |
# File 'lib/imgui.rb', line 1319 def AddFontDefault(font_cfg = nil) ImGui::ImFontAtlas_AddFontDefault(self, font_cfg) end |
#AddFontFromFileTTF(filename, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
1323 1324 1325 |
# File 'lib/imgui.rb', line 1323 def AddFontFromFileTTF(filename, size_pixels, font_cfg = nil, glyph_ranges = nil) ImGui::ImFontAtlas_AddFontFromFileTTF(self, filename, size_pixels, font_cfg, glyph_ranges) end |
#AddFontFromMemoryCompressedBase85TTF(compressed_font_data_base85, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
1327 1328 1329 |
# File 'lib/imgui.rb', line 1327 def AddFontFromMemoryCompressedBase85TTF(compressed_font_data_base85, size_pixels, font_cfg = nil, glyph_ranges = nil) ImGui::ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(self, compressed_font_data_base85, size_pixels, font_cfg, glyph_ranges) end |
#AddFontFromMemoryCompressedTTF(compressed_font_data, compressed_font_data_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
1331 1332 1333 |
# File 'lib/imgui.rb', line 1331 def AddFontFromMemoryCompressedTTF(compressed_font_data, compressed_font_data_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ImGui::ImFontAtlas_AddFontFromMemoryCompressedTTF(self, compressed_font_data, compressed_font_data_size, size_pixels, font_cfg, glyph_ranges) end |
#AddFontFromMemoryTTF(font_data, font_data_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
1335 1336 1337 |
# File 'lib/imgui.rb', line 1335 def AddFontFromMemoryTTF(font_data, font_data_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ImGui::ImFontAtlas_AddFontFromMemoryTTF(self, font_data, font_data_size, size_pixels, font_cfg, glyph_ranges) end |
#Build ⇒ Object
1339 1340 1341 |
# File 'lib/imgui.rb', line 1339 def Build() ImGui::ImFontAtlas_Build(self) end |
#CalcCustomRectUV(rect, out_uv_min, out_uv_max) ⇒ Object
1343 1344 1345 |
# File 'lib/imgui.rb', line 1343 def CalcCustomRectUV(rect, out_uv_min, out_uv_max) ImGui::ImFontAtlas_CalcCustomRectUV(self, rect, out_uv_min, out_uv_max) end |
#Clear ⇒ Object
1347 1348 1349 |
# File 'lib/imgui.rb', line 1347 def Clear() ImGui::ImFontAtlas_Clear(self) end |
#ClearFonts ⇒ Object
1351 1352 1353 |
# File 'lib/imgui.rb', line 1351 def ClearFonts() ImGui::ImFontAtlas_ClearFonts(self) end |
#ClearInputData ⇒ Object
1355 1356 1357 |
# File 'lib/imgui.rb', line 1355 def ClearInputData() ImGui::ImFontAtlas_ClearInputData(self) end |
#ClearTexData ⇒ Object
1359 1360 1361 |
# File 'lib/imgui.rb', line 1359 def ClearTexData() ImGui::ImFontAtlas_ClearTexData(self) end |
#destroy ⇒ Object
1427 1428 1429 |
# File 'lib/imgui.rb', line 1427 def destroy() ImGui::ImFontAtlas_destroy(self) end |
#GetCustomRectByIndex(index) ⇒ Object
1363 1364 1365 |
# File 'lib/imgui.rb', line 1363 def GetCustomRectByIndex(index) ImGui::ImFontAtlas_GetCustomRectByIndex(self, index) end |
#GetGlyphRangesChineseFull ⇒ Object
1367 1368 1369 |
# File 'lib/imgui.rb', line 1367 def GetGlyphRangesChineseFull() ImGui::ImFontAtlas_GetGlyphRangesChineseFull(self) end |
#GetGlyphRangesChineseSimplifiedCommon ⇒ Object
1371 1372 1373 |
# File 'lib/imgui.rb', line 1371 def GetGlyphRangesChineseSimplifiedCommon() ImGui::ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(self) end |
#GetGlyphRangesCyrillic ⇒ Object
1375 1376 1377 |
# File 'lib/imgui.rb', line 1375 def GetGlyphRangesCyrillic() ImGui::ImFontAtlas_GetGlyphRangesCyrillic(self) end |
#GetGlyphRangesDefault ⇒ Object
1379 1380 1381 |
# File 'lib/imgui.rb', line 1379 def GetGlyphRangesDefault() ImGui::ImFontAtlas_GetGlyphRangesDefault(self) end |
#GetGlyphRangesGreek ⇒ Object
1383 1384 1385 |
# File 'lib/imgui.rb', line 1383 def GetGlyphRangesGreek() ImGui::ImFontAtlas_GetGlyphRangesGreek(self) end |
#GetGlyphRangesJapanese ⇒ Object
1387 1388 1389 |
# File 'lib/imgui.rb', line 1387 def GetGlyphRangesJapanese() ImGui::ImFontAtlas_GetGlyphRangesJapanese(self) end |
#GetGlyphRangesKorean ⇒ Object
1391 1392 1393 |
# File 'lib/imgui.rb', line 1391 def GetGlyphRangesKorean() ImGui::ImFontAtlas_GetGlyphRangesKorean(self) end |
#GetGlyphRangesThai ⇒ Object
1395 1396 1397 |
# File 'lib/imgui.rb', line 1395 def GetGlyphRangesThai() ImGui::ImFontAtlas_GetGlyphRangesThai(self) end |
#GetGlyphRangesVietnamese ⇒ Object
1399 1400 1401 |
# File 'lib/imgui.rb', line 1399 def GetGlyphRangesVietnamese() ImGui::ImFontAtlas_GetGlyphRangesVietnamese(self) end |
#GetMouseCursorTexData(cursor, out_offset, out_size, out_uv_border, out_uv_fill) ⇒ Object
1403 1404 1405 |
# File 'lib/imgui.rb', line 1403 def GetMouseCursorTexData(cursor, out_offset, out_size, out_uv_border, out_uv_fill) ImGui::ImFontAtlas_GetMouseCursorTexData(self, cursor, out_offset, out_size, out_uv_border, out_uv_fill) end |
#GetTexDataAsAlpha8(out_pixels, out_width, out_height, out_bytes_per_pixel = nil) ⇒ Object
1407 1408 1409 |
# File 'lib/imgui.rb', line 1407 def GetTexDataAsAlpha8(out_pixels, out_width, out_height, out_bytes_per_pixel = nil) ImGui::ImFontAtlas_GetTexDataAsAlpha8(self, out_pixels, out_width, out_height, out_bytes_per_pixel) end |
#GetTexDataAsRGBA32(out_pixels, out_width, out_height, out_bytes_per_pixel = nil) ⇒ Object
1411 1412 1413 |
# File 'lib/imgui.rb', line 1411 def GetTexDataAsRGBA32(out_pixels, out_width, out_height, out_bytes_per_pixel = nil) ImGui::ImFontAtlas_GetTexDataAsRGBA32(self, out_pixels, out_width, out_height, out_bytes_per_pixel) end |
#IsBuilt ⇒ Object
1419 1420 1421 |
# File 'lib/imgui.rb', line 1419 def IsBuilt() ImGui::ImFontAtlas_IsBuilt(self) end |
#SetTexID(id) ⇒ Object
1423 1424 1425 |
# File 'lib/imgui.rb', line 1423 def SetTexID(id) ImGui::ImFontAtlas_SetTexID(self, id) end |