Autor Beitrag
TomPIII866
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Do 04.09.08 12:14 
Hallo,

und zwar habe ich in meiner Anwendung eine Druck-Funktion integriert.
Ich drucke auf eine Canvas und gebe den Text dort mit TextOut aus.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
      with Printer.Canvas do
        begin
          Font.Name := 'Arial';
          Brush.Color := clWhite;
          Font.Size := -14;
          Font.Style := [fsBold, fsUnderline];
          TextOut(trunc(breite / 100 * 5), trunc(hoehe / 100 * 6), 'Text');
        end;


Soweit so gut.
Jetzt ist meine Frage: Ist es möglich, griechische Buchstaben im fortlaufenden Text auszugeben?
Ist es des Weiteren möglich, hoch- und tiefgestellten Text auszugeben? ² und ³ klappt ja, aber mehr habe ich noch nicht rausgefunden.

Danke für eure Tipps! :)
Tom
TomPIII866 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Do 04.09.08 15:23 
Habe es wie folgt probiert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure druck;
var hoehe, breite : Word;
var l : Integer;
begin
  with Form1 do
    begin
      Printer.Orientation := poLandscape;   //Querformat einstellen
      Printer.BeginDoc;
      Printer.Canvas.TextOut(0, 0, '');
      breite := Printer.Pagewidth;   //Höhe und Breite ermitteln
      hoehe := Printer.PageHeight;
      with Printer.Canvas do
        begin
          Font.Name := 'Arial';
          Brush.Color := clWhite;
          Font.Size := -10;
          Font.Style := [];
          SetTextAlign(Handle, TA_LEFT + TA_TOP);
          TextOut(trunc(breite / 100 * 5), trunc(hoehe / 100 * 12), 'Danach ein griechisches Zeichen...');
          l := TextWidth('Danach ein griechisches Zeichen...');
          Font.Name := 'Symbol';
          TextOut(trunc(breite / 100 * 5) + l, trunc(hoehe / 100 * 12), 't');
        end;  
    end;
end;


Ja, nur leider ermittelt er die TextWidth viel zu kurz, sodass das Zeichen inmitten des vorigen Textes geschrieben wird. :(
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Do 04.09.08 16:45 
Wo kommt /100*5 her?
TomPIII866 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Do 04.09.08 22:30 
Das breite/100*5 bedeutet, dass der Textanfang (Texteinrückung von links) 5% der verfügbaren Blattbreite betragen soll.
Habe ich so gemacht, dass das Layout auf allen Druckern gleich ist. :)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 05.09.08 06:00 
Mich würd interessieren, warum du Size auf -10 gestellt hast?

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
TomPIII866 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: So 07.09.08 10:00 
Hi!

Size ist auf -10, damit die Schriftgröße auf 10pt festgelegt wird.
Ist das falsch?



Das Problem ist, dass ich ja griechische Zeichen bekomme, aber leider rückt er sie zu wenig ein. Er berechnet sozusagen das "l" falsch. Es ist zu klein.
Hat da einer eine Idee?

Danke! :)
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: So 07.09.08 10:53 
user profile iconTomPIII866 hat folgendes geschrieben:
Hi!

Size ist auf -10, damit die Schriftgröße auf 10pt festgelegt wird.
Ist das falsch?



Das Problem ist, dass ich ja griechische Zeichen bekomme, aber leider rückt er sie zu wenig ein. Er berechnet sozusagen das "l" falsch. Es ist zu klein.
Hat da einer eine Idee?

Danke! :)


1. Größe 10 ist Size = 10. Allerdings ist dann Punkt 0 oben links. So wie du es hast, ist er unten links.
2. Er berechnet es nicht falsch, sondern es liegt daran, dass du zwei verschiedene Schriftarten verwendest, ist halt bei jeder Schriftart anders. Am besten probierst du mal eine paar Werte aus, als zusätzliche Einrückung, und berechnest dann, welcher Anteil das auf die Schriftgröße bezogen ist.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 07.09.08 12:37 
Mach mal Size +10 und probiers nochmal.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
TomPIII866 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: So 07.09.08 18:46 
Ihr seid einfach göttlich! :-)

Mit positiven Schriftgrößen klappt es! :-)