function StrokeText($x, $y, $txt, $dir = 0, $paragraph_align = "left", $debug = false) { $x = round($x); $y = round($y); // Do special language encoding if (LANGUAGE_CYRILLIC) { $txt = LanguageConv::ToCyrillic($txt); } if (!is_numeric($dir)) { JpGraphError::Raise(" Direction for text most be given as an angle between 0 and 90."); } if ($this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2 + 1) { $this->_StrokeBuiltinFont($x, $y, $txt, $dir, $paragraph_align, $debug); } elseif ($this->font_family >= FF_COURIER && $this->font_family <= FF_BOOK) { $this->_StrokeTTF($x, $y, $txt, $dir, $paragraph_align, $debug); } else { JpGraphError::Raise(" Unknown font font family specification. "); } }
function StrokeText($x, $y, $txt, $dir = 0, $paragraph_align = "left") { // Do special language encoding if (LANGUAGE_CYRILLIC) { $txt = LanguageConv::ToCyrillic($txt); } if (!is_numeric($dir)) { JpGraphError::Raise(" Direction for text most be given as an angle between 0 and 90."); } if ($this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2 + 1) { // Internal font if (is_numeric($dir) && $dir != 90 && $dir != 0) { JpGraphError::Raise(" Internal font does not support drawing text at arbitrary angle. Use TTF fonts instead."); } $h = $this->GetTextHeight($txt); $fh = $this->GetFontHeight($txt); $w = $this->GetTextWidth($txt); if ($this->text_halign == "right") { $x -= $dir == 0 ? $w : $h; } elseif ($this->text_halign == "center") { $x -= $dir == 0 ? $w / 2 : $h / 2; } if ($this->text_valign == "top") { $y += $dir == 0 ? $h : $w; } elseif ($this->text_valign == "center") { $y += $dir == 0 ? $h / 2 : $w / 2; } if ($dir == 90) { imagestringup($this->img, $this->font_family, $x, $y, $txt, $this->current_color); } else { if (ereg("\n", $txt)) { $tmp = explode("\n", $txt); for ($i = 0; $i < count($tmp); ++$i) { $w1 = $this->GetTextWidth($tmp[$i]); if ($paragraph_align == "left") { imagestring($this->img, $this->font_family, $x, $y - $h + 1 + $i * $fh, $tmp[$i], $this->current_color); } elseif ($paragraph_align == "right") { imagestring($this->img, $this->font_family, $x + ($w - $w1), $y - $h + 1 + $i * $fh, $tmp[$i], $this->current_color); } else { imagestring($this->img, $this->font_family, $x + $w / 2 - $w1 / 2, $y - $h + 1 + $i * $fh, $tmp[$i], $this->current_color); } } } else { //Put the text imagestring($this->img, $this->font_family, $x, $y - $h + 1, $txt, $this->current_color); } } } elseif ($this->font_family >= FF_COURIER && $this->font_family <= FF_BOOK) { // TTF font $file = $this->ttf->File($this->font_family, $this->font_style); $angle = $dir; $bbox = ImageTTFBBox($this->font_size, $angle, $file, $txt); if ($this->text_halign == "right") { $x -= $bbox[2] - $bbox[0]; } elseif ($this->text_halign == "center") { $x -= ($bbox[4] - $bbox[0]) / 2; } elseif ($this->text_halign == "topanchor") { $x -= $bbox[4] - $bbox[0]; } elseif ($this->text_halign == "left") { $x += -($bbox[6] - $bbox[0]); } if ($this->text_valign == "top") { $y -= $bbox[5]; } elseif ($this->text_valign == "center") { $y -= ($bbox[5] - $bbox[1]) / 2; } elseif ($this->text_valign == "bottom") { $y -= $bbox[1]; } // Use lower left of bbox as fix-point, not the default baselinepoint. $x -= $bbox[0]; if ($GLOBALS['gd2']) { $old = ImageAlphaBlending($this->img, true); } ImageTTFText($this->img, $this->font_size, $angle, $x, $y, $this->current_color, $file, $txt); if ($GLOBALS['gd2']) { ImageAlphaBlending($this->img, $old); } } else { JpGraphError::Raise(" Unknown font font family specification. "); } }
public function CreateUTF8Banner($Query) { global $LNG, $LANG; $image = imagecreatefrompng($this->source); $date = date(DATEFORMAT); $Font = ROOT_PATH . 'styles/arial.ttf'; // Variables $b_univ = iconv("UTF-8", "koi8-r", $Query['game_name']); $b_user = iconv("UTF-8", "koi8-r", $Query['username']); $b_planet = iconv("UTF-8", "koi8-r", $Query['name']); $b_xyz = "[" . $Query['galaxy'] . ":" . $Query['system'] . ":" . $Query['planet'] . "]"; $b_lvl = $Query['total_rank'] . "/" . $Query['users_amount']; $b_build = $LNG['ub_buildings'] . ": " . pretty_number($Query['build_points']); $b_fleet = $LNG['ub_fleets'] . ": " . pretty_number($Query['fleet_points']); $b_def = $LNG['ub_defenses'] . ": " . pretty_number($Query['defs_points']); $b_search = $LNG['ub_researh'] . ": " . pretty_number($Query['tech_points']); $b_total = $LNG['ub_points'] . ": " . pretty_number($Query['total_points']); // Colors $red = hexdec(substr($this->textcolor, 0, 2)); $green = hexdec(substr($this->textcolor, 2, 4)); $blue = hexdec(substr($this->textcolor, 4, 6)); $select = imagecolorallocate($image, $red, $green, $blue); // Display // Univers name imagettftext($image, 7, 0, $this->CenterTextBanner($b_univ, 1, 630), 65, $select, $Font, LanguageConv::ToCyrillic($b_univ)); // Today date imagettftext($image, 7, 0, $this->CenterTextBanner($date, 1, 630), 75, $select, $Font, $date); // Player name imagettftext($image, 10, 0, 15, 18, $select, $Font, LanguageConv::ToCyrillic($b_user)); // Player b_planet imagettftext($image, 10, 0, 150, 18, $select, $Font, LanguageConv::ToCyrillic($b_planet . " " . $b_xyz)); // Player level imagettftext($image, 14, 0, $this->CenterTextBanner($b_lvl, 10, 795), 46, $select, $Font, $b_lvl); // Player stats imagettftext($image, 10, 0, 15, 36, $select, $Font, LanguageConv::ToCyrillic($b_build)); imagettftext($image, 10, 0, 15, 51, $select, $Font, LanguageConv::ToCyrillic($b_fleet)); imagettftext($image, 10, 0, 230, 36, $select, $Font, LanguageConv::ToCyrillic($b_search)); imagettftext($image, 10, 0, 230, 51, $select, $Font, LanguageConv::ToCyrillic($b_def)); imagettftext($image, 10, 0, 15, 66, $select, $Font, LanguageConv::ToCyrillic($b_total)); // Creat and delete banner ImagePNG($image); imagedestroy($image); }