News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

Add char "hard space" to font cyr.bdf, please

Started by jk271, December 31, 2012, 03:45:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jk271

Hello,
I am playing simutrans with translation texts in utf8. Traslation text downloaded from simutranslator contains character "hard space" (char 160). Unfortunately character 160 is not present in current font file cyr.bdf, so I see rectagles instead of spaces.

Please, add "hard space" to font cyr.bdf.


It can be easily fixed by addition of following lines into file fonts/cyr.bdf.

diff --git a/simutrans/font/cyr.bdf b/simutrans/font/cyr.bdf
index c49d703..fd1a64d 100644
--- a/simutrans/font/cyr.bdf
+++ b/simutrans/font/cyr.bdf
@@ -1420,6 +1420,13 @@ C0
60
C0
ENDCHAR
+STARTCHAR char160
+ENCODING 160
+SWIDTH 389 0
+DWIDTH 5 0
+BBX 5 0 0 0
+BITMAP
+ENDCHAR
STARTCHAR char161
ENCODING 161
SWIDTH 311 0

Ters

If hard space is added, it should behave as a hard space. Unless support for that already exists, just replacing the hard spaces with normal spaces in the translations is a better solution than having a fake hard space. (A true hard space may be better, but is it really needed?)

jk271

I do not need real hard space. Althow it would be nice to have it in the font. I would like to avoid rectanges being displayed in case of hard space being present in the translation. My aim was to anticipate unintented result of ocurrance of hard space in translation.

I have removed hard space from translation text and it works well. It would work till hard space is accidentally added back.

Thank you for workaround, but I would rather to see it fixed in font file too. :)

Ters

Support for hard spaces could be useful, unfortunately, few people know how to use it right. It could be that Simutrans treats hardspaces right layout-wise, I just don't know where to look.

Dwachs

What is this hard space supposed to do? And why is it present in the translations?
Parsley, sage, rosemary, and maggikraut.

Ters

By what appears to be the most popular definition, a hard space is a space that isn't a place to perform line breaking. Non-breaking space is a synonym in this case. This essentially means that Simutrans should treat it as a letter, not as whitespace, though it looks like one.

jk271

Hard space is good for example for binding preposition to following word. Let me show it on example:
Imagine having text "Some very long text ... at school ... some another very long text".

If normal space (32) is used, "at" and "school" may appear on different lines as automatic line break may occur between the words "at" and "school".

If hard space (160) is used between words "at" and "school", these two word will be always on the same line. Line break will be before them or after them or somewhere else but never between them.


File with font in BDF format describes, how does the character look like. Hard space look like the normal space. I have checked in some automatically generated BDF font. Chars 32 (space) and char 160 (hard space) had the same definition there.

There is no need to tell that character should behave like hard space in the bdf file. It behaves like hard space automatically as it has code 160 (line with text ENCODING 160 in the patch) and character with code 160 is hard space.

Following screenshots shows, hard space "in action". No other BDF font modification except previously posted in this thread has been done.

Ters

Then Simutrans treats hard space right, it just lacks the proper visual definition of the charater itself. This should be added to all fonts, not just cyr.bdf.

prissi

Hard spaces would make it even hard to accomodate breaks at the right locations. Simutrans has anyway a touch job formatting building descriptions. Hard spaces would make those even uglier.

Ters

The purpose of a hard space is to avoid ugly line breaks at inappropriate places. If using hard spaces makes the result uglier, then they are used wrong.

AP

Quote from: Ters on January 04, 2013, 04:54:05 PM
The purpose of a hard space is to avoid ugly line breaks at inappropriate places. If using hard spaces makes the result uglier, then they are used wrong.
Ters is correct. Hard spaces may require a bit of intelligence by the user, but used correctly are a good tool.

VS

Using hard spaces is not worse than displaying boxes ;)

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

prissi

The problem is that the width of the text boxes depends on the zoom levvel. As such the user can hardly guess the line break positions and hard breaks make the work for the program more difficult. Still adding this to the bdf is considered.

Ters

Which text boxes? Or which zoom level? Not that it matters much. If line breaks were predictable, one could just put newline characters at the right places. Hard spaces is to ensure a line break doesn't happen at a particular location no matter what.

I think it's most useful for the help texts. It could have been useful for messages, but the individual message windows are so small that they sometimes have to resort to breaking lines in the middle of a word. Building information windows are much of the same.

VS

Where did this discussion go... LOL :D

Prissi, I think you are imagining uses that have nothing to do with what this is for. Doesn't German have a rule that some words can not end a line? So you do not put normal space after these words, but a hard space. Many word processors insert this character automatically since it is very easy to detect such situations.

It's mostly useful for longer texts, so maybe not so much in normal GUI...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Ters

I have never heard of any rules forbidding specific words from ending a line in the languages I know, but then again, typography was very superficially covered at school, if at all. As a Wikipedia editor I have however learned a rule that forbids line breaks between a number and the corresponding unit of measurement. (I also learned that a dash isn't just a dash.)

VS

Czech forbids one-letter prepositions on end of line. That's actually taught in 4th grade or so :) I guess I am too biased, then, as this character is really important to me (proofreading student papers, meh).

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Fabio

Italian forbids apostrophes on line ending, but usually there is no space between apostrophe and next word.

French usually has a space before a comma, but I doubt a line starting with a comma would be desired.

prissi

I was not aware (apart from the number / unit) that there are such rules for languages. On the other hand, japanese allows breaking wherever you like ...

Ok, enough arguments to have 160 in the fonts.

jk271

I am looking forward to see hard space in repository.
I hope it is not too hard to add a hard space.

Dwachs

incorporated in r6605, please test whether it is working
Parsley, sage, rosemary, and maggikraut.

jk271

I have add hard space to help translation of airtools and than I have opened help text in simutrans. Hard space worked as it has been expected.
Thank you for merge of patch into trunk.