Class: ImFontAtlas

Inherits:
FFI::Struct
  • Object
show all
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

Class Method Details

.createObject



1336
1337
1338
# File 'lib/imgui.rb', line 1336

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



1228
1229
1230
# File 'lib/imgui.rb', line 1228

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



1232
1233
1234
# File 'lib/imgui.rb', line 1232

def AddCustomRectRegular(width, height)
  ImGui::ImFontAtlas_AddCustomRectRegular(self, width, height)
end

#AddFont(font_cfg) ⇒ Object



1236
1237
1238
# File 'lib/imgui.rb', line 1236

def AddFont(font_cfg)
  ImGui::ImFontAtlas_AddFont(self, font_cfg)
end

#AddFontDefault(font_cfg = nil) ⇒ Object



1240
1241
1242
# File 'lib/imgui.rb', line 1240

def AddFontDefault(font_cfg = nil)
  ImGui::ImFontAtlas_AddFontDefault(self, font_cfg)
end

#AddFontFromFileTTF(filename, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object



1244
1245
1246
# File 'lib/imgui.rb', line 1244

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



1248
1249
1250
# File 'lib/imgui.rb', line 1248

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_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object



1252
1253
1254
# File 'lib/imgui.rb', line 1252

def AddFontFromMemoryCompressedTTF(compressed_font_data, compressed_font_size, size_pixels, font_cfg = nil, glyph_ranges = nil)
  ImGui::ImFontAtlas_AddFontFromMemoryCompressedTTF(self, compressed_font_data, compressed_font_size, size_pixels, font_cfg, glyph_ranges)
end

#AddFontFromMemoryTTF(font_data, font_size, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object



1256
1257
1258
# File 'lib/imgui.rb', line 1256

def AddFontFromMemoryTTF(font_data, font_size, size_pixels, font_cfg = nil, glyph_ranges = nil)
  ImGui::ImFontAtlas_AddFontFromMemoryTTF(self, font_data, font_size, size_pixels, font_cfg, glyph_ranges)
end

#BuildObject



1260
1261
1262
# File 'lib/imgui.rb', line 1260

def Build()
  ImGui::ImFontAtlas_Build(self)
end

#CalcCustomRectUV(rect, out_uv_min, out_uv_max) ⇒ Object



1264
1265
1266
# File 'lib/imgui.rb', line 1264

def CalcCustomRectUV(rect, out_uv_min, out_uv_max)
  ImGui::ImFontAtlas_CalcCustomRectUV(self, rect, out_uv_min, out_uv_max)
end

#ClearObject



1268
1269
1270
# File 'lib/imgui.rb', line 1268

def Clear()
  ImGui::ImFontAtlas_Clear(self)
end

#ClearFontsObject



1272
1273
1274
# File 'lib/imgui.rb', line 1272

def ClearFonts()
  ImGui::ImFontAtlas_ClearFonts(self)
end

#ClearInputDataObject



1276
1277
1278
# File 'lib/imgui.rb', line 1276

def ClearInputData()
  ImGui::ImFontAtlas_ClearInputData(self)
end

#ClearTexDataObject



1280
1281
1282
# File 'lib/imgui.rb', line 1280

def ClearTexData()
  ImGui::ImFontAtlas_ClearTexData(self)
end

#destroyObject



1348
1349
1350
# File 'lib/imgui.rb', line 1348

def destroy()
  ImGui::ImFontAtlas_destroy(self)
end

#GetCustomRectByIndex(index) ⇒ Object



1284
1285
1286
# File 'lib/imgui.rb', line 1284

def GetCustomRectByIndex(index)
  ImGui::ImFontAtlas_GetCustomRectByIndex(self, index)
end

#GetGlyphRangesChineseFullObject



1288
1289
1290
# File 'lib/imgui.rb', line 1288

def GetGlyphRangesChineseFull()
  ImGui::ImFontAtlas_GetGlyphRangesChineseFull(self)
end

#GetGlyphRangesChineseSimplifiedCommonObject



1292
1293
1294
# File 'lib/imgui.rb', line 1292

def GetGlyphRangesChineseSimplifiedCommon()
  ImGui::ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(self)
end

#GetGlyphRangesCyrillicObject



1296
1297
1298
# File 'lib/imgui.rb', line 1296

def GetGlyphRangesCyrillic()
  ImGui::ImFontAtlas_GetGlyphRangesCyrillic(self)
end

#GetGlyphRangesDefaultObject



1300
1301
1302
# File 'lib/imgui.rb', line 1300

def GetGlyphRangesDefault()
  ImGui::ImFontAtlas_GetGlyphRangesDefault(self)
end

#GetGlyphRangesGreekObject



1304
1305
1306
# File 'lib/imgui.rb', line 1304

def GetGlyphRangesGreek()
  ImGui::ImFontAtlas_GetGlyphRangesGreek(self)
end

#GetGlyphRangesJapaneseObject



1308
1309
1310
# File 'lib/imgui.rb', line 1308

def GetGlyphRangesJapanese()
  ImGui::ImFontAtlas_GetGlyphRangesJapanese(self)
end

#GetGlyphRangesKoreanObject



1312
1313
1314
# File 'lib/imgui.rb', line 1312

def GetGlyphRangesKorean()
  ImGui::ImFontAtlas_GetGlyphRangesKorean(self)
end

#GetGlyphRangesThaiObject



1316
1317
1318
# File 'lib/imgui.rb', line 1316

def GetGlyphRangesThai()
  ImGui::ImFontAtlas_GetGlyphRangesThai(self)
end

#GetGlyphRangesVietnameseObject



1320
1321
1322
# File 'lib/imgui.rb', line 1320

def GetGlyphRangesVietnamese()
  ImGui::ImFontAtlas_GetGlyphRangesVietnamese(self)
end

#GetMouseCursorTexData(cursor, out_offset, out_size, out_uv_border, out_uv_fill) ⇒ Object



1324
1325
1326
# File 'lib/imgui.rb', line 1324

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



1328
1329
1330
# File 'lib/imgui.rb', line 1328

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



1332
1333
1334
# File 'lib/imgui.rb', line 1332

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

#IsBuiltObject



1340
1341
1342
# File 'lib/imgui.rb', line 1340

def IsBuilt()
  ImGui::ImFontAtlas_IsBuilt(self)
end

#SetTexID(id) ⇒ Object



1344
1345
1346
# File 'lib/imgui.rb', line 1344

def SetTexID(id)
  ImGui::ImFontAtlas_SetTexID(self, id)
end