Closed Saint-Theana closed 2 years ago
You cannot (iirc) set a font directly to an already created terminal.
Instead you need to look for class "SwingTerminalFontConfiguration", create a subclass of it to override selectDefaultFont to return your favourite array of Fonts, then create an instance of your FontConfiguration subclass and pass that to method setTerminalEmulatorFontConfiguration(...) of the TerminalFactory...
I have to admit I haven't needed that, myself, so I hope this pointer already helps. Also, I haven't closely followed changes of the last few years, so there might even be an easier way in the meantime.
On Sat, Apr 2, 2022 at 4:55 PM Saint-Theana @.***> wrote:
I created a terminal by
DefaultTerminalFactory factory = new DefaultTerminalFactory(System.out, System.in, Charset.forName("UTF8"));Terminal term = factory.createTerminalEmulator();
Then create a screen by that terminal. Finally I created a TextGraph by calling screen.newTextGraphics(); When I put something in TextGraph by calling putCSIStyledString(....),I got Texts on the terminal as I expectd,but font is very unclear from far distance. This is a picture taken from a very close distance.(about 10cm from my phone and screen on my pc.) [image: PJPGBHNC7}JNC0EB$RR7] https://user-images.githubusercontent.com/34052138/161388683-14d7e709-dfc3-4bea-b325-8a53cd36c300.jpg The title of terminal emulator window shows that is a SwingTerminalFrame. I tried to set font by those code but it doesnt work.
SwingTerminalFrame term = (SwingTerminalFrame) factory.createTerminalEmulator();term.setFont(new Font("FreeMono", Font.PLAIN, 30));
Please help me,best regards.
— Reply to this email directly, view it on GitHub https://github.com/mabe02/lanterna/issues/558, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIDBMSZSRSOZ6K3DWDBNWTVDBNUXANCNFSM5SLBF2WA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Oops, sorry ... Just noticed that selectDefaultFont methods are static, and thus cannot really be "overridden"...
You still seem to need to subclass SwingTerminalFontConfiguration, but then call it's super-constructor somewhat like SwingTerminalFontConfiguration.newInstance() does, just with your own array of Fonts...
On Sun, Apr 3, 2022 at 11:41 PM Andreas Leitgeb @.***> wrote:
You cannot (iirc) set a font directly to an already created terminal.
Instead you need to look for class "SwingTerminalFontConfiguration", create a subclass of it to override selectDefaultFont to return your favourite array of Fonts, then create an instance of your FontConfiguration subclass and pass that to method setTerminalEmulatorFontConfiguration(...) of the TerminalFactory...
I have to admit I haven't needed that, myself, so I hope this pointer already helps. Also, I haven't closely followed changes of the last few years, so there might even be an easier way in the meantime.
On Sat, Apr 2, 2022 at 4:55 PM Saint-Theana @.***> wrote:
I created a terminal by
DefaultTerminalFactory factory = new DefaultTerminalFactory(System.out, System.in, Charset.forName("UTF8"));Terminal term = factory.createTerminalEmulator();
Then create a screen by that terminal. Finally I created a TextGraph by calling screen.newTextGraphics(); When I put something in TextGraph by calling putCSIStyledString(....),I got Texts on the terminal as I expectd,but font is very unclear from far distance. This is a picture taken from a very close distance.(about 10cm from my phone and screen on my pc.) [image: PJPGBHNC7}JNC0EB$RR7] https://user-images.githubusercontent.com/34052138/161388683-14d7e709-dfc3-4bea-b325-8a53cd36c300.jpg The title of terminal emulator window shows that is a SwingTerminalFrame. I tried to set font by those code but it doesnt work.
SwingTerminalFrame term = (SwingTerminalFrame) factory.createTerminalEmulator();term.setFont(new Font("FreeMono", Font.PLAIN, 30));
Please help me,best regards.
— Reply to this email directly, view it on GitHub https://github.com/mabe02/lanterna/issues/558, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIDBMSZSRSOZ6K3DWDBNWTVDBNUXANCNFSM5SLBF2WA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I looked into source code and found that the default font was directly created by a static method,I am not sure I can override it,forget about it,I chose to use the source code of lanterna rather than binary library so I can be able to do some modification. I hope lanterna can provide feafures such as changing the default fonts in the near future. Thanks.
public SwingTerminal(TerminalScrollController scrollController) {
this(TerminalEmulatorDeviceConfiguration.getDefault(),
SwingTerminalFontConfiguration.getDefault(),
TerminalEmulatorColorConfiguration.getDefault(),
scrollController);
}
I created a terminal by
Then create a screen by that terminal. Finally I created a TextGraph by calling
screen.newTextGraphics();
When I put something in TextGraph by callingputCSIStyledString(....)
,I got Texts on the terminal as I expectd,but font is very unclear from far distance. This is a picture taken from a very close distance.(about 10cm betwin my phone and screen on my pc.) The title of terminal emulator window shows that is a SwingTerminalFrame. I tried to set font by those code but it doesnt work.Please help me,best regards.