Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: third_party/harfbuzz/src/harfbuzz-thai.c

Issue 384503008: Delete third_party/harfbuzz (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove public header Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
25 #include "harfbuzz-shaper.h"
26 #include "harfbuzz-shaper-private.h"
27 #include "harfbuzz-external.h"
28
29 #include <assert.h>
30
31 static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri butes *attributes)
32 {
33 typedef int (*th_brk_def)(const char*, int[], int);
34 static void *thaiCodec = 0;
35 static th_brk_def th_brk = 0;
36 char *cstr = 0;
37 int brp[128];
38 int *break_positions = brp;
39 hb_uint32 numbreaks;
40 hb_uint32 i;
41
42 if (!thaiCodec)
43 thaiCodec = HB_TextCodecForMib(2259);
44
45 /* load libthai dynamically */
46 if (!th_brk && thaiCodec) {
47 th_brk = (th_brk_def)HB_Library_Resolve("thai", "th_brk");
48 if (!th_brk)
49 thaiCodec = 0;
50 }
51
52 if (!th_brk)
53 return;
54
55 cstr = HB_TextCodec_ConvertFromUnicode(thaiCodec, string, len, 0);
56 if (!cstr)
57 return;
58
59 break_positions = brp;
60 numbreaks = th_brk(cstr, break_positions, 128);
61 if (numbreaks > 128) {
62 break_positions = (int *)malloc(numbreaks * sizeof(int));
63 numbreaks = th_brk(cstr, break_positions, numbreaks);
64 }
65
66 for (i = 0; i < len; ++i)
67 attributes[i].lineBreakType = HB_NoBreak;
68
69 for (i = 0; i < numbreaks; ++i) {
70 if (break_positions[i] > 0)
71 attributes[break_positions[i]-1].lineBreakType = HB_Break;
72 }
73
74 if (break_positions != brp)
75 free(break_positions);
76
77 HB_TextCodec_FreeResult(cstr);
78 }
79
80
81 void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)
82 {
83 assert(script == HB_Script_Thai);
84 attributes += from;
85 thaiWordBreaks(text + from, len, attributes);
86 }
87
OLDNEW
« no previous file with comments | « third_party/harfbuzz/src/harfbuzz-stream-private.h ('k') | third_party/harfbuzz/src/harfbuzz-tibetan.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698