/**
* @file
* SVG Fonts dialog - implementation.
*/
/* Authors:
* Felipe C. da S. Sanches <juca@members.fsf.org>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2008 Authors
* Released under GNU GPLv2 (or later). Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "svg-fonts-dialog.h"
#include "document-private.h"
#include "document-undo.h"
#include <gtkmm/notebook.h>
#include <gtkmm/imagemenuitem.h>
#include <message-stack.h>
#include "selection.h"
#include <string.h>
#include "sp-font-face.h"
#include "desktop.h"
#include "display/nr-svgfonts.h"
#include "verbs.h"
#include "sp-glyph.h"
#include "sp-missing-glyph.h"
#include "sp-font.h"
#include "sp-glyph-kerning.h"
#include <glibmm/stringutils.h>
_x(0),
_y(0),
_svgfont(0),
_text()
{
}
}
redraw();
}
_x = x;
_y = y;
}
}
if (_svgfont){
cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(_svgfont->get_font_face(), false /* does not have reference */)) );
}
return TRUE;
}
namespace Inkscape {
namespace UI {
namespace Dialog {
/*
Gtk::HBox* SvgFontsDialog::AttrEntry(gchar* lbl, const SPAttributeEnum attr){
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
Gtk::Entry* entry = Gtk::manage(new Gtk::Entry());
hbox->add(* entry );
hbox->show_all();
entry->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_attr_changed));
return hbox;
}
*/
this->dialog = d;
this->show_all();
}
if (!t) return;
}
switch(this->attr){
case SP_PROP_FONT_FAMILY:
if (SP_IS_FONTFACE(node)){
o = node;
continue;
}
break;
default:
o = NULL;
}
}
if(name && o) {
_("Set SVG Font attribute"));
}
}
return hbox;
}
/*
Gtk::HBox* SvgFontsDialog::AttrSpin(gchar* lbl){
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
hbox->add(* Gtk::manage(new Inkscape::UI::Widget::SpinBox()) );
hbox->show_all();
return hbox;
}*/
/*** SvgFontsDialog ***/
}
if (!spfont) return
//TODO: figure out why do we need to append("") before clearing items properly...
this->remove_all();
if (SP_IS_GLYPH(node)){
}
}
}
if (!get_selected_kerning_pair()) {
return;
}
//TODO: I am unsure whether this is the correct way of calling SPDocumentUndo::maybe_done
undokey += ":";
//slider values increase from right to left so that they match the kerning pair preview
//XML Tree being directly used here while it shouldn't be.
this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider->get_value()).c_str());
DocumentUndo::maybeDone(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value"));
//populate_kerning_pairs_box();
}
{
}
}
{
}
}
{
}
}
{
}
{
}
{
}
if (get_selected_spfont()){
global_vbox.set_sensitive(true);
glyphs_vbox.set_sensitive(true);
kerning_vbox.set_sensitive(true);
} else {
global_vbox.set_sensitive(false);
glyphs_vbox.set_sensitive(false);
kerning_vbox.set_sensitive(false);
}
}
/* Add all fonts in the document to the combobox. */
{
}
}
}
if (!kern) {
return;
}
this->kerning_pair = kern;
//slider values increase from right to left so that they match the kerning pair preview
}
if (!font) return;
if (SP_IS_FONTFACE(obj)){
}
}
}
if (!spfont) return;
kerning_slider->set_draw_value(false);
kerning_slider->set_value(0);
}
if (spfont){
//TODO: tell cairo that the glyphs cache has to be invalidated
// The current solution is to recreate the whole cairo svgfont.
// This is not a good solution to the issue because big fonts will result in poor performance.
}
}
{
if(i)
return (*i)[_KerningPairsListColumns.spnode];
return NULL;
}
{
if(i)
return NULL;
}
{
if(i)
return NULL;
}
{
if(i)
return (*i)[_GlyphsListColumns.glyph_node];
return NULL;
}
/* global_vbox->add(*AttrCombo((gchar*) _("Style:"), SP_PROP_FONT_STYLE));
global_vbox->add(*AttrCombo((gchar*) _("Variant:"), SP_PROP_FONT_VARIANT));
global_vbox->add(*AttrCombo((gchar*) _("Weight:"), SP_PROP_FONT_WEIGHT));
*/
//Set Width (horiz_adv_x):
return &global_vbox;
}
void
{
if (!_GlyphsListStore) return;
if (SP_IS_GLYPH(node)){
}
}
}
void
{
if (!_KerningPairsListStore) return;
if (SP_IS_HKERN(node)){
row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(node))->u1->attribute_string().c_str();
row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(node))->u2->attribute_string().c_str();
}
}
}
{
// create a new glyph
// Append the new glyph node to the current font
// get corresponding object
g_assert(SP_IS_GLYPH(g));
return g;
}
if (!font) return;
get_selected_svgfont()->refresh();
}
}
if (SP_IS_FONTFACE(obj)){
//XML Tree being directly used here while it shouldn't be.
}
}
//This matrix flips y-axis and places the origin at baseline
Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(baseline_offset));
return pathv*m;
}
if (!desktop) {
g_warning("SvgFontsDialog: No active desktop");
return;
}
return;
}
if (!node) return;//TODO: should this be an assert?
return;
} //TODO: //Is there a better way to tell it to to the user?
if (!glyph){
return;
}
//XML Tree being directly used here while it shouldn't be.
}
if (!desktop) {
g_warning("SvgFontsDialog: No active desktop");
return;
}
return;
}
if (!node) return;//TODO: should this be an assert?
return;
} //TODO: //Is there a better way to tell it to to the user?
if (SP_IS_MISSING_GLYPH(obj)){
//XML Tree being directly used here while it shouldn't be.
}
}
}
if (!desktop) {
g_warning("SvgFontsDialog: No active desktop");
return;
}
if (SP_IS_MISSING_GLYPH(obj)){
//XML Tree being directly used here while it shouldn't be.
}
}
}
if (!i) return;
//XML Tree being directly used here while it shouldn't be.
}
if (!i) return;
//XML Tree being directly used here while it shouldn't be.
}
if (!font) return;
//XML Tree being directly used here while it shouldn't be.
update_fonts();
}
if(!_GlyphsList.get_selection()) return;
if(!i) return;
//XML Tree being directly used here while it shouldn't be.
}
if(!_KerningPairsList.get_selection()) return;
if(!i) return;
//XML Tree being directly used here while it shouldn't be.
}
_GlyphsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::glyphs_list_button_release));
create_glyphs_popup_menu(_GlyphsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_glyph));
missing_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::missing_glyph_description_from_selected_path));
missing_glyph_reset_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::reset_missing_glyph_description));
_GlyphsListScroller.set_size_request(-1, 290);//It seems that is does not work. Why? I want a box with larger height
glyph_from_path_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::set_glyph_description_from_selected_path));
dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(0))->signal_edited().connect(
dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(1))->signal_edited().connect(
return &glyphs_vbox;
}
//look for this kerning pair on the currently selected font
this->kerning_pair = NULL;
//TODO: It is not really correct to get only the first byte of each string.
//TODO: We should also support vertical kerning
if (SP_IS_HKERN(node) && (static_cast<SPGlyphKerning*>(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
&& (static_cast<SPGlyphKerning*>(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
continue;
}
}
if (this->kerning_pair) return; //We already have this kerning pair
// create a new hkern node
// Append the new hkern node to the current font
// get corresponding object
}
_KerningPairsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::kerning_pairs_list_button_release));
create_kerning_pairs_popup_menu(_KerningPairsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_kerning_pair));
//Kerning Setup:
add_kernpair_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_kerning_pair));
_KerningPairsList.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_pair_selection_changed));
kerning_slider->signal_value_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_value_changed));
// _KerningPairsList.append_column_numeric_editable(_("Kerning Value"), _KerningPairsListColumns.kerning_value, "%f");
return &kerning_vbox;
}
{
// create a new font
//By default, set the horizontal advance to 1024 units
// Append the new font node to defs
//create a missing glyph
//create a missing glyph
// get corresponding object
g_assert(SP_IS_FONT(f));
return f;
}
if (!font) return;
if (SP_IS_FONTFACE(obj)){
//XML Tree being directly used here while it shouldn't be.
}
}
}
if (SP_IS_FONTFACE(obj)){
//XML Tree being directly used here while it shouldn't be.
}
}
update_fonts();
// select_font(font);
}
{
#if WITH_GTKMM_3_0
#else
#endif
//List of SVGFonts declared in a document:
_FontsList.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_font_selection_changed));
this->update_fonts();
tabs->set_scrollable();
//Text Preview:
_preview_entry.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_preview_text_changed));
_FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release));
_getContents()->show_all();
}
SvgFontsDialog::~SvgFontsDialog(){}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :