Logo Search packages:      
Sourcecode: acidbase version File versions  Download package

Cpdf::getTextWidth ( size,

calculate how wide a given text string will be on a page, at a given size. this can be called externally, but is alse used by the other class functions

Definition at line 2248 of file class.pdf.php.

References PRVTcheckTextDirective(), selectFont(), and setCurrentFont().

Referenced by PRVTgetTextPosition().

  // this function should not change any of the settings, though it will need to
  // track any directives which change during calculation, so copy them at the start
  // and put them back at the end.
  $store_currentTextState = $this->currentTextState;

  if (!$this->numFonts){

  // converts a number or a float to a string so it can get the width
  $text = "$text";

  // hmm, this is where it all starts to get tricky - use the font information to
  // calculate the width of each character, add them up and convert to user units
  $cf = $this->currentFont;
  for ($i=0;$i<$len;$i++){
    $directive = $this->PRVTcheckTextDirective($text,$i,$f);
    if ($directive){
      if ($f){
        $cf = $this->currentFont;
    } else {
      if (isset($this->fonts[$cf]['differences'][$char])){
        // then this character is being replaced by another
        $name = $this->fonts[$cf]['differences'][$char];
        if (isset($this->fonts[$cf]['C'][$name]['WX'])){
      } else if (isset($this->fonts[$cf]['C'][$char]['WX'])){
  $this->currentTextState = $store_currentTextState;

  return $w*$size/1000;

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index