/src/3rdparty/harfbuzz/tests/linebreaking/harfbuzz-qt.cpp

https://bitbucket.org/ultra_iter/qt-vtl · C++ · 87 lines · 51 code · 13 blank · 23 comment · 0 complexity · 151b840186d898a6d967736a86a4d57c MD5 · raw file

  1. /*
  2. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  3. *
  4. * This is part of HarfBuzz, an OpenType Layout engine library.
  5. *
  6. * Permission is hereby granted, without written agreement and without
  7. * license or royalty fees, to use, copy, modify, and distribute this
  8. * software and its documentation for any purpose, provided that the
  9. * above copyright notice and the following two paragraphs appear in
  10. * all copies of this software.
  11. *
  12. * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
  13. * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  14. * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  15. * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  16. * DAMAGE.
  17. *
  18. * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  19. * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  20. * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
  21. * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  22. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  23. */
  24. #include <harfbuzz-external.h>
  25. #include <Qt/private/qunicodetables_p.h>
  26. #include <QLibrary>
  27. #include <QTextCodec>
  28. extern "C" {
  29. HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch)
  30. {
  31. #if QT_VERSION >= 0x040300
  32. return (HB_LineBreakClass)QUnicodeTables::lineBreakClass(ch);
  33. #else
  34. #error "This test currently requires Qt >= 4.3"
  35. #endif
  36. }
  37. void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass)
  38. {
  39. *category = (HB_CharCategory)QChar::category(ch);
  40. *combiningClass = QChar::combiningClass(ch);
  41. }
  42. HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch)
  43. {
  44. return (HB_CharCategory)QChar::category(ch);
  45. }
  46. int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch)
  47. {
  48. return QChar::combiningClass(ch);
  49. }
  50. HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch)
  51. {
  52. return QChar::mirroredChar(ch);
  53. }
  54. HB_WordClass HB_GetWordClass(HB_UChar32 ch)
  55. {
  56. const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ch);
  57. return (HB_WordClass) prop->wordBreak;
  58. }
  59. HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch)
  60. {
  61. const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ch);
  62. return (HB_SentenceClass) prop->sentenceBreak;
  63. }
  64. void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak)
  65. {
  66. const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ch);
  67. *grapheme = (HB_GraphemeClass) prop->graphemeBreak;
  68. *lineBreak = (HB_LineBreakClass) prop->line_break_class;
  69. }
  70. void *HB_Library_Resolve(const char *library, int version, const char *symbol)
  71. {
  72. return QLibrary::resolve(library, version, symbol);
  73. }
  74. }