No difference between font size units 'pixels' and 'points'

조회 수: 12 (최근 30일)
Jakob Weis
Jakob Weis 2024년 9월 20일
댓글: Jakob Weis 2025년 2월 7일
I noticed when changing the font size of a figure it makes no difference if one chooses pixels or points as units. Is this a known issue or intended?
figure(1)
set(gcf,'Position',[10 10 800 800])
peaks;
fontsize(16,'pixels')
figure(2)
set(gcf,'Position',[10 10 800 800])
peaks;
fontsize(16,'points')
left: figure 1, font size = 16 px; right: figure 2, font size = 16 pt; created using MATLAB Desktop
Interestingly, creating the same figures using the code above in the New Desktop for MATLAB produces 33% bigger font sizes given in points compared to pixels (consistent with the points/pixels size conversion).
left: figure 1, font size = 16 px; right: figure 2, font size = 16 pt; created using New Desktop for MATLAB
  댓글 수: 5
Bruno Luong
Bruno Luong 2024년 9월 22일
Perhaps the New Desktop redefines the pixel unit differently. I don't know New Desktop myself.
Jakob Weis
Jakob Weis 2025년 2월 7일
Just to clarify, as of R2025a (featuring the New Desktop by default) pixels seem to be redefined. Running on Mac and using the same screen:
get(0,'ScreenPixelsPerInch')
returns 72 in R2024b and 96 in R2025a prerelease.

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2024년 9월 20일
편집: DGM 2024년 9월 20일
I'm not sure how it's doing the scaling internally, but my guess would start here:
% units per em
sz = 16;
% units per inch
pxpin = get(0,'ScreenPixelsPerInch'); % px/in
ptpin = 72; % pt/in
% inches per em
szinpx = sz/pxpin
szinpx = 0.1600
szinpt = sz/ptpin
szinpt = 0.2222
That would tell us that on this system, the rendered sizes should differ, but measuring the exact height of 1 em is a bit of a chore unless you know what text features are 1 em high. Instead, we can just measure the ratio of character heights.
% expected ratio of on-screen sizes
ptpin/pxpin
ans = 0.7200
On my machine, the calculated ratio seems to be quite close to the size ratio I can measure from screenshots.
If your reported display resolution were 72, then the rendered sizes would be the same. It seems that would be expected on a Mac.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by