当前位置: 首页>>代码示例>>PHP>>正文


PHP TCPDF_FONTS::unichr方法代码示例

本文整理汇总了PHP中TCPDF_FONTS::unichr方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_FONTS::unichr方法的具体用法?PHP TCPDF_FONTS::unichr怎么用?PHP TCPDF_FONTS::unichr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TCPDF_FONTS的用法示例。


在下文中一共展示了TCPDF_FONTS::unichr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hyphenateWord

 /**
  * Returns an array of chars containing soft hyphens.
  * @param $word (array) array of chars
  * @param $patterns (array) Array of hypenation patterns.
  * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm.
  * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
  * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
  * @param $charmin (int) Minimum word length to apply the hyphenation algoritm.
  * @param $charmax (int) Maximum length of broken piece of word.
  * @return array text with soft hyphens
  * @author Nicola Asuni
  * @since 4.9.012 (2010-04-12)
  * @protected
  */
 protected function hyphenateWord($word, $patterns, $dictionary = array(), $leftmin = 1, $rightmin = 2, $charmin = 1, $charmax = 8)
 {
     $hyphenword = array();
     // hyphens positions
     $numchars = count($word);
     if ($numchars <= $charmin) {
         return $word;
     }
     $word_string = TCPDF_FONTS::UTF8ArrSubString($word, '', '', $this->isunicode);
     // some words will be returned as-is
     $pattern = '/^([a-zA-Z0-9_\\.\\-]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$/';
     if (preg_match($pattern, $word_string) > 0) {
         // email
         return $word;
     }
     $pattern = '/(([a-zA-Z0-9\\-]+\\.)?)((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$/';
     if (preg_match($pattern, $word_string) > 0) {
         // URL
         return $word;
     }
     if (isset($dictionary[$word_string])) {
         return TCPDF_FONTS::UTF8StringToArray($dictionary[$word_string], $this->isunicode, $this->CurrentFont);
     }
     // suround word with '_' characters
     $tmpword = array_merge(array(95), $word, array(95));
     $tmpnumchars = $numchars + 2;
     $maxpos = $tmpnumchars - $charmin;
     for ($pos = 0; $pos < $maxpos; ++$pos) {
         $imax = min($tmpnumchars - $pos, $charmax);
         for ($i = $charmin; $i <= $imax; ++$i) {
             $subword = strtolower(TCPDF_FONTS::UTF8ArrSubString($tmpword, $pos, $pos + $i, $this->isunicode));
             if (isset($patterns[$subword])) {
                 $pattern = TCPDF_FONTS::UTF8StringToArray($patterns[$subword], $this->isunicode, $this->CurrentFont);
                 $pattern_length = count($pattern);
                 $digits = 1;
                 for ($j = 0; $j < $pattern_length; ++$j) {
                     // check if $pattern[$j] is a number
                     if ($pattern[$j] >= 48 and $pattern[$j] <= 57) {
                         if ($j == 0) {
                             $zero = $pos - 1;
                         } else {
                             $zero = $pos + $j - $digits;
                         }
                         if (!isset($hyphenword[$zero]) or $hyphenword[$zero] != $pattern[$j]) {
                             $hyphenword[$zero] = TCPDF_FONTS::unichr($pattern[$j], $this->isunicode);
                         }
                         ++$digits;
                     }
                 }
             }
         }
     }
     $inserted = 0;
     $maxpos = $numchars - $rightmin;
     for ($i = $leftmin; $i <= $maxpos; ++$i) {
         if (isset($hyphenword[$i]) and $hyphenword[$i] % 2 != 0) {
             // 173 = soft hyphen character
             array_splice($word, $i + $inserted, 0, 173);
             ++$inserted;
         }
     }
     return $word;
 }
开发者ID:TheTypoMaster,项目名称:myapps,代码行数:77,代码来源:tcpdf.php

示例2: putHtmlListBullet


//.........这里部分代码省略.........
             break;
             // ordered types
             // $this->listcount[$this->listnum];
             // $textitem
         // ordered types
         // $this->listcount[$this->listnum];
         // $textitem
         case '1':
         case 'decimal':
             $textitem = $this->listcount[$this->listnum];
             break;
         case 'decimal-leading-zero':
             $textitem = sprintf('%02d', $this->listcount[$this->listnum]);
             break;
         case 'i':
         case 'lower-roman':
             $textitem = strtolower(TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]));
             break;
         case 'I':
         case 'upper-roman':
             $textitem = TCPDF_STATIC::intToRoman($this->listcount[$this->listnum]);
             break;
         case 'a':
         case 'lower-alpha':
         case 'lower-latin':
             $textitem = chr(97 + $this->listcount[$this->listnum] - 1);
             break;
         case 'A':
         case 'upper-alpha':
         case 'upper-latin':
             $textitem = chr(65 + $this->listcount[$this->listnum] - 1);
             break;
         case 'lower-greek':
             $textitem = TCPDF_FONTS::unichr(945 + $this->listcount[$this->listnum] - 1, $this->isunicode);
             break;
             /*
             // Types to be implemented (special handling)
             case 'hebrew': {
             	break;
             }
             case 'armenian': {
             	break;
             }
             case 'georgian': {
             	break;
             }
             case 'cjk-ideographic': {
             	break;
             }
             case 'hiragana': {
             	break;
             }
             case 'katakana': {
             	break;
             }
             case 'hiragana-iroha': {
             	break;
             }
             case 'katakana-iroha': {
             	break;
             }
             */
         /*
         // Types to be implemented (special handling)
         case 'hebrew': {
         	break;
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:67,代码来源:tcpdf.php

示例3: getCellCode

 /**
  * Returns the PDF string code to print a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text.<br />
  * If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.
  * @param $w (float) Cell width. If 0, the cell extends up to the right margin.
  * @param $h (float) Cell height. Default value: 0.
  * @param $txt (string) String to print. Default value: empty string.
  * @param $border (mixed) Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
  * @param $ln (int) Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right (or left for RTL languages)</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
  * @param $align (string) Allows to center or align the text. Possible values are:<ul><li>L or empty string: left align (default value)</li><li>C: center</li><li>R: right align</li><li>J: justify</li></ul>
  * @param $fill (boolean) Indicates if the cell background must be painted (true) or transparent (false).
  * @param $link (mixed) URL or identifier returned by AddLink().
  * @param $stretch (int) font stretch mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if text is larger than cell width</li><li>2 = forced horizontal scaling to fit cell width</li><li>3 = character spacing only if text is larger than cell width</li><li>4 = forced character spacing to fit cell width</li></ul> General font stretching and scaling values will be preserved when possible.
  * @param $ignore_min_height (boolean) if true ignore automatic minimum height value.
  * @param $calign (string) cell vertical alignment relative to the specified Y value. Possible values are:<ul><li>T : cell top</li><li>C : center</li><li>B : cell bottom</li><li>A : font top</li><li>L : font baseline</li><li>D : font bottom</li></ul>
  * @param $valign (string) text vertical alignment inside the cell. Possible values are:<ul><li>T : top</li><li>M : middle</li><li>B : bottom</li></ul>
  * @return string containing cell code
  * @protected
  * @since 1.0
  * @see Cell()
  */
 protected function getCellCode($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'M')
 {
     // replace 'NO-BREAK SPACE' (U+00A0) character with a simple space
     $txt = str_replace(TCPDF_FONTS::unichr(160, $this->isunicode), ' ', $txt);
     $prev_cell_margin = $this->cell_margin;
     $prev_cell_padding = $this->cell_padding;
     $txt = TCPDF_STATIC::removeSHY($txt, $this->isunicode);
     $rs = '';
     //string to be returned
     $this->adjustCellPadding($border);
     if (!$ignore_min_height) {
         $min_cell_height = $this->getCellHeight($this->FontSize);
         if ($h < $min_cell_height) {
             $h = $min_cell_height;
         }
     }
     $k = $this->k;
     // check page for no-write regions and adapt page margins if necessary
     list($this->x, $this->y) = $this->checkPageRegions($h, $this->x, $this->y);
     if ($this->rtl) {
         $x = $this->x - $this->cell_margin['R'];
     } else {
         $x = $this->x + $this->cell_margin['L'];
     }
     $y = $this->y + $this->cell_margin['T'];
     $prev_font_stretching = $this->font_stretching;
     $prev_font_spacing = $this->font_spacing;
     // cell vertical alignment
     switch ($calign) {
         case 'A':
             // font top
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'];
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'] - $this->FontAscent - $this->FontDescent;
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h - $this->FontAscent - $this->FontDescent) / 2;
                     break;
             }
             break;
         case 'L':
             // font baseline
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'] + $this->FontAscent;
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'] - $this->FontDescent;
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h + $this->FontAscent - $this->FontDescent) / 2;
                     break;
             }
             break;
         case 'D':
             // font bottom
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'] + $this->FontAscent + $this->FontDescent;
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'];
                     break;
                 default:
                 case 'C':
//.........这里部分代码省略.........
开发者ID:bochniak,项目名称:lms-1,代码行数:101,代码来源:tcpdf.php

示例4: array

$core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats');
// set fill color
$pdf->SetFillColor(221, 238, 255);
// create one HTML table for each core font
foreach ($core_fonts as $font) {
    // add a page
    $pdf->AddPage();
    // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
    // set font for title
    $pdf->SetFont('helvetica', 'B', 16);
    // print font name
    $pdf->Cell(0, 10, 'FONT: ' . $font, 1, 1, 'C', true, '', 0, false, 'T', 'M');
    // set font for chars
    $pdf->SetFont($font, '', 16);
    // print each character
    for ($i = 0; $i < 256; ++$i) {
        if ($i > 0 and $i % 16 == 0) {
            $pdf->Ln();
        }
        $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M');
    }
    $pdf->Ln(20);
    // print a pangram
    $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M');
}
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_055.pdf', 'D');
//============================================================+
// END OF FILE
//============================================================+
开发者ID:mwijsman,项目名称:AlaBonteKoe,代码行数:31,代码来源:example_055.php

示例5: testPdfOutput

 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 055');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 055', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', '', 14);
     // array of font names
     $core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats');
     // set fill color
     $pdf->SetFillColor(221, 238, 255);
     // create one HTML table for each core font
     foreach ($core_fonts as $font) {
         // add a page
         $pdf->AddPage();
         // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
         // set font for title
         $pdf->SetFont('helvetica', 'B', 16);
         // print font name
         $pdf->Cell(0, 10, 'FONT: ' . $font, 1, 1, 'C', true, '', 0, false, 'T', 'M');
         // set font for chars
         $pdf->SetFont($font, '', 16);
         // print each character
         for ($i = 0; $i < 256; ++$i) {
             if ($i > 0 and $i % 16 == 0) {
                 $pdf->Ln();
             }
             $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M');
         }
         $pdf->Ln(20);
         // print a pangram
         $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M');
     }
     // ---------------------------------------------------------
     $this->comparePdfs($pdf);
 }
开发者ID:fooman,项目名称:tcpdf,代码行数:59,代码来源:Example055Test.php


注:本文中的TCPDF_FONTS::unichr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。