kopia lustrzana https://github.com/hholzgra/ocitysmap
add hyperlinks to neighbourhood page number arrows
requires at least Cairo 1.15.10 and PyCairo 1.18.0, and currently suffers from https://gitlab.freedesktop.org/cairo/cairo/issues/336 so that only back links work, but not forward links so keeping this in a development branch only for nowdev-pdf-links
rodzic
e811b98df2
commit
e52c0a08cc
|
|
@ -707,6 +707,10 @@ class MultiPageRenderer(Renderer):
|
||||||
ctx.save()
|
ctx.save()
|
||||||
ctx.set_source_rgb(0, 0, 0)
|
ctx.set_source_rgb(0, 0, 0)
|
||||||
ctx.translate(-arrow_edge/2, -arrow_edge*0.45)
|
ctx.translate(-arrow_edge/2, -arrow_edge*0.45)
|
||||||
|
try: # tag_begin() does not exist prior to pycairo 1.18
|
||||||
|
ctx.tag_begin(cairo.TAG_LINK, "page=%d" % number)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
ctx.line_to(0, 0)
|
ctx.line_to(0, 0)
|
||||||
ctx.line_to(0, arrow_edge)
|
ctx.line_to(0, arrow_edge)
|
||||||
ctx.line_to(arrow_edge, arrow_edge)
|
ctx.line_to(arrow_edge, arrow_edge)
|
||||||
|
|
@ -714,15 +718,27 @@ class MultiPageRenderer(Renderer):
|
||||||
ctx.line_to(arrow_edge/2, -arrow_edge*.25)
|
ctx.line_to(arrow_edge/2, -arrow_edge*.25)
|
||||||
ctx.close_path()
|
ctx.close_path()
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
|
try: # tag_end() does not exist prior to pycairo 1.18
|
||||||
|
ctx.tag_end(cairo.TAG_LINK)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
|
|
||||||
ctx.save()
|
ctx.save()
|
||||||
if reverse_text:
|
if reverse_text:
|
||||||
ctx.rotate(math.pi)
|
ctx.rotate(math.pi)
|
||||||
|
try: # tag_begin() does not exist prior to pycairo 1.18
|
||||||
|
ctx.tag_begin(cairo.TAG_LINK, "page=%d" % number)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
draw_utils.draw_text_adjusted(ctx, str(number), 0, 0, arrow_edge,
|
draw_utils.draw_text_adjusted(ctx, str(number), 0, 0, arrow_edge,
|
||||||
arrow_edge, max_char_number=max_digit_number,
|
arrow_edge, max_char_number=max_digit_number,
|
||||||
text_color=(1, 1, 1, 1), width_adjust=0.85,
|
text_color=(1, 1, 1, 1), width_adjust=0.85,
|
||||||
height_adjust=0.9)
|
height_adjust=0.9)
|
||||||
|
try: # tag_end() does not exist prior to pycairo 1.18
|
||||||
|
ctx.tag_end(cairo.TAG_LINK)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
|
|
||||||
def _render_neighbour_arrows(self, ctx, cairo_surface, map_number,
|
def _render_neighbour_arrows(self, ctx, cairo_surface, map_number,
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue