mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Futura has bee purged
This commit is contained in:
@@ -2,11 +2,11 @@ from fractions import Fraction
|
|||||||
import re
|
import re
|
||||||
import math
|
import math
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
class TimecodeFormat(namedtuple("_TimecodeFormat", "frame_duration logical_fps drop_frame")):
|
class TimecodeFormat(namedtuple("_TimecodeFormat", "frame_duration logical_fps drop_frame")):
|
||||||
|
|
||||||
def smpte_to_seconds(self, smpte: str) -> Fraction:
|
def smpte_to_seconds(self, smpte: str) -> Optional[Fraction]:
|
||||||
frame_count = smpte_to_frame_count(smpte, self.logical_fps, drop_frame_hint=self.drop_frame)
|
frame_count = smpte_to_frame_count(smpte, self.logical_fps, drop_frame_hint=self.drop_frame)
|
||||||
if frame_count is None:
|
if frame_count is None:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ from reportlab.platypus.frames import Frame
|
|||||||
from reportlab.pdfbase import pdfmetrics
|
from reportlab.pdfbase import pdfmetrics
|
||||||
from reportlab.pdfbase.ttfonts import TTFont
|
from reportlab.pdfbase.ttfonts import TTFont
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
# TODO: A Generic report useful for spotting
|
# TODO: A Generic report useful for spotting
|
||||||
# TODO: A report useful for M&E mixer's notes
|
# TODO: A report useful for M&E mixer's notes
|
||||||
|
# TODO: Use a default font that doesn't need to be installed
|
||||||
|
|
||||||
# This is from https://code.activestate.com/recipes/576832/ for
|
# This is from https://code.activestate.com/recipes/576832/ for
|
||||||
# generating page count messages
|
# generating page count messages
|
||||||
@@ -36,7 +38,7 @@ class ReportCanvas(canvas.Canvas):
|
|||||||
|
|
||||||
def draw_page_number(self, page_count):
|
def draw_page_number(self, page_count):
|
||||||
self.saveState()
|
self.saveState()
|
||||||
self.setFont("Futura", 10)
|
self.setFont('Helvetica', 10) #FIXME make this customizable
|
||||||
self.drawString(0.5 * inch, 0.5 * inch, "Page %d of %d" % (self._pageNumber, page_count))
|
self.drawString(0.5 * inch, 0.5 * inch, "Page %d of %d" % (self._pageNumber, page_count))
|
||||||
right_edge = self._pagesize[0] - 0.5 * inch
|
right_edge = self._pagesize[0] - 0.5 * inch
|
||||||
self.drawRightString(right_edge, 0.5 * inch, self._report_date.strftime("%m/%d/%Y %H:%M"))
|
self.drawRightString(right_edge, 0.5 * inch, self._report_date.strftime("%m/%d/%Y %H:%M"))
|
||||||
@@ -60,7 +62,8 @@ def make_doc_template(page_size, filename, document_title,
|
|||||||
document_header: str,
|
document_header: str,
|
||||||
client: str,
|
client: str,
|
||||||
document_subheader: str,
|
document_subheader: str,
|
||||||
left_margin=0.5 * inch) -> ADRDocTemplate:
|
left_margin=0.5 * inch,
|
||||||
|
fonts: List[TTFont] = []) -> ADRDocTemplate:
|
||||||
right_margin = top_margin = bottom_margin = 0.5 * inch
|
right_margin = top_margin = bottom_margin = 0.5 * inch
|
||||||
page_box = GRect(0., 0., page_size[0], page_size[1])
|
page_box = GRect(0., 0., page_size[0], page_size[1])
|
||||||
_, page_box = page_box.split_x(left_margin, direction='l')
|
_, page_box = page_box.split_x(left_margin, direction='l')
|
||||||
@@ -85,7 +88,9 @@ def make_doc_template(page_size, filename, document_title,
|
|||||||
frames=frames,
|
frames=frames,
|
||||||
onPage=on_page_lambda)
|
onPage=on_page_lambda)
|
||||||
|
|
||||||
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
for font in fonts:
|
||||||
|
pdfmetrics.registerFont(font)
|
||||||
|
|
||||||
doc = ADRDocTemplate(filename,
|
doc = ADRDocTemplate(filename,
|
||||||
title=document_title,
|
title=document_title,
|
||||||
author=supervisor,
|
author=supervisor,
|
||||||
@@ -112,11 +117,11 @@ def time_format(mins, zero_str="-"):
|
|||||||
|
|
||||||
|
|
||||||
def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box, footer_box, title: str, supervisor: str,
|
def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box, footer_box, title: str, supervisor: str,
|
||||||
document_subheader: str, client: str, doc_title=""):
|
document_subheader: str, client: str, doc_title="", font_name='Helvetica'):
|
||||||
|
|
||||||
(_supervisor_box, client_box,), title_box = right_box.divide_y([16., 16., ])
|
(_supervisor_box, client_box,), title_box = right_box.divide_y([16., 16., ])
|
||||||
title_box.draw_text_cell(a_canvas, title, "Futura", 18, inset_y=2., inset_x=5.)
|
title_box.draw_text_cell(a_canvas, title, font_name, 18, inset_y=2., inset_x=5.)
|
||||||
client_box.draw_text_cell(a_canvas, client, "Futura", 11, inset_y=2., inset_x=5.)
|
client_box.draw_text_cell(a_canvas, client, font_name, 11, inset_y=2., inset_x=5.)
|
||||||
|
|
||||||
a_canvas.saveState()
|
a_canvas.saveState()
|
||||||
a_canvas.setLineWidth(0.5)
|
a_canvas.setLineWidth(0.5)
|
||||||
@@ -133,13 +138,13 @@ def draw_header_footer(a_canvas: ReportCanvas, left_box, right_box, footer_box,
|
|||||||
|
|
||||||
(doc_title_cell, spotting_version_cell,), _ = left_box.divide_y([18., 14], direction='d')
|
(doc_title_cell, spotting_version_cell,), _ = left_box.divide_y([18., 14], direction='d')
|
||||||
|
|
||||||
doc_title_cell.draw_text_cell(a_canvas, doc_title, 'Futura', 14., inset_y=2.)
|
doc_title_cell.draw_text_cell(a_canvas, doc_title, font_name, 14., inset_y=2.)
|
||||||
|
|
||||||
if document_subheader is not None:
|
if document_subheader is not None:
|
||||||
spotting_version_cell.draw_text_cell(a_canvas, document_subheader, 'Futura', 12., inset_y=2.)
|
spotting_version_cell.draw_text_cell(a_canvas, document_subheader, font_name, 12., inset_y=2.)
|
||||||
|
|
||||||
if supervisor is not None:
|
if supervisor is not None:
|
||||||
a_canvas.setFont('Futura', 11.)
|
a_canvas.setFont(font_name, 11.)
|
||||||
a_canvas.drawCentredString(footer_box.min_x + footer_box.width / 2., footer_box.min_y, supervisor)
|
a_canvas.drawCentredString(footer_box.min_x + footer_box.width / 2., footer_box.min_y, supervisor)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ from ptulsconv.pdf import make_doc_template
|
|||||||
|
|
||||||
# TODO: A Continuity
|
# TODO: A Continuity
|
||||||
|
|
||||||
def table_for_scene(scene, tc_format):
|
def table_for_scene(scene, tc_format, font_name = 'Helvetica'):
|
||||||
scene_style = getSampleStyleSheet()['Normal']
|
scene_style = getSampleStyleSheet()['Normal']
|
||||||
scene_style.fontName = 'Futura'
|
scene_style.fontName = font_name
|
||||||
scene_style.leftIndent = 0.
|
scene_style.leftIndent = 0.
|
||||||
scene_style.leftPadding = 0.
|
scene_style.leftPadding = 0.
|
||||||
scene_style.spaceAfter = 18.
|
scene_style.spaceAfter = 18.
|
||||||
@@ -29,7 +29,7 @@ def table_for_scene(scene, tc_format):
|
|||||||
style = [('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
style = [('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
||||||
('LEFTPADDING', (0, 0), (0, 0), 0.0),
|
('LEFTPADDING', (0, 0), (0, 0), 0.0),
|
||||||
('BOTTOMPADDING', (0, 0), (-1, -1), 12.),
|
('BOTTOMPADDING', (0, 0), (-1, -1), 12.),
|
||||||
('FONTNAME', (0, 0), (-1, -1), 'Futura')]
|
('FONTNAME', (0, 0), (-1, -1), font_name)]
|
||||||
|
|
||||||
return Table(data=[row], style=style, colWidths=[1.0 * inch, 6.5 * inch])
|
return Table(data=[row], style=style, colWidths=[1.0 * inch, 6.5 * inch])
|
||||||
|
|
||||||
|
|||||||
@@ -202,16 +202,16 @@ def populate_columns(lines: List[ADRLine], columns, include_omitted, _page_size)
|
|||||||
|
|
||||||
|
|
||||||
def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=False,
|
def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=False,
|
||||||
page_size=portrait(letter)):
|
page_size=portrait(letter), font_name='Helvetica'):
|
||||||
columns = build_columns(lines, include_omitted=include_omitted, reel_list=reel_list)
|
columns = build_columns(lines, include_omitted=include_omitted, reel_list=reel_list)
|
||||||
data, style, columns_widths = populate_columns(lines, columns, include_omitted, page_size)
|
data, style, columns_widths = populate_columns(lines, columns, include_omitted, page_size)
|
||||||
|
|
||||||
style.append(('FONTNAME', (0, 0), (-1, -1), "Futura"))
|
style.append(('FONTNAME', (0, 0), (-1, -1), font_name))
|
||||||
style.append(('FONTSIZE', (0, 0), (-1, -1), 9.))
|
style.append(('FONTSIZE', (0, 0), (-1, -1), 9.))
|
||||||
style.append(('LINEBELOW', (0, 0), (-1, 0), 1.0, colors.black))
|
style.append(('LINEBELOW', (0, 0), (-1, 0), 1.0, colors.black))
|
||||||
# style.append(('LINEBELOW', (0, 1), (-1, -1), 0.25, colors.gray))
|
# style.append(('LINEBELOW', (0, 1), (-1, -1), 0.25, colors.gray))
|
||||||
|
|
||||||
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
#pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
||||||
|
|
||||||
title = "%s Line Count" % lines[0].title
|
title = "%s Line Count" % lines[0].title
|
||||||
filename = title + '.pdf'
|
filename = title + '.pdf'
|
||||||
@@ -230,7 +230,7 @@ def output_report(lines: List[ADRLine], reel_list: List[str], include_omitted=Fa
|
|||||||
story = [Spacer(height=0.5 * inch, width=1.), table]
|
story = [Spacer(height=0.5 * inch, width=1.), table]
|
||||||
|
|
||||||
style = getSampleStyleSheet()['Normal']
|
style = getSampleStyleSheet()['Normal']
|
||||||
style.fontName = 'Futura'
|
style.fontName = font_name
|
||||||
style.fontSize = 12.
|
style.fontSize = 12.
|
||||||
style.spaceBefore = 16.
|
style.spaceBefore = 16.
|
||||||
style.spaceAfter = 16.
|
style.spaceAfter = 16.
|
||||||
|
|||||||
@@ -40,17 +40,17 @@ def build_aux_data_field(line: ADRLine):
|
|||||||
return "<br />".join(entries)
|
return "<br />".join(entries)
|
||||||
|
|
||||||
|
|
||||||
def build_story(lines: List[ADRLine], tc_rate: TimecodeFormat):
|
def build_story(lines: List[ADRLine], tc_rate: TimecodeFormat, font_name='Helvetica'):
|
||||||
story = list()
|
story = list()
|
||||||
|
|
||||||
this_scene = None
|
this_scene = None
|
||||||
scene_style = getSampleStyleSheet()['Normal']
|
scene_style = getSampleStyleSheet()['Normal']
|
||||||
scene_style.fontName = 'Futura'
|
scene_style.fontName = font_name
|
||||||
scene_style.leftIndent = 0.
|
scene_style.leftIndent = 0.
|
||||||
scene_style.leftPadding = 0.
|
scene_style.leftPadding = 0.
|
||||||
scene_style.spaceAfter = 18.
|
scene_style.spaceAfter = 18.
|
||||||
line_style = getSampleStyleSheet()['Normal']
|
line_style = getSampleStyleSheet()['Normal']
|
||||||
line_style.fontName = 'Futura'
|
line_style.fontName = font_name
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
table_style = [('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
table_style = [('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ from reportlab.platypus import Paragraph
|
|||||||
|
|
||||||
from .__init__ import GRect
|
from .__init__ import GRect
|
||||||
|
|
||||||
from ptulsconv.broadcast_timecode import TimecodeFormat
|
from ptulsconv.broadcast_timecode import TimecodeFormat, footage_to_frame_count
|
||||||
from ptulsconv.docparser.adr_entity import ADRLine
|
from ptulsconv.docparser.adr_entity import ADRLine
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
font_name = 'Helvetica'
|
||||||
|
|
||||||
def draw_header_block(canvas, rect, record: ADRLine):
|
def draw_header_block(canvas, rect, record: ADRLine):
|
||||||
rect.draw_text_cell(canvas, record.cue_number, "Helvetica", 44, vertical_align='m')
|
rect.draw_text_cell(canvas, record.cue_number, "Helvetica", 44, vertical_align='m')
|
||||||
@@ -23,19 +24,19 @@ def draw_header_block(canvas, rect, record: ADRLine):
|
|||||||
|
|
||||||
def draw_character_row(canvas, rect, record: ADRLine):
|
def draw_character_row(canvas, rect, record: ADRLine):
|
||||||
label_frame, value_frame = rect.split_x(1.25 * inch)
|
label_frame, value_frame = rect.split_x(1.25 * inch)
|
||||||
label_frame.draw_text_cell(canvas, "CHARACTER", "Futura", 10, force_baseline=9.)
|
label_frame.draw_text_cell(canvas, "CHARACTER", font_name, 10, force_baseline=9.)
|
||||||
line = "%s / %s" % (record.character_id, record.character_name)
|
line = "%s / %s" % (record.character_id, record.character_name)
|
||||||
if record.actor_name is not None:
|
if record.actor_name is not None:
|
||||||
line = line + " / " + record.actor_name
|
line = line + " / " + record.actor_name
|
||||||
value_frame.draw_text_cell(canvas, line, "Futura", 12, force_baseline=9.)
|
value_frame.draw_text_cell(canvas, line, font_name, 12, force_baseline=9.)
|
||||||
rect.draw_border(canvas, ['min_y', 'max_y'])
|
rect.draw_border(canvas, ['min_y', 'max_y'])
|
||||||
|
|
||||||
|
|
||||||
def draw_cue_number_block(canvas, rect, record: ADRLine):
|
def draw_cue_number_block(canvas, rect, record: ADRLine):
|
||||||
(label_frame, number_frame,), aux_frame = rect.divide_y([0.20 * inch, 0.375 * inch], direction='d')
|
(label_frame, number_frame,), aux_frame = rect.divide_y([0.20 * inch, 0.375 * inch], direction='d')
|
||||||
label_frame.draw_text_cell(canvas, "CUE NUMBER", "Futura", 10,
|
label_frame.draw_text_cell(canvas, "CUE NUMBER", font_name, 10,
|
||||||
inset_y=5., vertical_align='t')
|
inset_y=5., vertical_align='t')
|
||||||
number_frame.draw_text_cell(canvas, record.cue_number, "Futura", 14,
|
number_frame.draw_text_cell(canvas, record.cue_number, font_name, 14,
|
||||||
inset_x=10., inset_y=2., draw_baseline=True)
|
inset_x=10., inset_y=2., draw_baseline=True)
|
||||||
|
|
||||||
tags = {'tv': 'TV',
|
tags = {'tv': 'TV',
|
||||||
@@ -49,7 +50,7 @@ def draw_cue_number_block(canvas, rect, record: ADRLine):
|
|||||||
if getattr(record, key):
|
if getattr(record, key):
|
||||||
tag_field = tag_field + tags[key] + " "
|
tag_field = tag_field + tags[key] + " "
|
||||||
|
|
||||||
aux_frame.draw_text_cell(canvas, tag_field, "Futura", 10,
|
aux_frame.draw_text_cell(canvas, tag_field, font_name, 10,
|
||||||
inset_x=10., inset_y=2., vertical_align='t')
|
inset_x=10., inset_y=2., vertical_align='t')
|
||||||
rect.draw_border(canvas, 'max_x')
|
rect.draw_border(canvas, 'max_x')
|
||||||
|
|
||||||
@@ -58,13 +59,13 @@ def draw_timecode_block(canvas, rect, record: ADRLine, tc_display_format: Timeco
|
|||||||
(in_label_frame, in_frame, out_label_frame, out_frame), _ = rect.divide_y(
|
(in_label_frame, in_frame, out_label_frame, out_frame), _ = rect.divide_y(
|
||||||
[0.20 * inch, 0.25 * inch, 0.20 * inch, 0.25 * inch], direction='d')
|
[0.20 * inch, 0.25 * inch, 0.20 * inch, 0.25 * inch], direction='d')
|
||||||
|
|
||||||
in_label_frame.draw_text_cell(canvas, "IN", "Futura", 10,
|
in_label_frame.draw_text_cell(canvas, "IN", font_name, 10,
|
||||||
vertical_align='t', inset_y=5., inset_x=5.)
|
vertical_align='t', inset_y=5., inset_x=5.)
|
||||||
in_frame.draw_text_cell(canvas, tc_display_format.seconds_to_smpte(record.start), "Futura", 14,
|
in_frame.draw_text_cell(canvas, tc_display_format.seconds_to_smpte(record.start), font_name, 14,
|
||||||
inset_x=10., inset_y=2., draw_baseline=True)
|
inset_x=10., inset_y=2., draw_baseline=True)
|
||||||
out_label_frame.draw_text_cell(canvas, "OUT", "Futura", 10,
|
out_label_frame.draw_text_cell(canvas, "OUT", font_name, 10,
|
||||||
vertical_align='t', inset_y=5., inset_x=5.)
|
vertical_align='t', inset_y=5., inset_x=5.)
|
||||||
out_frame.draw_text_cell(canvas, tc_display_format.seconds_to_smpte(record.finish), "Futura", 14,
|
out_frame.draw_text_cell(canvas, tc_display_format.seconds_to_smpte(record.finish), font_name, 14,
|
||||||
inset_x=10., inset_y=2., draw_baseline=True)
|
inset_x=10., inset_y=2., draw_baseline=True)
|
||||||
|
|
||||||
rect.draw_border(canvas, 'max_x')
|
rect.draw_border(canvas, 'max_x')
|
||||||
@@ -75,16 +76,16 @@ def draw_reason_block(canvas, rect, record: ADRLine):
|
|||||||
reason_label, reason_value = reason_cell.split_x(.75 * inch)
|
reason_label, reason_value = reason_cell.split_x(.75 * inch)
|
||||||
notes_label, notes_value = notes_cell.split_x(.75 * inch)
|
notes_label, notes_value = notes_cell.split_x(.75 * inch)
|
||||||
|
|
||||||
reason_label.draw_text_cell(canvas, "Reason:", "Futura", 12,
|
reason_label.draw_text_cell(canvas, "Reason:", font_name, 12,
|
||||||
inset_x=5., inset_y=5., vertical_align='b')
|
inset_x=5., inset_y=5., vertical_align='b')
|
||||||
reason_value.draw_text_cell(canvas, record.reason or "", "Futura", 12,
|
reason_value.draw_text_cell(canvas, record.reason or "", font_name, 12,
|
||||||
inset_x=5., inset_y=5., draw_baseline=True,
|
inset_x=5., inset_y=5., draw_baseline=True,
|
||||||
vertical_align='b')
|
vertical_align='b')
|
||||||
notes_label.draw_text_cell(canvas, "Note:", "Futura", 12,
|
notes_label.draw_text_cell(canvas, "Note:", font_name, 12,
|
||||||
inset_x=5., inset_y=5., vertical_align='t')
|
inset_x=5., inset_y=5., vertical_align='t')
|
||||||
|
|
||||||
style = getSampleStyleSheet()['BodyText']
|
style = getSampleStyleSheet()['BodyText']
|
||||||
style.fontName = 'Futura'
|
style.fontName = font_name
|
||||||
style.fontSize = 12
|
style.fontSize = 12
|
||||||
style.leading = 14
|
style.leading = 14
|
||||||
|
|
||||||
@@ -96,10 +97,10 @@ def draw_reason_block(canvas, rect, record: ADRLine):
|
|||||||
def draw_prompt(canvas, rect, prompt=""):
|
def draw_prompt(canvas, rect, prompt=""):
|
||||||
label, block = rect.split_y(0.20 * inch, direction='d')
|
label, block = rect.split_y(0.20 * inch, direction='d')
|
||||||
|
|
||||||
label.draw_text_cell(canvas, "PROMPT", "Futura", 10, vertical_align='t', inset_y=5., inset_x=0.)
|
label.draw_text_cell(canvas, "PROMPT", font_name, 10, vertical_align='t', inset_y=5., inset_x=0.)
|
||||||
|
|
||||||
style = getSampleStyleSheet()['BodyText']
|
style = getSampleStyleSheet()['BodyText']
|
||||||
style.fontName = 'Futura'
|
style.fontName = font_name
|
||||||
style.fontSize = 14
|
style.fontSize = 14
|
||||||
|
|
||||||
style.leading = 24
|
style.leading = 24
|
||||||
@@ -116,10 +117,10 @@ def draw_prompt(canvas, rect, prompt=""):
|
|||||||
def draw_notes(canvas, rect, note=""):
|
def draw_notes(canvas, rect, note=""):
|
||||||
label, block = rect.split_y(0.20 * inch, direction='d')
|
label, block = rect.split_y(0.20 * inch, direction='d')
|
||||||
|
|
||||||
label.draw_text_cell(canvas, "NOTES", "Futura", 10, vertical_align='t', inset_y=5., inset_x=0.)
|
label.draw_text_cell(canvas, "NOTES", font_name, 10, vertical_align='t', inset_y=5., inset_x=0.)
|
||||||
|
|
||||||
style = getSampleStyleSheet()['BodyText']
|
style = getSampleStyleSheet()['BodyText']
|
||||||
style.fontName = 'Futura'
|
style.fontName = font_name
|
||||||
style.fontSize = 14
|
style.fontSize = 14
|
||||||
style.leading = 24
|
style.leading = 24
|
||||||
|
|
||||||
@@ -175,12 +176,12 @@ def draw_aux_block(canvas, rect, recording_time_sec_this_line, recording_time_se
|
|||||||
lines, last_line = content_rect.divide_y([12., 12., 24., 24., 24., 24.], direction='d')
|
lines, last_line = content_rect.divide_y([12., 12., 24., 24., 24., 24.], direction='d')
|
||||||
|
|
||||||
lines[0].draw_text_cell(canvas,
|
lines[0].draw_text_cell(canvas,
|
||||||
"Time for this line: %.1f mins" % (recording_time_sec_this_line / 60.), "Futura", 9.)
|
"Time for this line: %.1f mins" % (recording_time_sec_this_line / 60.), font_name, 9.)
|
||||||
lines[1].draw_text_cell(canvas, "Running time: %03.1f mins" % (recording_time_sec / 60.), "Futura", 9.)
|
lines[1].draw_text_cell(canvas, "Running time: %03.1f mins" % (recording_time_sec / 60.), font_name, 9.)
|
||||||
lines[2].draw_text_cell(canvas, "Actual Start: ______________", "Futura", 9., vertical_align='b')
|
lines[2].draw_text_cell(canvas, "Actual Start: ______________", font_name, 9., vertical_align='b')
|
||||||
lines[3].draw_text_cell(canvas, "Record Date: ______________", "Futura", 9., vertical_align='b')
|
lines[3].draw_text_cell(canvas, "Record Date: ______________", font_name, 9., vertical_align='b')
|
||||||
lines[4].draw_text_cell(canvas, "Engineer: ______________", "Futura", 9., vertical_align='b')
|
lines[4].draw_text_cell(canvas, "Engineer: ______________", font_name, 9., vertical_align='b')
|
||||||
lines[5].draw_text_cell(canvas, "Location: ______________", "Futura", 9., vertical_align='b')
|
lines[5].draw_text_cell(canvas, "Location: ______________", font_name, 9., vertical_align='b')
|
||||||
|
|
||||||
|
|
||||||
def draw_footer(canvas, rect, record: ADRLine, report_date, line_no, total_lines):
|
def draw_footer(canvas, rect, record: ADRLine, report_date, line_no, total_lines):
|
||||||
@@ -189,7 +190,7 @@ def draw_footer(canvas, rect, record: ADRLine, report_date, line_no, total_lines
|
|||||||
spotting_name = [record.spot] if record.spot is not None else []
|
spotting_name = [record.spot] if record.spot is not None else []
|
||||||
pages_s = ["Line %i of %i" % (line_no, total_lines)]
|
pages_s = ["Line %i of %i" % (line_no, total_lines)]
|
||||||
footer_s = " - ".join(report_date_s + spotting_name + pages_s)
|
footer_s = " - ".join(report_date_s + spotting_name + pages_s)
|
||||||
rect.draw_text_cell(canvas, footer_s, font_name="Futura", font_size=10., inset_y=2.)
|
rect.draw_text_cell(canvas, footer_s, font_name=font_name, font_size=10., inset_y=2.)
|
||||||
|
|
||||||
|
|
||||||
def create_report_for_character(records, report_date, tc_display_format: TimecodeFormat):
|
def create_report_for_character(records, report_date, tc_display_format: TimecodeFormat):
|
||||||
@@ -200,7 +201,7 @@ def create_report_for_character(records, report_date, tc_display_format: Timecod
|
|||||||
assert outfile is not None
|
assert outfile is not None
|
||||||
assert outfile[-4:] == '.pdf', "Output file must have 'pdf' extension!"
|
assert outfile[-4:] == '.pdf', "Output file must have 'pdf' extension!"
|
||||||
|
|
||||||
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
#pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
||||||
|
|
||||||
page: GRect = GRect(0, 0, letter[0], letter[1])
|
page: GRect = GRect(0, 0, letter[0], letter[1])
|
||||||
page = page.inset(inch * 0.5)
|
page = page.inset(inch * 0.5)
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ from ..broadcast_timecode import TimecodeFormat
|
|||||||
from ..docparser.adr_entity import ADRLine
|
from ..docparser.adr_entity import ADRLine
|
||||||
|
|
||||||
|
|
||||||
def output_report(lines: List[ADRLine], tc_display_format: TimecodeFormat):
|
def output_report(lines: List[ADRLine], tc_display_format: TimecodeFormat, font_name="Helvetica"):
|
||||||
character_numbers = set([n.character_id for n in lines])
|
character_numbers = set([n.character_id for n in lines])
|
||||||
pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
#pdfmetrics.registerFont(TTFont('Futura', 'Futura.ttc'))
|
||||||
|
|
||||||
for n in character_numbers:
|
for n in character_numbers:
|
||||||
char_lines = [line for line in lines if not line.omitted and line.character_id == n]
|
char_lines = [line for line in lines if not line.omitted and line.character_id == n]
|
||||||
@@ -39,7 +39,7 @@ def output_report(lines: List[ADRLine], tc_display_format: TimecodeFormat):
|
|||||||
story = []
|
story = []
|
||||||
|
|
||||||
prompt_style = getSampleStyleSheet()['Normal']
|
prompt_style = getSampleStyleSheet()['Normal']
|
||||||
prompt_style.fontName = 'Futura'
|
prompt_style.fontName = font_name
|
||||||
prompt_style.fontSize = 18.
|
prompt_style.fontSize = 18.
|
||||||
|
|
||||||
prompt_style.leading = 24.
|
prompt_style.leading = 24.
|
||||||
@@ -47,7 +47,7 @@ def output_report(lines: List[ADRLine], tc_display_format: TimecodeFormat):
|
|||||||
prompt_style.rightIndent = 1.5 * inch
|
prompt_style.rightIndent = 1.5 * inch
|
||||||
|
|
||||||
number_style = getSampleStyleSheet()['Normal']
|
number_style = getSampleStyleSheet()['Normal']
|
||||||
number_style.fontName = 'Futura'
|
number_style.fontName = font_name
|
||||||
number_style.fontSize = 14
|
number_style.fontSize = 14
|
||||||
|
|
||||||
number_style.leading = 24
|
number_style.leading = 24
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ class TestBroadcastTimecode(unittest.TestCase):
|
|||||||
Setp through every text file in export_cases and make sure it can
|
Setp through every text file in export_cases and make sure it can
|
||||||
be converted into PDF docs without throwing an error
|
be converted into PDF docs without throwing an error
|
||||||
"""
|
"""
|
||||||
for path in glob.glob(os.path.dirname(__file__) + "/../export_cases/Robin Hood Spotting.txt"):
|
files = [os.path.dirname(__file__) + "/../export_cases/Robin Hood Spotting.txt"]
|
||||||
|
#files.append(os.path.dirname(__file__) + "/../export_cases/Robin Hood Spotting2.txt")
|
||||||
|
for path in files:
|
||||||
tempdir = tempfile.TemporaryDirectory()
|
tempdir = tempfile.TemporaryDirectory()
|
||||||
os.chdir(tempdir.name)
|
os.chdir(tempdir.name)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user