class Fontist::InstallLocations::SystemLocation
System font directory location
This location represents the system-wide font directory, with platform-specific base paths:
macOS (regular): /Library/Fonts/fontist/ macOS (supplementary): /System/Library/Assets*/com_apple_MobileAsset_Font*/{asset}.asset/AssetData/ Linux: /usr/local/share/fonts/fontist/ Windows: %windir%/Fonts/fontist/
## Managed vs Non-Managed
This location is managed when:
-
Using default path with /fontist subdirectory (default behavior)
-
Installing macOS supplementary fonts (always OS-managed)
This location is non-managed when:
-
User sets FONTIST_SYSTEM_FONTS_PATH to system root (e.g., /Library/Fonts)
-
In non-managed mode, fonts are added with unique names to avoid conflicts
## Permissions
This location **always requires elevated permissions** (sudo/admin rights) Shows warning before installation attempts
## Customization
Set via environment variable:
export FONTIST_SYSTEM_FONTS_PATH=/Library/Fonts/fontist
Or via config:
fontist config set system_fonts_path /Library/Fonts/fontist
Public Instance Methods
Source
# File lib/fontist/install_locations/system_location.rb, line 52 def base_path # Check for custom path from config/ENV custom_path = Fontist::Config.system_fonts_path return Pathname.new(File.expand_path(custom_path)) if custom_path # Platform-specific default paths case Fontist::Utils::System.user_os when :macos macos_system_path when :linux Pathname.new("/usr/local/share/fonts").join("fontist") when :windows windows_dir = ENV["windir"] || ENV["SystemRoot"] || "C:/Windows" Pathname.new(windows_dir).join("Fonts/fontist") else raise Fontist::Errors::GeneralError, "Unsupported platform for system font installation: #{Fontist::Utils::System.user_os}" end end
Returns base installation path
Priority:
-
Custom path from
Config.system_fonts_path(if set) -
Platform default + /fontist subdirectory
-
Exception: macOS supplementary fonts use special OS-managed paths
-
@return [Pathname] System font installation directory
Source
# File lib/fontist/install_locations/system_location.rb, line 40 def location_type :system end
Returns location type identifier @return [Symbol] :system
Source
# File lib/fontist/install_locations/system_location.rb, line 82 def permission_warning <<~WARNING โ ๏ธ WARNING: Installing to system font directory This requires root/administrator permissions and may affect your system. Installation will fail if you don't have sufficient permissions. Recommended alternatives: - Use default (fontist): Safe, isolated, no permissions needed - Use --location=user: Install to your user font directory Continue with system installation? (Ctrl+C to cancel) WARNING end
Returns warning message about elevated permissions
@return [String] Warning message
Source
# File lib/fontist/install_locations/system_location.rb, line 75 def requires_elevated_permissions? true end
System installations always require elevated permissions
@return [Boolean] Always true
Protected Instance Methods
Source
# File lib/fontist/install_locations/system_location.rb, line 105 def index @index ||= Fontist::Indexes::SystemIndex.instance end
Returns the SystemIndex instance
This index tracks all fonts installed in system locations
@return [Indexes::SystemIndex] Singleton index instance
Source
# File lib/fontist/install_locations/system_location.rb, line 120 def managed_location? # macOS supplementary fonts are always OS-managed return true if formula.macos_import? # If no custom path, we're using the default managed subdirectory return true unless Fontist::Config.system_fonts_path # If custom path ends with /fontist, it's managed uses_fontist_subdirectory? end
Determines if this location is managed by Fontist
System location is managed if:
-
Installing macOS supplementary font (always OS-managed), OR
-
No custom path set (uses default /fontist subdirectory), OR
-
Custom path ends with โ/fontistโ subdirectory
System location is non-managed if:
-
Custom path points to system root directory (e.g., /Library/Fonts)
@return [Boolean] true if Fontist manages this location