/*
* 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 <libnrtype/font-instance.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 {
_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 );
// Feature settings ---------------------
// Add tooltips
_feature_entry.set_tooltip_text( _("Feature settings in CSS form. No sanity checking is performed."));
// Add to frame
add( _feature_frame );
// Add signals
//_feature_entry.signal_key_press_event().connect ( sigc::mem_fun(*this, &FontVariants::feature_callback) );
}
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
// std::cout << "FontVariants::caps_init()" << std::endl;
}
void
// std::cout << "FontVariants::caps_callback()" << std::endl;
_caps_changed = true;
}
void
// std::cout << "FontVariants::numeric_init()" << std::endl;
}
void
// std::cout << "FontVariants::numeric_callback()" << std::endl;
_numeric_changed = true;
}
void
// std::cout << "FontVariants::feature_init()" << std::endl;
}
void
// std::cout << "FontVariants::feature_callback()" << std::endl;
_feature_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 );
if( different_features ) {
} else {
}
if( res ) {
} else {
_ligatures_common.set_sensitive( false );
}
} else {
_ligatures_discretionary.set_sensitive( false );
}
} else {
_ligatures_historical.set_sensitive( false );
}
} else {
_ligatures_contextual.set_sensitive( false );
}
} else {
_position_sub.set_sensitive( false );
}
} else {
_position_super.set_sensitive( false );
}
} else {
_caps_small.set_sensitive( false );
}
} else {
_caps_all_small.set_sensitive( false );
}
} else {
_caps_petite.set_sensitive( false );
}
} else {
_caps_all_petite.set_sensitive( false );
}
} else {
_caps_unicase.set_sensitive( false );
}
} else {
_caps_titling.set_sensitive( false );
}
} else {
_numeric_lining.set_sensitive( false );
}
} else {
_numeric_old_style.set_sensitive( false );
}
} else {
_numeric_proportional.set_sensitive( false );
}
} else {
_numeric_tabular.set_sensitive( false );
}
} else {
_numeric_diagonal.set_sensitive( false );
}
} else {
_numeric_stacked.set_sensitive( false );
}
} else {
_numeric_ordinal.set_sensitive( false );
}
} else {
_numeric_slashed_zero.set_sensitive( false );
}
// Make list of tables not handled above... eventually add Gtk::Label with
// this info.
// std::map<Glib::ustring,int> table_copy = res->openTypeTables;
// if( (it = table_copy.find("liga")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("clig")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("dlig")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("hlig")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("calt")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("subs")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("sups")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("smcp")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("c2sc")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("pcap")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("unic")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("titl")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("lnum")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("onum")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("pnum")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("tnum")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("frac")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("afrc")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("ordn")) != table_copy.end() ) table_copy.erase( it );
// if( (it = table_copy.find("zero")) != table_copy.end() ) table_copy.erase( it );
// for(it = table_copy.begin(); it != table_copy.end(); ++it) {
// std::cout << "Other: " << it->first << " Occurances: " << it->second << std::endl;
// }
} else {
}
_ligatures_changed = false;
_position_changed = false;
_caps_changed = false;
_numeric_changed = false;
_feature_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
{
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
{
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 ";
}
// Feature settings
}
}
} // 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 :