MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / registerFont

Function registerFont

packages/core/ui/styling/font.ios.ts:149–171  ·  view source on GitHub ↗
(fontFile: string)

Source from the content-addressed store, hash-verified

147
148export namespace ios {
149 export function registerFont(fontFile: string) {
150 let filePath = path.join(knownFolders.currentApp().path, FONTS_BASE_PATH, fontFile);
151 if (!File.exists(filePath)) {
152 filePath = path.join(knownFolders.currentApp().path, fontFile);
153 }
154 const fontData = NSFileManager.defaultManager.contentsAtPath(filePath);
155 if (!fontData) {
156 throw new Error('Could not load font from: ' + fontFile);
157 }
158 const provider = CGDataProviderCreateWithCFData(fontData);
159 const font = CGFontCreateWithDataProvider(provider);
160
161 if (!font) {
162 throw new Error('Could not load font from: ' + fontFile);
163 }
164
165 const error = new interop.Reference<NSError>();
166 if (!CTFontManagerRegisterGraphicsFont(font, error)) {
167 if (Trace.isEnabled()) {
168 Trace.write('Error occur while registering font: ' + CFErrorCopyDescription(<NSError>error.value), Trace.categories.Error, Trace.messageType.error);
169 }
170 }
171 }
172}
173
174function registerFontsInFolder(fontsFolderPath) {

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
isEnabledMethod · 0.80
writeMethod · 0.65
existsMethod · 0.45

Tested by

no test coverage detected