xpuz.pdf
¤
Module implementing PDF export functionality.
PDF
¤
PDF(
cwrapper: CrosswordWrapper,
starting_word_positions: List[Tuple[int]],
starting_word_matrix: List[List[int]],
definitions_a: List[Dict[int, Tuple[str]]],
definitions_d: List[Dict[int, Tuple[str]]],
)
Provides the functionality to create a PDF with the an empty crossword grid and its definitions, as well as the completed crossword grid.
Disclaimer
Cannot draw crosswords that contains complex glyphs, such as
Mandarin and Japanese, due to limitations with cairo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cwrapper |
CrosswordWrapper
|
The crossword wrapper. |
required |
starting_word_positions |
List[Tuple[int]]
|
required | |
starting_word_matrix |
List[List[int]]
|
required | |
definitions_a |
List[Dict[int, Tuple[str]]]
|
required | |
definitions_d |
List[Dict[int, Tuple[str]]]
|
required |
Source code in src/xpuz/pdf.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
_draw_all
¤
_draw_all() -> None
Driver function to draw the PDF.
Source code in src/xpuz/pdf.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
_draw_cell_letter
¤
Draw the letter at self.grid[row][col].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row |
int
|
The row, used as a reference to determine the drawing location. |
required |
col |
int
|
The column, used as a reference to determine the drawing location. |
required |
Source code in src/xpuz/pdf.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
_draw_definitions
¤
_draw_definitions() -> None
Driver function to draw both columns of a crossword's definitions.
Source code in src/xpuz/pdf.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
_draw_definitions_col
¤
_draw_definitions_col(
definitions: List[str],
dir_title: str,
start_x: float,
start_y: float,
backlog: Union[List[None], List[str]],
) -> None
Draw either the across or down definitions column.
Disclaimer
Does not provide wrapping for clues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definitions |
List[str]
|
The definitions for either the across or down column. |
required |
dir_title |
str
|
The title for the column. |
required |
start_x |
float
|
The x position to begin drawing the column. |
required |
start_y |
float
|
The y position to begin drawing the column. |
required |
backlog |
Union[List[None], List[str]]
|
The definitions that could not fit on the existing page. It is empty in the first call of this method. |
required |
Source code in src/xpuz/pdf.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
_draw_display_name
¤
_draw_display_name(name: str) -> None
Draw name at the top of the current page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The display name. |
required |
Source code in src/xpuz/pdf.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
_draw_grid
¤
_draw_grid(with_answers: bool = False) -> None
Draw the crossword grid in the center of the page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_answers |
bool
|
Whether to draw this current part of the crossword PDF with answers in the grid or not. |
False
|
Source code in src/xpuz/pdf.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
_draw_grid_lines
¤
_draw_grid_lines() -> None
Draw lines in between all of the cells.
Source code in src/xpuz/pdf.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
_draw_number_label
¤
Draw a number label in the top left hand corner of the cell at row
and col.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row |
int
|
The row, used as a reference to determine the drawing location. |
required |
col |
int
|
The column, used as a reference to determine the drawing location. |
required |
Source code in src/xpuz/pdf.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
_on_finish
¤
_on_finish() -> None
Provide information to the user after drawing is finished.
Source code in src/xpuz/pdf.py
103 104 105 106 107 108 109 110 111 112 | |
_set_font_face
¤
_set_font_face(
family: str = "Arial",
slant: str = FONT_SLANT_NORMAL,
weight: str = FONT_WEIGHT_BOLD,
) -> None
Set the font that is used by pycairo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family |
str
|
The font family. |
'Arial'
|
slant |
str
|
The font slant. |
FONT_SLANT_NORMAL
|
weight |
str
|
The font weight. |
FONT_WEIGHT_BOLD
|
Source code in src/xpuz/pdf.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
write
¤
write() -> None
Begin the PDF writing process.
Source code in src/xpuz/pdf.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |