@geastack/engine 0.1.17 → 0.1.19

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/canvas.cpp CHANGED
@@ -1,5 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  #include "ui/renderer_features.h"
3
+ #include "ui/state_init.h"
3
4
  #include "canvas.h"
4
5
  #include "display.h"
5
6
  #include "graphics/font.h"
@@ -148,9 +149,18 @@ constexpr int kTextSpriteMinSizePx = 40;
148
149
  constexpr std::size_t kTextSpriteMaxBytes = 768u * 1024u;
149
150
 
150
151
  struct TextSprite {
152
+ #if GEA_EMBEDDED_UI_STATE_DYNAMIC_INIT
153
+ // Preserve the member defaults while keeping this cache in relocatable BSS.
154
+ __attribute__((noinline)) TextSprite() {}
155
+ #endif
151
156
  enum State { Empty, Seen, Cached };
152
157
  char text[kTextSpriteMaxLen + 1] = {0};
153
158
  const RasterizedFontData *fontData = nullptr;
159
+ #if GEA_EMBEDDED_TTF_FREETYPE
160
+ std::uint64_t fontGeneration=0;
161
+ #else
162
+ static constexpr std::uint64_t fontGeneration=0;
163
+ #endif
154
164
  int sizePx = -1;
155
165
  State state = Empty;
156
166
  int minLX = 0;
@@ -256,7 +266,7 @@ TextSprite &textSpriteFor(const char *text, const RasterizedFont &font)
256
266
  // such as "FPS: 59" and "FPS: 60" evict each other. Hits stay read-only;
257
267
  // a four-byte replacement cursor advances only for a new cache key.
258
268
  for (TextSprite &candidate : gTextSprites) {
259
- if (candidate.fontData == font.data() && candidate.sizePx == font.sizePx() &&
269
+ if (candidate.fontData == font.data() && candidate.fontGeneration==font.data()->generation && candidate.sizePx == font.sizePx() &&
260
270
  std::strcmp(candidate.text, text) == 0)
261
271
  return candidate;
262
272
  }
@@ -993,6 +1003,10 @@ struct SolidGlyphRow {
993
1003
  };
994
1004
 
995
1005
  struct SolidGlyphCacheEntry {
1006
+ #if GEA_EMBEDDED_UI_STATE_DYNAMIC_INIT
1007
+ // Preserve the member defaults while keeping this cache in relocatable BSS.
1008
+ __attribute__((noinline)) SolidGlyphCacheEntry() {}
1009
+ #endif
996
1010
  const RasterizedFontData *font = nullptr;
997
1011
  pixel::native_t color = 0;
998
1012
  pixel::native_t background = 0;
@@ -2734,7 +2748,12 @@ void Canvas::drawTextFont(const char *text, int x, int y, pixel::native_t color,
2734
2748
 
2735
2749
  void Canvas::drawTextFontFamily(const char *text, int x, int y, pixel::native_t color, int family_id, int size_px)
2736
2750
  {
2737
- drawRasterizedText(text, x, y, color, FontRegistry::rasterizedFamily(family_id, size_px));
2751
+ drawTextFontFamily(text,x,y,color,family_id,size_px,400,1000);
2752
+ }
2753
+
2754
+ void Canvas::drawTextFontFamily(const char *text,int x,int y,pixel::native_t color,int family_id,int size_px,int weight,int stretch)
2755
+ {
2756
+ drawRasterizedText(text, x, y, color, FontRegistry::rasterizedFamily(family_id, size_px,weight,stretch));
2738
2757
  }
2739
2758
 
2740
2759
  // Sum the glyph advances for a string in a family/size, so callers can centre
@@ -2918,6 +2937,11 @@ constexpr int kGlyphStampSlots = 256;
2918
2937
 
2919
2938
  struct PackedGlyphStamp {
2920
2939
  const RasterizedFontData *fontData = nullptr;
2940
+ #if GEA_EMBEDDED_TTF_FREETYPE
2941
+ std::uint64_t fontGeneration=0;
2942
+ #else
2943
+ static constexpr std::uint64_t fontGeneration=0;
2944
+ #endif
2921
2945
  int sizePx = 0;
2922
2946
  int codepoint = 0;
2923
2947
  std::uint8_t fg = 0xFF; // native 0..15 level; 0xFF = empty slot
@@ -2978,6 +3002,9 @@ bool buildPackedGlyphStamp(PackedGlyphStamp &e, const gea::framework::graphics::
2978
3002
  }
2979
3003
  }
2980
3004
  e.fontData = font.data();
3005
+ #if GEA_EMBEDDED_TTF_FREETYPE
3006
+ e.fontGeneration=font.data()->generation;
3007
+ #endif
2981
3008
  e.sizePx = font.sizePx();
2982
3009
  e.codepoint = cp;
2983
3010
  e.fg = fg;
@@ -3040,7 +3067,7 @@ void Canvas::drawRasterizedText(const char *text, int x, int y, pixel::native_t
3040
3067
  #endif
3041
3068
  if (len > 0 && len <= static_cast<std::size_t>(kTextSpriteMaxLen)) {
3042
3069
  TextSprite &slot = textSpriteFor(text, font);
3043
- const bool idMatch = slot.fontData == font.data() &&
3070
+ const bool idMatch = slot.fontData == font.data() && slot.fontGeneration==font.data()->generation &&
3044
3071
  slot.sizePx == font.sizePx() &&
3045
3072
  std::strcmp(slot.text, text) == 0;
3046
3073
  if (idMatch && slot.state == TextSprite::Cached) {
@@ -3101,6 +3128,9 @@ void Canvas::drawRasterizedText(const char *text, int x, int y, pixel::native_t
3101
3128
  } else if (!idMatch) {
3102
3129
  // First sighting: claim the slot and render normally this time.
3103
3130
  slot.fontData = font.data();
3131
+ #if GEA_EMBEDDED_TTF_FREETYPE
3132
+ slot.fontGeneration=font.data()->generation;
3133
+ #endif
3104
3134
  slot.sizePx = font.sizePx();
3105
3135
  std::strncpy(slot.text, text, kTextSpriteMaxLen);
3106
3136
  slot.text[kTextSpriteMaxLen] = '\0';
@@ -3169,7 +3199,7 @@ void Canvas::drawRasterizedText(const char *text, int x, int y, pixel::native_t
3169
3199
  const std::uint8_t fg4 = static_cast<std::uint8_t>(color & 0x0F);
3170
3200
  PackedGlyphStamp &e = gGlyphStamps[glyphStampSlot(font.data(), font.sizePx(), cp)];
3171
3201
  bool ready = e.fg == fg4 && e.backdrop == gTextStampBackdrop &&
3172
- e.fontData == font.data() && e.sizePx == font.sizePx() &&
3202
+ e.fontData == font.data() && e.fontGeneration==font.data()->generation && e.sizePx == font.sizePx() &&
3173
3203
  e.codepoint == cp;
3174
3204
  if (!ready) {
3175
3205
  e.fg = 0xFF;
@@ -3423,6 +3453,11 @@ void Canvas::drawTextFont(const char *text, int x, int y, pixel::native_t color,
3423
3453
  }
3424
3454
 
3425
3455
  void Canvas::drawTextFontFamily(const char *text, int x, int y, pixel::native_t color, int family_id, int size_px)
3456
+ {
3457
+ drawTextFontFamily(text,x,y,color,family_id,size_px,400,1000);
3458
+ }
3459
+
3460
+ void Canvas::drawTextFontFamily(const char *text,int x,int y,pixel::native_t color,int family_id,int size_px,int weight,int stretch)
3426
3461
  {
3427
3462
  #if GEA_EMBEDDED_TTF_RUNTIME_FONTS
3428
3463
  // No baked atlas linked, but the runtime TTF rasterizer can still serve the
@@ -3432,7 +3467,7 @@ void Canvas::drawTextFontFamily(const char *text, int x, int y, pixel::native_t
3432
3467
  // bitmap console font. Falls through to the bitmap font for families the
3433
3468
  // runtime rasterizer doesn't know.
3434
3469
  if (!pixels_ || !text) return;
3435
- RasterizedFont font = FontRegistry::rasterizedFamily(family_id, size_px);
3470
+ RasterizedFont font = FontRegistry::rasterizedFamily(family_id, size_px,weight,stretch);
3436
3471
  if (font.valid()) {
3437
3472
  int pen_x = x;
3438
3473
  int pen_y = y;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/engine",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "GeaStack rendering engine, intrinsic JSX primitives, and native engine backends.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -57,6 +57,6 @@
57
57
  },
58
58
  "sideEffects": false,
59
59
  "dependencies": {
60
- "@geastack/core": "^0.1.40"
60
+ "@geastack/core": "^0.1.46"
61
61
  }
62
62
  }
@@ -5,11 +5,23 @@
5
5
  #define GEA_EMBEDDED_TTF_RUNTIME_FONTS 0
6
6
  #endif
7
7
 
8
+ #ifndef GEA_EMBEDDED_TTF_FREETYPE
9
+ #define GEA_EMBEDDED_TTF_FREETYPE 0
10
+ #endif
11
+ #if GEA_EMBEDDED_TTF_FREETYPE && !GEA_EMBEDDED_TTF_RUNTIME_FONTS
12
+ #error "FreeType requires runtime TTF fonts"
13
+ #endif
8
14
  #if GEA_EMBEDDED_TTF_RUNTIME_FONTS
9
15
  #include "memory.h"
16
+ #if GEA_EMBEDDED_TTF_FREETYPE
17
+ #include <ft2build.h>
18
+ #include FT_FREETYPE_H
19
+ #include FT_MULTIPLE_MASTERS_H
20
+ #endif
10
21
 
11
22
  #include <algorithm>
12
23
  #include <cmath>
24
+ #include <climits>
13
25
  #include <cstdarg>
14
26
  #include <cstddef>
15
27
  #include <cstdio>
@@ -112,18 +124,37 @@ void runtimeTtfTrace(const char *, ...) {}
112
124
  constexpr int kRuntimeAsciiFirst = 0x20;
113
125
  constexpr int kRuntimeAsciiLast = 0x7e;
114
126
  constexpr int kRuntimeAsciiCount = kRuntimeAsciiLast - kRuntimeAsciiFirst + 1;
127
+ #if GEA_EMBEDDED_TTF_FREETYPE
128
+ constexpr int kRuntimeExtraCodepoints[] = {0x00b0,0x00b5,0x00d7,0x2013,0x2014,0x2018,0x2019,0x201c,0x201d,0x2022,0x2026,0x2190,0x2191,0x2192,0x2193,0x2212};
129
+ constexpr int kRuntimeExtraGlyphs = sizeof(kRuntimeExtraCodepoints)/sizeof(int);
130
+ #else
115
131
  constexpr int kRuntimeExtraGlyphs = 1;
132
+ #endif
116
133
  constexpr int kRuntimeGlyphCapacity = kRuntimeAsciiCount + kRuntimeExtraGlyphs;
117
134
  constexpr int kRuntimeFontCacheSlots = 64;
135
+ #if GEA_EMBEDDED_TTF_FREETYPE
136
+ constexpr int kRuntimeMaxAtlasWidth = 4096;
137
+ constexpr int kRuntimeMaxFontPx = 2048;
138
+ #else
118
139
  constexpr int kRuntimeMaxAtlasWidth = 256;
119
- constexpr int kRuntimeAtlasPadding = 1;
120
140
  constexpr int kRuntimeMaxFontPx = 192;
141
+ #endif
142
+ constexpr int kRuntimeAtlasPadding = 1;
121
143
 
122
144
  struct RuntimeRasterizedFontSlot {
123
145
  bool built = false;
124
146
  bool ready = false;
125
147
  int familyId = -1;
126
148
  int requestedSizePx = 0;
149
+ #if GEA_EMBEDDED_TTF_FREETYPE
150
+ int weight = 400;
151
+ int stretch = 1000;
152
+ #else
153
+ static constexpr int weight=400,stretch=1000;
154
+ #endif
155
+ #if GEA_EMBEDDED_TTF_FREETYPE
156
+ FT_Face face = nullptr;
157
+ #endif
127
158
  unsigned long usedAt = 0;
128
159
  const std::uint8_t *fontBytes = nullptr;
129
160
  unsigned long fontLength = 0;
@@ -142,7 +173,11 @@ struct RuntimeRasterizedFontSlot {
142
173
  int runtimeCodepointAt(int index)
143
174
  {
144
175
  if (index >= 0 && index < kRuntimeAsciiCount) return kRuntimeAsciiFirst + index;
176
+ #if GEA_EMBEDDED_TTF_FREETYPE
177
+ if (index>=kRuntimeAsciiCount && index<kRuntimeGlyphCapacity) return kRuntimeExtraCodepoints[index-kRuntimeAsciiCount];
178
+ #else
145
179
  if (index == kRuntimeAsciiCount) return 0x00b0;
180
+ #endif
146
181
  return -1;
147
182
  }
148
183
 
@@ -179,22 +214,57 @@ unsigned long nextRuntimeFontClock()
179
214
  void releaseRuntimeFontSlot(RuntimeRasterizedFontSlot &slot)
180
215
  {
181
216
  if (slot.atlas) memory::Allocator::free(slot.atlas);
217
+ #if GEA_EMBEDDED_TTF_FREETYPE
218
+ if(slot.face)FT_Done_Face(slot.face);
219
+ #endif
182
220
  slot = RuntimeRasterizedFontSlot{};
183
221
  }
184
222
 
185
- bool buildRuntimeFontSlot(RuntimeRasterizedFontSlot &slot, int familyId, int sizePx)
223
+ bool buildRuntimeFontSlot(RuntimeRasterizedFontSlot &slot, int familyId, int sizePx, int weight, int stretch)
186
224
  {
187
225
  runtimeTtfTrace("slot.begin family=%d size=%d", familyId, sizePx);
188
226
  releaseRuntimeFontSlot(slot);
189
227
  slot.built = true;
190
228
  slot.familyId = familyId;
191
229
  slot.requestedSizePx = sizePx;
230
+ #if GEA_EMBEDDED_TTF_FREETYPE
231
+ slot.weight=weight;slot.stretch=stretch;
232
+ #else
233
+ (void)weight;(void)stretch;
234
+ #endif
192
235
 
193
236
  unsigned long fontLength = 0;
194
237
  const std::uint8_t *fontBytes = generated::lookupRuntimeTtfFontForFamily(familyId, &fontLength);
195
238
  runtimeTtfTrace("slot.lookup family=%d bytes=%p len=%lu", familyId, static_cast<const void *>(fontBytes), fontLength);
196
239
  if (!fontBytes || fontLength == 0) return false;
197
240
 
241
+ #if GEA_EMBEDDED_TTF_FREETYPE
242
+ static FT_Library library=[](){FT_Library value=nullptr;return FT_Init_FreeType(&value)==0?value:nullptr;}();
243
+ if(!library || fontLength>static_cast<unsigned long>(LONG_MAX) || FT_New_Memory_Face(library,fontBytes,static_cast<FT_Long>(fontLength),0,&slot.face))return false;
244
+ FT_MM_Var *axes=nullptr;
245
+ bool hasWidth=false;
246
+ if(!FT_Get_MM_Var(slot.face,&axes)) {
247
+ FT_Fixed coords[32]{};
248
+ if(axes->num_axis>32){FT_Done_MM_Var(library,axes);return false;}
249
+ for(FT_UInt i=0;i<axes->num_axis;i++){
250
+ const auto &axis=axes->axis[i];double value=axis.def/65536.0;
251
+ if(axis.tag==FT_MAKE_TAG('w','g','h','t'))value=weight;
252
+ if(axis.tag==FT_MAKE_TAG('w','d','t','h')){value=stretch/10.0;hasWidth=true;}
253
+ coords[i]=static_cast<FT_Fixed>(std::clamp(value,axis.minimum/65536.0,axis.maximum/65536.0)*65536.0);
254
+ }
255
+ const auto error=FT_Set_Var_Design_Coordinates(slot.face,axes->num_axis,coords);
256
+ FT_Done_MM_Var(library,axes);if(error)return false;
257
+ }
258
+ const int clampedSizePx=std::clamp(sizePx>0?sizePx:16,1,kRuntimeMaxFontPx);
259
+ if(FT_Set_Pixel_Sizes(slot.face,0,clampedSizePx))return false;
260
+ // CSS stretch also applies to faces with no width axis, without altering weight.
261
+ FT_Matrix transform{hasWidth?65536:static_cast<FT_Fixed>(stretch*65536LL/1000),0,0,65536};
262
+ FT_Set_Transform(slot.face,&transform,nullptr);
263
+ slot.fontBytes=fontBytes;slot.fontLength=fontLength;
264
+ const int ascender=static_cast<int>((slot.face->size->metrics.ascender+63)/64);
265
+ const int descender=static_cast<int>((-slot.face->size->metrics.descender+63)/64);
266
+ const int lineHeight=std::max(1,ascender+descender);
267
+ #else
198
268
  const int offset = stbtt_GetFontOffsetForIndex(fontBytes, 0);
199
269
  runtimeTtfTrace("slot.offset family=%d offset=%d", familyId, offset);
200
270
  if (offset < 0 || !stbtt_InitFont(&slot.fontInfo, fontBytes, offset)) return false;
@@ -215,6 +285,8 @@ bool buildRuntimeFontSlot(RuntimeRasterizedFontSlot &slot, int familyId, int siz
215
285
  const int descender = ceilToInt(static_cast<float>(-descent) * scale);
216
286
  const int lineHeight = std::max(1, ascender + descender);
217
287
 
288
+ #endif
289
+
218
290
  int glyphCount = 0;
219
291
  for (int i = 0; i < kRuntimeGlyphCapacity; i++) {
220
292
  const int codepoint = runtimeCodepointAt(i);
@@ -236,7 +308,12 @@ bool buildRuntimeFontSlot(RuntimeRasterizedFontSlot &slot, int familyId, int siz
236
308
  if (!slot.atlas) return false;
237
309
  slot.atlas[0] = 0;
238
310
 
239
- slot.data.id = 0x70000000 + familyId * 1000 + clampedSizePx;
311
+ #if GEA_EMBEDDED_TTF_FREETYPE
312
+ static std::uint64_t nextGeneration=0;
313
+ if(nextGeneration==UINT64_MAX)return false;
314
+ slot.data.generation=++nextGeneration;
315
+ #endif
316
+ slot.data.id = 0x70000000 + familyId * 1000 + clampedSizePx;
240
317
  slot.data.sizePx = clampedSizePx;
241
318
  slot.data.lineHeight = lineHeight;
242
319
  slot.data.ascender = ascender;
@@ -291,6 +368,9 @@ bool reserveRuntimeAtlasRows(RuntimeRasterizedFontSlot &slot, int requiredHeight
291
368
  slot.atlasCapacityHeight,
292
369
  newHeight);
293
370
  const std::size_t newBytes = static_cast<std::size_t>(kRuntimeMaxAtlasWidth) * static_cast<std::size_t>(newHeight);
371
+ #if GEA_EMBEDDED_TTF_FREETYPE
372
+ if(newBytes>16u*1024u*1024u)return false;
373
+ #endif
294
374
  std::uint8_t *next = static_cast<std::uint8_t *>(memory::Allocator::allocatePreferSpiram(newBytes, alignof(std::uint8_t)));
295
375
  if (!next) return false;
296
376
  std::memset(next, 0, newBytes);
@@ -323,6 +403,15 @@ void ensureRuntimeGlyphMetrics(const RasterizedFontData *data, int codepoint)
323
403
  }
324
404
  Glyph &glyph = slot->glyphs[index];
325
405
  slot->metricReady[index] = 1;
406
+ #if GEA_EMBEDDED_TTF_FREETYPE
407
+ if(!slot->face || !FT_Get_Char_Index(slot->face,codepoint) || FT_Load_Char(slot->face,codepoint,FT_LOAD_RENDER|FT_LOAD_TARGET_NORMAL))return;
408
+ const auto &bitmap=slot->face->glyph->bitmap;
409
+ glyph.width=bitmap.width;glyph.height=bitmap.rows;
410
+ glyph.advance=static_cast<int>((slot->face->glyph->advance.x+32)/64);
411
+ glyph.advance16=static_cast<int>((slot->face->glyph->advance.x+2)/4);
412
+ glyph.bearingX=slot->face->glyph->bitmap_left;glyph.bearingY=slot->face->glyph->bitmap_top;
413
+ if(glyph.width>kRuntimeMaxAtlasWidth){glyph.width=0;glyph.height=0;return;}
414
+ #else
326
415
  if (codepoint != '?' && codepoint != ' ' && stbtt_FindGlyphIndex(&slot->fontInfo, codepoint) == 0) return;
327
416
 
328
417
  const float scale = stbtt_ScaleForMappingEmToPixels(&slot->fontInfo, static_cast<float>(slot->data.sizePx));
@@ -343,6 +432,7 @@ void ensureRuntimeGlyphMetrics(const RasterizedFontData *data, int codepoint)
343
432
  glyph.advance = std::max(1, roundToInt(static_cast<float>(advanceWidth) * scale));
344
433
  glyph.bearingX = x0;
345
434
  glyph.bearingY = -y0;
435
+ #endif
346
436
  if (glyph.width <= 0 || glyph.height <= 0) return;
347
437
 
348
438
  if (slot->atlasCursorX > 0 && slot->atlasCursorX + glyph.width + kRuntimeAtlasPadding > kRuntimeMaxAtlasWidth) {
@@ -398,6 +488,15 @@ void ensureRuntimeGlyphCoverage(const RasterizedFontData *data, const Glyph &gly
398
488
  slotGlyph.height);
399
489
  rasterTraceCount++;
400
490
  }
491
+ #if GEA_EMBEDDED_TTF_FREETYPE
492
+ if(FT_Load_Char(slot->face,slotGlyph.codepoint,FT_LOAD_RENDER|FT_LOAD_TARGET_NORMAL))return;
493
+ const auto &bitmap=slot->face->glyph->bitmap;
494
+ if(bitmap.pixel_mode!=FT_PIXEL_MODE_GRAY || static_cast<int>(bitmap.width)!=slotGlyph.width || static_cast<int>(bitmap.rows)!=slotGlyph.height)return;
495
+ for(int row=0;row<slotGlyph.height;row++) {
496
+ const auto *source=bitmap.buffer+(bitmap.pitch>=0?row:slotGlyph.height-1-row)*std::abs(bitmap.pitch);
497
+ std::memcpy(slot->atlas+(slotGlyph.sourceY+row)*data->atlasWidth+slotGlyph.sourceX,source,slotGlyph.width);
498
+ }
499
+ #else
401
500
  const float scale = stbtt_ScaleForMappingEmToPixels(&slot->fontInfo, static_cast<float>(slot->data.sizePx));
402
501
  if (scale <= 0.0f) return;
403
502
  stbtt_MakeCodepointBitmap(&slot->fontInfo,
@@ -408,11 +507,18 @@ void ensureRuntimeGlyphCoverage(const RasterizedFontData *data, const Glyph &gly
408
507
  scale,
409
508
  scale,
410
509
  slotGlyph.codepoint);
510
+ #endif
411
511
  }
412
512
 
413
- const RasterizedFontData *runtimeTtfFontForFamily(int familyId, int sizePx)
513
+ const RasterizedFontData *runtimeTtfFontForFamily(int familyId, int sizePx, int weight, int stretch)
414
514
  {
415
515
  if (familyId < 0) return nullptr;
516
+ #if GEA_EMBEDDED_TTF_FREETYPE
517
+ weight=std::clamp(weight>0?weight:400,1,1000);stretch=std::clamp(stretch>0?stretch:1000,1,32767);
518
+ #else
519
+ // Existing stb backend does not vary axes; preserve its prior two-tuple cache.
520
+ weight=400;stretch=1000;
521
+ #endif
416
522
  const int requestedSizePx = std::clamp(sizePx > 0 ? sizePx : 16, 1, kRuntimeMaxFontPx);
417
523
  RuntimeRasterizedFontSlot *slots = runtimeFontSlots();
418
524
  if (!slots) return nullptr;
@@ -422,7 +528,7 @@ const RasterizedFontData *runtimeTtfFontForFamily(int familyId, int sizePx)
422
528
 
423
529
  for (int i = 0; i < kRuntimeFontCacheSlots; i++) {
424
530
  RuntimeRasterizedFontSlot &slot = slots[i];
425
- if (slot.built && slot.familyId == familyId && slot.requestedSizePx == requestedSizePx) {
531
+ if (slot.built && slot.familyId == familyId && slot.requestedSizePx == requestedSizePx && slot.weight==weight && slot.stretch==stretch) {
426
532
  slot.usedAt = now;
427
533
  return slot.ready ? &slot.data : nullptr;
428
534
  }
@@ -431,7 +537,7 @@ const RasterizedFontData *runtimeTtfFontForFamily(int familyId, int sizePx)
431
537
  }
432
538
 
433
539
  RuntimeRasterizedFontSlot *slot = empty ? empty : lru;
434
- const bool ready = buildRuntimeFontSlot(*slot, familyId, requestedSizePx);
540
+ const bool ready = buildRuntimeFontSlot(*slot, familyId, requestedSizePx, weight, stretch);
435
541
  slot->usedAt = now;
436
542
  return ready ? &slot->data : nullptr;
437
543
  }
@@ -544,10 +650,15 @@ RasterizedFont FontRegistry::rasterized(int fontId)
544
650
  }
545
651
 
546
652
  RasterizedFont FontRegistry::rasterizedFamily(int familyId, int sizePx)
653
+ {
654
+ return rasterizedFamily(familyId,sizePx,400,1000);
655
+ }
656
+
657
+ RasterizedFont FontRegistry::rasterizedFamily(int familyId, int sizePx,int weight,int stretch)
547
658
  {
548
659
  ensureGeneratedFontsLinked();
549
660
  #if GEA_EMBEDDED_TTF_RUNTIME_FONTS
550
- if (const RasterizedFontData *data = runtimeTtfFontForFamily(familyId, sizePx)) {
661
+ if (const RasterizedFontData *data = runtimeTtfFontForFamily(familyId, sizePx,weight,stretch)) {
551
662
  return RasterizedFont(data);
552
663
  }
553
664
  #endif