예제 #1
0
파일: libshapes.c 프로젝트: ajstarks/openvg
// Text renders a string of text at a specified location, size, using the specified font glyphs
// derived from http://web.archive.org/web/20070808195131/http://developer.hybrid.fi/font2openvg/renderFont.cpp.txt
void Text(VGfloat x, VGfloat y, const char *s, Fontinfo f, int pointsize) {
	VGfloat size = (VGfloat) pointsize, xx = x, mm[9];
	vgGetMatrix(mm);
	int character;
	unsigned char *ss = (unsigned char *)s;
	while ((ss = next_utf8_char(ss, &character)) != NULL) {
		int glyph = f.CharacterMap[character];
		if (character >= MAXFONTPATH-1) {
			continue;
		}
		if (glyph == -1) {
			continue;			   //glyph is undefined
		}
		VGfloat mat[9] = {
			size, 0.0f, 0.0f,
			0.0f, size, 0.0f,
			xx, y, 1.0f
		};
		vgLoadMatrix(mm);
		vgMultMatrix(mat);
		vgDrawPath(f.Glyphs[glyph], VG_FILL_PATH);
		xx += size * f.GlyphAdvances[glyph] / 65536.0f;
	}
	vgLoadMatrix(mm);
}
예제 #2
0
파일: keyboard.c 프로젝트: whot/weston
static void
delete_before_cursor(struct virtual_keyboard *keyboard)
{
	const char *start, *end;

	if (!keyboard->surrounding_text) {
		fprintf(stderr, "delete_before_cursor: No surrounding text available\n");
		return;
	}

	start = prev_utf8_char(keyboard->surrounding_text,
			       keyboard->surrounding_text + keyboard->surrounding_cursor);
	if (!start) {
		fprintf(stderr, "delete_before_cursor: No previous character to delete\n");
		return;
	}

	end = next_utf8_char(start);

	wl_input_method_context_delete_surrounding_text(keyboard->context,
							(start - keyboard->surrounding_text) - keyboard->surrounding_cursor,
							end - start);
	wl_input_method_context_commit_string(keyboard->context,
					      keyboard->serial,
					      "");

	/* Update surrounding text */
	keyboard->surrounding_cursor = start - keyboard->surrounding_text;
	keyboard->surrounding_text[keyboard->surrounding_cursor] = '\0';
	if (*end)
		memmove(keyboard->surrounding_text + keyboard->surrounding_cursor, end, strlen(end));
}
예제 #3
0
파일: libshapes.c 프로젝트: ajstarks/openvg
// TextWidth returns the width of a text string at the specified font and size.
VGfloat TextWidth(const char *s, Fontinfo f, int pointsize) {
	VGfloat tw = 0.0;
	VGfloat size = (VGfloat) pointsize;
	int character;
	unsigned char *ss = (unsigned char *)s;
	while ((ss = next_utf8_char(ss, &character)) != NULL) {
		int glyph = f.CharacterMap[character];
		if (character >= MAXFONTPATH-1) {
			continue;
		}
		if (glyph == -1) {
			continue;			   //glyph is undefined
		}
		tw += size * f.GlyphAdvances[glyph] / 65536.0f;
	}
	return tw;
}
예제 #4
0
파일: yujson.c 프로젝트: eientei/yukkipaste
int escape_json_string(YUString *out, char *in, size_t len) {
  unsigned char *p;
  unsigned char *oldp;
  unsigned char *end;
  int skiplen;
  uint32_t unichar;

  p = (unsigned char*)in;
  end = p + len;

  while (p != end) {
    unichar = next_utf8_char((char*)p,(char*)end,&skiplen);
    if (skiplen == 0) {
      yu_string_sprintfa(out, "\\u%04x",*p++);
      continue;
    }

    oldp = p;
    p += skiplen;
    switch (unichar) {
      case  ' ': yu_string_append0(out,  " "); continue;
      case '\b': yu_string_append0(out,"\\b"); continue;
      case '\f': yu_string_append0(out,"\\f"); continue;
      case '\n': yu_string_append0(out,"\\n"); continue;
      case '\r': yu_string_append0(out,"\\r"); continue;
      case '\t': yu_string_append0(out,"\\t"); continue;
      case '\v': yu_string_append0(out,"\\v"); continue;
      case  '"': yu_string_append0(out,"\\\"");continue;
      case '\\': yu_string_append0(out,"\\\\");continue;
    }
    if (unichar < 32) {
      yu_string_sprintfa(out, "\\u%04x",unichar);
      continue;
    }
    yu_string_append(out,(char*)oldp,(size_t)skiplen);
  }

  return 0;
}