1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
|
/*
* Author:
* Tavmjong Bah <tavmjong@free.fr>
*
* Copyright (C) 2015, 2018 Tavmong Bah
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glibmm/i18n.h>
#include <gtkmm.h>
#include <libnrtype/font-instance.h>
#include "font-variants.h"
// For updating from selection
#include "desktop.h"
#include "object/sp-text.h"
namespace Inkscape {
namespace UI {
namespace Widget {
FontVariants::FontVariants () :
Gtk::VBox (),
_ligatures_frame ( Glib::ustring(C_("Font variant", "Ligatures" )) ),
_ligatures_common ( Glib::ustring(C_("Font variant", "Common" )) ),
_ligatures_discretionary ( Glib::ustring(C_("Font variant", "Discretionary")) ),
_ligatures_historical ( Glib::ustring(C_("Font variant", "Historical" )) ),
_ligatures_contextual ( Glib::ustring(C_("Font variant", "Contextual" )) ),
_position_frame ( Glib::ustring(C_("Font variant", "Position" )) ),
_position_normal ( Glib::ustring(C_("Font variant", "Normal" )) ),
_position_sub ( Glib::ustring(C_("Font variant", "Subscript" )) ),
_position_super ( Glib::ustring(C_("Font variant", "Superscript" )) ),
_caps_frame ( Glib::ustring(C_("Font variant", "Capitals" )) ),
_caps_normal ( Glib::ustring(C_("Font variant", "Normal" )) ),
_caps_small ( Glib::ustring(C_("Font variant", "Small" )) ),
_caps_all_small ( Glib::ustring(C_("Font variant", "All small" )) ),
_caps_petite ( Glib::ustring(C_("Font variant", "Petite" )) ),
_caps_all_petite ( Glib::ustring(C_("Font variant", "All petite" )) ),
_caps_unicase ( Glib::ustring(C_("Font variant", "Unicase" )) ),
_caps_titling ( Glib::ustring(C_("Font variant", "Titling" )) ),
_numeric_frame ( Glib::ustring(C_("Font variant", "Numeric" )) ),
_numeric_lining ( Glib::ustring(C_("Font variant", "Lining" )) ),
_numeric_old_style ( Glib::ustring(C_("Font variant", "Old Style" )) ),
_numeric_default_style ( Glib::ustring(C_("Font variant", "Default Style")) ),
_numeric_proportional ( Glib::ustring(C_("Font variant", "Proportional" )) ),
_numeric_tabular ( Glib::ustring(C_("Font variant", "Tabular" )) ),
_numeric_default_width ( Glib::ustring(C_("Font variant", "Default Width")) ),
_numeric_diagonal ( Glib::ustring(C_("Font variant", "Diagonal" )) ),
_numeric_stacked ( Glib::ustring(C_("Font variant", "Stacked" )) ),
_numeric_default_fractions( Glib::ustring(C_("Font variant", "Default Fractions")) ),
_numeric_ordinal ( Glib::ustring(C_("Font variant", "Ordinal" )) ),
_numeric_slashed_zero ( Glib::ustring(C_("Font variant", "Slashed Zero" )) ),
_feature_frame ( Glib::ustring(C_("Font variant", "Feature Settings")) ),
_feature_label ( Glib::ustring(C_("Font variant", "Selection has different Feature Settings!")) ),
_ligatures_changed( false ),
_position_changed( false ),
_caps_changed( false ),
_numeric_changed( false )
{
// Ligatures --------------------------
// Add tooltips
_ligatures_common.set_tooltip_text(
_("Common ligatures. On by default. OpenType tables: 'liga', 'clig'"));
_ligatures_discretionary.set_tooltip_text(
_("Discretionary ligatures. Off by default. OpenType table: 'dlig'"));
_ligatures_historical.set_tooltip_text(
_("Historical ligatures. Off by default. OpenType table: 'hlig'"));
_ligatures_contextual.set_tooltip_text(
_("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
_ligatures_grid.attach( _ligatures_common, 0, 0, 1, 1);
_ligatures_grid.attach( _ligatures_discretionary, 0, 1, 1, 1);
_ligatures_grid.attach( _ligatures_historical, 0, 2, 1, 1);
_ligatures_grid.attach( _ligatures_contextual, 0, 3, 1, 1);
_ligatures_grid.attach( _ligatures_label_common, 1, 0, 1, 1);
_ligatures_grid.attach( _ligatures_label_discretionary, 1, 1, 1, 1);
_ligatures_grid.attach( _ligatures_label_historical, 1, 2, 1, 1);
_ligatures_grid.attach( _ligatures_label_contextual, 1, 3, 1, 1);
_ligatures_frame.add( _ligatures_grid );
pack_start( _ligatures_frame, Gtk::PACK_SHRINK );
ligatures_init();
// Position ----------------------------------
// Add tooltips
_position_normal.set_tooltip_text( _("Normal position."));
_position_sub.set_tooltip_text( _("Subscript. OpenType table: 'subs'") );
_position_super.set_tooltip_text( _("Superscript. OpenType table: 'sups'") );
// Group buttons
Gtk::RadioButton::Group position_group = _position_normal.get_group();
_position_sub.set_group(position_group);
_position_super.set_group(position_group);
// Add signals
_position_normal.signal_button_press_event().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
_position_sub.signal_button_press_event().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
_position_super.signal_button_press_event().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
// Add to frame
_position_vbox.pack_start( _position_normal);
_position_vbox.pack_start( _position_sub );
_position_vbox.pack_start( _position_super );
_position_frame.add( _position_vbox );
pack_start( _position_frame, Gtk::PACK_SHRINK );
position_init();
// Caps ----------------------------------
// Add tooltips
_caps_normal.set_tooltip_text( _("Normal capitalization."));
_caps_small.set_tooltip_text( _("Small-caps (lowercase). OpenType table: 'smcp'"));
_caps_all_small.set_tooltip_text( _("All small-caps (uppercase and lowercase). OpenType tables: 'c2sc' and 'smcp'"));
_caps_petite.set_tooltip_text( _("Petite-caps (lowercase). OpenType table: 'pcap'"));
_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
Gtk::RadioButton::Group caps_group = _caps_normal.get_group();
_caps_small.set_group(caps_group);
_caps_all_small.set_group(caps_group);
_caps_petite.set_group(caps_group);
_caps_all_petite.set_group(caps_group);
_caps_unicase.set_group(caps_group);
_caps_titling.set_group(caps_group);
// Add signals
_caps_normal.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
_caps_small.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
_caps_all_small.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
_caps_petite.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
_caps_all_petite.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
_caps_unicase.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
_caps_titling.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
// Add to frame
_caps_vbox.pack_start( _caps_normal );
_caps_vbox.pack_start( _caps_small );
_caps_vbox.pack_start( _caps_all_small );
_caps_vbox.pack_start( _caps_petite );
_caps_vbox.pack_start( _caps_all_petite);
_caps_vbox.pack_start( _caps_unicase );
_caps_vbox.pack_start( _caps_titling );
_caps_frame.add( _caps_vbox );
pack_start( _caps_frame, Gtk::PACK_SHRINK );
caps_init();
// Numeric ------------------------------
// Add tooltips
_numeric_default_style.set_tooltip_text( _("Normal style."));
_numeric_lining.set_tooltip_text( _("Lining numerals. OpenType table: 'lnum'"));
_numeric_old_style.set_tooltip_text( _("Old style numerals. OpenType table: 'onum'"));
_numeric_default_width.set_tooltip_text( _("Normal widths."));
_numeric_proportional.set_tooltip_text( _("Proportional width numerals. OpenType table: 'pnum'"));
_numeric_tabular.set_tooltip_text( _("Same width numerals. OpenType table: 'tnum'"));
_numeric_default_fractions.set_tooltip_text( _("Normal fractions."));
_numeric_diagonal.set_tooltip_text( _("Diagonal fractions. OpenType table: 'frac'"));
_numeric_stacked.set_tooltip_text( _("Stacked fractions. OpenType table: 'afrc'"));
_numeric_ordinal.set_tooltip_text( _("Ordinals (raised 'th', etc.). OpenType table: 'ordn'"));
_numeric_slashed_zero.set_tooltip_text( _("Slashed zeros. OpenType table: 'zero'"));
// Group buttons
Gtk::RadioButton::Group style_group = _numeric_default_style.get_group();
_numeric_lining.set_group(style_group);
_numeric_old_style.set_group(style_group);
Gtk::RadioButton::Group width_group = _numeric_default_width.get_group();
_numeric_proportional.set_group(width_group);
_numeric_tabular.set_group(width_group);
Gtk::RadioButton::Group fraction_group = _numeric_default_fractions.get_group();
_numeric_diagonal.set_group(fraction_group);
_numeric_stacked.set_group(fraction_group);
// Add signals
_numeric_default_style.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::numeric_callback) );
_numeric_lining.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
_numeric_stylebox.pack_start( _numeric_default_style );
_numeric_stylebox.pack_start( _numeric_lining );
_numeric_stylebox.pack_start( _numeric_old_style );
_numeric_vbox.pack_start( _numeric_stylebox );
_numeric_widthbox.pack_start( _numeric_default_width );
_numeric_widthbox.pack_start( _numeric_proportional );
_numeric_widthbox.pack_start( _numeric_tabular );
_numeric_vbox.pack_start( _numeric_widthbox );
_numeric_fractionbox.pack_start( _numeric_default_fractions );
_numeric_fractionbox.pack_start( _numeric_diagonal );
_numeric_fractionbox.pack_start( _numeric_stacked );
_numeric_vbox.pack_start( _numeric_fractionbox );
_numeric_vbox.pack_start( _numeric_ordinal );
_numeric_vbox.pack_start( _numeric_slashed_zero );
_numeric_frame.add( _numeric_vbox );
pack_start( _numeric_frame, Gtk::PACK_SHRINK );
// Feature settings ---------------------
// Add tooltips
_feature_entry.set_tooltip_text( _("Feature settings in CSS form. No sanity checking is performed."));
_feature_list.set_justify( Gtk::JUSTIFY_LEFT );
_feature_list.set_line_wrap( true );
_feature_substitutions.set_justify( Gtk::JUSTIFY_LEFT );
_feature_substitutions.set_line_wrap( true );
// Add to frame
_feature_vbox.pack_start( _feature_entry );
_feature_vbox.pack_start( _feature_label );
_feature_vbox.pack_start( _feature_list );
_feature_vbox.pack_start( _feature_substitutions );
_feature_frame.add( _feature_vbox );
pack_start( _feature_frame, Gtk::PACK_SHRINK );
// Add signals
//_feature_entry.signal_key_press_event().connect ( sigc::mem_fun(*this, &FontVariants::feature_callback) );
_feature_entry.signal_changed().connect( sigc::mem_fun(*this, &FontVariants::feature_callback) );
show_all_children();
}
void
FontVariants::ligatures_init() {
// std::cout << "FontVariants::ligatures_init()" << std::endl;
}
void
FontVariants::ligatures_callback() {
// std::cout << "FontVariants::ligatures_callback()" << std::endl;
_ligatures_changed = true;
_changed_signal.emit();
}
void
FontVariants::position_init() {
// std::cout << "FontVariants::position_init()" << std::endl;
}
bool
FontVariants::position_callback(GdkEventButton * /*event*/) {
// std::cout << "FontVariants::position_callback()" << std::endl;
_position_changed = true;
_changed_signal.emit();
}
void
FontVariants::caps_init() {
// std::cout << "FontVariants::caps_init()" << std::endl;
}
void
FontVariants::caps_callback() {
// std::cout << "FontVariants::caps_callback()" << std::endl;
_caps_changed = true;
_changed_signal.emit();
}
void
FontVariants::numeric_init() {
// std::cout << "FontVariants::numeric_init()" << std::endl;
}
void
FontVariants::numeric_callback() {
// std::cout << "FontVariants::numeric_callback()" << std::endl;
_numeric_changed = true;
_changed_signal.emit();
}
void
FontVariants::feature_init() {
// std::cout << "FontVariants::feature_init()" << std::endl;
}
void
FontVariants::feature_callback() {
// std::cout << "FontVariants::feature_callback()" << std::endl;
_feature_changed = true;
_changed_signal.emit();
}
// Update GUI based on query.
void
FontVariants::update( SPStyle const *query, bool different_features, Glib::ustring& font_spec ) {
_ligatures_all = query->font_variant_ligatures.computed;
_ligatures_mix = query->font_variant_ligatures.value;
_ligatures_common.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
_ligatures_discretionary.set_active(_ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
_ligatures_historical.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
_ligatures_contextual.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
_ligatures_common.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
_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 );
_position_all = query->font_variant_position.computed;
_position_mix = query->font_variant_position.value;
_position_normal.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_NORMAL );
_position_sub.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_SUB );
_position_super.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_SUPER );
_position_normal.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_NORMAL );
_position_sub.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_SUB );
_position_super.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_SUPER );
_caps_all = query->font_variant_caps.computed;
_caps_mix = query->font_variant_caps.value;
_caps_normal.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_NORMAL );
_caps_small.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_SMALL );
_caps_all_small.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL );
_caps_petite.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_PETITE );
_caps_all_petite.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE );
_caps_unicase.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_UNICASE );
_caps_titling.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_TITLING );
_caps_normal.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_NORMAL );
_caps_small.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_SMALL );
_caps_all_small.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL );
_caps_petite.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_PETITE );
_caps_all_petite.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE );
_caps_unicase.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_UNICASE );
_caps_titling.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_TITLING );
_numeric_all = query->font_variant_numeric.computed;
_numeric_mix = query->font_variant_numeric.value;
if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_LINING_NUMS) {
_numeric_lining.set_active();
} else if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_OLDSTYLE_NUMS) {
_numeric_old_style.set_active();
} else {
_numeric_default_style.set_active();
}
if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_PROPORTIONAL_NUMS) {
_numeric_proportional.set_active();
} else if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_TABULAR_NUMS) {
_numeric_tabular.set_active();
} else {
_numeric_default_width.set_active();
}
if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_DIAGONAL_FRACTIONS) {
_numeric_diagonal.set_active();
} else if (_numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_STACKED_FRACTIONS) {
_numeric_stacked.set_active();
} else {
_numeric_default_fractions.set_active();
}
_numeric_ordinal.set_active( _numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_ORDINAL );
_numeric_slashed_zero.set_active( _numeric_all & SP_CSS_FONT_VARIANT_NUMERIC_SLASHED_ZERO );
_numeric_lining.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_LINING_NUMS );
_numeric_old_style.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_OLDSTYLE_NUMS );
_numeric_proportional.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_PROPORTIONAL_NUMS );
_numeric_tabular.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_TABULAR_NUMS );
_numeric_diagonal.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_DIAGONAL_FRACTIONS );
_numeric_stacked.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_STACKED_FRACTIONS );
_numeric_ordinal.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_ORDINAL );
_numeric_slashed_zero.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_SLASHED_ZERO );
if( query->font_feature_settings.value )
_feature_entry.set_text( query->font_feature_settings.value );
if( different_features ) {
_feature_label.show();
} else {
_feature_label.hide();
}
// Disable/Enable based on available OpenType tables.
font_instance* res = font_factory::Default()->FaceFromFontSpecification( font_spec.c_str() );
if( res ) {
std::map<Glib::ustring,int>::iterator it;
if((it = res->openTypeTables.find("liga"))!= res->openTypeTables.end() ||
(it = res->openTypeTables.find("clig"))!= res->openTypeTables.end()) {
_ligatures_common.set_sensitive();
} else {
_ligatures_common.set_sensitive( false );
}
if((it = res->openTypeTables.find("dlig"))!= res->openTypeTables.end()) {
_ligatures_discretionary.set_sensitive();
} else {
_ligatures_discretionary.set_sensitive( false );
}
if((it = res->openTypeTables.find("hlig"))!= res->openTypeTables.end()) {
_ligatures_historical.set_sensitive();
} else {
_ligatures_historical.set_sensitive( false );
}
if((it = res->openTypeTables.find("calt"))!= res->openTypeTables.end()) {
_ligatures_contextual.set_sensitive();
} else {
_ligatures_contextual.set_sensitive( false );
}
if((it = res->openTypeTables.find("subs"))!= res->openTypeTables.end()) {
_position_sub.set_sensitive();
} else {
_position_sub.set_sensitive( false );
}
if((it = res->openTypeTables.find("sups"))!= res->openTypeTables.end()) {
_position_super.set_sensitive();
} else {
_position_super.set_sensitive( false );
}
if((it = res->openTypeTables.find("smcp"))!= res->openTypeTables.end()) {
_caps_small.set_sensitive();
} else {
_caps_small.set_sensitive( false );
}
if((it = res->openTypeTables.find("c2sc"))!= res->openTypeTables.end() &&
(it = res->openTypeTables.find("smcp"))!= res->openTypeTables.end()) {
_caps_all_small.set_sensitive();
} else {
_caps_all_small.set_sensitive( false );
}
if((it = res->openTypeTables.find("pcap"))!= res->openTypeTables.end()) {
_caps_petite.set_sensitive();
} else {
_caps_petite.set_sensitive( false );
}
if((it = res->openTypeTables.find("c2sc"))!= res->openTypeTables.end() &&
(it = res->openTypeTables.find("pcap"))!= res->openTypeTables.end()) {
_caps_all_petite.set_sensitive();
} else {
_caps_all_petite.set_sensitive( false );
}
if((it = res->openTypeTables.find("unic"))!= res->openTypeTables.end()) {
_caps_unicase.set_sensitive();
} else {
_caps_unicase.set_sensitive( false );
}
if((it = res->openTypeTables.find("titl"))!= res->openTypeTables.end()) {
_caps_titling.set_sensitive();
} else {
_caps_titling.set_sensitive( false );
}
if((it = res->openTypeTables.find("lnum"))!= res->openTypeTables.end()) {
_numeric_lining.set_sensitive();
} else {
_numeric_lining.set_sensitive( false );
}
if((it = res->openTypeTables.find("onum"))!= res->openTypeTables.end()) {
_numeric_old_style.set_sensitive();
} else {
_numeric_old_style.set_sensitive( false );
}
if((it = res->openTypeTables.find("pnum"))!= res->openTypeTables.end()) {
_numeric_proportional.set_sensitive();
} else {
_numeric_proportional.set_sensitive( false );
}
if((it = res->openTypeTables.find("tnum"))!= res->openTypeTables.end()) {
_numeric_tabular.set_sensitive();
} else {
_numeric_tabular.set_sensitive( false );
}
if((it = res->openTypeTables.find("frac"))!= res->openTypeTables.end()) {
_numeric_diagonal.set_sensitive();
} else {
_numeric_diagonal.set_sensitive( false );
}
if((it = res->openTypeTables.find("afrac"))!= res->openTypeTables.end()) {
_numeric_stacked.set_sensitive();
} else {
_numeric_stacked.set_sensitive( false );
}
if((it = res->openTypeTables.find("ordn"))!= res->openTypeTables.end()) {
_numeric_ordinal.set_sensitive();
} else {
_numeric_ordinal.set_sensitive( false );
}
if((it = res->openTypeTables.find("zero"))!= res->openTypeTables.end()) {
_numeric_slashed_zero.set_sensitive();
} else {
_numeric_slashed_zero.set_sensitive( false );
}
// List available ligatures
Glib::ustring markup_liga;
Glib::ustring markup_dlig;
Glib::ustring markup_hlig;
Glib::ustring markup_calt;
for (auto table: res->openTypeLigatures) {
Glib::ustring markup;
markup += "<span font_family='";
markup += sp_font_description_get_family(res->descr);
markup += "'>";
markup += Glib::Markup::escape_text(table.second);
markup += "</span>";
if (table.first == "liga") markup_liga += markup;
if (table.first == "clig") markup_liga += markup;
if (table.first == "dlig") markup_dlig += markup;
if (table.first == "hlig") markup_hlig += markup;
if (table.first == "calt") markup_calt += markup;
}
_ligatures_label_common.set_markup ( markup_liga.c_str() );
_ligatures_label_discretionary.set_markup ( markup_dlig.c_str() );
_ligatures_label_historical.set_markup ( markup_hlig.c_str() );
_ligatures_label_contextual.set_markup ( markup_calt.c_str() );
// 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 );
std::string ott_list = "OpenType tables not included above: ";
for(it = table_copy.begin(); it != table_copy.end(); ++it) {
// std::cout << "Other: " << it->first << " Occurrences: " << it->second << std::endl;
ott_list += it->first;
ott_list += ", ";
}
_feature_list.set_text( ott_list.c_str() );
// "<span foreground='darkblue'>";
Glib::ustring markup;
for (auto table: res->openTypeStylistic) {
markup += table.first;
markup += ": ";
markup += "<span font_family='";
markup += sp_font_description_get_family(res->descr);
markup += "'>";
markup += Glib::Markup::escape_text(table.second);
markup += "</span>";
markup += " → ";
markup += "<span font_family='";
markup += sp_font_description_get_family(res->descr);
markup += "'>";
markup += "<span font_features='";
markup += table.first;
markup += "'>";
markup += Glib::Markup::escape_text(table.second);
markup += "</span>";
markup += "</span>\n";
}
_feature_substitutions.set_markup ( markup.c_str() );
} else {
std::cerr << "FontVariants::update(): Couldn't find font_instance for: "
<< font_spec << std::endl;
}
_ligatures_changed = false;
_position_changed = false;
_caps_changed = false;
_numeric_changed = false;
_feature_changed = false;
}
void
FontVariants::fill_css( SPCSSAttr *css ) {
// Ligatures
bool common = _ligatures_common.get_active();
bool discretionary = _ligatures_discretionary.get_active();
bool historical = _ligatures_historical.get_active();
bool contextual = _ligatures_contextual.get_active();
if( !common && !discretionary && !historical && !contextual ) {
sp_repr_css_set_property(css, "font-variant-ligatures", "none" );
} else if ( common && !discretionary && !historical && contextual ) {
sp_repr_css_set_property(css, "font-variant-ligatures", "normal" );
} else {
Glib::ustring css_string;
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 ";
sp_repr_css_set_property(css, "font-variant-ligatures", css_string.c_str() );
}
// Position
{
unsigned position_new = SP_CSS_FONT_VARIANT_POSITION_NORMAL;
Glib::ustring css_string;
if( _position_normal.get_active() ) {
css_string = "normal";
} else if( _position_sub.get_active() ) {
css_string = "sub";
position_new = SP_CSS_FONT_VARIANT_POSITION_SUB;
} else if( _position_super.get_active() ) {
css_string = "super";
position_new = SP_CSS_FONT_VARIANT_POSITION_SUPER;
}
// 'if' may not be necessary... need to test.
if( (_position_all != position_new) || ((_position_mix != 0) && _position_changed) ) {
sp_repr_css_set_property(css, "font-variant-position", css_string.c_str() );
}
}
// Caps
{
//unsigned caps_new;
Glib::ustring css_string;
if( _caps_normal.get_active() ) {
css_string = "normal";
// caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
} else if( _caps_small.get_active() ) {
css_string = "small-caps";
// caps_new = SP_CSS_FONT_VARIANT_CAPS_SMALL;
} else if( _caps_all_small.get_active() ) {
css_string = "all-small-caps";
// caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL;
} else if( _caps_petite.get_active() ) {
css_string = "petite";
// caps_new = SP_CSS_FONT_VARIANT_CAPS_PETITE;
} else if( _caps_all_petite.get_active() ) {
css_string = "all-petite";
// caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE;
} else if( _caps_unicase.get_active() ) {
css_string = "unicase";
// caps_new = SP_CSS_FONT_VARIANT_CAPS_UNICASE;
} else if( _caps_titling.get_active() ) {
css_string = "titling";
// caps_new = SP_CSS_FONT_VARIANT_CAPS_TITLING;
//} else {
// caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
}
// May not be necessary... need to test.
//if( (_caps_all != caps_new) || ((_caps_mix != 0) && _caps_changed) ) {
sp_repr_css_set_property(css, "font-variant-caps", css_string.c_str() );
//}
}
// Numeric
bool default_style = _numeric_default_style.get_active();
bool lining = _numeric_lining.get_active();
bool old_style = _numeric_old_style.get_active();
bool default_width = _numeric_default_width.get_active();
bool proportional = _numeric_proportional.get_active();
bool tabular = _numeric_tabular.get_active();
bool default_fractions = _numeric_default_fractions.get_active();
bool diagonal = _numeric_diagonal.get_active();
bool stacked = _numeric_stacked.get_active();
bool ordinal = _numeric_ordinal.get_active();
bool slashed_zero = _numeric_slashed_zero.get_active();
if (default_style & default_width & default_fractions & !ordinal & !slashed_zero) {
sp_repr_css_set_property(css, "font-variant-numeric", "normal");
} else {
Glib::ustring css_string;
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 ";
sp_repr_css_set_property(css, "font-variant-numeric", css_string.c_str() );
}
// Feature settings
Glib::ustring feature_string = _feature_entry.get_text();
if( !feature_string.empty() || feature_string.compare( "normal" ) ) {
sp_repr_css_set_property(css, "font-feature-settings", feature_string.c_str());
}
}
} // 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 :
|