@@ -2062,6 +2062,19 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
2062
2062
width , height , descent , glyphs , rects = \
2063
2063
self ._text2path .mathtext_parser .parse (s , 72 , prop )
2064
2064
2065
+ if gc .get_url () is not None :
2066
+ link_annotation = {
2067
+ 'Type' : Name ('Annot' ),
2068
+ 'Subtype' : Name ('Link' ),
2069
+ 'Rect' : (x , y , x + width , y + height ),
2070
+ 'Border' : [0 , 0 , 0 ],
2071
+ 'A' : {
2072
+ 'S' : Name ('URI' ),
2073
+ 'URI' : gc .get_url (),
2074
+ },
2075
+ }
2076
+ self .file ._annotations [- 1 ][1 ].append (link_annotation )
2077
+
2065
2078
# When using Type 3 fonts, we can't use character codes higher
2066
2079
# than 255, so we use the "Do" command to render those
2067
2080
# instead.
@@ -2136,6 +2149,19 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
2136
2149
with dviread .Dvi (dvifile , 72 ) as dvi :
2137
2150
page , = dvi
2138
2151
2152
+ if gc .get_url () is not None :
2153
+ link_annotation = {
2154
+ 'Type' : Name ('Annot' ),
2155
+ 'Subtype' : Name ('Link' ),
2156
+ 'Rect' : (x , y , x + page .width , y + page .height ),
2157
+ 'Border' : [0 , 0 , 0 ],
2158
+ 'A' : {
2159
+ 'S' : Name ('URI' ),
2160
+ 'URI' : gc .get_url (),
2161
+ },
2162
+ }
2163
+ self .file ._annotations [- 1 ][1 ].append (link_annotation )
2164
+
2139
2165
# Gather font information and do some setup for combining
2140
2166
# characters into strings. The variable seq will contain a
2141
2167
# sequence of font and text entries. A font entry is a list
@@ -2235,6 +2261,21 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
2235
2261
if is_opentype_cff_font (font .fname ):
2236
2262
fonttype = 42
2237
2263
2264
+ if gc .get_url () is not None :
2265
+ font .set_text (s )
2266
+ width , height = font .get_width_height ()
2267
+ link_annotation = {
2268
+ 'Type' : Name ('Annot' ),
2269
+ 'Subtype' : Name ('Link' ),
2270
+ 'Rect' : (x , y , x + width / 64 , y + height / 64 ),
2271
+ 'Border' : [0 , 0 , 0 ],
2272
+ 'A' : {
2273
+ 'S' : Name ('URI' ),
2274
+ 'URI' : gc .get_url (),
2275
+ },
2276
+ }
2277
+ self .file ._annotations [- 1 ][1 ].append (link_annotation )
2278
+
2238
2279
# If fonttype != 3 or there are no multibyte characters, emit the whole
2239
2280
# string at once.
2240
2281
if fonttype != 3 or all (ord (char ) <= 255 for char in s ):
0 commit comments