LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Questions about fbterm's usage in Slint or Slackware installer (http://www.linuxquestions.org/questions/slackware-14/questions-about-fbterms-usage-in-slint-or-slackware-installer-4175495696/)

Didier Spaier 02-20-2014 04:31 PM

Questions about fbterm's usage in Slint or Slackware installer
 
I want to be able to display Chinese characters in Slint installer (that could benefit to the genuine Slackware installer in the future :-)

Of course we can't use a console font in a Linux console for that, as we need to be able to display thousands of characters.

And I won't consider shipping an X server inside the installer ;)

But a volunteer to do Chinese translation told me that I could use fbterm instead.

He's right and fortunately fbterm can work either on top of a framebuffer if available, else fallback to vesa, and still use TTF fonts to display tens of thousands of characters.

So far, so good, I made some tries and that seems to work (installing in the installer mainly fbterm + fontconfig + freetype + wqy-zenhei-font-ttf), but I have an open issue and a question.
  • Open issue: I don't know ho to launch fbterm automatically, as if done in the console of the installer it complains "stdin isn't a interactive tty", so at the moment the user needs to open another terminal (Alt+F2 for instance) and run fbterm manually before typing "setup", which is not acceptable. Is there a way I can do that automatically, for instance adding some instructions at the end of rc.S (either making of the console an interactive tty or opening another tty and running fbterm in it, before any dialog box appears)?
  • Question: to automate launching of fbterm, if I detect that we have no framebuffer (as there is no /dev/fb0), I will have to choose the VESA resolution. I can scan what's available with fbterm --vesa-mode=list, but should I choose simply 640x480 8 bit (the safe choice) of e.g. 1024x768 or more if available?
Thanks for any clue.

Darth Vader 02-21-2014 09:02 AM

On the ol'good days, DARKSTAR Linux used to have a graphical installer, written in Qt, called YaLI. One of the YaLI's variants was capable to run directly from framebuffer, and technically launched directly in the installer initrd, from rc.d scripts, as runlevel 4...

But that damn application was a environment nazi, requiring strictly a root console to properly work.

So, the solution was to use SU. If I remember right, something like:

Code:

/bin/su -l -c /usr/sbin/YaLI
I hope it helps... :hattip:

Didier Spaier 03-05-2014 05:09 PM

Eventually I closed the issue and answered the question stated in the first post of this thread.

1. Closing the issue


The reason why FbTerm complained "stdin isn't a interactive tty" was that I launched it too soon, i.e. before udev had created the ttys.

To avoid that I made following changes in the installer.

I modified Pat's /etc/inittab, that now begins like this
Code:

# /etc/inittab
# Boot-time system configuration/initialization script.
# This is run first except when booting in single-user mode.
# Initialization is now split in two parts, so that we can use an FbTerm for
# the second (interactive) part: as FbTerm needs to be run inside an
# interactive tty, we have to wait until the ttys be created by udev. Didier Spaier
::sysinit:/etc/rc.d/rc.S1
tty1::sysinit:/etc/rc.d/start_rc.S2

# Login /bin/sh invocations on selected ttys.
# /bin/sh being run in interactive mode reads /etc/profile that now sets ENV to
# /etc/rc.d/start_FbTerm.sh, that sets the font size then starts an FbTerm. Didier Spaier
tty1::respawn:-/bin/sh
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh

So now init works this way:
  1. It launches the first (non interactive) part of rc.S, (script rc.S1)
  2. Then it launches start_rc.S2, that run the new script SetFont (see below) then starts an FbTerm running rc.S2, which is the second (interactive) part of rc.S.
  3. After that three ttys become available for interaction between the user and the system. Their expected usage is through FbTerm, but the user can close the FbTerm simply typing "exit", then launch a new one typing "logout", as init respawns the tty with a FbTerm in it.
This may look convoluted, but seems to work ;)

2. Answering the question

Eventually I don't set the VESA mode (I can do that only if no frame buffer is used anyway), but set the size of the font to optimize usage of the display.

By "optimize" I mean: choose the biggest font size that allows to display at least 90 columns and 26 lines in the terminal, whatever be the display size.

Thanks to ability of FbTerm to work either with a VESA driver or a frame buffer driver, the installer will thus have a similar appearance, regardless of display size or method used for drawing.

To do that I wrote the script /etc/rc.d/SetFont (called by /etc/rc.d/start_rc.S2 and /etc/rc.d/start_FbTerm.sh as well) that finds the greatest available VESA display size (in pixels) and sets the size of the font accordingly. That font size is then set as an optional parameter of the fbterm command.

The appropriate font size for a given display size (e.g. 1024x768) is not computed "on the fly" (doing that is an exercise left to te reader :-) but simply recorded for the display sizes most used in recent years, as retrieved for instance here. In case of an unusual (i.e. not recorded in SetFont) display size, FbTerm's default size is be used.

Of course the optimal font size depends on font's dimensions (width and height), but we will use only two fonts, both mono spaced: DejaVu Sans Mono for most European scripts and WenQuanYi Zen Hei Mono, mostly for CJK (Chinese, Japanese and Korean). Fortunately these fonts are already included in Slackware, thanks Pat.

Those who didn't fell asleep reading this boring post up to this point (congratulations!) and wanting to know more (if any :-) will be able to see the scripts in the ISO installers in directory http://slint.fr/testing. Just mount the ISO file somewhere and unpack the initrd.

I'll post about using the "testing" installers and request help to check the list of usual display sizes in specific threads later.


All times are GMT -5. The time now is 05:01 AM.