/[qemacs]/qemacs/unicode_join.c
ViewVC logotype

Diff of /qemacs/unicode_join.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by chqrlie, Wed May 4 19:27:36 2005 UTC revision 1.4 by chqrlie, Wed May 11 12:04:30 2005 UTC
# Line 47  static unsigned short *read_array_be16(F Line 47  static unsigned short *read_array_be16(F
47      tab = malloc(n * sizeof(unsigned short));      tab = malloc(n * sizeof(unsigned short));
48      if (!tab)      if (!tab)
49          return NULL;          return NULL;
50      for(i=0;i<n;i++) {      for (i = 0; i < n; i++) {
51          tab[i] = uni_get_be16(f);          tab[i] = uni_get_be16(f);
52      }      }
53      return tab;      return tab;
# Line 56  static unsigned short *read_array_be16(F Line 56  static unsigned short *read_array_be16(F
56  void load_ligatures(void)  void load_ligatures(void)
57  {  {
58      FILE *f;      FILE *f;
59        char filename[MAX_FILENAME_SIZE];
60      unsigned char buf[1024];      unsigned char buf[1024];
61      int long_count;      int long_count;
62    
63      if (find_resource_file(buf, sizeof(buf), "ligatures") < 0)      if (find_resource_file(filename, sizeof(filename), "ligatures") < 0)
64          return;          return;
65    
66      f = fopen(buf, "r");      f = fopen(filename, "r");
67      if (!f)      if (!f)
68          return;          return;
69      if (fread(buf, 1, 4, f) != 4 ||      if (fread(buf, 1, 4, f) != 4 ||
# Line 128  static int unicode_ligature(unsigned int Line 129  static int unicode_ligature(unsigned int
129      memcpy(buf, buf_out, len * sizeof(int));      memcpy(buf, buf_out, len * sizeof(int));
130    
131      q = buf_out;      q = buf_out;
132      for(i=0;i<len;) {      for (i = 0; i < len;) {
133          l1 = buf[i];          l1 = buf[i];
134          /* eliminate invisible chars */          /* eliminate invisible chars */
135          if (l1 >= 0x202a && l1 <= 0x202e) {          if (l1 >= 0x202a && l1 <= 0x202e) {
# Line 155  static int unicode_ligature(unsigned int Line 156  static int unicode_ligature(unsigned int
156          } else {          } else {
157              /* generic case : use ligature_long[] table */              /* generic case : use ligature_long[] table */
158              lig = ligature_long;              lig = ligature_long;
159              for(;;) {              for (;;) {
160                  len1 = *lig++;                  len1 = *lig++;
161                  if (len1 == 0)                  if (len1 == 0)
162                      break;                      break;
163                  len2 = *lig++;                  len2 = *lig++;
164                  if (i + len1 <= len) {                  if (i + len1 <= len) {
165                      for(j=0;j<len1;j++) {                      for (j = 0; j < len1; j++) {
166                          if (buf[i+j] != lig[j])                          if (buf[i+j] != lig[j])
167                              goto notfound;                              goto notfound;
168                      }                      }
169                      for(j=0;j<len1;j++)                      for (j = 0; j < len1; j++)
170                          pos_L_to_V[i + j] = q - buf_out;                          pos_L_to_V[i + j] = q - buf_out;
171                      for(j=0;j<len2;j++) {                      for (j = 0; j < len2; j++) {
172                          *q++ = lig[len1 + j];                          *q++ = lig[len1 + j];
173                      }                      }
174                      i += len1;                      i += len1;
# Line 198  static int unicode_classify(unsigned int Line 199  static int unicode_classify(unsigned int
199      int i, mask, c;      int i, mask, c;
200    
201      mask = 0;      mask = 0;
202      for(i=0;i<len;i++) {      for (i = 0; i < len; i++) {
203          c = buf[i];          c = buf[i];
204          if (c <= 0x7f) /* latin1 fast handling */          if (c <= 0x7f) /* latin1 fast handling */
205              continue;              continue;
# Line 216  static int unicode_classify(unsigned int Line 217  static int unicode_classify(unsigned int
217  static void compose_char_to_glyph(unsigned int *ctog, int len, unsigned *ctog1)  static void compose_char_to_glyph(unsigned int *ctog, int len, unsigned *ctog1)
218  {  {
219      int i;      int i;
220      for(i=0;i<len;i++)      for (i = 0; i < len; i++)
221          ctog[i] = ctog1[ctog[i]];          ctog[i] = ctog1[ctog[i]];
222  }  }
223    
# Line 225  static void bidi_reverse_buf(unsigned in Line 226  static void bidi_reverse_buf(unsigned in
226      int i, len2 = len / 2;      int i, len2 = len / 2;
227            
228      for (i = 0; i < len2; i++) {      for (i = 0; i < len2; i++) {
229          unsigned int tmp = str[i];          unsigned int tmp = str[i];
230          str[i] = fribidi_get_mirror_char(str[len - 1 - i]);          str[i] = fribidi_get_mirror_char(str[len - 1 - i]);
231          str[len - 1 - i] = fribidi_get_mirror_char(tmp);          str[len - 1 - i] = fribidi_get_mirror_char(tmp);
232      }      }
233      /* do not forget central char ! */      /* do not forget central char ! */
234      if (len & 1) {      if (len & 1) {
# Line 243  static void bidi_reverse_buf(unsigned in Line 244  static void bidi_reverse_buf(unsigned in
244     buffer. */     buffer. */
245  int unicode_to_glyphs(unsigned int *dst, unsigned int *char_to_glyph_pos,  int unicode_to_glyphs(unsigned int *dst, unsigned int *char_to_glyph_pos,
246                        int dst_size, unsigned int *src, int src_size,                        int dst_size, unsigned int *src, int src_size,
247                        int reverse)                        int reverse)
248  {  {
249      int len, i;      int len, i;
250      unsigned int ctog[src_size];      unsigned int ctog[src_size];
# Line 290  int unicode_to_glyphs(unsigned int *dst, Line 291  int unicode_to_glyphs(unsigned int *dst,
291    
292          if (reverse) {          if (reverse) {
293              bidi_reverse_buf(buf, len);              bidi_reverse_buf(buf, len);
294              for(i=0;i<src_size;i++) {              for (i = 0; i < src_size; i++) {
295                  ctog[i] = len - 1 - ctog[i];                  ctog[i] = len - 1 - ctog[i];
296              }              }
297          }          }
# Line 325  int unicode_to_glyphs(unsigned int *dst, Line 326  int unicode_to_glyphs(unsigned int *dst,
326          len = dst_size;          len = dst_size;
327      memcpy(dst, src, len * sizeof(unsigned int));      memcpy(dst, src, len * sizeof(unsigned int));
328      if (char_to_glyph_pos) {      if (char_to_glyph_pos) {
329          for(i=0;i<len;i++)          for (i = 0; i < len; i++)
330              char_to_glyph_pos[i] = i;              char_to_glyph_pos[i] = i;
331      }      }
332      return len;      return len;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26