I draw text on a canvas and set the font by:
Image3.Canvas.font.name := 'Arial Narrow';
Everything is right on my machine. But on another pc from my client the wrong font (bigger) is printed.
So I installed all Arial Narrow fonts on the clients machine. But I still have the wrong font.
Edit: Font seems to be right, but not scale:
This is the problem
Windows 7 has on its Control Panel, Appearance and Personalization, Display setting, an ability to Magnify the text and other items by 125% or 150%.
Any ideas how to get those settings?
At first you set the size of the image as bitmap,Because before using canvas, bitmap has to be created.
so that bitmap.canvas.font does have a default size,
so later it wont increase its size.So the original font will be produced.
Getting the DPI and adjusting the font size did it for me:
DC := GetDC(HWND_DESKTOP);
try
DPI:=GetDeviceCaps(DC,LOGPIXELSY);
finally
ReleaseDC(DC,HWND_DESKTOP);
end;
Image3.Canvas.font.size := round(myConstant*96/DPI);
Related
I am trying to display the current date in Nepali language. I have declared constant string for the caption. It renders the text pretty fine on windows 8.1 but the same text is displayed too small in windows 7. Adjusting the font size also doesn't help much as it should.
Things I tried
Installed Nepali language pack for windows 7
Installed several Unicode fonts like arial unicode ms, segoe ui, microsoft neo gothic and others
The source code has been saved as UTF-8 encoding
But the problem remains same.
Windows 8.1 output:
Windows 7 output:
There are two labels on the form. One is used to display the current temperature("segoe ui" font) which renders pretty fine on both the windows versions while the other one is used for displaying the date that has the actual problem.
Edit
How to create issue?
create a new vcl form application project
Drop a label and a button
On button click change the caption of the label
sample code
procedure TForm1.Button1Click(Sender: TObject);
const text = 'आइतबार कार्तिक २७ गते २०७२';
begin
Label1.Caption := text;
end;
The font property for label has been set to: #Microsoft NeoGothic,11,[B],ANSI_CHARSET,clWindowText
By the way, this font doesn't exist in windows 7, I installed it and other ones as well but this couldn't help.
SO the question is, "How to display the caption in similar fashion in windows 7"
I have an issue with font height in standard main menu/popup menu when it contains images. Looks like this.
When there are no images, there are no problems as displayed above. Main menu uses TImageList with image width/height set to 16.
So I want to preserve image size at 16x16 and center it, to get something like this:
How can I read the font height of the main menu and adjust images in TImageList accordingly? One idea I have is to copy images from one TImageList to another with larger image width/height but I still need to determine proper size from the font size. How do I do that?
UPDATE
I solved this by examining SystemParametersInfo - SPI_GETNONCLIENTMETRICS value and using the iMenuHeight value for TImageList Width/Height. As images are deleted after changing Width/Height, I copied another to another TImageList. Works exactly as it should. Thank you everyone for your most helpful answers.
UPDATE 2
After examining the problem futher the solution which I marked as correct down there is giving better result so I switched to that one instead. Tested on Win7 and XP, appears to be working properly.
You can get the height of Screen.MenuFont by selecting it to a temporary DC:
function GetMenuFontHeight: Integer;
var
DC: HDC;
SaveObj: HGDIOBJ;
Size: TSize;
begin
DC := GetDC(HWND_DESKTOP);
try
SaveObj := SelectObject(DC, Screen.MenuFont.Handle);
GetTextExtentPoint32(DC, '|', 1, Size); // the character doesn't really matter
Result := Size.cy;
SelectObject(DC, SaveObj);
finally
ReleaseDC(HWND_DESKTOP, DC);
end;
end;
Well, Canvas.GetTextHeight('gh') usually helps to get height of text. But in case of different DPI, you can simply scale by Screen.PixelsPerInch / 96.0.
The text height is probably not what you need to use. I suggest that you use icons whose square dimension is equal to the prevailing small icon size. That's the system metric whose ID is SM_CXSMICON. Retrieve the value by calling GetSystemMetrics passing that ID.
You can use Power Menu Component with many advanced features
Download from here : http://elvand.com/downloads/DELPHI/PowerMenu.zip
Delphi7-XE2
size=193 KB
#include <windows.h>
int GetMainMenuHeight(void)
{
NONCLIENTMETRICS Rec;
Rec.cbSize = sizeof(Rec);
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, Rec.cbSize, &Rec.cbSize, 0))
return Rec.iMenuHeight;
else return -1;
}
I have an issue using Delphi 2007 & TChart 7.0.10.0 or 7.0.11.0 or the latest evaluation 9.0.5.0 on the TChart scaling.
The problem arises as soon I enlarge the window after a certain width and KEEP the Form height!
This is the drawing using a smaller form size.
now if I enlarge to 1200 weight I get this ugly scaling:
If I export in the designer without the aspect ratio set and with 1200 weight you will se this:
How to get ride of this?
Hp
I see you've set top and bottom margins to Chart1 in your project (8 and 20 percent respectively). I guess this has the intention of giving more space (in height) for Chart2 when you resize the form making it bigger.
Chart1's Top and Height properties should be set according to fill this blank space in the Form's OnResize event.
Try this:
procedure TGSSkillgroupStatisticForm.FormResize(Sender: TObject);
begin
Chart1.Draw;
Chart2.Top:=Chart1.ChartRect.Bottom + 25;
Chart2.Height:=Chart1.Height-Chart1.ChartRect.Bottom-40;
end;
Steema Support Central
Keep in mind that I only scale in the x-axis. Your 3-D bar / construct will after a certain width, overlap the scaling numbers! Your given answer do not fix this issue at all. To see the real problem in a better way, I added on the form creation:
Chart2.BottomAxis.Maximum := 20;
Series2.AddBar(12, 'Hallo', clred);
Here the result:
I am currently resizing my Delphi5 application from 800x600 to be scalable up to 1440x1080.
The only thing that still looks too small is the Form Caption and the ShowMessage/MessageDlg text.
Am I right in thinking the ShowMessage text is related to the Windows default size?
Is there any way to increase the Form Caption font size? It doesn't seem connected to the Form font size.
Thanks
The font size of the title bar is handled by windows and is system wide. If you want modify the font or other attibutes you must draw manually the non client area of the form(Windows).
Until Windows XP you can draw directly in the caption(title) bar modifying the font , color and text handling the WM_NCPAINT message, starting with windows vista and the DWM introduction you must use the DwmSetWindowAttribute function with the DWMWA_ALLOW_NCPAINT value in order to use this technique.
I have been adding icons to my mobile control Line Item controls and haven't quite figured out what the preferred size of these icons should be. The CSS has max size settings of 35 by 35px.
The reason I ask this is because the icons don't seem to line up correctly. The CSS positions them at 0 0. If all else fails I may modify CSS and position them to something other than 0 0.
Still interested in hearing how you have dealt with this.
In the teamroom template, the mobile view for Recent Activity has icons that line up with the text. All these images are 16 X 16px.
There will never be 1 fit for all, the layout will be dependant on font size, row height and where you want it to line up. Some people may want it to align in the middle vertically and others will want it to align with the title in the row.
I would say 21px x 21px. but that depends on what font-size you are using.
Icon size can depends upon the applicaton. Normal size is 32x32 and an extended icon size is 64x64. If you want to line up the icons, you might have to change the icons to a standard size.