result_t create_hsi_window(handle_t parent, memid_t key, handle_t *hwnd) { result_t result; // create our window if (failed(result = create_child_widget(parent, key, widget_wndproc, hwnd))) return result; // create the window data. hsi_window_t *wnd = (hsi_window_t *)neutron_malloc(sizeof(hsi_window_t)); memset(wnd, 0, sizeof(hsi_window_t)); wnd->version = sizeof(hsi_window_t); if (failed(lookup_color(key, "background-color", &wnd->background_color))) wnd->background_color = color_black; reg_get_bool(key, "draw-border", &wnd->draw_border); if (failed(lookup_font(key, "font", &wnd->font))) { // we always have the neo font. if (failed(result = open_font("neo", 9, &wnd->font))) return result; } // store the parameters for the window set_wnddata(*hwnd, wnd); rect_t rect; get_window_rect(*hwnd, &rect); invalidate_rect(*hwnd, &rect); return s_ok; }
void resource_manager::read_download_file() { char *path = 0; FILE *fp = font::open_file("download", &path); if (!fp) fatal("can't find `download'"); char buf[512]; int lineno = 0; while (fgets(buf, sizeof(buf), fp)) { lineno++; char *p = strtok(buf, " \t\r\n"); if (p == 0 || *p == '#') continue; char *q = strtok(0, " \t\r\n"); if (!q) fatal_with_file_and_line(path, lineno, "missing filename"); lookup_font(p)->filename = strsave(q); } a_delete path; fclose(fp); }
void resource_manager::need_font(const char *name) { lookup_font(name)->flags |= resource::FONT_NEEDED; }
PDFFont const& FontManagement::font_load(IFontEx const& font) { if (font.has_multiple_encondings()) { std::auto_ptr<PDFFont> fnt(new PDFFont(*this, &font, 0)); return lookup_font(fnt); } bool force_cid = false; switch (font.typeface().type()) { case FACE_TRUE_TYPE: // the following block disallows using cid fonts for <1.3 // that's correct for truetype (cannot be embedded as // CIDFontType2) but we need to reconsider this for other font // types once they are supported // // do not force cids version <1.3 - cannot embed the font program if (m_doc.version() >= 3) force_cid = static_cast<bool>(m_doc.exec_context().config().get_int("fonts.force_cid")); break; case FACE_TYPE_1_ADOBE_STANDARD: break; case FACE_OPEN_TYPE_CFF: // it seems that making CFF font by simply extracting cff // table works for versions < 1.6 // m_doc.ensure_version(6, "OpenType with CFF"); break; default: throw exception_invalid_input(msg_unknown_font_format()) << JAGLOC; } PDFFontDictData fdict_data(font, force_cid); // do not allow composite fonts for <1.3 if (m_doc.version() < 3 && PDFFontData::COMPOSITE_FONT == fdict_data.font_type()) { throw exception_invalid_operation(msg_cid_fonts_not_supported()) << JAGLOC; } // retrieve font dictionary, it can already exist or we need to create a new // one FontDictMap::iterator fdict_it = m_fontdicts.find(fdict_data); if (fdict_it == m_fontdicts.end()) { // create a new font dictionary and font and them to their maps // TBD: add one-based handle-id to FontDictMap ctor std::auto_ptr<FontDictionary> fdict( new FontDictionary(m_doc, ++m_fdict_id, fdict_data, font.encoding_canonical())); std::auto_ptr<PDFFont> pdffont(new PDFFont(*this, &font, fdict.get())); PDFFont const& result = *pdffont; m_fonts.insert(pdffont.release()); m_fontdicts.insert(fdict_data, fdict.release()); return result; } else { // font dictionary already exists, create a pdf font a and try to look // it up in the font map std::auto_ptr<PDFFont> pdffont( new PDFFont(*this, &font, fdict_it->second)); return lookup_font(pdffont); } }