summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 80b358e)
raw | patch | inline | side by side (parent: 80b358e)
author | JucaBlues <JucaBlues@users.sourceforge.net> | |
Fri, 11 Jul 2008 06:03:47 +0000 (06:03 +0000) | ||
committer | JucaBlues <JucaBlues@users.sourceforge.net> | |
Fri, 11 Jul 2008 06:03:47 +0000 (06:03 +0000) |
* added font preview to the SvgFonts dialog
index 7b0b4938b7584acde2e529e6bac7eb488b3a2734..b59d0569de467a6f6161ecfe79dc4cc8f912ce3a 100644 (file)
#include "inkscape-cairo.h"
#include "nr-svgfonts.h"
-//***********************************//
-// SvgFontDrawingArea Implementation //
-//***********************************//
-class SvgFontDrawingArea : Gtk::DrawingArea{
-public:
-SvgFontDrawingArea(SvgFont* svgfont){
- this->svgfont = svgfont;
-}
-private:
-SvgFont* svgfont;
-
-bool on_expose_event (GdkEventExpose *event){
- Glib::RefPtr<Gdk::Window> window = get_window();
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
- cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(this->svgfont->get_font_face(), false /* does not have reference */)) );
- cr->set_font_size (100);
- cr->move_to (100, 100);
- cr->show_text ("A@!A!@A");
-
- return TRUE;
-}
-};//class SvgFontDrawingArea
-
//*************************//
// UserFont Implementation //
//*************************//
this->font = spfont;
this->missingglyph = NULL;
this->userfont = NULL;
-
- //This is an auxiliary gtkWindow used only while we do not have proper Pango integration with cairo-user-fonts.
- Gtk::Window* window;
- SvgFontDrawingArea* font_da;
-
- window = new Gtk::Window();
- window->set_default_size (1200, 850);
- font_da = new SvgFontDrawingArea(this);
- window->add((Gtk::Widget&) *font_da);
- window->show_all();
}
cairo_status_t
index 58840e414e729711d7256146837a9a339bdcc9c2..ff98f521f6879030acb9bad86ee87367c7bd242e 100644 (file)
*/
#include "cairo.h"
-#include <gtkmm.h>
+//#include <gtkmm.h>
#include <gtkmm/widget.h>
-#include <gtkmm/window.h>
-#include <gdkmm/drawable.h>
-#include <gdkmm/general.h> // for cairo helper functions
+//#include <gtkmm/window.h>
+//#include <gdkmm/drawable.h>
+//#include <gdkmm/general.h> // for cairo helper functions
#include "../sp-glyph.h"
#include "../sp-missing-glyph.h"
diff --git a/src/sp-font.cpp b/src/sp-font.cpp
index c99d5a1b66814da6e93812de1539702be92a1620..789d3a62a95111076a72e9df9b1c926f0e9ac9d0 100644 (file)
--- a/src/sp-font.cpp
+++ b/src/sp-font.cpp
@@ -103,8 +103,6 @@ static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML:
sp_object_read_attr(object, "vert-origin-y");
sp_object_read_attr(object, "vert-adv-y");
- SvgFont* svgfont = new SvgFont(SP_FONT(object));
-
sp_document_add_resource(document, "font", object);
}
index fb51da7deb239c9f812c6a6c7684f9923fcb7aa8..38639a20d189b3bdb3d51ec41f087658db3c4a00 100644 (file)
#include "svg-fonts-dialog.h"
+SvgFontDrawingArea::SvgFontDrawingArea(){
+ this->text = (gchar*) "A@!A!@A";
+ this->svgfont = NULL;
+ ((Gtk::Widget*) this)->set_size_request(150, 50);
+}
+
+void SvgFontDrawingArea::set_svgfont(SvgFont* svgfont){
+ this->svgfont = svgfont;
+}
+
+void SvgFontDrawingArea::set_text(gchar* text){
+ this->text = text;
+}
+
+void SvgFontDrawingArea::redraw(){
+ ((Gtk::Widget*) this)->queue_draw();
+}
+
+bool SvgFontDrawingArea::on_expose_event (GdkEventExpose *event){
+ if (this->svgfont){
+ Glib::RefPtr<Gdk::Window> window = get_window();
+ Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+ cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(this->svgfont->get_font_face(), false /* does not have reference */)) );
+ cr->set_font_size (20);
+ cr->move_to (20, 20);
+ cr->show_text (this->text);
+ }
+ return TRUE;
+}
+
namespace Inkscape {
namespace UI {
namespace Dialog {
Gtk::TreeModel::Row row = *_model->append();
SPFont* f = (SPFont*)l->data;
row[_columns.font] = f;
+ row[_columns.svgfont] = new SvgFont(f);
const gchar* lbl = f->label();
const gchar* id = SP_OBJECT_ID(f);
row[_columns.label] = lbl ? lbl : (id ? id : "font");
}
}
+void SvgFontsDialog::on_font_selection_changed(){
+ _font_da.set_svgfont(this->get_selected_svgfont());
+ _font_da.redraw();
+}
+
+SvgFont* SvgFontsDialog::get_selected_svgfont()
+{
+ Gtk::TreeModel::iterator i = _font_list.get_selection()->get_selected();
+ if(i)
+ return (*i)[_columns.svgfont];
+ return NULL;
+}
+
SvgFontsDialog::SvgFontsDialog()
: UI::Widget::Panel("", "dialogs.svgfonts", SP_VERB_DIALOG_SVG_FONTS)
{
_model = Gtk::ListStore::create(_columns);
_font_list.set_model(_model);
_font_list.append_column_editable("_Font", _columns.label);
+ _font_list.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_font_selection_changed));
+
this->update_fonts();
+ _getContents()->add((Gtk::Widget&) _font_da);
+ _getContents()->show_all();
+
//Settings for the selected SVGFont:
- _font_family.set_label("font-family");
- _font_variant.set_label("font-variant");
+// _font_family.set_label("font-family");
+// _font_variant.set_label("font-variant");
- _font_settings.add(_font_family);
- _font_settings.add(_font_variant);
+// _font_settings.add(_font_family);
+// _font_settings.add(_font_variant);
}
SvgFontsDialog::~SvgFontsDialog(){}
index 415aa8f7ed5621fdbb1383bbeff97a2116da8528..044ce5d44eae6d6337a9d6360dc0a8189448701f 100644 (file)
#include "desktop.h"
#include "desktop-handles.h"
+#include <gtkmm.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>
#include <gtkmm/entry.h>
#include <gtkmm/box.h>
+#include "display/nr-svgfonts.h"
+
+class SvgFontDrawingArea : Gtk::DrawingArea{
+public:
+ SvgFontDrawingArea();
+ void set_text(gchar*);
+ void set_svgfont(SvgFont*);
+ void redraw();
+private:
+ SvgFont* svgfont;
+ gchar* text;
+ bool on_expose_event (GdkEventExpose *event);
+};
+
struct SPFont;
namespace Inkscape {
{ return *new SvgFontsDialog(); }
void update_fonts();
-
+ SvgFont* get_selected_svgfont();
+ void on_font_selection_changed();
private:
class Columns : public Gtk::TreeModel::ColumnRecord
{
Columns()
{
add(font);
+ add(svgfont);
add(label);
- //add(sel);
}
Gtk::TreeModelColumn<SPFont*> font;
+ Gtk::TreeModelColumn<SvgFont*> svgfont;
Gtk::TreeModelColumn<Glib::ustring> label;
- //Gtk::TreeModelColumn<int> sel;
};
Glib::RefPtr<Gtk::ListStore> _model;
Columns _columns;
Gtk::TreeView _font_list;
Gtk::VBox _font_settings;
+ SvgFontDrawingArea _font_da;
class EntryWidget : public Gtk::HBox
{
public: