feat: added a work around to attempt to position text to the top right of the image for different fonts/sizes dynamically, while not 100% accurate it's close enough
This commit is contained in:
parent
e02ec82568
commit
fe6a5247bc
25
frame_forge/font_scaler.py
Normal file
25
frame_forge/font_scaler.py
Normal file
@ -0,0 +1,25 @@
|
||||
import math
|
||||
|
||||
|
||||
class FontScaler:
|
||||
def __init__(self, original_font_size=100, original_scale=3.5):
|
||||
self.original_font_size = original_font_size
|
||||
self.original_scale = original_scale
|
||||
|
||||
def calculate_scale_factor(self, desired_font_size):
|
||||
"""Calculate the scale factor based on the desired font size."""
|
||||
return math.log(desired_font_size) / math.log(self.original_font_size)
|
||||
|
||||
def adjust_scale_factor(self, scale_factor, multiplier):
|
||||
"""Adjust the scale factor with a multiplier."""
|
||||
return scale_factor * multiplier
|
||||
|
||||
def scale_font(self, scale_factor):
|
||||
"""Scale the font size based on the original scale and scale factor."""
|
||||
return self.original_scale * scale_factor
|
||||
|
||||
def get_adjusted_scale(self, desired_font_size, multiplier=1.0):
|
||||
"""Get the adjusted font scale based on the desired font size and multiplier."""
|
||||
scale_factor = self.calculate_scale_factor(desired_font_size)
|
||||
adjusted_scale_factor = self.adjust_scale_factor(scale_factor, multiplier)
|
||||
return self.scale_font(adjusted_scale_factor)
|
Loading…
x
Reference in New Issue
Block a user