尝试调整lazasrus的SynEdit字体宽度

发布时间 2023-07-21 16:42:24作者: 秋·风

lazasrus的SynEdit字体宽度和自带的控件在相同的字体时是不一样的,使用不同字体,字距相差非常大。lazarus IDE的代码编辑器使用SynEdit,也存在同样情况,为改善这情况,近日抽空修改了SynEdit的代码,用最简单的方法处理这个问题(不算完)。
修改方法:
打开/lazarus/components/synedit/syntextdrrawer.pp,定位function TheTextDrawer.GetCharWidth: Integer;增加以下黄色代码,并重新编译lazarus就可以。

function TheTextDrawer.GetCharWidth: Integer;
begin
  FBaseCharWidth:=round( FFontStock.BaseFont.size*0.75);//新增代码
  CharExtra:=0;   //新增代码
  Result := FBaseCharWidth+ CharExtra;
end;

修复前:


左图是修复后的,右图修复前的: