浏览代码

fix text blur on multi pixel screen

/main
fzhangtj 6 年前
当前提交
94809d4a
共有 1 个文件被更改,包括 15 次插入9 次删除
  1. 24
      Assets/UIWidgets/ui/painting/txt/mesh_generator.cs

24
Assets/UIWidgets/ui/painting/txt/mesh_generator.cs


using UIWidgets.ui.txt;
using UnityEditor;
using UnityEngine;
namespace UIWidgets.ui.painting.txt

var triangles = new int[length * 6];
var uv = new Vector2[length * 4];
var text = textBlob.text;
var scale = EditorGUIUtility.pixelsPerPoint;
var fontSizeToLoad = (int)scale * style.UnityFontSize;
style.UnityFontSize, style.UnityFontStyle);
fontSizeToLoad, style.UnityFontStyle);
for (int charIndex = 0; charIndex < length; ++charIndex)
{
var ch = text[charIndex + textBlob.start];

}
else
{
font.GetCharacterInfo(ch, out charInfo, style.UnityFontSize, style.UnityFontStyle);
vertices[4 * charIndex + 0] = offset + new Vector3((float)(position.x + charInfo.minX),
(float)(position.y - charInfo.maxY), 0);
vertices[4 * charIndex + 1] = offset + new Vector3((float)(position.x + charInfo.maxX),
(float)(position.y - charInfo.maxY), 0);
font.GetCharacterInfo(ch, out charInfo, fontSizeToLoad, style.UnityFontStyle);
var minX = charInfo.minX / scale;
var maxX = charInfo.maxX / scale;
var minY = charInfo.minY / scale;
var maxY = charInfo.maxY / scale;
vertices[4 * charIndex + 0] = offset + new Vector3((float)(position.x + minX),
(float)(position.y - maxY), 0);
vertices[4 * charIndex + 1] = offset + new Vector3((float)(position.x + maxX),
(float)(position.y - maxY), 0);
(float)(position.x + charInfo.maxX), (float)(position.y - charInfo.minY), 0);
(float)(position.x + maxX), (float)(position.y - minY), 0);
(float)(position.x + charInfo.minX), (float)(position.y - charInfo.minY), 0);
(float)(position.x + minX), (float)(position.y - minY), 0);
uv[4 * charIndex + 0] = charInfo.uvTopLeft;
uv[4 * charIndex + 1] = charInfo.uvTopRight;

正在加载...
取消
保存