diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-06-19 09:28:09 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-06-19 09:32:10 -0400 |
commit | 010a120351e410ba5cd53eb439dc4a211630e965 (patch) | |
tree | 90b66396013e0040df32b495dd2d2b59d5b817ee /demos | |
parent | a4dcc6bc5254d95823c2e7773ea75a17ee7dd81c (diff) | |
download | gtk+-010a120351e410ba5cd53eb439dc4a211630e965.tar.gz |
Add a font features demo
This started life as a standalone tool, but it is nicer
to have it integrated in gtk3-demo.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/gtk-demo/Makefile.am | 1 | ||||
-rw-r--r-- | demos/gtk-demo/demo.gresource.xml | 3 | ||||
-rw-r--r-- | demos/gtk-demo/font-features.ui | 1346 | ||||
-rw-r--r-- | demos/gtk-demo/font_features.c | 202 |
4 files changed, 1552 insertions, 0 deletions
diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am index 43cba929f2..6fcfa3100e 100644 --- a/demos/gtk-demo/Makefile.am +++ b/demos/gtk-demo/Makefile.am @@ -25,6 +25,7 @@ demos = \ entry_completion.c \ event_axes.c \ expander.c \ + font_features.c \ gestures.c \ glarea.c \ headerbar.c \ diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml index c364e42487..f05d86c94a 100644 --- a/demos/gtk-demo/demo.gresource.xml +++ b/demos/gtk-demo/demo.gresource.xml @@ -183,4 +183,7 @@ <file>glarea-fragment.glsl</file> <file>glarea-vertex.glsl</file> </gresource> + <gresource prefix="/font-features"> + <file>font-features.ui</file> + </gresource> </gresources> diff --git a/demos/gtk-demo/font-features.ui b/demos/gtk-demo/font-features.ui new file mode 100644 index 0000000000..b378a10005 --- /dev/null +++ b/demos/gtk-demo/font-features.ui @@ -0,0 +1,1346 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.1 --> +<interface> + <requires lib="gtk+" version="3.12"/> + <object class="GtkWindow" id="window"> + <property name="can_focus">False</property> + <property name="default-width">600</property> + <property name="default-height">500</property> + <child type="titlebar"> + <object class="GtkHeaderBar"> + <property name="visible">True</property> + <property name="show_close_button">True</property> + <property name="title">Font Features</property> + <child> + <object class="GtkButton" id="reset"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="tooltip-text">Reset</property> + <signal name="clicked" handler="reset" swapped="no"/> + <child> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">view-refresh-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="pack-type">start</property> + </packing> + </child> + </object> + </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">never</property> + <child> + <object class="GtkViewport" id="viewport1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">10</property> + <property name="margin_right">10</property> + <property name="margin_top">10</property> + <property name="margin_bottom">10</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkFontButton" id="font"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="font">Sans 12</property> + <signal name="font-set" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box13"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="box14"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="kern_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="kern"> + <property name="label" translatable="yes">Enabled</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="kern_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Kerning</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="box15"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="liga_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="liga"> + <property name="label" translatable="yes">Common</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="liga_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box16"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="dlig_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="dlig"> + <property name="label" translatable="yes">Discretionary</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="dlig_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box17"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="hlig_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="hlig"> + <property name="label" translatable="yes">Historical</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="hlig_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box18"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="clig_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="clig"> + <property name="label" translatable="yes">Contextual</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="clig_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Ligatures</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="box19"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="smcp_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="smcp"> + <property name="label" translatable="yes">Small Caps</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="smcp_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box20"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="c2sc_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="c2sc"> + <property name="label" translatable="yes">Small Caps from Caps</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="c2sc_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Letter Case</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander7"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkRadioButton" id="numcasedefault"> + <property name="label" translatable="yes">Default</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="lnum"> + <property name="label" translatable="yes">Lining</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">numcasedefault</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="onum"> + <property name="label" translatable="yes">Old-Style</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">numcasedefault</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Number Case</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander8"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkRadioButton" id="numspacedefault"> + <property name="label" translatable="yes">Default</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="pnum"> + <property name="label" translatable="yes">Proportional</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">numspacedefault</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="tnum"> + <property name="label" translatable="yes">Tabular</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">numspacedefault</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Number Spacing</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander9"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkRadioButton" id="fractiondefault"> + <property name="label" translatable="yes">Off</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="frac"> + <property name="label" translatable="yes">Normal</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">fractiondefault</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="afrc"> + <property name="label" translatable="yes">Alternate</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">fractiondefault</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label10"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Fractions</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">6</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander10"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="box21"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="zero_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="zero"> + <property name="label" translatable="yes">Slashed Zero</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="zero_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box22"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="nalt_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="nalt"> + <property name="label" translatable="yes">Alt. Annotation</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="nalt_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label11"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Numeric Extras</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">7</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander11"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box9"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="box28"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="swsh_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="swsh"> + <property name="label" translatable="yes">Swash</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="swsh_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box29"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="calt_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="calt"> + <property name="label" translatable="yes">Contextual</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="calt_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box30"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="hist_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="hist"> + <property name="label" translatable="yes">Historical</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="hist_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box31"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="salt_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="salt"> + <property name="label" translatable="yes">Stylistic</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="salt_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Character Alternatives</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">8</property> + </packing> + </child> + <child> + <object class="GtkExpander" id="expander12"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkBox" id="box10"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkBox" id="box23"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="ss01_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ss01"> + <property name="label" translatable="yes">Set 1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="ss01_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box24"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="ss02_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ss02"> + <property name="label" translatable="yes">Set 2</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="ss02_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box25"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="ss03_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ss03"> + <property name="label" translatable="yes">Set 3</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="ss03_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box26"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="ss04_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ss04"> + <property name="label" translatable="yes">Set 4</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="ss04_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box27"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="ss05_dflt"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ss05"> + <property name="label" translatable="yes">Set 5</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="notify::active" handler="update" swapped="no"/> + <property name="sensitive" bind-source="ss05_dflt" bind-property="active" bind-flags="sync-create|bidirectional"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label13"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Alternative Stylistic Sets</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">9</property> + </packing> + </child> + </object> + </child> + <style> + <class name="view"/> + </style> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box12"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkStack" id="stack"> + <property name="visible">True</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_top">20</property> + <property name="margin_bottom">20</property> + <child> + <object class="GtkEventBox"> + <property name="visible">True</property> + <signal name="button-press-event" handler="switch_to_entry"/> + <child> + <object class="GtkLabel" id="label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="valign">start</property> + </object> + </child> + </object> + <packing> + <property name="name">label</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry"> + <property name="visible">True</property> + <property name="text">Lucky affluent actor asks to feast on giant 10.34" cheese-filled quiche in fjord.</property> + <signal name="key-press-event" handler="entry_key_press"/> + <signal name="activate" handler="switch_to_label"/> + <property name="valign">start</property> + </object> + <packing> + <property name="name">entry</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="settings"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">20</property> + <property name="margin_right">20</property> + <property name="margin_bottom">20</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/demos/gtk-demo/font_features.c b/demos/gtk-demo/font_features.c new file mode 100644 index 0000000000..7e8cec8138 --- /dev/null +++ b/demos/gtk-demo/font_features.c @@ -0,0 +1,202 @@ +/* Font Features + * + * This demonstrates support for OpenType font features with + * Pango attributes. The attributes can be used manually or + * via Pango markup. + */ + +#include <gtk/gtk.h> + +static GtkWidget *label; +static GtkWidget *settings; +static GtkWidget *font; +static GtkWidget *resetbutton; +static GtkWidget *numcasedefault; +static GtkWidget *numspacedefault; +static GtkWidget *fractiondefault; +static GtkWidget *stack; +static GtkWidget *entry; + +static GtkWidget *toggle[24]; + +static void +update (void) +{ + GString *s; + char *font_desc; + char *font_settings; + const char *text; + gboolean has_feature; + int i; + + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + font_desc = gtk_font_chooser_get_font (GTK_FONT_CHOOSER (font)); + + s = g_string_new (""); + + has_feature = FALSE; + for (i = 0; i < 24; i++) + { + if (!gtk_widget_is_sensitive (toggle[i])) + continue; + + if (GTK_IS_RADIO_BUTTON (toggle[i])) + { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle[i]))) + { + if (has_feature) + g_string_append (s, ", "); + g_string_append (s, gtk_buildable_get_name (GTK_BUILDABLE (toggle[i]))); + g_string_append (s, " 1"); + has_feature = TRUE; + } + } + else + { + if (has_feature) + g_string_append (s, ", "); + g_string_append (s, gtk_buildable_get_name (GTK_BUILDABLE (toggle[i]))); + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle[i]))) + g_string_append (s, " 1"); + else + g_string_append (s, " 0"); + has_feature = TRUE; + } + } + + font_settings = g_string_free (s, FALSE); + + gtk_label_set_text (GTK_LABEL (settings), font_settings); + + s = g_string_new (""); + g_string_append_printf (s, "<span font_desc='%s' font_features='%s'>%s</span>", font_desc, font_settings, text); + + gtk_label_set_markup (GTK_LABEL (label), s->str); + + g_string_free (s, TRUE); + + g_free (font_desc); + g_free (font_settings); +} + +static void +reset (void) +{ + int i; + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (numcasedefault), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (numspacedefault), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fractiondefault), TRUE); + for (i = 0; i < 24; i++) + { + if (!GTK_IS_RADIO_BUTTON (toggle[i])) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle[i]), FALSE); + gtk_widget_set_sensitive (toggle[i], FALSE); + } + } +} + +static char *text; + +static void +switch_to_entry (void) +{ + text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); + gtk_stack_set_visible_child_name (GTK_STACK (stack), "entry"); +} + +static void +switch_to_label (void) +{ + g_free (text); + text = NULL; + gtk_stack_set_visible_child_name (GTK_STACK (stack), "label"); + update (); +} + +static gboolean +entry_key_press (GtkEntry *entry, GdkEventKey *event) +{ + if (event->keyval == GDK_KEY_Escape) + { + gtk_entry_set_text (GTK_ENTRY (entry), text); + switch_to_label (); + return GDK_EVENT_STOP; + } + + return GDK_EVENT_PROPAGATE; +} + +GtkWidget * +do_font_features (GtkWidget *do_widget) +{ + static GtkWidget *window = NULL; + + if (!window) + { + GtkBuilder *builder; + int i; + + builder = gtk_builder_new_from_resource ("/font-features/font-features.ui"); + + gtk_builder_add_callback_symbol (builder, "update", update); + gtk_builder_add_callback_symbol (builder, "reset", reset); + gtk_builder_add_callback_symbol (builder, "switch_to_entry", switch_to_entry); + gtk_builder_add_callback_symbol (builder, "switch_to_label", switch_to_label); + gtk_builder_add_callback_symbol (builder, "entry_key_press", G_CALLBACK (entry_key_press)); + gtk_builder_connect_signals (builder, NULL); + + window = GTK_WIDGET (gtk_builder_get_object (builder, "window")); + label = GTK_WIDGET (gtk_builder_get_object (builder, "label")); + settings = GTK_WIDGET (gtk_builder_get_object (builder, "settings")); + resetbutton = GTK_WIDGET (gtk_builder_get_object (builder, "reset")); + font = GTK_WIDGET (gtk_builder_get_object (builder, "font")); + numcasedefault = GTK_WIDGET (gtk_builder_get_object (builder, "numcasedefault")); + numspacedefault = GTK_WIDGET (gtk_builder_get_object (builder, "numspacedefault")); + fractiondefault = GTK_WIDGET (gtk_builder_get_object (builder, "fractiondefault")); + stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack")); + entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry")); + + i = 0; + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "kern")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "liga")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "dlig")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "hlig")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "clig")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "smcp")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "c2sc")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "lnum")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "onum")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "pnum")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "tnum")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "frac")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "afrc")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "zero")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "nalt")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "swsh")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "calt")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "hist")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "salt")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "ss01")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "ss02")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "ss03")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "ss04")); + toggle[i++] = GTK_WIDGET (gtk_builder_get_object (builder, "ss05")); + + update (); + } + + if (!gtk_widget_get_visible (window)) + { + gtk_window_present (GTK_WINDOW (window)); + } + else + { + gtk_widget_destroy (window); + window = NULL; + } + + return window; +} |