mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/macos: add more text APIs
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
.{
|
||||
.name = "macos",
|
||||
.version = "0.1.0",
|
||||
.paths = .{""},
|
||||
.dependencies = .{
|
||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ pub usingnamespace @import("text/font_manager.zig");
|
||||
pub usingnamespace @import("text/frame.zig");
|
||||
pub usingnamespace @import("text/framesetter.zig");
|
||||
pub usingnamespace @import("text/line.zig");
|
||||
pub usingnamespace @import("text/paragraph_style.zig");
|
||||
pub usingnamespace @import("text/run.zig");
|
||||
pub usingnamespace @import("text/stylized_strings.zig");
|
||||
|
||||
|
46
pkg/macos/text/paragraph_style.zig
Normal file
46
pkg/macos/text/paragraph_style.zig
Normal file
@ -0,0 +1,46 @@
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const foundation = @import("../foundation.zig");
|
||||
const graphics = @import("../graphics.zig");
|
||||
const text = @import("../text.zig");
|
||||
const c = @import("c.zig");
|
||||
|
||||
// https://developer.apple.com/documentation/coretext/ctparagraphstyle?language=objc
|
||||
pub const ParagraphStyle = opaque {
|
||||
pub fn create(
|
||||
settings: []const ParagraphStyleSetting,
|
||||
) Allocator.Error!*ParagraphStyle {
|
||||
return @ptrCast(@constCast(c.CTParagraphStyleCreate(
|
||||
@ptrCast(settings.ptr),
|
||||
settings.len,
|
||||
)));
|
||||
}
|
||||
|
||||
pub fn release(self: *ParagraphStyle) void {
|
||||
foundation.CFRelease(self);
|
||||
}
|
||||
};
|
||||
|
||||
/// https://developer.apple.com/documentation/coretext/ctparagraphstylesetting?language=objc
|
||||
pub const ParagraphStyleSetting = extern struct {
|
||||
spec: ParagraphStyleSpecifier,
|
||||
value_size: usize,
|
||||
value: *const anyopaque,
|
||||
};
|
||||
|
||||
/// https://developer.apple.com/documentation/coretext/ctparagraphstylespecifier?language=objc
|
||||
pub const ParagraphStyleSpecifier = enum(c_uint) {
|
||||
base_writing_direction = 13,
|
||||
};
|
||||
|
||||
pub const WritingDirection = enum(i8) {
|
||||
natural = -1,
|
||||
left_to_right = 0,
|
||||
right_to_left = 1,
|
||||
};
|
||||
|
||||
test ParagraphStyle {
|
||||
const p = try ParagraphStyle.create(&.{});
|
||||
defer p.release();
|
||||
}
|
@ -3,10 +3,12 @@ const c = @import("c.zig");
|
||||
|
||||
pub const StringAttribute = enum {
|
||||
font,
|
||||
paragraph_style,
|
||||
|
||||
pub fn key(self: StringAttribute) *foundation.String {
|
||||
return @ptrFromInt(@intFromPtr(switch (self) {
|
||||
.font => c.kCTFontAttributeName,
|
||||
.paragraph_style => c.kCTParagraphStyleAttributeName,
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user