Esempio n. 1
0
 point measure_icon(canvas& cnv, uint32_t cp, float size)
 {
    auto  state = cnv.new_state();
    auto& thm = get_theme();
    cnv.font(thm.icon_font, size);
    return cnv.measure_text(codepoint_to_utf8(cp).c_str()).size;
 }
Esempio n. 2
0
GSDLLEXPORT int GSDLLAPI
gsapi_run_file(void *lib, const char *file_name,
        int user_errors, int *pexit_code)
{
#ifndef GS_NO_UTF8
    char *d, *temp;
    const char *c = file_name;
    char dummy[6];
    int rune, code, len;
#endif
    gs_lib_ctx_t *ctx = (gs_lib_ctx_t *)lib;
    gs_main_instance *minst;
    if (lib == NULL)
        return gs_error_Fatal;
    minst = get_minst_from_memory(ctx->memory);

#ifdef GS_NO_UTF8
    return gs_main_run_file(minst, file_name, user_errors, pexit_code,
                            &(minst->error_object));
#else
    /* Convert the file_name to utf8 */
    if (minst->get_codepoint) {
        len = 1;
        while ((rune = minst->get_codepoint(NULL, &c)) >= 0)
            len += codepoint_to_utf8(dummy, rune);
        temp = (char *)gs_alloc_bytes_immovable(ctx->memory, len, "gsapi_run_file");
        if (temp == NULL)
            return 0;
        c = file_name;
        d = temp;
        while ((rune = minst->get_codepoint(NULL, &c)) >= 0)
           d += codepoint_to_utf8(d, rune);
        *d = 0;
    }
    else {
      temp = (char *)file_name;
    }
    code =  gs_main_run_file(minst, temp, user_errors, pexit_code,
                             &(minst->error_object));
    if (temp != file_name)
        gs_free_object(ctx->memory, temp, "gsapi_run_file");
    return code;
#endif
}