srctree

Robin Linden parent fa199b2c d427090a
type: Set up a new library for handling text/font bits

inlinesplit
.clang-tidy added: 54, removed: 6, total 48
@@ -76,7 +76,7 @@ Checks: >
# clang-tidy-16.
WarningsAsErrors: "*,-clang-diagnostic-builtin-macro-redefined"
 
HeaderFilterRegex: "\\./(archive|azm|browser|css|css2|dom|dom2|engine|etest|geom|gfx|html|html2|idna|img|js|layout|net|os|protocol|render|style|tui|uri|url|util|wasm)/"
HeaderFilterRegex: "\\./(archive|azm|browser|css|css2|dom|dom2|engine|etest|geom|gfx|html|html2|idna|img|js|layout|net|os|protocol|render|style|tui|type|uri|url|util|wasm)/"
 
CheckOptions:
# performance-move-const-arg
 
.gitlint added: 54, removed: 6, total 48
@@ -4,4 +4,4 @@ ignore=body-is-missing
# TODO(robinlinden): Better way of documenting and setting this up.
# Each commit must start with the main area it affects.
[title-match-regex]
regex=^(archive|azm|browser|bzl|css|css2|dom|dom2|engine|etest|geom|gfx|html|html2|idna|img|js|layout|net|os|protocol|render|style|tui|uri|url|util|wasm|all|build|ci|deps|doc|meta)(/.*|\+.*)?:
regex=^(archive|azm|browser|bzl|css|css2|dom|dom2|engine|etest|geom|gfx|html|html2|idna|img|js|layout|net|os|protocol|render|style|tui|type|uri|url|util|wasm|all|build|ci|deps|doc|meta)(/.*|\+.*)?:
 
filename was Deleted added: 54, removed: 6, total 48
@@ -0,0 +1,9 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bzl:copts.bzl", "HASTUR_COPTS")
 
cc_library(
name = "type",
hdrs = ["type.h"],
copts = HASTUR_COPTS,
visibility = ["//visibility:public"],
)
 
filename was Deleted added: 54, removed: 6, total 48
@@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#ifndef TYPE_TYPE_H_
#define TYPE_TYPE_H_
 
#include <memory>
#include <optional>
#include <string_view>
 
namespace type {
 
struct Size {
int width{};
int height{};
[[nodiscard]] bool operator==(Size const &) const = default;
};
 
struct Px {
int v{};
[[nodiscard]] bool operator==(Px const &) const = default;
};
 
class IFont {
public:
virtual ~IFont() = default;
[[nodiscard]] virtual Size measure(std::string_view) const = 0;
};
 
class IType {
public:
virtual ~IType() = default;
[[nodiscard]] virtual std::optional<std::shared_ptr<IFont const>> font(std::string_view name, Px size) const = 0;
};
 
} // namespace type
 
#endif