Add fontname option
Use this option value both in the graph and as font family in HTML.
This commit is contained in:
parent
66fdfc7374
commit
5aac2ba8f3
@ -41,6 +41,7 @@ class Metadata:
|
||||
|
||||
@dataclass
|
||||
class Options:
|
||||
fontname: PlainText = 'arial'
|
||||
color_mode: ColorMode = 'SHORT'
|
||||
mini_bom_mode: bool = True
|
||||
|
||||
|
||||
@ -93,18 +93,17 @@ class Harness:
|
||||
dot = Graph()
|
||||
dot.body.append(f'// Graph generated by {APP_NAME} {__version__}')
|
||||
dot.body.append(f'// {APP_URL}')
|
||||
font = 'arial'
|
||||
dot.attr('graph', rankdir='LR',
|
||||
ranksep='2',
|
||||
bgcolor='white',
|
||||
nodesep='0.33',
|
||||
fontname=font)
|
||||
fontname=self.options.fontname)
|
||||
dot.attr('node', shape='record',
|
||||
style='filled',
|
||||
fillcolor='white',
|
||||
fontname=font)
|
||||
fontname=self.options.fontname)
|
||||
dot.attr('edge', style='bold',
|
||||
fontname=font)
|
||||
fontname=self.options.fontname)
|
||||
|
||||
# prepare ports on connectors depending on which side they will connect
|
||||
for _, cable in self.cables.items():
|
||||
@ -372,7 +371,7 @@ class Harness:
|
||||
with open_file_write(f'{filename}.bom.tsv') as file:
|
||||
file.write(tuplelist2tsv(bomlist))
|
||||
# HTML output
|
||||
generate_html_output(filename, bomlist, self.metadata)
|
||||
generate_html_output(filename, bomlist, self.metadata, self.options)
|
||||
|
||||
def bom(self):
|
||||
if not self._bom:
|
||||
|
||||
@ -6,17 +6,17 @@ from typing import List, Union
|
||||
import re
|
||||
|
||||
from wireviz import __version__, APP_NAME, APP_URL
|
||||
from wireviz.DataClasses import Metadata
|
||||
from wireviz.DataClasses import Metadata, Options
|
||||
from wireviz.wv_helper import flatten2d, open_file_read, open_file_write
|
||||
|
||||
def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], metadata: Metadata):
|
||||
def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], metadata: Metadata, options: Options):
|
||||
with open_file_write(f'{filename}.html') as file:
|
||||
file.write('<!DOCTYPE html>\n')
|
||||
file.write('<html lang="en"><head>\n')
|
||||
file.write(' <meta charset="UTF-8">\n')
|
||||
file.write(f' <meta name="generator" content="{APP_NAME} {__version__} - {APP_URL}">\n')
|
||||
file.write(f' <title>{metadata.title}</title>\n')
|
||||
file.write('</head><body style="font-family:Arial">\n')
|
||||
file.write(f'</head><body style="font-family:{options.fontname}">\n')
|
||||
|
||||
file.write(f'<h1>{metadata.title}</h1>\n')
|
||||
if metadata.description:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user