Syntax
h=fontsize([FS,ds])
Input Parameter
FS : | | default is 16pt on a printout |
ds : | | if true, the font size is adjusted based on the figure size |
Output Parameter
Examples
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, `fontsize`, is designed to adjust the font size of all text elements in a MATLAB figure. It is part of the SolidGeometry library and was introduced in version 5.1.
Input Parameters
- FS: The default font size, set to 16pt for printouts. It can be adjusted based on the figure size if the dynamic size option is enabled.
- ds: A boolean parameter that, when true, adjusts the font size dynamically based on the figure's height.
Output Results
- h: A handle to all text elements whose font size has been adjusted.
Algorithm Steps
- Retrieve the font size (`FS`) from the input parameters, defaulting to 16 if not provided.
- Retrieve the dynamic size flag (`ds`) from the input parameters, defaulting to true if not provided.
- Get the current figure's position using `get(gcf,'Position')`.
- If `ds` is true, adjust `FS` by scaling it with the figure's height (`sc(4)`) relative to a base height of 640.
- Initialize an empty array `h` to store handles to text elements.
- If the number of output arguments is less than 2, proceed to adjust font sizes:
- Find all textboxes (`Textbox` type) and set their font size to `FS`.
- Find all text elements (`Text` type) and set their font size to `FS`.
- Find all axes (`Axes` type), set their font size to `FS`, and set their font angle to italic.
- Store the handles of these elements in `h`.
Algorithm explaination created using ChatGPT on 2025-08-19 01:20. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21