iOS上使用自定义ttf字体

iOS UIFont-实现三方字体的下载和使用 在上一章我们完成啦如何加载使用本地的字体。如果我们有很多的字体可供用户选择,我们当然可以全部使用本地字体加载方式,可是这样就增加了我们的包体积,我们当然还是希望自己的App包小一点,所以一般这种有很多种字体供选择切换的功能,是先让用户自己选择字体下载,下载完成后再设置字体。到这里字体的下载和使用就完成了,需要特别注意调用注册字体的时机,这里有点坑,已经注册过的字体重复调用的话,postScriptName会获取失败。 阅读详情

原文地址:http://blog.youkuaiyun.com/duxinfeng2010/article/details/37834635

项目中想使用第三方的字体,在stackoverflow上查询解决办法,也折腾一会,添加成功,示例如下:


1.将xx.ttf字体库加入工程里面

2.在工程的xx-Info.plist文件中新添加一行Fonts provided by application,加上字体库的名称




3.引用字体库的名称,设置字体: [UIFontfontWithName:@"fontname" size:24];


[objc]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 50)];  
  2. label.text = @"这是一个TEST。123456";  
  3. UIFont *font = [UIFont fontWithName:@"文鼎CS中等線" size:24];  
  4. label.font = font;  
  5. [self.view addSubview:label];  


如果不知道字体名称,可以遍历字体进行查询:

[objc]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. for(NSString *fontfamilyname in [UIFont familyNames])  
  2.   {  
  3.       NSLog(@"family:'%@'",fontfamilyname);  
  4.       for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname])  
  5.       {  
  6.           NSLog(@"\tfont:'%@'",fontName);  
  7.       }  
  8.       NSLog(@"-------------");  
  9.   }  




示例Demo下载地址:http://download.youkuaiyun.com/detail/duxinfeng2010/7639683


参考http://stackoverflow.com/questions/15447558/can-not-include-ttf-font-into-project


私服游戏风险拆解:从宣传话术到服务端安全的工程视角 游戏私服常以“微变”“全屏技能”“爆率翻倍”等话术吸引玩家,但从技术本质看,这类非正规服务器往往缺少可信的安全边界。服务端程序来源不明、客户端和登录器可能携带恶意模块,通信协议加密强度低,账号与支付数据极易泄露。理解私服背后的技术链路,是识别风险的前提。正规游戏服务端开发遵循鉴权、加密、参数校验、权限隔离等工程规范,强调数据一致性与长期运营安全。对于普通玩家,保护设备与账号信息优先于体验“爽感”;对于开发者,搭建合规的游戏服务器需要从网络同步、数据库设计、安全防御和运维监控等基础能力入手。本文从技术科普角度 阅读详情

相关推荐

C# 异步编程详解(Task,async/await)

同步和异步主要用于修饰方法。当一个方法被调用时,调用者需要等待该方法执行完毕并返回才能继续执行,我们称这个方法是同步方法;当一个方法被调用时立即返回,并获取一个线程执行该方法内部的业务,调用者不用等待该方法执行完毕,我们称这个方法为异步方法。异步的好处在于非阻塞(调用线程不会暂停执行去等待子线程完成),因此我们把一些不需要立即使用结果、较耗时的任务设为异步执行,可以提高程序的运行效率。

luxingyu329的博客 4151

ios-运用第三方字体

字体我们在ios开发中可以使用字体资源文件后缀为.otf或者为.ttf的文件导入到项目中进行使用,当然我们还可以要在info.plist文件中进行配置,添加“Fonts provided by application”配置项如下图所示。 然后我们需要在Item0处后面填入你导入的第三方字体库的名称。这样我们就可以使用第三方字体了。可以在代码中使用也可以在storyboard中使用改变字体的型

rv0p111 717

运维面试常见问题

对数据库表中一列或多列的值进行排序的一种结构,使用索引可快速访问数据库表中的特定信息。优缺点:优点:利用索引可以加速对数据的检索,索引是可以唯一的,创建索引允许指定单个列或者多个列缺点:减慢了数据录入速度,同时也增加了数据库的尺寸大小。

asdmjy123的博客 1370

iOS UIFont-新增第三方字体

在项目中添加三方字体,是在开发中比较常见的需求,每次新增字体,都会遗忘其中某个步骤,又要去百度一下才能把字体添加使用成功。每次这样有点浪费时间和打击自信,于是便想着,自己好好来理一理新增字体的步骤,加深下印象呢!

lyh1083908486的博客 1894

Windows 2008 R2虚拟机跑金蝶K3 WISE 12.1的5个关键配置细节(附避坑清单)

本文详细介绍了在Windows Server 2008 R2虚拟机中部署金蝶K3 WISE 12.1的5个关键配置细节,包括服务器角色与账户权限、组件服务调优、数据库与中间层协同部署、补丁管理策略及性能优化工具。这些实战经验可帮助企业IT团队避免常见陷阱,确保ERP系统稳定运行。

weixin_30847939的博客 317

DLMS—Cryptographic algorithms—(Green-Book)加密算法

密码学是数学的一个分支,基于数据的转换,并且可以用来提供多种安全服务:保密性、数据完整性、认证、授权和不可否认性。密码学依赖于两个基本组成部分:算法(或密码学方法)和密钥。算法是一个数学函数,而密钥是在转换过程中使用的参数。密码算法和密钥用于对数据应用密码保护(例如,加密数据或生成数字签名),以及移除或检查保护(例如,解密加密的数据或验证数字签名)。密码哈希函数:这类函数不需要密钥(尽管它们可以以使用密钥的模式使用)。哈希函数通常用作算法的一个组成部分,以提供安全服务。见9.2.3.2节。对称密钥算法。

一个bug是bug,多个bug能work 1707

IOS使用第三方字体

1、从网上下载所需字体的TTF文件。将字体所对应的TTF文件拖入项目中。

wangzhi8910的专栏 804

别再乱按F8了!Win10系统修复的正确姿势:用管理员CMD运行sfc /scannow

本文详细介绍了Windows 10系统修复的正确方法,重点推荐使用管理员CMD运行`sfc /scannow`命令。相比传统的F8键和重装系统,这一方法更高效且安全,能解决大多数系统文件损坏问题。文章还提供了管理员CMD的启动方式、sfc命令的完整参数解析以及实战故障排除流程图,帮助用户快速恢复系统健康。

weixin_29218963的博客 459

iphone字体_ios 13新字体更换教程,Adobe Creative Cloud下载

近日,苹果 iOS13 系统的更新中,iOS 13系统将首次可以使用Adobe庞大的字体库,字体数多达17000多种,用户可以在运行iOS 13.1版本系统中从自定义字体选项中更换字体。消息一出,不少果粉就问如何更换,因为目前,Adobe Creative Cloud 未登陆中国区 App Store,如果想要体验的朋友可切换至其它地区的 App Store 下载体验。另外,iOS 1...

weixin_39669265的博客 4307

BPMN-JS :修改节点“Change Type”事件类型

修改路径:node_modules\bpmn-js\lib\features\replace\ReplaceOptions.js。

TaylorY的博客 678

实战:批量抓取免费代理IP全流程(附自动验证+失效剔除,爬虫抗封必备)

本文分享了一套从免费代理IP中筛选可用高匿代理的实用方案。作者通过半年实践,总结出"批量抓取+精准验证+动态维护"的方法,能从2000条免费IP中筛选出30-50条可用代理,满足中小规模爬虫需求。 方案包含四个核心环节: 多源代理抓取:针对快代理、西刺代理等不同网站定制解析规则 三层验证机制:检查有效性、匿名度和响应速度 代理池自动维护:实时淘汰失效IP Scrapy整合实战:提供可直接复用的代码 文章特别指出免费代理的三大痛点:存活率低(80%10分钟内失效)、匿名性差(仅5%是高匿代

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1601

iOS中使用自定义ttf/ttc字体,以及cocosbuilder中指定字体的方法

iOS中使用自定义ttf/ttc字体的方法,网上一搜一堆,但是还是有一些没有说清的地方,因此我认为有必要再总结整理一下。(可跳至快速总结直接看结论) 首先,明确个概念,这儿讨论的使用ttf/ttc字体的方法,是指使用iOS自建的机制渲染字体,即UIFont去渲染字体将文本生成一张贴图。因此就要符合iOS的一些既定规则。 规则有两个:1)让iOS系统找到你的字体 2)

聚焦游戏和图形引擎开发技术 7931

第八届传智杯微信小程序开发挑战赛练习题库

本文是微信小程序开发练习题库,包含单选题、多选题和判断题三种题型。单选题主要考察小程序开发基础知识,如数组方法、组件使用、API调用等;多选题涵盖样式属性、页面跳转、数据处理等综合知识;判断题则测试开发者对小程序特性、生命周期、功能限制等概念的理解。题目内容涉及小程序开发的各个方面,包括组件使用、API调用、数据绑定、页面配置等核心知识点,适合开发者进行自我测试和知识巩固。

qq_73044452的博客 505

ios工程-ttf格式字体:添加自定义的字体,并在工程中成功的使用字体

ios工程-ttf格式字体:添加自定义的字体,并在工程中成功的使用字体 设备/引擎:Mac(11.6)/cocos 开发工具:Xcode(13.0) 开发需求:在工程中使用自定义的字体文件 1.将字体文件加入工程Resource中 这个不难理解,不再赘述 2.在工程Info.plist中添加字段Fonts provided by application 添加Item,将你所需要的字体加入即可 3.在工程中调用即可 如上所属即可完成对自定义字体的使用。 希望能给大家带来帮助!!!有什么问题需要讨论的可以评

ImCode 1681

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

苹果ttc转ttf_iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)

提供字体文件路径,返回所需要字体:-(UIFont*)customFontWithPath:(NSString*)path size:(CGFloat)size{NSURL *fontUrl = [NSURL fileURLWithPath:path];CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL((__bridg...

weixin_32457139的博客 1503

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)

最近做了个有关阅读的应用,使用了自定义字体,学习了一下这方面的知识。 1.首先是最简单也普遍的做法,打包内置字符库文件: 把字体库文件添加到工程,如font1.ttf添加到工程,然后在工程plist添加一项Fonts provided by application,这是个数组,然后添加key item1,value就是刚才说的font1.ttf,如图:   那么在工

未知数 717

【iOS开发】使用自定义 '.ttf ' 字体

项目中根据设计要求,需要使用第三方字体,具体添加步骤如下:1 . 将xxx.ttf字体库加入工程里面2 . 在工程的xx - Info.plist文件中新添加一行Fonts provided by application,加上字体库的名称3.引用字体库的名称,设置字体: UIFont *font = [UIFont fontWithName:@"Lantinghei" size:25.0];4.应用

Hanrovey Blog 1666

iOS 开发使用自定义得ttf 字体

1.将xx.ttf字体库加入工程里面。 2.在工程的xx-Info.plist文件中新添加一行Fonts provided by application,加上字体库的名称 3.引用字体库的名称,设置字体:[UIFontfontWithName:@"fontname"size:24]; 如果不知道字体名称,可以遍历字体进行查询: for(NSString*f...

weixin_30776273的博客 82
上一篇: iOS7以上自定义一个navigationController,并沿用系统的侧滑返回效果
下一篇: storyboard中自定义cell
Mideveloper
博客等级 码龄14年 157粉丝 68原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值