/*! * \brief Apply the current style properties to the given object */ void DiaOutputDev::applyStyle (DiaObject *obj, bool fill) { GPtrArray *plist = g_ptr_array_new (); if (!fill) { prop_list_add_line_width (plist, this->line_width); prop_list_add_line_style (plist, this->line_style, this->dash_length); prop_list_add_line_colour (plist, &this->stroke_color); } else { prop_list_add_line_width (plist, 0); prop_list_add_line_colour (plist, &this->fill_color); prop_list_add_fill_colour (plist, &this->fill_color); } prop_list_add_show_background (plist, fill ? TRUE : FALSE); // using the "Standard - Path" internal enum values here is a bit dirty prop_list_add_enum (plist, "stroke_or_fill", fill ? 0x2 : 0x1); obj->ops->set_props (obj, plist); prop_list_free (plist); }
/*! * \brief Draw a string to _Textobj * * To get objects more similar to what we had during export we * should probably use TextOutputDev. It reassembles strings * based on their position on the page. Or maybe Dia/cairo should * stop realigning single glyphs in it's output? * * \todo Check alignment options - it's just guessed yet. */ void DiaOutputDev::drawString(GfxState *state, GooString *s) { Color text_color = this->fill_color; int len = s->getLength(); DiaObject *obj; gchar *utf8 = NULL; DiaFont *font; // ignore empty strings if (len == 0) return; // get the font if (!state->getFont()) return; if (!(state->getFontSize() > 0.0)) return; font = (DiaFont *)g_hash_table_lookup (this->font_map, state->getFont()); // we have to decode the string data first { GfxFont *f = state->getFont(); char *p = s->getCString(); CharCode code; int j = 0, m, n; utf8 = g_new (gchar, len * 6 + 1); Unicode *u; int uLen; double dx, dy, ox, oy; while (len > 0) { n = f->getNextChar(p, len, &code, &u, &uLen, &dx, &dy, &ox, &oy); p += n; len -= n; m = g_unichar_to_utf8 (u[0], &utf8[j]); j += m; } utf8[j] = '\0'; } // check for invisible text -- this is used by Acrobat Capture if (state->getRender() == 3) text_color.alpha = 0.0; // not sure how state->getLineX() is related, it's 0 in my test cases double tx = state->getCurX(); double ty = state->getCurY(); int rot = state->getRotate(); if (rot == 0) obj = create_standard_text (tx * scale, page_height - ty * scale); else /* XXX: at least for rot==90 */ obj = create_standard_text (ty * scale, tx * scale); //not applyStyle (obj, TEXT); GPtrArray *plist = g_ptr_array_new (); // the "text" property is special, it must be initialized with text // attributes, too. So here it comes first to avoid overwriting // the other values with defaults. prop_list_add_text (plist, "text", utf8); prop_list_add_font (plist, "text_font", font); prop_list_add_text_colour (plist, &text_color); prop_list_add_enum (plist, "text_alignment", this->alignment); prop_list_add_fontsize (plist, "text_height", state->getTransformedFontSize() * scale / 0.8); obj->ops->set_props (obj, plist); prop_list_free (plist); g_free (utf8); addObject (obj); }