private int fontSizeCompare(float sizeDp, int cols, int rows, int width, int height) {
// read new metrics to get exact pixel dimensions
defaultPaint.setTextSize((int) (sizeDp * this.displayDensity + 0.5f));
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 %fdp resulted in %d x %d", sizeDp, 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
阅读 38
收藏 0
点赞 0
评论 0
项目:GitHub
作者:
评论列表
文章目录