PageRenderTime 2753ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 1ms

/libre/icecat/harfbuzz-1.1.3.patch

https://gitlab.com/parabola/abslibre_abslibre
Patch | 1853 lines | 1746 code | 107 blank | 0 comment | 0 complexity | 7bef6d5da4ec26cc3170f5095cc94458 MD5 | raw file
  1. diff -uN gfx/harfbuzz/src_old/check-defs.sh gfx/harfbuzz/src/check-defs.sh
  2. --- gfx/harfbuzz/src_old/check-defs.sh 1970-01-01 01:00:00.000000000 +0100
  3. +++ gfx/harfbuzz/src/check-defs.sh 2016-06-05 23:47:59.650463392 +0200
  4. @@ -0,0 +1,44 @@
  5. +#!/bin/sh
  6. +
  7. +LC_ALL=C
  8. +export LC_ALL
  9. +
  10. +test -z "$srcdir" && srcdir=.
  11. +test -z "$MAKE" && MAKE=make
  12. +stat=0
  13. +
  14. +if which nm 2>/dev/null >/dev/null; then
  15. + :
  16. +else
  17. + echo "check-defs.sh: 'nm' not found; skipping test"
  18. + exit 77
  19. +fi
  20. +
  21. +defs="harfbuzz.def"
  22. +$MAKE $defs > /dev/null
  23. +tested=false
  24. +for def in $defs; do
  25. + lib=`echo "$def" | sed 's/[.]def$//;s@.*/@@'`
  26. + so=.libs/lib${lib}.so
  27. +
  28. + EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] ' | grep -v ' _fini\>\| _init\>\| _fdata\>\| _ftext\>\| _fbss\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>\| __gcov_flush\>\| llvm_' | cut -d' ' -f3`"
  29. +
  30. + if test -f "$so"; then
  31. +
  32. + echo "Checking that $so has the same symbol list as $def"
  33. + {
  34. + echo EXPORTS
  35. + echo "$EXPORTED_SYMBOLS"
  36. + # cheat: copy the last line from the def file!
  37. + tail -n1 "$def"
  38. + } | diff "$def" - >&2 || stat=1
  39. +
  40. + tested=true
  41. + fi
  42. +done
  43. +if ! $tested; then
  44. + echo "check-defs.sh: libharfbuzz shared library not found; skipping test"
  45. + exit 77
  46. +fi
  47. +
  48. +exit $stat
  49. diff -uN gfx/harfbuzz/src_old/check-header-guards.sh gfx/harfbuzz/src/check-header-guards.sh
  50. --- gfx/harfbuzz/src_old/check-header-guards.sh 2016-05-10 22:26:55.000000000 +0200
  51. +++ gfx/harfbuzz/src/check-header-guards.sh 2016-06-05 23:48:00.885456341 +0200
  52. @@ -9,13 +9,12 @@
  53. test "x$HBHEADERS" = x && HBHEADERS=`cd "$srcdir"; find . -maxdepth 1 -name 'hb*.h'`
  54. test "x$HBSOURCES" = x && HBSOURCES=`cd "$srcdir"; find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'`
  55. -
  56. for x in $HBHEADERS $HBSOURCES; do
  57. test -f "$srcdir/$x" && x="$srcdir/$x"
  58. - echo "$x" | grep '[^h]$' -q && continue;
  59. + echo "$x" | grep -q '[^h]$' && continue;
  60. xx=`echo "$x" | sed 's@.*/@@'`
  61. tag=`echo "$xx" | tr 'a-z.-' 'A-Z_'`
  62. - lines=`grep "\<$tag\>" "$x" | wc -l | sed 's/[ ]*//g'`
  63. + lines=`grep -w "$tag" "$x" | wc -l | sed 's/[ ]*//g'`
  64. if test "x$lines" != x3; then
  65. echo "Ouch, header file $x does not have correct preprocessor guards"
  66. stat=1
  67. diff -uN gfx/harfbuzz/src_old/check-libstdc++.sh gfx/harfbuzz/src/check-libstdc++.sh
  68. --- gfx/harfbuzz/src_old/check-libstdc++.sh 2016-05-10 22:26:55.000000000 +0200
  69. +++ gfx/harfbuzz/src/check-libstdc++.sh 2016-06-05 23:48:03.413441951 +0200
  70. @@ -19,9 +19,9 @@
  71. so=.libs/libharfbuzz.$suffix
  72. if ! test -f "$so"; then continue; fi
  73. - echo "Checking that we are not linking to libstdc++"
  74. - if ldd $so | grep 'libstdc[+][+]'; then
  75. - echo "Ouch, linked to libstdc++"
  76. + echo "Checking that we are not linking to libstdc++ or libc++"
  77. + if ldd $so | grep 'libstdc[+][+]\|libc[+][+]'; then
  78. + echo "Ouch, linked to libstdc++ or libc++"
  79. stat=1
  80. fi
  81. tested=true
  82. diff -uN gfx/harfbuzz/src_old/gen-indic-table.py gfx/harfbuzz/src/gen-indic-table.py
  83. --- gfx/harfbuzz/src_old/gen-indic-table.py 2016-05-10 22:26:56.000000000 +0200
  84. +++ gfx/harfbuzz/src/gen-indic-table.py 2016-06-05 23:48:08.239414549 +0200
  85. @@ -91,6 +91,7 @@
  86. "Visarga": 'Vs',
  87. "Vowel": 'Vo',
  88. "Vowel_Dependent": 'M',
  89. + "Consonant_Prefixed": 'CPrf',
  90. "Other": 'x',
  91. },{
  92. "Not_Applicable": 'x',
  93. @@ -209,7 +210,7 @@
  94. for (start,end) in zip (starts, ends):
  95. if p not in [start>>page_bits, end>>page_bits]: continue
  96. offset = "indic_offset_0x%04xu" % start
  97. - print " if (hb_in_range (u, 0x%04Xu, 0x%04Xu)) return indic_table[u - 0x%04Xu + %s];" % (start, end, start, offset)
  98. + print " if (hb_in_range (u, 0x%04Xu, 0x%04Xu)) return indic_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
  99. for u,d in singles.items ():
  100. if p != u>>page_bits: continue
  101. print " if (unlikely (u == 0x%04Xu)) return _(%s,%s);" % (u, short[0][d[0]], short[1][d[1]])
  102. diff -uN gfx/harfbuzz/src_old/gen-use-table.py gfx/harfbuzz/src/gen-use-table.py
  103. --- gfx/harfbuzz/src_old/gen-use-table.py 1970-01-01 01:00:00.000000000 +0100
  104. +++ gfx/harfbuzz/src/gen-use-table.py 2016-06-05 23:48:09.467407592 +0200
  105. @@ -0,0 +1,476 @@
  106. +#!/usr/bin/python
  107. +
  108. +import sys
  109. +
  110. +if len (sys.argv) != 5:
  111. + print >>sys.stderr, "usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt"
  112. + sys.exit (1)
  113. +
  114. +BLACKLISTED_BLOCKS = ["Thai", "Lao", "Tibetan"]
  115. +
  116. +files = [file (x) for x in sys.argv[1:]]
  117. +
  118. +headers = [[f.readline () for i in range (2)] for j,f in enumerate(files) if j != 2]
  119. +headers.append (["UnicodeData.txt does not have a header."])
  120. +
  121. +data = [{} for f in files]
  122. +values = [{} for f in files]
  123. +for i, f in enumerate (files):
  124. + for line in f:
  125. +
  126. + j = line.find ('#')
  127. + if j >= 0:
  128. + line = line[:j]
  129. +
  130. + fields = [x.strip () for x in line.split (';')]
  131. + if len (fields) == 1:
  132. + continue
  133. +
  134. + uu = fields[0].split ('..')
  135. + start = int (uu[0], 16)
  136. + if len (uu) == 1:
  137. + end = start
  138. + else:
  139. + end = int (uu[1], 16)
  140. +
  141. + t = fields[1 if i != 2 else 2]
  142. +
  143. + for u in range (start, end + 1):
  144. + data[i][u] = t
  145. + values[i][t] = values[i].get (t, 0) + end - start + 1
  146. +
  147. +defaults = ('Other', 'Not_Applicable', 'Cn', 'No_Block')
  148. +
  149. +# TODO Characters that are not in Unicode Indic files, but used in USE
  150. +data[0][0x034F] = defaults[0]
  151. +data[0][0x2060] = defaults[0]
  152. +for u in range (0xFE00, 0xFE0F + 1):
  153. + data[0][u] = defaults[0]
  154. +
  155. +# Merge data into one dict:
  156. +for i,v in enumerate (defaults):
  157. + values[i][v] = values[i].get (v, 0) + 1
  158. +combined = {}
  159. +for i,d in enumerate (data):
  160. + for u,v in d.items ():
  161. + if i >= 2 and not u in combined:
  162. + continue
  163. + if not u in combined:
  164. + combined[u] = list (defaults)
  165. + combined[u][i] = v
  166. +combined = {k:v for k,v in combined.items() if v[3] not in BLACKLISTED_BLOCKS}
  167. +data = combined
  168. +del combined
  169. +num = len (data)
  170. +
  171. +
  172. +property_names = [
  173. + # General_Category
  174. + 'Cc', 'Cf', 'Cn', 'Co', 'Cs', 'Ll', 'Lm', 'Lo', 'Lt', 'Lu', 'Mc',
  175. + 'Me', 'Mn', 'Nd', 'Nl', 'No', 'Pc', 'Pd', 'Pe', 'Pf', 'Pi', 'Po',
  176. + 'Ps', 'Sc', 'Sk', 'Sm', 'So', 'Zl', 'Zp', 'Zs',
  177. + # Indic_Syllabic_Category
  178. + 'Other',
  179. + 'Bindu',
  180. + 'Visarga',
  181. + 'Avagraha',
  182. + 'Nukta',
  183. + 'Virama',
  184. + 'Pure_Killer',
  185. + 'Invisible_Stacker',
  186. + 'Vowel_Independent',
  187. + 'Vowel_Dependent',
  188. + 'Vowel',
  189. + 'Consonant_Placeholder',
  190. + 'Consonant',
  191. + 'Consonant_Dead',
  192. + 'Consonant_With_Stacker',
  193. + 'Consonant_Prefixed',
  194. + 'Consonant_Preceding_Repha',
  195. + 'Consonant_Succeeding_Repha',
  196. + 'Consonant_Subjoined',
  197. + 'Consonant_Medial',
  198. + 'Consonant_Final',
  199. + 'Consonant_Head_Letter',
  200. + 'Modifying_Letter',
  201. + 'Tone_Letter',
  202. + 'Tone_Mark',
  203. + 'Gemination_Mark',
  204. + 'Cantillation_Mark',
  205. + 'Register_Shifter',
  206. + 'Syllable_Modifier',
  207. + 'Consonant_Killer',
  208. + 'Non_Joiner',
  209. + 'Joiner',
  210. + 'Number_Joiner',
  211. + 'Number',
  212. + 'Brahmi_Joining_Number',
  213. + # Indic_Positional_Category
  214. + 'Not_Applicable',
  215. + 'Right',
  216. + 'Left',
  217. + 'Visual_Order_Left',
  218. + 'Left_And_Right',
  219. + 'Top',
  220. + 'Bottom',
  221. + 'Top_And_Bottom',
  222. + 'Top_And_Right',
  223. + 'Top_And_Left',
  224. + 'Top_And_Left_And_Right',
  225. + 'Bottom_And_Right',
  226. + 'Top_And_Bottom_And_Right',
  227. + 'Overstruck',
  228. +]
  229. +
  230. +class PropertyValue(object):
  231. + def __init__(self, name_):
  232. + self.name = name_
  233. + def __str__(self):
  234. + return self.name
  235. + def __eq__(self, other):
  236. + return self.name == (other if isinstance(other, basestring) else other.name)
  237. + def __ne__(self, other):
  238. + return not (self == other)
  239. +
  240. +property_values = {}
  241. +
  242. +for name in property_names:
  243. + value = PropertyValue(name)
  244. + assert value not in property_values
  245. + assert value not in globals()
  246. + property_values[name] = value
  247. +globals().update(property_values)
  248. +
  249. +
  250. +def is_BASE(U, UISC, UGC):
  251. + return (UISC in [Number, Consonant, Consonant_Head_Letter,
  252. + #SPEC-OUTDATED Consonant_Placeholder,
  253. + Tone_Letter] or
  254. + (UGC == Lo and UISC in [Avagraha, Bindu, Consonant_Final, Consonant_Medial,
  255. + Consonant_Subjoined, Vowel, Vowel_Dependent]))
  256. +def is_BASE_VOWEL(U, UISC, UGC):
  257. + return UISC == Vowel_Independent
  258. +def is_BASE_IND(U, UISC, UGC):
  259. + #SPEC-BROKEN return (UISC in [Consonant_Dead, Modifying_Letter] or UGC == Po)
  260. + return (UISC in [Consonant_Dead, Modifying_Letter] or
  261. + (UGC == Po and not is_BASE_OTHER(U, UISC, UGC))) # for 104E
  262. +def is_BASE_NUM(U, UISC, UGC):
  263. + return UISC == Brahmi_Joining_Number
  264. +def is_BASE_OTHER(U, UISC, UGC):
  265. + if UISC == Consonant_Placeholder: return True #SPEC-OUTDATED
  266. + return U in [0x00A0, 0x00D7, 0x2015, 0x2022, 0x25CC,
  267. + 0x25FB, 0x25FC, 0x25FD, 0x25FE]
  268. +def is_CGJ(U, UISC, UGC):
  269. + return U == 0x034F
  270. +def is_CONS_FINAL(U, UISC, UGC):
  271. + return ((UISC == Consonant_Final and UGC != Lo) or
  272. + UISC == Consonant_Succeeding_Repha)
  273. +def is_CONS_FINAL_MOD(U, UISC, UGC):
  274. + #SPEC-OUTDATED return UISC in [Consonant_Final_Modifier, Syllable_Modifier]
  275. + return UISC == Syllable_Modifier
  276. +def is_CONS_MED(U, UISC, UGC):
  277. + return UISC == Consonant_Medial and UGC != Lo
  278. +def is_CONS_MOD(U, UISC, UGC):
  279. + return UISC in [Nukta, Gemination_Mark, Consonant_Killer]
  280. +def is_CONS_SUB(U, UISC, UGC):
  281. + #SPEC-OUTDATED return UISC == Consonant_Subjoined
  282. + return UISC == Consonant_Subjoined and UGC != Lo
  283. +def is_HALANT(U, UISC, UGC):
  284. + return UISC in [Virama, Invisible_Stacker]
  285. +def is_HALANT_NUM(U, UISC, UGC):
  286. + return UISC == Number_Joiner
  287. +def is_ZWNJ(U, UISC, UGC):
  288. + return UISC == Non_Joiner
  289. +def is_ZWJ(U, UISC, UGC):
  290. + return UISC == Joiner
  291. +def is_Word_Joiner(U, UISC, UGC):
  292. + return U == 0x2060
  293. +def is_OTHER(U, UISC, UGC):
  294. + #SPEC-OUTDATED return UGC == Zs # or any other SCRIPT_COMMON characters
  295. + return (UISC == Other
  296. + and not is_SYM_MOD(U, UISC, UGC)
  297. + and not is_CGJ(U, UISC, UGC)
  298. + and not is_Word_Joiner(U, UISC, UGC)
  299. + and not is_VARIATION_SELECTOR(U, UISC, UGC)
  300. + )
  301. +def is_Reserved(U, UISC, UGC):
  302. + return UGC == 'Cn'
  303. +def is_REPHA(U, UISC, UGC):
  304. + #return UISC == Consonant_Preceding_Repha
  305. + #SPEC-OUTDATED hack to categorize Consonant_With_Stacker and Consonant_Prefixed
  306. + return UISC in [Consonant_Preceding_Repha, Consonant_With_Stacker, Consonant_Prefixed]
  307. +def is_SYM(U, UISC, UGC):
  308. + if U == 0x25CC: return False #SPEC-OUTDATED
  309. + #SPEC-OUTDATED return UGC in [So, Sc] or UISC == Symbol_Letter
  310. + return UGC in [So, Sc]
  311. +def is_SYM_MOD(U, UISC, UGC):
  312. + return U in [0x1B6B, 0x1B6C, 0x1B6D, 0x1B6E, 0x1B6F, 0x1B70, 0x1B71, 0x1B72, 0x1B73]
  313. +def is_VARIATION_SELECTOR(U, UISC, UGC):
  314. + return 0xFE00 <= U <= 0xFE0F
  315. +def is_VOWEL(U, UISC, UGC):
  316. + return (UISC == Pure_Killer or
  317. + (UGC != Lo and UISC in [Vowel, Vowel_Dependent]))
  318. +def is_VOWEL_MOD(U, UISC, UGC):
  319. + return (UISC in [Tone_Mark, Cantillation_Mark, Register_Shifter, Visarga] or
  320. + (UGC != Lo and UISC == Bindu))
  321. +
  322. +use_mapping = {
  323. + 'B': is_BASE,
  324. + 'IV': is_BASE_VOWEL,
  325. + 'IND': is_BASE_IND,
  326. + 'N': is_BASE_NUM,
  327. + 'GB': is_BASE_OTHER,
  328. + 'CGJ': is_CGJ,
  329. + 'F': is_CONS_FINAL,
  330. + 'FM': is_CONS_FINAL_MOD,
  331. + 'M': is_CONS_MED,
  332. + 'CM': is_CONS_MOD,
  333. + 'SUB': is_CONS_SUB,
  334. + 'H': is_HALANT,
  335. + 'HN': is_HALANT_NUM,
  336. + 'ZWNJ': is_ZWNJ,
  337. + 'ZWJ': is_ZWJ,
  338. + 'WJ': is_Word_Joiner,
  339. + 'O': is_OTHER,
  340. + 'Rsv': is_Reserved,
  341. + 'R': is_REPHA,
  342. + 'S': is_SYM,
  343. + 'SM': is_SYM_MOD,
  344. + 'VS': is_VARIATION_SELECTOR,
  345. + 'V': is_VOWEL,
  346. + 'VM': is_VOWEL_MOD,
  347. +}
  348. +
  349. +use_positions = {
  350. + 'F': {
  351. + 'Abv': [Top],
  352. + 'Blw': [Bottom],
  353. + 'Pst': [Right],
  354. + },
  355. + 'M': {
  356. + 'Abv': [Top],
  357. + 'Blw': [Bottom],
  358. + 'Pst': [Right],
  359. + 'Pre': [Left],
  360. + },
  361. + 'CM': {
  362. + 'Abv': [Top],
  363. + 'Blw': [Bottom],
  364. + },
  365. + 'V': {
  366. + 'Abv': [Top, Top_And_Bottom, Top_And_Bottom_And_Right, Top_And_Right],
  367. + 'Blw': [Bottom, Overstruck, Bottom_And_Right],
  368. + 'Pst': [Right],
  369. + 'Pre': [Left, Top_And_Left, Top_And_Left_And_Right, Left_And_Right],
  370. + },
  371. + 'VM': {
  372. + 'Abv': [Top],
  373. + 'Blw': [Bottom, Overstruck],
  374. + 'Pst': [Right],
  375. + 'Pre': [Left],
  376. + },
  377. + 'SM': {
  378. + 'Abv': [Top],
  379. + 'Blw': [Bottom],
  380. + },
  381. + 'H': None,
  382. + 'B': None,
  383. + 'FM': None,
  384. + 'SUB': None,
  385. +}
  386. +
  387. +def map_to_use(data):
  388. + out = {}
  389. + items = use_mapping.items()
  390. + for U,(UISC,UIPC,UGC,UBlock) in data.items():
  391. +
  392. + # Resolve Indic_Syllabic_Category
  393. +
  394. + # TODO: These don't have UISC assigned in Unicode 8.0, but
  395. + # have UIPC
  396. + if U == 0x17DD: UISC = Vowel_Dependent
  397. + if 0x1CE2 <= U <= 0x1CE8: UISC = Cantillation_Mark
  398. +
  399. + # TODO: U+1CED should only be allowed after some of
  400. + # the nasalization marks, maybe only for U+1CE9..U+1CF1.
  401. + if U == 0x1CED: UISC = Tone_Mark
  402. +
  403. + evals = [(k, v(U,UISC,UGC)) for k,v in items]
  404. + values = [k for k,v in evals if v]
  405. + assert len(values) == 1, "%s %s %s %s" % (hex(U), UISC, UGC, values)
  406. + USE = values[0]
  407. +
  408. + # Resolve Indic_Positional_Category
  409. +
  410. + # TODO: Not in Unicode 8.0 yet, but in spec.
  411. + if U == 0x1B6C: UIPC = Bottom
  412. +
  413. + # TODO: These should die, but have UIPC in Unicode 8.0
  414. + if U in [0x953, 0x954]: UIPC = Not_Applicable
  415. +
  416. + # TODO: In USE's override list but not in Unicode 8.0
  417. + if U == 0x103C: UIPC = Left
  418. +
  419. + # TODO: These are not in USE's override list that we have, nor are they in Unicode 8.0
  420. + if 0xA926 <= U <= 0xA92A: UIPC = Top
  421. + if U == 0x111CA: UIPC = Bottom
  422. + if U == 0x11300: UIPC = Top
  423. + if U == 0x1133C: UIPC = Bottom
  424. + if U == 0x1171E: UIPC = Left # Correct?!
  425. + if 0x1CF2 <= U <= 0x1CF3: UIPC = Right
  426. + if 0x1CF8 <= U <= 0x1CF9: UIPC = Top
  427. +
  428. + assert (UIPC in [Not_Applicable, Visual_Order_Left] or
  429. + USE in use_positions), "%s %s %s %s %s" % (hex(U), UIPC, USE, UISC, UGC)
  430. +
  431. + pos_mapping = use_positions.get(USE, None)
  432. + if pos_mapping:
  433. + values = [k for k,v in pos_mapping.items() if v and UIPC in v]
  434. + assert len(values) == 1, "%s %s %s %s %s %s" % (hex(U), UIPC, USE, UISC, UGC, values)
  435. + USE = USE + values[0]
  436. +
  437. + out[U] = (USE, UBlock)
  438. + return out
  439. +
  440. +defaults = ('O', 'No_Block')
  441. +data = map_to_use(data)
  442. +
  443. +# Remove the outliers
  444. +singles = {}
  445. +for u in [0x034F, 0x25CC, 0x1107F]:
  446. + singles[u] = data[u]
  447. + del data[u]
  448. +
  449. +print "/* == Start of generated table == */"
  450. +print "/*"
  451. +print " * The following table is generated by running:"
  452. +print " *"
  453. +print " * ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt"
  454. +print " *"
  455. +print " * on files with these headers:"
  456. +print " *"
  457. +for h in headers:
  458. + for l in h:
  459. + print " * %s" % (l.strip())
  460. +print " */"
  461. +print
  462. +print '#include "hb-ot-shape-complex-use-private.hh"'
  463. +print
  464. +
  465. +total = 0
  466. +used = 0
  467. +last_block = None
  468. +def print_block (block, start, end, data):
  469. + global total, used, last_block
  470. + if block and block != last_block:
  471. + print
  472. + print
  473. + print " /* %s */" % block
  474. + if start % 16:
  475. + print ' ' * (20 + (start % 16 * 6)),
  476. + num = 0
  477. + assert start % 8 == 0
  478. + assert (end+1) % 8 == 0
  479. + for u in range (start, end+1):
  480. + if u % 16 == 0:
  481. + print
  482. + print " /* %04X */" % u,
  483. + if u in data:
  484. + num += 1
  485. + d = data.get (u, defaults)
  486. + sys.stdout.write ("%6s," % d[0])
  487. +
  488. + total += end - start + 1
  489. + used += num
  490. + if block:
  491. + last_block = block
  492. +
  493. +uu = data.keys ()
  494. +uu.sort ()
  495. +
  496. +last = -100000
  497. +num = 0
  498. +offset = 0
  499. +starts = []
  500. +ends = []
  501. +for k,v in sorted(use_mapping.items()):
  502. + if k in use_positions and use_positions[k]: continue
  503. + print "#define %s USE_%s /* %s */" % (k, k, v.__name__[3:])
  504. +for k,v in sorted(use_positions.items()):
  505. + if not v: continue
  506. + for suf in v.keys():
  507. + tag = k + suf
  508. + print "#define %s USE_%s" % (tag, tag)
  509. +print ""
  510. +print "static const USE_TABLE_ELEMENT_TYPE use_table[] = {"
  511. +for u in uu:
  512. + if u <= last:
  513. + continue
  514. + block = data[u][1]
  515. +
  516. + start = u//8*8
  517. + end = start+1
  518. + while end in uu and block == data[end][1]:
  519. + end += 1
  520. + end = (end-1)//8*8 + 7
  521. +
  522. + if start != last + 1:
  523. + if start - last <= 1+16*3:
  524. + print_block (None, last+1, start-1, data)
  525. + last = start-1
  526. + else:
  527. + if last >= 0:
  528. + ends.append (last + 1)
  529. + offset += ends[-1] - starts[-1]
  530. + print
  531. + print
  532. + print "#define use_offset_0x%04xu %d" % (start, offset)
  533. + starts.append (start)
  534. +
  535. + print_block (block, start, end, data)
  536. + last = end
  537. +ends.append (last + 1)
  538. +offset += ends[-1] - starts[-1]
  539. +print
  540. +print
  541. +occupancy = used * 100. / total
  542. +page_bits = 12
  543. +print "}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)
  544. +print
  545. +print "USE_TABLE_ELEMENT_TYPE"
  546. +print "hb_use_get_categories (hb_codepoint_t u)"
  547. +print "{"
  548. +print " switch (u >> %d)" % page_bits
  549. +print " {"
  550. +pages = set([u>>page_bits for u in starts+ends+singles.keys()])
  551. +for p in sorted(pages):
  552. + print " case 0x%0Xu:" % p
  553. + for (start,end) in zip (starts, ends):
  554. + if p not in [start>>page_bits, end>>page_bits]: continue
  555. + offset = "use_offset_0x%04xu" % start
  556. + print " if (hb_in_range (u, 0x%04Xu, 0x%04Xu)) return use_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
  557. + for u,d in singles.items ():
  558. + if p != u>>page_bits: continue
  559. + print " if (unlikely (u == 0x%04Xu)) return %s;" % (u, d[0])
  560. + print " break;"
  561. + print ""
  562. +print " default:"
  563. +print " break;"
  564. +print " }"
  565. +print " return USE_O;"
  566. +print "}"
  567. +print
  568. +for k in sorted(use_mapping.keys()):
  569. + if k in use_positions and use_positions[k]: continue
  570. + print "#undef %s" % k
  571. +for k,v in sorted(use_positions.items()):
  572. + if not v: continue
  573. + for suf in v.keys():
  574. + tag = k + suf
  575. + print "#undef %s" % tag
  576. +print
  577. +print "/* == End of generated table == */"
  578. +
  579. +# Maintain at least 50% occupancy in the table */
  580. +if occupancy < 50:
  581. + raise Exception ("Table too sparse, please investigate: ", occupancy)
  582. diff -uN gfx/harfbuzz/src_old/harfbuzz-icu.pc gfx/harfbuzz/src/harfbuzz-icu.pc
  583. --- gfx/harfbuzz/src_old/harfbuzz-icu.pc 1970-01-01 01:00:00.000000000 +0100
  584. +++ gfx/harfbuzz/src/harfbuzz-icu.pc 2016-06-05 23:48:12.049392976 +0200
  585. @@ -0,0 +1,13 @@
  586. +prefix=/usr/local
  587. +exec_prefix=/usr/local
  588. +libdir=/usr/local/lib
  589. +includedir=/usr/local/include
  590. +
  591. +Name: harfbuzz
  592. +Description: HarfBuzz text shaping library ICU integration
  593. +Version: 1.0.1
  594. +
  595. +Requires: harfbuzz
  596. +Requires.private: icu-uc
  597. +Libs: -L${libdir} -lharfbuzz-icu
  598. +Cflags: -I${includedir}/harfbuzz
  599. diff -uN gfx/harfbuzz/src_old/harfbuzz.pc gfx/harfbuzz/src/harfbuzz.pc
  600. --- gfx/harfbuzz/src_old/harfbuzz.pc 1970-01-01 01:00:00.000000000 +0100
  601. +++ gfx/harfbuzz/src/harfbuzz.pc 2016-06-05 23:48:14.499379160 +0200
  602. @@ -0,0 +1,11 @@
  603. +prefix=/usr/local
  604. +exec_prefix=/usr/local
  605. +libdir=/usr/local/lib
  606. +includedir=/usr/local/include
  607. +
  608. +Name: harfbuzz
  609. +Description: HarfBuzz text shaping library
  610. +Version: 1.0.1
  611. +
  612. +Libs: -L${libdir} -lharfbuzz
  613. +Cflags: -I${includedir}/harfbuzz
  614. diff -uN gfx/harfbuzz/src_old/harfbuzz.pc.in gfx/harfbuzz/src/harfbuzz.pc.in
  615. --- gfx/harfbuzz/src_old/harfbuzz.pc.in 2016-05-10 22:26:55.000000000 +0200
  616. +++ gfx/harfbuzz/src/harfbuzz.pc.in 2016-06-05 23:48:15.731372204 +0200
  617. @@ -8,4 +8,6 @@
  618. Version: %VERSION%
  619. Libs: -L${libdir} -lharfbuzz
  620. +Libs.private: %libs_private%
  621. +Requires.private: %requires_private%
  622. Cflags: -I${includedir}/harfbuzz
  623. diff -uN gfx/harfbuzz/src_old/hb-atomic-private.hh gfx/harfbuzz/src/hb-atomic-private.hh
  624. --- gfx/harfbuzz/src_old/hb-atomic-private.hh 2016-05-10 22:26:56.000000000 +0200
  625. +++ gfx/harfbuzz/src/hb-atomic-private.hh 2016-06-05 23:48:16.918365513 +0200
  626. @@ -39,7 +39,11 @@
  627. /* We need external help for these */
  628. -#if 0
  629. +#if defined(hb_atomic_int_impl_add) \
  630. + && defined(hb_atomic_ptr_impl_get) \
  631. + && defined(hb_atomic_ptr_impl_cmpexch)
  632. +
  633. +/* Defined externally, i.e. in config.h; must have typedef'ed hb_atomic_int_impl_t as well. */
  634. #elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__))
  635. @@ -58,11 +62,12 @@
  636. #endif
  637. }
  638. -typedef LONG hb_atomic_int_t;
  639. -#define hb_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V))
  640. +typedef LONG hb_atomic_int_impl_t;
  641. +#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  642. +#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd (&(AI), (V))
  643. -#define hb_atomic_ptr_get(P) (_HBMemoryBarrier (), (void *) *(P))
  644. -#define hb_atomic_ptr_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))
  645. +#define hb_atomic_ptr_impl_get(P) (_HBMemoryBarrier (), (void *) *(P))
  646. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))
  647. #elif !defined(HB_NO_MT) && defined(__APPLE__)
  648. @@ -74,28 +79,31 @@
  649. #include <Availability.h>
  650. #endif
  651. -typedef int32_t hb_atomic_int_t;
  652. -#define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
  653. -#define hb_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P))
  654. +typedef int32_t hb_atomic_int_impl_t;
  655. +#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  656. +#define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
  657. +
  658. +#define hb_atomic_ptr_impl_get(P) (OSMemoryBarrier (), (void *) *(P))
  659. #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100)
  660. -#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
  661. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
  662. #else
  663. #if __ppc64__ || __x86_64__ || __aarch64__
  664. -#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P))
  665. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P))
  666. #else
  667. -#define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P))
  668. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P))
  669. #endif
  670. #endif
  671. #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
  672. -typedef int hb_atomic_int_t;
  673. -#define hb_atomic_int_add(AI, V) __sync_fetch_and_add (&(AI), (V))
  674. +typedef int hb_atomic_int_impl_t;
  675. +#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  676. +#define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add (&(AI), (V))
  677. -#define hb_atomic_ptr_get(P) (void *) (__sync_synchronize (), *(P))
  678. -#define hb_atomic_ptr_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N))
  679. +#define hb_atomic_ptr_impl_get(P) (void *) (__sync_synchronize (), *(P))
  680. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N))
  681. #elif !defined(HB_NO_MT) && defined(HAVE_SOLARIS_ATOMIC_OPS)
  682. @@ -103,33 +111,79 @@
  683. #include <atomic.h>
  684. #include <mbarrier.h>
  685. -typedef unsigned int hb_atomic_int_t;
  686. -#define hb_atomic_int_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V))
  687. +typedef unsigned int hb_atomic_int_impl_t;
  688. +#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  689. +#define hb_atomic_int_impl_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V))
  690. +
  691. +#define hb_atomic_ptr_impl_get(P) ( ({__machine_rw_barrier ();}), (void *) *(P))
  692. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false)
  693. +
  694. +
  695. +#elif !defined(HB_NO_MT) && defined(_AIX) && defined(__IBMCPP__)
  696. +
  697. +#include <builtins.h>
  698. +
  699. +
  700. +static inline int hb_fetch_and_add(volatile int* AI, unsigned int V) {
  701. + __lwsync();
  702. + int result = __fetch_and_add(AI, V);
  703. + __isync();
  704. + return result;
  705. +}
  706. +static inline int hb_compare_and_swaplp(volatile long* P, long O, long N) {
  707. + __sync();
  708. + int result = __compare_and_swaplp (P, &O, N);
  709. + __sync();
  710. + return result;
  711. +}
  712. -#define hb_atomic_ptr_get(P) ( ({__machine_rw_barrier ();}), (void *) *(P))
  713. -#define hb_atomic_ptr_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false)
  714. +typedef int hb_atomic_int_impl_t;
  715. +#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  716. +#define hb_atomic_int_impl_add(AI, V) hb_fetch_and_add (&(AI), (V))
  717. +#define hb_atomic_ptr_impl_get(P) (__sync(), (void *) *(P))
  718. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N))
  719. #elif !defined(HB_NO_MT)
  720. #define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */
  721. -typedef volatile int hb_atomic_int_t;
  722. -#define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V))
  723. -#define hb_atomic_ptr_get(P) ((void *) *(P))
  724. -#define hb_atomic_ptr_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false)
  725. +typedef volatile int hb_atomic_int_impl_t;
  726. +#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  727. +#define hb_atomic_int_impl_add(AI, V) (((AI) += (V)) - (V))
  728. +
  729. +#define hb_atomic_ptr_impl_get(P) ((void *) *(P))
  730. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false)
  731. #else /* HB_NO_MT */
  732. -typedef int hb_atomic_int_t;
  733. -#define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V))
  734. +typedef int hb_atomic_int_impl_t;
  735. +#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  736. +#define hb_atomic_int_impl_add(AI, V) (((AI) += (V)) - (V))
  737. +
  738. +#define hb_atomic_ptr_impl_get(P) ((void *) *(P))
  739. +#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false)
  740. -#define hb_atomic_ptr_get(P) ((void *) *(P))
  741. -#define hb_atomic_ptr_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false)
  742. #endif
  743. -/* TODO Add tracing. */
  744. +
  745. +#define HB_ATOMIC_INT_INIT(V) {HB_ATOMIC_INT_IMPL_INIT(V)}
  746. +
  747. +struct hb_atomic_int_t
  748. +{
  749. + hb_atomic_int_impl_t v;
  750. +
  751. + inline void set_unsafe (int v_) { v = v_; }
  752. + inline int get_unsafe (void) const { return v; }
  753. + inline int inc (void) { return hb_atomic_int_impl_add (const_cast<hb_atomic_int_impl_t &> (v), 1); }
  754. + inline int dec (void) { return hb_atomic_int_impl_add (const_cast<hb_atomic_int_impl_t &> (v), -1); }
  755. +};
  756. +
  757. +
  758. +#define hb_atomic_ptr_get(P) hb_atomic_ptr_impl_get(P)
  759. +#define hb_atomic_ptr_cmpexch(P,O,N) hb_atomic_ptr_impl_cmpexch((P),(O),(N))
  760. +
  761. #endif /* HB_ATOMIC_PRIVATE_HH */
  762. diff -uN gfx/harfbuzz/src_old/hb-blob.cc gfx/harfbuzz/src/hb-blob.cc
  763. --- gfx/harfbuzz/src_old/hb-blob.cc 2016-05-10 22:26:55.000000000 +0200
  764. +++ gfx/harfbuzz/src/hb-blob.cc 2016-06-05 23:48:18.064359059 +0200
  765. @@ -78,8 +78,8 @@
  766. }
  767. /**
  768. - * hb_blob_create: (Xconstructor)
  769. - * @data: (array length=length) (closure user_data) (destroy destroy) (scope notified) (transfer none): Pointer to blob data.
  770. + * hb_blob_create: (skip)
  771. + * @data: Pointer to blob data.
  772. * @length: Length of @data in bytes.
  773. * @mode: Memory mode for @data.
  774. * @user_data: Data parameter to pass to @destroy.
  775. @@ -91,7 +91,7 @@
  776. * Return value: New blob, or the empty blob if something failed or if @length is
  777. * zero. Destroy with hb_blob_destroy().
  778. *
  779. - * Since: 1.0
  780. + * Since: 0.9.2
  781. **/
  782. hb_blob_t *
  783. hb_blob_create (const char *data,
  784. @@ -147,7 +147,7 @@
  785. * @length is zero or @offset is beyond the end of @parent's data. Destroy
  786. * with hb_blob_destroy().
  787. *
  788. - * Since: 1.0
  789. + * Since: 0.9.2
  790. **/
  791. hb_blob_t *
  792. hb_blob_create_sub_blob (hb_blob_t *parent,
  793. @@ -179,7 +179,7 @@
  794. *
  795. * Return value: (transfer full): the empty blob.
  796. *
  797. - * Since: 1.0
  798. + * Since: 0.9.2
  799. **/
  800. hb_blob_t *
  801. hb_blob_get_empty (void)
  802. @@ -210,7 +210,7 @@
  803. *
  804. * Return value: @blob.
  805. *
  806. - * Since: 1.0
  807. + * Since: 0.9.2
  808. **/
  809. hb_blob_t *
  810. hb_blob_reference (hb_blob_t *blob)
  811. @@ -228,7 +228,7 @@
  812. *
  813. * See TODO:link object types for more information.
  814. *
  815. - * Since: 1.0
  816. + * Since: 0.9.2
  817. **/
  818. void
  819. hb_blob_destroy (hb_blob_t *blob)
  820. @@ -250,7 +250,7 @@
  821. *
  822. * Return value:
  823. *
  824. - * Since: 1.0
  825. + * Since: 0.9.2
  826. **/
  827. hb_bool_t
  828. hb_blob_set_user_data (hb_blob_t *blob,
  829. @@ -271,7 +271,7 @@
  830. *
  831. * Return value: (transfer none):
  832. *
  833. - * Since: 1.0
  834. + * Since: 0.9.2
  835. **/
  836. void *
  837. hb_blob_get_user_data (hb_blob_t *blob,
  838. @@ -287,7 +287,7 @@
  839. *
  840. *
  841. *
  842. - * Since: 1.0
  843. + * Since: 0.9.2
  844. **/
  845. void
  846. hb_blob_make_immutable (hb_blob_t *blob)
  847. @@ -306,7 +306,7 @@
  848. *
  849. * Return value: TODO
  850. *
  851. - * Since: 1.0
  852. + * Since: 0.9.2
  853. **/
  854. hb_bool_t
  855. hb_blob_is_immutable (hb_blob_t *blob)
  856. @@ -323,7 +323,7 @@
  857. *
  858. * Return value: the length of blob data in bytes.
  859. *
  860. - * Since: 1.0
  861. + * Since: 0.9.2
  862. **/
  863. unsigned int
  864. hb_blob_get_length (hb_blob_t *blob)
  865. @@ -340,7 +340,7 @@
  866. *
  867. * Returns: (transfer none) (array length=length):
  868. *
  869. - * Since: 1.0
  870. + * Since: 0.9.2
  871. **/
  872. const char *
  873. hb_blob_get_data (hb_blob_t *blob, unsigned int *length)
  874. @@ -365,7 +365,7 @@
  875. * Returns: (transfer none) (array length=length): Writable blob data,
  876. * or %NULL if failed.
  877. *
  878. - * Since: 1.0
  879. + * Since: 0.9.2
  880. **/
  881. char *
  882. hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length)
  883. diff -uN gfx/harfbuzz/src_old/hb-blob.h gfx/harfbuzz/src/hb-blob.h
  884. --- gfx/harfbuzz/src_old/hb-blob.h 2016-05-10 22:26:56.000000000 +0200
  885. +++ gfx/harfbuzz/src/hb-blob.h 2016-06-05 23:48:19.231352500 +0200
  886. @@ -64,7 +64,7 @@
  887. typedef struct hb_blob_t hb_blob_t;
  888. -hb_blob_t *
  889. +HB_EXTERN hb_blob_t *
  890. hb_blob_create (const char *data,
  891. unsigned int length,
  892. hb_memory_mode_t mode,
  893. @@ -77,21 +77,21 @@
  894. * modify the parent data as that data may be
  895. * shared among multiple sub-blobs.
  896. */
  897. -hb_blob_t *
  898. +HB_EXTERN hb_blob_t *
  899. hb_blob_create_sub_blob (hb_blob_t *parent,
  900. unsigned int offset,
  901. unsigned int length);
  902. -hb_blob_t *
  903. +HB_EXTERN hb_blob_t *
  904. hb_blob_get_empty (void);
  905. -hb_blob_t *
  906. +HB_EXTERN hb_blob_t *
  907. hb_blob_reference (hb_blob_t *blob);
  908. -void
  909. +HB_EXTERN void
  910. hb_blob_destroy (hb_blob_t *blob);
  911. -hb_bool_t
  912. +HB_EXTERN hb_bool_t
  913. hb_blob_set_user_data (hb_blob_t *blob,
  914. hb_user_data_key_t *key,
  915. void * data,
  916. @@ -99,25 +99,25 @@
  917. hb_bool_t replace);
  918. -void *
  919. +HB_EXTERN void *
  920. hb_blob_get_user_data (hb_blob_t *blob,
  921. hb_user_data_key_t *key);
  922. -void
  923. +HB_EXTERN void
  924. hb_blob_make_immutable (hb_blob_t *blob);
  925. -hb_bool_t
  926. +HB_EXTERN hb_bool_t
  927. hb_blob_is_immutable (hb_blob_t *blob);
  928. -unsigned int
  929. +HB_EXTERN unsigned int
  930. hb_blob_get_length (hb_blob_t *blob);
  931. -const char *
  932. +HB_EXTERN const char *
  933. hb_blob_get_data (hb_blob_t *blob, unsigned int *length);
  934. -char *
  935. +HB_EXTERN char *
  936. hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length);
  937. diff -uN gfx/harfbuzz/src_old/hb-buffer.cc gfx/harfbuzz/src/hb-buffer.cc
  938. --- gfx/harfbuzz/src_old/hb-buffer.cc 2016-05-10 22:26:55.000000000 +0200
  939. +++ gfx/harfbuzz/src/hb-buffer.cc 2016-06-05 23:48:28.261301901 +0200
  940. @@ -35,7 +35,28 @@
  941. #define HB_DEBUG_BUFFER (HB_DEBUG+0)
  942. #endif
  943. +/**
  944. + * SECTION: hb-buffer
  945. + * @title: Buffers
  946. + * @short_description: Input and output buffers
  947. + * @include: hb.h
  948. + *
  949. + * Buffers serve dual role in HarfBuzz; they hold the input characters that are
  950. + * passed hb_shape(), and after shaping they hold the output glyphs.
  951. + **/
  952. +/**
  953. + * hb_segment_properties_equal:
  954. + * @a: first #hb_segment_properties_t to compare.
  955. + * @b: second #hb_segment_properties_t to compare.
  956. + *
  957. + * Checks the equality of two #hb_segment_properties_t's.
  958. + *
  959. + * Return value: (transfer full):
  960. + * %true if all properties of @a equal those of @b, false otherwise.
  961. + *
  962. + * Since: 0.9.7
  963. + **/
  964. hb_bool_t
  965. hb_segment_properties_equal (const hb_segment_properties_t *a,
  966. const hb_segment_properties_t *b)
  967. @@ -48,6 +69,17 @@
  968. }
  969. +/**
  970. + * hb_segment_properties_hash:
  971. + * @p: #hb_segment_properties_t to hash.
  972. + *
  973. + * Creates a hash representing @p.
  974. + *
  975. + * Return value:
  976. + * A hash of @p.
  977. + *
  978. + * Since: 0.9.7
  979. + **/
  980. unsigned int
  981. hb_segment_properties_hash (const hb_segment_properties_t *p)
  982. {
  983. @@ -85,6 +117,11 @@
  984. {
  985. if (unlikely (in_error))
  986. return false;
  987. + if (unlikely (size > max_len))
  988. + {
  989. + in_error = true;
  990. + return false;
  991. + }
  992. unsigned int new_allocated = allocated;
  993. hb_glyph_position_t *new_pos = NULL;
  994. @@ -192,6 +229,7 @@
  995. hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT;
  996. props = default_props;
  997. + scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT;
  998. content_type = HB_BUFFER_CONTENT_TYPE_INVALID;
  999. in_error = false;
  1000. @@ -443,7 +481,7 @@
  1001. {
  1002. unsigned int i, j;
  1003. - if (start == end - 1)
  1004. + if (end - start < 2)
  1005. return;
  1006. for (i = start, j = end - 1; i < j; i++, j--) {
  1007. @@ -454,7 +492,7 @@
  1008. info[j] = t;
  1009. }
  1010. - if (pos) {
  1011. + if (have_positions) {
  1012. for (i = start, j = end - 1; i < j; i++, j--) {
  1013. hb_glyph_position_t t;
  1014. @@ -498,14 +536,10 @@
  1015. }
  1016. void
  1017. -hb_buffer_t::merge_clusters (unsigned int start,
  1018. - unsigned int end)
  1019. +hb_buffer_t::merge_clusters_impl (unsigned int start,
  1020. + unsigned int end)
  1021. {
  1022. -#ifdef HB_NO_MERGE_CLUSTERS
  1023. - return;
  1024. -#endif
  1025. -
  1026. - if (unlikely (end - start < 2))
  1027. + if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS)
  1028. return;
  1029. unsigned int cluster = info[start].cluster;
  1030. @@ -523,7 +557,7 @@
  1031. /* If we hit the start of buffer, continue in out-buffer. */
  1032. if (idx == start)
  1033. - for (unsigned i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--)
  1034. + for (unsigned int i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--)
  1035. out_info[i - 1].cluster = cluster;
  1036. for (unsigned int i = start; i < end; i++)
  1037. @@ -533,9 +567,8 @@
  1038. hb_buffer_t::merge_out_clusters (unsigned int start,
  1039. unsigned int end)
  1040. {
  1041. -#ifdef HB_NO_MERGE_CLUSTERS
  1042. - return;
  1043. -#endif
  1044. + if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS)
  1045. + return;
  1046. if (unlikely (end - start < 2))
  1047. return;
  1048. @@ -555,12 +588,44 @@
  1049. /* If we hit the end of out-buffer, continue in buffer. */
  1050. if (end == out_len)
  1051. - for (unsigned i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++)
  1052. + for (unsigned int i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++)
  1053. info[i].cluster = cluster;
  1054. for (unsigned int i = start; i < end; i++)
  1055. out_info[i].cluster = cluster;
  1056. }
  1057. +void
  1058. +hb_buffer_t::delete_glyph ()
  1059. +{
  1060. + unsigned int cluster = info[idx].cluster;
  1061. + if (idx + 1 < len && cluster == info[idx + 1].cluster)
  1062. + {
  1063. + /* Cluster survives; do nothing. */
  1064. + goto done;
  1065. + }
  1066. +
  1067. + if (out_len)
  1068. + {
  1069. + /* Merge cluster backward. */
  1070. + if (cluster < out_info[out_len - 1].cluster)
  1071. + {
  1072. + unsigned int old_cluster = out_info[out_len - 1].cluster;
  1073. + for (unsigned i = out_len; i && out_info[i - 1].cluster == old_cluster; i--)
  1074. + out_info[i - 1].cluster = cluster;
  1075. + }
  1076. + goto done;
  1077. + }
  1078. +
  1079. + if (idx + 1 < len)
  1080. + {
  1081. + /* Merge cluster forward. */
  1082. + merge_clusters (idx, idx + 2);
  1083. + goto done;
  1084. + }
  1085. +
  1086. +done:
  1087. + skip_glyph ();
  1088. +}
  1089. void
  1090. hb_buffer_t::guess_segment_properties (void)
  1091. @@ -667,11 +732,16 @@
  1092. /**
  1093. * hb_buffer_create: (Xconstructor)
  1094. *
  1095. - *
  1096. + * Creates a new #hb_buffer_t with all properties to defaults.
  1097. *
  1098. - * Return value: (transfer full)
  1099. + * Return value: (transfer full):
  1100. + * A newly allocated #hb_buffer_t with a reference count of 1. The initial
  1101. + * reference count should be released with hb_buffer_destroy() when you are done
  1102. + * using the #hb_buffer_t. This function never returns %NULL. If memory cannot
  1103. + * be allocated, a special #hb_buffer_t object will be returned on which
  1104. + * hb_buffer_allocation_successful() returns %false.
  1105. *
  1106. - * Since: 1.0
  1107. + * Since: 0.9.2
  1108. **/
  1109. hb_buffer_t *
  1110. hb_buffer_create (void)
  1111. @@ -681,6 +751,8 @@
  1112. if (!(buffer = hb_object_create<hb_buffer_t> ()))
  1113. return hb_buffer_get_empty ();
  1114. + buffer->max_len = HB_BUFFER_MAX_LEN_DEFAULT;
  1115. +
  1116. buffer->reset ();
  1117. return buffer;
  1118. @@ -693,7 +765,7 @@
  1119. *
  1120. * Return value: (transfer full):
  1121. *
  1122. - * Since: 1.0
  1123. + * Since: 0.9.2
  1124. **/
  1125. hb_buffer_t *
  1126. hb_buffer_get_empty (void)
  1127. @@ -703,7 +775,10 @@
  1128. const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil),
  1129. HB_BUFFER_FLAG_DEFAULT,
  1130. + HB_BUFFER_CLUSTER_LEVEL_DEFAULT,
  1131. HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT,
  1132. + HB_BUFFER_SCRATCH_FLAG_DEFAULT,
  1133. + HB_BUFFER_MAX_LEN_DEFAULT,
  1134. HB_BUFFER_CONTENT_TYPE_INVALID,
  1135. HB_SEGMENT_PROPERTIES_DEFAULT,
  1136. @@ -719,13 +794,15 @@
  1137. /**
  1138. * hb_buffer_reference: (skip)
  1139. - * @buffer: a buffer.
  1140. + * @buffer: an #hb_buffer_t.
  1141. *
  1142. - *
  1143. + * Increases the reference count on @buffer by one. This prevents @buffer from
  1144. + * being destroyed until a matching call to hb_buffer_destroy() is made.
  1145. *
  1146. * Return value: (transfer full):
  1147. + * The referenced #hb_buffer_t.
  1148. *
  1149. - * Since: 1.0
  1150. + * Since: 0.9.2
  1151. **/
  1152. hb_buffer_t *
  1153. hb_buffer_reference (hb_buffer_t *buffer)
  1154. @@ -735,11 +812,13 @@
  1155. /**
  1156. * hb_buffer_destroy: (skip)
  1157. - * @buffer: a buffer.
  1158. + * @buffer: an #hb_buffer_t.
  1159. *
  1160. - *
  1161. + * Deallocate the @buffer.
  1162. + * Decreases the reference count on @buffer by one. If the result is zero, then
  1163. + * @buffer and all associated resources are freed. See hb_buffer_reference().
  1164. *
  1165. - * Since: 1.0
  1166. + * Since: 0.9.2
  1167. **/
  1168. void
  1169. hb_buffer_destroy (hb_buffer_t *buffer)
  1170. @@ -750,13 +829,15 @@
  1171. free (buffer->info);
  1172. free (buffer->pos);
  1173. + if (buffer->message_destroy)
  1174. + buffer->message_destroy (buffer->message_data);
  1175. free (buffer);
  1176. }
  1177. /**
  1178. * hb_buffer_set_user_data: (skip)
  1179. - * @buffer: a buffer.
  1180. + * @buffer: an #hb_buffer_t.
  1181. * @key:
  1182. * @data:
  1183. * @destroy:
  1184. @@ -766,7 +847,7 @@
  1185. *
  1186. * Return value:
  1187. *
  1188. - * Since: 1.0
  1189. + * Since: 0.9.2
  1190. **/
  1191. hb_bool_t
  1192. hb_buffer_set_user_data (hb_buffer_t *buffer,
  1193. @@ -780,14 +861,14 @@
  1194. /**
  1195. * hb_buffer_get_user_data: (skip)
  1196. - * @buffer: a buffer.
  1197. + * @buffer: an #hb_buffer_t.
  1198. * @key:
  1199. *
  1200. *
  1201. *
  1202. * Return value:
  1203. *
  1204. - * Since: 1.0
  1205. + * Since: 0.9.2
  1206. **/
  1207. void *
  1208. hb_buffer_get_user_data (hb_buffer_t *buffer,
  1209. @@ -799,12 +880,13 @@
  1210. /**
  1211. * hb_buffer_set_content_type:
  1212. - * @buffer: a buffer.
  1213. - * @content_type:
  1214. + * @buffer: an #hb_buffer_t.
  1215. + * @content_type: the type of buffer contents to set
  1216. *
  1217. - *
  1218. + * Sets the type of @buffer contents, buffers are either empty, contain
  1219. + * characters (before shaping) or glyphs (the result of shaping).
  1220. *
  1221. - * Since: 1.0
  1222. + * Since: 0.9.5
  1223. **/
  1224. void
  1225. hb_buffer_set_content_type (hb_buffer_t *buffer,
  1226. @@ -815,13 +897,14 @@
  1227. /**
  1228. * hb_buffer_get_content_type:
  1229. - * @buffer: a buffer.
  1230. + * @buffer: an #hb_buffer_t.
  1231. *
  1232. - *
  1233. + * see hb_buffer_set_content_type().
  1234. *
  1235. - * Return value:
  1236. + * Return value:
  1237. + * The type of @buffer contents.
  1238. *
  1239. - * Since: 1.0
  1240. + * Since: 0.9.5
  1241. **/
  1242. hb_buffer_content_type_t
  1243. hb_buffer_get_content_type (hb_buffer_t *buffer)
  1244. @@ -832,12 +915,12 @@
  1245. /**
  1246. * hb_buffer_set_unicode_funcs:
  1247. - * @buffer: a buffer.
  1248. + * @buffer: an #hb_buffer_t.
  1249. * @unicode_funcs:
  1250. *
  1251. *
  1252. *
  1253. - * Since: 1.0
  1254. + * Since: 0.9.2
  1255. **/
  1256. void
  1257. hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
  1258. @@ -857,13 +940,13 @@
  1259. /**
  1260. * hb_buffer_get_unicode_funcs:
  1261. - * @buffer: a buffer.
  1262. + * @buffer: an #hb_buffer_t.
  1263. *
  1264. *
  1265. *
  1266. * Return value:
  1267. *
  1268. - * Since: 1.0
  1269. + * Since: 0.9.2
  1270. **/
  1271. hb_unicode_funcs_t *
  1272. hb_buffer_get_unicode_funcs (hb_buffer_t *buffer)
  1273. @@ -873,12 +956,18 @@
  1274. /**
  1275. * hb_buffer_set_direction:
  1276. - * @buffer: a buffer.
  1277. - * @direction:
  1278. + * @buffer: an #hb_buffer_t.
  1279. + * @direction: the #hb_direction_t of the @buffer
  1280. *
  1281. - *
  1282. + * Set the text flow direction of the buffer. No shaping can happen without
  1283. + * setting @buffer direction, and it controls the visual direction for the
  1284. + * output glyphs; for RTL direction the glyphs will be reversed. Many layout
  1285. + * features depend on the proper setting of the direction, for example,
  1286. + * reversing RTL text before shaping, then shaping with LTR direction is not
  1287. + * the same as keeping the text in logical order and shaping with RTL
  1288. + * direction.
  1289. *
  1290. - * Since: 1.0
  1291. + * Since: 0.9.2
  1292. **/
  1293. void
  1294. hb_buffer_set_direction (hb_buffer_t *buffer,
  1295. @@ -893,13 +982,14 @@
  1296. /**
  1297. * hb_buffer_get_direction:
  1298. - * @buffer: a buffer.
  1299. + * @buffer: an #hb_buffer_t.
  1300. *
  1301. - *
  1302. + * See hb_buffer_set_direction()
  1303. *
  1304. - * Return value:
  1305. + * Return value:
  1306. + * The direction of the @buffer.
  1307. *
  1308. - * Since: 1.0
  1309. + * Since: 0.9.2
  1310. **/
  1311. hb_direction_t
  1312. hb_buffer_get_direction (hb_buffer_t *buffer)
  1313. @@ -909,12 +999,20 @@
  1314. /**
  1315. * hb_buffer_set_script:
  1316. - * @buffer: a buffer.
  1317. - * @script:
  1318. + * @buffer: an #hb_buffer_t.
  1319. + * @script: an #hb_script_t to set.
  1320. *
  1321. - *
  1322. + * Sets the script of @buffer to @script.
  1323. *
  1324. - * Since: 1.0
  1325. + * Script is crucial for choosing the proper shaping behaviour for scripts that
  1326. + * require it (e.g. Arabic) and the which OpenType features defined in the font
  1327. + * to be applied.
  1328. + *
  1329. + * You can pass one of the predefined #hb_script_t values, or use
  1330. + * hb_script_from_string() or hb_script_from_iso15924_tag() to get the
  1331. + * corresponding script from an ISO 15924 script tag.
  1332. + *
  1333. + * Since: 0.9.2
  1334. **/
  1335. void
  1336. hb_buffer_set_script (hb_buffer_t *buffer,
  1337. @@ -928,13 +1026,14 @@
  1338. /**
  1339. * hb_buffer_get_script:
  1340. - * @buffer: a buffer.
  1341. + * @buffer: an #hb_buffer_t.
  1342. *
  1343. - *
  1344. + * See hb_buffer_set_script().
  1345. *
  1346. - * Return value:
  1347. + * Return value:
  1348. + * The #hb_script_t of the @buffer.
  1349. *
  1350. - * Since: 1.0
  1351. + * Since: 0.9.2
  1352. **/
  1353. hb_script_t
  1354. hb_buffer_get_script (hb_buffer_t *buffer)
  1355. @@ -944,12 +1043,20 @@
  1356. /**
  1357. * hb_buffer_set_language:
  1358. - * @buffer: a buffer.
  1359. - * @language:
  1360. + * @buffer: an #hb_buffer_t.
  1361. + * @language: an hb_language_t to set.
  1362. *
  1363. - *
  1364. + * Sets the language of @buffer to @language.
  1365. + *
  1366. + * Languages are crucial for selecting which OpenType feature to apply to the
  1367. + * buffer which can result in applying language-specific behaviour. Languages
  1368. + * are orthogonal to the scripts, and though they are related, they are
  1369. + * different concepts and should not be confused with each other.
  1370. + *
  1371. + * Use hb_language_from_string() to convert from ISO 639 language codes to
  1372. + * #hb_language_t.
  1373. *
  1374. - * Since: 1.0
  1375. + * Since: 0.9.2
  1376. **/
  1377. void
  1378. hb_buffer_set_language (hb_buffer_t *buffer,
  1379. @@ -963,13 +1070,14 @@
  1380. /**
  1381. * hb_buffer_get_language:
  1382. - * @buffer: a buffer.
  1383. + * @buffer: an #hb_buffer_t.
  1384. *
  1385. - *
  1386. + * See hb_buffer_set_language().
  1387. *
  1388. - * Return value:
  1389. + * Return value: (transfer none):
  1390. + * The #hb_language_t of the buffer. Must not be freed by the caller.
  1391. *
  1392. - * Since: 1.0
  1393. + * Since: 0.9.2
  1394. **/
  1395. hb_language_t
  1396. hb_buffer_get_language (hb_buffer_t *buffer)
  1397. @@ -979,12 +1087,14 @@
  1398. /**
  1399. * hb_buffer_set_segment_properties:
  1400. - * @buffer: a buffer.
  1401. - * @props:
  1402. + * @buffer: an #hb_buffer_t.
  1403. + * @props: an #hb_segment_properties_t to use.
  1404. *
  1405. - *
  1406. + * Sets the segment properties of the buffer, a shortcut for calling
  1407. + * hb_buffer_set_direction(), hb_buffer_set_script() and
  1408. + * hb_buffer_set_language() individually.
  1409. *
  1410. - * Since: 1.0
  1411. + * Since: 0.9.7
  1412. **/
  1413. void
  1414. hb_buffer_set_segment_properties (hb_buffer_t *buffer,
  1415. @@ -998,12 +1108,12 @@
  1416. /**
  1417. * hb_buffer_get_segment_properties:
  1418. - * @buffer: a buffer.
  1419. - * @props:
  1420. + * @buffer: an #hb_buffer_t.
  1421. + * @props: (out): the output #hb_segment_properties_t.
  1422. *
  1423. - *
  1424. + * Sets @props to the #hb_segment_properties_t of @buffer.
  1425. *
  1426. - * Since: 1.0
  1427. + * Since: 0.9.7
  1428. **/
  1429. void
  1430. hb_buffer_get_segment_properties (hb_buffer_t *buffer,
  1431. @@ -1015,12 +1125,12 @@
  1432. /**
  1433. * hb_buffer_set_flags:
  1434. - * @buffer: a buffer.
  1435. - * @flags:
  1436. + * @buffer: an #hb_buffer_t.
  1437. + * @flags: the buffer flags to set.
  1438. *
  1439. - *
  1440. + * Sets @buffer flags to @flags. See #hb_buffer_flags_t.
  1441. *
  1442. - * Since: 1.0
  1443. + * Since: 0.9.7
  1444. **/
  1445. void
  1446. hb_buffer_set_flags (hb_buffer_t *buffer,
  1447. @@ -1034,13 +1144,14 @@
  1448. /**
  1449. * hb_buffer_get_flags:
  1450. - * @buffer: a buffer.
  1451. + * @buffer: an #hb_buffer_t.
  1452. *
  1453. - *
  1454. + * See hb_buffer_set_flags().
  1455. *
  1456. * Return value:
  1457. + * The @buffer flags.
  1458. *
  1459. - * Since: 1.0
  1460. + * Since: 0.9.7
  1461. **/
  1462. hb_buffer_flags_t
  1463. hb_buffer_get_flags (hb_buffer_t *buffer)
  1464. @@ -1048,15 +1159,53 @@
  1465. return buffer->flags;
  1466. }
  1467. +/**
  1468. + * hb_buffer_set_cluster_level:
  1469. + * @buffer: an #hb_buffer_t.
  1470. + * @cluster_level:
  1471. + *
  1472. + *
  1473. + *
  1474. + * Since: 0.9.42
  1475. + **/
  1476. +void
  1477. +hb_buffer_set_cluster_level (hb_buffer_t *buffer,
  1478. + hb_buffer_cluster_level_t cluster_level)
  1479. +{
  1480. + if (unlikely (hb_object_is_inert (buffer)))
  1481. + return;
  1482. +
  1483. + buffer->cluster_level = cluster_level;
  1484. +}
  1485. +
  1486. +/**
  1487. + * hb_buffer_get_cluster_level:
  1488. + * @buffer: an #hb_buffer_t.
  1489. + *
  1490. + *
  1491. + *
  1492. + * Return value:
  1493. + *
  1494. + * Since: 0.9.42
  1495. + **/
  1496. +hb_buffer_cluster_level_t
  1497. +hb_buffer_get_cluster_level (hb_buffer_t *buffer)
  1498. +{
  1499. + return buffer->cluster_level;
  1500. +}
  1501. +
  1502. /**
  1503. * hb_buffer_set_replacement_codepoint:
  1504. - * @buffer: a buffer.
  1505. - * @replacement:
  1506. + * @buffer: an #hb_buffer_t.
  1507. + * @replacement: the replacement #hb_codepoint_t
  1508. *
  1509. - *
  1510. + * Sets the #hb_codepoint_t that replaces invalid entries for a given encoding
  1511. + * when adding text to @buffer.
  1512. *
  1513. - * Since: 1.0
  1514. + * Default is %HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT.
  1515. + *
  1516. + * Since: 0.9.31
  1517. **/
  1518. void
  1519. hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,
  1520. @@ -1070,13 +1219,14 @@
  1521. /**
  1522. * hb_buffer_get_replacement_codepoint:
  1523. - * @buffer: a buffer.
  1524. + * @buffer: an #hb_buffer_t.
  1525. *
  1526. - *
  1527. + * See hb_buffer_set_replacement_codepoint().
  1528. *
  1529. * Return value:
  1530. + * The @buffer replacement #hb_codepoint_t.
  1531. *
  1532. - * Since: 1.0
  1533. + * Since: 0.9.31
  1534. **/
  1535. hb_codepoint_t
  1536. hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer)
  1537. @@ -1087,11 +1237,12 @@
  1538. /**
  1539. * hb_buffer_reset:
  1540. - * @buffer: a buffer.
  1541. + * @buffer: an #hb_buffer_t.
  1542. *
  1543. - *
  1544. + * Resets the buffer to its initial status, as if it was just newly created
  1545. + * with hb_buffer_create().
  1546. *
  1547. - * Since: 1.0
  1548. + * Since: 0.9.2
  1549. **/
  1550. void
  1551. hb_buffer_reset (hb_buffer_t *buffer)
  1552. @@ -1101,11 +1252,12 @@
  1553. /**
  1554. * hb_buffer_clear_contents:
  1555. - * @buffer: a buffer.
  1556. + * @buffer: an #hb_buffer_t.
  1557. *
  1558. - *
  1559. + * Similar to hb_buffer_reset(), but does not clear the Unicode functions and
  1560. + * the replacement code point.
  1561. *
  1562. - * Since: 1.0
  1563. + * Since: 0.9.11
  1564. **/
  1565. void
  1566. hb_buffer_clear_contents (hb_buffer_t *buffer)
  1567. @@ -1115,14 +1267,15 @@
  1568. /**
  1569. * hb_buffer_pre_allocate:
  1570. - * @buffer: a buffer.
  1571. - * @size:
  1572. + * @buffer: an #hb_buffer_t.
  1573. + * @size: number of items to pre allocate.
  1574. *
  1575. - *
  1576. + * Pre allocates memory for @buffer to fit at least @size number of items.
  1577. *
  1578. - * Return value:
  1579. + * Return value:
  1580. + * %true if @buffer memory allocation succeeded, %false otherwise.
  1581. *
  1582. - * Since: 1.0
  1583. + * Since: 0.9.2
  1584. **/
  1585. hb_bool_t
  1586. hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size)
  1587. @@ -1132,13 +1285,14 @@
  1588. /**
  1589. * hb_buffer_allocation_successful:
  1590. - * @buffer: a buffer.
  1591. + * @buffer: an #hb_buffer_t.
  1592. *
  1593. - *
  1594. + * Check if allocating memory for the buffer succeeded.
  1595. *
  1596. - * Return value:
  1597. + * Return value:
  1598. + * %true if @buffer memory allocation succeeded, %false otherwise.
  1599. *
  1600. - * Since: 1.0
  1601. + * Since: 0.9.2
  1602. **/
  1603. hb_bool_t
  1604. hb_buffer_allocation_successful (hb_buffer_t *buffer)
  1605. @@ -1148,13 +1302,20 @@
  1606. /**
  1607. * hb_buffer_add:
  1608. - * @buffer: a buffer.
  1609. - * @codepoint:
  1610. - * @cluster:
  1611. + * @buffer: an #hb_buffer_t.
  1612. + * @codepoint: a Unicode code point.
  1613. + * @cluster: the cluster value of @codepoint.
  1614. + *
  1615. + * Appends a character with the Unicode value of @codepoint to @buffer, and
  1616. + * gives it the initial cluster value of @cluster. Clusters can be any thing
  1617. + * the client wants, they are usually used to refer to the index of the
  1618. + * character in the input text stream and are output in
  1619. + * #hb_glyph_info_t.cluster field.
  1620. *
  1621. - *
  1622. + * This function does not check the validity of @codepoint, it is up to the
  1623. + * caller to ensure it is a valid Unicode code point.
  1624. *
  1625. - * Since: 1.0
  1626. + * Since: 0.9.7
  1627. **/
  1628. void
  1629. hb_buffer_add (hb_buffer_t *buffer,
  1630. @@ -1167,14 +1328,16 @@
  1631. /**
  1632. * hb_buffer_set_length:
  1633. - * @buffer: a buffer.
  1634. - * @length:
  1635. + * @buffer: an #hb_buffer_t.
  1636. + * @length: the new length of @buffer.
  1637. *
  1638. - *
  1639. + * Similar to hb_buffer_pre_allocate(), but clears any new items added at the
  1640. + * end.
  1641. *
  1642. * Return value:
  1643. + * %true if @buffer memory allocation succeeded, %false otherwise.
  1644. *
  1645. - * Since: 1.0
  1646. + * Since: 0.9.2
  1647. **/
  1648. hb_bool_t
  1649. hb_buffer_set_length (hb_buffer_t *buffer,
  1650. @@ -1207,13 +1370,15 @@
  1651. /**
  1652. * hb_buffer_get_length:
  1653. - * @buffer: a buffer.
  1654. + * @buffer: an #hb_buffer_t.
  1655. *
  1656. * Returns the number of items in the buffer.
  1657. *
  1658. - * Return value: buffer length.
  1659. + * Return value:
  1660. + * The @buffer length.
  1661. + * The value valid as long as buffer has not been modified.
  1662. *
  1663. - * Since: 1.0
  1664. + * Since: 0.9.2
  1665. **/
  1666. unsigned int
  1667. hb_buffer_get_length (hb_buffer_t *buffer)
  1668. @@ -1223,15 +1388,17 @@
  1669. /**
  1670. * hb_buffer_get_glyph_infos:
  1671. - * @buffer: a buffer.
  1672. + * @buffer: an #hb_buffer_t.
  1673. * @length: (out): output array length.
  1674. *
  1675. - * Returns buffer glyph information array. Returned pointer
  1676. - * is valid as long as buffer contents are not modified.
  1677. + * Returns @buffer glyph information array. Returned pointer
  1678. + * is valid as long as @buffer contents are not modified.
  1679. *
  1680. - * Return value: (transfer none) (array length=length): buffer glyph information array.
  1681. + * Return value: (transfer none) (array length=length):
  1682. + * The @buffer glyph information array.
  1683. + * The value valid as long as buffer has not been modified.
  1684. *
  1685. - * Since: 1.0
  1686. + * Since: 0.9.2
  1687. **/
  1688. hb_glyph_info_t *
  1689. hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
  1690. @@ -1245,15 +1412,17 @@
  1691. /**
  1692. * hb_buffer_get_glyph_positions:
  1693. - * @buffer: a buffer.
  1694. + * @buffer: an #hb_buffer_t.
  1695. * @length: (out): output length.
  1696. *
  1697. - * Returns buffer glyph position array. Returned pointer
  1698. - * is valid as long as buffer contents are not modified.
  1699. + * Returns @buffer glyph position array. Returned pointer
  1700. + * is valid as long as @buffer contents are not modified.
  1701. *
  1702. - * Return value: (transfer none) (array length=length): buffer glyph position array.
  1703. + * Return value: (transfer none) (array length=length):
  1704. + * The @buffer glyph position array.
  1705. + * The value valid as long as buffer has not been modified.
  1706. *
  1707. - * Since: 1.0
  1708. + * Since: 0.9.2
  1709. **/
  1710. hb_glyph_position_t *
  1711. hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
  1712. @@ -1270,11 +1439,11 @@
  1713. /**
  1714. * hb_buffer_reverse:
  1715. - * @buffer: a buffer.
  1716. + * @buffer: an #hb_buffer_t.
  1717. *
  1718. * Reverses buffer contents.
  1719. *
  1720. - * Since: 1.0
  1721. + * Since: 0.9.2
  1722. **/
  1723. void
  1724. hb_buffer_reverse (hb_buffer_t *buffer)
  1725. @@ -1283,14 +1452,31 @@
  1726. }
  1727. /**
  1728. + * hb_buffer_reverse_range:
  1729. + * @buffer: an #hb_buffer_t.
  1730. + * @start: start index.
  1731. + * @end: end index.
  1732. + *
  1733. + * Reverses buffer contents between start to end.
  1734. + *
  1735. + * Since: 0.9.41
  1736. + **/
  1737. +void
  1738. +hb_buffer_reverse_range (hb_buffer_t *buffer,
  1739. + unsigned int start, unsigned int end)
  1740. +{
  1741. + buffer->reverse_range (start, end);
  1742. +}
  1743. +
  1744. +/**
  1745. * hb_buffer_reverse_clusters:
  1746. -