FONTS.md (imgui-1.86) | : | FONTS.md (imgui-1.87) | ||
---|---|---|---|---|
skipping to change at line 289 | skipping to change at line 289 | |||
} | } | |||
} | } | |||
} | } | |||
``` | ``` | |||
##### [Return to Index](#index) | ##### [Return to Index](#index) | |||
## Using Font Data Embedded In Source Code | ## Using Font Data Embedded In Source Code | |||
- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/ blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C styl e array that you can embed in source code. | - Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/ blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C styl e array that you can embed in source code. | |||
- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocorn | - See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocorn | |||
ut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instruction on h | ut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instructions on | |||
ow to use the tool. | how to use the tool. | |||
- You may find a precompiled version binary_to_compressed_c.exe for Windows inst | - You may find a precompiled version binary_to_compressed_c.exe for Windows insi | |||
ead of demo binaries package (see [README](https://github.com/ocornut/imgui/blob | de the demo binaries package (see [README](https://github.com/ocornut/imgui/blob | |||
/master/docs/README.md)). | /master/docs/README.md)). | |||
- The tool can optionally output Base85 encoding to reduce the size of _source c ode_ but the read-only arrays in the actual binary will be about 20% bigger. | - The tool can optionally output Base85 encoding to reduce the size of _source c ode_ but the read-only arrays in the actual binary will be about 20% bigger. | |||
Then load the font with: | Then load the font with: | |||
```cpp | ```cpp | |||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compres sed_data_size, size_pixels, ...); | ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compres sed_data_size, size_pixels, ...); | |||
``` | ``` | |||
or | or | |||
```cpp | ```cpp | |||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_ba se85, size_pixels, ...); | ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_ba se85, size_pixels, ...); | |||
``` | ``` | |||
##### [Return to Index](#index) | ##### [Return to Index](#index) | |||
## About filenames | ## About filenames | |||
**Please note that many new C/C++ users have issues their files _because the fil ename they provide is wrong_.** | **Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_.** | |||
Two things to watch for: | Two things to watch for: | |||
- Make sure your IDE/debugger settings starts your executable from the right wor king directory. In Visual Studio you can change your working directory in projec t `Properties > General > Debugging > Working Directory`. People assume that the ir execution will start from the root folder of the project, where by default it oftens start from the folder where object or executable files are stored. | - Make sure your IDE/debugger settings starts your executable from the right wor king directory. In Visual Studio you can change your working directory in projec t `Properties > General > Debugging > Working Directory`. People assume that the ir execution will start from the root folder of the project, where by default it oftens start from the folder where object or executable files are stored. | |||
```cpp | ```cpp | |||
// Relative filename depends on your Working Directory when running your program ! | // Relative filename depends on your Working Directory when running your program ! | |||
io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...); | io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...); | |||
// Load from the parent folder of your Working Directory | // Load from the parent folder of your Working Directory | |||
io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...); | io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...); | |||
``` | ``` | |||
End of changes. 2 change blocks. | ||||
7 lines changed or deleted | 7 lines changed or added |