From: Andreas H. <ah...@us...> - 2004-01-10 19:23:31
|
Update of /cvsroot/jvcl/dev/JVCL3/common In directory sc8-pr-cvs1:/tmp/cvs-serv19718/common Modified Files: QWindows.pas Log Message: Improved GetTextMetrics function Index: QWindows.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/common/QWindows.pas,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** QWindows.pas 10 Jan 2004 15:18:39 -0000 1.22 --- QWindows.pas 10 Jan 2004 19:23:28 -0000 1.23 *************** *** 307,327 **** end; tagTEXTMETRICA = record - { supported by QFontMetrics } tmHeight: Longint; tmAscent: Longint; tmDescent: Longint; ! (* unsupported: ! tmItalic: Byte; ! tmUnderlined: Byte; ! tmStruckOut: Byte; ! tmPitchAndFamily: Byte; ! tmCharSet: Byte; ! tmWeight: Longint; ! tmInternalLeading: Longint; tmExternalLeading: Longint; tmAveCharWidth: Longint; tmMaxCharWidth: Longint; ! tmOverhang: Longint; tmDigitizedAspectX: Longint; tmDigitizedAspectY: Longint; --- 307,328 ---- end; + const + DEFAULT_PITCH = 0; + FIXED_PITCH = 1; + VARIABLE_PITCH = 2; + + DEFAULT_CHARSET = 1; + + type tagTEXTMETRICA = record tmHeight: Longint; tmAscent: Longint; tmDescent: Longint; ! //tmInternalLeading: Longint; // not supported tmExternalLeading: Longint; tmAveCharWidth: Longint; tmMaxCharWidth: Longint; ! tmWeight: Longint; ! //tmOverhang: Longint; // not supported tmDigitizedAspectX: Longint; tmDigitizedAspectY: Longint; *************** *** 330,334 **** tmDefaultChar: AnsiChar; tmBreakChar: AnsiChar; ! *) end; TTextMetric = tagTEXTMETRICA; --- 331,339 ---- tmDefaultChar: AnsiChar; tmBreakChar: AnsiChar; ! tmItalic: Byte; ! tmUnderlined: Byte; ! tmStruckOut: Byte; ! tmPitchAndFamily: Byte; ! tmCharSet: Byte; end; TTextMetric = tagTEXTMETRICA; *************** *** 783,787 **** { (very) limited implementations of } function GetDeviceCaps(Handle: QPainterH; devcap: TDeviceCap): Integer; ! function GetTextMetrics(Handle: QPainterH; tt: TTextMetric): Integer; type --- 788,792 ---- { (very) limited implementations of } function GetDeviceCaps(Handle: QPainterH; devcap: TDeviceCap): Integer; ! function GetTextMetrics(Handle: QPainterH; var tt: TTextMetric): Integer; type *************** *** 3457,3470 **** { a very limited implementation of } ! function GetTextMetrics(Handle: QPainterH; tt: TTextMetric): Integer; var ! tm: QFontMetricsH; begin ! QPainter_fontMetrics(Handle, @tm); with tt do begin ! tmHeight := QFontMetrics_height(tm); ! tmAscent := QFontMetrics_ascent(tm); ! tmDescent := QFontMetrics_descent(tm); end; Result := 0; --- 3462,3511 ---- { a very limited implementation of } ! function GetTextMetrics(Handle: QPainterH; var tt: TTextMetric): Integer; var ! fm: QFontMetricsH; ! fi: QFontInfoH; begin ! QPainter_fontMetrics(Handle, @fm); with tt do begin ! tmHeight := QFontMetrics_height(fm); ! tmAscent := QFontMetrics_ascent(fm); ! tmDescent := QFontMetrics_descent(fm); ! tmAveCharWidth := QFontMetrics_width(fm, 'x'); ! tmMaxCharWidth := QFontMetrics_maxWidth(fm); ! //tmInternalLeading := 0; ! tmExternalLeading := QFontMetrics_leading(fm); ! //tmOverhang := 0; ! ! fi := QFontInfo_create(QPainter_font(Handle)); ! try ! QPainter_fontInfo(Handle, fi); ! case QFontInfo_weight(fi) of ! 25: // Light ! tmWeight := 300; ! 50: // Normal: ! tmWeight := 400; ! 63: // DemiBold ! tmWeight := 600; ! 75: // Bold ! tmWeight := 700; ! 87: // Black ! tmWeight := 900; ! else ! tmWeight := Round(QFontInfo_weight(fi) * 9.5); ! end; ! ! tmItalic := Ord(QFontInfo_italic(fi)); ! tmUnderlined := Ord(QFontInfo_underline(fi)); ! tmStruckOut := Ord(QFontInfo_strikeOut(fi)); ! if QFontInfo_fixedPitch(fi) then ! tmPitchAndFamily := FIXED_PITCH ! else ! tmPitchAndFamily := VARIABLE_PITCH; ! tmCharSet := DEFAULT_CHARSET; ! finally ! QFontInfo_destroy(fi); ! end; end; Result := 0; *************** *** 5052,5059 **** end else // limited implementation - begin Result := True; - QPainter_restore(Handle); - end; end; --- 5093,5097 ---- |