4#include "imgui/imgui.h"
8#if defined(__APPLE__) && defined(__MACH__)
10#include <TargetConditionals.h>
12#import <CoreText/CoreText.h>
14#if TARGET_IPHONE_SIMULATOR == 1
18#elif TARGET_OS_IPHONE == 1
22#elif TARGET_OS_MAC == 1
25#import <Cocoa/Cocoa.h>
30 NSArray *fontNames = @[
@"Helvetica",
@"Times New Roman",
@"Courier",
@"Arial",
@"Verdana" ];
32 for (NSString *fontName in fontNames) {
33 NSFont *font = [NSFont fontWithName:fontName size:14.0];
35 NSLog(
@"Font not found: %@", fontName);
39 CTFontDescriptorRef fontDescriptor =
40 CTFontDescriptorCreateWithNameAndSize((CFStringRef)font.fontName, font.pointSize);
41 CFURLRef fontURL = (CFURLRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontURLAttribute);
42 NSString *fontPath = [(NSURL *)fontURL path];
43 CFRelease(fontDescriptor);
45 if (fontPath != nil && [[NSFileManager defaultManager] isReadableFileAtPath:fontPath]) {
47 ImGuiIO &io = ImGui::GetIO();
48 ImFontConfig icons_config;
49 icons_config.MergeMode =
true;
50 icons_config.GlyphOffset.y = 5.0f;
51 icons_config.GlyphMinAdvanceX = 13.0f;
52 icons_config.PixelSnapH =
true;
53 static const ImWchar icons_ranges[] = {
ICON_MIN_MD, 0xf900, 0};
54 static const float ICON_FONT_SIZE = 18.0f;
55 ImFont *imFont = io.Fonts->AddFontFromFileTTF([fontPath UTF8String], 14.0f);
57 NSLog(
@"Failed to load font: %@", fontPath);
62 NSLog(
@"Font file not accessible: %@", fontPath);
#define FONT_ICON_FILE_NAME_MD