TerminalBridge.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:GitHub 作者:
/**
 * Request a different font size. Will make call to parentChanged() to make
 * sure we resize PTY if needed.
 *
 * @param sizeDp Size of font in dp
 */
private final void setFontSize(float sizeDp) {
    if (sizeDp <= 0.0) {
        return;
    }

    final int fontSizePx = (int) (sizeDp * this.displayDensity + 0.5f);

    defaultPaint.setTextSize(fontSizePx);
    fontSizeDp = sizeDp;

    // read new metrics to get exact pixel dimensions
    FontMetrics fm = defaultPaint.getFontMetrics();
    charTop = (int) Math.ceil(fm.top);

    float[] widths = new float[1];
    defaultPaint.getTextWidths("X", widths);
    charWidth = (int) Math.ceil(widths[0]);
    charHeight = (int) Math.ceil(fm.descent - fm.top);

    // refresh any bitmap with new font size
    if (parent != null) {
        parentChanged(parent);
    }

    for (FontSizeChangedListener ofscl : fontSizeChangedListeners) {
        ofscl.onFontSizeChanged(sizeDp);
    }

    host.setFontSize((int) sizeDp);
    manager.hostdb.saveHost(host);

    forcedSize = false;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号