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



1539
1540
1541
# File 'lib/imgui.rb', line 1539

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



1431
1432
1433
# File 'lib/imgui.rb', line 1431

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



1435
1436
1437
# File 'lib/imgui.rb', line 1435

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

#AddFont(font_cfg) ⇒ Object



1439
1440
1441
# File 'lib/imgui.rb', line 1439

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

#AddFontDefault(font_cfg = nil) ⇒ Object



1443
1444
1445
# File 'lib/imgui.rb', line 1443

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

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



1447
1448
1449
# File 'lib/imgui.rb', line 1447

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



1451
1452
1453
# File 'lib/imgui.rb', line 1451

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



1455
1456
1457
# File 'lib/imgui.rb', line 1455

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



1459
1460
1461
# File 'lib/imgui.rb', line 1459

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

#BuildObject



1463
1464
1465
# File 'lib/imgui.rb', line 1463

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

#CalcCustomRectUV(rect, out_uv_min, out_uv_max) ⇒ Object



1467
1468
1469
# File 'lib/imgui.rb', line 1467

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

#ClearObject



1471
1472
1473
# File 'lib/imgui.rb', line 1471

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

#ClearFontsObject



1475
1476
1477
# File 'lib/imgui.rb', line 1475

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

#ClearInputDataObject



1479
1480
1481
# File 'lib/imgui.rb', line 1479

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

#ClearTexDataObject



1483
1484
1485
# File 'lib/imgui.rb', line 1483

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

#destroyObject



1551
1552
1553
# File 'lib/imgui.rb', line 1551

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

#GetCustomRectByIndex(index) ⇒ Object



1487
1488
1489
# File 'lib/imgui.rb', line 1487

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

#GetGlyphRangesChineseFullObject



1491
1492
1493
# File 'lib/imgui.rb', line 1491

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

#GetGlyphRangesChineseSimplifiedCommonObject



1495
1496
1497
# File 'lib/imgui.rb', line 1495

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

#GetGlyphRangesCyrillicObject



1499
1500
1501
# File 'lib/imgui.rb', line 1499

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

#GetGlyphRangesDefaultObject



1503
1504
1505
# File 'lib/imgui.rb', line 1503

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

#GetGlyphRangesGreekObject



1507
1508
1509
# File 'lib/imgui.rb', line 1507

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

#GetGlyphRangesJapaneseObject



1511
1512
1513
# File 'lib/imgui.rb', line 1511

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

#GetGlyphRangesKoreanObject



1515
1516
1517
# File 'lib/imgui.rb', line 1515

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

#GetGlyphRangesThaiObject



1519
1520
1521
# File 'lib/imgui.rb', line 1519

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

#GetGlyphRangesVietnameseObject



1523
1524
1525
# File 'lib/imgui.rb', line 1523

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

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



1527
1528
1529
# File 'lib/imgui.rb', line 1527

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



1531
1532
1533
# File 'lib/imgui.rb', line 1531

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



1535
1536
1537
# File 'lib/imgui.rb', line 1535

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



1543
1544
1545
# File 'lib/imgui.rb', line 1543

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

#SetTexID(id) ⇒ Object



1547
1548
1549
# File 'lib/imgui.rb', line 1547

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