Fwd: Changing font of GtkSourceView changes font of GtkSourceMap

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Changing font of GtkSourceView changes font of GtkSourceMap

Gtk+ - Apps Dev mailing list
Forwarding to gtk-app-devel since there appears to be much more activity
related to GtkSourceView.

---------- Forwarded message ---------
From: Mitko Haralanov <[hidden email]>
Date: Tue, Feb 5, 2019, 13:42
Subject: Changing font of GtkSourceView changes font of GtkSourceMap
To: <[hidden email]>


I can't figure out how to change the font of GtkSourceView and
GtkSourceMap in a reasonable way.

According to the documentation, the View and the Map should be using
the same font but with the Map using a font size of 1pt. To me this
implies that when I change the font of the TextBuffer of the View
using tags, I can copy the PangoFontDescription to a new object,
change the font size to 1pt and set the new PangoFontDescription as
the "font-desc" property of the Map.

In practice, however, the Map always has the exact same font size as
the View. No matter what I do, I can't seem to change the font size of
the Map to 1pt, unless I change the font size of the View to 1pt, as
well.

What is the correct processes for changing the font size of both the
View and the Map?

Thank you,
- Mitko
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Changing font of GtkSourceView changes font of GtkSourceMap

Gtk+ - Apps Dev mailing list
Any help would be appreciated.

Thank you.

On Tue, Feb 5, 2019 at 2:28 PM Mitko Haralanov <[hidden email]> wrote:

>
> Forwarding to gtk-app-devel since there appears to be much more activity related to GtkSourceView.
>
> ---------- Forwarded message ---------
> From: Mitko Haralanov <[hidden email]>
> Date: Tue, Feb 5, 2019, 13:42
> Subject: Changing font of GtkSourceView changes font of GtkSourceMap
> To: <[hidden email]>
>
>
> I can't figure out how to change the font of GtkSourceView and
> GtkSourceMap in a reasonable way.
>
> According to the documentation, the View and the Map should be using
> the same font but with the Map using a font size of 1pt. To me this
> implies that when I change the font of the TextBuffer of the View
> using tags, I can copy the PangoFontDescription to a new object,
> change the font size to 1pt and set the new PangoFontDescription as
> the "font-desc" property of the Map.
>
> In practice, however, the Map always has the exact same font size as
> the View. No matter what I do, I can't seem to change the font size of
> the Map to 1pt, unless I change the font size of the View to 1pt, as
> well.
>
> What is the correct processes for changing the font size of both the
> View and the Map?
>
> Thank you,
> - Mitko
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Changing font of GtkSourceView changes font of GtkSourceMap

Gtk+ - Apps Dev mailing list
Still looking for some help on this.

Thank you.

On Mon, Feb 11, 2019 at 9:11 AM Mitko Haralanov <[hidden email]> wrote:

>
> Any help would be appreciated.
>
> Thank you.
>
> On Tue, Feb 5, 2019 at 2:28 PM Mitko Haralanov <[hidden email]> wrote:
> >
> > Forwarding to gtk-app-devel since there appears to be much more activity related to GtkSourceView.
> >
> > ---------- Forwarded message ---------
> > From: Mitko Haralanov <[hidden email]>
> > Date: Tue, Feb 5, 2019, 13:42
> > Subject: Changing font of GtkSourceView changes font of GtkSourceMap
> > To: <[hidden email]>
> >
> >
> > I can't figure out how to change the font of GtkSourceView and
> > GtkSourceMap in a reasonable way.
> >
> > According to the documentation, the View and the Map should be using
> > the same font but with the Map using a font size of 1pt. To me this
> > implies that when I change the font of the TextBuffer of the View
> > using tags, I can copy the PangoFontDescription to a new object,
> > change the font size to 1pt and set the new PangoFontDescription as
> > the "font-desc" property of the Map.
> >
> > In practice, however, the Map always has the exact same font size as
> > the View. No matter what I do, I can't seem to change the font size of
> > the Map to 1pt, unless I change the font size of the View to 1pt, as
> > well.
> >
> > What is the correct processes for changing the font size of both the
> > View and the Map?
> >
> > Thank you,
> > - Mitko
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Changing font of GtkSourceView changes font of GtkSourceMap

Reuben Rissler
I am not sure if this helps any:


#!/usr/bin/env python

import gi
gi.require_version('GtkSource', '3.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GtkSource, GObject, Pango

class GUI:
     def __init__(self):

         GObject.type_register(GtkSource.View)
         window = Gtk.Window()
         window.connect('destroy', self.on_window_destroy)
         pane = Gtk.Paned(orientation = Gtk.Orientation.HORIZONTAL)
         window.add(pane)
         s_view = GtkSource.View()
         pane.pack1(s_view)
         s_map = GtkSource.Map()
         s_map.set_view(s_view)
         pane.pack2(s_map)
         s_map.set_property('font-desc',
Pango.font_description_from_string("Sans 3"))
         window.show_all()

     def on_window_destroy(self, window):
         Gtk.main_quit()


if __name__ == "__main__":
     app = GUI()
     Gtk.main()



On 02/27/2019 12:36 PM, Mitko Haralanov via gtk-app-devel-list wrote:

> Still looking for some help on this.
>
> Thank you.
>
> On Mon, Feb 11, 2019 at 9:11 AM Mitko Haralanov <[hidden email]> wrote:
>> Any help would be appreciated.
>>
>> Thank you.
>>
>> On Tue, Feb 5, 2019 at 2:28 PM Mitko Haralanov <[hidden email]> wrote:
>>> Forwarding to gtk-app-devel since there appears to be much more activity related to GtkSourceView.
>>>
>>> ---------- Forwarded message ---------
>>> From: Mitko Haralanov <[hidden email]>
>>> Date: Tue, Feb 5, 2019, 13:42
>>> Subject: Changing font of GtkSourceView changes font of GtkSourceMap
>>> To: <[hidden email]>
>>>
>>>
>>> I can't figure out how to change the font of GtkSourceView and
>>> GtkSourceMap in a reasonable way.
>>>
>>> According to the documentation, the View and the Map should be using
>>> the same font but with the Map using a font size of 1pt. To me this
>>> implies that when I change the font of the TextBuffer of the View
>>> using tags, I can copy the PangoFontDescription to a new object,
>>> change the font size to 1pt and set the new PangoFontDescription as
>>> the "font-desc" property of the Map.
>>>
>>> In practice, however, the Map always has the exact same font size as
>>> the View. No matter what I do, I can't seem to change the font size of
>>> the Map to 1pt, unless I change the font size of the View to 1pt, as
>>> well.
>>>
>>> What is the correct processes for changing the font size of both the
>>> View and the Map?
>>>
>>> Thank you,
>>> - Mitko
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Changing font of GtkSourceView changes font of GtkSourceMap

Gtk+ - Apps Dev mailing list
Thanks for the example.

I modified it to illustrate the behavior:

import gi
gi.require_version('GtkSource', '3.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GtkSource, GObject, Pango


def set_font(button, view, map, tag):
    font_name = button.get_font_name()
    font = Pango.font_description_from_string(font_name)
    map_font = font.copy()
    map_font.set_size(1*Pango.SCALE)
    tag.set_property("font-desc", font)
    buffer = view.get_buffer()
    buffer.apply_tag(tag, buffer.get_start_iter(), buffer.get_end_iter())
    map.set_property("font-desc", map_font)

class GUI:
    def __init__(self):

        GObject.type_register(GtkSource.View)
        window = Gtk.Window()
        window.connect('destroy', self.on_window_destroy)
        box = Gtk.VBox()
        window.add(box)
        fontchooser = Gtk.FontButton()
        box.pack_start(fontchooser, False, True, 0)
        pane = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL)
        box.pack_start(pane, True, True, 0)
        s_view = GtkSource.View()
        buffer = s_view.get_buffer()
        with open("/usr/share/doc/glade/README", 'r') as fd:
            buffer.set_text(fd.read())
        tag = buffer.create_tag("buffer-font")
        pane.pack1(s_view, True, False)
        s_map = GtkSource.Map()
        s_map.set_view(s_view)
        pane.pack2(s_map, True, False)
        fontchooser.connect("font-set", set_font, s_view, s_map, tag)
        window.show_all()

    def on_window_destroy(self, window):
        Gtk.main_quit()

if __name__ == "__main__":
    app = GUI()
    Gtk.main()

Give it try and change the font of the view. You'll see that the font
of the map changes to the same font as the view, including *the same
size*.

Thank you.

On Thu, Feb 28, 2019 at 8:47 AM Reuben Rissler <[hidden email]> wrote:

>
> I am not sure if this helps any:
>
>
> #!/usr/bin/env python
>
> import gi
> gi.require_version('GtkSource', '3.0')
> gi.require_version('Gtk', '3.0')
> from gi.repository import Gtk, GtkSource, GObject, Pango
>
> class GUI:
>      def __init__(self):
>
>          GObject.type_register(GtkSource.View)
>          window = Gtk.Window()
>          window.connect('destroy', self.on_window_destroy)
>          pane = Gtk.Paned(orientation = Gtk.Orientation.HORIZONTAL)
>          window.add(pane)
>          s_view = GtkSource.View()
>          pane.pack1(s_view)
>          s_map = GtkSource.Map()
>          s_map.set_view(s_view)
>          pane.pack2(s_map)
>          s_map.set_property('font-desc',
> Pango.font_description_from_string("Sans 3"))
>          window.show_all()
>
>      def on_window_destroy(self, window):
>          Gtk.main_quit()
>
>
> if __name__ == "__main__":
>      app = GUI()
>      Gtk.main()
>
>
>
> On 02/27/2019 12:36 PM, Mitko Haralanov via gtk-app-devel-list wrote:
> > Still looking for some help on this.
> >
> > Thank you.
> >
> > On Mon, Feb 11, 2019 at 9:11 AM Mitko Haralanov <[hidden email]> wrote:
> >> Any help would be appreciated.
> >>
> >> Thank you.
> >>
> >> On Tue, Feb 5, 2019 at 2:28 PM Mitko Haralanov <[hidden email]> wrote:
> >>> Forwarding to gtk-app-devel since there appears to be much more activity related to GtkSourceView.
> >>>
> >>> ---------- Forwarded message ---------
> >>> From: Mitko Haralanov <[hidden email]>
> >>> Date: Tue, Feb 5, 2019, 13:42
> >>> Subject: Changing font of GtkSourceView changes font of GtkSourceMap
> >>> To: <[hidden email]>
> >>>
> >>>
> >>> I can't figure out how to change the font of GtkSourceView and
> >>> GtkSourceMap in a reasonable way.
> >>>
> >>> According to the documentation, the View and the Map should be using
> >>> the same font but with the Map using a font size of 1pt. To me this
> >>> implies that when I change the font of the TextBuffer of the View
> >>> using tags, I can copy the PangoFontDescription to a new object,
> >>> change the font size to 1pt and set the new PangoFontDescription as
> >>> the "font-desc" property of the Map.
> >>>
> >>> In practice, however, the Map always has the exact same font size as
> >>> the View. No matter what I do, I can't seem to change the font size of
> >>> the Map to 1pt, unless I change the font size of the View to 1pt, as
> >>> well.
> >>>
> >>> What is the correct processes for changing the font size of both the
> >>> View and the Map?
> >>>
> >>> Thank you,
> >>> - Mitko
> > _______________________________________________
> > gtk-app-devel-list mailing list
> > [hidden email]
> > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> >
>
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list