Project1

标题: BitmapFont-位图字体 [打印本页]

作者: Mr.Jin    时间: 2016-9-1 17:11
标题: BitmapFont-位图字体
位图字体类呢 简单来说就是 用文字的图像和文字在图像中的位置数据结合成的一个绘制位图的工具
比如像这样子的:


只粗略找了一下,没有找到,索性写了一个比较基本的实现,效果如下:


因为我不会转编码……也就不支持中文,所以目前这个脚本的用处比较小
希望有对位图字体感兴趣的朋友来交流一下
VA工程:
BitmapFontV0.5.zip (1.29 MB, 下载次数: 74)
作者: fux2    时间: 2016-9-3 09:09
RM里转码无非是用MultiByteToWideChar和WideCharToMultiByte
  1. # 声明
  2.   MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  3.   WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  4.   #--------------------------------------------------------------------------
  5.   # ● 转码:系统转UTF-8
  6.   #--------------------------------------------------------------------------
  7.   def s2u(text)
  8.     len = MultiByteToWideChar.call(0, 0, text, -1, nil, 0);
  9.     buf = "\0" * (len*2)
  10.     MultiByteToWideChar.call(0, 0, text, -1, buf, buf.size/2);
  11.     len = WideCharToMultiByte.call(65001, 0, buf, -1, nil, 0, nil, nil);
  12.     ret = "\0" * len
  13.     WideCharToMultiByte.call(65001, 0, buf, -1, ret, ret.size, nil, nil);
  14.     return ret.delete("\000")
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 转码:UTF-8转系统
  18.   #--------------------------------------------------------------------------
  19.   def u2s(text)
  20.     len = MultiByteToWideChar.call(65001, 0, text, -1, nil, 0);
  21.     buf = "\0" * (len*2)
  22.     MultiByteToWideChar.call(65001, 0, text, -1, buf, buf.size/2);
  23.     len = WideCharToMultiByte.call(0, 0, buf, -1, nil, 0, nil, nil);
  24.     ret = "\0" * len
  25.     WideCharToMultiByte.call(0, 0, buf, -1, ret, ret.size, nil, nil);
  26.     return ret.delete("\000")
  27.   end
复制代码

但本人对字体文件的数据结构没什么了解,你可以试试转码后是否有对应的下标。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1