@geastack/engine 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rasterized_font.cpp +40 -3
package/package.json
CHANGED
package/rasterized_font.cpp
CHANGED
|
@@ -139,7 +139,21 @@ constexpr int kRuntimeExtraGlyphs = sizeof(kRuntimeExtraCodepoints)/sizeof(int);
|
|
|
139
139
|
constexpr int kRuntimeExtraCodepoints[] = {0x00b0, 0x2022};
|
|
140
140
|
constexpr int kRuntimeExtraGlyphs = sizeof(kRuntimeExtraCodepoints) / sizeof(int);
|
|
141
141
|
#endif
|
|
142
|
-
|
|
142
|
+
// Room for the glyphs an app declares beyond the fixed set above: the build's
|
|
143
|
+
// font generator emits generated::runtimeTtfDeclaredCodepoints() -- the raster
|
|
144
|
+
// baseline plus every `--gea-font-charset` the app's CSS names -- so a runtime
|
|
145
|
+
// TTF slot covers the same characters a baked atlas would. Each entry costs a
|
|
146
|
+
// Glyph in every cache slot, so the default stays 0 where there is no FreeType
|
|
147
|
+
// (small boards); desktop builds raise it.
|
|
148
|
+
#ifndef GEA_EMBEDDED_TTF_RUNTIME_DECLARED_GLYPHS
|
|
149
|
+
#if GEA_EMBEDDED_TTF_FREETYPE
|
|
150
|
+
#define GEA_EMBEDDED_TTF_RUNTIME_DECLARED_GLYPHS 128
|
|
151
|
+
#else
|
|
152
|
+
#define GEA_EMBEDDED_TTF_RUNTIME_DECLARED_GLYPHS 0
|
|
153
|
+
#endif
|
|
154
|
+
#endif
|
|
155
|
+
constexpr int kRuntimeDeclaredGlyphCapacity = GEA_EMBEDDED_TTF_RUNTIME_DECLARED_GLYPHS;
|
|
156
|
+
constexpr int kRuntimeGlyphCapacity = kRuntimeAsciiCount + kRuntimeExtraGlyphs + kRuntimeDeclaredGlyphCapacity;
|
|
143
157
|
constexpr int kRuntimeFontCacheSlots = 64;
|
|
144
158
|
#if GEA_EMBEDDED_TTF_FREETYPE
|
|
145
159
|
constexpr int kRuntimeMaxAtlasWidth = 4096;
|
|
@@ -179,11 +193,28 @@ struct RuntimeRasterizedFontSlot {
|
|
|
179
193
|
int atlasRowHeight = 0;
|
|
180
194
|
};
|
|
181
195
|
|
|
196
|
+
bool runtimeFixedCodepoint(int codepoint)
|
|
197
|
+
{
|
|
198
|
+
if (codepoint >= kRuntimeAsciiFirst && codepoint <= kRuntimeAsciiLast) return true;
|
|
199
|
+
for (int i = 0; i < kRuntimeExtraGlyphs; ++i)
|
|
200
|
+
if (kRuntimeExtraCodepoints[i] == codepoint) return true;
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
|
|
182
204
|
int runtimeCodepointAt(int index)
|
|
183
205
|
{
|
|
184
206
|
if (index >= 0 && index < kRuntimeAsciiCount) return kRuntimeAsciiFirst + index;
|
|
185
|
-
|
|
186
|
-
return
|
|
207
|
+
index -= kRuntimeAsciiCount;
|
|
208
|
+
if (index >= 0 && index < kRuntimeExtraGlyphs) return kRuntimeExtraCodepoints[index];
|
|
209
|
+
index -= kRuntimeExtraGlyphs;
|
|
210
|
+
if (index < 0 || index >= kRuntimeDeclaredGlyphCapacity) return -1;
|
|
211
|
+
// Declared codepoints the fixed set already covers leave a gap (-1) rather
|
|
212
|
+
// than a duplicate entry.
|
|
213
|
+
int count = 0;
|
|
214
|
+
const int *declared = generated::runtimeTtfDeclaredCodepoints(&count);
|
|
215
|
+
if (!declared || index >= count) return -1;
|
|
216
|
+
const int codepoint = declared[index];
|
|
217
|
+
return codepoint > 0 && !runtimeFixedCodepoint(codepoint) ? codepoint : -1;
|
|
187
218
|
}
|
|
188
219
|
|
|
189
220
|
int roundToInt(float value)
|
|
@@ -744,6 +775,12 @@ __attribute__((weak)) const std::uint8_t *lookupRuntimeTtfFontForFamily(int fami
|
|
|
744
775
|
return nullptr;
|
|
745
776
|
}
|
|
746
777
|
|
|
778
|
+
__attribute__((weak)) const int *runtimeTtfDeclaredCodepoints(int *count)
|
|
779
|
+
{
|
|
780
|
+
if (count) *count = 0;
|
|
781
|
+
return nullptr;
|
|
782
|
+
}
|
|
783
|
+
|
|
747
784
|
} // namespace generated
|
|
748
785
|
|
|
749
786
|
} // namespace gea::framework::graphics
|