mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-20 10:46:07 +03:00
test rendering box glyphs, looks OKAY
This commit is contained in:
@ -289,6 +289,17 @@ pub fn create(alloc: Allocator, app: *App, config: *const Config) !*Window {
|
|||||||
// Pre-calculate our initial cell size ourselves.
|
// Pre-calculate our initial cell size ourselves.
|
||||||
const cell_size = try renderer.CellSize.init(alloc, font_group);
|
const cell_size = try renderer.CellSize.init(alloc, font_group);
|
||||||
|
|
||||||
|
// Setup our box font
|
||||||
|
font_group.group.box_font = font.BoxFont{
|
||||||
|
.width = @floatToInt(u32, cell_size.width),
|
||||||
|
.height = @floatToInt(u32, cell_size.height),
|
||||||
|
.thickness = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
const idx = (try font_group.indexForCodepoint(alloc, 0x2500, .regular, null)).?;
|
||||||
|
_ = try font_group.renderGlyph(alloc, idx, 0x2500, null);
|
||||||
|
|
||||||
// Convert our padding from points to pixels
|
// Convert our padding from points to pixels
|
||||||
const padding_x = (@intToFloat(f32, config.@"window-padding-x") * x_dpi) / 72;
|
const padding_x = (@intToFloat(f32, config.@"window-padding-x") * x_dpi) / 72;
|
||||||
const padding_y = (@intToFloat(f32, config.@"window-padding-y") * y_dpi) / 72;
|
const padding_y = (@intToFloat(f32, config.@"window-padding-y") * y_dpi) / 72;
|
||||||
|
@ -237,7 +237,19 @@ fn indexForCodepointExact(self: Group, cp: u32, style: Style, p: ?Presentation)
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the Face represented by a given FontIndex.
|
/// Returns the presentation for a specific font index. This is useful for
|
||||||
|
/// determining what atlas is needed.
|
||||||
|
pub fn presentationFromIndex(self: Group, index: FontIndex) !font.Presentation {
|
||||||
|
if (index.special()) |sp| switch (sp) {
|
||||||
|
.box => return .text,
|
||||||
|
};
|
||||||
|
|
||||||
|
const face = try self.faceFromIndex(index);
|
||||||
|
return face.presentation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the Face represented by a given FontIndex. Note that special
|
||||||
|
/// fonts (i.e. box glyphs) do not have a face.
|
||||||
pub fn faceFromIndex(self: Group, index: FontIndex) !Face {
|
pub fn faceFromIndex(self: Group, index: FontIndex) !Face {
|
||||||
if (index.special() != null) return error.SpecialHasNoFace;
|
if (index.special() != null) return error.SpecialHasNoFace;
|
||||||
const deferred = &self.faces.get(index.style).items[@intCast(usize, index.idx)];
|
const deferred = &self.faces.get(index.style).items[@intCast(usize, index.idx)];
|
||||||
|
@ -132,8 +132,10 @@ pub fn renderGlyph(
|
|||||||
if (gop.found_existing) return gop.value_ptr.*;
|
if (gop.found_existing) return gop.value_ptr.*;
|
||||||
|
|
||||||
// Uncached, render it
|
// Uncached, render it
|
||||||
const face = try self.group.faceFromIndex(index);
|
const atlas: *Atlas = switch (try self.group.presentationFromIndex(index)) {
|
||||||
const atlas: *Atlas = if (face.presentation == .emoji) &self.atlas_color else &self.atlas_greyscale;
|
.text => &self.atlas_greyscale,
|
||||||
|
.emoji => &self.atlas_color,
|
||||||
|
};
|
||||||
const glyph = self.group.renderGlyph(
|
const glyph = self.group.renderGlyph(
|
||||||
alloc,
|
alloc,
|
||||||
atlas,
|
atlas,
|
||||||
|
@ -501,6 +501,12 @@ pub fn setFontSize(self: *OpenGL, size: font.face.DesiredSize) !void {
|
|||||||
if (std.meta.eql(self.cell_size, new_cell_size)) return;
|
if (std.meta.eql(self.cell_size, new_cell_size)) return;
|
||||||
self.cell_size = new_cell_size;
|
self.cell_size = new_cell_size;
|
||||||
|
|
||||||
|
// Set the cell size of the box font
|
||||||
|
if (self.font_group.group.box_font) |*box| {
|
||||||
|
box.width = @floatToInt(u32, self.cell_size.width);
|
||||||
|
box.height = @floatToInt(u32, self.cell_size.height);
|
||||||
|
}
|
||||||
|
|
||||||
// Notify the window that the cell size changed.
|
// Notify the window that the cell size changed.
|
||||||
_ = self.window_mailbox.push(.{
|
_ = self.window_mailbox.push(.{
|
||||||
.cell_size = new_cell_size,
|
.cell_size = new_cell_size,
|
||||||
|
Reference in New Issue
Block a user