/*! * \brief Add font data to an attribute node. * @param attr The attribute node. * @param font The value to set. * \ingroup DiagramXmlOut */ void data_add_font(AttributeNode attr, const DiaFont *font, DiaContext *ctx) { DataNode data_node; char buffer[20+1]; /* Enought for 64bit int + zero */ data_node = xmlNewChild(attr, NULL, (const xmlChar *)"font", NULL); xmlSetProp(data_node, (const xmlChar *)"family", (xmlChar *) dia_font_get_family(font)); g_snprintf(buffer, 20, "%d", dia_font_get_style(font)); xmlSetProp(data_node, (const xmlChar *)"style", (xmlChar *) buffer); /* Legacy support: don't crash older Dia on missing 'name' attribute */ xmlSetProp(data_node, (const xmlChar *)"name", (xmlChar *) dia_font_get_legacy_name(font)); }
G_CONST_RETURN char* dia_font_get_psfontname(const DiaFont *font) { /* This hack corrects a couple fonts that were misnamed in * earlier versions of Dia. See bug #477079. */ const char *fontname = dia_font_get_legacy_name(font); if (!fontname) return NULL; if (strcmp(fontname, "NewCenturySchoolbook-Roman") == 0) return "NewCenturySchlbk-Roman"; else if (strcmp(fontname, "NewCenturySchoolbook-Italic") == 0) return "NewCenturySchlbk-Italic"; else if (strcmp(fontname, "NewCenturySchoolbook-Bold") == 0) return "NewCenturySchlbk-Bold"; else if (strcmp(fontname, "NewCenturySchoolbook-BoldItalic") == 0) return "NewCenturySchlbk-BoldItalic"; return fontname; }