Rank: Advanced Member
Groups: Guest
Joined: 10/12/2015(UTC) Posts: 44
|
I'm using the Font.MeasureString to get the metrics of custom TTFs. Here's the code I'm using: Code:
public static Size GetFontSize(string textToMeasure) {
using (var bitmap = new Bitmap(100, 100, PixelFormat.Format32bppArgb, RgbColor.Blue))
using (var graphics = bitmap.GetAdvancedGraphics())
using (var customFont = new CustomFontRegistry()) {
bitmap.DpiX = 96;
bitmap.DpiY = 96;
customFont.Add(@"C:\Users\blind\Desktop\3062.ttf");
graphics.FontRegistry = customFont;
var font = graphics.CreateFont(customFont.Fonts[0].PostscriptName, 50);
var size = font.MeasureString(textToMeasure);
return new Size() {
Height = Convert.ToInt32(size.Height),
Width = Convert.ToInt32(size.Width)
};
}
}
When I use the character ":" my debug session ends and my CPU goes to 100%. Now I've looked into this font, and it appears that it doesn't contain that specific character. Our users upload their own fonts, so I can't just ignore this issue, is there a way for me to determine that the character doesn't exist in the TTF? I'd be OK with your SDK throwing an error and me trapping it, or if you returned Null or a size of 0....but it just goes haywire. Any suggestions? 3062.zip (9kb) downloaded 7 time(s).
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Quote:When I use the character ":" my debug session ends and my CPU goes to 100%. Now I've looked into this font, and it appears that it doesn't contain that specific character. We successfully reproduced the problem of 100% CPU usage and will fix it shortly (Aurigma Bug #0023431). I will keep you informed of the status. Quote:Our users upload their own fonts, so I can't just ignore this issue, is there a way for me to determine that the character doesn't exist in the TTF? We support font fallback, but unfortunately it is not possible to check whether a character is implemented in a font. We plan to implement this functionality in the further releases (Aurigma Bug #0022479). Code:customFont.Add("3062.ttf");
customFont.Add("ARIALUNI.TTF");
customFont.FallbackFonts.Add("Arial Unicode MS");
Edited by user Thursday, June 15, 2017 11:11:58 AM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
The bug #0023431 was fixed in the version 9.1.20 of SDK |
Best regards, Fedor Skvortsov
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.