Prawn update
This commit is contained in:
parent
7a652e619e
commit
b6e3aaa9fb
150
book_of_faces.rb
Normal file
150
book_of_faces.rb
Normal file
@ -0,0 +1,150 @@
|
||||
require "prawn"
|
||||
require "pry"
|
||||
|
||||
puts "Book of Faces PDF generator"
|
||||
class BookOfFaces
|
||||
FONT_SIZE_CHAPTER = 48
|
||||
FONT_SIZE_SECTION = 24
|
||||
FONT_SIZE_BODY = 12
|
||||
|
||||
attr_accessor :pdf, :number_name, :chapter_name, :chapter_title, :section_name
|
||||
|
||||
def start_chapter(num, name)
|
||||
@number_name = num
|
||||
@chapter_name = name
|
||||
|
||||
@chapter_title = "Chapter #{number_name}: #{chapter_name}"
|
||||
puts "Starting #{chapter_title}"
|
||||
|
||||
pdf.outline.update do
|
||||
puts "\tAdding #{@book_of_faces.chapter_title} on page #{page_number}"
|
||||
section(@book_of_faces.chapter_title, :destination => page_number)
|
||||
end
|
||||
|
||||
puts "\tSetting font size"
|
||||
pdf.font_size FONT_SIZE_CHAPTER
|
||||
pdf.font "Abess"
|
||||
puts "\tPrinting chapter to document"
|
||||
pdf.text "Chapter #{number_name}: #{chapter_name}"
|
||||
|
||||
puts "\tRestoring body text"
|
||||
pdf.font "Goudy"
|
||||
pdf.font_size FONT_SIZE_BODY
|
||||
end
|
||||
|
||||
def start_section(section_name)
|
||||
puts "Beginning section #{section_name}:"
|
||||
|
||||
@section_name = section_name
|
||||
|
||||
pdf.outline.add_subsection_to(chapter_title) do
|
||||
@pdf.outline.section section_name, :destination => @pdf.page_number
|
||||
end
|
||||
|
||||
puts "\tSetting font size"
|
||||
pdf.font_size FONT_SIZE_SECTION
|
||||
pdf.text section_name
|
||||
|
||||
puts "\tRestoring body text"
|
||||
pdf.font_size FONT_SIZE_BODY
|
||||
pdf.font "Goudy"
|
||||
|
||||
end
|
||||
|
||||
def roll_results(dramatic_failure:, failure:, success:, exceptional_success:)
|
||||
pdf.font_size FONT_SIZE_BODY
|
||||
pdf.font "Goudy"
|
||||
|
||||
pdf.text "Roll Results", :style => :bold
|
||||
|
||||
pdf.formatted_text [
|
||||
{ :text => "Dramatic Failure: ", :styles => [:bold] },
|
||||
{ :text => dramatic_failure }
|
||||
]
|
||||
|
||||
pdf.formatted_text [
|
||||
{ :text => "Failure: ", :styles => [:bold] },
|
||||
{ :text => failure }
|
||||
]
|
||||
|
||||
pdf.formatted_text [
|
||||
{ :text => "Success: ", :styles => [:bold] },
|
||||
{ :text => success }
|
||||
]
|
||||
|
||||
pdf.formatted_text [
|
||||
{ :text => "Exceptional Success: ", :styles => [:bold] },
|
||||
{ :text => exceptional_success }
|
||||
]
|
||||
end
|
||||
|
||||
def generate
|
||||
@pdf = Prawn::Document.new(:margin => 0)
|
||||
pdf.default_leading 10
|
||||
|
||||
pdf.font_families.update(
|
||||
"Goudy" => {
|
||||
:normal => "goudy.ttf",
|
||||
:bold => "goudy-bold.ttf",
|
||||
:italic => "goudy-italic.ttf"
|
||||
},
|
||||
"Abess" => {
|
||||
:normal => "abess.ttf"
|
||||
},
|
||||
"Lilith" => {
|
||||
:normal => "lilith.ttf"
|
||||
}
|
||||
)
|
||||
|
||||
pdf.outline.instance_variable_set(:@book_of_faces, self)
|
||||
|
||||
puts "Importing cover..."
|
||||
pdf.image("cover.png", :width => 612, :height => 792)
|
||||
|
||||
puts "Printing inner cover..."
|
||||
pdf.start_new_page(:margin => 75)
|
||||
|
||||
pdf.font "Abess"
|
||||
pdf.font_size 72
|
||||
pdf.text "The Book\nOf Faces", :align => :center
|
||||
puts "\tBook Of Faces big text..."
|
||||
|
||||
pdf.font "Goudy"
|
||||
pdf.font_size 36
|
||||
pdf.text "\nA grimoire of spells, Gifts, Disciplines, Contracts, and other anomalies, with anecdotes and exposition from their in-game authors\n\n", :align => :center
|
||||
puts "\tDescription..."
|
||||
|
||||
pdf.font_size 24
|
||||
pdf.text "Written by members of the /cofd/ Discord, edited by NEETzsche", :align => :center
|
||||
puts "\tMain credit..."
|
||||
|
||||
pdf.start_new_page
|
||||
|
||||
pdf.outline.define do
|
||||
end
|
||||
|
||||
start_chapter "One", "Introduction"
|
||||
|
||||
start_section "Judging It By Its Cover"
|
||||
|
||||
pdf.text "This tome is an Artifact-grimoire with certain special properties. It easily weighs about thirty or so pounds from all of the paper within it. It is leather bound with a very visible face on its cover and no title listed; each time people look away and take another look at it, the face on it changes. Upon opening it, it appears anachronistic and mixed. Most of the pages are merely old paper, but some of them are papyrus scrolls that have been glued into it, while others are cuneiform tablets, and some are even touch screens. Upon inspection of this tome, it's clear it should be much bigger, and much heavier, than it actually is. A quill pen is attached to it by a string. Even though a quill pen normally would only be used with ink-on-paper, it appears to also work as a tool to etch into the cuneiform tablets, as a stylus for the touch screens, and whatever else someone manages to find in this tome. Its contents change upon future viewings, making it feel like an endless sea."
|
||||
|
||||
start_section "Exploring Its Contents"
|
||||
|
||||
pdf.text "If one were to open it up and start reading, the content would make no sense. It simply cannot be understood. No amount of knowledge on High Speech, First Tongue, or whatever other language of supernatural origin seems to decipher it. However, he who possesses this book may inscribe their meaningful experiences into it. Mages can Scribe Grimoire (Mage: the Awakening, p. 166) into it, except not only is it Lasting, but they may also place their improvised spells in it as though they were Rotes. They may also write their anecdotes, philosophy and experiences within this book, as long as they are sufficiently meaningful. Other supernatural entities like vampires or werewolves may list in explicit detail their Gifts, Disciplines, Contracts or other traits."
|
||||
|
||||
pdf.text "This action requires an hour of soul-searching, a successful roll on their equivalent Integrity rating, and a Beat. This Beat is consumed by the book; that Beat is gone forever."
|
||||
|
||||
roll_results(
|
||||
:dramatic_failure => "Same as failure, but in addition to this, the Book of Faces is offended at the player's arrogance. It emits a piercing roar that deals one point of Resistant aggravated damage to everyone in the room.",
|
||||
:failure => "The person attempting it gave the Book Of Faces dross. It gave it crap, nonsense. Emo scribblings and cockamamie shitposts. They do not get their Beat back; turns out, their life experience wasn't that useful after all. They may try again without penalty, but must sacrifice another Beat.",
|
||||
:success => "The content the character submitted is of actual value, and it is accepted, incorporated into its pages.\n\nIf the roll succeeds, for the remainder of the scene, the character may at his discretion learn any of the Rotes (as long as they have the Arcanum prerequisites, and even if they were Improvised spells when they were put into the Book of Faces) and Disciplines, may have Gifts conferred upon them, and may enter into Contracts found therein. In mechanics terms, the character reads the Book of Faces extensively for a number of hours and spends their Experiences however they desire, focusing on the things they find most interesting. If they want to use the Book of Faces again in the future, they must make a second roll.",
|
||||
:exceptional_success => "The willworker not only gives it valuable information, but demonstrates they are particularly capable of learning. They gain a full Experience point, but it can only be spent learning things from the Book of Faces"
|
||||
)
|
||||
|
||||
pdf.render_file("book_of_faces.pdf")
|
||||
end
|
||||
end
|
||||
|
||||
book_of_faces = BookOfFaces.new
|
||||
book_of_faces.generate
|
Loading…
Reference in New Issue
Block a user