Example #1
0
int say_font_load_from_memory(say_font *font, void *buf, size_t size) {
  int err = FT_New_Memory_Face(font->library, buf, size, 0, &font->face);
  if (err) {
    say_error_set("could not create face");
    return 0;
  }

  err = FT_Select_Charmap(font->face, FT_ENCODING_UNICODE);
  if (err) {
    say_error_set("could not select unicode charmap");
    return 0;
  }

  return 1;
}
Example #2
0
bool say_window_resize(say_window *win, size_t w, size_t h) {
  if (w == 0 || h == 0) {
    say_error_set("can't create empty window");
    return false;
  }

  return say_imp_window_resize(win->win, w, h);
}
Example #3
0
static int say_font_set_size(say_font *font, size_t size) {
  if (say_font_get_size(font) != size) {
    int err = FT_Set_Pixel_Sizes(font->face, 0, size);
    if (err) {
      say_error_set("could not set font size");
      return 0;
    }
  }

  int err = FT_Select_Charmap(font->face, FT_ENCODING_UNICODE);
  if (err) {
    say_error_set("could not select unicode charmap");
    return 0;
  }

  return 1;
}
Example #4
0
bool say_window_set_icon(say_window *win, say_image *icon) {
  if (say_image_get_width(icon)  == 0 ||
      say_image_get_height(icon) == 0) {
    say_error_set("can't create icon from empty string");
    return false;
  }

  return say_imp_window_set_icon(win->win, icon);
}
Example #5
0
int say_font_load_from_file(say_font *font, const char *file) {
  int err = FT_New_Face(font->library, file, 0, &font->face);
  if (err) {
    say_error_set("could not create face");
    return 0;
  }

  return 1;
}
Example #6
0
void say_audio_context_ensure() {
  if (!say_audio_device) {
    say_audio_device = alcOpenDevice(NULL);
    if (!say_audio_device) {
      say_error_set("could not open audio device");
      return;
    }
  }

  if (!say_audio_context) {
    say_audio_context = alcCreateContext(say_audio_device, NULL);
    if (!say_audio_context) {
      say_error_set("could not create audio context");
      return;
    }

    alcMakeContextCurrent(say_audio_context);
  }
}
Example #7
0
say_font *say_font_create() {
  say_font *font = malloc(sizeof(say_font));

  int err = FT_Init_FreeType(&font->library);
  if (err) {
    free(font);

    say_error_set("could not initialize freetype library");
    return NULL;
  }

  font->face = NULL;

  font->pages = say_table_create((say_destructor)say_page_free);

  return font;
}
Example #8
0
int say_window_open(say_window *win, size_t w, size_t h, const char *title,
                    uint8_t style) {
  if (w < 1 || h < 1) {
    say_error_set("window size must be at least (1,1)");
    return 0;
  }

  win->show_cursor = true;

  if (!say_imp_window_open(win->win, title, w, h, style))
    return false;

  say_target_set_context_proc(win->target,
                              (say_context_proc)say_context_create_for_window);
  say_target_set_bind_hook(win->target, say_window_unbind_fbo);
  say_target_set_custom_data(win->target, (void*)win);
  say_target_set_size(win->target, say_make_vector2(w, h));
  say_view_set_size(win->target->view, say_make_vector2(w, h));
  say_view_set_center(win->target->view, say_make_vector2(w / 2.0, h / 2.0));
  say_target_make_current(win->target);

  return 1;
}