Category filter

Script to Install Font in macOS devices

Within an organization, you might require special fonts to be distributed for specific users. You might be using these in the documents for customers or while creating presentations. Regardless of the circumstance, getting these fonts installed manually is quite time-consuming, considering the process involves visiting different sites that host the fonts, downloading them, and double-clicking on the downloaded files on each device to install the font. IT admins can utilize the script given below to remotely install the required font on macOS devices using Hexnode’s
Execute Custom Script
action.

You can use the below script to install fonts to Font Book in devices by running a simple command.

Scripting Language – Bash

File extension – .sh

Disclaimer:


The Sample Scripts provided below are adapted from third-party Open-Source sites.

Install fonts to Font Book

Use the below command to make the font available to the logged in user. You can copy either of the font types, True Type Fonts (TTF) or Open Type Fonts (OTF), using this command.

For example, a logged in user ‘User1’ with the font ‘CROCHETPATTERN.ttf’ in the Downloads folder, can use the following command to install it in Font Book.

Ex: cp –R /users/user1/Downloads/CROCHETPATTERN.ttf ~/Library/Fonts/

Alternatively, to make the font available for all existing and newly created users on the system, the font needs to be copied to the system’s font folder.

What happens at the device end?

The font added using the script will be installed on the Mac device, added to the Font Book, and can later be used in text editors. The font can be seen in the All Fonts section of the Font Book.
The font will be added to Font Book of the macOS device.

Notes:

  • The Hexnode agent app requires Full Disk Access for the script to run successfully. It can be granted from the Hexnode UEM portal by configuring a
    PPPC profile
    with the following specifications:
    • Identifier – /Library/Application Support/HexnodeMDM/hexnodeagentd
    • Code requirement – anchor apple generic and identifier "com.hexnode.hexnodeagentd" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = BX6L6CPUN8)
  • Or from the device end:
    • Go to System Settings > Privacy & Security > Full Disk Access.
    • Select hexnodeagentd and provide the admin’s credentials./li>
  • You can choose one of the following locations depending on your needs:
    • /Library/Fonts applies to every user, existing and newly created.
    • ~/Library/Fonts applies to the current user.
    • /Library/User Template/Non_localized/Library/Fonts applies to new users.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.
  • Sample Script Repository