Re: GtkSource.PrintCompositor: How to possible printing plain text documents without lost blank lines and indentations?




 
Here is something else that might help. Try a monospace font to test with. If you use a monospace font then 
your spacing should be kept correct. If I draw a grid around the characters, monospace will hold the spacing 
to the 28x32 grid.

Eric

...
new_font = Pango.FontDescription("Monospace 20")
...
def draw_page(self, operation, gtk_context, page_number):
        cr = gtk_context.get_cairo_context()

        #Get rectangle for one monospace char for sizing.
        self.pango_layout.set_markup("5")
        rectangle_ink, rectangle_log = self.pango_layout.get_extents()
       
        #Draw rectangles around monospaced text.
        cr.set_source_rgb(1.0, 0.0, 1.0)
        cr.set_line_width(1)
        font_width = rectangle_log.width/Pango.SCALE
        font_height = rectangle_log.height/Pango.SCALE
        for x in range(28): 
            for y in range(32):
                cr.rectangle(y * font_width, x * font_height, font_width, font_height)
                cr.stroke()
          
        #Show Text.
        cr.set_source_rgb(0.0, 0.0, 0.0)
        start = self.textbuffer.get_start_iter()
        end = self.textbuffer.get_end_iter()
        string = self.textbuffer.get_text(start, end, False)
        self.pango_layout.set_markup(string)
        PangoCairo.show_layout(cr, self.pango_layout)

 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]