text-toolbar.cpp revision b5d9052a69ae76da70d3d4783ee661fa5be5e8db
#ifdef HAVE_CONFIG_H
# include "config.h"
#include "ui/widget/spinbutton.h"
#include "toolbox.h"
#include "text-toolbar.h"
#include "../desktop.h"
#include "../desktop-handles.h"
#include "../desktop-style.h"
#include "document-undo.h"
#include "../verbs.h"
#include "../inkscape.h"
#include "../connection-pool.h"
#include "../selection-chemistry.h"
#include "../selection.h"
#include "../ege-adjustment-action.h"
#include "../ege-output-action.h"
#include "../ege-select-one-action.h"
#include "../ink-action.h"
#include "../ink-comboboxentry-action.h"
#include "../widgets/spinbutton-events.h"
#include "../widgets/spw-utilities.h"
#include "../widgets/widget-sizes.h"
#include "../xml/node-event-vector.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
#include "../helper/unit-menu.h"
#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-namedview.h"
#include "../svg/css-ostringstream.h"
#include "../sp-flowtext.h"
#include "../sp-text.h"
#include "../style.h"
#include "../libnrtype/font-lister.h"
#include "../libnrtype/font-instance.h"
#include "../text-context.h"
#include "../text-editing.h"
#include "widgets/font-selector.h"
#ifdef DEBUG_TEXT
if (show_sample) {
Ink_ComboBoxEntry_Action* act = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) );
if (!current_font) {
while ( valid ) {
found = true;
Ink_ComboBoxEntry_Action* fontStyleAction = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontStyleAction" ) );
if (found) {
if (font) {
} else if (current_style) {
#ifdef DEBUG_TEXT
#ifdef DEBUG_TEXT
int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
#ifdef DEBUG_TEXT
if( fontFromStyle ) {
#ifdef DEBUG_TEXT
if ( fontFromStyle ) {
#ifdef DEBUG_TEXT
if (!fontSpec.empty()) newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family);
#ifdef DEBUG_TEXT
std::cout << " New FontSpec from ReplaceFontSpecificationFamily :" << newFontSpec << ":" << std::endl;
if (font) {
#ifdef DEBUG_TEXT
#ifdef DEBUG_TEXT
int max_size = prefs->getInt("/dialogs/textandfont/maxFontSize", 10000); // somewhat arbitrary, but text&font preview freezes with too huge fontsizes
int result_numbers =
int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
if ( fontFromStyle ) {
Ink_ComboBoxEntry_Action* act = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) );
font_instance *font = (font_factory::Default())->FaceFromUIStrings (fontFamily.c_str(), current_style.c_str());
if (font) {
#ifdef DEBUG_TEXT
int result_baseline = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_BASELINES);
bool setSuper = false;
bool setSub = false;
if( prop == 0 ) {
setSuper = true;
setSub = true;
// in style.cpp.
if( setSuper ) {
} else if( setSub ) {
if (!bbox)
double left_slack = 0;
double right_slack = 0;
double move = 0;
switch (mode) {
switch (mode) {
switch (mode) {
switch (mode)
int result_numbers =
bool modmade = false;
SP_OBJECT(items->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
modmade = true;
if(modmade) {
int result_numbers =
int result_numbers =
int result_numbers =
bool modmade = false;
if( tc ) {
text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
if( attributes ) {
modmade = true;
if(modmade) {
bool modmade = false;
if( tc ) {
text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
if( attributes ) {
modmade = true;
if(modmade) {
bool modmade = false;
if( tc ) {
text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
if( attributes ) {
sp_te_adjust_rotation( tc->text, tc->text_sel_start, tc->text_sel_end, SP_ACTIVE_DESKTOP, delta_deg );
modmade = true;
if(modmade) {
switch (mode)
int result_numbers =
int sizes[] = {
// Array must be same length as SPCSSUnit in style.h
#ifdef DEBUG_TEXT
static int count = 0;
++count;
#ifdef DEBUG_TEXT
isFlow = true;
int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
int result_baseline = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_BASELINES);
if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) {
#ifdef DEBUG_TEXT
#ifdef DEBUG_TEXT
Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
InkToggleAction* textSuperscriptAction = INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextSuperscriptAction" ) );
InkToggleAction* textSubscriptAction = INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextSubscriptAction" ) );
EgeSelectOneAction* textAlignAction = EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextAlignAction" ) );
int activeButton = 0;
double height;
double wordSpacing;
double letterSpacing;
else letterSpacing = query->letter_spacing.computed; // Assume no units (change in desktop-style.cpp)
#ifdef DEBUG_TEXT
if( tc ) {
text_tag_attributes_at_position( tc->text, std::min(tc->text_sel_start, tc->text_sel_end), &char_index );
if( attributes ) {
#ifdef DEBUG_TEXT
#ifdef DEBUG_TEXT
static void sp_text_toolbox_selection_modified(Inkscape::Selection *selection, guint /*flags*/, GObject *tbl)
NULL,
Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
NULL,
NULL,
GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_mode_changed), holder );
gchar const* labels[] = {_("Smaller spacing"), 0, 0, 0, 0, C_("Text tool", "Normal"), 0, 0, 0, 0, 0, _("Larger spacing")};
gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, C_("Text tool", "Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")};
gchar const* labels[] = {_("Negative spacing"), 0, 0, 0, C_("Text tool", "Normal"), 0, 0, 0, 0, 0, 0, 0, _("Positive spacing")};
Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISTextToolboxGTK");