import_font.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ///if (is_paint || is_sculpt)
  2. function import_font_run(path: string) {
  3. for (let i: i32 = 0; i < project_fonts.length; ++i) {
  4. let f: slot_font_t = project_fonts[i];
  5. if (f.file == path) {
  6. console_info(strings_info0());
  7. return;
  8. }
  9. }
  10. let font: g2_font_t = data_get_font(path);
  11. g2_font_init(font); // Make sure font_ is ready
  12. let count: i32 = krom_g2_font_count(font.font_);
  13. let font_slots: slot_font_t[] = [];
  14. for (let i: i32 = 0; i < count; ++i) {
  15. let ar: string[] = string_split(path, path_sep);
  16. let name: string = ar[ar.length - 1];
  17. let f: g2_font_t = g2_font_clone(font);
  18. g2_font_set_font_index(f, i);
  19. let font_slot: slot_font_t = slot_font_create(name, f, path);
  20. array_push(font_slots, font_slot);
  21. }
  22. app_notify_on_init(function (font_slots: slot_font_t[]) {
  23. for (let i: i32 = 0; i < font_slots.length; ++i) {
  24. let f: slot_font_t = font_slots[i];
  25. context_raw.font = f;
  26. array_push(project_fonts, f);
  27. util_render_make_font_preview();
  28. }
  29. }, font_slots);
  30. ui_base_hwnds[tab_area_t.STATUS].redraws = 2;
  31. }
  32. ///end