mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
style: Format code with consistent quotes and line breaks
This commit is contained in:
parent
c6e544750b
commit
8935c87d7a
1 changed files with 33 additions and 28 deletions
|
@ -5,31 +5,31 @@ Reads the Glass_TTY_VT220.ttf font and creates an SVG with the word "aider"
|
||||||
in terminal green (#14b014) on a white background.
|
in terminal green (#14b014) on a white background.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import argparse
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def generate_svg_with_embedded_font(font_path, text="aider", color="#14b014", output_path=None):
|
def generate_svg_with_embedded_font(font_path, text="aider", color="#14b014", output_path=None):
|
||||||
"""
|
"""
|
||||||
Generate an SVG with embedded TTF font data.
|
Generate an SVG with embedded TTF font data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
font_path (str): Path to the TTF font file
|
font_path (str): Path to the TTF font file
|
||||||
text (str): Text to display in the SVG
|
text (str): Text to display in the SVG
|
||||||
color (str): Color of the text (hex format)
|
color (str): Color of the text (hex format)
|
||||||
output_path (str, optional): Path to save the SVG file, if None prints to stdout
|
output_path (str, optional): Path to save the SVG file, if None prints to stdout
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: The SVG content
|
str: The SVG content
|
||||||
"""
|
"""
|
||||||
# Read the font file and encode it as base64
|
# Read the font file and encode it as base64
|
||||||
with open(font_path, 'rb') as f:
|
with open(font_path, "rb") as f:
|
||||||
font_data = f.read()
|
font_data = f.read()
|
||||||
|
|
||||||
font_base64 = base64.b64encode(font_data).decode('utf-8')
|
font_base64 = base64.b64encode(font_data).decode("utf-8")
|
||||||
|
|
||||||
# Calculate SVG dimensions based on text length
|
# Calculate SVG dimensions based on text length
|
||||||
# These values can be adjusted to modify the appearance
|
# These values can be adjusted to modify the appearance
|
||||||
char_width = 40
|
char_width = 40
|
||||||
|
@ -37,7 +37,7 @@ def generate_svg_with_embedded_font(font_path, text="aider", color="#14b014", ou
|
||||||
height = 100
|
height = 100
|
||||||
text_x = 20
|
text_x = 20
|
||||||
text_y = 65
|
text_y = 65
|
||||||
|
|
||||||
# Create the SVG with embedded font
|
# Create the SVG with embedded font
|
||||||
svg = f"""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
svg = f"""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<svg width="{width}" height="{height}" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
|
<svg width="{width}" height="{height}" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
@ -60,46 +60,51 @@ def generate_svg_with_embedded_font(font_path, text="aider", color="#14b014", ou
|
||||||
<rect class="background" width="{width}" height="{height}" x="0" y="0" />
|
<rect class="background" width="{width}" height="{height}" x="0" y="0" />
|
||||||
<text x="{text_x}" y="{text_y}" class="logo-text">{text}</text>
|
<text x="{text_x}" y="{text_y}" class="logo-text">{text}</text>
|
||||||
</svg>"""
|
</svg>"""
|
||||||
|
|
||||||
# Save to file or print to stdout
|
# Save to file or print to stdout
|
||||||
if output_path:
|
if output_path:
|
||||||
with open(output_path, 'w') as f:
|
with open(output_path, "w") as f:
|
||||||
f.write(svg)
|
f.write(svg)
|
||||||
print(f"SVG logo saved to {output_path}")
|
print(f"SVG logo saved to {output_path}")
|
||||||
|
|
||||||
return svg
|
return svg
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='Generate an SVG logo with embedded font')
|
parser = argparse.ArgumentParser(description="Generate an SVG logo with embedded font")
|
||||||
parser.add_argument('--font', type=str, default='aider/website/assets/Glass_TTY_VT220.ttf',
|
parser.add_argument(
|
||||||
help='Path to the TTF font file')
|
"--font",
|
||||||
parser.add_argument('--text', type=str, default='aider',
|
type=str,
|
||||||
help='Text to display in the SVG')
|
default="aider/website/assets/Glass_TTY_VT220.ttf",
|
||||||
parser.add_argument('--color', type=str, default='#14b014',
|
help="Path to the TTF font file",
|
||||||
help='Color of the text (hex format)')
|
)
|
||||||
parser.add_argument('--output', type=str, default='aider/website/assets/logo.svg',
|
parser.add_argument("--text", type=str, default="aider", help="Text to display in the SVG")
|
||||||
help='Path to save the SVG file')
|
parser.add_argument(
|
||||||
|
"--color", type=str, default="#14b014", help="Color of the text (hex format)"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output",
|
||||||
|
type=str,
|
||||||
|
default="aider/website/assets/logo.svg",
|
||||||
|
help="Path to save the SVG file",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Make sure the font file exists
|
# Make sure the font file exists
|
||||||
if not os.path.exists(args.font):
|
if not os.path.exists(args.font):
|
||||||
print(f"Error: Font file not found at {args.font}")
|
print(f"Error: Font file not found at {args.font}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create output directory if it doesn't exist
|
# Create output directory if it doesn't exist
|
||||||
if args.output:
|
if args.output:
|
||||||
output_dir = os.path.dirname(args.output)
|
output_dir = os.path.dirname(args.output)
|
||||||
if output_dir and not os.path.exists(output_dir):
|
if output_dir and not os.path.exists(output_dir):
|
||||||
os.makedirs(output_dir)
|
os.makedirs(output_dir)
|
||||||
|
|
||||||
# Generate the SVG
|
# Generate the SVG
|
||||||
generate_svg_with_embedded_font(
|
generate_svg_with_embedded_font(
|
||||||
args.font,
|
args.font, text=args.text, color=args.color, output_path=args.output
|
||||||
text=args.text,
|
|
||||||
color=args.color,
|
|
||||||
output_path=args.output
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue