iOS加载动态自定义字体

  NSString *cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;

NSLog(@"源文件目录: %@", cachePath);

NSString * fontPath = [NSString stringWithFormat:@"%@/%@",cachePath, @"xxx.ttf"];

CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]);

CGFontRef customfont = CGFontCreateWithDataProvider(fontDataProvider);

CGDataProviderRelease(fontDataProvider);

NSString *fontName = (__bridge NSString *)CGFontCopyFullName(customfont);

CFErrorRef error;

CTFontManagerRegisterGraphicsFont(customfont, &error);

if (error){

// 为了可以重复注册

CTFontManagerUnregisterGraphicsFont(customfont, &error);

CTFontManagerRegisterGraphicsFont(customfont, &error);

}

CGFontRelease(customfont);

UIFont *font = [UIFont fontWithName:fontName size:28];

iOS加载动态自定义字体的更多相关文章

  1. iOS 加载动态库报错问题

    dyld: Library not loaded: @rpath Referenced from: Reason: no suitable image found.  Did find: 要么使用静态 ...

  2. 【转载】cocos2dx 中 Android NDK 加载动态库的问题

     原文地址:http://blog.csdn.net/sozell/article/details/10551309 cocos2dx 中 Android NDK 加载动态库的问题 闲聊 最近在接入各 ...

  3. QLibrary 加载动态库

    阅读本文大概需要 6.6分钟 一般情况下在没有头文件支持情况下,想要引入某个动态库,最好的办法就是使用「动态加载」的方法,在Qt中一般使用QLibyary来操作 常用 api QLibrary(con ...

  4. Java类的加载の动态

    类的加载方式 静态加载类,是编译时刻加载 动态加载类,是运行时刻加载 new创建对象:是静态加载类,在编译时刻就需要加载所有的可能使用到的类.有一个类有问题(如不存在),都不能通过编译,会报错. Cl ...

  5. Linux下c函数dlopen实现加载动态库so文件代码举例

    dlopen()是一个强大的库函数.该函数将打开一个新库,并把它装入内存.该函数主要用来加载库中的符号,这些符号在编译的时候是不知道的.这种机制使得在系统中添加或者删除一个模块时,都不需要重新编译了. ...

  6. NGINX 加载动态模块(NGINX 1.9.11开始增加加载动态模块支持)

    NGINX 1.9.11开始增加加载动态模块支持,从此不再需要替换nginx文件即可增加第三方扩展.目前官方只有几个模块支持动态加载,第三方模块需要升级支持才可编译成模块. tinywan@tinyw ...

  7. Android必学-异步加载+Android自定义View源码【申明:来源于网络】

    Android必学-异步加载+Android自定义View源码[申明:来源于网络] 异步加载地址:http://download.csdn.net/detail/u013792369/8867609 ...

  8. LoadLibrary加载动态库失败

    [1]LoadLibrary加载动态库失败的可能原因以及解决方案: (1)dll动态库文件路径不对.此场景细分为以下几种情况: 1.1 文件路径的确错误.比如:本来欲加载的是A文件夹下的动态库a.dl ...

  9. ASP.net 加载不了字体Failed to load resource: the server responded with a status of 404 (Not Found)

    在bootstrap下加载不了字体内容.出现下列错误. 1.打开IIS找到部署的网站,点击MIME类型,把.woff和.woff2两个类型分别添加到新类型中,重启网站即可.  

  10. C++批量加载动态库函数方法

    1.枚举定义enum  {    // 0 - GigE DLL (implicitly called)    Func_isVersionCompliantDLL,    Func_isDriver ...

随机推荐

  1. k8s 删除 node节点

    查看现有状态 [root@master ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master NotReady control-plan ...

  2. Java_用数组保存并显示杨辉三角

    import java.util.Scanner; public class Yang_Hui_Triangle { public static void main(String[] args) { ...

  3. Laravel ORM 常用方法

    1. 数据查询 ->find($id);  //需要一个主键$id并返回一个模型对象.若不存在则返回null ->findOrFail($id);  //需要一个主键$id并返回一个模型对 ...

  4. python菜鸟学习: 15 GUI界面化记事本

    # -*- coding: utf-8 -*-import tkinter as tkdef getNewCreate(): passdef getCharcount1(sss): # 添加字数统 s ...

  5. Qt设置程序图标

    修改.pro文件添加一下代码:要求.pro文件和.ico文件在同一文件夹下 RC_ICONS = xxx.ico (你的程序图标)最后重新构建一次即可

  6. mysql 创建函数失败解决办法,版本 8.0.26

    报错信息:[Err] 1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declarat ...

  7. Python学习笔记(五)if分支语句

    一.if语法 示例: 1 money = int(input('请输入余额:')) 2 if money >= 5: 3 print('买得起!') 4 5 if True: 6 print(' ...

  8. docker安装postgres并启用postgis扩展

    镜像 查看所有镜像 docker images 可以直接拉取postgis镜像 docker pull postgis 也可以在已有镜像上安装postgres,再启用扩展: docker pull p ...

  9. make vscode portable together with its extensions

    0. the goal make vscode poratable together with its extensions, so that the offline pc could make us ...

  10. h5页面回到顶部

    1.锚点 <aname="top"></a> <ahref="#top"></a> 2.回到顶部 documen ...