[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/ezc/Graph/src/driver/ -> svg_font.php (summary)

File containing the ezcGraphSVGDriver class

Author: Freddie Witherden
Copyright: Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
License: http://ez.no/licenses/new_bsd New BSD License
Version: 1.5
File Size: 298 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ezcGraphSvgFont:: (7 methods):
  initializeFont()
  getFontName()
  xpathEscape()
  getGlyph()
  getKerning()
  calculateStringWidth()
  addFontToDocument()


Class: ezcGraphSvgFont  - X-Ref

Helper class, offering requrired calculation basics and font metrics to use
SVG fonts with the SVG driver.

You may convert any ttf font into a SVG font using the `ttf2svg` bianry from
the batik package. Depending on the distribution it may only be available as
`batik-ttf2svg-<version>`.

Usage:
<code>
$font = new ezcGraphSvgFont();
var_dump(
$font->calculateStringWidth( '../tests/data/font.svg', 'Just a test string.' ),
$font->calculateStringWidth( '../tests/data/font2.svg', 'Just a test string.' )
);
</code>

initializeFont( $fontPath )   X-Ref
Initialize SVG font

Loads the SVG font $filename. This should be the path to the file
generated by ttf2svg.

Returns the (normlized) name of the initilized font.

param: string $fontPath
return: string

getFontName( $fontPath )   X-Ref
Get name of font

Get the name of the given font, by extracting its font family from the
SVG font file.

param: string $fontPath
return: string

xpathEscape( $char )   X-Ref
XPath has no standard means of escaping ' and ", with the only solution
being to delimit your string with the opposite type of quote. ( And if
your string contains both concat(  ) it ).

This method will correctly delimit $char with the appropriate quote type
so that it can be used in an XPath expression.

param: string $char
return: string

getGlyph( $fontPath, $char )   X-Ref
Returns the <glyph> associated with $char.

param: string $fontPath
param: string $char
return: float

getKerning( $fontPath, SimpleXMLElement $glyph1, SimpleXMLElement $glyph2 )   X-Ref
Returns the amount of kerning to apply for glyphs $g1 and $g2. If no
valid kerning pair can be found 0 is returned.

param: string $fontPath
param: SimpleXMLElement $g1
param: SimpleXMLElement $g2
return: int

calculateStringWidth( $fontPath, $string )   X-Ref
Calculates the width of $string in the current font in Em's.

param: string $fontPath
param: string $string
return: float

addFontToDocument( DOMDocument $document )   X-Ref
Add font definitions to SVG document

Add the SVG font definition paths for all used glyphs and kernings to
the given SVG document.

param: DOMDocument $document
return: void



Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7