FileMaker Copyfitting with JavaScript
In this post I will demonstrate a FileMaker Copyfitting technique using HTML5 canvas and JavaScript. Watch the tutorial and download the demo.
What is Copyfitting?
Copyfitting is automatically adjusting the font size of a piece of text where the lengths of the text may vary.
The Problem – One Size Doesn’t Fit All
In my years in the print industry as a graphic designer and pre-press professional, I dealt with this issue a lot. In the case of generating something like business cards or shipping labels, you may have names and addresses of various length. Some may be short and some may be very long. When designing these items it is best to design for your worst case scenario, in other words, your longest data. However, this basic rule doesn’t always yield the best result. Your longest data may look great but when you get to a shorter instance, it may need to be adjusted manually. This can be very time consuming and costly.
The Solution – FileMaker Copyfitting to the Rescue
Using HTML5 we have access to the canvas element. Accessing the canvas element with JavaScript we have the ability to measure the text extent and then compare that measurement to the size of the text area in FileMaker. Making this function recursive allows it to perform in a loop until it reaches a font size that fits the text area. By supplying the function with minimum and maximum font preferences, this function can be used to enlarge smaller fonts or to reduce larger fonts.
In the video below I will demonstrate how I implemented this great technique in FileMaker. A free sample file is included at the end of this post to help you get started.
[vc_separator]
Watch The Tutorial
Thanks for stoping by to read this post. Feel free to comment on what you think of this technique.
As always, keep pushing the limits of what FileMaker can do!
Best regards,
Aaron Giard
Gregor Beuster
Thank you so much for this… another great use case for JavaScript!
Pingback: Client Relations, Weighing Scale, and FileMaker Copyfitting - FileMakerProGurus
Pingback: FileMaker Copyfitting with JavaScript - Cirrus ...
alistair campbell
hi Aron
i would like a copy of the database
but the download link is not working for me.
Could you please check download link
Thanks
Alistair
Aaron Giard
Hi Alistair,
I have sent you an email. I hope that helps. Thanks for viewing!
-Aaron Giard
Hollister deals
I’m truly enjoying the design and layout of your site. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Exceptional work!
Shawn A. Krueger
Aaron, very cool demo. Coming from the print world, I have longed for copyfitting in FileMaker.
I was having a little issue with the demo file. I kept getting the message:
“The file “Cirrus_Logic_Copyfitting_Demo.fmp12” could not be opened. Either the host is not available, or the file is not available on that host.”
when trying to process the records.
Turns out, it didn’t like having more than 1 version of FileMaker open. Once I quit the other one, the issue went away.
But that message got me thinking… and it turns out that it also does not work if you change the file name. A simple fix is to replace the literal file name in the off-layout JavaScript text block with “{{FileName}}” – without the quotes.
Thanks for sharing!
-Shawn
Aaron Giard
Hi Shawn,
Yes, your issue is common when using the FMPURL method if you have more than one version of FileMaker. I wish there were a way to target the version, but I digress. I also agree that making the filename modular would be the best way to go, although I did not do that for this demo.
I am glad you are enjoying the file. I hope you find it useful. If you use it in production for anything, I’d love to hear about it.
Thanks for viewing!
-Aaron
eebest8 fiverr
“You really saved my skin with this information. Thanks!”