pkg/macos: font initializes, get glyphs

This commit is contained in:
Mitchell Hashimoto
2022-10-01 21:49:02 -07:00
parent 0f34617eab
commit 791739de9c
7 changed files with 83 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig");
@@ -100,6 +101,14 @@ pub const StringEncoding = enum(u32) {
utf32_le = 0x1c000100,
};
pub fn stringGetSurrogatePairForLongCharacter(
ch: u32,
surrogates: []u16,
) bool {
assert(surrogates.len >= 2);
return c.CFStringGetSurrogatePairForLongCharacter(ch, surrogates.ptr) == 1;
}
test "string" {
const testing = std.testing;
@@ -119,3 +128,10 @@ test "string" {
try testing.expectEqualStrings("hello world", cstr);
}
}
test "unichar" {
const testing = std.testing;
var unichars: [2]u16 = undefined;
try testing.expect(!stringGetSurrogatePairForLongCharacter('A', &unichars));
}