ff
This commit is contained in:
parent
7aa05887d5
commit
fd71b631c4
@ -224,7 +224,7 @@ pub const Font = struct {
|
||||
return;
|
||||
}
|
||||
|
||||
kb.kbts_ShapeBegin(Context, kb.KBTS_DIRECTION_DONT_KNOW, kb.KBTS_LANGUAGE_ENGLISH);
|
||||
kb.kbts_ShapeBegin(Context, kb.KBTS_DIRECTION_DONT_KNOW, kb.KBTS_LANGUAGE_DONT_KNOW);
|
||||
kb.kbts_ShapeUtf8(Context, text.ptr, @intCast(text.len), kb.KBTS_USER_ID_GENERATION_MODE_CODEPOINT_INDEX);
|
||||
kb.kbts_ShapeEnd(Context);
|
||||
|
||||
@ -243,7 +243,7 @@ pub const Font = struct {
|
||||
|
||||
var g : [*c]kb.kbts_glyph = null;
|
||||
while (kb.kbts_GlyphIteratorNext(&Run.Glyphs, &g) != 0) {
|
||||
const RunGlyph : *kb.kbts_glyph = g.?; // assert non-null
|
||||
const RunGlyph : *kb.kbts_glyph = g.?;
|
||||
const CodepointIndex : i32 = RunGlyph.UserIdOrCodepointIndex;
|
||||
var ShapeCodepoint : kb.kbts_shape_codepoint = undefined;
|
||||
if (kb.kbts_ShapeGetShapeCodepoint(Context, CodepointIndex, &ShapeCodepoint) == 0) {
|
||||
@ -258,11 +258,9 @@ pub const Font = struct {
|
||||
if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| {
|
||||
var v0 = rl.Vector2.zero();
|
||||
var v1 = rl.Vector2.zero();
|
||||
// const bx = @as(f32, @floatFromInt(glyph.bearing_x));
|
||||
const by = glyph.dpi_bearing_y;
|
||||
|
||||
v0 = render_pos.add(.{ .x = x_offset + glyph.dpi_bearing_x,
|
||||
.y = y_offset - by });
|
||||
.y = y_offset - glyph.dpi_bearing_y });
|
||||
|
||||
v1 = v0.add(rl.Vector2{ .x = glyph.dpi_width, .y = glyph.dpi_height });
|
||||
const p0 : rl.Vector4 = .{ .x = v0.x, .y = v0.y, .z = 0.0, .w = 1.0 };
|
||||
|
||||
@ -35,7 +35,6 @@ pub fn main() !void {
|
||||
std.log.info("Hello Client!", .{});
|
||||
|
||||
try init();
|
||||
defer _ = dbg_allocator.deinit();
|
||||
try znet.init();
|
||||
defer znet.deinit();
|
||||
rl.setConfigFlags(.{ .window_highdpi = true });
|
||||
@ -49,23 +48,23 @@ pub fn main() !void {
|
||||
18, 20, 22,
|
||||
};
|
||||
|
||||
var inconsolata: [sizes.len]font.Font = undefined;
|
||||
var vollkorn: [sizes.len]font.Font = undefined;
|
||||
var arabic: [sizes.len]font.Font = undefined;
|
||||
var japanese: [sizes.len]font.Font = undefined;
|
||||
// var inconsolata: [sizes.len]font.Font = undefined;
|
||||
// var arabic: [sizes.len]font.Font = undefined;
|
||||
// var japanese: [sizes.len]font.Font = undefined;
|
||||
|
||||
for (sizes, 0..) |pt, i| {
|
||||
inconsolata[i] = try font.Font.init("assets/fonts/Inconsolata/static/Inconsolata-Regular.ttf", @intCast(pt), allocator);
|
||||
vollkorn[i] = try font.Font.init("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf", @intCast(pt), allocator);
|
||||
arabic[i] = try font.Font.init("assets/fonts/Noto_Sans_Arabic/static/NotoSansArabic-Regular.ttf", @intCast(pt), allocator);
|
||||
japanese[i] = try font.Font.init("assets/fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf", @intCast(pt), allocator);
|
||||
// inconsolata[i] = try font.Font.init("assets/fonts/Inconsolata/static/Inconsolata-Regular.ttf", @intCast(pt), allocator);
|
||||
// arabic[i] = try font.Font.init("assets/fonts/Noto_Sans_Arabic/static/NotoSansArabic-Regular.ttf", @intCast(pt), allocator);
|
||||
// japanese[i] = try font.Font.init("assets/fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf", @intCast(pt), allocator);
|
||||
}
|
||||
|
||||
defer {
|
||||
for (&inconsolata) |*f| f.deinit(allocator);
|
||||
for (&vollkorn) |*f| f.deinit(allocator);
|
||||
for (&arabic) |*f| f.deinit(allocator);
|
||||
for (&japanese) |*f| f.deinit(allocator);
|
||||
// for (&inconsolata) |*f| f.deinit(allocator);
|
||||
// for (&arabic) |*f| f.deinit(allocator);
|
||||
// for (&japanese) |*f| f.deinit(allocator);
|
||||
}
|
||||
|
||||
font.shader = try rl.loadShader(null, "assets/text.frag");
|
||||
@ -220,22 +219,22 @@ pub fn main() !void {
|
||||
y += dpi_font_ascent;
|
||||
}
|
||||
|
||||
for (&inconsolata) |*f| {
|
||||
f.render_text(
|
||||
"Whereas, disregard and contempt for human rights have resulted!fi",
|
||||
rl.Vector2{ .x = 0, .y = y},
|
||||
true,
|
||||
.white,
|
||||
.blank,
|
||||
false,
|
||||
true
|
||||
);
|
||||
// for (&inconsolata) |*f| {
|
||||
// f.render_text(
|
||||
// "Whereas, disregard and contempt for human rights have resulted!fi",
|
||||
// rl.Vector2{ .x = 0, .y = y},
|
||||
// true,
|
||||
// .white,
|
||||
// .blank,
|
||||
// false,
|
||||
// true
|
||||
// );
|
||||
|
||||
const font_ascent : f32 = @floatFromInt(f.face.size().metrics().ascender >> 6);
|
||||
const dpi_font_ascent = font_ascent / rl.getWindowScaleDPI().y;
|
||||
// const font_ascent : f32 = @floatFromInt(f.face.size().metrics().ascender >> 6);
|
||||
// const dpi_font_ascent = font_ascent / rl.getWindowScaleDPI().y;
|
||||
|
||||
y += dpi_font_ascent;
|
||||
}
|
||||
// y += dpi_font_ascent;
|
||||
// }
|
||||
|
||||
// for (&japanese) |*f| {
|
||||
// f.render_text(
|
||||
@ -257,16 +256,16 @@ pub fn main() !void {
|
||||
// for (&arabic) |*f| {
|
||||
// f.render_text(
|
||||
// "الليل طويل وبارد في الخارج",
|
||||
// c.Vector2{ .x = 0, .y = y},
|
||||
// rl.Vector2{ .x = 0, .y = y},
|
||||
// true,
|
||||
// c.WHITE,
|
||||
// c.BLANK,
|
||||
// .white,
|
||||
// .blank,
|
||||
// false,
|
||||
// true
|
||||
// );
|
||||
|
||||
// const font_ascent : f32 = @floatFromInt(f.face.size().metrics().ascender >> 6);
|
||||
// const dpi_font_ascent = font_ascent / c.GetWindowScaleDPI().y;
|
||||
// const dpi_font_ascent = font_ascent / rl.getWindowScaleDPI().y;
|
||||
|
||||
// y += dpi_font_ascent;
|
||||
// }
|
||||
@ -378,6 +377,9 @@ pub fn main() !void {
|
||||
|
||||
rl.swapScreenBuffer();
|
||||
}
|
||||
|
||||
const deinit_status = dbg_allocator.deinit();
|
||||
if (deinit_status == .leak) std.testing.expect(false) catch @panic("TEST FAIL");
|
||||
}
|
||||
|
||||
fn init() !void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user