drawbot
drawbot copied to clipboard
Function to get current fontSize()
Hello,
Given there are utility functions like fontLineHeight() and fontFilePath() I wonder if there’s a possibility for a way to get current fontSize property of drawBot. Perhaps it could get returned from fontSize() with no argument supplied?
I though of reverse engeneering fontLineHeight() as that is tied to current fontSize but seems too convoluted.
Use-case: I have a bunch of computation intensive for loops to find best-fit font-size using binary search and I‘d like to check if current fontSize is already set appropriately before running the algorithm.
Thank you.
mm, I see
the difference between fontLineHeight() and fontSize(value) is that everything is related to that value you provide while setting the fontSize and the lineHeight is different for each font, depending on font.
In my experience scale works better to fit a text then using fontSize. Calculate the bounding box of your text and scale it along the box you want to fit it in.
@typemytype Thanks for your reply.
Scale is a good option, but sometimes I also use the binary search algorithm for running text so that’s why I need to use fontSize to look for text reflow/line breaks.
All in all I just think it would be a reasonable addition to DrawBot API as there are copious functions to get parameters like fontFilePath() and fontNumber() but oddly enough there is none for fontSize().