How to assign word spacing for multilingual fonts?

satya's picture

Hello folks,

I am working on a Devanagari typeface and this will have a Latin version too. Since I have both the languages in the same font together and I want the word spacing for Devanagari a little tighter than the Latin. How do I assign two separate word spacing in a single font?

Is there a way to assign separate word spacings in FontLab?

Thanks a bunch.
Satya

John Hudson's picture

Create two separate word space glyphs, one called /space/ and encoded as U+0020 (and also as U+00A0 if you want the same glyph to serve as the no-break space) and another called something like /spave.dev/ and left unencoded. Then, in your Devanagari OpenType Layout you implement the Localised Forms 'locl' feature, and have a lookup that maps

space -> space.dev

The 'locl' layout feature is applied by Uniscribe and compatible layout engines prior to any other feature (but it also a good idea to order the lookups in your font so that 'locl' precedes others).

Now, that's the approved method, but you will probably find that results vary because not all software will treat the wordspace character as part of the run of Devanagari text. But it should work in Windows Vista.

satya's picture

You are so helpful, John.
Thanks a lot.

sergeym's picture

I think we tried two use different spaces on one of our fonts in Vista. It would work fine in single-script scenarios, but in mixed text, non-uniformal space width did not look very good. So, ou should be carefeul and know what you are doing.

Thanks,
Sergey

twardoch's picture

For consistency's sake, I'd call the other space space.deva, since "deva" is the OT script tag for Devanagari.

In FontLab Studio, in the right-bottom part of the OpenType panel, you'd write:

languagesystem latn dflt;
languagesystem deva dflt;

and then you'd add a new OpenType feature and in the top-right part of the OpenType panel, you'd write:

feature locl {
sub space by space.deva;
} locl;

Regards,
Adam

John Hudson's picture

For consistency’s sake, I’d call the other space space.deva, since “deva” is the OT script tag for Devanagari.

Unless you are using the 'dev2' tag for the improved Vista / Office 2007 shaping, or are making a font that supports both tags, in which case '.dev' seems a reasonably compromise.

In FontLab Studio, in the right-bottom part of the OpenType panel, you’d write...

You could, but Devanagari requires OTL lookups not supported by FontLab, so you need to work in VOLT.

twardoch's picture

John,

indeed, the fact I gave instructions for FLS was an oversimplification of some sort. I mean, the instructions could have general use for any writing system, also non-complex, but for Devanagari, you'll need to end up using VOLT. At some point, FontLab Studio will support mark attachment but not yet.

A.

dan_reynolds's picture

Hello! Can I revive this thread for a moment?

I've been trying this above-mentioned method in VOLT on Vista, and haven't been able to get it to work properly. I've created a feature with an alternate word space, and this does allow my text in Word, etc. to switch from the normal space to the alternate space, but not quite back again.

When I just have Latin text, or Devanagari text, everything is fine. In the Latin text words are separated by the normal space, and in Devanagari text the words are separated by the alternate space. But when the two scripts mix, it isn't so happy.

My problem, as John and Sergey predict, appears when I have a text like वे वर्ष 1962 तक. Specifically, my problem is the space around "1962"… the space before the 1 is the alternate space, and the space after the 2 is a normal space. This is not how I'd like the line of text to render.

In Nepali text, for instance, it is less of an issue, as Nepali seems to use Latin figures and punctuation less often. But languages like Hindi, which may use it a lot, cause more difficulty. Although in my feature I also have alternate figures (one.deva, two.deva, etc.…) and alternate punctuation (comma.deva, etc.), these do not switch the way the space does, even when I set the default language in Word to Hindi. I don't know why they won't switch.

So, if I use two space glyphs, everything is groovy. Until a "Latin" character pops up in the string of text. Afterwards, all "Latin" characters will be the default Latin characters—including the word space—until another Devanagari character comes up. Then the space glyph switches to its alternate again. I don't know why this happens, and I don't know why my other alternates don't switch either.

Other than that, I can get almost everything I put into VOLT to come out again properly! Except the below the base mark positioning. But that is another story ;-)

satya's picture

Very good question, Dan.

dan_reynolds's picture

Yes, I hope so. I'm waiting for a very good answer!

Miguel Sousa's picture

> the space before the 1 is the alternate space, and the space after the 2 is a normal space. This is not how I’d like the line of text to render.

This sounds like a layout engine issue, not a problem in your font.

(hack alert!) You can try adding a contextual substitution to the font that replaces the default space by the Devanagari space, when the default space is preceded by a digit and followed by a Devanagari character. In pseudo-FDK notation,

sub [all digit glyphs] space' [all Devanagari glyphs] by space.dev;

John Hudson's picture

I don't think that hack would work for Dan, Miguel. The issue here is probably that the layout engine is splitting the character string into separate glyph runs and associating word spaces with the preceding run. So in Dan's example the runs would look like this:

devanagari space | numerals space | devanagari

But what he needs to get his variant word spaces working correctly is either

devanagari space | numerals | space devanagari

or a single run that merges numerals

devanagari space numerals space devanagari

dan_reynolds's picture

Miguel, I tried to create a hack substitution, but that didn't work either. I don't know how much substituting is supported in Word anyway.

I think that you are right suggesting that this has to do with the layout engine and not the font, but I don't know enough to say for sure. John sums the issue up quite well.

Syndicate content Syndicate content