修正 IronPDF 中的字體字距問題
此問題特別影響我們函式庫的 WebKit 版本(<= 2021.3.1)。 Arial 和 Arial Bold 等系統字型出現的字距調整問題,是因 Windows 系統字型內的字距設定有誤所致。 為解決此問題,我們建議升級至 IronPDF 的較新版本。 自版本 (>= 2021.9.3678) 起,我們導入了 Chrome Engine 渲染技術,不僅提升了相容性,更解決了這些字型字距調整問題。
解決方案
為解決字體字距問題,請移除系統字體,並從線上資源下載新字體(例如 ArialMT)。 接著,請使用 @font-face 將此字型連結至 HTML:
@font-face {
/* Define a new font family for ArialMT Regular */
font-family: 'ArialMT Regular';
font-style: normal;
font-weight: normal;
/* Specify the local source and the WOFF format for the font */
src: local('ArialMT Regular'), url('arialmt.woff') format('woff');
}
接著,請將 HTML 中的所有 font-family: Arial; 宣告替換為 font-family: ArialMT Regular;,然後渲染 PDF。 此變更可確保使用網頁字型取代可能引發問題的系統字型,從而避免因系統預設字型所導致的字距調整問題。

