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. HIVE- lag函数和lead函数

    select date_flag,category_flag,field,LAG(filed, 1) OVER (PARTITION BY category_flag ORDER BY date_fl ...

  2. jupyter notebook 切换环境

    jupyter-notebook 中切换 conda 虚拟环境 介绍 ​ jupyter notebook是anaconda中root目录中默认的python环境,如果要使拥创建的其他环境,则需要安装 ...

  3. C#开发上位机常用

    从深圳回内地几年了,突然想把之前项目中用到的东西做信合集,别忘记了!!!

  4. 光盘实现半自动化安装linux以及PXE实现自动安装

    重点 实验一:使用 kickstart 半自动化安装CentOS系统 可以将定制安装光盘,并结合kickstart实现基于光盘启动的半自动化安装 实现过程  首先下载httpd搭建个web网页 [ro ...

  5. GNSS模块

    1. Location服务注册 第一个注册是在 SystemServer 中将 location 服务注册到 ServiceManager中去:第二个注册是在 SystemServiceRegistr ...

  6. selenium grid4.0+分布式的部署配置(hub/node方式)

    一.grid安装 本文已jar包的方式讲解,访问并下载jar包:Releases · SeleniumHQ/selenium · GitHub 二.grid配置 假设主机:10.1.5.219,从机: ...

  7. 从main_phase跳回reset_phase的方式

    在main_phase中调用: phase.jump(uvm_reset_phase::get()); 注意需要防止进入死循环.

  8. Elasticsearch Java client使用

    前言 Elasticsearch官方列出了好几个客户端,如下所示 Java Client Java Rest Client(Java High Level REST Client) Java Tran ...

  9. 高CPU Java应用分析

    模拟CPU 40%左右 import java.util.concurrent.CountDownLatch; public class Main extends Thread { private C ...

  10. java script--一些冷知识

    java script--一些冷知识 目录 java script--一些冷知识 布兰登·艾奇,JavaScript 创始人 java script logo json logo json node. ...