zoukankan      html  css  js  c++  java
  • 多个平台下使用Custom Fonts

    1:操作系统下使用:

    win:   C:\Windows\Fonts

    Max:  Macintosh/Library/Fonts folder

    Mac的话还有一个好用的Fontbook,位置在Finder/Application/Fontbook,打开后,添加新字体直接拖拽新字体到Fontbook里,可以预览所选的字体。

    添加完新字体后需要重新启动Illustrator或者PS。

     

    2:Illustrator/PS下使用:

    Illustrator/PS使用系统里的字体,所以要先确认系统有装

    注意:HelveticalNeue里的BoldCond,注父HeveticaNeue里包含多个子font。

    3:Titanium 下使用:(Titanium使用TTF and OTF 字体)

    Mac环境下使用:http://docs.appcelerator.com/titanium/2.1/index.html#!/guide/Custom_Fonts

    步骤:

    Download your fonts 或者 copy font from system folder

    Copy the TTF/OTF file to the /Resources/fonts/directory.

    If you want to use different fonts on iOS than Android, you can copy those files to Resources/iphone/fonts and Resources/android/fonts instead.

    参考下列代码:

     1 /*
     2 * Let's say you downloaded the "Spicy Rice" font from Google WebFonts.
     3 * You'd have a file named SpicyRice-Regular.ttf in your fonts directory
     4 */
     5 
     6 var customFont = 'Spicy Rice'; // use the friendly-name on iOS
     7 if(Ti.Platform.osname=='android') {
     8    // on Android, use the "base name" of the file (name without extension)
     9    customFont = 'SpicyRice-Regular';
    10 } 
    11 
    12 var label1 = Titanium.UI.createLabel({
    13    color:'#000',
    14    text:'I am Window 1',
    15    font:{
    16       fontSize:40,
    17       fontFamily: customFont
    18    },
    19    textAlign:'center',
    20    'auto'
    21 });

    如果在Android: build your project and the custom font should show up.

    Additional iOS steps

    On iOS, you must list custom fonts in your app's Info.plist file.

     

    1. Build the project at least once (the font won't work yet).

    2. Copy build/iphone/Info.plist to the project root folder (where Resources is located).

    3. Double-click Info.plist to open it in Xcode.

    4. Right-click a blank area in the list of keys and choose Add Row. From the resulting list, choose Fonts provided by application.

    5. Expand Fonts provided by application and click in the Value field. Enter the full name of the font file. If you've put the file in the fonts directory as we suggest, make sure to include that path, e.g. /fonts/SpicyRice-Regular.ttf

    6. Save the file and close Xcode.

    7. In Studio, clean the project then build it again. This time your custom font should show up.

    8. As noted in the code sample above, you also need to use the "friendly name" for the font, rather than its file name. To determine this name, double-click the TTF/OTF file to open it in Font Book. The font's friendly name is shown in the window's title bar.

      images/download/attachments/29004935/friendlyname.png

  • 相关阅读:
    《代码大全》阅读心得一
    vi列模式
    以指定的概率/机会获取元素
    自用VIM配置
    优雅的Javascript
    关于遮罩层
    CSS3属性BorderRadius详解[圆角]
    CSS3属性boxshadow详解[盒子阴影]
    CSS3文字特效
    Css3 Animation详解
  • 原文地址:https://www.cnblogs.com/shawnzxx/p/2672775.html
Copyright © 2011-2022 走看看