zoukankan      html  css  js  c++  java
  • 更换 字体

    引用:http://zhidao.baidu.com/question/297919794.html

    .自定义字体
    android Typeface使用TTF字体文件设置字体
    
    我们可以在程序中放入ttf字体文件,在程序中使用Typeface设置字体。
    第一步,在assets目录下新建fonts目录,把ttf字体文件放到这。
    第二步,程序中调用:
    AssetManager mgr=getAssets();//得到AssetManager
    Typeface tf=Typeface.createFromAsset(mgr, "fonts/ttf.ttf");//根据路径得到Typeface
    tv.setTypeface(tf);//设置字体    
    
    2.在xml文件中使用android:textStyle=”bold” 可以将英文设置成粗体,  但是不能将中文设置成粗体, 
    将中文设置成粗体的方法是: 
    TextView tv = (TextView)findViewById(R.id.TextView01); 
     tv.getPaint().setFakeBoldText(true);//中文仿“粗体”--使用TextPaint的仿“粗体”设置setFakeBoldText为true。
    
    
    -------------------------------------------------------------------------------------------------------------
     引用:http://www.cmd100.com/bbs/forum-redirect-tid-5305-goto-lastpost.html
    TTF简介:TTF(TrueTypeFont)是Apple公司和Microsoft公司共同推出的字体文件格式,随着windows的流行,已经变成最常用的一种字体文件表示方式,在一些特殊的场合,系统字符集不包含你要用的字体,这时候必须使用自己的字体文件,如甲骨文等古文字处理,一般在系统盘\WINDOWS\Fonts里,直接双击能查看是什么样的字体 

    TTF(TrueTypeFont)是一种字库名称。
    在android中使用实例之一,如下:
    import android.app.Activity;   
    import android.content.Context;   
    import android.graphics.Canvas;   
    import android.graphics.Color;   
    import android.graphics.Paint;   
    import android.graphics.Typeface;   
    import android.os.Bundle;   
    import android.view.View;   
      
    public class Typefaces extends Activity   
    {   
        /** Called when the activity is first created. */  
        @Override  
        public void onCreate(Bundle savedInstanceState)   
        {   
            super.onCreate(savedInstanceState);   
               
            setContentView(new SampleView(this));   
        }   
           
        private static class SampleView extends View    
        {   
            private Paint    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);   
            private Typeface mFace;   
               
            public SampleView(Context context)    
            {   
                super(context);   
                //实例化自定义字体   
                mFace = Typeface.createFromAsset(getContext().getAssets(),"fonts/samplefont.ttf");   
                //设置字体大小   
                mPaint.setTextSize(32);   
            }   
               
            @Override protected void onDraw(Canvas canvas)    
            {   
                canvas.drawColor(Color.WHITE);   
                //绘制默认字体   
                mPaint.setTypeface(null);   
                canvas.drawText("Default:abcdefg", 10, 100, mPaint);   
                //绘制自定义字体   
                mPaint.setTypeface(mFace);   
                canvas.drawText("Custom:abcdefg", 10, 200, mPaint);
       
            }   
        }   
    }  
    //消除锯齿   
    paint.setFlags(Paint.ANTI_ALIAS_FLAG)   
    //取得字符串宽度   
    paint.measureText() 
  • 相关阅读:
    6.Dump域内用户Hash姿势集合
    4.浅谈跨域劫持
    7. Smali基础语法总结
    7.linux安全基线加固
    12. git常用语法总结
    5.内网渗透之PTH&PTT&PTK
    4. 内网渗透之IPC$入侵
    1.我所了解的内网渗透
    34.不安全的HTTP
    2.内网渗透之端口转发
  • 原文地址:https://www.cnblogs.com/sode/p/2132660.html
Copyright © 2011-2022 走看看