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
1600 1601 1602 |
# File 'lib/imgui.rb', line 1600 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
1492 1493 1494 |
# File 'lib/imgui.rb', line 1492 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
1496 1497 1498 |
# File 'lib/imgui.rb', line 1496 def AddCustomRectRegular(width, height) ImGui::ImFontAtlas_AddCustomRectRegular(self, width, height) end |
#AddFont(font_cfg) ⇒ Object
1500 1501 1502 |
# File 'lib/imgui.rb', line 1500 def AddFont(font_cfg) ImGui::ImFontAtlas_AddFont(self, font_cfg) end |
#AddFontDefault(font_cfg = nil) ⇒ Object
1504 1505 1506 |
# File 'lib/imgui.rb', line 1504 def AddFontDefault(font_cfg = nil) ImGui::ImFontAtlas_AddFontDefault(self, font_cfg) end |
#AddFontFromFileTTF(filename, size_pixels, font_cfg = nil, glyph_ranges = nil) ⇒ Object
1508 1509 1510 |
# File 'lib/imgui.rb', line 1508 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
1512 1513 1514 |
# File 'lib/imgui.rb', line 1512 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
1516 1517 1518 |
# File 'lib/imgui.rb', line 1516 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
1520 1521 1522 |
# File 'lib/imgui.rb', line 1520 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
1524 1525 1526 |
# File 'lib/imgui.rb', line 1524 def Build() ImGui::ImFontAtlas_Build(self) end |
#CalcCustomRectUV(rect, out_uv_min, out_uv_max) ⇒ Object
1528 1529 1530 |
# File 'lib/imgui.rb', line 1528 def CalcCustomRectUV(rect, out_uv_min, out_uv_max) ImGui::ImFontAtlas_CalcCustomRectUV(self, rect, out_uv_min, out_uv_max) end |
#Clear ⇒ Object
1532 1533 1534 |
# File 'lib/imgui.rb', line 1532 def Clear() ImGui::ImFontAtlas_Clear(self) end |
#ClearFonts ⇒ Object
1536 1537 1538 |
# File 'lib/imgui.rb', line 1536 def ClearFonts() ImGui::ImFontAtlas_ClearFonts(self) end |
#ClearInputData ⇒ Object
1540 1541 1542 |
# File 'lib/imgui.rb', line 1540 def ClearInputData() ImGui::ImFontAtlas_ClearInputData(self) end |
#ClearTexData ⇒ Object
1544 1545 1546 |
# File 'lib/imgui.rb', line 1544 def ClearTexData() ImGui::ImFontAtlas_ClearTexData(self) end |
#destroy ⇒ Object
1612 1613 1614 |
# File 'lib/imgui.rb', line 1612 def destroy() ImGui::ImFontAtlas_destroy(self) end |
#GetCustomRectByIndex(index) ⇒ Object
1548 1549 1550 |
# File 'lib/imgui.rb', line 1548 def GetCustomRectByIndex(index) ImGui::ImFontAtlas_GetCustomRectByIndex(self, index) end |
#GetGlyphRangesChineseFull ⇒ Object
1552 1553 1554 |
# File 'lib/imgui.rb', line 1552 def GetGlyphRangesChineseFull() ImGui::ImFontAtlas_GetGlyphRangesChineseFull(self) end |
#GetGlyphRangesChineseSimplifiedCommon ⇒ Object
1556 1557 1558 |
# File 'lib/imgui.rb', line 1556 def GetGlyphRangesChineseSimplifiedCommon() ImGui::ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(self) end |
#GetGlyphRangesCyrillic ⇒ Object
1560 1561 1562 |
# File 'lib/imgui.rb', line 1560 def GetGlyphRangesCyrillic() ImGui::ImFontAtlas_GetGlyphRangesCyrillic(self) end |
#GetGlyphRangesDefault ⇒ Object
1564 1565 1566 |
# File 'lib/imgui.rb', line 1564 def GetGlyphRangesDefault() ImGui::ImFontAtlas_GetGlyphRangesDefault(self) end |
#GetGlyphRangesGreek ⇒ Object
1568 1569 1570 |
# File 'lib/imgui.rb', line 1568 def GetGlyphRangesGreek() ImGui::ImFontAtlas_GetGlyphRangesGreek(self) end |
#GetGlyphRangesJapanese ⇒ Object
1572 1573 1574 |
# File 'lib/imgui.rb', line 1572 def GetGlyphRangesJapanese() ImGui::ImFontAtlas_GetGlyphRangesJapanese(self) end |
#GetGlyphRangesKorean ⇒ Object
1576 1577 1578 |
# File 'lib/imgui.rb', line 1576 def GetGlyphRangesKorean() ImGui::ImFontAtlas_GetGlyphRangesKorean(self) end |
#GetGlyphRangesThai ⇒ Object
1580 1581 1582 |
# File 'lib/imgui.rb', line 1580 def GetGlyphRangesThai() ImGui::ImFontAtlas_GetGlyphRangesThai(self) end |
#GetGlyphRangesVietnamese ⇒ Object
1584 1585 1586 |
# File 'lib/imgui.rb', line 1584 def GetGlyphRangesVietnamese() ImGui::ImFontAtlas_GetGlyphRangesVietnamese(self) end |
#GetMouseCursorTexData(cursor, out_offset, out_size, out_uv_border, out_uv_fill) ⇒ Object
1588 1589 1590 |
# File 'lib/imgui.rb', line 1588 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
1592 1593 1594 |
# File 'lib/imgui.rb', line 1592 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
1596 1597 1598 |
# File 'lib/imgui.rb', line 1596 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
1604 1605 1606 |
# File 'lib/imgui.rb', line 1604 def IsBuilt() ImGui::ImFontAtlas_IsBuilt(self) end |
#SetTexID(id) ⇒ Object
1608 1609 1610 |
# File 'lib/imgui.rb', line 1608 def SetTexID(id) ImGui::ImFontAtlas_SetTexID(self, id) end |