Text in annotations is longer when using colors. Bug?

Using annotations in matlab I noticed that when I use colored text the spacing between words increases. See the example below
Is this a know bug? Can it be fixed with some workaround?
annotation('textbox',[.2 .5 0 0],'String',["a a a a a a a a a a" "a a a a a a a a a a"],'FitBoxToText','on','FontName','consolas','FontSize',14)
annotation('textbox',[.2 .5 0 0],'String',["a a a a a a a a a a" "\color{red}a \color{black}a \color{red}a \color{black}a \color{red}a \color{black}a \color{red}a \color{black}a \color{red}a \color{black}a"],'FitBoxToText','on','FontName','consolas','FontSize',14)

댓글 수: 6

Adam Danz
Adam Danz 2020년 7월 28일
편집: Adam Danz 2020년 7월 28일
There does appear to be a difference in width of about 1 pixel or so that accumulates with every red letter. It can be seen when plotting your two examples on top of eachother.
dpb
dpb 2020년 7월 28일
Try various renderers to see if makes any difference.
Wonder if bold font would match up...
giannit
giannit 2020년 7월 28일
편집: giannit 2020년 7월 28일
@AdamDanz The same happens also in the case we replace all \color{red} with \color{black}.
I don't think this is a wanted feature by developers, isn't it?
@dpb what do you mean with renderer? Interpreter? If so, we can only use 'tex'.
The same happens with bold
annotation('textbox',[.2 .5 0 0],'String',["\bfa a a a a a a a a a" "\color{red}a \color{black}a \color{red}a \color{black}a \color{red}a \color{black}a \color{red}a \color{black}a \color{red}a \color{black}a"],'FitBoxToText','on','FontName','consolas','FontSize',14)
Adam Danz
Adam Danz 2020년 7월 28일
편집: Adam Danz 2020년 7월 28일
For render info
I tried painters but the problem persists. I doubt the offset is intentional.
dpb
dpb 2020년 7월 28일
I suspect it's all tied in to the font family and the TeX implementation. Probably not much could be done as AFAIK TMW just picked up an opensource TeX distribution and embedded the necessary pieces.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 7월 28일

댓글:

dpb
2020년 7월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by