Lines Matching refs:dsc

106 static void lv_tiny_ttf_cache_create(ttf_font_desc_t * dsc);
129 ttf_font_desc_t * dsc = (ttf_font_desc_t *)font->dsc; in lv_tiny_ttf_set_size() local
130 dsc->scale = stbtt_ScaleForMappingEmToPixels(&dsc->info, font_size); in lv_tiny_ttf_set_size()
132 stbtt_GetFontVMetrics(&dsc->info, &dsc->ascent, &dsc->descent, &line_gap); in lv_tiny_ttf_set_size()
133 font->line_height = (int32_t)(dsc->scale * (dsc->ascent - dsc->descent + line_gap)); in lv_tiny_ttf_set_size()
134 font->base_line = (int32_t)(dsc->scale * (line_gap - dsc->descent)); in lv_tiny_ttf_set_size()
138 if(dsc->glyph_cache) { in lv_tiny_ttf_set_size()
139 lv_cache_destroy(dsc->glyph_cache, NULL); in lv_tiny_ttf_set_size()
140 dsc->glyph_cache = NULL; in lv_tiny_ttf_set_size()
143 if(dsc->draw_data_cache) { in lv_tiny_ttf_set_size()
144 lv_cache_destroy(dsc->draw_data_cache, NULL); in lv_tiny_ttf_set_size()
145 dsc->draw_data_cache = NULL; in lv_tiny_ttf_set_size()
148 lv_tiny_ttf_cache_create(dsc); in lv_tiny_ttf_set_size()
155 if(font->dsc != NULL) { in lv_tiny_ttf_destroy()
156 ttf_font_desc_t * ttf = (ttf_font_desc_t *)font->dsc; in lv_tiny_ttf_destroy()
165 font->dsc = NULL; in lv_tiny_ttf_destroy()
222 ttf_font_desc_t * dsc = (ttf_font_desc_t *)font->dsc; in ttf_get_glyph_dsc_cb() local
229 … lv_cache_entry_t * entry = lv_cache_acquire_or_create(dsc->glyph_cache, &search_key, (void *)dsc); in ttf_get_glyph_dsc_cb()
232 if(!dsc->cache_size) { /* no cache, do everything directly */ in ttf_get_glyph_dsc_cb()
233 uint32_t g1 = stbtt_FindGlyphIndex(&dsc->info, (int)unicode_letter); in ttf_get_glyph_dsc_cb()
234 tiny_ttf_glyph_cache_create_cb(&search_key, dsc); in ttf_get_glyph_dsc_cb()
241 …int g2 = stbtt_FindGlyphIndex(&dsc->info, (int)unicode_letter_next); /* not using cache, only do g… in ttf_get_glyph_dsc_cb()
243 int k = stbtt_GetGlyphKernAdvance(&dsc->info, g1, g2); in ttf_get_glyph_dsc_cb()
244 dsc_out->adv_w = (uint16_t)floor((((float)adv_w + (float)k) * dsc->scale) + in ttf_get_glyph_dsc_cb()
259 lv_cache_release(dsc->glyph_cache, entry, NULL); in ttf_get_glyph_dsc_cb()
268 …ache_entry_t * entry_next = lv_cache_acquire_or_create(dsc->glyph_cache, &search_key, (void *)dsc); in ttf_get_glyph_dsc_cb()
271 g2 = stbtt_FindGlyphIndex(&dsc->info, (int)unicode_letter_next); in ttf_get_glyph_dsc_cb()
275 lv_cache_release(dsc->glyph_cache, entry_next, NULL); in ttf_get_glyph_dsc_cb()
279 int k = stbtt_GetGlyphKernAdvance(&dsc->info, g1, g2); in ttf_get_glyph_dsc_cb()
280 dsc_out->adv_w = (uint16_t)floor((((float)adv_w + (float)k) * dsc->scale) + in ttf_get_glyph_dsc_cb()
294 ttf_font_desc_t * dsc = (ttf_font_desc_t *)font->dsc; in ttf_get_glyph_bitmap_cb() local
300 …ache_entry_t * entry = lv_cache_acquire_or_create(dsc->draw_data_cache, &search_key, (void *)font-… in ttf_get_glyph_bitmap_cb()
302 if(!dsc->cache_size) { /* no cache, do everything directly */ in ttf_get_glyph_bitmap_cb()
303 if(tiny_ttf_draw_data_cache_create_cb(&search_key, (void *)font->dsc)) { in ttf_get_glyph_bitmap_cb()
325 ttf_font_desc_t * dsc = (ttf_font_desc_t *)font->dsc; in ttf_release_glyph_cb() local
326 if(!dsc->cache_size) { /* no cache, do everything directly */ in ttf_release_glyph_cb()
333 lv_cache_release(dsc->draw_data_cache, g_dsc->entry, NULL); in ttf_release_glyph_cb()
338 static void lv_tiny_ttf_cache_create(ttf_font_desc_t * dsc) in lv_tiny_ttf_cache_create() argument
341dsc->glyph_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(tiny_ttf_glyph_cache_data_… in lv_tiny_ttf_cache_create()
347 lv_cache_set_name(dsc->glyph_cache, "TINY_TTF_GLYPH"); in lv_tiny_ttf_cache_create()
349dsc->draw_data_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(tiny_ttf_cache_data_t)… in lv_tiny_ttf_cache_create()
355 lv_cache_set_name(dsc->draw_data_cache, "TINY_TTF_DRAW_DATA"); in lv_tiny_ttf_cache_create()
366 ttf_font_desc_t * dsc = lv_malloc_zeroed(sizeof(ttf_font_desc_t)); in lv_tiny_ttf_create() local
367 if(dsc == NULL) { in lv_tiny_ttf_create()
373 if(LV_FS_RES_OK != lv_fs_open(&dsc->file, path, LV_FS_MODE_RD)) { in lv_tiny_ttf_create()
374 lv_free(dsc); in lv_tiny_ttf_create()
378 dsc->stream.file = &dsc->file; in lv_tiny_ttf_create()
381 dsc->stream.data = (const uint8_t *)data; in lv_tiny_ttf_create()
382 dsc->stream.size = data_size; in lv_tiny_ttf_create()
384 … if(0 == stbtt_InitFont(&dsc->info, &dsc->stream, stbtt_GetFontOffsetForIndex(&dsc->stream, 0))) { in lv_tiny_ttf_create()
385 lv_free(dsc); in lv_tiny_ttf_create()
391 dsc->stream = (const uint8_t *)data; in lv_tiny_ttf_create()
392 if(0 == stbtt_InitFont(&dsc->info, dsc->stream, stbtt_GetFontOffsetForIndex(dsc->stream, 0))) { in lv_tiny_ttf_create()
393 lv_free(dsc); in lv_tiny_ttf_create()
399 dsc->cache_size = cache_size; in lv_tiny_ttf_create()
403 lv_free(dsc); in lv_tiny_ttf_create()
409 if(stbtt_KernTableCheck(&dsc->info) == 0) { in lv_tiny_ttf_create()
413 dsc->kerning = kerning; in lv_tiny_ttf_create()
419 out_font->dsc = dsc; in lv_tiny_ttf_create()
451 ttf_font_desc_t * dsc = (ttf_font_desc_t *)user_data; in tiny_ttf_glyph_cache_create_cb() local
456 int g1 = stbtt_FindGlyphIndex(&dsc->info, (int)unicode_letter); in tiny_ttf_glyph_cache_create_cb()
463 stbtt_GetGlyphBitmapBox(&dsc->info, g1, dsc->scale, dsc->scale, &x1, &y1, &x2, &y2); in tiny_ttf_glyph_cache_create_cb()
466 stbtt_GetGlyphHMetrics(&dsc->info, g1, &advw, &lsb); in tiny_ttf_glyph_cache_create_cb()
467 if(dsc->kerning != LV_FONT_KERNING_NORMAL) { /* calculate default advance */ in tiny_ttf_glyph_cache_create_cb()
468 int k = stbtt_GetGlyphKernAdvance(&dsc->info, g1, 0); in tiny_ttf_glyph_cache_create_cb()
469 dsc_out->adv_w = (uint16_t)floor((((float)advw + (float)k) * dsc->scale) + in tiny_ttf_glyph_cache_create_cb()
473 dsc_out->adv_w = (uint16_t)floor(((float)advw * dsc->scale) + in tiny_ttf_glyph_cache_create_cb()
513 ttf_font_desc_t * dsc = (ttf_font_desc_t *)user_data; in tiny_ttf_draw_data_cache_create_cb() local
515 const stbtt_fontinfo * info = (const stbtt_fontinfo *)&dsc->info; in tiny_ttf_draw_data_cache_create_cb()
517 stbtt_GetGlyphBitmapBox(info, g1, dsc->scale, dsc->scale, &x1, &y1, &x2, &y2); in tiny_ttf_draw_data_cache_create_cb()
531 stbtt_MakeGlyphBitmap(info, draw_buf->data, w, h, stride, dsc->scale, dsc->scale, g1); in tiny_ttf_draw_data_cache_create_cb()