3#import <CoreText/CoreText.h>
4#include <TargetConditionals.h>
7#include "imgui/imgui.h"
9#if TARGET_OS_IPHONE == 1 || TARGET_IPHONE_SIMULATOR == 1
13#elif TARGET_OS_MAC == 1
15#import <Cocoa/Cocoa.h>
18 NSArray *fontNames = @[
@"Helvetica",
@"Times New Roman",
@"Courier",
@"Arial",
@"Verdana" ];
20 for (NSString *fontName in fontNames) {
21 NSFont *font = [NSFont fontWithName:fontName size:14.0];
23 NSLog(
@"Font not found: %@", fontName);
27 CTFontDescriptorRef fontDescriptor =
28 CTFontDescriptorCreateWithNameAndSize((CFStringRef)font.fontName, font.pointSize);
29 CFURLRef fontURL = (CFURLRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontURLAttribute);
30 NSString *fontPath = [(NSURL *)fontURL path];
31 CFRelease(fontDescriptor);
33 if (fontPath != nil && [[NSFileManager defaultManager] isReadableFileAtPath:fontPath]) {
35 ImGuiIO &io = ImGui::GetIO();
36 ImFontConfig icons_config;
37 icons_config.MergeMode =
true;
38 icons_config.GlyphOffset.y = 5.0f;
39 icons_config.GlyphMinAdvanceX = 13.0f;
40 icons_config.PixelSnapH =
true;
41 static const ImWchar icons_ranges[] = {
ICON_MIN_MD, 0xf900, 0};
42 static const float ICON_FONT_SIZE = 18.0f;
43 ImFont *imFont = io.Fonts->AddFontFromFileTTF([fontPath UTF8String], 14.0f);
45 NSLog(
@"Failed to load font: %@", fontPath);
50 NSLog(
@"Font file not accessible: %@", fontPath);
#define FONT_ICON_FILE_NAME_MD