From 3df07d1628689f7a8d3c49070d4ca85d10d300f7 Mon Sep 17 00:00:00 2001 From: Pavel Petrenko Date: Thu, 1 Aug 2024 12:17:55 +0300 Subject: [PATCH] Created an extension for monospaced font Signed-off-by: Pavel Petrenko --- .../Theme/Extensions/UIFont+monospaced.swift | 18 ++++++++++++++++++ iphone/Maps/Maps.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 22 insertions(+) create mode 100644 iphone/Maps/Core/Theme/Extensions/UIFont+monospaced.swift diff --git a/iphone/Maps/Core/Theme/Extensions/UIFont+monospaced.swift b/iphone/Maps/Core/Theme/Extensions/UIFont+monospaced.swift new file mode 100644 index 0000000000..89990edbc6 --- /dev/null +++ b/iphone/Maps/Core/Theme/Extensions/UIFont+monospaced.swift @@ -0,0 +1,18 @@ +import UIKit + +extension UIFont { + + /// Creates a UIFont object with monospaced numbers keeping other font descriptors like size and weight + @objc var monospaced: UIFont { + let attributes: [UIFontDescriptor.AttributeName: Any] = [ + .featureSettings: [ + [ + UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType, + UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector + ] + ] + ] + let monospacedNumbersFontDescriptor = fontDescriptor.addingAttributes(attributes) + return UIFont(descriptor: monospacedNumbersFontDescriptor, size: pointSize) + } +} diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 17f44e9019..2a0165961d 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 039371B62C5B68CD00708377 /* UIFont+monospaced.swift in Sources */ = {isa = PBXBuildFile; fileRef = 039371B52C5B68CD00708377 /* UIFont+monospaced.swift */; }; 1DFA2F6A20D3B57400FB2C66 /* UIColor+PartnerColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DFA2F6920D3B57400FB2C66 /* UIColor+PartnerColor.m */; }; 3304306D21D4EAFB00317CA3 /* SearchCategoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3304306C21D4EAFB00317CA3 /* SearchCategoryCell.swift */; }; 33046832219C57180041F3A8 /* CategorySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33046831219C57180041F3A8 /* CategorySettingsViewController.swift */; }; @@ -738,6 +739,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 039371B52C5B68CD00708377 /* UIFont+monospaced.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+monospaced.swift"; sourceTree = ""; }; 1D3623240D0F684500981E51 /* MapsAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapsAppDelegate.h; sourceTree = ""; }; 1D3623250D0F684500981E51 /* MapsAppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = MapsAppDelegate.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 1DFA2F6820D3B52F00FB2C66 /* UIColor+PartnerColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIColor+PartnerColor.h"; sourceTree = ""; }; @@ -2754,6 +2756,7 @@ 993DF0D223F6BDB000AC231A /* UIColor+rgba.swift */, AC79C8912A65AB9500594C24 /* UIColor+hexString.swift */, 993DF0D323F6BDB000AC231A /* UIColor+image.swift */, + 039371B52C5B68CD00708377 /* UIFont+monospaced.swift */, ); path = Extensions; sourceTree = ""; @@ -4588,6 +4591,7 @@ 993DF10523F6BDB100AC231A /* UINavigationItem+styleName.swift in Sources */, 9977E69C247BFB510073780C /* SearchTextField.swift in Sources */, 4726254921C27D4B00C7BAAD /* PlacePageDescriptionViewController.swift in Sources */, + 039371B62C5B68CD00708377 /* UIFont+monospaced.swift in Sources */, 447DB4BC2BA78282000DF4C2 /* MWMOsmReauthAlert.mm in Sources */, 340475711E081A4600C92850 /* MWMSettings.mm in Sources */, 33046832219C57180041F3A8 /* CategorySettingsViewController.swift in Sources */,