Skip to content

Commit

Permalink
feat: add doom emacs support hidpi setting
Browse files Browse the repository at this point in the history
  • Loading branch information
liaobinbin committed Jul 14, 2024
1 parent 9e5557d commit 9dd2582
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 14 deletions.
2 changes: 1 addition & 1 deletion content/posts/doom-emacs-set-chinese-font/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Doom Emacs 给中文指定字体"
date: 2022-07-13T09:58:09+08:00
draft: false
categories: ["工具"]
categories: ["Emacs"]
tags: ["emacs", "lisp", "font", "chinese"]
---

Expand Down
27 changes: 27 additions & 0 deletions content/posts/doom-emacs-set-hidpi-font.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#+TITLE: Doom Emacs 字体 HiDPI 设置
#+DATE: 2024-07-14
#+DRAFT: false
#+CATEGORYS: Emacs
#+TAGS[]: emacs font doomemacs

我使用的是 =4K= 显示器,其分辨率为 =3840x2160=

在我的 linux 操作环境系统中,我已经将系统层面的整体缩放调整为 =1.5= 倍, 使其整体界面的实际效果以 =2560x1440= 进行显示。用以获得相较于 =1080p= 整数倍缩放获得更宽裕的空间使用,兼顾矢量字体的清晰度。

但是除了在 =emacs -nw= 下运行的时候,例如直接启动 emacs ,我的整体文字仍然按照设定的字体大小,就像固定的像素大小进行渲染和显示。

这在 =4K= 下导致我的文字异常的小,于是在网上寻求解决办法。

幸运的是,我很快的在 =doomemacs= 的 issue 中找到了解决办法。

具体解决办法如下:

#+begin_src elisp
(setq doom-font (font-spec :family "Terminess Nerd Font" :size 16.0 ))
#+end_src

是的,你没有看错,这就是和默认的设置方式一模一样。

但是重点就是 =size= 不是一个整数,而是一个浮点数。

然后我的 emacs 显示效果就完美的应用上了系统设置的 =DPI= 系数

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/style.min.css","MediaType":"text/css","Data":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#id-1{width:50%}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/2444e9.min.css","MediaType":"text/css","Data":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#id-1{height:120px}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/4a7949.min.css","MediaType":"text/css","Data":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#id-1{max-height:120px}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/5b98dd.min.css","MediaType":"text/css","Data":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#id-2{text-align:center}#id-4{background:#292a2d30}#id-5{background:#292a2d30}#id-6{background:#292a2d30}#id-7{display:flex;justify-content:center}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/726bc0.min.css","MediaType":"text/css","Data":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#id-1{width:75%;justify-content:center}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/8aea00.min.css","MediaType":"text/css","Data":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#id-1{width:75%;text-align:center}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/a7c26b.min.css","MediaType":"text/css","Data":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#id-1{text-align:center}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/d8d1a4.min.css","MediaType":"text/css","Data":{}}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"css/e2eb86.min.css","MediaType":"text/css","Data":{}}

Large diffs are not rendered by default.

32 changes: 20 additions & 12 deletions themes/LoveIt/assets/css/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@

// ========== Global ========== //
// Font and Line Height
$global-font-family: system-ui, -apple-system, Segoe UI, Roboto, Emoji,
Helvetica, Arial, sans-serif !default;
$global-font-family:
system-ui,
-apple-system,
Segoe UI,
Roboto,
Emoji,
Helvetica,
Arial,
sans-serif !default;
$global-font-size: 16px !default;
$global-font-weight: 400 !default;
$global-line-height: 1.5rem !default;
Expand Down Expand Up @@ -115,16 +122,17 @@ $pagination-link-hover-color-dark: #fff !default;

// ========== Code ========== //
// Font family and size of the code
$code-font-family: "Source Code Pro", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default;
$code-font-size: .875rem !default;
$code-font-family: "Source Code Pro", Menlo, Monaco, Consolas, "Liberation Mono",
"Courier New", monospace !default;
$code-font-size: 0.875rem !default;

// Color of the code
$code-color: #E74C3C !default;
$code-color-dark: #E5BF78 !default;
$code-color: #e74c3c !default;
$code-color-dark: #e5bf78 !default;

// Color of the code background
$code-background-color: #f5f5f5 !default;
$code-background-color-dark: #272C34 !default;
$code-background-color-dark: #272c34 !default;

$code-info-color: #9c9c9c !default;
$code-info-color-dark: #b1b0b0 !default;
Expand Down Expand Up @@ -183,7 +191,8 @@ $code-type-list:
"language-yml" "YAML",
"language-yaml" "YAML",
"language-wgsl" "WGSL",
!default;
"language-elisp" "ELisp",
"language-lisp" "Lisp" !default;

// Color map of the code highlight
$code-highlight-color-map: (
Expand Down Expand Up @@ -259,7 +268,7 @@ $code-highlight-color-map: (
/* GenericStrong */ "gs": #e72d40,
/* GenericSubheading */ "gu": #e72d40,
/* GenericTraceback */ "gt": #e72d40,
/* TextWhitespace */ "w": #bbbbbb,
/* TextWhitespace */ "w": #bbbbbb
) !default;
$code-highlight-color-map-dark: (
/* Parentheses */ "p": #a9a9b3,
Expand Down Expand Up @@ -334,7 +343,7 @@ $code-highlight-color-map-dark: (
/* GenericStrong */ "gs": #f16372,
/* GenericSubheading */ "gu": #f16372,
/* GenericTraceback */ "gt": #f16372,
/* TextWhitespace */ "w": #bbbbbb,
/* TextWhitespace */ "w": #bbbbbb
) !default;
// ========== Code ========== //

Expand All @@ -352,6 +361,5 @@ $admonition-color-list:
"danger" #ff1744 rgba(68, 138, 255, 0.1),
"bug" #f50057 rgba(255, 23, 68, 0.1),
"example" #651fff rgba(101, 31, 255, 0.1),
"quote" #9e9e9e rgba(159, 159, 159, 0.1),
!default;
"quote" #9e9e9e rgba(159, 159, 159, 0.1) !default;
// ========== Admonition ========== //

0 comments on commit 9dd2582

Please sign in to comment.