better!
This commit is contained in:
parent
61b2dd0417
commit
297f56885c
@ -23,5 +23,5 @@ void main()
|
|||||||
// float x = fract(fragTexCoord.s);
|
// float x = fract(fragTexCoord.s);
|
||||||
// float final = smoothstep(divider - 0.1, divider + 0.1, x);
|
// float final = smoothstep(divider - 0.1, divider + 0.1, x);
|
||||||
|
|
||||||
finalColor = vec4(fragTexCoord, 0.0, 1.0);
|
finalColor = vec4(1, 1, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ pub const Font = struct {
|
|||||||
var face = try ft_lib.createFaceMemory(font_data, 0);
|
var face = try ft_lib.createFaceMemory(font_data, 0);
|
||||||
var glyphs = std.AutoHashMap(u32, Glyph).init(allocator);
|
var glyphs = std.AutoHashMap(u32, Glyph).init(allocator);
|
||||||
try face.setCharSize(0, size * 64, 0, 96);
|
try face.setCharSize(0, size * 64, 0, 96);
|
||||||
|
try face.selectCharmap(.unicode);
|
||||||
|
|
||||||
var rects = try std.ArrayList(rp.stbrp_rect).initCapacity(allocator, 1024);
|
var rects = try std.ArrayList(rp.stbrp_rect).initCapacity(allocator, 1024);
|
||||||
defer rects.deinit(allocator);
|
defer rects.deinit(allocator);
|
||||||
@ -71,12 +72,16 @@ pub const Font = struct {
|
|||||||
.format = .uncompressed_grayscale
|
.format = .uncompressed_grayscale
|
||||||
};
|
};
|
||||||
|
|
||||||
for (0..face.numGlyphs()) |i| {
|
var iter = face.iterateCharmap();
|
||||||
|
while (iter.next()) |char| {
|
||||||
|
const i = iter.index;
|
||||||
|
|
||||||
|
// for (0..face.numGlyphs()) |i| {
|
||||||
try face.loadGlyph(@intCast(i), .{});
|
try face.loadGlyph(@intCast(i), .{});
|
||||||
const bmp = face.glyph().bitmap();
|
const bmp = face.glyph().bitmap();
|
||||||
|
|
||||||
try rects.append(allocator, .{
|
try rects.append(allocator, .{
|
||||||
.id = @intCast(face.glyph().glyphIndex()),
|
.id = @intCast(char),//@intCast(face.glyph().glyphIndex()),
|
||||||
.w = @intCast(bmp.width()),
|
.w = @intCast(bmp.width()),
|
||||||
.h = @intCast(bmp.rows()),
|
.h = @intCast(bmp.rows()),
|
||||||
.x = 0,
|
.x = 0,
|
||||||
@ -89,9 +94,9 @@ pub const Font = struct {
|
|||||||
|
|
||||||
for (rects.items) |rect| {
|
for (rects.items) |rect| {
|
||||||
if (rect.was_packed == 0) continue;
|
if (rect.was_packed == 0) continue;
|
||||||
const i : u32 = @intCast(rect.id);
|
const char : u32 = @intCast(rect.id);
|
||||||
//index := FT_Get_Char_Index(face, xx it);
|
const index = face.getCharIndex(char) orelse return error.NoGlyph;// FT_Get_Char_Index(face, xx it);
|
||||||
try face.loadGlyph(i, .{ .render = true });
|
try face.loadGlyph(index, .{ .render = true });
|
||||||
|
|
||||||
const bmp = face.glyph().bitmap();
|
const bmp = face.glyph().bitmap();
|
||||||
const buf = bmp.buffer() orelse continue;
|
const buf = bmp.buffer() orelse continue;
|
||||||
@ -130,8 +135,8 @@ pub const Font = struct {
|
|||||||
const glyph = Glyph{
|
const glyph = Glyph{
|
||||||
.x = x,
|
.x = x,
|
||||||
.y = y,
|
.y = y,
|
||||||
.utf32 = @intCast(i),
|
.utf32 = char,
|
||||||
.index = face.glyph().glyphIndex(),
|
.index = index,
|
||||||
.bearing_x = face.glyph().bitmapLeft(),
|
.bearing_x = face.glyph().bitmapLeft(),
|
||||||
.bearing_y = face.glyph().bitmapTop(),
|
.bearing_y = face.glyph().bitmapTop(),
|
||||||
.width = width,
|
.width = width,
|
||||||
@ -243,7 +248,6 @@ pub const Font = struct {
|
|||||||
|
|
||||||
// glyph : *Glyph = table_find_pointer(*text.font.glyphs, RunGlyph.Id);
|
// glyph : *Glyph = table_find_pointer(*text.font.glyphs, RunGlyph.Id);
|
||||||
if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| {
|
if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| {
|
||||||
std.log.info("glyph: {}", .{glyph});
|
|
||||||
var v0 = rl.Vector2.zero();
|
var v0 = rl.Vector2.zero();
|
||||||
var v1 = rl.Vector2.zero();
|
var v1 = rl.Vector2.zero();
|
||||||
if (count_descent) {
|
if (count_descent) {
|
||||||
@ -292,7 +296,6 @@ pub const Font = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -> vec2, float, s32
|
|
||||||
pub fn size_row(self: *Font, str: []const u8, n: i32, max_width: f32) struct {rl.Vector2, f32, i32} {
|
pub fn size_row(self: *Font, str: []const u8, n: i32, max_width: f32) struct {rl.Vector2, f32, i32} {
|
||||||
_ = max_width;
|
_ = max_width;
|
||||||
_ = n;
|
_ = n;
|
||||||
@ -326,7 +329,7 @@ pub const Font = struct {
|
|||||||
std.log.info("aah it's wrong!! idk how to handle the error rn!!", .{});
|
std.log.info("aah it's wrong!! idk how to handle the error rn!!", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.glyphs.getPtr(@intCast(ShapeCodepoint.Codepoint))) |glyph| {
|
if (self.glyphs.getPtr(@intCast(RunGlyph.Id))) |glyph| {
|
||||||
size.y = @max(size.y, @as(f32, @floatFromInt(glyph.height)));
|
size.y = @max(size.y, @as(f32, @floatFromInt(glyph.height)));
|
||||||
// size.x += (ft.mulFix(RunGlyph.AdvanceX, self.face.size().metrics().x_scale) >> 6);
|
// size.x += (ft.mulFix(RunGlyph.AdvanceX, self.face.size().metrics().x_scale) >> 6);
|
||||||
size.x += @floatFromInt(ft.mulFix(RunGlyph.AdvanceX, @intCast(self.face.size().metrics().x_scale)) >> 6);
|
size.x += @floatFromInt(ft.mulFix(RunGlyph.AdvanceX, @intCast(self.face.size().metrics().x_scale)) >> 6);
|
||||||
|
|||||||
@ -176,15 +176,10 @@ pub fn main() !void {
|
|||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
rl.clearBackground(.sky_blue);
|
rl.clearBackground(.black);
|
||||||
|
|
||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
|
|
||||||
// f.texture.drawPro(
|
|
||||||
// .{.x = 0, .y = 0, .width = 4096, .height = 4096},
|
|
||||||
// .{.x = 0, .y = 0, .width = 512, .height = 512 },
|
|
||||||
// .zero(), 0, .white);
|
|
||||||
|
|
||||||
rl.beginShaderMode(shader);
|
rl.beginShaderMode(shader);
|
||||||
|
|
||||||
f.render_text(
|
f.render_text(
|
||||||
@ -224,6 +219,11 @@ pub fn main() !void {
|
|||||||
// rl.gl.rlEnd();
|
// rl.gl.rlEnd();
|
||||||
rl.endShaderMode();
|
rl.endShaderMode();
|
||||||
|
|
||||||
|
// f.texture.drawPro(
|
||||||
|
// .{.x = 0, .y = 0, .width = 4096, .height = 4096},
|
||||||
|
// .{.x = 0, .y = 0, .width = 512, .height = 512 },
|
||||||
|
// .zero(), 0, .white);
|
||||||
|
|
||||||
// const connected_text = "Connected";
|
// const connected_text = "Connected";
|
||||||
//const not_connected_text = "Not Connected";
|
//const not_connected_text = "Not Connected";
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user