Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pypdf/_text_extraction/_layout_mode/_font_widths.py: 88%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

8 statements  

1# Widths for the standard 14 fonts as described on page 416 of the PDF 1.7 standard 

2STANDARD_WIDTHS = { 

3 "Helvetica": { # 4 fonts, includes bold, oblique and boldoblique variants 

4 " ": 278, 

5 "!": 278, 

6 '"': 355, 

7 "#": 556, 

8 "$": 556, 

9 "%": 889, 

10 "&": 667, 

11 "'": 191, 

12 "(": 333, 

13 ")": 333, 

14 "*": 389, 

15 "+": 584, 

16 ",": 278, 

17 "-": 333, 

18 ".": 278, 

19 "/": 278, 

20 "0": 556, 

21 "1": 556, 

22 "2": 556, 

23 "3": 556, 

24 "4": 556, 

25 "5": 556, 

26 "6": 556, 

27 "7": 556, 

28 "8": 556, 

29 "9": 556, 

30 ":": 278, 

31 ";": 278, 

32 "<": 584, 

33 "=": 584, 

34 ">": 584, 

35 "?": 611, 

36 "@": 975, 

37 "A": 667, 

38 "B": 667, 

39 "C": 722, 

40 "D": 722, 

41 "E": 667, 

42 "F": 611, 

43 "G": 778, 

44 "H": 722, 

45 "I": 278, 

46 "J": 500, 

47 "K": 667, 

48 "L": 556, 

49 "M": 833, 

50 "N": 722, 

51 "O": 778, 

52 "P": 667, 

53 "Q": 944, 

54 "R": 667, 

55 "S": 667, 

56 "T": 611, 

57 "U": 278, 

58 "V": 278, 

59 "W": 584, 

60 "X": 556, 

61 "Y": 556, 

62 "Z": 500, 

63 "[": 556, 

64 "\\": 556, 

65 "]": 556, 

66 "^": 278, 

67 "_": 278, 

68 "`": 278, 

69 "a": 278, 

70 "b": 278, 

71 "c": 333, 

72 "d": 556, 

73 "e": 556, 

74 "f": 556, 

75 "g": 556, 

76 "h": 556, 

77 "i": 556, 

78 "j": 556, 

79 "k": 556, 

80 "l": 556, 

81 "m": 556, 

82 "n": 278, 

83 "o": 278, 

84 "p": 556, 

85 "q": 556, 

86 "r": 500, 

87 "s": 556, 

88 "t": 556, 

89 "u": 278, 

90 "v": 500, 

91 "w": 500, 

92 "x": 222, 

93 "y": 222, 

94 "z": 556, 

95 "{": 222, 

96 "|": 833, 

97 "}": 556, 

98 "~": 556, 

99 }, 

100 "Times": { # 4 fonts, includes bold, oblique and boldoblique variants 

101 " ": 250, 

102 "!": 333, 

103 '"': 408, 

104 "#": 500, 

105 "$": 500, 

106 "%": 833, 

107 "&": 778, 

108 "'": 180, 

109 "(": 333, 

110 ")": 333, 

111 "*": 500, 

112 "+": 564, 

113 ",": 250, 

114 "-": 333, 

115 ".": 250, 

116 "/": 564, 

117 "0": 500, 

118 "1": 500, 

119 "2": 500, 

120 "3": 500, 

121 "4": 500, 

122 "5": 500, 

123 "6": 500, 

124 "7": 500, 

125 "8": 500, 

126 "9": 500, 

127 ":": 278, 

128 ";": 278, 

129 "<": 564, 

130 "=": 564, 

131 ">": 564, 

132 "?": 444, 

133 "@": 921, 

134 "A": 722, 

135 "B": 667, 

136 "C": 667, 

137 "D": 722, 

138 "E": 611, 

139 "F": 556, 

140 "G": 722, 

141 "H": 722, 

142 "I": 333, 

143 "J": 389, 

144 "K": 722, 

145 "L": 611, 

146 "M": 889, 

147 "N": 722, 

148 "O": 722, 

149 "P": 556, 

150 "Q": 722, 

151 "R": 667, 

152 "S": 556, 

153 "T": 611, 

154 "U": 722, 

155 "V": 722, 

156 "W": 944, 

157 "X": 722, 

158 "Y": 722, 

159 "Z": 611, 

160 "[": 333, 

161 "\\": 278, 

162 "]": 333, 

163 "^": 469, 

164 "_": 500, 

165 "`": 333, 

166 "a": 444, 

167 "b": 500, 

168 "c": 444, 

169 "d": 500, 

170 "e": 444, 

171 "f": 333, 

172 "g": 500, 

173 "h": 500, 

174 "i": 278, 

175 "j": 278, 

176 "k": 500, 

177 "l": 278, 

178 "m": 722, 

179 "n": 500, 

180 "o": 500, 

181 "p": 500, 

182 "q": 500, 

183 "r": 333, 

184 "s": 389, 

185 "t": 278, 

186 "u": 500, 

187 "v": 444, 

188 "w": 722, 

189 "x": 500, 

190 "y": 444, 

191 "z": 389, 

192 "{": 348, 

193 "|": 220, 

194 "}": 348, 

195 "~": 469, 

196 }, 

197} 

198 

199# 4 fonts, includes bold, oblique and bold oblique variants 

200STANDARD_WIDTHS[ 

201 "Courier" 

202] = dict.fromkeys(STANDARD_WIDTHS["Times"], 600) # fixed width 

203STANDARD_WIDTHS["ZapfDingbats"] = dict.fromkeys(STANDARD_WIDTHS["Times"], 1000) # 1 font 

204STANDARD_WIDTHS["Symbol"] = dict.fromkeys(STANDARD_WIDTHS["Times"], 500) # 1 font 

205# add aliases per table H.3 on page 1110 of the PDF 1.7 standard 

206STANDARD_WIDTHS["CourierNew"] = STANDARD_WIDTHS["Courier"] 

207STANDARD_WIDTHS["Arial"] = STANDARD_WIDTHS["Helvetica"] 

208STANDARD_WIDTHS["TimesNewRoman"] = STANDARD_WIDTHS["Times"]