Показать сообщение отдельно
Старый 31.08.2009, 12:50   #2
abcdef
Знающий
 
Регистрация: 16.09.2008
Сообщений: 299
Написано 71 полезных сообщений
(для 123 пользователей)
Ответ: алгоритмы j2me для рисованного интерфейса

Аналогичный алгоритм собственного шрифта размер 5x6 (русификация моя), занимающий массив integer (32 bit) всего из 256 элементов.

Образы шрифтов загружены с http://www.ticalc.org/archives/files...260/26014.html и где-то отсюда: http://www.menuetos.net/

В архиве найденные шрифты в текстовом формате и моя программа для конвертирования в массив longInt (32 bit) на TurboPascal7.1

p.s.: выкладывайте если улучшите отображение символов, заранее спасибо!
//Raster font 5x6.
//programming by arT (c). e-mail: [email protected]
//
//Пример создания и работы с собственным растровым шрифтом в MidletPascal
//каждый символ занимает 30 bit (число типа integer). Оставшиеся 2 bit'а  (0011 bin = 04 dec) + 1
//можно использовать под ширину символа, если делать не моноширинный шрифт
//
//Используемые подпрограммы:
//procedure text(x,y : integer; s : string); - вывод текста "s" в позиции "x,y"
//function win2utf(s : string) : string; - конвертироание из win в utf8 кодировку
//function utf2win(s : string) : string; - конвертироание из utf8 в win кодировку
var
  f : array[0..255] of integer; //битовый образ шрифта 0..255,5x6
  s : string;
  c : char;
  i,j,k,h,w : integer;
  bool : boolean;


procedure text(x,y : integer; s : string);
// вывод шрифта 5x6 из битового образа f[0..255]
var
  c,i,len : integer;
begin
  len:=length(s)-1;
  for i:=0 to len do
  begin
    c:=f[ord(getChar(s,i)) and 255];
    if ((c and 536870912)<>0)  then plot(x,y);
    if ((c and 268435456)<>0)  then plot(x+1,y);
    if ((c and 134217728)<>0)  then plot(x+2,y);
    if ((c and 67108864)<>0)   then plot(x+3,y);
    if ((c and 33554432)<>0)   then plot(x+4,y);
    y:=y+1;
    if ((c and 16777216)<>0)   then plot(x,y);
    if ((c and 8388608)<>0)    then plot(x+1,y);
    if ((c and 4194304)<>0)    then plot(x+2,y);
    if ((c and 2097152)<>0)    then plot(x+3,y);
    if ((c and 1048576)<>0)    then plot(x+4,y);
    y:=y+1;
    if ((c and 524288)<>0)     then plot(x,y);
    if ((c and 262144)<>0)     then plot(x+1,y);
    if ((c and 131072)<>0)     then plot(x+2,y);
    if ((c and 65536)<>0)      then plot(x+3,y);
    if ((c and 32768)<>0)      then plot(x+4,y);
    y:=y+1;
    if ((c and 16384)<>0)      then plot(x,y);
    if ((c and 8192)<>0)       then plot(x+1,y);
    if ((c and 4096)<>0)       then plot(x+2,y);
    if ((c and 2048)<>0)       then plot(x+3,y);
    if ((c and 1024)<>0)       then plot(x+4,y);
    y:=y+1;
    if ((c and 512)<>0)        then plot(x,y);
    if ((c and 256)<>0)        then plot(x+1,y);
    if ((c and 128)<>0)        then plot(x+2,y);
    if ((c and 64)<>0)         then plot(x+3,y);
    if ((c and 32)<>0)         then plot(x+4,y);
    y:=y+1;
    if ((c and 16)<>0)         then plot(x,y);
    if ((c and 8)<>0)          then plot(x+1,y);
    if ((c and 4)<>0)          then plot(x+2,y);
    if ((c and 2)<>0)          then plot(x+3,y);
    if ((c and 1)<>0)          then plot(x+4,y);
    y:=y-5;
    x:=x+5;
  end;
end;


function win2utf(s : string) : string;
var  {rus_ansi to unicode}
  i,c : integer;
begin
  for i:=length(s)-1 downto 0 do
  begin
    c:=ord(getChar(s,i)) and 255;
    if (c>=192) then  s:=setChar(s,chr(c+848),i);
    if (c=168)  then  s:=setChar(s,chr($0401),i); {Ё}
    if (c=184)  then  s:=setChar(s,chr($0451),i); {ё}
  end;
  win2utf := s;
end;


function utf2win(s : string) : string;
var
  i,c : integer;
begin
  for i:=length(s)-1 downto 0 do
  begin
    c:=ord(getChar(s,i));
    if (c>255)   then  s:=setChar(s,chr(c-848),i);
    if (c=$0401) then  s:=setChar(s,chr(168),i); {Ё}
    if (c=$0451) then  s:=setChar(s,chr(184),i); {ё}
  end;
  utf2win := s;
end;


begin
  s:='0,33408703,33226623,29342148,4685252,15579278,15710350,473088,33081343,0,0,4477576,9053064,0,12921670,22506965,8796552,2308290,4657604,10823690,32319818,4665796,1023,4657631,4657284,4329924,97344,294144,556032,359744,146400,1030272,0,8658952,10813440,21976020,149297604,10625344,14825920,8650752,4464900,8523912,10627072,145536,132,458752,128,2232584,4532548,12718212,12652814,12652620,10827842,14954572,4469060,14749832,6623564,4528204,4100,131204,2236546,14694400,8521864,12652548,13195790,6633802,12923212,6562054,12921164,12857612,12857608,6564166,10828106,14815374,14832268,10826058,8659214,32467538,19749458,13191756,12923144,4532614,12923210,6557772,14815364,10824006,10823812,19491806,10817866,10817668,14749966,12853516,17309828,12718220,270976,14,8519680,414348,17584776,139524,4608652,291340,4469000,13250712,17584788,4198532,4198536,17457812,4329604,555986,807572,283272,25842448,13259140,401672,401548,8790276,676492,676104,617436,664212,21635344,397580,4481284,4329604,17051920,14016,0,0,0,136,12874000,660,672,9314568,9315208,9043968,27930967,281551000,16896,15358606,4539716,15400622,11191620,149935246,17301504,17301504,21626880,21626880,25344,448,992,448512,12582912,403054732,16896,351887,70424,9064724,20992648,0,16794128,4673988,6582558,17967249,21898120,17302032,428484812,350499086,15259182,13250560,21120,900,24576,15259182,29360128,9052160,9315200,8937472,25452544,8912896,21648272,15558986,16384,2585100,17301504,9052188,21120,19542358,19542358,28193238,8397324,6633802,14954828,12923212,14950664,15018993,14954766,22723253,12660812,19487570,153705298,10826058,6629722,30370386,10828106,13191756,15018314,12923144,6562054,14815364,10817672,15390148,10817866,10824130,10827842,22730720,22730721,25442638,18413245,8665422,29440092,24835767,6625610,414348,942748,17592984,467208,207313,487948,703157,464972,613202,4807506,680596,207194,555986,676756,283272,938644,938896,139524,462980,676112,4675012,664212,676740,684164,710624,710625,801102,587453,276814,931932,784055,207050,';
  j:=0;
  for i:=0 to 255 do
  begin
    bool:=false;
    repeat
      c:=getChar(s,j);
      if (c='-') then bool:=true;
      j:=j+1;
    until (c>='0') and (c<='9');
    k:=0;
    repeat
      k:=k*10+(ord(c)-ord('0'));
      c:=getChar(s,j);
      j:=j+1;
    until (c<'0') or (c>'9');
    if bool=true then k:=-k;
    f[i]:=k;
  end;
  w:=getWidth;
  h:=getHeight;
  setColor(0,0,0);
  fillRect(0,0,w,h);
  setColor(0,255,0);
  text(0,0,utf2win('Small font 5x6 by arT(c)'));
  text(0,7,utf2win('e-mail: [email protected]'));
  setColor(0,255,255);
  text(0,13,utf2win('Привет мир!'));
  repaint;
  repeat delay(1000); until false;
end.
Вложения
Тип файла: zip smallfont.jar.zip (20.2 Кб, 572 просмотров)

Последний раз редактировалось abcdef, 31.08.2009 в 14:41.
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
Phantom (31.08.2009)