private int fontSizeCompare(float size, int cols, int rows, int width, int height) {
// read new metrics to get exact pixel dimensions
defaultPaint.setTextSize(size);
FontMetrics fm = defaultPaint.getFontMetrics();
float[] widths = new float[1];
defaultPaint.getTextWidths("X", widths);
int termWidth = (int)widths[0] * cols;
int termHeight = (int)Math.ceil(fm.descent - fm.top) * rows;
Log.d("fontsize", String.format("font size %f resulted in %d x %d", size, termWidth, termHeight));
// Check to see if it fits in resolution specified.
if (termWidth > width || termHeight > height)
return 1;
if (termWidth == width || termHeight == height)
return 0;
return -1;
}
TerminalBridge.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:connectbot
作者:
评论列表
文章目录