diff --git a/build.zig b/build.zig index cf07455d..d9c17af2 100644 --- a/build.zig +++ b/build.zig @@ -136,8 +136,7 @@ pub fn build(b: *std.Build) !void { module.addImport("mach-opus", dep.module("mach-opus")); } } - if (b.lazyDependency("font_assets", .{})) |dep| module.addImport("font-assets", dep.module("font-assets")); - + if (want_examples) { for (examples) |example| b.getInstallStep().dependOn(example.install_step); } diff --git a/build.zig.zon b/build.zig.zon index fa69e512..2a120784 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -16,11 +16,6 @@ .hash = "1220adfccce3dbc4e4fa8650fdaec110a676f6b8a1462ed6ef422815207f8288e9d2", .lazy = true, }, - .font_assets = .{ - .url = "https://github.com/hexops/font-assets/archive/b2336a29b1ae633d47452a2041b258e9538ef5f0.tar.gz", - .hash = "1220521ff5b01885da9b3cba75b607b315f60ae351594ee9e4a270b164374889fea0", - .lazy = true, - }, .mach_objc = .{ .url = "https://pkg.machengine.org/mach-objc/79b6f80c32b14948554958afe72dace261b14afc.tar.gz", .hash = "12203675829014e69be2ea7c126ecf25d403009d336b7ca5f6e7c4ccede826c8e597", diff --git a/src/gfx/Text.zig b/src/gfx/Text.zig index c2a6dd07..2ce9de27 100644 --- a/src/gfx/Text.zig +++ b/src/gfx/Text.zig @@ -500,7 +500,7 @@ fn updatePipelineBuffers( // TODO(text): keep fonts around for reuse later // const font_name = text_style.get(style, .font_name).?; // _ = font_name; // TODO(text): actually use font name - const font_bytes = @import("font-assets").fira_sans_regular_ttf; + const font_bytes = gfx.default_font; var font = if (text.font_once) |f| f else blk: { text.font_once = try gfx.Font.initBytes(font_bytes); break :blk text.font_once.?; diff --git a/src/gfx/font/firasans/FiraSans-Regular.ttf b/src/gfx/font/firasans/FiraSans-Regular.ttf new file mode 100644 index 00000000..a4e65638 Binary files /dev/null and b/src/gfx/font/firasans/FiraSans-Regular.ttf differ diff --git a/src/gfx/font/firasans/LICENSE b/src/gfx/font/firasans/LICENSE new file mode 100644 index 00000000..a2c1ae22 --- /dev/null +++ b/src/gfx/font/firasans/LICENSE @@ -0,0 +1,93 @@ +Copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/gfx/font/main.zig b/src/gfx/font/main.zig index ff7fd608..61b4140e 100644 --- a/src/gfx/font/main.zig +++ b/src/gfx/font/main.zig @@ -79,12 +79,15 @@ pub const RenderedGlyph = struct { height: u32, }; +/// The default font used by Mach. currently Fira Sans Regular, but may change in the future. +pub const default_font = @embedFile("firasans/FiraSans-Regular.ttf"); + test { std.testing.refAllDeclsRecursive(@This()); // Load a font const allocator = std.testing.allocator; - const font_bytes = @import("font-assets").fira_sans_regular_ttf; + const font_bytes = default_font; var font = try Font.initBytes(font_bytes); defer font.deinit(allocator); diff --git a/src/gfx/main.zig b/src/gfx/main.zig index 24c742fb..fba0df89 100644 --- a/src/gfx/main.zig +++ b/src/gfx/main.zig @@ -10,6 +10,7 @@ pub const modules = .{ Sprite, Text }; // Fonts pub const Font = @import("font/main.zig").Font; +pub const default_font = @import("font/main.zig").default_font; pub const TextRun = @import("font/main.zig").TextRun; pub const Glyph = @import("font/main.zig").Glyph; pub const px_per_pt = @import("font/main.zig").px_per_pt;