Replace soft-hyphenation character with a hard-hyphenation
Hi,
I'm trying to get soft-hyphenation to work in an acceptable fashion before going into deeper details.
I want te solve the following task;
- In the _measureUnbrokenSpan loop (Layout-TNG-Compute.cpp) soft-hyphens are detected. It can nicely break in such situation. - Currently a soft-hypen is invisible, but clearly the position in the source stream is know. - Based on this position I want to *replace* the softhypen in this rendering run with a '-' - This might need an a priori knowledge of the '-' width
Could anyone suggest how to append a Span with only a "-" or replace the soft-hyphen with a hard one in this run?
Thanks in advance,
Stefan de Konink
I'm trying to get soft-hyphenation to work in an acceptable fashion before going into deeper details.
Before I respond to the rest, let me just mention that the code was written (by me) with the intention that soft hyphens ought to work, but I never got round to doing any testing (and to my knowledge, neither has anyone else) so I'm not surprised that it doesn't work.
I want te solve the following task;
- In the _measureUnbrokenSpan loop (Layout-TNG-Compute.cpp) soft-hyphens
are detected. It can nicely break in such situation.
- Currently a soft-hypen is invisible, but clearly the position in the
source stream is know.
- Based on this position I want to *replace* the softhypen in this
rendering run with a '-'
- This might need an a priori knowledge of the '-' width
Could anyone suggest how to append a Span with only a "-" or replace the soft-hyphen with a hard one in this run?
That's not quite the correct way to do it. If you bring up the character map application for your OS, you'll notice that U+00AD (the soft hyphen) has a valid glyph and looks just like a normal hyphen, so what the code is supposed to do is leave the soft hyphen in place when it's needed and omit it when it's not. This means that there aren't any problems with needing to know the width of the character, because we've already measured it.
So the way it was intended to work was that unbroken spans are converted into broken spans by _measureUnbrokenSpan (i.e. word wrapping) which pays attention to soft hyphens. _outputLine then simply omits soft hyphens unless they're at the end of a broken span. Omitting, in this case, means that they don't get put into the Layout::characters_ or Layout::glyphs_ vectors. From your description, it sounds like the logic I described in the last two sentences isn't working and it's always omitting the character and/or glyph.
Please continue to ask questions if any of this e-mail didn't make any sense. There are two debugging features in the layout code: I expect you've already found the IFTRACE debug macro at the top of Layout-TNG-Compute.cpp, but there's also the Layout::dumpAsText() function which is called in a commented-out line at sp-flowtext.cpp:509 (and others in sp-text.cpp, either before or after the text is fitted onto a path).
Richard.
Richard Hughes wrote:
From your description, it sounds like the logic I described in the last two sentences isn't working and it's always omitting the character and/or glyph.
Indeed it never shows the character and/or glyph. It is good news that no string need to be modified. I'll try to debug it :) Because I *really* want to get this to work.
As I also told on IRC a few years a go, I have a succesfull Open Source Bulletin Board system running on Inkscape for rendering (the only thing that does flows nicely). Now there is a new broadcaster that wants to use it and adding hyphenation support is a real wish of mine.
Stefan
On Thu, Oct 30, 2008 at 11:48 PM, Stefan de Konink wrote:
Indeed it never shows the character and/or glyph. It is good news that no string need to be modified. I'll try to debug it :) Because I *really* want to get this to work.
That means also, that Inkscape should be able to mark parts of text as written in a specific language ;-)
Alexandre
Alexandre Prokoudine wrote:
On Thu, Oct 30, 2008 at 11:48 PM, Stefan de Konink wrote:
Indeed it never shows the character and/or glyph. It is good news that no string need to be modified. I'll try to debug it :) Because I *really* want to get this to work.
That means also, that Inkscape should be able to mark parts of text as written in a specific language ;-)
No this is the wrong perception :) Inkscape supports annotated text; in order to hyphenate 'normal' text it you need to have grammar rules like Babel (TeX) uses or search and replace on a wordlist.
Stefan
On Thu, Oct 30, 2008 at 5:41 PM, Richard Hughes <cyreve@...400...> wrote:
I'm trying to get soft-hyphenation to work in an acceptable fashion before going into deeper details.
Before I respond to the rest, let me just mention that the code was written (by me) with the intention that soft hyphens ought to work, but I never got round to doing any testing (and to my knowledge, neither has anyone else) so I'm not surprised that it doesn't work.
So, once we get this to work, will it be possible to add a "Enable hyphenation" command or extension which would insert soft hyphens into a flowed text object, based on language, e.g. using TeX vocabularies?
bulia byak wrote:
On Thu, Oct 30, 2008 at 5:41 PM, Richard Hughes <cyreve@...400...> wrote:
I'm trying to get soft-hyphenation to work in an acceptable fashion before going into deeper details.
Before I respond to the rest, let me just mention that the code was written (by me) with the intention that soft hyphens ought to work, but I never got round to doing any testing (and to my knowledge, neither has anyone else) so I'm not surprised that it doesn't work.
So, once we get this to work, will it be possible to add a "Enable hyphenation" command or extension which would insert soft hyphens into a flowed text object, based on language, e.g. using TeX vocabularies?
Exactly. But hyphenation is by default a strategy to break up text :)
And... if I understand CSS3 correctly, the language component is part of it.
Stefan
participants (4)
-
Alexandre Prokoudine
-
bulia byak
-
Richard Hughes
-
Stefan de Konink