Customize Fonts with the Service Chat SDK
You can customize three font settings used throughout the Service Chat SDK interface:
Font Setting | Default Value | Samples Uses in the SDK |
---|---|---|
SCFontWeightLight | Helvetica Neue - Light | Knowledge article cell summary, Case Management field text, Case Management submit success view, content of error messages |
SCFontWeightRegular | Helvetica Neue | Navigation bar, Chat text, Knowledge data category cell in detail view, Knowledge "show more" article footer, Knowledge "show more" button cell |
SCFontWeightBold | Helvetica Neue - Semibold | Knowledge category headers, Knowledge article cell title, Case Management field labels, Case Management submit button, title of error messages |
To configure your app to use different fonts:
-
Add new fonts to your Xcode project.
Any new fonts must be added as a resource to your Xcode project. When adding, be sure to select Copy items if needed.
-
Add new fonts to your project target.
For each new font, add it to your project target under Target Membership.
-
Add the font to your app's Info.plist.
You'll need to add all new fonts into a string array. Each string element of the array must be the name of each font resource file.
If you're viewing your Info.plist as a Property List, add an Array named Fonts provided by application.
If you're viewing your Info.plist as Source Code, add an array named UIAppFonts. For example:
<key>UIAppFonts</key> <array> <string>MyCustomFont1.ttf</string> <string>MyCustomFont2.ttf</string> <string>MyCustomFont3.ttf</string> </array>
-
Customize any of the Service Chat
SDK font values using SCAppearanceConfiguration.
To customize the fonts, create an SCAppearanceConfiguration instance, set the font descriptor for each font setting you want to change, and store the SCAppearanceConfiguration instance in the appearanceConfiguration property of the ServiceCloud shared instance.
Swift Example:
// Create appearance configuration instance let config = SCAppearanceConfiguration() // Customize font let descriptor = UIFontDescriptor(fontAttributes: [UIFontDescriptor.AttributeName.family : "Proxima Nova"]) config.setFontDescriptor(descriptor, fontFileName: "ProximaNova-Light.otf", forWeight: SCFontWeightLight) // Add other customizations here... // Save configuration instance ServiceCloud.shared().appearanceConfiguration = config
Objective-C Example:
// Create appearance configuration instance SCAppearanceConfiguration *config = [SCAppearanceConfiguration new]; // Customize font UIFontDescriptor *descriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:@{ UIFontDescriptorFamilyAttribute: @"Proxima Nova", UIFontDescriptorFaceAttribute: @"Light" }]; [config setFontDescriptor:descriptor fontFileName:@"ProximaNova-Light.otf" forWeight:SCFontWeightLight]; // Add other customizations here... // Save configuration instance [SCServiceCloud sharedInstance].appearanceConfiguration = config;
Be sure to use the exact font descriptor attribute name and font file name for your custom font.