Re: preventing wrapping on certain words only

2011-05-09 Thread Ellié Computing Open Source Program

From: Behdad Esfahbod
Sent: Friday, May 06, 2011 10:01 PM
On 05/06/11 10:07, Ellié Computing Open Source Program wrote:

Hello,

1. I’ve been investigating the Pango API, but could not find a way to
prevent
wrapping for specific portions of text. I saw the global wrapping option
WRAP_WORD / WRAP_CHAR / WRAP_WORD_CHAR using pango_layout_set_wrap ( ).

How should I do this?
The idea behind this is to be sure that a text such as “(...)“ (could be
as
well “/* ... */”) does not get wrapped.

Not quite possible right now.



2. Another question, how would I add a place holder for an image so that
I
could do something like: hello img width=50 height=10! in logic and
determine where the image should be?
Can I obtain that from Pango or should I use something else? more
powerful on
top of it?


Checkout pango/examples/cairoshape.c


I believe that using that shape technic it should be possible to first
render the 'no-wrap' section then make it a 'shape' in the normal text, not
feasible in general but for very simple texts it could work. Of course
having a no-wrap attribute would be way more practical :)

Regards
Armel

___
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list


Re: preventing wrapping on certain words only

2011-05-09 Thread Dov Grobgeld
Couldn't this be done by changing all spaces to NO-BREAK SPACE (U+00A0) in
the section that should not be wrapped? But perhaps, you still have the
problem of hyphenation. Does pango honor  ZERO WIDTH NO-BREAK SPACE
(U+FEFF)? Could you sandwich that between all characters of the section to
prevent hyphenation?

Regards,
Dov

On Mon, May 9, 2011 at 11:07, Ellié Computing Open Source Program 
opensou...@elliecomputing.com wrote:

 From: Behdad Esfahbod
 Sent: Friday, May 06, 2011 10:01 PM

 On 05/06/11 10:07, Ellié Computing Open Source Program wrote:

 Hello,

 1. I’ve been investigating the Pango API, but could not find a way to
 prevent
 wrapping for specific portions of text. I saw the global wrapping option
 WRAP_WORD / WRAP_CHAR / WRAP_WORD_CHAR using pango_layout_set_wrap ( ).

 How should I do this?
 The idea behind this is to be sure that a text such as “(...)“ (could be
 as
 well “/* ... */”) does not get wrapped.

 Not quite possible right now.


  2. Another question, how would I add a place holder for an image so that
 I
 could do something like: hello img width=50 height=10! in logic and
 determine where the image should be?
 Can I obtain that from Pango or should I use something else? more
 powerful on
 top of it?


 Checkout pango/examples/cairoshape.c


 I believe that using that shape technic it should be possible to first
 render the 'no-wrap' section then make it a 'shape' in the normal text, not
 feasible in general but for very simple texts it could work. Of course
 having a no-wrap attribute would be way more practical :)


 Regards
 Armel

 ___
 gtk-i18n-list mailing list
 gtk-i18n-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-i18n-list

___
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list


Re: Drawing glyph bounding box on rendered text?

2011-05-09 Thread august

Behdad posted a python application that draws lines around clusters,
runs, and lines:

http://mail.gnome.org/archives/gtk-i18n-list/2011-April/msg7.html

Maybe you haven't seen that yet and can help.

best -august.

 Hi all,
 
 I'm trying to accurately draw a rectangle around each glyph (not
 character) in rendered text. I'm very close but things aren't quite
 lining up correctly. I've attached an image showing this, but if the
 mailing list filters it, you can also see it here:
 http://www.phonething.com/test.png
 Green box shows line extents, red boxes should show bounding box for
 each glyph.
 
 As you can see, widths and X starting positions of the boxes are off
 slightly. (So is height, but I suppose I could lock that to the
 bottom of the line extents?)
 
 Relevant code that drew that is:
 
 double pango_to_ink = (1.0 / ((double) PANGO_SCALE)); // utility
 
 [ create surface, context, layout, then do pango_layout_set_text() ]
 
 [ for each line in layout use pango_layout_iter_get_line() : ]
 
 pango_layout_iter_get_line_extents(pIter, line_r, NULL);
 pangolineX = pango_to_ink * ((double) line_r.x);  // start position
 of this line of the layout
 pangolineY = pango_to_ink * ((double) line_r.y);
 
 [ get each run in current line: ]
 
 for (i = 0; i  pRun-glyphs-num_glyphs; i++) // loop through
 glyphs in current run
  {
 
  pango_font_get_glyph_extents(font, glyphID, NULL, glyphbox);
 // Just to get glyph height as it's not in the geometry
 
  glyphX = pangolineX + pango_to_ink * ((double)
 pRun-glyphs-glyphs[i].geometry.x_offset);
  glyphY = pangolineY + pango_to_ink * ((double)
 pRun-glyphs-glyphs[i].geometry.y_offset);
  glyphW = pango_to_ink * ((double)
 pRun-glyphs-glyphs[i].geometry.width);
  glyphH = pango_to_ink * ((double) glyphbox.height);
 
   cairo_rectangle(context, glyphX, glyphY, glyphW, glyphH - glyphY);
   cairo_stroke(context);
 
   }
 
 
 Where am I going wrong in getting the glyph bounding boxes
 accurately? (this needs to also work for Indic, Hebrew, Arabic,
 Chinese and so on)
 It doesn't matter if the box has empty space, i.e. incorporates the
 distance between glyphs, though knowing the actual glyph bounding
 box AND the space separating it from the next glyph
 would be ideal.
 
 Thanks and regards,
 Alex
 


 ___
 gtk-i18n-list mailing list
 gtk-i18n-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-i18n-list


-- 
---
http://aug.ment.org

___
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list


Re: Drawing glyph bounding box on rendered text?

2011-05-09 Thread august

Whoops sorry.  Fired that off without noticing he sent that code to you
originally.

I go back into lurker mode.  Appologies.


 Behdad posted a python application that draws lines around clusters,
 runs, and lines:
 
   http://mail.gnome.org/archives/gtk-i18n-list/2011-April/msg7.html
 
 Maybe you haven't seen that yet and can help.
 
 best -august.

___
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list