font-variants.cpp revision 61b32d9a7d286d60c7f59324eabad35d80fb2f04
/*
* Author:
* Tavmjong Bah <tavmjong@free.fr>
*
* Copyright (C) 2015 Tavmong Bah
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtkmm.h>
#include <iostream>
#include "font-variants.h"
// For updating from selection
#include "desktop.h"
#include "selection.h"
#include "style.h"
#include "sp-text.h"
#include "sp-tspan.h"
#include "sp-tref.h"
#include "sp-textpath.h"
#include "sp-item-group.h"
namespace Inkscape {
namespace UI {
namespace Widget {
FontVariants::FontVariants () :
_ligatures_changed( false ),
_position_changed( false ),
_caps_changed( false ),
_numeric_changed( false )
{
// Ligatures --------------------------
// Add tooltips
_("Common ligatures. On by default. OpenType tables: 'liga', 'clig'"));
_("Discretionary ligatures. Off by default. OpenType table: 'dlig'"));
_("Historical ligatures. Off by default. OpenType table: 'hlig'"));
_("Contextual forms. On by default. OpenType table: 'calt'"));
// Add signals
_ligatures_common.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
_ligatures_discretionary.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
_ligatures_historical.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
_ligatures_contextual.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
// Add to frame
add( _ligatures_frame );
// Position ----------------------------------
// Add tooltips
// Group buttons
// Add signals
_position_normal.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
_position_super.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
// Add to frame
add( _position_frame );
// Caps ----------------------------------
// Add tooltips
_caps_all_small.set_tooltip_text( _("All small-caps (uppercase and lowercase). OpenType tables: 'c2sc' and 'smcp'"));
_caps_all_petite.set_tooltip_text( _("All petite-caps (uppercase and lowercase). OpenType tables: 'c2sc' and 'pcap'"));
_caps_unicase.set_tooltip_text( _("Unicase (small caps for uppercase, normal for lowercase). OpenType table: 'unic'"));
_caps_titling.set_tooltip_text( _("Titling caps (lighter-weight uppercase for use in titles). OpenType table: 'titl'"));
// Group buttons
// Add signals
// Add to frame
add( _caps_frame );
caps_init();
// Numeric ------------------------------
// Add tooltips
// Group buttons
// Add signals
_numeric_default_style.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_old_style.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_default_width.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_proportional.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_tabular.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_default_fractions.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_diagonal.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_stacked.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_ordinal.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_slashed_zero.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
// Add to frame
add( _numeric_frame );
}
void
// std::cout << "FontVariants::ligatures_init()" << std::endl;
}
void
// std::cout << "FontVariants::ligatures_callback()" << std::endl;
_ligatures_changed = true;
}
void
// std::cout << "FontVariants::position_init()" << std::endl;
}
void
// std::cout << "FontVariants::position_callback()" << std::endl;
_position_changed = true;
}
void
FontVariants::caps_init() {
// std::cout << "FontVariants::caps_init()" << std::endl;
}
void
// std::cout << "FontVariants::caps_callback()" << std::endl;
_caps_changed = true;
}
void
FontVariants::numeric_init() {
// std::cout << "FontVariants::numeric_init()" << std::endl;
}
void
// std::cout << "FontVariants::numeric_callback()" << std::endl;
_numeric_changed = true;
}
// Update GUI based on query.
void
_ligatures_discretionary.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
_ligatures_historical.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
_ligatures_contextual.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
} else if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_OLDSTYLE_NUMS) {
} else {
}
} else if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_TABULAR_NUMS) {
} else {
}
} else if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_STACKED_FRACTIONS) {
} else {
}
_numeric_proportional.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_PROPORTIONAL_NUMS );
_numeric_diagonal.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_DIAGONAL_FRACTIONS );
_ligatures_changed = false;
_position_changed = false;
_caps_changed = false;
_numeric_changed = false;
}
void
// Ligatures
} else {
if ( !common )
css_string += "no-common-ligatures ";
if ( discretionary )
css_string += "discretionary-ligatures ";
if ( historical )
css_string += "historical-ligatures ";
if ( !contextual )
css_string += "no-contextual ";
}
// Position
{
unsigned position_new = SP_CSS_FONT_VARIANT_POSITION_NORMAL;
if( _position_normal.get_active() ) {
css_string = "normal";
} else if( _position_sub.get_active() ) {
css_string = "sub";
} else if( _position_super.get_active() ) {
css_string = "super";
}
// 'if' may not be necessary... need to test.
}
}
// Caps
{
unsigned caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
if( _caps_normal.get_active() ) {
css_string = "normal";
} else if( _caps_small.get_active() ) {
css_string = "small-caps";
} else if( _caps_all_small.get_active() ) {
css_string = "all-small-caps";
} else if( _caps_all_petite.get_active() ) {
css_string = "petite";
} else if( _caps_all_petite.get_active() ) {
css_string = "all-petite";
} else if( _caps_unicase.get_active() ) {
css_string = "unicase";
} else if( _caps_titling.get_active() ) {
css_string = "titling";
}
// May not be necessary... need to test.
//if( (_caps_all != caps_new) || ((_caps_mix != 0) && _caps_changed) ) {
//}
}
// Numeric
} else {
if ( lining )
css_string += "lining-nums ";
if ( old_style )
css_string += "oldstyle-nums ";
if ( proportional )
css_string += "proportional-nums ";
if ( tabular )
css_string += "tabular-nums ";
if ( diagonal )
css_string += "diagonal-fractions ";
if ( stacked )
css_string += "stacked-fractions ";
if ( ordinal )
css_string += "ordinal ";
if ( slashed_zero )
css_string += "slashed-zero ";
}
}
} // namespace Widget
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :