16#include <AUI/Url/AUrl.h>
18#include "AUI/Render/FontRendering.h"
19#include "AUI/GL/Texture2D.h"
21#include "AUI/Render/SimpleTexturePacker.h"
23#include "AUI/Common/AStringVector.h"
24#include "AFontFamily.h"
25#include <AUI/Common/AByteBuffer.h>
40 int advanceX, advanceY;
45 return image ==
nullptr;
48 void* rendererData =
nullptr;
56 return (size << 2) | int(fr);
59 bool operator<(
const FontKey& f)
const {
60 return hash() < f.hash();
66 void* rendererData =
nullptr;
70 using FontEntry = std::pair<FontKey, FontData&>;
81 return mCharData[
FontKey{size, fr}];
84 Character renderGlyph(
const FontEntry& fs,
long glyph);
91 FontEntry getFontEntry(
const FontKey& key) {
92 return {key, mCharData[key]};
95 glm::vec2 getKerning(
wchar_t left,
wchar_t right);
99 Character& getCharacter(
const FontEntry& charset,
long glyph);
101 float length(
const FontEntry& charset,
const AString&
text);
103 template<
class Iterator>
104 float length(
const FontEntry& charset, Iterator begin, Iterator end) {
105 int size = charset.first.size;
108 for (Iterator i = begin; i != end; i++) {
110 advance += getSpaceWidth(size);
114 Character& ch = getCharacter(charset, *i);
116 advance += ch.advanceX;
117 advance = glm::floor(advance);
119 advance += getSpaceWidth(size);
126 trimStringToWidth(
const FontEntry& charset, AString::iterator begin, AString::iterator end,
float maxWidth) {
128 for (
auto i = begin; i != end; i++) {
132 float charWidth = length(charset, i, std::next(i));
133 if (
width + charWidth > maxWidth) {
145 AString getFontFamilyName()
const;
148 AFontFamily::Weight getFontWeight()
const;
150 int getAscenderHeight(
unsigned size)
const;
152 int getDescenderHeight(
unsigned size)
const;
154 int getSpaceWidth(
unsigned size) {
155 return size * 10 / 23;
159 bool isItalic()
const;
std::vector-like growing array for byte storage.
Definition: AByteBuffer.h:31
Definition: AFontManager.h:19
A std::map with AUI extensions.
Definition: AMap.h:218
Represents a Unicode character string.
Definition: AString.h:37
Uniform Resource Locator implementation.
Definition: AUrl.h:31
A std::vector with AUI extensions.
Definition: AVector.h:38
Definition: FreeType.h:16
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
FontRendering
Controls the expanding of AView.
Definition: FontRendering.h:22