Google Groups Home
Help | Sign in
sprawdzanie istnienia czcionki
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Maciej Litwiniuk  
View profile
 More options Dec 1 2006, 7:33 am
Newsgroups: alt.pl.comp.lang.csharp
From: "Maciej Litwiniuk" <mlitwin...@gmail.com>
Date: 1 Dec 2006 04:33:01 -0800
Local: Fri, Dec 1 2006 7:33 am
Subject: sprawdzanie istnienia czcionki
Witam szanowne grono!

W pisanej obecnie aplikacji zaistniała potrzeba sprawdzenia istnienia
(specyficznej) czcionki przy każdym uruchomieniu. Oczywiście można
to robić iterując po liście czcionek w systemie, jednak takie
rozwiązanie jest bardzo czasochłonne, gdy w systemie istnieje sporo
(>500) zainstalowanych czcionek. Zastanawiam się więc, czy istnieje
jakaś sprytniejsza metoda sprawdzająca niż poniższa:
private bool FontExists(string name)
{
        for (int i = 0; i <= System.Drawing.FontFamily.Families.Length - 1;
i++)
        {
                if (System.Drawing.FontFamily.Families[i].Name == name)
                {
                        return true;
                }
        }
        return false;

}

Z góry dziękuję za wszelkie sugestie bądź rozwiązania.

Pozdrawiam,
Maciej Litwiniuk


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wiktor Zychla  
View profile
 More options Dec 1 2006, 8:35 am
Newsgroups: alt.pl.comp.lang.csharp
From: "Wiktor Zychla" <u...@nospam.com.eu>
Date: Fri, 1 Dec 2006 14:35:45 +0100
Local: Fri, Dec 1 2006 8:35 am
Subject: Re: sprawdzanie istnienia czcionki

> Z góry dziękuję za wszelkie sugestie bądź rozwiązania.

wykorzystałbym cechę systemu, który dla nazwy czcionki sam dobiera jej
odpowiednik, jesli dana czcionka nie istniejesze:

bool FontExists( string FontName )

{

    using ( Font f = new Font( FontName, 12 ) )

        return f.Name == FontName;

}

MessageBox.Show( FontExists( "Courier New" ).ToString() );

MessageBox.Show( FontExists( "qwe" ).ToString() );

MessageBox.Show( FontExists( "Tahoma" ).ToString() );

daje mi:

True

False

True

Wiktor Zychla


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google