potential fix for font scaling
This commit is contained in:
@ -84,9 +84,32 @@ def markdown2html(markdown, basepath, re_render, resources, viewport_width, font
|
||||
|
||||
# FIXME: highlight the code using Sublime's syntax
|
||||
|
||||
# Apply font scaling via inline styles
|
||||
if font_scale != 1.0:
|
||||
BASE_PX_SIZE = 15 # Base font size in pixels
|
||||
TAG_MULTIPLIERS = {
|
||||
'p': 1.0,
|
||||
'li': 1.0,
|
||||
'h1': 2.0,
|
||||
'h2': 1.8,
|
||||
'h3': 1.6,
|
||||
'h4': 1.4,
|
||||
'h5': 1.2,
|
||||
'h6': 1.1,
|
||||
'blockquote': 1.0,
|
||||
'code': 0.9, # Assuming code is slightly smaller
|
||||
# Add other tags as needed, e.g., 'td', 'th' for tables
|
||||
}
|
||||
|
||||
# Find all tags that we want to scale
|
||||
for element in soup.find_all(list(TAG_MULTIPLIERS.keys())):
|
||||
multiplier = TAG_MULTIPLIERS.get(element.name, 1.0)
|
||||
target_size = round(BASE_PX_SIZE * multiplier * font_scale)
|
||||
# Simple style setting (overwrites existing inline style if any)
|
||||
# A more robust solution would parse and merge existing styles
|
||||
element['style'] = f"font-size: {target_size}px;"
|
||||
|
||||
# FIXME: report that ST doesn't support <br/> but does work with <br />... WTF?
|
||||
# Add font scaling CSS rule - REMOVED as MiniHTML doesn't support transform/font-size scaling this way
|
||||
# font_scale_css = "body {{ transform: scale({}); transform-origin: top left; }}\n".format(font_scale)
|
||||
stylesheet = resources["stylesheet"] # Use only the base stylesheet
|
||||
|
||||
return "<style>\n{}\n</style>\n\n{}".format(stylesheet, soup).replace(
|
||||
|
||||
Reference in New Issue
Block a user