CyaFont::~CyaFont() { if( m_pRenderableFont != NULL ) nfrf_release( m_pRenderableFont, NULL); m_pRenderableFont = NULL; if( m_displayRC ) nfrc_release( m_displayRC, NULL); m_displayRC = NULL; #ifndef NO_PERFORMANCE_HACK m_displayRCData = NULL; #endif /* NO_PERFORMANCE_HACK */ }
CNetscapeFontModule::~CNetscapeFontModule() { if( m_workingRC ) nfrc_release( m_workingRC, NULL); m_workingRC = NULL; // Save the catalog if (m_pFontBrokerUtilityInterface) { char exeDir_buffer[1024]; FE_GetProgramDirectory( exeDir_buffer, 512 ); if( *exeDir_buffer ) { strcat( exeDir_buffer, WF_FONT_CATALOG ); nffbu_SaveCatalog(m_pFontBrokerUtilityInterface, exeDir_buffer, NULL); } } releaseDisplayer(); }
// // Font stream handler. // This will be called by netlib to when a stream of type FO_FONT // is available. // extern "C" NET_StreamClass* /*ARGSUSED*/ wfNewStream(FO_Present_Types format_out, void* client_data, URL_Struct* urls, MWContext* cx) { struct nffbc *fbc = (struct nffbc *) client_data; struct wf_new_stream_data *inData = (struct wf_new_stream_data *) urls->fe_data; cfbImpl *oimpl = cfb2cfbImpl(fbc); FontBrokerObject *fbobj = (FontBrokerObject *)oimpl->object; const char *mimetype = fbobj->GetMimetype(urls->content_type, urls->address); if (!mimetype || !*mimetype) { return (NULL); } WF_TRACEMSG(("NF: Looking for mimetype: %s.", mimetype)); NET_StreamClass *netStream = NULL; // Find which font Displayer implements the mimetype struct wfListElement *tmp = fbobj->fpPeers.head; for(; tmp; tmp = tmp->next) { FontDisplayerPeerObject *fpp = (FontDisplayerPeerObject *) tmp->item; if (fpp->isMimetypeEnabled(mimetype) > 0) { // Get the font Displayer stream handle WF_TRACEMSG(("NF: fppeer %s supports mimetype %s.", fpp->name(), mimetype)); struct nfstrm *fpStream = fpp->CreateFontStreamHandler(inData->rc, inData->url_of_page); if (!fpStream) { // Error. Cannot create stream from Font Displayer. // We will cycle through other Displayers to see if we can // find any other font Displayer who can service us. WF_TRACEMSG(("NF: fppeer %s cannot create fpStream. " "Continuing...", fpp->name())); fpp = NULL; continue; } // Create a libnet stream netStream = (NET_StreamClass *) WF_ALLOC(sizeof(NET_StreamClass)); if (!netStream) { // Error. No point continuing. WF_TRACEMSG(("NF: Error: Cannot create net stream. No memory.")); nfstrm_release(fpStream, NULL); break; } // Create our stream data object struct stream_data *wfStream = new stream_data; if (!wfStream) { WF_TRACEMSG(("NF: Error: No memory to allocate stream_data.")); nfstrm_release(fpStream, NULL); delete netStream; netStream = NULL; break; } // Fill our stream data wfStream->urls = urls; nffbc_addRef(fbc, NULL); wfStream->fbc = fbc; // fpstream was created here. So no need to addref it as // the creation process would already have incremented the // refcount. //nfstrm_addRef(fpStream, NULL); wfStream->fpStream = fpStream; // Tell the wffpPeer about this new stream fpp->StreamCreated(fpStream); nfdoer_addRef(inData->observer, NULL); wfStream->observer = inData->observer; nff_addRef(inData->f, NULL); wfStream->f = inData->f; wfStream->fpPeer = fpp; // Fill libnet stream netStream->name = "Font Broker"; netStream->abort = wfAbort; netStream->complete = wfComplete; netStream->put_block = (MKStreamWriteFunc)wfWrite; netStream->is_write_ready = wfWriteReady; netStream->data_object = (void *)wfStream; netStream->window_id = cx; break; } } // Cleanup our wf_new_stream_data that was passed in nfdoer_release(inData->observer, NULL); nff_release(inData->f, NULL); nfrc_release(inData->rc, NULL); if (inData->url_of_page) { delete inData->url_of_page; inData->url_of_page = NULL; } delete inData; return (netStream); }