zoukankan      html  css  js  c++  java
  • canvas绘图详解-10-文字渲染

    1、context.font = "20px sans-serf" 默认
    支持 可以这只以下五种属性
    font-style:normal|italic|oblique
    font-variant:normal|smallcaps
    font-weight:normal|lighter|bold|bolder
    font-size:20px|2em|150%|xx-samall
    font-family:Hrial,Helvetic,sans-serf

    解释一下

    2、context.textAlign = left||center||right

     

    和你想象的不一样吧,是以起始点为标准,起始点表示最左边,中间,最右边

    3、context.textBaseline = top || middle || bottom || Alphabetic || ideographic || hanging 

    解释一下

     

    4、渲染文字

    context.measureText(string).width;//获取一段文字的宽度
    context.fillText(string , x , y , [maxlen]);//实心字体 context.strokeText(string , x , y , [maxlen]);//边框字体

    x,y为起始点坐标,maxlengh是字体最大长度,如果超出会自动压缩,单位默认px,不用写

    context.fillStyle = "#058";
    context.font = "bold 120px Arial";
    context.textAlign = "center";
    context.textBaseline = "middle";
    context.fillText("CANVAS", canvas.width/2 , canvas.height/2);
  • 相关阅读:
    oracle之数据限定与排序
    oracle之分组函数
    oracle之SQL的数据类型
    lftp简单使用
    黑盘-蓝盘-绿盘-红盘
    windows 路由
    http扩展请求头中的x-Forwarded-For
    http状态码304
    firewall 实现数据的端口转发
    通过curl获取网页访问时间
  • 原文地址:https://www.cnblogs.com/wufangfang/p/6378080.html
Copyright © 2011-2022 走看看