pdf_test_hyphenator.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * File containing the ezcDocumentPdfHyphenator class
  4. *
  5. * Licensed to the Apache Software Foundation (ASF) under one
  6. * or more contributor license agreements. See the NOTICE file
  7. * distributed with this work for additional information
  8. * regarding copyright ownership. The ASF licenses this file
  9. * to you under the Apache License, Version 2.0 (the
  10. * "License"); you may not use this file except in compliance
  11. * with the License. You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing,
  16. * software distributed under the License is distributed on an
  17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18. * KIND, either express or implied. See the License for the
  19. * specific language governing permissions and limitations
  20. * under the License.
  21. *
  22. * @package Document
  23. * @version //autogen//
  24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  25. * @access private
  26. */
  27. /**
  28. * Default hyphenation implementation, which does no word splitting at all.
  29. *
  30. * @package Document
  31. * @access private
  32. * @version //autogen//
  33. */
  34. class ezcTestDocumentPdfHyphenator extends ezcDocumentPdfHyphenator
  35. {
  36. /**
  37. * Split word into hypens
  38. *
  39. * Takes a word as a string and should return an array containing arrays of
  40. * two words, which each represent a possible split of a word. The german
  41. * word "Zuckerstück" for example changes its hyphens depending on the
  42. * splitting point, so the return value would look like:
  43. *
  44. * <code>
  45. * array(
  46. * array( 'Zuk-', 'kerstück' ),
  47. * array( 'Zucker-', 'stück' ),
  48. * )
  49. * </code>
  50. *
  51. * You should always also include the concatenation character in the split
  52. * words, since it might change depending on the used language.
  53. *
  54. * @param mixed $word
  55. * @return void
  56. */
  57. public function splitWord( $word )
  58. {
  59. $splits = array();
  60. for ( $i = 1; $i < iconv_strlen( $word, 'UTF-8' ); ++$i )
  61. {
  62. $splits[] = array(
  63. iconv_substr( $word, 0, $i ) . '-',
  64. iconv_substr( $word, $i )
  65. );
  66. }
  67. return $splits;
  68. }
  69. }
  70. ?>