Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

css加载本地字体在导出图片的预览中生效,导出后的图片则未正确加载字体 #79

Open
u2003 opened this issue Jan 3, 2025 · 4 comments

Comments

@u2003
Copy link

u2003 commented Jan 3, 2025

开发者大大好。我在css snippet新增了以下内容,希望改变字体,导出图片预览时一切字体显示正常,但导出之后的图片只有Adobe Garamond生效了,本地字体方正仿宋并没有生效,请问为什么会这样呢?我需要怎么修改css可以解决这个问题?或者说这是插件的bug?十分感谢!

@font-face {
    font-family: 'FZFangSong';
    src: local('FZFSJW--GB1-0'), local('方正仿宋简体');
  }
  
  .export-image-preview-container.markdown-preview-view,
  .export-image-root.markdown-reading-view {
      margin-top: 72px;
      margin-left: 42px;
      font-family: 'Adobe Garamond', 'FZFangSong', sans-serif !important;
      line-height: 2;
      padding-top: 0 !important;
      padding-bottom: 0 !important;
  }

  .export-image-preview-container.markdown-preview-view div.mod-ui > p {
    margin-block-start: 32px !important;
    margin-block-end: 32px !important;
@zhouhua
Copy link
Owner

zhouhua commented Jan 3, 2025 via email

@u2003
Copy link
Author

u2003 commented Jan 3, 2025

感谢回复!我是mac系统,adobe garamond是系统字体。把自定义的字体base64编码之后插入css解决了这个问题,不过不知道有没有更方便的方法呀。

@zhouhua
Copy link
Owner

zhouhua commented Jan 6, 2025

我第一次遇到这个问题,应该插件还不能支持 local(xxx) 字体的方式,如果你不自定义一个字体,source 用 local(), 而是直接用 font-family 指定本地字体的名字应该是可以的。

关于 local() 的写法的支持,我再研究一下。

@zhouhua
Copy link
Owner

zhouhua commented Jan 6, 2025

对于你的 case,试试直接这样写:

.export-image-preview-container.markdown-preview-view,
.export-image-root.markdown-reading-view {
    margin-top: 72px;
    margin-left: 42px;
    font-family: 'Adobe Garamond', 'FZFSJW--GB1-0', '方正仿宋简体', sans-serif !important;
    line-height: 2;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants