static void svg_text(double x, double y, const char *str, double rot, double hadj, const pGEcontext gc, pDevDesc dd) { SVGDesc *svgd = (SVGDesc*) dd->deviceSpecific; fputs("<text", svgd->file); if (rot == 0) { write_attr_dbl(svgd->file, "x", x); write_attr_dbl(svgd->file, "y", y); } else { fprintf(svgd->file, " transform='translate(%.2f,%.2f) rotate(%0.0f)'", x, y, -1.0 * rot); } write_attr_dbl(svgd->file, "font-size", gc->cex * gc->ps); if (is_bold(gc->fontface)) write_attr_str(svgd->file, "font-weight", "bold"); if (is_italic(gc->fontface)) write_attr_str(svgd->file, "font-style", "italic"); if (gc->col != -16777216) // black write_attr_col(svgd->file, "fill", gc->col); std::string font = fontname(gc->fontfamily); write_attr_str(svgd->file, "font-family", font.c_str()); fputs(">", svgd->file); write_escaped(svgd->file, str); fputs("</text>\n", svgd->file); }
static double docx_strheight(const char *str, const pGEcontext gc, pDevDesc dd) { DOCX_dev *docx_obj = (DOCX_dev*) dd->deviceSpecific; std::string file = fontfile(gc->fontfamily, gc->fontface, docx_obj->user_aliases); std::string name = fontname(gc->fontfamily, gc->fontface, docx_obj->system_aliases, docx_obj->user_aliases); gdtools::context_set_font(docx_obj->cc, name, gc->cex * gc->ps, is_bold(gc->fontface), is_italic(gc->fontface), file); FontMetric fm = gdtools::context_extents(docx_obj->cc, std::string(str)); return fm.height; }
static double svg_strwidth(const char *str, const pGEcontext gc, pDevDesc dd) { SVGDesc *svgd = (SVGDesc*) dd->deviceSpecific; gdtools::context_set_font(svgd->cc, fontname(gc->fontfamily), gc->cex * gc->ps, is_bold(gc->fontface), is_italic(gc->fontface)); FontMetric fm = gdtools::context_extents(svgd->cc, std::string(str)); return fm.width; }
static double xlsx_strwidth(const char *str, const pGEcontext gc, pDevDesc dd) { XLSX_dev *xlsx_obj = (XLSX_dev*) dd->deviceSpecific; std::string file = fontfile(gc->fontfamily, gc->fontface, xlsx_obj->user_aliases); std::string name = fontname(gc->fontfamily, gc->fontface, xlsx_obj->system_aliases, xlsx_obj->user_aliases); gdtools::context_set_font(xlsx_obj->cc, name, gc->cex * gc->ps, is_bold(gc->fontface), is_italic(gc->fontface), file); FontMetric fm = gdtools::context_extents(xlsx_obj->cc, std::string(str)); return fm.width; }
void VSpanHandler::SetFont(const VString& inValue) { VTextStyle* TheStyle = fStyles->GetData(); if(TheStyle) { VString fontname(inValue); if(fontname.BeginsWith("'") || fontname.BeginsWith("\"")) fontname.Remove(1,1); if(fontname.EndsWith("'") || fontname.EndsWith("\"")) fontname.Remove(fontname.GetLength(),1); TheStyle->SetFontName(fontname); } }
static void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog ) { if (g_isIdle) wxapp_install_idle_handler(); GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget); wxGtkString fontname(gtk_font_selection_dialog_get_font_name(fontdlg)); dialog->SetChosenFont( fontname); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); event.SetEventObject( dialog ); dialog->GetEventHandler()->ProcessEvent( event ); }
void write_text_body_xlsx(pDevDesc dd, R_GE_gcontext *gc, const char* text, double hadj, double fontsize, double fontheight) { XLSX_dev *xlsx_obj = (XLSX_dev *) dd->deviceSpecific; ppr a_ppr_(hadj, fontsize); std::string fontname_ = fontname(gc->fontfamily, gc->fontface, xlsx_obj->system_aliases, xlsx_obj->user_aliases); rpr rpr_(fontsize, is_italic(gc->fontface), is_bold(gc->fontface), gc->col, fontname_); fputs("<xdr:txBody>", xlsx_obj->file ); fprintf(xlsx_obj->file, "%s", body_pr::a_tag().c_str() ); fputs("<a:p>", xlsx_obj->file ); fprintf(xlsx_obj->file, "%s", a_ppr_.a_tag().c_str() ); fputs("<a:r>", xlsx_obj->file ); fprintf(xlsx_obj->file, "%s", rpr_.a_tag().c_str() ); write_t_xlsx(dd, text); fputs("</a:r>", xlsx_obj->file ); fputs("</a:p>", xlsx_obj->file ); fputs("</xdr:txBody>", xlsx_obj->file ); }
CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc, const CFX_ByteStringC& name) { CFX_ByteString fontname(name); int font_id = PDF_GetStandardFontName(&fontname); if (font_id < 0) return nullptr; CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); CPDF_Font* pFont = pFontGlobals->Find(pDoc, font_id); if (pFont) return pFont; CPDF_Dictionary* pDict = new CPDF_Dictionary(pDoc->GetByteStringPool()); pDict->SetNewFor<CPDF_Name>("Type", "Font"); pDict->SetNewFor<CPDF_Name>("Subtype", "Type1"); pDict->SetNewFor<CPDF_Name>("BaseFont", fontname); pDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding"); return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict)); }
static void svg_metric_info(int c, const pGEcontext gc, double* ascent, double* descent, double* width, pDevDesc dd) { SVGDesc *svgd = (SVGDesc*) dd->deviceSpecific; // Convert to string - negative implies unicode code point char str[16]; if (c < 0) { Rf_ucstoutf8(str, (unsigned int) -c); } else { str[0] = (char) c; str[1] = '\0'; } gdtools::context_set_font(svgd->cc, fontname(gc->fontfamily), gc->cex * gc->ps, is_bold(gc->fontface), is_italic(gc->fontface)); FontMetric fm = gdtools::context_extents(svgd->cc, std::string(str)); *ascent = fm.ascent; *descent = fm.descent; *width = fm.width; }
void write_text_body_docx(pDevDesc dd, R_GE_gcontext *gc, const char* text, double hadj, double fontsize, double fontheight) { DOCX_dev *docx_obj = (DOCX_dev *) dd->deviceSpecific; ppr a_ppr_(hadj, fontsize); std::string fontname_ = fontname(gc->fontfamily, gc->fontface, docx_obj->system_aliases, docx_obj->user_aliases); rpr rpr_(fontsize, is_italic(gc->fontface), is_bold(gc->fontface), gc->col, fontname_); fputs("<wps:txbx>", docx_obj->file ); fputs("<w:txbxContent>", docx_obj->file ); fputs("<w:p>", docx_obj->file ); fprintf(docx_obj->file, "%s", a_ppr_.w_tag().c_str() ); fputs("<w:r>", docx_obj->file ); fprintf(docx_obj->file, "%s", rpr_.w_tag().c_str() ); write_t_docx(dd, text); fputs("</w:r>", docx_obj->file ); fputs("</w:p>", docx_obj->file ); fputs("</w:txbxContent>", docx_obj->file ); fputs("</wps:txbx>", docx_obj->file ); }
static void xlsx_metric_info(int c, const pGEcontext gc, double* ascent, double* descent, double* width, pDevDesc dd) { XLSX_dev *xlsx_obj = (XLSX_dev*) dd->deviceSpecific; // Convert to string - negative implies unicode code point char str[16]; if (c < 0) { Rf_ucstoutf8(str, (unsigned int) -c); } else { str[0] = (char) c; str[1] = '\0'; } std::string file = fontfile(gc->fontfamily, gc->fontface, xlsx_obj->user_aliases); std::string name = fontname(gc->fontfamily, gc->fontface, xlsx_obj->system_aliases, xlsx_obj->user_aliases); gdtools::context_set_font(xlsx_obj->cc, name, gc->cex * gc->ps, is_bold(gc->fontface), is_italic(gc->fontface), file); FontMetric fm = gdtools::context_extents(xlsx_obj->cc, std::string(str)); *ascent = fm.ascent; *descent = fm.descent; *width = fm.width; }
void dvifile::read_postamble() { quint8 magic_byte = readUINT8(); if (magic_byte != POST) { errorMsg = i18n("The postamble does not begin with the POST command."); return; } last_page_offset = readUINT32(); // Skip the numerator, denominator and magnification, the largest // box height and width and the maximal depth of the stack. These // are not used at the moment. command_pointer += 4 + 4 + 4 + 4 + 4 + 2; // The number of pages is more interesting for us. total_pages = readUINT16(); // As a next step, read the font definitions. quint8 cmnd = readUINT8(); while (cmnd >= FNTDEF1 && cmnd <= FNTDEF4) { quint32 TeXnumber = readUINT(cmnd-FNTDEF1+1); quint32 checksum = readUINT32(); // Checksum of the font, as found by TeX in the TFM file // Read scale and design factor, and the name of the font. All // these are explained in section A.4 of the DVI driver standard, // Level 0, published by the TUG DVI driver standards committee quint32 scale = readUINT32(); quint32 design = readUINT32(); quint16 len = readUINT8() + readUINT8(); // Length of the font name, including the directory name QByteArray fontname((char*)command_pointer, len); command_pointer += len; #ifdef DEBUG_FONTS kDebug(kvs::dvi) << "Postamble: define font \"" << fontname << "\" scale=" << scale << " design=" << design; #endif // According to section A.4 of the DVI driver standard, this font // shall be enlarged by the following factor before it is used. double enlargement_factor = (double(scale) * double(_magnification))/(double(design) * 1000.0); if (font_pool != 0) { TeXFontDefinition *fontp = font_pool->appendx(fontname, checksum, scale, enlargement_factor); // Insert font in dictionary and make sure the dictionary is big // enough. if (tn_table.capacity()-2 <= tn_table.count()) // Not quite optimal. The size of the dictionary should be a // prime for optimal performance. I don't care. tn_table.reserve(tn_table.capacity()*2); tn_table.insert(TeXnumber, fontp); } // Read the next command cmnd = readUINT8(); } if (cmnd != POSTPOST) { errorMsg = i18n("The postamble contained a command other than FNTDEF."); return; } // Now we remove all those fonts from the memory which are no longer // in use. if (font_pool != 0) font_pool->release_fonts(); }
/*! Returns a system-specific text string to use for font loading, based on the style settings of this node. */ SbString SoFontStyle::getFontName(void) const { SbString fontname(this->name.getValue().getString()); #if COIN_DEBUG static SbBool messageflag = TRUE; if (messageflag && (fontname != "defaultFont")) { SoDebugError::postWarning("SoFontStyle::getFontName", "Font name ('%s') is ignored when using " "FontStyle nodes. Use the 'family' and " "'style' fields instead.", fontname.getString()); messageflag = FALSE; // Only display this message once. } #endif switch (this->family.getValue()) { case SoFontStyle::SERIF: fontname = "Times New Roman"; break; case SoFontStyle::SANS: fontname = "Arial"; break; case SoFontStyle::TYPEWRITER: fontname = "Courier New"; break; #if COIN_DEBUG default: SoDebugError::postWarning("SoFontStyle::getFontName", "value of family field is invalid, setting to SERIF"); fontname = "Times New Roman"; break; #endif // COIN_DEBUG } // If this doesn't hold up, we need to include a few more cases in // the switch block. assert(SoFontStyle::NONE == 0); switch (this->style.getValue()) { case SoFontStyle::NONE: break; case SoFontStyle::BOLD: fontname += ":Bold"; break; case SoFontStyle::ITALIC: fontname += ":Italic"; break; case (SoFontStyle::BOLD | SoFontStyle::ITALIC): fontname += ":Bold Italic"; break; #if COIN_DEBUG default: SoDebugError::postWarning("SoFontStyle::getFontName", "value of style field is invalid"); break; #endif // COIN_DEUG } return fontname; }