Discussion:
[cairo] Using Pango+Cairo to layout non-standard / international text
robertk54
2008-04-10 14:38:02 UTC
Permalink
I am prototyping functionality which will be used to overlay text onto video.? The text can be of any font / language and will support various forms of animation.? I currently have Pango and Cairo working together.? Pango provides the font and layout and Cairo supports the rendering onto an ARGB surface.? Most of the basics are working.? I can select and render any installed font, scroll, fade, and resize the text.? My next effort is to be able to do 'non-standard' (horzontal / left-to-right) layouts and support international fonts.

I assumed that to handle right-to-left (i.e. Hebrew) or vertical (i.e. Chinese) fonts I would need to?adjust the gravity attribute (and possibly rotate the text?) but this does not seem to work.? I am currently using english fonts such (i.e. Arial) and would hope to?see the text rendered vertically instead of horizontally (I am not yet rotating so I guess I would expect the characters to be rotated but the text layed out horizontally?).??If I use anything but the default setting the text is rendered as small, hollow boxes.? Can anyone provide some insight into how to properly achieve this?

In addition, I would like to implement some code which could adjust the text on a character-by-character basis.? This would be to allow for wrapping text around a curved surface, etc.? Hopefully this is doable using Pango and Cairo alone.

Thanks,
Bob

p.s. thanks again to all who helped with my previous confusion related to FontConfig and FreeType.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20080410/b480d1dc/attachment.html
Kalle Vahlman
2008-04-10 20:25:24 UTC
Permalink
Post by robertk54
I assumed that to handle right-to-left (i.e. Hebrew) or vertical (i.e.
Chinese) fonts I would need to adjust the gravity attribute (and possibly
rotate the text?) but this does not seem to work. I am currently using
english fonts such (i.e. Arial) and would hope to see the text rendered
vertically instead of horizontally (I am not yet rotating so I guess I would
expect the characters to be rotated but the text layed out horizontally?).
If I use anything but the default setting the text is rendered as small,
hollow boxes. Can anyone provide some insight into how to properly achieve
this?
I've had this thread

http://lists.cairographics.org/archives/cairo/2007-October/011792.html

in my inbox as a todo for quite some time so I guess it's time to get
it over with.

Judging by the fact that you referred to the gravity setting, I'm
assuming you have read the original description from

http://library.gnome.org/devel/pango/stable/pango-Vertical-Text.html

I'll paste my proposal for an enhanced version here, in hopes that
this is not too offtopic for the cairo list. It seems to be a
recurring question here after all.

I have also made a demonstration of different orientations while
figuring it out for myself, available from here:

http://iki.fi/zuh/pango-rotated.c

Behdad, if you would kindly review and point out the foolish lies and
misinformation that I might have written below (and in the above
code), I can create a patch to the docs with a revised version and
attach it to a bug for further iterations (I'll do that tomorrow
anyway though).

---8<---

Since 1.16, Pango is able to correctly lay vertical text out. In fact,
it can set layouts of mixed vertical and non-vertical text. This
section describes the how to work with vertical text layout in Pango.

The way this is implemented is through the concept of gravity. Gravity
of normal Latin text is south. One way of defining gravity is to state
that it is the direction from the center of the glyph towards the
baseline. So gravity value of east means that glyphs will be rotated
ninety degrees counterclockwise.

Instead of changing the actual direction of the text flow, Pango
facilitiates vertical text layout by changing the gravity of the
glyphs when the layout (or more specifically, the matrix set to the
current PangoContext) is rotated. This has the huge advantage that
most algorithms working on a PangoLayout do not need any change as the
assumption that lines run in the X direction and stack in the Y
direction holds even for vertical text layouts.

The gravity of the glyphs is automatically adjusted by Pango according
to the natural orientation of the script if you set the base gravity
of the current PangoContext to PANGO_GRAVITY_AUTO with
pango_context_set_base_gravity(). Thus when you rotate the layout by
90 degrees clockwise, vertically orientated scripts are laid out in
their natural orientation, while others are rotated as usual.

A basic vertical layout example looks like this:

PangoMatrix matrix = PANGO_MATRIX_INIT;

...create layout...

pango_layout_set_text(layout, "...vertical text here...");
context = pango_layout_get_context(layout);
pango_context_set_base_gravity(context, PANGO_GRAVITY_AUTO);
pango_matrix_rotate(&matrix, 90.0);
pango_context_set_matrix(context, &matrix);
pango_layout_context_changed (layout);

...render the layout...

Each rendering backend might give further assistance on layout
handling, for example the cairo backend offers a way to automatically
apply the current cairo transformation to the layout so no separate
Pango matrix rotation is needed.

The result of the automatic orientation can be queried with
pango_context_get_gravity(). It returns the gravity depending on the
current transformation matrix set to the current PangoContext.

To force the base gravity setting you can set the PangoGravityHint to
PANGO_GRAVITY_HINT_STRONG. This makes Pango ignore the natural gravity
of the script, and by setting the gravity to the opposite direction of
your rotation you can keep the glyphs in the natural orientation. For
example, rotate the layout 90 degrees clockwise and set the gravity to
PANGO_GRAVITY_EAST to make Latin text flow vertically.

Font descriptions have a gravity property too, that can be set using
pango_font_description_set_gravity() and accessed using
pango_font_description_get_gravity(). However, those are rarely useful
from application code and are mainly used by PangoLayout internally.

Last but not least, one can create PangoAttributes for gravity and
gravity hint using pango_attr_gravity_new() and
pango_attr_gravity_hint_new(). The attributes are also available
through the Pango markup language.

---8>---
--
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi
robertk54
2008-04-11 15:07:18 UTC
Permalink
Post by Kalle Vahlman
I have also made a demonstration of different orientations while
http://iki.fi/zuh/pango-rotated.c
Thanks, this is great. I looked at it and will reference it when I
start using international fonts. I am currently playing with english
fonts and still can't get vertical text working. Below is the current
code I am using, I have moved things around a number of times to no
avail. This is part of my Pango-Cairo prototype code which is
currently running on Windows. The software plays a video file (YUV),
converts each frame to ARGB, overlays text, then renders to a display
window. I can update the text overlay parameters on the fly and the
rendered image updates in real time. The text is entered as a UTF8
string but it is actually just a plain text string with the extra
markup added as shown . . .

"The <i>quick</i> <span foreground="brown">brown</span> fox <span
rise="10000">j</span><span rise="20000">u</span><span
rise="30000">m</span><span rise="20000">p</span><span
rise="10000">s</span> over the <u>lazy</u> dog."

The font is selected from a pull down menu I populate by using
Pango+Cairo to enumerate the available families / faces . . .

<<
pPangoFontMap = pango_cairo_font_map_get_default ();
pango_font_map_list_families (pPangoFontMap, &pPangoFontFamily,
&n_families);
for (i=0; i<n_families; i++)
{
pango_font_family_list_faces (pPangoFontFamily[i],
&pPangoFontFace, &n_faces);
I select the gravity value with a radio button.

My initial goal is to render the text with the characters facing the
normal vertical direction no matter which orientation I select. To see
the string horizontallay I select auto or south. To see the string
vertically I select one of the east or west. With the current code,
selecting east or west simply rotates the text +/- 90 degrees. The
characters rotate with the string and do not remain vertical.

Selecting west the tops of the characters point west and the bottoms
point east. With the current code the characters are mirror images of
the original. 'The quick' is at the north and 'lazy dog' is in the
south. All the characters are flipped (mirror images) not simply the
text as in 'kciuq ehT'. 'The ' is rendered as hollow boxes, all other
characters are rendered in the proper font / format / etc. The current
font selcted is 'Papyrus Normal' but I get the same results other fonts.

Selecting east the tops of the characters point west and the bottoms
point east. With the current code the characters are not mirror images
and can be read as normal. 'The quick' is at the north and 'lazy dog'
is in the south. 'The ' is rendered as hollow boxes, all other
characters are rendered in the proper font / format / etc. The current
font selcted is 'Papyrus Normal' but I get the same results other fonts.

Selecting south or auto the characters and text are rendered normally.
'The ' as well as all other characters are rendered in the proper font
/ format / etc. The current font selcted is 'Papyrus Normal' but I get
the same results other fonts.

Selecting north the tops of the characters point south and the bottoms
point north. With the current code the characters are mirror images of
the original. 'The quick' is at the east and 'lazy dog' is in the
west. All the characters are flipped (mirror images) not simply the
text as in 'kciuq ehT'. 'The ' is rendered as hollow boxes, all other
characters are rendered in the proper font / format / etc. The current
font selcted is 'Papyrus Normal' but I get the same results other fonts.

<<
cairo_save (m_pCairo);
// Get the layout's current attribute list
pPangoAttrList = pango_layout_get_attributes (m_pPangoLayout);
// Update the attribute list from the markup text.
pango_parse_markup (utf8, -1, 0, &pPangoAttrList, &text, NULL,
NULL);
pango_layout_set_attributes (m_pPangoLayout, pPangoAttrList);
pango_layout_set_text (m_pPangoLayout, text, -1);
// Set the color and position of the cairo context.
cairo_set_source_rgba (m_pCairo, m_r, m_g, m_b, m_a);
cairo_move_to (m_pCairo, m_dXPos+m_dXPosStart,
m_dYPos+m_dYPosStart);
switch (gravity)
{
case PANGO_GRAVITY_SOUTH:
case PANGO_GRAVITY_AUTO:
rotation = 0 / (180.0 / G_PI);
break;
case PANGO_GRAVITY_EAST:
rotation = 90 / (180.0 / G_PI);
break;
case PANGO_GRAVITY_NORTH:
rotation = 180 / (180.0 / G_PI);
break;
case PANGO_GRAVITY_WEST:
rotation = 270 / (180.0 / G_PI);
break;
}
cairo_rotate (m_pCairo, rotation);
// Get the layout's current context
pPangoContext = pango_layout_get_context (m_pPangoLayout);
// Try to implement vertical text using context gravity
pango_context_set_base_gravity (pPangoContext, gravity);
pango_context_set_gravity_hint (pPangoContext,
PANGO_GRAVITY_HINT_STRONG);
// Let the pango layout know of the context changes above.
pango_layout_context_changed (m_pPangoLayout);
pango_cairo_show_layout (m_pCairo, m_pPangoLayout);
pango_attr_list_unref (pPangoAttrList);
cairo_restore (m_pCairo);
Kalle Vahlman
2008-04-11 17:35:20 UTC
Permalink
Post by robertk54
cairo_rotate (m_pCairo, rotation);
// Get the layout's current context
pPangoContext = pango_layout_get_context (m_pPangoLayout);
// Try to implement vertical text using context gravity
pango_context_set_base_gravity (pPangoContext, gravity);
pango_context_set_gravity_hint (pPangoContext,
PANGO_GRAVITY_HINT_STRONG);
// Let the pango layout know of the context changes above.
pango_layout_context_changed (m_pPangoLayout);
I think this should rather be pango_cairo_update_layout() to also tell
the transformation to the layout, not just the new options. Now it
just rotates the drawing commands, not the layout logic.
--
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi
robertk54
2008-04-11 22:25:02 UTC
Permalink
Post by robertk54
cairo_rotate (m_pCairo, rotation);
// Get the layout's current context
pPangoContext = pango_layout_get_context (m_pPangoLayout);
// Try to implement vertical text using context gravity
pango_context_set_base_gravity (pPangoContext, gravity);
pango_context_set_gravity_hint (pPangoContext,
PANGO_GRAVITY_HINT_STRONG);
// Let the pango layout know of the context changes above.
pango_layout_context_changed (m_pPangoLayout);
I think this should rather be pango_cairo_update_layout() to also tell
the transformation to the layout, not just the new options. Now it
just rotates the drawing commands, not the layout logic.
Added the call to pango_cairo_update_layout() in various points above
but had no observable affect.
Behdad Esfahbod
2008-04-15 22:42:45 UTC
Permalink
Post by Kalle Vahlman
I have also made a demonstration of different orientations while
http://iki.fi/zuh/pango-rotated.c
Please make a patch to add the functionality as
pango/examples/cairo-vertical.c. Just copy from other examples there
for the skeleton (that is, drop GTK+ requirement).
Post by Kalle Vahlman
Behdad, if you would kindly review and point out the foolish lies and
misinformation that I might have written below (and in the above
code), I can create a patch to the docs with a revised version and
attach it to a bug for further iterations (I'll do that tomorrow
anyway though).
---8<---
Since 1.16, Pango is able to correctly lay vertical text out. In fact,
it can set layouts of mixed vertical and non-vertical text. This
section describes the how to work with vertical text layout in Pango.
The way this is implemented is through the concept of gravity. Gravity
of normal Latin text is south. One way of defining gravity is to state
that it is the direction from the center of the glyph towards the
baseline. So gravity value of east means that glyphs will be rotated
ninety degrees counterclockwise.
Instead of changing the actual direction of the text flow, Pango
facilitiates vertical text layout by changing the gravity of the
s/facilitiates/facilitates/
Post by Kalle Vahlman
glyphs when the layout (or more specifically, the matrix set to the
current PangoContext) is rotated.
This par is inaccurate. "changing the gravity of the layout when ... is
rotated" only holds true for PANGO_GRAVITY_AUTO. How about: "Instead of
changing the actual direction of the text flow, Pango facilitates
vertical text layout by requiring that the layout be rotated using the
context matrix, and then the glyphs be adjusted for vertical layout by
way of setting the right gravity."
Post by Kalle Vahlman
This has the huge advantage that
most algorithms working on a PangoLayout do not need any change as the
assumption that lines run in the X direction and stack in the Y
direction holds even for vertical text layouts.
The gravity of the glyphs is automatically adjusted by Pango according
to the natural orientation of the script if you set the base gravity
of the current PangoContext to PANGO_GRAVITY_AUTO with
pango_context_set_base_gravity(). Thus when you rotate the layout by
90 degrees clockwise, vertically orientated scripts are laid out in
their natural orientation, while others are rotated as usual.
The above par also relies on the default gravity hint setting.
Post by Kalle Vahlman
PangoMatrix matrix = PANGO_MATRIX_INIT;
...create layout...
pango_layout_set_text(layout, "...vertical text here...");
context = pango_layout_get_context(layout);
pango_context_set_base_gravity(context, PANGO_GRAVITY_AUTO);
pango_matrix_rotate(&matrix, 90.0);
pango_context_set_matrix(context, &matrix);
pango_layout_context_changed (layout);
...render the layout...
This is useful, yes.
Post by Kalle Vahlman
Each rendering backend might give further assistance on layout
handling, for example the cairo backend offers a way to automatically
apply the current cairo transformation to the layout so no separate
Pango matrix rotation is needed.
Don't like the "each rendering backend" part.. Just say "using the
cairo backend"... May also make sense to note somewhere that vertical
text is currently only supported by the cairo backend and only with
freetype fonts.
Post by Kalle Vahlman
The result of the automatic orientation can be queried with
pango_context_get_gravity(). It returns the gravity depending on the
current transformation matrix set to the current PangoContext.
I think my original explanation is more accurate.
Post by Kalle Vahlman
To force the base gravity setting you can set the PangoGravityHint to
PANGO_GRAVITY_HINT_STRONG. This makes Pango ignore the natural gravity
of the script, and by setting the gravity to the opposite direction of
your rotation you can keep the glyphs in the natural orientation. For
example, rotate the layout 90 degrees clockwise and set the gravity to
PANGO_GRAVITY_EAST to make Latin text flow vertically.
This is becoming confusing even to me! Maybe just file your suggestions
in bugzilla and I finish and apply them later.
Post by Kalle Vahlman
Font descriptions have a gravity property too, that can be set using
pango_font_description_set_gravity() and accessed using
pango_font_description_get_gravity(). However, those are rarely useful
from application code and are mainly used by PangoLayout internally.
Last but not least, one can create PangoAttributes for gravity and
gravity hint using pango_attr_gravity_new() and
pango_attr_gravity_hint_new(). The attributes are also available
through the Pango markup language.
Good point about markup of course.
Post by Kalle Vahlman
---8>---
Cheers,
--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
Behdad Esfahbod
2008-04-15 22:27:20 UTC
Permalink
Post by robertk54
I assumed that to handle right-to-left (i.e. Hebrew) or vertical (i.e.
Chinese) fonts I would need to adjust the gravity attribute (and
possibly rotate the text?) but this does not seem to work.
For right-to-left text, no, you don't need to mess with gravity. That's
just for vertical.
--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
robertk54
2008-04-15 22:42:28 UTC
Permalink
Post by Behdad Esfahbod
Post by robertk54
I assumed that to handle right-to-left (i.e. Hebrew) or vertical (i.e.
Chinese) fonts I would need to adjust the gravity attribute (and
possibly rotate the text?) but this does not seem to work.
For right-to-left text, no, you don't need to mess with gravity.
That's
Post by Behdad Esfahbod
just for vertical.
Yes, thanks. My statement was not correct but my understanding was.

Will attempting to use such vertical text (font like Chinese which is
intended to be rendered vertically) work on Windows using just
Cairo+Pango? Or, will I need to use FreeType builds of these?
Behdad Esfahbod
2008-04-15 22:44:23 UTC
Permalink
Post by Behdad Esfahbod
Post by Behdad Esfahbod
Post by robertk54
I assumed that to handle right-to-left (i.e. Hebrew) or vertical
(i.e.
Post by Behdad Esfahbod
Post by robertk54
Chinese) fonts I would need to adjust the gravity attribute (and
possibly rotate the text?) but this does not seem to work.
For right-to-left text, no, you don't need to mess with gravity.
That's
Post by Behdad Esfahbod
just for vertical.
Yes, thanks. My statement was not correct but my understanding was.
Will attempting to use such vertical text (font like Chinese which is
intended to be rendered vertically) work on Windows using just
Cairo+Pango? Or, will I need to use FreeType builds of these?
You need the FreeType backend right now. Having said that, I may be
able to fix it in Pango. Will give it a try.
--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
robertk54
2008-04-17 18:10:34 UTC
Permalink
Post by robertk54
Will attempting to use such vertical text (font like Chinese which
is
Post by robertk54
intended to be rendered vertically) work on Windows using just
Cairo+Pango? Or, will I need to use FreeType builds of these?
You need the FreeType backend right now. Having said that, I may be
able to fix it in Pango. Will give it a try.
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32 and
/ or Linux?
robertk54
2008-04-28 14:57:43 UTC
Permalink
Post by robertk54
Will attempting to use such vertical text (font like Chinese which
is?
Post by robertk54
intended to be rendered vertically) work on Windows using just?
Cairo+Pango? Or, will I need to use FreeType builds of these??
?
You need the FreeType backend right now. Having said that, I may be?
able to fix it in Pango. Will give it a try.?
?
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32 and
/ or Linux??

Lack of response makes me assume I have to build this myself. I have
tried setting
up build environments with little luck. Tried GTK on windows using
MINGW but ran into dead end building just about anything. Will try
Linux next,
any tips on getting started here?
Alan W. Irwin
2008-04-28 15:14:34 UTC
Permalink
Post by robertk54
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32 and
/ or Linux??
Most Linux distros should have Pango+Cairo+FT2 binary packages you can
install. For example, Debian testing has
libpango1.0-0, Version 1.20.0-1
libcairo2, Version 1.4.14-1, and
libfreetype6, Version 2.3.5-1+b1

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
robertk54
2008-04-28 15:29:45 UTC
Permalink
Post by robertk54
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32
and?
Post by robertk54
/ or Linux???
?
Most Linux distros should have Pango+Cairo+FT2 binary packages you can?
install. For example, Debian testing has?
libpango1.0-0, Version 1.20.0-1?
libcairo2, Version 1.4.14-1, and?
libfreetype6, Version 2.3.5-1+b1?
?
Alan
I was under the impression the cairo and pango libraries you listed do
not
contain freetype support. This is not the case? I do not need
libcairo2ft2'
or 'libpangoft2'?

Thanks,
Bob
Behdad Esfahbod
2008-04-28 15:49:48 UTC
Permalink
Post by robertk54
Post by Alan W. Irwin
Post by robertk54
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32
and
Post by Alan W. Irwin
Post by robertk54
/ or Linux?
Most Linux distros should have Pango+Cairo+FT2 binary packages you can
install. For example, Debian testing has
libpango1.0-0, Version 1.20.0-1
libcairo2, Version 1.4.14-1, and
libfreetype6, Version 2.3.5-1+b1
Alan
I was under the impression the cairo and pango libraries you listed do
not
contain freetype support. This is not the case? I do not need
libcairo2ft2'
or 'libpangoft2'?
Now you are confusing us. Weren't you looking for win32 builds?
Post by robertk54
Thanks,
Bob
_______________________________________________
cairo mailing list
cairo at cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
robertk54
2008-04-28 15:56:21 UTC
Permalink
Post by robertk54
I was under the impression the cairo and pango libraries you listed do
not
contain freetype support. This is not the case? I do not need
libcairo2ft2'
or 'libpangoft2'?
Now you are confusing us. Weren't you looking for win32 builds?
Post by robertk54
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32
*** and / or Linux? ***
Win32 is for a prototype. Linux is the product. I would prefer
developing
using my working prototype and adding this feature. I got the latest
gtk
for Win32 and the cairo it comes with does not support freetype (pango
does).
I asumed this would be the same for the Linux version.
Carl Worth
2008-04-28 16:33:46 UTC
Permalink
On Mon, 28 Apr 2008 11:56:21 -0400,
Win32 is for a prototype. Linux is the product. I would prefer developing
using my working prototype and adding this feature. I got the latest gtk
for Win32 and the cairo it comes with does not support freetype (pango does).
I asumed this would be the same for the Linux version.
That's an incorrect assumption, then.

Most cairo builds that you will find will support the platform's
"native" font system. For Linux, this is freetype. So the cairo and
pango packages in almost any Linux distribution will have freetype
support.

For Microsoft Windows, most builds of cairo will *not* use freetype,
as it's generally not desired, (instead, cairo-using applications for
Windows generally want to access the native font system so that they
have the same list of fonts available as other applications, etc.).

Personally, I'd recommend developing your Linux applications on Linux
to avoid confusion. :-)

It should technically be possible to build cairo+pango with freetype
support on Microsoft Windows, but it's not something that's done
frequently, meaning that you're unlikely to find pre-built packages
for this, and you may run into some unique issues since you're doing
something that's been tested much less than more conventional uses.

Does that make more sense now?

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080428/2f131b60/attachment.pgp
robertk54
2008-04-28 16:45:15 UTC
Permalink
Post by Carl Worth
Win32 is for a prototype. Linux is the product. I would prefer developing
using my working prototype and adding this feature. I got the latest gtk
for Win32 and the cairo it comes with does not support freetype (pango does).
I asumed this would be the same for the Linux version.
That's an incorrect assumption, then.
Good news.
Post by Carl Worth
Most cairo builds that you will find will support the platform's
"native" font system. For Linux, this is freetype. So the cairo and
pango packages in almost any Linux distribution will have freetype
support.
For Microsoft Windows, most builds of cairo will *not* use freetype,
as it's generally not desired, (instead, cairo-using applications for
Windows generally want to access the native font system so that they
have the same list of fonts available as other applications, etc.).
This would not be an issue for me due to the type of application.
Post by Carl Worth
Personally, I'd recommend developing your Linux applications on Linux
to avoid confusion. :-)
If I were more of a Linux person then I would probably agree to this.
My prototype
is developed using DirectShow. I use it to play a video and
dynamically
add text and adjust settings. The product is something which does much
more
and does not have the ability to provide the instant feedback. I have
to run
a test, convert the files, transfer them and the view them. Real
annoying.
Post by Carl Worth
It should technically be possible to build cairo+pango with freetype
support on Microsoft Windows, but it's not something that's done
frequently, meaning that you're unlikely to find pre-built packages
for this, and you may run into some unique issues since you're doing
something that's been tested much less than more conventional uses.
Yes, I agree it should be possible. And if I had a few more months I
am sure I could do it. I already built cairo without freetype support
using
some msvc settings I found. I was hoping to build more using the MINGW
or even a Linux cross-compiling setup.
Post by Carl Worth
Does that make more sense now?
Absolutely, thanks. Perhaps the person who did the Linux install for
me
did not get the right version of the cairo library containing freetype
support.

Bob
Behdad Esfahbod
2008-04-28 16:45:25 UTC
Permalink
Post by Carl Worth
It should technically be possible to build cairo+pango with freetype
support on Microsoft Windows, but it's not something that's done
frequently, meaning that you're unlikely to find pre-built packages
for this, and you may run into some unique issues since you're doing
something that's been tested much less than more conventional uses.
Actually I think the GIMP builds for win32 use a Pango stack with the
ft2 backend. Tor?
--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
Tor Lillqvist
2008-04-28 16:51:40 UTC
Permalink
Post by Behdad Esfahbod
Actually I think the GIMP builds for win32 use a Pango stack with the
ft2 backend. Tor?
GIMP uses pangoft2 for its text tool, but cairo is not involved in it.

--tml
Alan W. Irwin
2008-04-28 17:28:51 UTC
Permalink
Post by robertk54
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32
and?
Post by robertk54
/ or Linux???
?
Most Linux distros should have Pango+Cairo+FT2 binary packages you can?
install. For example, Debian testing has?
libpango1.0-0, Version 1.20.0-1?
libcairo2, Version 1.4.14-1, and?
libfreetype6, Version 2.3.5-1+b1?
?
Alan
I was under the impression the cairo and pango libraries you listed do not
contain freetype support. This is not the case? I do not need libcairo2ft2'
or 'libpangoft2'?
I don't think you should worry about such details in advance for Linux. In
general, distro packagers try to be as general/helpful in their packaging as
possible rather than arbitrarily trying to make life difficult. Thus, I
suggest the approach you should take is just try to build your application.
If the build complains about a missing header, figure out which software
package that header belongs to (presumbably the development version of one
of the packages above) and install the package, then try building your
application again.

Also, I would advise using pkg-config to figure out what cflags and library
flags you need to build your application.

For example, PLplot has a cairo plotting device driver which depends on
pango, cairo, and freetype2. The PLplot CMake-based build system indirectly
makes calls to pkg-config similar to the following when done by hand:

software at raven> pkg-config --cflags pangocairo
-DPNG_NO_MMX_CODE -I/usr/include/pango-1.0 -I/usr/include/cairo
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2
-I/usr/include/libpng12

software at raven> pkg-config --libs pangocairo
-lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl
-lglib-2.0

pangocairo.pc is part of the libpango1.0-dev package on my system. The full
list of *.pc files belonging to that package is

software at raven> dpkg --listfiles libpango1.0-dev |grep .pc
/usr/lib/pkgconfig/pangoxft.pc
/usr/lib/pkgconfig/pangox.pc
/usr/lib/pkgconfig/pango.pc
/usr/lib/pkgconfig/pangoft2.pc
/usr/lib/pkgconfig/pangocairo.pc

so you may want to substitute "pango" or "pangoft2" for "pangocairo" in the
pkg-config commands above depending on what your application needs.

Anyhow, I hope the above practical experience with building
pango/cairo/freetype-dependent applications is enough to get you started. If
you still run into trouble after that, let the list know what the specific
build error is for your application, and I am sure somebody should be able
to help you further.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

Behdad Esfahbod
2008-04-28 15:49:09 UTC
Permalink
Post by robertk54
Post by robertk54
Will attempting to use such vertical text (font like Chinese which
is
Post by robertk54
intended to be rendered vertically) work on Windows using just
Cairo+Pango? Or, will I need to use FreeType builds of these?
You need the FreeType backend right now. Having said that, I may be
able to fix it in Pango. Will give it a try.
Are there binaries available for Cairo+FT2 and Pango+FT2 for Win32 and
/ or Linux?
Lack of response makes me assume I have to build this myself. I have
tried setting
up build environments with little luck. Tried GTK on windows using
MINGW but ran into dead end building just about anything. Will try
Linux next,
any tips on getting started here?
tml typically ships such binaries. Search for GTK+ win32 builds with
freetype.
--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
Loading...