[Cairo] Re: [xsvg] cairo_text_extents ?

Carl Worth cworth at east.isi.edu
Tue Nov 25 20:29:24 PST 2003


On Nov 25, Keith Packard wrote:
 > Yeah, I tried that with Xft and ended up confusing everyone horribly.  
 > Instead of inventing our own labeling scheme, we should just steal an 
 > existing one.  The X one is at least known to most people using existing X 
 > interfaces and shares 'left side bearing' with postscript.  Let's get 
 > metric conventions from existing systems and see if there's anything like 
 > a concensus.

I don't think we'll see great consensus, but there are some common
themes. In addition to the three from my previous mail, I've found
three more examples below.

My preference would actually be for a simple user-space rectangle
(x,y,width,height) along with x_advance, y_advance. The "advance" term
shows up in multiple places, and it has definite advantages over the
easily-confused "width" of PostScript.

As for the simple rectangle for the bounding box, it's quite common in
the APIs I've found. I quoted AFM before which had it, and all three
examples below also have it. Java has a Rectangle2D; Apple has
topLeft,width,height; and GDI has GlyphOrigin,BlackBoxX,BlackBoxY
(yes, here X/Y actually mean WIDTH/HEIGHT).

Several similar names do show up for the term known as "left
sidebearing", "LSB", "sideBearing", etc. But, couldn't we just omit
this field? Unless I'm missing something, it seems trivial to compute
this term given the current point and the bounding box.

Or would it help avoid confusion to include left_bearing,
right_bearing even if redundant?

Keith, can you provide more specific details about what problems you
had with the Xft API?

-Carl

Disclaimer: I don't know if any of these are current, standard, well
-loved, or universally-loathed. It's just what I was able to come up
with via google.

[1] Java 2
 float	getAdvanceX()
 float	getAdvanceY()
 Rectangle2D	getBounds2D()
 float	getLSB()
 float	getRSB() 

[2] Windows GDI

typedef struct _GLYPHMETRICS { 
  UINT  gmBlackBoxX; 
  UINT  gmBlackBoxY; 
  POINT gmptGlyphOrigin; 
  short gmCellIncX; 
  short gmCellIncY; 
} GLYPHMETRICS, *LPGLYPHMETRICS; 

[3] Apple Type Services (Carbon)

struct ATSGlyphScreenMetrics {
   Float32Point deviceAdvance;
   Float32Point topLeft;
   UInt32 height;
   UInt32 width;
   Float32Point sideBearing;
   Float32Point otherSideBearing;
};

[1] http://java.sun.com/j2se/1.4.2/docs/api/java/awt/font/GlyphMetrics.html
[2] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_48he.asp
[3] http://developer.apple.com/documentation/Carbon/Reference/ATS/atsfontsref_Reference/data_type_group_3.html




More information about the cairo mailing list