-
Notifications
You must be signed in to change notification settings - Fork 136
[draft] Use card text from the dominion strategy wiki #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I haven't looked in detail, but I'm very happy to replace the current language used to encode things like inline images - it grew organically out of a single initial substitution and has never been revisited. Been bugging me for a while. |
| for c in cards: | ||
| if not hasattr(c, "wiki_text"): | ||
| print(f"{c.name} has no wiki_text") | ||
| elif not c.wiki_text: | ||
| print(f"{c.name} has falsey wiki_text: [{c.wiki_text}]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is debugging code that will go away.
| if divider_text == "wiki-text": | ||
| s.fontSize = 11 # Dominion cards seem to be printed in 11 point font | ||
| s.leading = 13 # This is the space between adjacent lines | ||
| s.autoLeading = "max" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should leave a comment explaining this one too
| return | ||
|
|
||
| s = getSampleStyleSheet()["BodyText"] | ||
| s.fontName = self.fontStyle["Rules"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised that this wasn't using the Minion font. Any objections to using self.fontStyle["Regular"] instead? It's a little bit of extra work to switch back to Times for the <dash> rendering, since in Minion the dashes have whitespace between them, and to register the font family so bold and italics work, but I've got code locally that does all of that.
| self.blank_image = "highres/Coin.png" | ||
| self.question_image = "highres/CoinQ.png" | ||
| self.x_image = "highres/Coinx.png" | ||
| self.n_image = "highres/Coin{n}.png" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are higher resolution images I downloaded from the wiki. I'm not quite sure where to land on the tradeoff between resolution and generated file size. This should get clarified before merging, either not referring to files that aren't committed, or committing them.
| self.question_image = "coin_small_question.png" | ||
| self.x_image = "coin_small_x.png" | ||
| self.n_image = "coin_small_{n}.png" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scaling up the small images doesn't look very good when printed. I love the way the cost icons look, with number rendered as text overlaid on the blank image. If anyone's willing to do so, it would be awesome to have a set of coin and debt images with the numbers rendered in that way, to include as PNGs. Maybe I'll open an issue asking for help with that, as I've already got a lot on my plate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| IMAGES = InlineImages( | ||
| coin={ | ||
| "m": CoinInlineImage(1.2, 1, valign="-28%", resolution="low"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This valign value, together with the autoLeading, were the key pieces in getting the number on the coin image to line up with the surrounding text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 1.2:1 aspect ratio is because the images include whitespace on the right hand side. I don't think we need that; it would be better for them to just be square.
| def convert_wiki_markup(text): | ||
| """This whole function is obsolete""" | ||
| if not text: | ||
| return "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this here for now because it was harmless, but this is purely left-over from my original approach of keeping the current formatting code for inline images.
This is not ready to merge yet, but I wanted to show what I'm working on and get some feedback.
There's a lot going on here.
{{Cost|3}}to3 Coins).--front rules --back wiki-text) to compare them.leadingandautoLeadingparameters to make some vertical room around the images as needed.inline_images.pybecause I found it easier to understand/use.A few things that still aren't done:
Note regarding the
<nobr>tag: the reportlab docs say this will prevent line breaks, but it doesn't actually work. I patched the library code to fix it and plan on submitting a patch to them. In the meantime, the tag is simply parsed and harmlessly ignored using the published versions of the reportlab library. Take a look at how Sailor is rendered with vertical orientation if you want an example.