/** 动态计算字体大小
*
* @param WriteSize 默认字体大小50
* @param Texts 打印字符串List
* @param WriteHeight 打印区域高度
* @param writeWidth 打印区域宽度
* @return
*/
public static int FontSize(List<String> Texts,int WriteHeight, int writeWidth) {
Paint paint = new Paint();
paint.setStrokeWidth(3.0f);
int WriteSize = 50;
int WlenHeight = 0;
List<String> listLen1;
while (true) {
int Wlen1 = 0;
paint.setTextSize(WriteSize);
for (int i = 0; i < Texts.size(); i++) {
listLen1 = StringUtil
.autoSplit(Texts.get(i), paint, writeWidth);
Wlen1 += listLen1.size();
}
WlenHeight = Wlen1 * WriteSize;
if (WlenHeight > WriteHeight)
WriteSize -= 1;
else
break;
}
return WriteSize;
}