Unravel Engine C++ Reference
Loading...
Searching...
No Matches
text_metrics.h
Go to the documentation of this file.
1/*
2 * Copyright 2013 Jeremie Roy. All rights reserved.
3 * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
4 */
5
6#ifndef TEXT_METRICS_H_HEADER_GUARD
7#define TEXT_METRICS_H_HEADER_GUARD
8
9#include "font_manager.h"
10
11namespace gfx
12{
14{
15public:
16 text_metrics(font_manager* manager);
17
19 auto append_text(font_handle handle, const char* str, const char* end = nullptr) -> void;
20
22 auto append_text(font_handle handle, const wchar_t* str, const wchar_t* end = nullptr) -> void;
23
25 auto get_width() const -> float
26 {
27 return width_;
28 }
29
31 auto get_height() const -> float
32 {
33 return height_;
34 }
35
37 auto clear_text() -> void;
38
39private:
40 font_manager* manager_;
41 float width_;
42 float height_;
43 float x_;
44 float line_height_;
45 float line_gap_;
46};
47
50{
51public:
52 text_line_metrics(const font_info& info);
53
55 auto get_line_height() const -> float
56 {
57 return line_height_;
58 }
59
61 auto get_line_count(const bx::StringView& str) const -> uint32_t;
62
64 void get_sub_text(const bx::StringView& str,
65 uint32_t first_line,
66 uint32_t last_line,
67 const char*& begin,
68 const char*& end);
69
70private:
71 float line_height_;
72};
73} // namespace gfx
74#endif // TEXT_METRICS_H_HEADER_GUARD
Compute text crop area for text using a single font.
text_line_metrics(const font_info &info)
auto get_line_count(const bx::StringView &str) const -> uint32_t
Return the number of text line in the given text.
auto get_line_height() const -> float
Return the height of a line of text using the given font.
void get_sub_text(const bx::StringView &str, uint32_t first_line, uint32_t last_line, const char *&begin, const char *&end)
Return the first and last character visible in the [first_line, last_line] range.
auto get_width() const -> float
Return the width of the measured text.
auto get_height() const -> float
Return the height of the measured text.
auto clear_text() -> void
Clear the width and height of the measured text.
auto append_text(font_handle handle, const wchar_t *str, const wchar_t *end=nullptr) -> void
Append a wide char string to the metrics helper.
auto append_text(font_handle handle, const char *str, const char *end=nullptr) -> void
Append an ASCII/utf-8 string to the metrics helper.
text_metrics(font_manager *manager)
encoder * begin()
Definition graphics.cpp:265
void end(encoder *_encoder)
Definition graphics.cpp:270
gfx::uniform_handle handle
Definition uniform.cpp:9