Class: Fontist::InstallLocations::SystemLocation
- Inherits:
-
BaseLocation
- Object
- BaseLocation
- Fontist::InstallLocations::SystemLocation
- Defined in:
- lib/fontist/install_locations/system_location.rb
Overview
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
Instance Attribute Summary
Attributes inherited from BaseLocation
Instance Method Summary collapse
-
#base_path ⇒ Pathname
Returns base installation path.
-
#location_type ⇒ Symbol
Returns location type identifier.
-
#permission_warning ⇒ String
Returns warning message about elevated permissions.
-
#requires_elevated_permissions? ⇒ Boolean
System installations always require elevated permissions.
Methods inherited from BaseLocation
#find_fonts, #font_exists?, #font_path, #initialize, #install_font, #uninstall_font
Constructor Details
This class inherits a constructor from Fontist::InstallLocations::BaseLocation
Instance Method Details
#base_path ⇒ Pathname
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
-
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fontist/install_locations/system_location.rb', line 50 def base_path # Check for custom path from config/ENV custom_path = Fontist::Config.system_fonts_path return Pathname.new(File.(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 |
#location_type ⇒ Symbol
Returns location type identifier
38 39 40 |
# File 'lib/fontist/install_locations/system_location.rb', line 38 def location_type :system end |
#permission_warning ⇒ String
Returns warning message about elevated permissions
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fontist/install_locations/system_location.rb', line 80 def <<~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 |
#requires_elevated_permissions? ⇒ Boolean
System installations always require elevated permissions
73 74 75 |
# File 'lib/fontist/install_locations/system_location.rb', line 73 def true end |