Autor Beitrag
DrRzf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mi 03.01.07 16:04 
Ich benutze eine TBitmap für eine Textvorschau.
Der Text wird hier farbig und mit fontstyles dargestellt.
Sobald ich aber den Fontstyle auf [fsItalic] einstelle, tritt ein Darstellungsfehler auf.
Alle Buchstaben des Textes überlagern sich, und sind nicht mehr lesbar.
Zur veranschaulichung hab ich 2 Screenshots hochgeladen.
Der erste Zeigt den Text normal, der zweite zeigt den gleichen Text kursiv an.
Weis jemand wie man das beheben kann ?
Einloggen, um Attachments anzusehen!
_________________
rein statistisch gesehen darf man keiner statistik trauen die man nicht selbst gefälscht hat.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mi 03.01.07 16:36 
Da stimmt was mit der Zeichenbreite nicht. Kann es sein, dass du die Zeichen einzeln auf Bitmaps malst und dann zusammenkopierst? Sollte dem so sein, dann passt was mit der Breite dieser Bitmaps nicht.

Wie zeichnest du denn das jetzt? Ohne das zu wissen, kann ich nichts weiter sagen.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
DrRzf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mi 03.01.07 17:17 
Hier mal der komplette source der Zeichenroutine.
Die ganzen CBSSxxx sind CheckBoxen um den fontstyle auszuwählen.
Im Stringarray befinden sich die aufgesplitteten strings die in dieser prozedure wieder mit den Farbinformationen
aus dem FarbArray zu einer zeile zusammengesetzt werden.
Ausgabe auf der Bitmap erfolgt dabei direkt mit
Canvas.TextOut(ZPos,LPos,str);

Dank deinem Hinweis mit der Zeichenbreite weis ich jetzt auch das das irgendwie damit zusammenhängt.
denn wenn ich einen string kursiv mit Textout ausgebe ist die überlagerung weg.
Kann es villeicht sein dass die function TextWidth bei kursiver darstellung falsche werte zurückliefert ?


ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
procedure TForm1.DrawVorschau;
var
  z,s,i,ZPos,LPos : integer;
  used : boolean;
  str : string;
begin
  with ImageVorschau do
    begin
    //schriftstyles festlegen
    Canvas.Font.Size := 8;
    if CBSSh.Checked then Canvas.Font.Size := 12;
    if CBSShbig.Checked then Canvas.Font.Size := 16;
    Canvas.Font.Style := [];
    if CBSSb.Checked then Canvas.Font.Style := [fsBold];
    if CBSSi.Checked then Canvas.Font.Style := Canvas.Font.Style + [fsItalic];
    if CBSSu.Checked then Canvas.Font.Style := Canvas.Font.Style + [fsUnderline];
    if CBSSs.Checked then Canvas.Font.Style := Canvas.Font.Style + [fsStrikeOut];

    //schwarzes fenster zeichnen
    Canvas.Brush.Color := clBlack;
    Canvas.FillRect(Rect(0,0,497,209));

    //ausgabe des textes
    LPos := 5;
    for z := 1 to 31 do
      begin
      used := false;
      str := '';
      for s := 1 to 31 do //ist in der zeile was ?
        if StringArray[s,z] <> '' then
          begin
          used := true;
          str := str + StringArray[s,z];
          end;

      if used then
        begin
        ZPos := 5;
        for i := 1 to Length(str) do
          if str[i] = '_' then str[i] := ' ';
        if Ausrichtung = 1 then //[center]
          ZPos :=  497 div 2 - Canvas.TextWidth(str) div 2;
        if Ausrichtung = 2 then //[right]
          ZPos :=  497 - Canvas.TextWidth(str) - 5;
        for s := 1 to 31 do
          begin
          if StringArray[s,z] <> '' then
          Canvas.Font.Color := Farbarray[s,z];
          str := StringArray[s,z];
          for i := 1 to Length(str) do
            if str[i] = '_' then str[i] := ' ';
          Canvas.TextOut(ZPos,LPos,str);
          ZPos := ZPos +  Canvas.TextWidth(str);
          end;
        LPos := LPos + Canvas.TextHeight('A');
        end;
      end;
    end; //end with ImageVorschau do
end;

_________________
rein statistisch gesehen darf man keiner statistik trauen die man nicht selbst gefälscht hat.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mi 03.01.07 17:25 
Ich habs jetzt nicht getestet, aber versuch mal in Zeile 22 ein Canvas.Brush.Style:= bsClear; einzubauen. Im Moment hat ja jedes Zeichen eine schwarzen Hintergrund, und übermalt damit die überhängenden Teile des Zeichens vorher.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
DrRzf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mi 03.01.07 17:36 
Danke für den Tip.
Canvas.Brush.Style:= bsClear; in zeile 22 funktioniert.

Ich hatte das zwar auch schon versucht, aber ein paar zeilen vorher, bevor das schwarze fenster gezeichnet wird.

_________________
rein statistisch gesehen darf man keiner statistik trauen die man nicht selbst gefälscht hat.